@openinc/parse-server-opendash 4.36.0 → 4.37.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 (33) hide show
  1. package/dist/featuremap.json +1 -0
  2. package/dist/features/openservice/articles/articleEquipment.d.ts +19 -0
  3. package/dist/features/openservice/articles/articleEquipment.js +53 -0
  4. package/dist/features/openservice/articles/articleStock.d.ts +19 -0
  5. package/dist/features/openservice/articles/articleStock.js +31 -0
  6. package/dist/features/openservice/equipment/criticality.d.ts +29 -0
  7. package/dist/features/openservice/equipment/criticality.js +85 -0
  8. package/dist/features/openservice/tickets/ticketPriority.d.ts +18 -11
  9. package/dist/features/openservice/tickets/ticketPriority.js +54 -20
  10. package/dist/features/openservice/tickets/ticketRules.js +1 -1
  11. package/dist/features/schema/indexes.js +9 -0
  12. package/dist/hooks/BDE_Article.js +5 -1
  13. package/dist/hooks/BDE_DisruptionReason.d.ts +1 -0
  14. package/dist/hooks/BDE_DisruptionReason.js +70 -0
  15. package/dist/hooks/Service_Equipment.js +3 -0
  16. package/dist/scripts/backfill-stock-alert.d.ts +1 -0
  17. package/dist/scripts/backfill-stock-alert.js +89 -0
  18. package/dist/scripts/migration/lib/articleMeta.d.ts +7 -3
  19. package/dist/scripts/migration/lib/articleMeta.js +8 -10
  20. package/dist/scripts/migration/passes/05-articles.d.ts +8 -4
  21. package/dist/scripts/migration/passes/05-articles.js +29 -12
  22. package/dist/types/BDE_Article.d.ts +6 -0
  23. package/dist/types/BDE_Article.js +12 -0
  24. package/dist/types/BDE_DisruptionReason.d.ts +43 -0
  25. package/dist/types/BDE_DisruptionReason.js +72 -0
  26. package/dist/types/Service_Equipment.d.ts +3 -0
  27. package/dist/types/Service_Equipment.js +6 -0
  28. package/dist/types/index.d.ts +2 -0
  29. package/dist/types/index.js +5 -3
  30. package/package.json +2 -1
  31. package/schema/BDE_Article.json +9 -0
  32. package/schema/BDE_DisruptionReason.json +73 -0
  33. package/schema/Service_Equipment.json +3 -0
@@ -5,6 +5,7 @@
5
5
  "OD3_Assets": "CORE",
6
6
  "OD3_Attachment": "CORE",
7
7
  "OD3_BDE_Article": "CORE",
8
+ "OD3_BDE_DisruptionReason": "BDE",
8
9
  "OD3_BDE_Form": "BDE",
9
10
  "OD3_BDE_List": "BDE",
10
11
  "OD3_BDE_ListEntry": "BDE",
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Normalises `equipment` and rejects equipment of another tenant.
3
+ *
4
+ * The column holds plain equipment ids, written directly: an article belongs to
5
+ * the equipment it is assigned to, and the frontend adds the descendants when
6
+ * it asks for "the parts of this machine" (a part of the gearbox is a part of
7
+ * the machine too). Nothing is stored for the ancestors, so moving equipment in
8
+ * the hierarchy needs no rewrite here.
9
+ *
10
+ * Only a changed column is judged, so an article that already carries a bad id
11
+ * stays saveable — the ABAS sync re-saves the whole catalogue and must not stop
12
+ * on it. Ids that match no equipment pass: they show as nothing and harm
13
+ * nothing, while refusing them would block every save after equipment is
14
+ * deleted for good.
15
+ *
16
+ * Articles without a tenant are shared catalogue entries; they may reference
17
+ * any equipment, like shared master data on a ticket.
18
+ */
19
+ export declare function assertArticleEquipment(object: Parse.Object): Promise<void>;
@@ -0,0 +1,53 @@
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.assertArticleEquipment = assertArticleEquipment;
7
+ // The equipment an article is a spare part of (`OD3_BDE_Article.equipment`).
8
+ const node_1 = __importDefault(require("parse/node"));
9
+ const openservice_shared_1 = require("@opendash/openservice-shared");
10
+ const index_js_1 = require("../../../types/index.js");
11
+ /**
12
+ * Normalises `equipment` and rejects equipment of another tenant.
13
+ *
14
+ * The column holds plain equipment ids, written directly: an article belongs to
15
+ * the equipment it is assigned to, and the frontend adds the descendants when
16
+ * it asks for "the parts of this machine" (a part of the gearbox is a part of
17
+ * the machine too). Nothing is stored for the ancestors, so moving equipment in
18
+ * the hierarchy needs no rewrite here.
19
+ *
20
+ * Only a changed column is judged, so an article that already carries a bad id
21
+ * stays saveable — the ABAS sync re-saves the whole catalogue and must not stop
22
+ * on it. Ids that match no equipment pass: they show as nothing and harm
23
+ * nothing, while refusing them would block every save after equipment is
24
+ * deleted for good.
25
+ *
26
+ * Articles without a tenant are shared catalogue entries; they may reference
27
+ * any equipment, like shared master data on a ticket.
28
+ */
29
+ async function assertArticleEquipment(object) {
30
+ if (!object.dirty("equipment"))
31
+ return;
32
+ const ids = [...new Set((0, openservice_shared_1.refIds)(object.get("equipment")))];
33
+ if (ids.length === 0) {
34
+ object.unset("equipment");
35
+ return;
36
+ }
37
+ object.set("equipment", ids);
38
+ const tenantId = object.get("tenant")?.id;
39
+ if (!tenantId)
40
+ return;
41
+ const rows = await new node_1.default.Query(index_js_1.Service_Equipment)
42
+ .containedIn("objectId", ids)
43
+ .select("tenant")
44
+ .limit(ids.length)
45
+ .find({ useMasterKey: true });
46
+ for (const row of rows) {
47
+ const refTenantId = row.get("tenant")?.id;
48
+ if (!refTenantId || refTenantId === tenantId)
49
+ continue;
50
+ throw new node_1.default.Error(node_1.default.Error.VALIDATION_ERROR, `Cannot assign equipment ${row.id} of tenant ${refTenantId} to an ` +
51
+ `article of tenant ${tenantId}.`);
52
+ }
53
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Whether stock has reached the reorder point: `stock <= minimumStock`.
3
+ *
4
+ * No reorder point (unset or 0) means no alert — every ABAS article carries
5
+ * `minimumStock: 0` from the schema default, and none of them is "running out".
6
+ * Uncounted stock reads as 0: a part with a reorder point and no count is one
7
+ * to look at.
8
+ */
9
+ export declare function stockAlertOf(stock: unknown, minimumStock: unknown): boolean;
10
+ /**
11
+ * Keeps `stockAlert` in step with `stock` and `minimumStock` on every save.
12
+ *
13
+ * A stored flag because a query cannot compare two columns: the article list
14
+ * filters on it ("Meldebestand erreicht"), and the reorder notification of
15
+ * "Lager light" will need it to fire once on the edge rather than on every
16
+ * save. Stock is still counted by hand — nothing books consumption yet — so
17
+ * the flag is as good as the last count.
18
+ */
19
+ export declare function applyStockAlert(object: Parse.Object): void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stockAlertOf = stockAlertOf;
4
+ exports.applyStockAlert = applyStockAlert;
5
+ /**
6
+ * Whether stock has reached the reorder point: `stock <= minimumStock`.
7
+ *
8
+ * No reorder point (unset or 0) means no alert — every ABAS article carries
9
+ * `minimumStock: 0` from the schema default, and none of them is "running out".
10
+ * Uncounted stock reads as 0: a part with a reorder point and no count is one
11
+ * to look at.
12
+ */
13
+ function stockAlertOf(stock, minimumStock) {
14
+ if (typeof minimumStock !== "number" || minimumStock <= 0)
15
+ return false;
16
+ return (typeof stock === "number" ? stock : 0) <= minimumStock;
17
+ }
18
+ /**
19
+ * Keeps `stockAlert` in step with `stock` and `minimumStock` on every save.
20
+ *
21
+ * A stored flag because a query cannot compare two columns: the article list
22
+ * filters on it ("Meldebestand erreicht"), and the reorder notification of
23
+ * "Lager light" will need it to fire once on the edge rather than on every
24
+ * save. Stock is still counted by hand — nothing books consumption yet — so
25
+ * the flag is as good as the last count.
26
+ */
27
+ function applyStockAlert(object) {
28
+ const alert = stockAlertOf(object.get("stock"), object.get("minimumStock"));
29
+ if (object.get("stockAlert") !== alert)
30
+ object.set("stockAlert", alert);
31
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The classes, most critical first. Mirrors `CRITICALITY_LEVELS` in
3
+ * `@opendash/plugin-openservice-core`.
4
+ */
5
+ export declare const CRITICALITY_LEVELS: readonly ["A", "B", "C"];
6
+ export type Criticality = (typeof CRITICALITY_LEVELS)[number];
7
+ /**
8
+ * What the priority formula reads under `criticality`: the classes on the
9
+ * 0–100 scale of the ticket's factors. Unclassified equipment, and a ticket
10
+ * without equipment, read 0 like class C — the factors' rule for an empty
11
+ * input. Mirrors `CRITICALITY_VALUES` of the core plugin.
12
+ */
13
+ export declare const CRITICALITY_VALUES: Record<Criticality, number>;
14
+ export declare function isCriticality(value: unknown): value is Criticality;
15
+ /**
16
+ * Normalises `criticality` on an equipment being saved: trimmed and
17
+ * upper-cased, empty unsets it (the equipment inherits again). Anything but
18
+ * A, B or C is refused.
19
+ */
20
+ export declare function normalizeCriticality(object: Parse.Object): void;
21
+ /**
22
+ * The class an equipment counts as: its own, else the nearest ancestor's;
23
+ * `undefined` when nobody up the tree classified it. Reads one row per level
24
+ * with the master key — the caller decides whose equipment it asks about.
25
+ * Guarded against a cycle in `parent`, which migrated data has had.
26
+ */
27
+ export declare function effectiveCriticality(equipment: Parse.Object | undefined): Promise<Criticality | undefined>;
28
+ /** The number the priority formula reads for a class. */
29
+ export declare function criticalityValue(criticality: Criticality | undefined): number;
@@ -0,0 +1,85 @@
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.CRITICALITY_VALUES = exports.CRITICALITY_LEVELS = void 0;
7
+ exports.isCriticality = isCriticality;
8
+ exports.normalizeCriticality = normalizeCriticality;
9
+ exports.effectiveCriticality = effectiveCriticality;
10
+ exports.criticalityValue = criticalityValue;
11
+ // How critical a piece of equipment is for production: A (stops it), B
12
+ // (hampers it), C (neither). Set where somebody classified it and inherited
13
+ // downwards: a gearbox without its own class counts as its machine does.
14
+ const node_1 = __importDefault(require("parse/node"));
15
+ const index_js_1 = require("../../../types/index.js");
16
+ /**
17
+ * The classes, most critical first. Mirrors `CRITICALITY_LEVELS` in
18
+ * `@opendash/plugin-openservice-core`.
19
+ */
20
+ exports.CRITICALITY_LEVELS = ["A", "B", "C"];
21
+ /**
22
+ * What the priority formula reads under `criticality`: the classes on the
23
+ * 0–100 scale of the ticket's factors. Unclassified equipment, and a ticket
24
+ * without equipment, read 0 like class C — the factors' rule for an empty
25
+ * input. Mirrors `CRITICALITY_VALUES` of the core plugin.
26
+ */
27
+ exports.CRITICALITY_VALUES = {
28
+ A: 100,
29
+ B: 50,
30
+ C: 0,
31
+ };
32
+ /** Further up than any real hierarchy; stops a walk through broken data. */
33
+ const MAX_DEPTH = 50;
34
+ function isCriticality(value) {
35
+ return (typeof value === "string" &&
36
+ exports.CRITICALITY_LEVELS.includes(value));
37
+ }
38
+ /**
39
+ * Normalises `criticality` on an equipment being saved: trimmed and
40
+ * upper-cased, empty unsets it (the equipment inherits again). Anything but
41
+ * A, B or C is refused.
42
+ */
43
+ function normalizeCriticality(object) {
44
+ const raw = object.get("criticality");
45
+ if (raw == null)
46
+ return;
47
+ const value = typeof raw === "string" ? raw.trim().toUpperCase() : raw;
48
+ if (value === "") {
49
+ object.unset("criticality");
50
+ return;
51
+ }
52
+ if (!isCriticality(value)) {
53
+ throw new node_1.default.Error(node_1.default.Error.VALIDATION_ERROR, `criticality must be one of ${exports.CRITICALITY_LEVELS.join(", ")}`);
54
+ }
55
+ if (value !== raw)
56
+ object.set("criticality", value);
57
+ }
58
+ /**
59
+ * The class an equipment counts as: its own, else the nearest ancestor's;
60
+ * `undefined` when nobody up the tree classified it. Reads one row per level
61
+ * with the master key — the caller decides whose equipment it asks about.
62
+ * Guarded against a cycle in `parent`, which migrated data has had.
63
+ */
64
+ async function effectiveCriticality(equipment) {
65
+ const seen = new Set();
66
+ let id = equipment?.id;
67
+ while (id && !seen.has(id) && seen.size < MAX_DEPTH) {
68
+ seen.add(id);
69
+ const row = await new node_1.default.Query(index_js_1.Service_Equipment)
70
+ .select("criticality", "parent")
71
+ .equalTo("objectId", id)
72
+ .first({ useMasterKey: true });
73
+ if (!row)
74
+ return undefined;
75
+ const own = row.get("criticality");
76
+ if (isCriticality(own))
77
+ return own;
78
+ id = row.get("parent")?.id;
79
+ }
80
+ return undefined;
81
+ }
82
+ /** The number the priority formula reads for a class. */
83
+ function criticalityValue(criticality) {
84
+ return criticality ? exports.CRITICALITY_VALUES[criticality] : 0;
85
+ }
@@ -1,11 +1,11 @@
1
1
  import type { FormulaNode } from "@opendash/ruleset-core";
2
2
  import type { Service_FormConfig } from "../../../types/index.js";
3
3
  /**
4
- * The fields a priority formula may read, e.g.
4
+ * The names a priority formula may read, e.g.
5
5
  * `max(downtime, restriction) * 0.7 + frequency * 0.3`. Mirrors
6
- * `SCALE_FIELD_KEYS` in `@opendash/plugin-openservice-ticket`.
6
+ * `PRIORITY_FORMULA_INPUTS` in `@opendash/plugin-openservice-ticket`.
7
7
  */
8
- export declare const PRIORITY_FORMULA_INPUTS: readonly ["downtime", "restriction", "frequency"];
8
+ export declare const PRIORITY_FORMULA_INPUTS: readonly ["downtime", "restriction", "frequency", "criticality"];
9
9
  interface PriorityFormula {
10
10
  expression: FormulaNode;
11
11
  names: string[];
@@ -21,28 +21,35 @@ export declare function priorityFormulaOf(config: Service_FormConfig | undefined
21
21
  * The priority for a ticket's values, or `undefined` when there is nothing to
22
22
  * compute from. Mirrors `computePriority` of the frontend:
23
23
  *
24
- * - None of the inputs the formula reads is set: `undefined`, so a ticket
25
- * nobody has assessed keeps its priority.
24
+ * - None of the scale fields the formula reads is set: `undefined`, so a
25
+ * ticket nobody has assessed keeps its priority. The equipment's
26
+ * criticality does not count here — it is known for every ticket on
27
+ * classified equipment, assessed or not.
26
28
  * - Some are set: the rest count as 0, the lowest level.
27
29
  * - Clamped to 0–100 and rounded; no number at all (division by zero) is
28
30
  * `undefined` as well.
29
31
  */
30
32
  export declare function computePriority(formula: PriorityFormula, values: (key: string) => unknown): number | undefined;
31
- /** Whether this save changes one of the inputs a priority formula reads. */
32
- export declare function changesPriorityInputs(object: Parse.Object, original: Parse.Object | undefined): boolean;
33
+ /**
34
+ * Whether this save changes one of the inputs a priority formula reads: a
35
+ * scale field, or the equipment — whose class the formula reads under
36
+ * `criticality`. Without `formula`, whether it may: the equipment counts
37
+ * whenever a formula could read it.
38
+ */
39
+ export declare function changesPriorityInputs(object: Parse.Object, original: Parse.Object | undefined, formula?: PriorityFormula): boolean;
33
40
  /**
34
41
  * Sets the computed priority on a ticket being saved, under `config` — the
35
42
  * form config that applies to the user saving (see `applicableFormConfig`).
36
43
  *
37
44
  * Only when this save changes one of the inputs — a ticket the save does not
38
- * reassess keeps its priority, also when the formula has changed since — and
39
- * only when the caller does not set the priority itself in the same save: an
40
- * import keeps the priority its file states.
45
+ * reassess keeps its priority, also when the formula has changed since, or the
46
+ * class of its equipment — and only when the caller does not set the priority
47
+ * itself in the same save: an import keeps the priority its file states.
41
48
  *
42
49
  * "Changes" and "sets" are judged against `original`. The admin table sends
43
50
  * every field of its form, the unchanged priority included; counting that as
44
51
  * set by hand would leave the old priority after every factor edit there —
45
52
  * which is the case this exists for.
46
53
  */
47
- export declare function applyComputedPriority(object: Parse.Object, original: Parse.Object | undefined, config: Service_FormConfig | undefined): void;
54
+ export declare function applyComputedPriority(object: Parse.Object, original: Parse.Object | undefined, config: Service_FormConfig | undefined): Promise<void>;
48
55
  export {};
@@ -6,15 +6,26 @@ exports.computePriority = computePriority;
6
6
  exports.changesPriorityInputs = changesPriorityInputs;
7
7
  exports.applyComputedPriority = applyComputedPriority;
8
8
  const ruleset_core_1 = require("@opendash/ruleset-core");
9
+ const criticality_js_1 = require("../equipment/criticality.js");
9
10
  /**
10
- * The fields a priority formula may read, e.g.
11
+ * The ticket's own assessment: the scale fields. Mirrors `SCALE_FIELD_KEYS` in
12
+ * `@opendash/plugin-openservice-ticket`.
13
+ */
14
+ const ASSESSMENT_INPUTS = ["downtime", "restriction", "frequency"];
15
+ /**
16
+ * The equipment's class (A 100, B 50, C or none 0), inherited down the tree —
17
+ * see `criticality.ts`. Context, not an assessment: it alone never makes a
18
+ * ticket "assessed" (see {@link computePriority}).
19
+ */
20
+ const CRITICALITY_INPUT = "criticality";
21
+ /**
22
+ * The names a priority formula may read, e.g.
11
23
  * `max(downtime, restriction) * 0.7 + frequency * 0.3`. Mirrors
12
- * `SCALE_FIELD_KEYS` in `@opendash/plugin-openservice-ticket`.
24
+ * `PRIORITY_FORMULA_INPUTS` in `@opendash/plugin-openservice-ticket`.
13
25
  */
14
26
  exports.PRIORITY_FORMULA_INPUTS = [
15
- "downtime",
16
- "restriction",
17
- "frequency",
27
+ ...ASSESSMENT_INPUTS,
28
+ CRITICALITY_INPUT,
18
29
  ];
19
30
  /**
20
31
  * The formula a config's priority entry asks for, or `undefined` when the
@@ -49,8 +60,10 @@ function asNumber(value) {
49
60
  * The priority for a ticket's values, or `undefined` when there is nothing to
50
61
  * compute from. Mirrors `computePriority` of the frontend:
51
62
  *
52
- * - None of the inputs the formula reads is set: `undefined`, so a ticket
53
- * nobody has assessed keeps its priority.
63
+ * - None of the scale fields the formula reads is set: `undefined`, so a
64
+ * ticket nobody has assessed keeps its priority. The equipment's
65
+ * criticality does not count here — it is known for every ticket on
66
+ * classified equipment, assessed or not.
54
67
  * - Some are set: the rest count as 0, the lowest level.
55
68
  * - Clamped to 0–100 and rounded; no number at all (division by zero) is
56
69
  * `undefined` as well.
@@ -60,7 +73,7 @@ function computePriority(formula, values) {
60
73
  let anySet = false;
61
74
  for (const name of formula.names) {
62
75
  const value = asNumber(values(name));
63
- if (value !== undefined)
76
+ if (value !== undefined && name !== CRITICALITY_INPUT)
64
77
  anySet = true;
65
78
  scope[name] = value ?? 0;
66
79
  }
@@ -77,33 +90,54 @@ function changes(object, original, key) {
77
90
  ? object.get(key) !== original.get(key)
78
91
  : object.get(key) != null;
79
92
  }
80
- /** Whether this save changes one of the inputs a priority formula reads. */
81
- function changesPriorityInputs(object, original) {
82
- return exports.PRIORITY_FORMULA_INPUTS.some((key) => changes(object, original, key));
93
+ /**
94
+ * Whether this save moves the ticket to other equipment. Compared by id: a
95
+ * pointer comes back as a new object on every read.
96
+ */
97
+ function changesEquipment(object, original) {
98
+ const id = (o) => o?.get("equipment")?.id;
99
+ return original ? id(object) !== id(original) : id(object) != null;
100
+ }
101
+ /**
102
+ * Whether this save changes one of the inputs a priority formula reads: a
103
+ * scale field, or the equipment — whose class the formula reads under
104
+ * `criticality`. Without `formula`, whether it may: the equipment counts
105
+ * whenever a formula could read it.
106
+ */
107
+ function changesPriorityInputs(object, original, formula) {
108
+ if (ASSESSMENT_INPUTS.some((key) => changes(object, original, key)))
109
+ return true;
110
+ const readsCriticality = formula
111
+ ? formula.names.includes(CRITICALITY_INPUT)
112
+ : true;
113
+ return readsCriticality && changesEquipment(object, original);
83
114
  }
84
115
  /**
85
116
  * Sets the computed priority on a ticket being saved, under `config` — the
86
117
  * form config that applies to the user saving (see `applicableFormConfig`).
87
118
  *
88
119
  * Only when this save changes one of the inputs — a ticket the save does not
89
- * reassess keeps its priority, also when the formula has changed since — and
90
- * only when the caller does not set the priority itself in the same save: an
91
- * import keeps the priority its file states.
120
+ * reassess keeps its priority, also when the formula has changed since, or the
121
+ * class of its equipment — and only when the caller does not set the priority
122
+ * itself in the same save: an import keeps the priority its file states.
92
123
  *
93
124
  * "Changes" and "sets" are judged against `original`. The admin table sends
94
125
  * every field of its form, the unchanged priority included; counting that as
95
126
  * set by hand would leave the old priority after every factor edit there —
96
127
  * which is the case this exists for.
97
128
  */
98
- function applyComputedPriority(object, original, config) {
99
- if (!changesPriorityInputs(object, original))
100
- return;
101
- if (changes(object, original, "priority"))
102
- return;
129
+ async function applyComputedPriority(object, original, config) {
103
130
  const formula = priorityFormulaOf(config);
104
131
  if (!formula)
105
132
  return;
106
- const priority = computePriority(formula, (key) => object.get(key));
133
+ if (!changesPriorityInputs(object, original, formula))
134
+ return;
135
+ if (changes(object, original, "priority"))
136
+ return;
137
+ const criticality = formula.names.includes(CRITICALITY_INPUT)
138
+ ? (0, criticality_js_1.criticalityValue)(await (0, criticality_js_1.effectiveCriticality)(object.get("equipment")))
139
+ : undefined;
140
+ const priority = computePriority(formula, (key) => key === CRITICALITY_INPUT ? criticality : object.get(key));
107
141
  if (priority !== undefined)
108
142
  object.set("priority", priority);
109
143
  }
@@ -227,7 +227,7 @@ async function applyFormConfigRules(object, original, user, { master, sessionTok
227
227
  master,
228
228
  sessionToken,
229
229
  })) ?? (await (0, ticketFormConfig_js_1.applicableFormConfig)(tenant, user));
230
- (0, ticketPriority_js_1.applyComputedPriority)(object, original, config);
230
+ await (0, ticketPriority_js_1.applyComputedPriority)(object, original, config);
231
231
  if (!runRules || !config)
232
232
  return;
233
233
  applyValueRules(parseJson(config.fields), object, original, new Date());
@@ -189,8 +189,17 @@ exports.INDEXES = [
189
189
  // Work orders of an order plan (MES order view).
190
190
  od_orderPlan: ["orderPlan"],
191
191
  }),
192
+ // Reasons of a tenant, and the unique-key check of their hook.
193
+ defineIndexes(index_js_1.BDE_DisruptionReason, {
194
+ od_tenant_key: ["tenant", "key"],
195
+ }),
192
196
  defineIndexes(index_js_1.BDE_Article, {
193
197
  od_articleNumber: ["articleNumber"],
198
+ // Spare parts of an equipment subtree (`equipment` contained in the ids):
199
+ // the material picker and the equipment page.
200
+ od_equipment: ["equipment"],
201
+ // "Meldebestand erreicht": the article list filters on it.
202
+ od_stockAlert: ["stockAlert"],
194
203
  }),
195
204
  // --- MES ---
196
205
  // A cron job reads the last day's orders every minute.
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.init = init;
4
4
  const index_js_1 = require("../features/schema/index.js");
5
+ const articleEquipment_js_1 = require("../features/openservice/articles/articleEquipment.js");
6
+ const articleStock_js_1 = require("../features/openservice/articles/articleStock.js");
5
7
  const index_js_2 = require("../types/index.js");
6
8
  async function init() {
7
9
  // Soft delete: articles are referenced from a ticket's `material` list and
@@ -35,7 +37,9 @@ async function init() {
35
37
  allowCustomACL: true,
36
38
  allowTenantUserWrite: true,
37
39
  });
38
- // TODO
40
+ // After `defaultHandler`, which settles the tenant the check compares with.
41
+ await (0, articleEquipment_js_1.assertArticleEquipment)(object);
42
+ (0, articleStock_js_1.applyStockAlert)(object);
39
43
  });
40
44
  (0, index_js_1.afterSaveHook)(index_js_2.BDE_Article, async (request) => {
41
45
  const { object, original, user } = request;
@@ -0,0 +1 @@
1
+ export declare function init(): Promise<void>;
@@ -0,0 +1,70 @@
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 index_js_1 = require("../features/schema/index.js");
9
+ const index_js_2 = require("../types/index.js");
10
+ /** Longest key accepted — it is stored on every disruption booking. */
11
+ const MAX_KEY_LENGTH = 64;
12
+ async function init() {
13
+ // The reasons a BDE disruption is reported with. A reported disruption
14
+ // stores the reason's `key` in `OD3_BDE_WorkTime.comment`, and instances map
15
+ // it on — Künne sends `externalCode` to ABAS as `sgrund`. So the key is
16
+ // fixed once saved, unique per tenant, and a reason in use is deactivated
17
+ // (`active: false`) rather than deleted.
18
+ //
19
+ // Read by every user of the tenant (the disruption dialog offers them),
20
+ // written by the creator and tenant admins; further editors are granted in
21
+ // the BDE admin's permission dialog, so a custom ACL is kept.
22
+ (0, index_js_1.beforeSaveHook)(index_js_2.BDE_DisruptionReason, async (request) => {
23
+ const { object, original, master } = request;
24
+ await (0, index_js_1.defaultHandler)(request);
25
+ await (0, index_js_1.defaultAclHandler)(request, { allowCustomACL: true });
26
+ const key = String(object.get("key") ?? "").trim();
27
+ if (!key || key.length > MAX_KEY_LENGTH || /\s/.test(key)) {
28
+ throw new node_1.default.Error(node_1.default.Error.VALIDATION_ERROR, `A disruption reason needs a key of 1–${MAX_KEY_LENGTH} characters ` +
29
+ `without spaces.`);
30
+ }
31
+ if (original && original.get("key") !== key && !master) {
32
+ throw new node_1.default.Error(node_1.default.Error.VALIDATION_ERROR, "The key of a disruption reason cannot be changed: bookings store it.");
33
+ }
34
+ object.set("key", key);
35
+ const label = String(object.get("label") ?? "").trim();
36
+ if (!label) {
37
+ throw new node_1.default.Error(node_1.default.Error.VALIDATION_ERROR, "A disruption reason needs a label.");
38
+ }
39
+ object.set("label", label);
40
+ if (!object.isNew() && !object.dirty("key"))
41
+ return;
42
+ const duplicate = new node_1.default.Query(index_js_2.BDE_DisruptionReason).equalTo("key", key);
43
+ const tenant = object.get("tenant");
44
+ if (tenant)
45
+ duplicate.equalTo("tenant", tenant);
46
+ else
47
+ duplicate.doesNotExist("tenant");
48
+ if (object.id)
49
+ duplicate.notEqualTo("objectId", object.id);
50
+ if (await duplicate.first({ useMasterKey: true })) {
51
+ throw new node_1.default.Error(node_1.default.Error.DUPLICATE_VALUE, `There is already a disruption reason with the key "${key}".`);
52
+ }
53
+ });
54
+ (0, index_js_1.beforeDeleteHook)(index_js_2.BDE_DisruptionReason, async (request) => {
55
+ const { object } = request;
56
+ const key = object.get("key");
57
+ if (!key)
58
+ return;
59
+ const inUse = new node_1.default.Query(index_js_2.BDE_WorkTime)
60
+ .equalTo("status", "disrupted")
61
+ .equalTo("comment", key);
62
+ const tenant = object.get("tenant");
63
+ if (tenant)
64
+ inUse.equalTo("tenant", tenant);
65
+ if (await inUse.first({ useMasterKey: true })) {
66
+ throw new node_1.default.Error(node_1.default.Error.VALIDATION_ERROR, `The disruption reason "${key}" is used by bookings — deactivate it ` +
67
+ `instead of deleting it.`);
68
+ }
69
+ });
70
+ }
@@ -7,6 +7,7 @@ exports.init = init;
7
7
  const node_1 = __importDefault(require("parse/node"));
8
8
  const openservice_shared_1 = require("@opendash/openservice-shared");
9
9
  const index_js_1 = require("../features/schema/index.js");
10
+ const criticality_js_1 = require("../features/openservice/equipment/criticality.js");
10
11
  const index_js_2 = require("../features/permissions/index.js");
11
12
  const Permissions_js_1 = require("../features/permissions/types/Permissions.js");
12
13
  const ticketSortKeys_js_1 = require("../helper/ticketSortKeys.js");
@@ -37,6 +38,8 @@ async function init() {
37
38
  Boolean(object.get("deleted")) !== Boolean(original.get("deleted"))) {
38
39
  await (0, index_js_2.requirePermission)(request, Permissions_js_1.Permissions.SERVICE.masterdata_manage, "archive equipment");
39
40
  }
41
+ // A, B, C or unset (inherits from the parent) — see `criticality.ts`.
42
+ (0, criticality_js_1.normalizeCriticality)(object);
40
43
  await (0, index_js_1.defaultHandler)(request);
41
44
  await (0, index_js_1.defaultAclHandler)(request);
42
45
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
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
+ const node_1 = __importDefault(require("parse/node"));
7
+ const articleStock_js_1 = require("../features/openservice/articles/articleStock.js");
8
+ const index_js_1 = require("../types/index.js");
9
+ /**
10
+ * One-off backfill for `OD3_BDE_Article.stockAlert`.
11
+ *
12
+ * From here on the article hook keeps the flag in step with `stock` and
13
+ * `minimumStock`, but it only sees writes — an article saved before the flag
14
+ * existed is missing from the "Meldebestand erreicht" filter until someone
15
+ * touches it. This sets the flag where it is wrong or missing.
16
+ *
17
+ * PARSE_URL=… PARSE_APP_ID=… PARSE_MASTER_KEY=… \
18
+ * node dist/scripts/backfill-stock-alert.js [--dry-run]
19
+ *
20
+ * Reads every article, but writes only the ones whose flag differs. The re-save
21
+ * writes no changelog entry (`skipChangelog`) — the flag is derived, not an
22
+ * edit. Safe to re-run.
23
+ */
24
+ const BATCH_SIZE = 500;
25
+ function requireEnv(name) {
26
+ const value = process.env[name];
27
+ if (!value) {
28
+ console.error(`Missing required environment variable ${name}.`);
29
+ process.exit(1);
30
+ }
31
+ return value;
32
+ }
33
+ /** Iterate the articles in `createdAt` order, page by page. */
34
+ async function* pages() {
35
+ let after;
36
+ for (;;) {
37
+ const query = new node_1.default.Query(index_js_1.BDE_Article)
38
+ .select("stock", "minimumStock", "stockAlert")
39
+ .ascending("createdAt")
40
+ .limit(BATCH_SIZE);
41
+ // `createdAt` is not part of the generic attribute map, hence the cast.
42
+ if (after)
43
+ query.greaterThan("createdAt", after);
44
+ // Archived articles too, so un-archiving brings back a right flag. A query
45
+ // that constrains `isDeleted` gets past `hideSoftDeleted`.
46
+ query.containedIn("isDeleted", [true, false]);
47
+ const results = await query.find({ useMasterKey: true });
48
+ if (results.length === 0)
49
+ return;
50
+ yield results;
51
+ after = results[results.length - 1].createdAt;
52
+ if (results.length < BATCH_SIZE)
53
+ return;
54
+ }
55
+ }
56
+ async function main() {
57
+ const dryRun = process.argv.includes("--dry-run");
58
+ node_1.default.initialize(requireEnv("PARSE_APP_ID"), undefined, requireEnv("PARSE_MASTER_KEY"));
59
+ node_1.default.serverURL =
60
+ process.env.PARSE_URL ?? "http://localhost:1337/parse";
61
+ let scanned = 0;
62
+ let changed = 0;
63
+ let alerts = 0;
64
+ for await (const page of pages()) {
65
+ for (const article of page) {
66
+ scanned++;
67
+ const expected = (0, articleStock_js_1.stockAlertOf)(article.get("stock"), article.get("minimumStock"));
68
+ if (expected)
69
+ alerts++;
70
+ if (article.get("stockAlert") === expected)
71
+ continue;
72
+ changed++;
73
+ if (dryRun)
74
+ continue;
75
+ article.set("stockAlert", expected);
76
+ await article.save(null, {
77
+ useMasterKey: true,
78
+ context: { skipChangelog: true },
79
+ });
80
+ }
81
+ }
82
+ console.log(`${dryRun ? "[dry run] " : ""}scanned ${scanned} articles, ` +
83
+ `${changed} flag(s) ${dryRun ? "to set" : "set"}, ` +
84
+ `${alerts} at or below the reorder point`);
85
+ }
86
+ main().catch((error) => {
87
+ console.error(error);
88
+ process.exit(1);
89
+ });
@@ -14,8 +14,12 @@ import type { MigrationConfig } from "./env.js";
14
14
  * Pass 05 therefore writes those to the columns now, and only what still has no
15
15
  * home stays here: v1's `category` — deliberately never given a column, since
16
16
  * tags and `type` already classify and a third such field goes stale — v1's
17
- * `description` (the label column is taken by v1's `name`), and the `Source`
18
- * links behind `Item.sources`.
17
+ * `description` (the label column is taken by v1's `name`).
18
+ *
19
+ * **Equipment moved to a column on 2026-11-17.** The links behind
20
+ * `Item.sources` became `OD3_BDE_Article.equipment`, which the material picker
21
+ * and the equipment page read. Pass 05 writes them there and strips the old
22
+ * meta key.
19
23
  *
20
24
  * ⚠️ The ABAS sync still owns the columns it writes and replaces them on every
21
25
  * run. It does not touch the stock-keeping ones today — if that changes, they
@@ -42,7 +46,7 @@ export declare const ARTICLE_META_CONTEXT: string[];
42
46
  * once in the article form, once under *Kopfdaten*. Listed here rather than in
43
47
  * the pass because it is a statement about this context's history.
44
48
  */
45
- export declare const META_KEYS_NOW_COLUMNS: readonly ["price", "stock", "stockAlarmAt", "stockUnit", "storageLocation", "supplier", "orderNumber"];
49
+ export declare const META_KEYS_NOW_COLUMNS: readonly ["price", "stock", "stockAlarmAt", "stockUnit", "storageLocation", "supplier", "orderNumber", "equipment"];
46
50
  /**
47
51
  * The field definitions written to the shared `Meta_Config`.
48
52
  *
@@ -27,8 +27,12 @@ const pass_js_1 = require("./pass.js");
27
27
  * Pass 05 therefore writes those to the columns now, and only what still has no
28
28
  * home stays here: v1's `category` — deliberately never given a column, since
29
29
  * tags and `type` already classify and a third such field goes stale — v1's
30
- * `description` (the label column is taken by v1's `name`), and the `Source`
31
- * links behind `Item.sources`.
30
+ * `description` (the label column is taken by v1's `name`).
31
+ *
32
+ * **Equipment moved to a column on 2026-11-17.** The links behind
33
+ * `Item.sources` became `OD3_BDE_Article.equipment`, which the material picker
34
+ * and the equipment page read. Pass 05 writes them there and strips the old
35
+ * meta key.
32
36
  *
33
37
  * ⚠️ The ABAS sync still owns the columns it writes and replaces them on every
34
38
  * run. It does not touch the stock-keeping ones today — if that changes, they
@@ -63,6 +67,8 @@ exports.META_KEYS_NOW_COLUMNS = [
63
67
  "storageLocation",
64
68
  "supplier",
65
69
  "orderNumber",
70
+ // Since 2026-11-17 (`OD3_BDE_Article.equipment`).
71
+ "equipment",
66
72
  ];
67
73
  /**
68
74
  * The field definitions written to the shared `Meta_Config`.
@@ -75,14 +81,6 @@ exports.META_KEYS_NOW_COLUMNS = [
75
81
  exports.ARTICLE_META_FIELDS = [
76
82
  { type: "string", name: "category", label: "Kategorie" },
77
83
  { type: "string", name: "notes", label: "Beschreibung (v1)" },
78
- {
79
- type: "select_parse",
80
- name: "equipment",
81
- label: "Equipment",
82
- className: "OD3_Service_Equipment",
83
- display: "label",
84
- multiple: true,
85
- },
86
84
  ];
87
85
  /**
88
86
  * v1 stores `price` as a String, and these are German-language instances.
@@ -16,10 +16,14 @@ import { type Pass } from "../lib/pass.js";
16
16
  *
17
17
  * **What still has no column stays meta** under `["service","article","meta"]`:
18
18
  * v1's `category` — deliberately never given a column, since tags and `type`
19
- * already classify and a third such field goes stale — v1's `description`, for
20
- * which the label column is taken by v1's `name`, and the equipment links behind
21
- * `Item.sources`. Nothing is dropped. See `lib/articleMeta.ts` for why that
22
- * context and not the ABAS one.
19
+ * already classify and a third such field goes stale — and v1's `description`,
20
+ * for which the label column is taken by v1's `name`. Nothing is dropped. See
21
+ * `lib/articleMeta.ts` for why that context and not the ABAS one.
22
+ *
23
+ * **The equipment links behind `Item.sources` go to `equipment`** since
24
+ * 2026-11-17, the column the material picker and the equipment page read. An
25
+ * entry from an earlier run loses its meta `equipment` key the same way as the
26
+ * stock-keeping ones.
23
27
  *
24
28
  * Two naming traps, both inherited from BDE: the label column is `description`,
25
29
  * not `name`; and the soft-delete flag is `isDeleted`, not `deleted`.
@@ -8,6 +8,7 @@ const node_1 = __importDefault(require("parse/node"));
8
8
  const index_js_1 = require("../../../types/index.js");
9
9
  const acl_js_1 = require("../lib/acl.js");
10
10
  const articleMeta_js_1 = require("../lib/articleMeta.js");
11
+ const articleStock_js_1 = require("../../../features/openservice/articles/articleStock.js");
11
12
  const latest_js_1 = require("../lib/latest.js");
12
13
  const map_js_1 = require("../lib/map.js");
13
14
  const ptr_js_1 = require("../lib/ptr.js");
@@ -38,10 +39,14 @@ const ARTICLE_TYPE_SPARE_PART = "spare_part";
38
39
  *
39
40
  * **What still has no column stays meta** under `["service","article","meta"]`:
40
41
  * v1's `category` — deliberately never given a column, since tags and `type`
41
- * already classify and a third such field goes stale — v1's `description`, for
42
- * which the label column is taken by v1's `name`, and the equipment links behind
43
- * `Item.sources`. Nothing is dropped. See `lib/articleMeta.ts` for why that
44
- * context and not the ABAS one.
42
+ * already classify and a third such field goes stale — and v1's `description`,
43
+ * for which the label column is taken by v1's `name`. Nothing is dropped. See
44
+ * `lib/articleMeta.ts` for why that context and not the ABAS one.
45
+ *
46
+ * **The equipment links behind `Item.sources` go to `equipment`** since
47
+ * 2026-11-17, the column the material picker and the equipment page read. An
48
+ * entry from an earlier run loses its meta `equipment` key the same way as the
49
+ * stock-keeping ones.
45
50
  *
46
51
  * Two naming traps, both inherited from BDE: the label column is `description`,
47
52
  * not `name`; and the soft-delete flag is `isDeleted`, not `deleted`.
@@ -110,6 +115,13 @@ exports.pass05 = {
110
115
  if (typeof value === "number")
111
116
  target.set(to, value);
112
117
  }
118
+ // The reorder flag, set here as well as in the article hook: the
119
+ // migration's saves are not guaranteed to run it. Only where v1 had a
120
+ // reorder point — otherwise a re-run would clear a flag set since.
121
+ const reorderPoint = item.get("stockAlarmAt");
122
+ if (typeof reorderPoint === "number") {
123
+ target.set("stockAlert", (0, articleStock_js_1.stockAlertOf)(item.get("stock"), reorderPoint));
124
+ }
113
125
  // v1 stored price as a free-form string; keep the number, report the rest
114
126
  // rather than silently discarding it.
115
127
  //
@@ -154,8 +166,12 @@ exports.pass05 = {
154
166
  `Equipment (not referenced by a ticket? see D3)`);
155
167
  }
156
168
  }
169
+ // A column since 2026-11-17. Set on every run, so a re-run also clears
170
+ // links that are gone in v1.
157
171
  if (equipmentIds.length)
158
- metaValues.equipment = equipmentIds;
172
+ target.set("equipment", equipmentIds);
173
+ else if (existingId)
174
+ target.unset("equipment");
159
175
  if (!existingId) {
160
176
  target.setACL((0, acl_js_1.migrationAcl)({ tenantId, allowTenantUserWrite: true }));
161
177
  }
@@ -186,8 +202,9 @@ exports.pass05 = {
186
202
  // Meta last: it needs the article id, and an entry with no values is
187
203
  // not worth a row.
188
204
  const existingMeta = metaByArticle.get(newId);
189
- // An entry written before 2026-09-25 still carries the stock-keeping
190
- // values that are columns now. Keep whatever else it holds, drop those.
205
+ // An entry from an earlier run still carries values that are columns
206
+ // now (stock keeping since 2026-09-25, equipment since 2026-11-17).
207
+ // Keep whatever else it holds, drop those.
191
208
  const carried = {
192
209
  ...(existingMeta?.get("values") ?? {}),
193
210
  };
@@ -253,13 +270,13 @@ exports.pass05 = {
253
270
  }
254
271
  }
255
272
  if (withMeta > 0) {
256
- report.info(entry, `${withMeta} article(s) carry category, v1 description or equipment ` +
257
- `links as meta under ["service","article","meta"] — stock keeping is ` +
258
- `on the article itself`);
273
+ report.info(entry, `${withMeta} article(s) carry category or v1 description as meta ` +
274
+ `under ["service","article","meta"] — stock keeping and equipment ` +
275
+ `are on the article itself`);
259
276
  }
260
277
  if (legacyStripped > 0) {
261
- report.info(entry, `${legacyStripped} meta entr(ies) from a run before 2026-09-25 had ` +
262
- `their stock-keeping values stripped — those are columns now; ` +
278
+ report.info(entry, `${legacyStripped} meta entr(ies) from an earlier run had their ` +
279
+ `stock-keeping or equipment values stripped — those are columns now; ` +
263
280
  `${legacyRemoved} entr(ies) held nothing else and were removed`);
264
281
  }
265
282
  if (unparseablePrices > 0) {
@@ -7,6 +7,7 @@ export interface BDE_ArticleAttributes {
7
7
  updatedAt: Date;
8
8
  articleNumber?: string | undefined;
9
9
  description?: string | undefined;
10
+ equipment?: string[] | undefined;
10
11
  isDeleted: boolean;
11
12
  minimumStock: number;
12
13
  orderNumber?: string | undefined;
@@ -14,6 +15,7 @@ export interface BDE_ArticleAttributes {
14
15
  price: number;
15
16
  priceCurrency?: string | undefined;
16
17
  stock: number;
18
+ stockAlert: boolean;
17
19
  storageLocation?: string | undefined;
18
20
  supplier?: string | undefined;
19
21
  targettime: number;
@@ -28,6 +30,8 @@ export declare class BDE_Article extends Parse.Object<BDE_ArticleAttributes> {
28
30
  set articleNumber(value: string | undefined);
29
31
  get description(): string | undefined;
30
32
  set description(value: string | undefined);
33
+ get equipment(): string[] | undefined;
34
+ set equipment(value: string[] | undefined);
31
35
  get isDeleted(): boolean;
32
36
  set isDeleted(value: boolean);
33
37
  get minimumStock(): number;
@@ -42,6 +46,8 @@ export declare class BDE_Article extends Parse.Object<BDE_ArticleAttributes> {
42
46
  set priceCurrency(value: string | undefined);
43
47
  get stock(): number;
44
48
  set stock(value: number);
49
+ get stockAlert(): boolean;
50
+ set stockAlert(value: boolean);
45
51
  get storageLocation(): string | undefined;
46
52
  set storageLocation(value: string | undefined);
47
53
  get supplier(): string | undefined;
@@ -22,6 +22,12 @@ class BDE_Article extends node_1.default.Object {
22
22
  set description(value) {
23
23
  super.set("description", value);
24
24
  }
25
+ get equipment() {
26
+ return super.get("equipment");
27
+ }
28
+ set equipment(value) {
29
+ super.set("equipment", value);
30
+ }
25
31
  get isDeleted() {
26
32
  return super.get("isDeleted");
27
33
  }
@@ -64,6 +70,12 @@ class BDE_Article extends node_1.default.Object {
64
70
  set stock(value) {
65
71
  super.set("stock", value);
66
72
  }
73
+ get stockAlert() {
74
+ return super.get("stockAlert");
75
+ }
76
+ set stockAlert(value) {
77
+ super.set("stockAlert", value);
78
+ }
67
79
  get storageLocation() {
68
80
  return super.get("storageLocation");
69
81
  }
@@ -0,0 +1,43 @@
1
+ import Parse from "parse/node";
2
+ import type { Source } from "./Source";
3
+ import type { Tenant } from "./Tenant";
4
+ import type { _User } from "./_User";
5
+ export interface BDE_DisruptionReasonAttributes {
6
+ id: string;
7
+ objectId: string;
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ active: boolean;
11
+ externalCode?: string | undefined;
12
+ key: string;
13
+ label: string;
14
+ order: number;
15
+ planned: boolean;
16
+ sources: Parse.Relation<BDE_DisruptionReason, Source>;
17
+ suggestTicket: boolean;
18
+ tenant?: Tenant | undefined;
19
+ user?: _User | undefined;
20
+ }
21
+ export declare class BDE_DisruptionReason extends Parse.Object<BDE_DisruptionReasonAttributes> {
22
+ static className: string;
23
+ constructor(data?: Partial<BDE_DisruptionReasonAttributes>);
24
+ get active(): boolean;
25
+ set active(value: boolean);
26
+ get externalCode(): string | undefined;
27
+ set externalCode(value: string | undefined);
28
+ get key(): string;
29
+ set key(value: string);
30
+ get label(): string;
31
+ set label(value: string);
32
+ get order(): number;
33
+ set order(value: number);
34
+ get planned(): boolean;
35
+ set planned(value: boolean);
36
+ get sources(): Parse.Relation<BDE_DisruptionReason, Source>;
37
+ get suggestTicket(): boolean;
38
+ set suggestTicket(value: boolean);
39
+ get tenant(): Tenant | undefined;
40
+ set tenant(value: Tenant | undefined);
41
+ get user(): _User | undefined;
42
+ set user(value: _User | undefined);
43
+ }
@@ -0,0 +1,72 @@
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.BDE_DisruptionReason = void 0;
7
+ const node_1 = __importDefault(require("parse/node"));
8
+ class BDE_DisruptionReason extends node_1.default.Object {
9
+ static className = "OD3_BDE_DisruptionReason";
10
+ constructor(data) {
11
+ super("OD3_BDE_DisruptionReason", data);
12
+ }
13
+ get active() {
14
+ return super.get("active");
15
+ }
16
+ set active(value) {
17
+ super.set("active", value);
18
+ }
19
+ get externalCode() {
20
+ return super.get("externalCode");
21
+ }
22
+ set externalCode(value) {
23
+ super.set("externalCode", value);
24
+ }
25
+ get key() {
26
+ return super.get("key");
27
+ }
28
+ set key(value) {
29
+ super.set("key", value);
30
+ }
31
+ get label() {
32
+ return super.get("label");
33
+ }
34
+ set label(value) {
35
+ super.set("label", value);
36
+ }
37
+ get order() {
38
+ return super.get("order");
39
+ }
40
+ set order(value) {
41
+ super.set("order", value);
42
+ }
43
+ get planned() {
44
+ return super.get("planned");
45
+ }
46
+ set planned(value) {
47
+ super.set("planned", value);
48
+ }
49
+ get sources() {
50
+ return super.relation("sources");
51
+ }
52
+ get suggestTicket() {
53
+ return super.get("suggestTicket");
54
+ }
55
+ set suggestTicket(value) {
56
+ super.set("suggestTicket", value);
57
+ }
58
+ get tenant() {
59
+ return super.get("tenant");
60
+ }
61
+ set tenant(value) {
62
+ super.set("tenant", value);
63
+ }
64
+ get user() {
65
+ return super.get("user");
66
+ }
67
+ set user(value) {
68
+ super.set("user", value);
69
+ }
70
+ }
71
+ exports.BDE_DisruptionReason = BDE_DisruptionReason;
72
+ node_1.default.Object.registerSubclass("OD3_BDE_DisruptionReason", BDE_DisruptionReason);
@@ -5,6 +5,7 @@ export interface Service_EquipmentAttributes {
5
5
  objectId: string;
6
6
  createdAt: Date;
7
7
  updatedAt: Date;
8
+ criticality?: string | undefined;
8
9
  deleted: boolean;
9
10
  label: string;
10
11
  parent?: Service_Equipment | undefined;
@@ -16,6 +17,8 @@ export interface Service_EquipmentAttributes {
16
17
  export declare class Service_Equipment extends Parse.Object<Service_EquipmentAttributes> {
17
18
  static className: string;
18
19
  constructor(data?: Partial<Service_EquipmentAttributes>);
20
+ get criticality(): string | undefined;
21
+ set criticality(value: string | undefined);
19
22
  get deleted(): boolean;
20
23
  set deleted(value: boolean);
21
24
  get label(): string;
@@ -10,6 +10,12 @@ class Service_Equipment extends node_1.default.Object {
10
10
  constructor(data) {
11
11
  super("OD3_Service_Equipment", data);
12
12
  }
13
+ get criticality() {
14
+ return super.get("criticality");
15
+ }
16
+ set criticality(value) {
17
+ super.set("criticality", value);
18
+ }
13
19
  get deleted() {
14
20
  return super.get("deleted");
15
21
  }
@@ -10,6 +10,8 @@ export { Attachment } from "./Attachment";
10
10
  export type { AttachmentAttributes } from "./Attachment";
11
11
  export { BDE_Article } from "./BDE_Article";
12
12
  export type { BDE_ArticleAttributes } from "./BDE_Article";
13
+ export { BDE_DisruptionReason } from "./BDE_DisruptionReason";
14
+ export type { BDE_DisruptionReasonAttributes } from "./BDE_DisruptionReason";
13
15
  export { BDE_Form } from "./BDE_Form";
14
16
  export type { BDE_FormAttributes } from "./BDE_Form";
15
17
  export { BDE_List } from "./BDE_List";
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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
- 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_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;
3
+ 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_DisruptionReason = exports.BDE_Article = exports.Attachment = exports.Assets = exports.AlarmWebhook = exports.AlarmAction = exports.Alarm = void 0;
4
+ 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 = exports.Language = 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 = exports.NavigationItem = 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");
@@ -15,6 +15,8 @@ var Attachment_1 = require("./Attachment");
15
15
  Object.defineProperty(exports, "Attachment", { enumerable: true, get: function () { return Attachment_1.Attachment; } });
16
16
  var BDE_Article_1 = require("./BDE_Article");
17
17
  Object.defineProperty(exports, "BDE_Article", { enumerable: true, get: function () { return BDE_Article_1.BDE_Article; } });
18
+ var BDE_DisruptionReason_1 = require("./BDE_DisruptionReason");
19
+ Object.defineProperty(exports, "BDE_DisruptionReason", { enumerable: true, get: function () { return BDE_DisruptionReason_1.BDE_DisruptionReason; } });
18
20
  var BDE_Form_1 = require("./BDE_Form");
19
21
  Object.defineProperty(exports, "BDE_Form", { enumerable: true, get: function () { return BDE_Form_1.BDE_Form; } });
20
22
  var BDE_List_1 = require("./BDE_List");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.36.0",
3
+ "version": "4.37.0",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@12.16.1",
6
6
  "keywords": [
@@ -68,6 +68,7 @@
68
68
  "migrate:verify": "node dist/scripts/migration/verify.js",
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
+ "backfill:stock-alert": "node dist/scripts/backfill-stock-alert.js",
71
72
  "repair:ticket-acl": "node dist/scripts/repair-ticket-acl.js",
72
73
  "test:integration": "node --test --test-concurrency=1 \"test/integration/**/*.test.mjs\"",
73
74
  "test:unit": "node --test \"test/unit/**/*.test.mjs\"",
@@ -8,6 +8,10 @@
8
8
  "type": "String",
9
9
  "required": false
10
10
  },
11
+ "equipment": {
12
+ "type": "Array",
13
+ "required": false
14
+ },
11
15
  "isDeleted": {
12
16
  "type": "Boolean",
13
17
  "required": false,
@@ -40,6 +44,11 @@
40
44
  "required": false,
41
45
  "defaultValue": 0
42
46
  },
47
+ "stockAlert": {
48
+ "type": "Boolean",
49
+ "required": false,
50
+ "defaultValue": false
51
+ },
43
52
  "storageLocation": {
44
53
  "type": "String",
45
54
  "required": false
@@ -0,0 +1,73 @@
1
+ {
2
+ "fields": {
3
+ "key": {
4
+ "type": "String",
5
+ "required": true
6
+ },
7
+ "label": {
8
+ "type": "String",
9
+ "required": true
10
+ },
11
+ "externalCode": {
12
+ "type": "String",
13
+ "required": false
14
+ },
15
+ "planned": {
16
+ "type": "Boolean",
17
+ "required": false,
18
+ "defaultValue": false
19
+ },
20
+ "suggestTicket": {
21
+ "type": "Boolean",
22
+ "required": false,
23
+ "defaultValue": false
24
+ },
25
+ "sources": {
26
+ "type": "Relation",
27
+ "targetClass": "{{PREFIX}}Source",
28
+ "required": false
29
+ },
30
+ "order": {
31
+ "type": "Number",
32
+ "required": false,
33
+ "defaultValue": 0
34
+ },
35
+ "active": {
36
+ "type": "Boolean",
37
+ "required": false,
38
+ "defaultValue": true
39
+ },
40
+ "tenant": {
41
+ "type": "Pointer",
42
+ "targetClass": "{{PREFIX}}Tenant",
43
+ "required": false
44
+ },
45
+ "user": {
46
+ "type": "Pointer",
47
+ "targetClass": "_User",
48
+ "required": false
49
+ }
50
+ },
51
+ "classLevelPermissions": {
52
+ "find": {
53
+ "requiresAuthentication": true
54
+ },
55
+ "count": {
56
+ "requiresAuthentication": true
57
+ },
58
+ "get": {
59
+ "requiresAuthentication": true
60
+ },
61
+ "create": {
62
+ "requiresAuthentication": true
63
+ },
64
+ "update": {
65
+ "requiresAuthentication": true
66
+ },
67
+ "delete": {
68
+ "requiresAuthentication": true
69
+ },
70
+ "addField": {},
71
+ "protectedFields": {}
72
+ }
73
+ }
@@ -5,6 +5,9 @@
5
5
  "required": true,
6
6
  "defaultValue": false
7
7
  },
8
+ "criticality": {
9
+ "type": "String"
10
+ },
8
11
  "label": {
9
12
  "type": "String",
10
13
  "required": true