@openinc/parse-server-opendash 4.33.0 → 4.35.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.
Files changed (28) hide show
  1. package/dist/featuremap.json +0 -1
  2. package/dist/features/openservice/alarms/resolveEquipment.js +4 -1
  3. package/dist/features/openservice/alarms/ticket/AlarmTicketTypes.d.ts +14 -0
  4. package/dist/features/openservice/alarms/ticket/alarmTicketDefaults.d.ts +34 -0
  5. package/dist/features/openservice/alarms/ticket/alarmTicketDefaults.js +80 -0
  6. package/dist/features/openservice/alarms/ticket/createAlarmTicket.js +66 -7
  7. package/dist/features/openservice/alarms/ticket/ensureAlarmTicketAction.js +21 -21
  8. package/dist/features/openservice/demoSeed/demoData.d.ts +51 -0
  9. package/dist/features/openservice/demoSeed/demoData.js +305 -0
  10. package/dist/features/openservice/demoSeed/demoSeed.d.ts +82 -0
  11. package/dist/features/openservice/demoSeed/demoSeed.js +424 -0
  12. package/dist/functions/openinc-openservice-demo-seed.d.ts +21 -0
  13. package/dist/functions/openinc-openservice-demo-seed.js +63 -0
  14. package/dist/hooks/Service_Schedule.js +3 -2
  15. package/dist/types/Service_Schedule.d.ts +0 -3
  16. package/dist/types/Service_Schedule.js +0 -6
  17. package/dist/types/Service_Tag.d.ts +3 -0
  18. package/dist/types/Service_Tag.js +6 -0
  19. package/dist/types/index.d.ts +0 -2
  20. package/dist/types/index.js +1 -3
  21. package/package.json +1 -1
  22. package/schema/Service_Schedule.json +0 -3
  23. package/schema/Service_Tag.json +3 -0
  24. package/dist/hooks/Service_EquipmentAnnotation.d.ts +0 -1
  25. package/dist/hooks/Service_EquipmentAnnotation.js +0 -15
  26. package/dist/types/Service_EquipmentAnnotation.d.ts +0 -35
  27. package/dist/types/Service_EquipmentAnnotation.js +0 -57
  28. package/schema/Service_EquipmentAnnotation.json +0 -57
@@ -0,0 +1,424 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEMO_SEED_CONTEXT_FLAG = exports.DEMO_SEED_CONFIG_KEY = void 0;
7
+ exports.demoSeedStatus = demoSeedStatus;
8
+ exports.resolveTenant = resolveTenant;
9
+ exports.demoSeedUsers = demoSeedUsers;
10
+ exports.resolveUser = resolveUser;
11
+ exports.seedDemoData = seedDemoData;
12
+ exports.resetDemoData = resetDemoData;
13
+ const node_1 = __importDefault(require("parse/node"));
14
+ const index_js_1 = require("../../../types/index.js");
15
+ const demoData_js_1 = require("./demoData.js");
16
+ /**
17
+ * Where a tenant's demo seed remembers what it created.
18
+ *
19
+ * None of the seeded classes carries a marker column — a demo feature is no
20
+ * reason for a schema change. Instead the ids of everything seeded are kept in
21
+ * one config row per tenant, readable by `od-admin` only. A reset removes
22
+ * exactly those objects (plus what can only go together with them, see
23
+ * {@link resetDemoData}), so a tenant that also holds real data keeps it.
24
+ */
25
+ exports.DEMO_SEED_CONFIG_KEY = "OPENSERVICE_DEMO_SEED";
26
+ /**
27
+ * Context flag on every write the seed makes. The plan hook skips the Outlook
28
+ * sync for it: demo plans belong to a demo tenant, not in anybody's calendar.
29
+ */
30
+ exports.DEMO_SEED_CONTEXT_FLAG = "fromDemoSeed";
31
+ /** Reads. */
32
+ const MK = { useMasterKey: true };
33
+ /**
34
+ * Writes and deletes. `skipChangelog`: the seed's own rows would all read
35
+ * "created by master key, today" — noise in every history view, and rows the
36
+ * reset would have to chase afterwards.
37
+ */
38
+ const WRITE = {
39
+ useMasterKey: true,
40
+ context: { skipChangelog: true, [exports.DEMO_SEED_CONTEXT_FLAG]: true },
41
+ };
42
+ const SEEDED_CLASSES = [
43
+ index_js_1.Service_Equipment.className,
44
+ index_js_1.Service_Schedule.className,
45
+ index_js_1.Service_Schedule_Template.className,
46
+ index_js_1.Service_Schedule_Execution.className,
47
+ ];
48
+ /** Every tenant with the date of its last demo seed, if any. */
49
+ async function demoSeedStatus() {
50
+ const [tenants, rows] = await Promise.all([
51
+ new node_1.default.Query(index_js_1.Tenant).ascending("label").limit(1000).find(MK),
52
+ new node_1.default.Query(index_js_1.Config)
53
+ .equalTo("key", exports.DEMO_SEED_CONFIG_KEY)
54
+ .limit(1000)
55
+ .find(MK),
56
+ ]);
57
+ const seededAt = new Map();
58
+ for (const row of rows) {
59
+ const tenantId = row.get("tenant")?.id;
60
+ const record = parseRecord(row.get("value"));
61
+ if (tenantId && record)
62
+ seededAt.set(tenantId, record.seededAt);
63
+ }
64
+ return tenants.map((tenant) => ({
65
+ tenantId: tenant.id,
66
+ label: tenant.get("label") || tenant.id,
67
+ seededAt: seededAt.get(tenant.id),
68
+ }));
69
+ }
70
+ async function resolveTenant(tenantId) {
71
+ if (typeof tenantId !== "string" || !tenantId) {
72
+ throw new node_1.default.Error(node_1.default.Error.INVALID_QUERY, "tenantId is required");
73
+ }
74
+ return new node_1.default.Query(index_js_1.Tenant).get(tenantId, MK);
75
+ }
76
+ /** The tenant's users, as candidates for the `user` field of the demo data. */
77
+ async function demoSeedUsers(tenant) {
78
+ const users = await new node_1.default.Query(node_1.default.User)
79
+ .equalTo("tenant", tenant)
80
+ .notEqualTo("tenantBanned", true)
81
+ .limit(1000)
82
+ .find(MK);
83
+ return users
84
+ .map((user) => ({ userId: user.id, label: userLabel(user) }))
85
+ .sort((a, b) => a.label.localeCompare(b.label));
86
+ }
87
+ /**
88
+ * The user the demo data is attributed to — only one of the chosen tenant's,
89
+ * otherwise a demo plan would hand a foreign user read+write on it.
90
+ */
91
+ async function resolveUser(userId, tenant) {
92
+ if (userId == null || userId === "")
93
+ return undefined;
94
+ if (typeof userId !== "string") {
95
+ throw new node_1.default.Error(node_1.default.Error.INVALID_QUERY, "userId must be a string");
96
+ }
97
+ const user = (await new node_1.default.Query(node_1.default.User)
98
+ .equalTo("objectId", userId)
99
+ .equalTo("tenant", tenant)
100
+ .first(MK));
101
+ if (!user) {
102
+ throw new node_1.default.Error(node_1.default.Error.OBJECT_NOT_FOUND, `User ${userId} does not belong to tenant ${tenant.id}`);
103
+ }
104
+ return user;
105
+ }
106
+ function userLabel(user) {
107
+ const full = [user.get("firstname"), user.get("lastname")]
108
+ .filter(Boolean)
109
+ .join(" ");
110
+ return (user.get("name") ||
111
+ full ||
112
+ user.get("username") ||
113
+ user.get("email") ||
114
+ user.id);
115
+ }
116
+ /**
117
+ * Replace the tenant's demo data with a fresh set.
118
+ *
119
+ * Removes the previous seed first, so pressing the button twice does not
120
+ * leave two copies of Halle B.
121
+ *
122
+ * `user` becomes the `user` of every plan, template and execution: the owner
123
+ * of a plan (the ACL grants them read+write) and the author of the rest —
124
+ * and the `performedBy` of every execution.
125
+ * Without one the fields stay empty, as before.
126
+ */
127
+ async function seedDemoData(tenant, user) {
128
+ const removed = await resetDemoData(tenant);
129
+ // Written after every step, so a failure halfway still leaves a record the
130
+ // next reset can clean up from.
131
+ const record = {
132
+ seededAt: new Date().toISOString(),
133
+ equipment: [],
134
+ templates: [],
135
+ schedules: [],
136
+ executions: [],
137
+ };
138
+ // ── Equipment ──────────────────────────────────────────────────────────────
139
+ const hall = new index_js_1.Service_Equipment();
140
+ hall.set("label", demoData_js_1.DEMO_HALL);
141
+ hall.set("deleted", false);
142
+ hall.set("tenant", tenant);
143
+ await hall.save(null, WRITE);
144
+ record.equipment.push(hall.id);
145
+ await writeRecord(tenant, record);
146
+ const machines = demoData_js_1.DEMO_MACHINES.map((label) => {
147
+ const machine = new index_js_1.Service_Equipment();
148
+ machine.set("label", label);
149
+ machine.set("deleted", false);
150
+ machine.set("tenant", tenant);
151
+ machine.set("parent", hall);
152
+ return machine;
153
+ });
154
+ await node_1.default.Object.saveAll(machines, WRITE);
155
+ record.equipment.push(...machines.map((m) => m.id));
156
+ await writeRecord(tenant, record);
157
+ // ── Templates ──────────────────────────────────────────────────────────────
158
+ const templates = (0, demoData_js_1.demoTemplates)().map((data) => {
159
+ const template = new index_js_1.Service_Schedule_Template();
160
+ template.set("title", data.title);
161
+ template.set("description", data.description);
162
+ template.set("cadence", data.cadence);
163
+ template.set("steps", data.steps);
164
+ template.set("serviceProviders", []);
165
+ template.set("tenant", tenant);
166
+ if (user)
167
+ template.set("user", user);
168
+ return template;
169
+ });
170
+ await node_1.default.Object.saveAll(templates, WRITE);
171
+ record.templates = templates.map((t) => t.id);
172
+ await writeRecord(tenant, record);
173
+ // ── Plans ──────────────────────────────────────────────────────────────────
174
+ const plans = (0, demoData_js_1.demoSchedules)();
175
+ const schedules = plans.map((plan) => {
176
+ const schedule = new index_js_1.Service_Schedule();
177
+ schedule.set("title", plan.title);
178
+ schedule.set("active", true);
179
+ schedule.set("cadence", plan.cadence);
180
+ schedule.set("steps", plan.steps);
181
+ schedule.set("serviceProviders", []);
182
+ schedule.set("tenant", tenant);
183
+ if (user)
184
+ schedule.set("user", user);
185
+ schedule.set("equipment", machines[plan.machine]);
186
+ // Optional columns only when used: an explicit undefined would be written
187
+ // as null and muddle "not configured".
188
+ if (plan.color)
189
+ schedule.set("color", plan.color);
190
+ if (plan.leadDays != null)
191
+ schedule.set("leadDays", plan.leadDays);
192
+ if (plan.graceDays != null)
193
+ schedule.set("graceDays", plan.graceDays);
194
+ if (plan.escalationAfterDays != null) {
195
+ schedule.set("escalationAfterDays", plan.escalationAfterDays);
196
+ }
197
+ if (plan.pausedUntil)
198
+ schedule.set("pausedUntil", plan.pausedUntil);
199
+ if (plan.origin)
200
+ schedule.set("origin", plan.origin);
201
+ if (plan.asset)
202
+ schedule.set("asset", plan.asset);
203
+ return schedule;
204
+ });
205
+ await node_1.default.Object.saveAll(schedules, WRITE);
206
+ record.schedules = schedules.map((s) => s.id);
207
+ await writeRecord(tenant, record);
208
+ // Plans are private by default (`denyTenantUserRead`), and a master-key
209
+ // write has no creator to grant. Assigning the tenant's user role is what
210
+ // makes them visible to everybody logging into the demo — the afterSave
211
+ // hook rebuilds the ACL from the relation.
212
+ const userRole = await new node_1.default.Query(node_1.default.Role)
213
+ .equalTo("name", `od-tenant-user-${tenant.id}`)
214
+ .first(MK);
215
+ if (userRole) {
216
+ for (const schedule of schedules) {
217
+ schedule.relation("assignedRoles").add(userRole);
218
+ }
219
+ await node_1.default.Object.saveAll(schedules, WRITE);
220
+ }
221
+ else {
222
+ console.warn(`[DemoSeed] Tenant ${tenant.id} has no od-tenant-user role — demo plans stay visible to admins only`);
223
+ }
224
+ // ── Executions, from each plan's history ───────────────────────────────────
225
+ // Completed executions only: one without `completedAt` is still being worked
226
+ // through, and seeding those would make every plan look like somebody is
227
+ // mid-job on it. Every step is ticked, so the protocols read as complete.
228
+ // The step snapshot (`steps`) is frozen on by the execution hook.
229
+ const executions = plans.flatMap((plan, index) => plan.history.map((completedDaysAgo) => {
230
+ const completedAt = (0, demoData_js_1.demoDaysAgo)(completedDaysAgo);
231
+ const execution = new index_js_1.Service_Schedule_Execution();
232
+ execution.set("schedule", schedules[index]);
233
+ execution.set("tenant", tenant);
234
+ if (user) {
235
+ execution.set("user", user);
236
+ // Who carried it out — what the protocol shows as "durchgeführt von".
237
+ execution.set("performedBy", user);
238
+ }
239
+ execution.set("completedAt", completedAt);
240
+ execution.set("stepResults", plan.steps.map((s) => ({
241
+ stepId: s.id,
242
+ done: true,
243
+ completedAt: completedAt.toISOString(),
244
+ })));
245
+ return execution;
246
+ }));
247
+ await node_1.default.Object.saveAll(executions, WRITE);
248
+ record.executions = executions.map((e) => e.id);
249
+ await writeRecord(tenant, record);
250
+ return {
251
+ tenantId: tenant.id,
252
+ removed,
253
+ created: {
254
+ equipment: record.equipment.length,
255
+ schedules: schedules.length,
256
+ templates: templates.length,
257
+ executions: executions.length,
258
+ },
259
+ };
260
+ }
261
+ /**
262
+ * Remove what the last seed created in this tenant.
263
+ *
264
+ * Beyond the recorded ids, three things go with them because they cannot stay
265
+ * behind on their own:
266
+ * - executions somebody recorded by hand on a demo plan or demo machine — a
267
+ * plan with executions cannot be deleted, and they would point at nothing;
268
+ * - the role/user assignments of the demo plans (Parse leaves relation rows
269
+ * in `_Join:*` behind when the owning object is deleted);
270
+ * - changelog rows about demo objects, written by edits during the demo.
271
+ *
272
+ * Equipment that tickets or non-demo equipment point at is archived rather
273
+ * than deleted.
274
+ */
275
+ async function resetDemoData(tenant) {
276
+ const row = await findRecordRow(tenant);
277
+ const record = parseRecord(row?.get("value"));
278
+ const schedules = await byIds(tenant, index_js_1.Service_Schedule, record?.schedules);
279
+ const templates = await byIds(tenant, index_js_1.Service_Schedule_Template, record?.templates);
280
+ const equipment = await byIds(tenant, index_js_1.Service_Equipment, record?.equipment);
281
+ const recordedExecutions = await byIds(tenant, index_js_1.Service_Schedule_Execution, record?.executions);
282
+ // Executions point at plans (or, for a direct maintenance, at equipment);
283
+ // they have to go before what they point at.
284
+ const executions = uniqueById([
285
+ ...recordedExecutions,
286
+ ...(schedules.length
287
+ ? await new node_1.default.Query(index_js_1.Service_Schedule_Execution)
288
+ .equalTo("tenant", tenant)
289
+ .containedIn("schedule", schedules)
290
+ .limit(10000)
291
+ .find(MK)
292
+ : []),
293
+ ...(equipment.length
294
+ ? await new node_1.default.Query(index_js_1.Service_Schedule_Execution)
295
+ .equalTo("tenant", tenant)
296
+ .containedIn("equipment", equipment)
297
+ .doesNotExist("schedule")
298
+ .limit(10000)
299
+ .find(MK)
300
+ : []),
301
+ ]);
302
+ await node_1.default.Object.destroyAll(executions, WRITE);
303
+ await clearRelations(schedules, [
304
+ "assignedRoles",
305
+ "escalationRoles",
306
+ "assignedUsers",
307
+ ]);
308
+ await clearRelations(templates, ["assignedRoles"]);
309
+ await node_1.default.Object.destroyAll(schedules, WRITE);
310
+ await node_1.default.Object.destroyAll(templates, WRITE);
311
+ // Machines before the hall that is their parent; one at a time, because a
312
+ // refused delete must not take the rest of the batch with it.
313
+ let deletedEquipment = 0;
314
+ let archivedEquipment = 0;
315
+ const childrenFirst = [...equipment].sort((a, b) => Number(!a.get("parent")) - Number(!b.get("parent")));
316
+ for (const item of childrenFirst) {
317
+ // Somebody hung their own equipment under Halle B: deleting it would leave
318
+ // that child pointing at nothing. The equipment hook only checks tickets.
319
+ const children = await new node_1.default.Query(index_js_1.Service_Equipment)
320
+ .equalTo("parent", item)
321
+ .count(MK);
322
+ try {
323
+ if (children > 0)
324
+ throw new Error("has children");
325
+ await item.destroy(WRITE);
326
+ deletedEquipment++;
327
+ }
328
+ catch {
329
+ item.set("deleted", true);
330
+ await item.save(null, WRITE);
331
+ archivedEquipment++;
332
+ }
333
+ }
334
+ // History of edits made during the demo. Only rows about objects that are
335
+ // actually gone — an archived machine keeps its history.
336
+ const goneIds = [
337
+ ...executions,
338
+ ...schedules,
339
+ ...templates,
340
+ ...equipment.filter((item) => !item.get("deleted")),
341
+ ].map((o) => o.id);
342
+ await deleteChangelog(goneIds);
343
+ if (row)
344
+ await row.destroy(WRITE);
345
+ return {
346
+ executions: executions.length,
347
+ schedules: schedules.length,
348
+ templates: templates.length,
349
+ equipment: deletedEquipment,
350
+ archivedEquipment,
351
+ };
352
+ }
353
+ /** Recorded objects that still exist — scoped to the tenant, always. */
354
+ async function byIds(tenant, cls, ids) {
355
+ if (!ids?.length)
356
+ return [];
357
+ return new node_1.default.Query(cls.className)
358
+ .containedIn("objectId", ids)
359
+ .equalTo("tenant", tenant)
360
+ .limit(ids.length)
361
+ .find(MK);
362
+ }
363
+ async function clearRelations(objects, keys) {
364
+ const changed = [];
365
+ for (const object of objects) {
366
+ let dirty = false;
367
+ for (const key of keys) {
368
+ const relation = object.relation(key);
369
+ const members = await relation.query().limit(1000).find(MK);
370
+ if (members.length) {
371
+ relation.remove(members);
372
+ dirty = true;
373
+ }
374
+ }
375
+ if (dirty)
376
+ changed.push(object);
377
+ }
378
+ if (changed.length)
379
+ await node_1.default.Object.saveAll(changed, WRITE);
380
+ }
381
+ async function deleteChangelog(ids) {
382
+ if (!ids.length)
383
+ return;
384
+ const rows = await new node_1.default.Query(index_js_1.Changelog)
385
+ .containedIn("nameOfClass", SEEDED_CLASSES)
386
+ .containedIn("changedObject", ids)
387
+ .limit(10000)
388
+ .find(MK);
389
+ await node_1.default.Object.destroyAll(rows, WRITE);
390
+ }
391
+ function uniqueById(objects) {
392
+ return [...new Map(objects.map((o) => [o.id, o])).values()];
393
+ }
394
+ function findRecordRow(tenant) {
395
+ return new node_1.default.Query(index_js_1.Config)
396
+ .equalTo("key", exports.DEMO_SEED_CONFIG_KEY)
397
+ .equalTo("tenant", tenant)
398
+ .first(MK);
399
+ }
400
+ async function writeRecord(tenant, record) {
401
+ let row = await findRecordRow(tenant);
402
+ if (!row) {
403
+ row = new index_js_1.Config();
404
+ row.set("key", exports.DEMO_SEED_CONFIG_KEY);
405
+ row.set("tenant", tenant);
406
+ row.set("priority", 0);
407
+ const acl = new node_1.default.ACL();
408
+ acl.setRoleReadAccess("od-admin", true);
409
+ acl.setRoleWriteAccess("od-admin", true);
410
+ row.setACL(acl);
411
+ }
412
+ row.set("value", JSON.stringify(record));
413
+ await row.save(null, WRITE);
414
+ }
415
+ function parseRecord(value) {
416
+ if (typeof value !== "string" || !value)
417
+ return undefined;
418
+ try {
419
+ return JSON.parse(value);
420
+ }
421
+ catch {
422
+ return undefined;
423
+ }
424
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Seed or remove the open.SERVICE demo data set (Halle B, ten plans, four
3
+ * templates, their history) in a tenant of the caller's choice.
4
+ *
5
+ * Actions:
6
+ * - `status` (default) — whether the caller may use this at all, and every
7
+ * tenant with the date of its last seed. A caller who may not gets
8
+ * `{ allowed: false }` instead of an error, so the setup page can simply
9
+ * leave the section out.
10
+ * - `users` — the chosen tenant's users, for the `user` field of the data.
11
+ * - `seed` — replace the tenant's demo data with a fresh set, optionally
12
+ * attributed to `userId` (one of that tenant's users). Dates are relative
13
+ * to now, which is why re-seeding is the way to refresh it.
14
+ * - `reset` — remove what the last seed created, and nothing else.
15
+ *
16
+ * **Global admins only (`od-admin`).** Unlike the setup function, the tenant
17
+ * is a parameter here — that is the point of it — so a tenant admin must not
18
+ * be able to call it: they could write into, or wipe the demo data of, a
19
+ * tenant that is not theirs.
20
+ */
21
+ export declare function init(name: string): Promise<void>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.init = init;
7
+ const node_1 = __importDefault(require("parse/node"));
8
+ const demoSeed_js_1 = require("../features/openservice/demoSeed/demoSeed.js");
9
+ /**
10
+ * Seed or remove the open.SERVICE demo data set (Halle B, ten plans, four
11
+ * templates, their history) in a tenant of the caller's choice.
12
+ *
13
+ * Actions:
14
+ * - `status` (default) — whether the caller may use this at all, and every
15
+ * tenant with the date of its last seed. A caller who may not gets
16
+ * `{ allowed: false }` instead of an error, so the setup page can simply
17
+ * leave the section out.
18
+ * - `users` — the chosen tenant's users, for the `user` field of the data.
19
+ * - `seed` — replace the tenant's demo data with a fresh set, optionally
20
+ * attributed to `userId` (one of that tenant's users). Dates are relative
21
+ * to now, which is why re-seeding is the way to refresh it.
22
+ * - `reset` — remove what the last seed created, and nothing else.
23
+ *
24
+ * **Global admins only (`od-admin`).** Unlike the setup function, the tenant
25
+ * is a parameter here — that is the point of it — so a tenant admin must not
26
+ * be able to call it: they could write into, or wipe the demo data of, a
27
+ * tenant that is not theirs.
28
+ */
29
+ async function init(name) {
30
+ node_1.default.Cloud.define(name, async (request) => {
31
+ const allowed = request.master || (await isGlobalAdmin(request.user));
32
+ const { action, tenantId, userId } = request.params;
33
+ if ((action ?? "status") === "status") {
34
+ return allowed
35
+ ? { allowed: true, tenants: await (0, demoSeed_js_1.demoSeedStatus)() }
36
+ : { allowed: false, tenants: [] };
37
+ }
38
+ if (!allowed) {
39
+ throw new node_1.default.Error(node_1.default.Error.OPERATION_FORBIDDEN, `${name}: only global administrators may seed demo data`);
40
+ }
41
+ const tenant = await (0, demoSeed_js_1.resolveTenant)(tenantId);
42
+ switch (action) {
43
+ case "users":
44
+ return (0, demoSeed_js_1.demoSeedUsers)(tenant);
45
+ case "seed":
46
+ return (0, demoSeed_js_1.seedDemoData)(tenant, await (0, demoSeed_js_1.resolveUser)(userId, tenant));
47
+ case "reset":
48
+ return { tenantId: tenant.id, removed: await (0, demoSeed_js_1.resetDemoData)(tenant) };
49
+ default:
50
+ throw new node_1.default.Error(node_1.default.Error.INVALID_QUERY, `${name}: unknown action "${action}"`);
51
+ }
52
+ }, { requireUser: true });
53
+ }
54
+ /** Direct member of `od-admin` — the role every ACL in this server grants. */
55
+ async function isGlobalAdmin(user) {
56
+ if (!user)
57
+ return false;
58
+ const role = await new node_1.default.Query(node_1.default.Role)
59
+ .equalTo("name", "od-admin")
60
+ .equalTo("users", user)
61
+ .first({ useMasterKey: true });
62
+ return !!role;
63
+ }
@@ -9,6 +9,7 @@ const index_js_1 = require("../features/schema/index.js");
9
9
  const Permissions_js_1 = require("../features/permissions/types/Permissions.js");
10
10
  const index_js_2 = require("../features/permissions/index.js");
11
11
  const assignmentAcl_js_1 = require("../features/openservice/serviceSchedules/assignmentAcl.js");
12
+ const demoSeed_js_1 = require("../features/openservice/demoSeed/demoSeed.js");
12
13
  const index_js_3 = require("../features/openservice/serviceSchedules/calendarSync/index.js");
13
14
  const index_js_4 = require("../types/index.js");
14
15
  async function init() {
@@ -80,8 +81,8 @@ async function init() {
80
81
  // poller marks its own writes with this flag.
81
82
  if (context?.[index_js_3.CALENDAR_SYNC_CONTEXT_FLAG])
82
83
  return;
83
- // Seed data belongs to a demo tenant, not in anybody's calendar.
84
- if (object.get("seed"))
84
+ // Demo data belongs to a demo tenant, not in anybody's calendar.
85
+ if (context?.[demoSeed_js_1.DEMO_SEED_CONTEXT_FLAG])
85
86
  return;
86
87
  if (!original || calendarRelevantChange(object, original)) {
87
88
  // Deliberately not awaited: the calendar is a downstream system, and a
@@ -26,7 +26,6 @@ export interface Service_ScheduleAttributes {
26
26
  notifications: any[];
27
27
  origin?: string | undefined;
28
28
  pausedUntil?: Date | undefined;
29
- seed?: boolean | undefined;
30
29
  serviceProviders?: any[] | undefined;
31
30
  steps: any[];
32
31
  tenant: Tenant;
@@ -69,8 +68,6 @@ export declare class Service_Schedule extends Parse.Object<Service_ScheduleAttri
69
68
  set origin(value: string | undefined);
70
69
  get pausedUntil(): Date | undefined;
71
70
  set pausedUntil(value: Date | undefined);
72
- get seed(): boolean | undefined;
73
- set seed(value: boolean | undefined);
74
71
  get serviceProviders(): any[] | undefined;
75
72
  set serviceProviders(value: any[] | undefined);
76
73
  get steps(): any[];
@@ -109,12 +109,6 @@ class Service_Schedule extends node_1.default.Object {
109
109
  set pausedUntil(value) {
110
110
  super.set("pausedUntil", value);
111
111
  }
112
- get seed() {
113
- return super.get("seed");
114
- }
115
- set seed(value) {
116
- super.set("seed", value);
117
- }
118
112
  get serviceProviders() {
119
113
  return super.get("serviceProviders");
120
114
  }
@@ -5,6 +5,7 @@ export interface Service_TagAttributes {
5
5
  objectId: string;
6
6
  createdAt: Date;
7
7
  updatedAt: Date;
8
+ category?: string | undefined;
8
9
  color?: string | undefined;
9
10
  deleted: boolean;
10
11
  label?: string | undefined;
@@ -15,6 +16,8 @@ export interface Service_TagAttributes {
15
16
  export declare class Service_Tag extends Parse.Object<Service_TagAttributes> {
16
17
  static className: string;
17
18
  constructor(data?: Partial<Service_TagAttributes>);
19
+ get category(): string | undefined;
20
+ set category(value: string | undefined);
18
21
  get color(): string | undefined;
19
22
  set color(value: string | undefined);
20
23
  get deleted(): boolean;
@@ -10,6 +10,12 @@ class Service_Tag extends node_1.default.Object {
10
10
  constructor(data) {
11
11
  super("OD3_Service_Tag", data);
12
12
  }
13
+ get category() {
14
+ return super.get("category");
15
+ }
16
+ set category(value) {
17
+ super.set("category", value);
18
+ }
13
19
  get color() {
14
20
  return super.get("color");
15
21
  }
@@ -226,8 +226,6 @@ export { Report } from "./Report";
226
226
  export type { ReportAttributes } from "./Report";
227
227
  export { Service_Equipment } from "./Service_Equipment";
228
228
  export type { Service_EquipmentAttributes } from "./Service_Equipment";
229
- export { Service_EquipmentAnnotation } from "./Service_EquipmentAnnotation";
230
- export type { Service_EquipmentAnnotationAttributes } from "./Service_EquipmentAnnotation";
231
229
  export { Service_FormConfig } from "./Service_FormConfig";
232
230
  export type { Service_FormConfigAttributes } from "./Service_FormConfig";
233
231
  export { Service_KpiDefinition } from "./Service_KpiDefinition";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Language = exports.Knowledge_Video = exports.Knowledge_DocumentPage = exports.Knowledge_Document = exports.Knowledge_ChatMessage = exports.Knowledge_Chat = exports.Knowledge_Category = exports.Knowledge_Article = exports.GTFS_Wheelchair_Boarding = exports.GTFS_Wheelchair_Accessible = exports.GTFS_Trip = exports.GTFS_Stop_Times = exports.GTFS_Stop = exports.GTFS_Route_Type = exports.GTFS_Route = exports.GTFS_Location_Type = exports.GTFS_Level = exports.GTFS_Direction = exports.GTFS_Calendar = exports.GTFS_Bikes_Allowed = exports.GTFS_Agency = exports.EMS_ChargePoint = exports.Documentation_Document = exports.Documentation_Config = exports.Documentation_Category = exports.Dashboard = exports.Core_Token = exports.Core_RequestTemplate = exports.Core_Email = exports.Contact = exports.Config = exports.Company = exports.Chat_Message = exports.Changelog = exports.BDE_WorkTime = exports.BDE_WorkOrder = exports.BDE_Unit = exports.BDE_ShiftModel = exports.BDE_ShiftException = exports.BDE_Result = exports.BDE_Page = exports.BDE_ListEntry = exports.BDE_List = exports.BDE_Form = exports.BDE_Article = exports.Attachment = exports.Assets = exports.AlarmWebhook = exports.AlarmAction = exports.Alarm = void 0;
4
4
  exports.NavigationItem = exports.NavigationGroup = exports.Monitoring_Slideshow = exports.Monitoring_ReportImage = exports.Monitoring_ParseTableSensor = exports.Monitoring_Jobs = exports.Monitoring_DataHierachies = exports.Meta_Entry = exports.Meta_Context = exports.Meta_Config = exports.Maintenance_Ticket_Title = exports.Maintenance_Ticket_Source = exports.Maintenance_Ticket_QR_Code = exports.Maintenance_Ticket_Project = exports.Maintenance_Ticket_Material = exports.Maintenance_Ticket_Kanban_State_Current = exports.Maintenance_Ticket_Kanban_State = exports.Maintenance_Ticket_Issuecategory = exports.Maintenance_Ticket_FormConfig = exports.Maintenance_Ticket_Data = exports.Maintenance_Ticket_Assignment = exports.Maintenance_Ticket = exports.Maintenance_Source_File = exports.Maintenance_SourceMeta = exports.Maintenance_Schedule_Template = exports.Maintenance_Schedule_Step = exports.Maintenance_Schedule_Execution_Step = exports.Maintenance_Schedule_Execution = exports.Maintenance_Schedule = exports.Maintenance_Restriction = exports.Maintenance_Project = exports.Maintenance_Priority = exports.Maintenance_Order = exports.Maintenance_Message = exports.Maintenance_Media = exports.Maintenance_Kanban_State = exports.Maintenance_Item = exports.Maintenance_Issuecategory = exports.Maintenance_Frequency = exports.Maintenance_Duedate = exports.Maintenance_Downtime = exports.Mail_Groups = exports.MailTemplate = exports.ML_DataSelection = exports.MIAAS_MDSEndpoint = exports.MES_RessourceOverview = exports.MES_OrderPlan = exports.MES_Order = exports.MES_Article = exports.Log = void 0;
5
- exports.WidgetPreset = exports.Widget = exports.WebPush = exports.VirtualKPI = exports.User_Setting = exports.UserData = exports.TenantTrustedDomain = exports.TenantMeta = exports.Tenant = exports.Spreadsheet_Workbook = exports.SourceMeta = exports.Source = exports.Share = exports.Service_TicketCounter = exports.Service_Ticket = exports.Service_Tag = exports.Service_Status = exports.Service_Schedule_Template = exports.Service_Schedule_Execution = exports.Service_Schedule = exports.Service_Project = exports.Service_Occurrence = exports.Service_MigrationMap = exports.Service_KpiDefinition = exports.Service_FormConfig = exports.Service_EquipmentAnnotation = exports.Service_Equipment = exports.Report = exports.RAG_Request = exports.RAG_Questions = exports.RAG_Prompts = exports.RAG_Meta = exports.RAG_Interview = exports.RAG_Data = exports.Push = exports.Permission = exports.OWPlcItem = exports.OWPlcDevice = exports.Notification_Setting = exports.Notification = void 0;
5
+ exports.WidgetPreset = exports.Widget = exports.WebPush = exports.VirtualKPI = exports.User_Setting = exports.UserData = exports.TenantTrustedDomain = exports.TenantMeta = exports.Tenant = exports.Spreadsheet_Workbook = exports.SourceMeta = exports.Source = exports.Share = exports.Service_TicketCounter = exports.Service_Ticket = exports.Service_Tag = exports.Service_Status = exports.Service_Schedule_Template = exports.Service_Schedule_Execution = exports.Service_Schedule = exports.Service_Project = exports.Service_Occurrence = exports.Service_MigrationMap = exports.Service_KpiDefinition = exports.Service_FormConfig = exports.Service_Equipment = exports.Report = exports.RAG_Request = exports.RAG_Questions = exports.RAG_Prompts = exports.RAG_Meta = exports.RAG_Interview = exports.RAG_Data = exports.Push = exports.Permission = exports.OWPlcItem = exports.OWPlcDevice = exports.Notification_Setting = exports.Notification = void 0;
6
6
  var Alarm_1 = require("./Alarm");
7
7
  Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.Alarm; } });
8
8
  var AlarmAction_1 = require("./AlarmAction");
@@ -231,8 +231,6 @@ var Report_1 = require("./Report");
231
231
  Object.defineProperty(exports, "Report", { enumerable: true, get: function () { return Report_1.Report; } });
232
232
  var Service_Equipment_1 = require("./Service_Equipment");
233
233
  Object.defineProperty(exports, "Service_Equipment", { enumerable: true, get: function () { return Service_Equipment_1.Service_Equipment; } });
234
- var Service_EquipmentAnnotation_1 = require("./Service_EquipmentAnnotation");
235
- Object.defineProperty(exports, "Service_EquipmentAnnotation", { enumerable: true, get: function () { return Service_EquipmentAnnotation_1.Service_EquipmentAnnotation; } });
236
234
  var Service_FormConfig_1 = require("./Service_FormConfig");
237
235
  Object.defineProperty(exports, "Service_FormConfig", { enumerable: true, get: function () { return Service_FormConfig_1.Service_FormConfig; } });
238
236
  var Service_KpiDefinition_1 = require("./Service_KpiDefinition");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.33.0",
3
+ "version": "4.35.0",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@12.16.1",
6
6
  "keywords": [
@@ -74,9 +74,6 @@
74
74
  "type": "Date",
75
75
  "required": false
76
76
  },
77
- "seed": {
78
- "type": "Boolean"
79
- },
80
77
  "serviceProviders": {
81
78
  "type": "Array"
82
79
  },
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "fields": {
3
+ "category": {
4
+ "type": "String"
5
+ },
3
6
  "color": {
4
7
  "type": "String"
5
8
  },
@@ -1 +0,0 @@
1
- export declare function init(): Promise<void>;