@openinc/parse-server-opendash 3.20.1 → 3.20.3

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.
@@ -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,25 +285,24 @@ 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
- await role.save(null, {
293
- useMasterKey: true,
294
- });
295
- }
296
- else {
297
- console.log("--------> Role already exists");
290
+ try {
291
+ await role.save(null, {
292
+ useMasterKey: true,
293
+ });
294
+ }
295
+ catch (error) {
296
+ console.error("--------> Error creating role", error);
297
+ }
298
298
  }
299
299
  let changed = false;
300
300
  if (role.get("label") !== label) {
301
301
  role.set("label", label);
302
- console.log("--------> Updated role label");
303
302
  changed = true;
304
303
  }
305
304
  if (!(0, fast_equals_1.deepEqual)(acl.toJSON(), role.getACL()?.toJSON())) {
306
305
  role.setACL(acl);
307
- console.log("--------> Updated role ACL");
308
306
  changed = true;
309
307
  }
310
308
  if (Array.isArray(childRoles) && childRoles.length > 0) {
@@ -321,12 +319,10 @@ async function ensureRole(name, options) {
321
319
  .equalTo("name", childRoleName)
322
320
  .find({ useMasterKey: true });
323
321
  relation.add(childRole);
324
- console.log("--------> Added child role", childRoleName);
325
322
  changed = true;
326
323
  }
327
324
  }
328
325
  if (changed) {
329
- console.log("--------> Saving role");
330
326
  await role.save(null, { useMasterKey: true });
331
327
  }
332
328
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "3.20.1",
3
+ "version": "3.20.3",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@10.15.0",
6
6
  "keywords": [