solid-client icon indicating copy to clipboard operation
solid-client copied to clipboard

addPermission() is undefined on the response from createContainer()

Open AMWJ opened this issue 9 years ago • 4 comments

  1. Call createContainer().
  2. On the promise returned, call a function with the returned data available in the parameter.

This parameter will not have a method addPermission

AMWJ avatar Nov 21 '16 04:11 AMWJ

Hi Ariel, thanks for opening the issue!

The current API for what you're describing (let's say, creating a container called notes and setting a "public read" permission on it) would be something like:

client.createContainer('notes')
  .then(response => {
    return client.getPermissions(response.url)
  })
  .then(acls => {
    return acls
      .addPermission(solid.acl.EVERYONE, solid.acl.READ)
      // other .addPermission calls here
      .save()
  })
  .then(response => {
    // permissions modified.
  })

Is your proposal here to add methods to the SolidResponse class that would enable you to call response.addPermission() directly, without having to getPermissions() beforehand?

dmitrizagidulin avatar Nov 21 '16 16:11 dmitrizagidulin

@deiu indicated lacking this feature was a bug, although I may have misunderstood.

Incidentally, I tried following the flow you described, but getPermissions didn't succeed in finding the acl files for the newly created container.

AMWJ avatar Nov 21 '16 17:11 AMWJ

Ah, right, so, since one has just created the container, there wouldn't be a permission file for it.

We should probably make this series of steps easier on the developer. And implement a convenience factory method, so you could do something like:

client.createContainer('notes')
  .then(response => {
    return response.newAcl()
      .addPermission(solid.acl.EVERYONE, solid.acl.READ)
      // other .addPermission calls here
      .save()
  })
  .then(response => {
    // permissions modified.
  })

dmitrizagidulin avatar Nov 21 '16 17:11 dmitrizagidulin

OK, so this depends on PR #129 being merged. Stand by.

dmitrizagidulin avatar Nov 22 '16 19:11 dmitrizagidulin