-
Notifications
You must be signed in to change notification settings - Fork 189
[preview] dataset api #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
} | ||
} | ||
|
||
module.exports = getUser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any benefit to including code versus just parsing using a jwt library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I looked for modules I wasn't aware that browserify does some polyfilling, so I was trying to find something that was node + browser. The client side libs for this I found are way overkill for what ends up being incredibly straightforward code. I see no reason to bring in a dependency to do this.
Looks pretty good: general question: is it a covered usecase for one user to pull/push from another user's datasets? Right now this assumes that token=user, but will that assumption continue to be true? |
* // } | ||
* }); | ||
*/ | ||
Datasets.prototype.bulkFeatureUpdate = function(put, deletes, dataset, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be puts
to match the plural of deletes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll work this in. I want to make sure that the names of the variables here match the properties of the response object returned from the API.
About other people's datasets: I don't believe that it is currently possible, but it is something that we want to make possible. Datasets' ids make this a little bit clumsy. URLs are like:
In the context of requesting your own dataset, you configure the SDK with your access token, and so you only need to provide the Where a dataset id is required to make a request, a method in this lib looks like datasets.readFeature = function(featureid, datasetid, callback) {
// GET /datasets/v1/:user-from-token/:datasetid/feature/:featureid?access_token=:token
}; Even though it is honest, I kinda don't want to change this to datasets.readFeature = function(featureid, owner, datasetid, callback) {}; ... because much of the time the owner will be you and feel redundant. What if instead, add logic to each function that takes a dataset id: var owner;
var id;
if (datasetid.split('/').length > 1) {
owner = datasetid.split('/')[0];
id = datasetid.split('/')[1];
} else {
owner = this.user; // was determined via access token
id = datasetid;
} |
* // "id": {dataset id}, | ||
* // "name": {dataset name}, | ||
* // "description": {dataset description}, | ||
* // "created": {timestamp}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to defer this to another conversation, but I'm curious if you have thought about documenting return types/properties with documentationjs. By using placeholders in this "example", we miss an opertunity to communicate specifics about types or return formats - like the fact that the created
property is a ISO formatted string.
Ideally:
- return types would be thoroughly documented
- examples would be pure examples and show real looking values - not place holders
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upstream in JSDoc, there's no support for documenting parts of return values like you can document parts of params. See previous discussion: documentationjs/documentation#127
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 100% with you on the ideal case here. But @returns
just isn't the right place to put this. What you really want to do is document the @param {Function} callback
, which is a part of JSDoc that seems kinda clumsy and isn't supported in documentationjs.
I do think this is something we ought to elevate to the shortlist in documentationjs: documentationjs/documentation#9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rclark do you mean the @callback
tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep @tmcw that's what I was getting at.
invariant(typeof options === 'object', 'options must be an object'); | ||
invariant(!!options.name || !!options.description, 'options must include a name or a description'); | ||
|
||
if (options.name) invariant(typeof options.name === 'string', 'options.name must be a string'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do this type of validation here or let it happen on the server? I could see us making a backward compatible change that removes this requirement.
035c8d5
to
2a4c154
Compare
I'm happy with this for now. Aside from the cross-owner dataset access thing which I'd like to punt on until we're more clear on how we'll implement it, I think that I hit all the issues that you guys spotted. Good to merge @tmcw @willwhite? |
👍 yep! |
step on it 👍 |
make_service.js
.gitignore
coverage outputsAdditional scopes are needed to pass tests on travis. fixes #7
cc @tmcw @willwhite