kinto.js icon indicating copy to clipboard operation
kinto.js copied to clipboard

Update record permissions not documented

Open leplatrem opened this issue 9 years ago • 3 comments

Apparently possible via options in updateRecord()

leplatrem avatar Oct 11 '16 14:10 leplatrem

Hello, can I get a detailed explanation as to this?

Olamarx avatar Oct 12 '24 14:10 Olamarx

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

leplatrem avatar Oct 14 '24 09:10 leplatrem

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:

  1. Optional (marked with ?)
  2. 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:

  1. Passed through to the updateRequest function:
requests.updateRequest(
  path,
  { data: record, permissions }, // permissions passed here
  // ... other options
)
  1. 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

devhenode avatar Dec 26 '24 16:12 devhenode