@openinc/parse-server-opendash 3.20.2 → 3.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,4 +21,7 @@ export declare namespace Permissions {
21
21
  enum CORE {
22
22
  adminoverview = "opendash:can-access-admin-overview"
23
23
  }
24
+ enum DOCUMENTATION {
25
+ see_app = "documentation:can-see-app"
26
+ }
24
27
  }
@@ -33,6 +33,11 @@ var Permissions;
33
33
  //Access
34
34
  CORE["adminoverview"] = "opendash:can-access-admin-overview";
35
35
  })(CORE = Permissions.CORE || (Permissions.CORE = {}));
36
+ let DOCUMENTATION;
37
+ (function (DOCUMENTATION) {
38
+ //access
39
+ DOCUMENTATION["see_app"] = "documentation:can-see-app";
40
+ })(DOCUMENTATION = Permissions.DOCUMENTATION || (Permissions.DOCUMENTATION = {}));
36
41
  // can also be used for nested permissions
37
42
  // Example:
38
43
  // export namespace TestPlugin {
@@ -46,6 +46,7 @@ async function init() {
46
46
  }
47
47
  dataSource.set("name", object.get("label"));
48
48
  dataSource.set("tag", `tenant-data-${object.id}`);
49
+ dataSource.set("tenant", object);
49
50
  await dataSource.save(null, { useMasterKey: true });
50
51
  object.set("dataSource", dataSource);
51
52
  }
@@ -54,7 +55,6 @@ async function init() {
54
55
  await (0, __1.ensureRole)(`od-tenant-admin-${object.id}`, {
55
56
  label: `${object.get("label")} (Admin)`,
56
57
  });
57
- console.log("--------> Ensured tenant admin role");
58
58
  await (0, __1.ensureRole)(`od-tenant-user-${object.id}`, {
59
59
  label: object.get("label"),
60
60
  acl: new Parse.ACL({
@@ -63,9 +63,7 @@ async function init() {
63
63
  },
64
64
  }),
65
65
  });
66
- console.log("--------> Ensured tenant user role");
67
66
  if (!original) {
68
- console.log("--------> Trigger beforeSave after creation");
69
67
  // trigger beforeSave after creation
70
68
  await object.save(null, {
71
69
  useMasterKey: true,
@@ -9,9 +9,9 @@ async function init() {
9
9
  if (request.user && request.user.get("tenant")) {
10
10
  tenantId = request.user.get("tenant").id;
11
11
  }
12
- //if (!role.get("name") && role.isNew()) {
13
- // role.set("name", crypto.randomUUID());
14
- //}
12
+ if (!role.get("name") && role.isNew()) {
13
+ role.set("name", crypto.randomUUID());
14
+ }
15
15
  //Set ACL to od-tenant-admin-{id_of_tenant}
16
16
  if (role.isNew()) {
17
17
  role.setACL(new Parse.ACL({
package/dist/index.js CHANGED
@@ -275,7 +275,6 @@ async function getConfigBoolean(key) {
275
275
  * @returns A Promise that resolves when the role is successfully created or updated.
276
276
  */
277
277
  async function ensureRole(name, options) {
278
- console.log("--------> Inside ensureRole");
279
278
  const label = options?.label || undefined;
280
279
  const acl = options?.acl || new Parse.ACL();
281
280
  const childRoles = options?.childRoles || undefined;
@@ -286,10 +285,8 @@ async function ensureRole(name, options) {
286
285
  .equalTo("name", name)
287
286
  .first({ useMasterKey: true });
288
287
  if (!role) {
289
- console.log("--------> Creating role");
290
288
  role = new Parse.Role(name, acl);
291
289
  role.set("label", label);
292
- console.log("--------> CREATING role ", name);
293
290
  try {
294
291
  await role.save(null, {
295
292
  useMasterKey: true,
@@ -298,20 +295,14 @@ async function ensureRole(name, options) {
298
295
  catch (error) {
299
296
  console.error("--------> Error creating role", error);
300
297
  }
301
- console.log("--------> NEW Role created");
302
- }
303
- else {
304
- console.log("--------> Role already exists");
305
298
  }
306
299
  let changed = false;
307
300
  if (role.get("label") !== label) {
308
301
  role.set("label", label);
309
- console.log("--------> Updated role label");
310
302
  changed = true;
311
303
  }
312
304
  if (!(0, fast_equals_1.deepEqual)(acl.toJSON(), role.getACL()?.toJSON())) {
313
305
  role.setACL(acl);
314
- console.log("--------> Updated role ACL");
315
306
  changed = true;
316
307
  }
317
308
  if (Array.isArray(childRoles) && childRoles.length > 0) {
@@ -328,15 +319,12 @@ async function ensureRole(name, options) {
328
319
  .equalTo("name", childRoleName)
329
320
  .find({ useMasterKey: true });
330
321
  relation.add(childRole);
331
- console.log("--------> Added child role", childRoleName);
332
322
  changed = true;
333
323
  }
334
324
  }
335
325
  if (changed) {
336
- console.log("--------> Saving changed role");
337
326
  await role.save(null, { useMasterKey: true });
338
327
  }
339
- console.log("--------> Exiting ensureRole");
340
328
  }
341
329
  /**
342
330
  * Ensures that a user has a specific role.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "3.20.2",
3
+ "version": "3.20.4",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@10.15.0",
6
6
  "keywords": [