convergencelabs / convergence-project

The project used for Convergence Project Management and Issue Reporting
https://convergence.io
42 stars 5 forks source link

worldPermissions complains about missing toJSON() #183

Closed toebes closed 4 years ago

toebes commented 4 years ago

Versions

Describe the Bug Starting with example on https://docs.convergence.io/guide/models/model-service.html#opening-model-with-auto-create you encounter a couple of problems

  1. overrideWorld doesn't exist (it should be overrideCollectionWorldPermissions).
  2. The definitions for worldPermissions and "ted" complain about a missing toJSON()

Step To Reproduce Create a typescript file and include the example verbatim.

Expected Behavior Code should compile cleanly...

mmacfadden commented 4 years ago

Issue

I believe there there are two issues here:

1) The documentation is definitely incorrect. We need to update that. 2) The ModelPermissions class has a constructor, but for some reason it is hidden.

https://github.com/convergencelabs/convergence-client-javascript/blob/a7b42c894def1b92d1a9af34272ef7562bdf97b9/src/main/model/ModelPermissions.ts#L37

The constructor does not need to be hidden. I believe we should make it public.

Workaround

For the moment, I think you can use the ModelPermission.fromJSON() method:

https://docs.convergence.io/js-api/classes/real_time_data.modelpermissions.html#fromjson

Proposal

I think we should do two things:

  1. We should make the constructor for the ModelPermission public
  2. I think we should allow the user to pass in a ModelPermission object or a JSON structure to the auto create options. If JSON, we will internally call the fromJSON method to convert it.