kinto.js
kinto.js copied to clipboard
Update record permissions not documented
Apparently possible via options in updateRecord()
Hello, can I get a detailed explanation as to this?
The updateRecord() method can take permissions as input:
https://github.com/Kinto/kinto.js/blob/d68724e66b0e71f6479686dbd7182deaa64de878/src/http/collection.ts#L539
But the documentation does not mention it : https://github.com/Kinto/kinto.js/blob/master/docs/api.md#updating-a-record
The
updateRecord()method can take permissions as input:https://github.com/Kinto/kinto.js/blob/d68724e66b0e71f6479686dbd7182deaa64de878/src/http/collection.ts#L539
But the documentation does not mention it : https://github.com/Kinto/kinto.js/blob/master/docs/api.md#updating-a-record
Hi Lepstream, seems you opened the issue and the solution was later found. Looks like it solved.
But the api.md be contributed to, to show the update in the documentation. After carefully analysins it. I arrived at this
Function's handling of permissions.
The updateRecord function does accept permissions as an optional input through the [option] parameter. Here's the relevant type definition from the code:
options: {
// ... other options
permissions?: { [key in Permission]?: string[] };
// ... other options
}
The permissions parameter is:
- Optional (marked with
?) - An object where:
- Keys are of type
Permission(an enum/type not shown in the provided code) - Values are arrays of strings
- Each key-value pair is optional (marked with
?)
The permissions are then:
- Passed through to the
updateRequestfunction:
requests.updateRequest(
path,
{ data: record, permissions }, // permissions passed here
// ... other options
)
- Finally included in the request body by
[updateRequest]
return {
method: patch ? "PATCH" : "PUT",
path,
headers: { ...headers, ...safeHeader(safe, last_modified) },
body: { data, permissions } // permissions included in request body
};
First timer contributor