@openinc/parse-server-opendash 4.4.1 → 4.4.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.
@@ -23,6 +23,7 @@ async function initServiceSchedulesFeature() {
23
23
  .equalTo("key", ServiceSyncTypes_js_1.OUTLOOK_CONFIG_KEY)
24
24
  .includeAll()
25
25
  .findAll({ useMasterKey: true });
26
+ // TODO: Reenable when infinite loop is found
26
27
  // for (const config of configs) {
27
28
  // pollers.push(new ServiceCalendarSyncPoller(config).start(POLL_INTERVAL_MS));
28
29
  // }
@@ -13,7 +13,20 @@ async function init() {
13
13
  .map((filename) => filename.replace(".js", ""))
14
14
  .filter((name) => regex.test(name));
15
15
  for (const name of fns) {
16
+ // One unusable module must not cost the whole boot. `init` missing is the
17
+ // realistic case — a file whose content is commented out still compiles to
18
+ // a module, and the resulting `init is not a function` used to abort
19
+ // `initFunctions()` and everything the entrypoint runs after it.
16
20
  const { init } = require(`./${name}`);
17
- await init(name).catch((e) => console.error(e));
21
+ if (typeof init !== "function") {
22
+ console.error(`[@openinc/parse-server-opendash] Cloud function "${name}" exports no init() — skipped`);
23
+ continue;
24
+ }
25
+ try {
26
+ await init(name);
27
+ }
28
+ catch (error) {
29
+ console.error(`[@openinc/parse-server-opendash] Cloud function "${name}" failed to initialize:`, error);
30
+ }
18
31
  }
19
32
  }
@@ -18,7 +18,19 @@ async function init() {
18
18
  .map((filename) => filename.replace(".js", "")),
19
19
  ];
20
20
  for (const name of classNames) {
21
+ // A class whose module exports no `init` is skipped rather than allowed to
22
+ // throw: the hooks of every class after it — and every init step after
23
+ // `initHooks()` — would otherwise never be registered.
21
24
  const { init } = require(`./${name}`);
22
- await init().catch((e) => console.error(e));
25
+ if (typeof init !== "function") {
26
+ console.error(`[@openinc/parse-server-opendash] Hook module "${name}" exports no init() — skipped`);
27
+ continue;
28
+ }
29
+ try {
30
+ await init();
31
+ }
32
+ catch (error) {
33
+ console.error(`[@openinc/parse-server-opendash] Hooks for "${name}" failed to initialize:`, error);
34
+ }
23
35
  }
24
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.4.1",
3
+ "version": "4.4.3",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@11.25.0",
6
6
  "keywords": [
@@ -1,79 +0,0 @@
1
- "use strict";
2
- // import Parse from "parse/node";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- // import {
5
- // grantProviderAccess,
6
- // revokeProviderAccess,
7
- // } from "../features/openservice/serviceProviders/index.js";
8
- // import {
9
- // Permissions,
10
- // requirePermission,
11
- // } from "../features/permissions/index.js";
12
- // import { Tenant, type _User } from "../types/index.js";
13
- // /**
14
- // * Grant or revoke an external service provider's access to one maintenance
15
- // * plan.
16
- // *
17
- // * Params: `{ contactId, scheduleId, revoke? }`.
18
- // *
19
- // * **Who may call it.** A logged-in user holding `schedule_create` — the same
20
- // * capability that lets somebody set a plan up in the first place. Creating an
21
- // * account for a stranger and pointing it at a customer's plan is at least as
22
- // * consequential as creating the plan, so it does not get a weaker gate; and
23
- // * `requirePermission` means it is a real gate, not UI that can be walked
24
- // * around by calling the function directly (GRENZEN §2).
25
- // *
26
- // * The tenant comes from the caller's account, never from a parameter.
27
- // */
28
- // export async function init(name: string) {
29
- // Parse.Cloud.define(
30
- // name,
31
- // async (request) => {
32
- // await requirePermission(
33
- // {
34
- // sessionToken: request.user?.getSessionToken(),
35
- // master: request.master,
36
- // },
37
- // Permissions.SERVICE.schedule_create,
38
- // "Granting service provider access requires schedule creation rights.",
39
- // );
40
- // const user = request.user as _User | undefined;
41
- // const tenant = user?.get("tenant") as Tenant | undefined;
42
- // if (!tenant) {
43
- // throw new Parse.Error(
44
- // Parse.Error.OPERATION_FORBIDDEN,
45
- // `${name}: the calling user has no tenant`,
46
- // );
47
- // }
48
- // const { contactId, scheduleId, revoke } = request.params as {
49
- // contactId?: string;
50
- // scheduleId?: string;
51
- // revoke?: boolean;
52
- // };
53
- // if (!contactId || !scheduleId) {
54
- // throw new Parse.Error(
55
- // Parse.Error.INVALID_QUERY,
56
- // `${name} needs "contactId" and "scheduleId"`,
57
- // );
58
- // }
59
- // if (revoke) {
60
- // const result = await revokeProviderAccess(
61
- // tenant,
62
- // contactId,
63
- // scheduleId,
64
- // );
65
- // console.log(
66
- // `[${name}] revoked contact ${contactId} from schedule ${scheduleId}`,
67
- // );
68
- // return result;
69
- // }
70
- // const result = await grantProviderAccess(tenant, contactId, scheduleId);
71
- // console.log(
72
- // `[${name}] granted contact ${contactId} on schedule ${scheduleId} ` +
73
- // `as user ${result.userId}${result.created ? " (new account)" : ""}`,
74
- // );
75
- // return result;
76
- // },
77
- // { requireUser: true },
78
- // );
79
- // }