@openinc/parse-server-opendash 4.24.1 → 4.25.0
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.
- package/dist/features/config/helper/getConfig.js +2 -1
- package/dist/features/config/types/ConfigKeys.js +8 -26
- package/dist/features/openservice/alarms/ticket/AlarmTicketTypes.d.ts +0 -4
- package/dist/features/openservice/alarms/ticket/AlarmTicketTypes.js +1 -5
- package/dist/features/openservice/alarms/ticket/createAlarmTicket.js +6 -5
- package/dist/features/openservice/tickets/ticketAccess.d.ts +40 -0
- package/dist/features/openservice/tickets/ticketAccess.js +105 -0
- package/dist/features/openservice/tickets/ticketCleanup.d.ts +25 -0
- package/dist/features/openservice/tickets/ticketCleanup.js +65 -0
- package/dist/features/openservice/tickets/ticketNotifications.d.ts +2 -0
- package/dist/features/openservice/tickets/ticketNotifications.js +242 -0
- package/dist/features/openservice/tickets/ticketNumber.d.ts +12 -0
- package/dist/features/openservice/tickets/ticketNumber.js +75 -0
- package/dist/features/openservice/tickets/ticketReferences.d.ts +61 -0
- package/dist/features/openservice/tickets/ticketReferences.js +229 -0
- package/dist/features/permissions/types/Permissions.d.ts +1 -0
- package/dist/features/permissions/types/Permissions.js +5 -2
- package/dist/features/schema/indexes.js +13 -0
- package/dist/functions/openinc-backfill-ticket-sort-keys.d.ts +3 -2
- package/dist/functions/openinc-backfill-ticket-sort-keys.js +3 -2
- package/dist/helper/getUserLanguage.d.ts +3 -5
- package/dist/helper/getUserLanguage.js +7 -16
- package/dist/helper/roleNames.d.ts +7 -0
- package/dist/helper/roleNames.js +21 -0
- package/dist/helper/ticketSortKeys.d.ts +8 -9
- package/dist/helper/ticketSortKeys.js +21 -23
- package/dist/helper/updateWithoutTriggers.d.ts +22 -0
- package/dist/helper/updateWithoutTriggers.js +57 -0
- package/dist/hooks/Chat_Message.js +7 -30
- package/dist/hooks/Meta_Entry.js +6 -1
- package/dist/hooks/Service_Equipment.js +2 -1
- package/dist/hooks/Service_FormConfig.js +6 -5
- package/dist/hooks/Service_Project.js +2 -1
- package/dist/hooks/Service_Status.js +3 -6
- package/dist/hooks/Service_Tag.js +51 -11
- package/dist/hooks/Service_Ticket.js +22 -701
- package/dist/scripts/migration/lib/ptr.d.ts +1 -1
- package/dist/scripts/migration/lib/ptr.js +3 -5
- package/dist/scripts/migration/lib/ticket.js +3 -2
- package/dist/scripts/repair-ticket-acl.js +3 -3
- package/package.json +3 -1
- package/dist/helper/pointerIds.d.ts +0 -17
- package/dist/helper/pointerIds.js +0 -45
|
@@ -29,4 +29,4 @@ export declare function dateVal(d: Date): {
|
|
|
29
29
|
/** JSON-stringified context array, matching how the chat and meta plugins store it. */
|
|
30
30
|
export declare function contextToString(parts: string[]): string;
|
|
31
31
|
/** The context every artefact attached to one ticket shares (chat, assets, ...). */
|
|
32
|
-
export
|
|
32
|
+
export { ticketContext } from "@opendash/openservice-shared";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rolePtr = exports.userPtr = exports.tenantPtr = void 0;
|
|
3
|
+
exports.ticketContext = exports.rolePtr = exports.userPtr = exports.tenantPtr = void 0;
|
|
4
4
|
exports.ptr = ptr;
|
|
5
5
|
exports.maybePtr = maybePtr;
|
|
6
6
|
exports.dateVal = dateVal;
|
|
7
7
|
exports.contextToString = contextToString;
|
|
8
|
-
exports.ticketContext = ticketContext;
|
|
9
8
|
function ptr(className, objectId) {
|
|
10
9
|
return { __type: "Pointer", className, objectId };
|
|
11
10
|
}
|
|
@@ -33,6 +32,5 @@ function contextToString(parts) {
|
|
|
33
32
|
return JSON.stringify(parts);
|
|
34
33
|
}
|
|
35
34
|
/** The context every artefact attached to one ticket shares (chat, assets, ...). */
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
35
|
+
var openservice_shared_1 = require("@opendash/openservice-shared");
|
|
36
|
+
Object.defineProperty(exports, "ticketContext", { enumerable: true, get: function () { return openservice_shared_1.ticketContext; } });
|
|
@@ -18,8 +18,9 @@ const pass_js_1 = require("./pass.js");
|
|
|
18
18
|
* historical `createdAt`, because `RestWrite` replaces the write payload with the
|
|
19
19
|
* trigger's `Parse.Object` round-trip, which discards the field (see
|
|
20
20
|
* `features/schema/services/beforeSaveHook.ts`). So the two things that hook did
|
|
21
|
-
* are reimplemented here, deliberately mirroring
|
|
22
|
-
* `hooks/Service_Ticket.ts`
|
|
21
|
+
* are reimplemented here, deliberately mirroring the ticket's `beforeSave`
|
|
22
|
+
* (`hooks/Service_Ticket.ts` and its modules in `features/openservice/tickets/`)
|
|
23
|
+
* — keep them in sync.
|
|
23
24
|
*/
|
|
24
25
|
// ── Numbering ──────────────────────────────────────────────────────────────
|
|
25
26
|
const COUNTER_CLASS = "OD3_Service_TicketCounter";
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_1 = __importDefault(require("parse/node"));
|
|
7
|
-
const
|
|
7
|
+
const openservice_shared_1 = require("@opendash/openservice-shared");
|
|
8
8
|
const index_js_1 = require("../types/index.js");
|
|
9
9
|
/**
|
|
10
10
|
* One-off repair for ticket ACLs written before the `Service_Ticket` hook
|
|
@@ -68,10 +68,10 @@ function expectedGrants(ticket, roleNameById) {
|
|
|
68
68
|
const creatorId = ticket.get("createdBy")?.id;
|
|
69
69
|
if (creatorId)
|
|
70
70
|
grant(creatorId, true, true);
|
|
71
|
-
for (const userId of (0,
|
|
71
|
+
for (const userId of (0, openservice_shared_1.refIds)(ticket.get("assignedUsers"))) {
|
|
72
72
|
grant(userId, true, true);
|
|
73
73
|
}
|
|
74
|
-
for (const roleId of (0,
|
|
74
|
+
for (const roleId of (0, openservice_shared_1.refIds)(ticket.get("assignedRoles"))) {
|
|
75
75
|
const name = roleNameById.get(roleId);
|
|
76
76
|
if (name)
|
|
77
77
|
grant(`role:${name}`, true, true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openinc/parse-server-opendash",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.25.0",
|
|
4
4
|
"description": "Parse Server Cloud Code for open.INC Stack.",
|
|
5
5
|
"packageManager": "pnpm@12.8.1",
|
|
6
6
|
"keywords": [
|
|
@@ -69,9 +69,11 @@
|
|
|
69
69
|
"backfill:meta-contexts": "node dist/scripts/backfill-meta-contexts.js",
|
|
70
70
|
"backfill:changelog-search": "node dist/scripts/backfill-changelog-search.js",
|
|
71
71
|
"repair:ticket-acl": "node dist/scripts/repair-ticket-acl.js",
|
|
72
|
+
"test:integration": "node --test --test-concurrency=1 \"test/integration/**/*.test.mjs\"",
|
|
72
73
|
"seed:v1": "node dist/scripts/seed-v1-testdata.js"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
76
|
+
"@opendash/openservice-shared": "nightly",
|
|
75
77
|
"@opendash/ruleset-core": "nightly",
|
|
76
78
|
"@openinc/parse-server-schema": "^4.1.8",
|
|
77
79
|
"amqplib": "^0.10.9",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the object ids from an array-of-ref field, tolerating undefined and
|
|
3
|
-
* malformed entries.
|
|
4
|
-
*
|
|
5
|
-
* The entity adapter stores array-of-ref fields as plain id **strings**, not as
|
|
6
|
-
* `Parse.Object`s. Reading `.id` off them returned undefined, so an ACL built
|
|
7
|
-
* from such a field granted nobody anything — silently. Every consumer of
|
|
8
|
-
* `assignedUsers`, `assignedRoles`, `users` or `roles` has to go through here.
|
|
9
|
-
*/
|
|
10
|
-
export declare function pointerIds(value: unknown): string[];
|
|
11
|
-
/**
|
|
12
|
-
* Role **names** for an array-of-ref field holding role pointers.
|
|
13
|
-
*
|
|
14
|
-
* `Parse.ACL` grants roles by name, never by id, so a role reference has to be
|
|
15
|
-
* resolved before it can be written into an ACL.
|
|
16
|
-
*/
|
|
17
|
-
export declare function roleNames(Parse: typeof import("parse/node").default, value: unknown): Promise<string[]>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pointerIds = pointerIds;
|
|
4
|
-
exports.roleNames = roleNames;
|
|
5
|
-
/**
|
|
6
|
-
* Extracts the object ids from an array-of-ref field, tolerating undefined and
|
|
7
|
-
* malformed entries.
|
|
8
|
-
*
|
|
9
|
-
* The entity adapter stores array-of-ref fields as plain id **strings**, not as
|
|
10
|
-
* `Parse.Object`s. Reading `.id` off them returned undefined, so an ACL built
|
|
11
|
-
* from such a field granted nobody anything — silently. Every consumer of
|
|
12
|
-
* `assignedUsers`, `assignedRoles`, `users` or `roles` has to go through here.
|
|
13
|
-
*/
|
|
14
|
-
function pointerIds(value) {
|
|
15
|
-
if (!Array.isArray(value))
|
|
16
|
-
return [];
|
|
17
|
-
return value
|
|
18
|
-
.map((entry) => {
|
|
19
|
-
if (typeof entry === "string")
|
|
20
|
-
return entry;
|
|
21
|
-
if (entry && typeof entry === "object") {
|
|
22
|
-
const o = entry;
|
|
23
|
-
return o.id ?? o.objectId;
|
|
24
|
-
}
|
|
25
|
-
return undefined;
|
|
26
|
-
})
|
|
27
|
-
.filter((id) => typeof id === "string");
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Role **names** for an array-of-ref field holding role pointers.
|
|
31
|
-
*
|
|
32
|
-
* `Parse.ACL` grants roles by name, never by id, so a role reference has to be
|
|
33
|
-
* resolved before it can be written into an ACL.
|
|
34
|
-
*/
|
|
35
|
-
async function roleNames(Parse, value) {
|
|
36
|
-
const ids = pointerIds(value);
|
|
37
|
-
if (ids.length === 0)
|
|
38
|
-
return [];
|
|
39
|
-
const roles = await new Parse.Query(Parse.Role)
|
|
40
|
-
.containedIn("objectId", ids)
|
|
41
|
-
.find({ useMasterKey: true });
|
|
42
|
-
return roles
|
|
43
|
-
.map((role) => role.getName())
|
|
44
|
-
.filter((name) => !!name);
|
|
45
|
-
}
|