@openinc/parse-server-opendash 4.32.6 → 4.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/openservice/demoSeed/demoData.d.ts +51 -0
- package/dist/features/openservice/demoSeed/demoData.js +305 -0
- package/dist/features/openservice/demoSeed/demoSeed.d.ts +82 -0
- package/dist/features/openservice/demoSeed/demoSeed.js +424 -0
- package/dist/features/openware/helper/mesSourceScope.d.ts +18 -0
- package/dist/features/openware/helper/mesSourceScope.js +144 -0
- package/dist/functions/openinc-openservice-demo-seed.d.ts +21 -0
- package/dist/functions/openinc-openservice-demo-seed.js +63 -0
- package/dist/hooks/BDE_WorkOrder.js +26 -1
- package/dist/hooks/MES_Order.js +12 -0
- package/dist/hooks/MES_OrderPlan.js +17 -0
- package/dist/hooks/Service_Schedule.js +3 -2
- package/dist/types/Service_Schedule.d.ts +0 -3
- package/dist/types/Service_Schedule.js +0 -6
- package/package.json +1 -1
- package/schema/BDE_ShiftException.json +10 -10
- package/schema/BDE_ShiftModel.json +7 -7
- package/schema/BDE_WorkOrder.json +6 -6
- package/schema/Chat_Message.json +6 -6
- package/schema/Core_RequestTemplate.json +33 -28
- package/schema/MES_RessourceOverview.json +74 -0
- package/schema/OWPlcDeviceTemplate.json +44 -0
- package/schema/RAG_Data.json +0 -5
- package/schema/Service_Schedule.json +0 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface DemoStep {
|
|
2
|
+
id: string;
|
|
3
|
+
order: number;
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface DemoCadence {
|
|
9
|
+
kind: "rrule" | "manual";
|
|
10
|
+
rrule?: string;
|
|
11
|
+
dtstart?: string;
|
|
12
|
+
timezone?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DemoSchedule {
|
|
15
|
+
title: string;
|
|
16
|
+
/** Index into {@link DEMO_MACHINES}. */
|
|
17
|
+
machine: number;
|
|
18
|
+
cadence: DemoCadence;
|
|
19
|
+
color?: string;
|
|
20
|
+
leadDays?: number;
|
|
21
|
+
graceDays?: number;
|
|
22
|
+
escalationAfterDays?: number;
|
|
23
|
+
pausedUntil?: Date;
|
|
24
|
+
origin?: string;
|
|
25
|
+
asset?: Record<string, unknown>;
|
|
26
|
+
/** Completed executions, in days ago, newest first. */
|
|
27
|
+
history: number[];
|
|
28
|
+
steps: DemoStep[];
|
|
29
|
+
}
|
|
30
|
+
export interface DemoTemplate {
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
cadence: DemoCadence;
|
|
34
|
+
steps: DemoStep[];
|
|
35
|
+
}
|
|
36
|
+
export declare const DEMO_HALL = "Halle B";
|
|
37
|
+
export declare const DEMO_MACHINES: string[];
|
|
38
|
+
declare const daysAgo: (n: number) => Date;
|
|
39
|
+
/**
|
|
40
|
+
* Built per call: step ids must be fresh, and every date is relative to now.
|
|
41
|
+
*
|
|
42
|
+
* `history` drives the executions and is what makes the forecast card show
|
|
43
|
+
* four different answers:
|
|
44
|
+
* - a steady rhythm → a date with high confidence
|
|
45
|
+
* - shrinking gaps → a date plus "intervals getting shorter"
|
|
46
|
+
* - erratic gaps → no date, "no dependable rhythm"
|
|
47
|
+
* - fewer than four → no date, "not enough history yet"
|
|
48
|
+
*/
|
|
49
|
+
export declare function demoSchedules(): DemoSchedule[];
|
|
50
|
+
export declare function demoTemplates(): DemoTemplate[];
|
|
51
|
+
export { daysAgo as demoDaysAgo };
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.demoDaysAgo = exports.DEMO_MACHINES = exports.DEMO_HALL = void 0;
|
|
4
|
+
exports.demoSchedules = demoSchedules;
|
|
5
|
+
exports.demoTemplates = demoTemplates;
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
7
|
+
/**
|
|
8
|
+
* The open.SERVICE demo data set: Halle B with five machines, ten plans, four
|
|
9
|
+
* templates and a completed history for each plan.
|
|
10
|
+
*
|
|
11
|
+
* The ten plans are not ten variations of the same plan. Each one exists to
|
|
12
|
+
* put a particular state on screen — every cadence kind the editor offers, an
|
|
13
|
+
* overdue plan, a paused one, one created by an alarm, and four different
|
|
14
|
+
* verdicts from the execution forecast (good, trending, unpredictable, not
|
|
15
|
+
* enough history). Every entry names its reason; if a plan stops earning its
|
|
16
|
+
* place, delete it rather than letting the list drift into noise.
|
|
17
|
+
*
|
|
18
|
+
* All dates are relative to *now*, so the data has to be re-seeded every few
|
|
19
|
+
* weeks to keep looking fresh — which is what the button on the setup page is
|
|
20
|
+
* for.
|
|
21
|
+
*
|
|
22
|
+
* Ported from `plugins/openservice-schedule/src/scripts/seed-testdata.mjs` in
|
|
23
|
+
* the opendash repo, which this replaces.
|
|
24
|
+
*/
|
|
25
|
+
const TIMEZONE = "Europe/Berlin";
|
|
26
|
+
exports.DEMO_HALL = "Halle B";
|
|
27
|
+
exports.DEMO_MACHINES = [
|
|
28
|
+
"CNC-04",
|
|
29
|
+
"Presse-A",
|
|
30
|
+
"Roboter R-12",
|
|
31
|
+
"Lackierkabine L-1",
|
|
32
|
+
"Kompressor K-3",
|
|
33
|
+
];
|
|
34
|
+
const [CNC, PRESSE, ROBOTER, LACK, KOMPRESSOR] = [0, 1, 2, 3, 4];
|
|
35
|
+
/**
|
|
36
|
+
* Stands in for an `OD3_Alarm.objectId` on the alarm-created plan. Fixed, so
|
|
37
|
+
* every seed produces the same `origin` marker — which is what the alarm dedup
|
|
38
|
+
* relies on.
|
|
39
|
+
*/
|
|
40
|
+
const DEMO_ALARM_ID = "seedAlarmK3";
|
|
41
|
+
// ── Date helpers ──────────────────────────────────────────────────────────────
|
|
42
|
+
const daysAgo = (n) => {
|
|
43
|
+
const d = new Date();
|
|
44
|
+
d.setDate(d.getDate() - n);
|
|
45
|
+
return d;
|
|
46
|
+
};
|
|
47
|
+
exports.demoDaysAgo = daysAgo;
|
|
48
|
+
const daysFromNow = (n) => daysAgo(-n);
|
|
49
|
+
/**
|
|
50
|
+
* `date` at `hour` o'clock Berlin wall time, as an ISO string with the offset
|
|
51
|
+
* that is actually in force on that day.
|
|
52
|
+
*
|
|
53
|
+
* The old script hard-coded `+02:00`, which put every anchor seeded in winter
|
|
54
|
+
* an hour early: the cadence keeps the *wall time* of its dtstart, and 06:00
|
|
55
|
+
* at +02:00 is 05:00 in CET.
|
|
56
|
+
*/
|
|
57
|
+
function berlinIso(date, hour) {
|
|
58
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
59
|
+
const y = date.getFullYear();
|
|
60
|
+
const m = pad(date.getMonth() + 1);
|
|
61
|
+
const d = pad(date.getDate());
|
|
62
|
+
// Noon UTC on that day is safely away from both DST switches (01:00 UTC).
|
|
63
|
+
const probe = new Date(`${y}-${m}-${d}T12:00:00Z`);
|
|
64
|
+
const name = new Intl.DateTimeFormat("en-US", {
|
|
65
|
+
timeZone: TIMEZONE,
|
|
66
|
+
timeZoneName: "longOffset",
|
|
67
|
+
})
|
|
68
|
+
.formatToParts(probe)
|
|
69
|
+
.find((part) => part.type === "timeZoneName")?.value ?? "GMT+01:00";
|
|
70
|
+
const offset = name === "GMT" ? "+00:00" : name.replace("GMT", "");
|
|
71
|
+
return `${y}-${m}-${d}T${pad(hour)}:00:00${offset}`;
|
|
72
|
+
}
|
|
73
|
+
/** A date ~6 weeks back on the given weekday (0 = Mon … 6 = Sun). */
|
|
74
|
+
function pastWeekday(weekdayMon0, hour) {
|
|
75
|
+
const d = daysAgo(42);
|
|
76
|
+
const jsTarget = weekdayMon0 === 6 ? 0 : weekdayMon0 + 1; // JS: 0 = Sun
|
|
77
|
+
while (d.getDay() !== jsTarget)
|
|
78
|
+
d.setDate(d.getDate() + 1);
|
|
79
|
+
return berlinIso(d, hour);
|
|
80
|
+
}
|
|
81
|
+
/** The 15th of the month two months back. */
|
|
82
|
+
function pastMonth15(hour) {
|
|
83
|
+
const d = new Date();
|
|
84
|
+
d.setDate(15);
|
|
85
|
+
d.setMonth(d.getMonth() - 2);
|
|
86
|
+
return berlinIso(d, hour);
|
|
87
|
+
}
|
|
88
|
+
const rrule = (rule, dtstart) => ({
|
|
89
|
+
kind: "rrule",
|
|
90
|
+
rrule: rule,
|
|
91
|
+
dtstart,
|
|
92
|
+
// Zoned like a plan created through the UI, so the plans keep their wall
|
|
93
|
+
// time across daylight saving instead of drifting by an hour.
|
|
94
|
+
timezone: TIMEZONE,
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* A work step. `required` steps block the sign-off, so every plan has at least
|
|
98
|
+
* one — an execution nobody can fail to complete tests nothing.
|
|
99
|
+
*/
|
|
100
|
+
const step = (order, title, description, required = false) => ({ id: (0, crypto_1.randomUUID)(), order, title, description, required });
|
|
101
|
+
// ── The data ─────────────────────────────────────────────────────────────────
|
|
102
|
+
/**
|
|
103
|
+
* Built per call: step ids must be fresh, and every date is relative to now.
|
|
104
|
+
*
|
|
105
|
+
* `history` drives the executions and is what makes the forecast card show
|
|
106
|
+
* four different answers:
|
|
107
|
+
* - a steady rhythm → a date with high confidence
|
|
108
|
+
* - shrinking gaps → a date plus "intervals getting shorter"
|
|
109
|
+
* - erratic gaps → no date, "no dependable rhythm"
|
|
110
|
+
* - fewer than four → no date, "not enough history yet"
|
|
111
|
+
*/
|
|
112
|
+
function demoSchedules() {
|
|
113
|
+
return [
|
|
114
|
+
{
|
|
115
|
+
// Steady weekly rhythm → the forecast's best case.
|
|
116
|
+
title: "CNC-04 — Spindel-Inspektion",
|
|
117
|
+
machine: CNC,
|
|
118
|
+
cadence: rrule("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO", pastWeekday(0, 6)),
|
|
119
|
+
color: "#7fbb47",
|
|
120
|
+
history: [2, 9, 16, 23, 30, 37],
|
|
121
|
+
steps: [
|
|
122
|
+
step(0, "Sichtprüfung", "Auf Beschädigungen und Leckagen prüfen.", true),
|
|
123
|
+
step(1, "Schmierung", "Schmiernippel abschmieren."),
|
|
124
|
+
step(2, "Lagerspiel messen", "Axiales/radiales Spiel prüfen.", true),
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
// Tolerance configured: actionable 2 days early, still "on time" 3 late.
|
|
129
|
+
title: "CNC-04 — Kühlmittel prüfen",
|
|
130
|
+
machine: CNC,
|
|
131
|
+
cadence: rrule("FREQ=WEEKLY;INTERVAL=2;BYDAY=WE", pastWeekday(2, 9)),
|
|
132
|
+
leadDays: 2,
|
|
133
|
+
graceDays: 3,
|
|
134
|
+
history: [4, 18, 32],
|
|
135
|
+
steps: [
|
|
136
|
+
step(0, "Konzentration messen", "Refraktometer, Sollwert 8 %.", true),
|
|
137
|
+
step(1, "Nachfüllen", "Bei Bedarf Emulsion ergänzen."),
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
// No rule at all. The forecast is the *only* hint about the next one,
|
|
142
|
+
// which is the case it was built for.
|
|
143
|
+
title: "CNC-04 — Werkzeugwechsel nach Bedarf",
|
|
144
|
+
machine: CNC,
|
|
145
|
+
cadence: { kind: "manual" },
|
|
146
|
+
history: [5, 26, 48, 69, 91],
|
|
147
|
+
steps: [
|
|
148
|
+
step(0, "Werkzeug prüfen", "Schneidkanten auf Verschleiß sichten.", true),
|
|
149
|
+
step(1, "Wechseln", "Werkzeug tauschen und Nullpunkt setzen."),
|
|
150
|
+
step(2, "Probelauf", "Erstes Teil vermessen."),
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
// Shrinking gaps (60 → 20 days): the forecast should warn that the
|
|
155
|
+
// intervals are getting shorter and extrapolate the *next* one.
|
|
156
|
+
title: "Presse-A — Hydraulikfilter",
|
|
157
|
+
machine: PRESSE,
|
|
158
|
+
cadence: rrule("FREQ=MONTHLY;BYMONTHDAY=15", pastMonth15(8)),
|
|
159
|
+
color: "#e8a33d",
|
|
160
|
+
history: [10, 30, 60, 100, 150],
|
|
161
|
+
steps: [
|
|
162
|
+
step(0, "Ölstand prüfen", "Füllstand am Schauglas kontrollieren.", true),
|
|
163
|
+
step(1, "Filter wechseln", "Rücklauffilter tauschen.", true),
|
|
164
|
+
step(2, "Dichtungen kontrollieren", "Auf Undichtigkeiten prüfen."),
|
|
165
|
+
step(3, "Probelauf", "Druck aufbauen, auf Leckagen achten."),
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
// Past due with no execution at all → overdue list and compliance tile.
|
|
170
|
+
title: "Presse-A — Dichtungen prüfen",
|
|
171
|
+
machine: PRESSE,
|
|
172
|
+
cadence: rrule("FREQ=WEEKLY;INTERVAL=1;BYDAY=TH", pastWeekday(3, 13)),
|
|
173
|
+
history: [],
|
|
174
|
+
steps: [
|
|
175
|
+
step(0, "Sichtprüfung Dichtungen", "Auf Risse und Austritt prüfen.", true),
|
|
176
|
+
step(1, "Befund notieren", "Auffälligkeiten dokumentieren."),
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
// Erratic history → the forecast must refuse rather than invent a date.
|
|
181
|
+
title: "Roboter R-12 — Achsen schmieren",
|
|
182
|
+
machine: ROBOTER,
|
|
183
|
+
cadence: rrule("FREQ=WEEKLY;INTERVAL=1;BYDAY=FR", pastWeekday(4, 14)),
|
|
184
|
+
history: [3, 5, 61, 66, 190],
|
|
185
|
+
steps: [
|
|
186
|
+
step(0, "Achsen 1–3 schmieren", "Fett nach Herstellerangabe.", true),
|
|
187
|
+
step(1, "Achsen 4–6 schmieren", "Fett nach Herstellerangabe.", true),
|
|
188
|
+
step(2, "Referenzfahrt", "Alle Achsen referenzieren."),
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
// Paused: no occurrences before `pausedUntil` — the machine is out of use.
|
|
193
|
+
title: "Roboter R-12 — Greifer kalibrieren",
|
|
194
|
+
machine: ROBOTER,
|
|
195
|
+
cadence: rrule("FREQ=MONTHLY;BYDAY=+1TU", pastMonth15(10)),
|
|
196
|
+
pausedUntil: daysFromNow(45),
|
|
197
|
+
history: [40, 72],
|
|
198
|
+
steps: [
|
|
199
|
+
step(0, "Greifkraft messen", "Mit Prüfkörper gegen Sollwert.", true),
|
|
200
|
+
step(1, "Offset korrigieren", "Abweichung in der Steuerung nachführen."),
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
// Escalation configured — stored and shown, but nothing acts on it yet.
|
|
205
|
+
// Seeded so that stays visible instead of theoretical.
|
|
206
|
+
title: "Lackierkabine L-1 — Filterwechsel",
|
|
207
|
+
machine: LACK,
|
|
208
|
+
cadence: rrule("FREQ=WEEKLY;INTERVAL=2;BYDAY=TU", pastWeekday(1, 7)),
|
|
209
|
+
graceDays: 2,
|
|
210
|
+
escalationAfterDays: 5,
|
|
211
|
+
history: [12, 26, 40, 54],
|
|
212
|
+
steps: [
|
|
213
|
+
step(0, "Vorfilter tauschen", "Matten erneuern.", true),
|
|
214
|
+
step(1, "Deckenfilter prüfen", "Bei Sättigung tauschen."),
|
|
215
|
+
step(2, "Druckdifferenz notieren", "Messwert ins Protokoll."),
|
|
216
|
+
],
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
// Daily and dense — the forecast's most confident case, and enough rows
|
|
220
|
+
// to make the machine book and the load widget non-trivial.
|
|
221
|
+
title: "Kompressor K-3 — Kondensat ablassen",
|
|
222
|
+
machine: KOMPRESSOR,
|
|
223
|
+
cadence: rrule("FREQ=DAILY;INTERVAL=1", berlinIso(daysAgo(42), 7)),
|
|
224
|
+
history: [0, 1, 2, 3, 4, 5, 6, 7],
|
|
225
|
+
steps: [
|
|
226
|
+
step(0, "Kondensatablass öffnen", "Bis Luft austritt.", true),
|
|
227
|
+
step(1, "Menge notieren", "Auffälligkeiten melden."),
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
// Created by an alarm: a COUNT=1 one-off carrying the `origin` marker and
|
|
232
|
+
// the firing context under `asset.alarm`. Feeds the "triggered by an
|
|
233
|
+
// alarm" card on the detail page and the trigger overview.
|
|
234
|
+
title: "Kompressor K-3 — Lagerschaden prüfen (Alarm)",
|
|
235
|
+
machine: KOMPRESSOR,
|
|
236
|
+
cadence: rrule("FREQ=DAILY;COUNT=1", berlinIso(daysFromNow(2), 8)),
|
|
237
|
+
color: "#d4564b",
|
|
238
|
+
origin: `alarm:${DEMO_ALARM_ID}`,
|
|
239
|
+
asset: {
|
|
240
|
+
alarm: {
|
|
241
|
+
alarmId: DEMO_ALARM_ID,
|
|
242
|
+
name: "K-3 Lagertemperatur kritisch",
|
|
243
|
+
sensor: "halle-b/kompressor-k3.bearing_temp [0]",
|
|
244
|
+
value: 87.4,
|
|
245
|
+
condition: "> 80",
|
|
246
|
+
firedAt: daysAgo(1).toISOString(),
|
|
247
|
+
actionId: "openservice-create-schedule",
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
history: [],
|
|
251
|
+
steps: [
|
|
252
|
+
step(0, "Lagertemperatur messen", "Mit Infrarotthermometer.", true),
|
|
253
|
+
step(1, "Laufgeräusch prüfen", "Auf Mahlen oder Schleifen achten.", true),
|
|
254
|
+
step(2, "Befund dokumentieren", "Bei Auffälligkeit Ticket erstellen."),
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
function demoTemplates() {
|
|
260
|
+
const today = (rule, hour) => rrule(rule, berlinIso(new Date(), hour));
|
|
261
|
+
return [
|
|
262
|
+
{
|
|
263
|
+
title: "Standard Spindel-Inspektion",
|
|
264
|
+
description: "Wöchentliche Sicht- und Funktionsprüfung der Spindel.",
|
|
265
|
+
cadence: today("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO", 6),
|
|
266
|
+
steps: [
|
|
267
|
+
step(0, "Sichtprüfung", "Auf Beschädigungen und Leckagen prüfen.", true),
|
|
268
|
+
step(1, "Schmierung", "Schmiernippel abschmieren."),
|
|
269
|
+
step(2, "Lagerspiel messen", "Axiales/radiales Spiel prüfen.", true),
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
title: "Monatliche Hydraulik-Wartung",
|
|
274
|
+
description: "Hydraulikaggregat: Ölstand, Filter und Dichtungen.",
|
|
275
|
+
cadence: today("FREQ=MONTHLY;BYMONTHDAY=15", 8),
|
|
276
|
+
steps: [
|
|
277
|
+
step(0, "Ölstand prüfen", "Füllstand am Schauglas kontrollieren.", true),
|
|
278
|
+
step(1, "Filter wechseln", "Rücklauffilter tauschen."),
|
|
279
|
+
step(2, "Dichtungen kontrollieren", "Auf Undichtigkeiten prüfen."),
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
title: "Jährliche Sicherheitsprüfung",
|
|
284
|
+
description: "Gesetzlich vorgeschriebene jährliche Prüfung.",
|
|
285
|
+
cadence: today("FREQ=YEARLY", 7),
|
|
286
|
+
steps: [
|
|
287
|
+
step(0, "Elektrische Prüfung", "DGUV V3 durchführen.", true),
|
|
288
|
+
step(1, "Not-Aus-Test", "Alle Not-Aus-Kreise auslösen.", true),
|
|
289
|
+
step(2, "Protokoll ablegen", "Prüfprotokoll dokumentieren."),
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
// The template an alarm applies. Its title is what a plan created by the
|
|
294
|
+
// "Wartungstermin anlegen" action inherits when no title is configured.
|
|
295
|
+
title: "Lagerschaden-Prüfung (Alarm)",
|
|
296
|
+
description: "Kurzprüfung nach einem Temperatur- oder Vibrationsalarm.",
|
|
297
|
+
cadence: today("FREQ=DAILY;COUNT=1", 8),
|
|
298
|
+
steps: [
|
|
299
|
+
step(0, "Lagertemperatur messen", "Mit Infrarotthermometer.", true),
|
|
300
|
+
step(1, "Laufgeräusch prüfen", "Auf Mahlen oder Schleifen achten.", true),
|
|
301
|
+
step(2, "Befund dokumentieren", "Bei Auffälligkeit Ticket erstellen."),
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
];
|
|
305
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Tenant, type _User } from "../../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Where a tenant's demo seed remembers what it created.
|
|
4
|
+
*
|
|
5
|
+
* None of the seeded classes carries a marker column — a demo feature is no
|
|
6
|
+
* reason for a schema change. Instead the ids of everything seeded are kept in
|
|
7
|
+
* one config row per tenant, readable by `od-admin` only. A reset removes
|
|
8
|
+
* exactly those objects (plus what can only go together with them, see
|
|
9
|
+
* {@link resetDemoData}), so a tenant that also holds real data keeps it.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEMO_SEED_CONFIG_KEY = "OPENSERVICE_DEMO_SEED";
|
|
12
|
+
/**
|
|
13
|
+
* Context flag on every write the seed makes. The plan hook skips the Outlook
|
|
14
|
+
* sync for it: demo plans belong to a demo tenant, not in anybody's calendar.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEMO_SEED_CONTEXT_FLAG = "fromDemoSeed";
|
|
17
|
+
export interface DemoSeedTenantStatus {
|
|
18
|
+
tenantId: string;
|
|
19
|
+
label: string;
|
|
20
|
+
seededAt?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface DemoSeedResult {
|
|
23
|
+
tenantId: string;
|
|
24
|
+
removed: {
|
|
25
|
+
executions: number;
|
|
26
|
+
schedules: number;
|
|
27
|
+
templates: number;
|
|
28
|
+
equipment: number;
|
|
29
|
+
/**
|
|
30
|
+
* Equipment that tickets or hand-made equipment still point at —
|
|
31
|
+
* archived instead of deleted.
|
|
32
|
+
*/
|
|
33
|
+
archivedEquipment: number;
|
|
34
|
+
};
|
|
35
|
+
created?: {
|
|
36
|
+
equipment: number;
|
|
37
|
+
schedules: number;
|
|
38
|
+
templates: number;
|
|
39
|
+
executions: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Every tenant with the date of its last demo seed, if any. */
|
|
43
|
+
export declare function demoSeedStatus(): Promise<DemoSeedTenantStatus[]>;
|
|
44
|
+
export declare function resolveTenant(tenantId: unknown): Promise<Tenant>;
|
|
45
|
+
export interface DemoSeedUser {
|
|
46
|
+
userId: string;
|
|
47
|
+
label: string;
|
|
48
|
+
}
|
|
49
|
+
/** The tenant's users, as candidates for the `user` field of the demo data. */
|
|
50
|
+
export declare function demoSeedUsers(tenant: Tenant): Promise<DemoSeedUser[]>;
|
|
51
|
+
/**
|
|
52
|
+
* The user the demo data is attributed to — only one of the chosen tenant's,
|
|
53
|
+
* otherwise a demo plan would hand a foreign user read+write on it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveUser(userId: unknown, tenant: Tenant): Promise<_User | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Replace the tenant's demo data with a fresh set.
|
|
58
|
+
*
|
|
59
|
+
* Removes the previous seed first, so pressing the button twice does not
|
|
60
|
+
* leave two copies of Halle B.
|
|
61
|
+
*
|
|
62
|
+
* `user` becomes the `user` of every plan, template and execution: the owner
|
|
63
|
+
* of a plan (the ACL grants them read+write) and the author of the rest —
|
|
64
|
+
* and the `performedBy` of every execution.
|
|
65
|
+
* Without one the fields stay empty, as before.
|
|
66
|
+
*/
|
|
67
|
+
export declare function seedDemoData(tenant: Tenant, user?: _User): Promise<DemoSeedResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Remove what the last seed created in this tenant.
|
|
70
|
+
*
|
|
71
|
+
* Beyond the recorded ids, three things go with them because they cannot stay
|
|
72
|
+
* behind on their own:
|
|
73
|
+
* - executions somebody recorded by hand on a demo plan or demo machine — a
|
|
74
|
+
* plan with executions cannot be deleted, and they would point at nothing;
|
|
75
|
+
* - the role/user assignments of the demo plans (Parse leaves relation rows
|
|
76
|
+
* in `_Join:*` behind when the owning object is deleted);
|
|
77
|
+
* - changelog rows about demo objects, written by edits during the demo.
|
|
78
|
+
*
|
|
79
|
+
* Equipment that tickets or non-demo equipment point at is archived rather
|
|
80
|
+
* than deleted.
|
|
81
|
+
*/
|
|
82
|
+
export declare function resetDemoData(tenant: Tenant): Promise<DemoSeedResult["removed"]>;
|