@dotbep/core 0.2.7 → 0.2.9
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/index.d.ts +7 -40
- package/dist/index.js +1142 -1179
- package/package.json +4 -1
- package/examples/01-participants.ts +0 -127
- package/examples/02-files.ts +0 -100
- package/examples/03-workflows.ts +0 -149
- package/examples/04-bim-uses.ts +0 -70
- package/examples/05-standards.ts +0 -60
- package/examples/06-schedule.ts +0 -124
- package/examples/07-loin.ts +0 -133
- package/examples/08-deliverables.ts +0 -126
- package/examples/09-notes.ts +0 -73
- package/examples/10-llm.ts +0 -109
- package/examples/11-resolved.ts +0 -133
- package/examples/12-history.ts +0 -166
- package/examples/13-engine.ts +0 -152
- package/examples/bep.d.ts +0 -38
- package/examples/example.bep +0 -0
- package/examples/run-all.ts +0 -38
- package/src/base/entity.ts +0 -148
- package/src/base/history.ts +0 -497
- package/src/base/index.ts +0 -5
- package/src/base/singleton.ts +0 -26
- package/src/entities/actions.ts +0 -25
- package/src/entities/adapters.ts +0 -16
- package/src/entities/annexes.ts +0 -17
- package/src/entities/assetTypes.ts +0 -30
- package/src/entities/automations.ts +0 -24
- package/src/entities/bimUses.ts +0 -50
- package/src/entities/deliverables.ts +0 -66
- package/src/entities/disciplines.ts +0 -21
- package/src/entities/effects.ts +0 -28
- package/src/entities/env.ts +0 -17
- package/src/entities/events.ts +0 -24
- package/src/entities/extensions.ts +0 -16
- package/src/entities/flags.ts +0 -17
- package/src/entities/guides.ts +0 -26
- package/src/entities/index.ts +0 -32
- package/src/entities/lbsNodes.ts +0 -193
- package/src/entities/lods.ts +0 -22
- package/src/entities/loin.ts +0 -127
- package/src/entities/lois.ts +0 -22
- package/src/entities/members.ts +0 -137
- package/src/entities/milestones.ts +0 -32
- package/src/entities/notes.ts +0 -27
- package/src/entities/objectives.ts +0 -17
- package/src/entities/phases.ts +0 -17
- package/src/entities/remoteData.ts +0 -17
- package/src/entities/resolvers.ts +0 -20
- package/src/entities/roles.ts +0 -29
- package/src/entities/softwares.ts +0 -26
- package/src/entities/standards.ts +0 -68
- package/src/entities/teams.ts +0 -42
- package/src/entities/workflows.ts +0 -256
- package/src/index.ts +0 -464
- package/src/runtime/Engine.ts +0 -352
- package/src/runtime/MemoryStorage.ts +0 -31
- package/src/runtime/Runtime.ts +0 -106
- package/src/runtime/index.ts +0 -4
- package/src/runtime/transitions.ts +0 -456
- package/src/runtime/types.ts +0 -279
- package/src/types/history.ts +0 -37
- package/src/types/index.ts +0 -24
- package/src/types/resolved.ts +0 -137
- package/src/types/schema.ts +0 -757
- package/src/utils/diff.ts +0 -109
- package/src/utils/index.ts +0 -9
- package/src/utils/integrity.ts +0 -108
- package/src/utils/lbs.ts +0 -116
- package/src/utils/mermaid.ts +0 -110
- package/src/utils/naming.ts +0 -62
- package/src/utils/nomenclature.ts +0 -107
- package/src/utils/normalize.ts +0 -35
- package/src/utils/raci.ts +0 -25
- package/src/utils/textFile.ts +0 -24
- package/tsconfig.json +0 -12
- package/vite.config.ts +0 -24
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { z as a, ZodError as
|
|
3
|
-
const
|
|
1
|
+
import oe from "jszip";
|
|
2
|
+
import { z as a, ZodError as Ve } from "zod";
|
|
3
|
+
const He = a.enum([
|
|
4
4
|
"appointing-party",
|
|
5
5
|
"lead-appointed-party",
|
|
6
6
|
"appointed-party"
|
|
7
|
-
]),
|
|
7
|
+
]), Ye = a.enum(["video", "document"]), Qe = a.enum(["zone", "location"]), et = a.enum(["LR", "TB"]), Ds = a.enum(["start", "end", "process", "decision", "automation"]), tt = a.enum(["info", "warning", "blocking"]), st = a.enum([
|
|
8
8
|
"roles",
|
|
9
9
|
"members",
|
|
10
10
|
"teams",
|
|
@@ -44,15 +44,15 @@ const Ye = a.enum([
|
|
|
44
44
|
roleId: a.string(),
|
|
45
45
|
description: a.string().optional(),
|
|
46
46
|
bepEditor: a.boolean().optional()
|
|
47
|
-
}).describe("A project participant identified by email. Each member holds one role, which determines their responsibilities across workflow steps."),
|
|
47
|
+
}).describe("A project participant identified by email. Each member holds one role, which determines their responsibilities across workflow steps."), nt = a.object({
|
|
48
48
|
id: a.string().min(1).describe("Must comply with the naming convention token pattern."),
|
|
49
49
|
name: a.string().min(1),
|
|
50
|
-
isoRole:
|
|
50
|
+
isoRole: He,
|
|
51
51
|
description: a.string().optional(),
|
|
52
52
|
disciplineIds: a.array(a.string()).optional(),
|
|
53
53
|
representativeEmail: a.email().optional().describe("ref Member.email"),
|
|
54
54
|
memberEmails: a.array(a.email()).optional()
|
|
55
|
-
}).describe("A company or discipline group participating in the project. Teams group members under an ISO role and can be assigned RACI responsibilities at the workflow level."), pe =
|
|
55
|
+
}).describe("A company or discipline group participating in the project. Teams group members under an ISO role and can be assigned RACI responsibilities at the workflow level."), pe = nt.refine((s) => !s.representativeEmail || (s.memberEmails ?? []).includes(s.representativeEmail), {
|
|
56
56
|
message: "representativeEmail must be included in memberEmails.",
|
|
57
57
|
path: ["representativeEmail"]
|
|
58
58
|
}), it = a.enum([
|
|
@@ -62,13 +62,13 @@ const Ye = a.enum([
|
|
|
62
62
|
"assetType",
|
|
63
63
|
"lbsZone",
|
|
64
64
|
"lbsLocation"
|
|
65
|
-
]),
|
|
65
|
+
]), ot = a.discriminatedUnion("type", [
|
|
66
66
|
a.object({ type: a.literal("field"), token: it, pattern: a.string().optional() }),
|
|
67
67
|
a.object({ type: a.literal("sequence"), padding: a.number().int().min(1).optional() })
|
|
68
68
|
]), he = a.object({
|
|
69
69
|
delimiter: a.string().min(1),
|
|
70
|
-
segments: a.array(
|
|
71
|
-
}).describe("A structured rule for generating deliverable names. Specifies a delimiter and a sequence of segments that are joined to produce consistent, parseable file names.").refine((
|
|
70
|
+
segments: a.array(ot).min(1)
|
|
71
|
+
}).describe("A structured rule for generating deliverable names. Specifies a delimiter and a sequence of segments that are joined to produce consistent, parseable file names.").refine((s) => s.segments.filter((e) => e.type === "sequence").length <= 1, {
|
|
72
72
|
message: "segments can contain at most one sequence.",
|
|
73
73
|
path: ["segments"]
|
|
74
74
|
}), ge = a.object({
|
|
@@ -81,13 +81,13 @@ const Ye = a.enum([
|
|
|
81
81
|
date: a.iso.date(),
|
|
82
82
|
phaseId: a.string(),
|
|
83
83
|
description: a.string().optional()
|
|
84
|
-
}).describe("A named deadline within a phase. Anchors deliverables and information requirements to a specific date in the project timeline."),
|
|
84
|
+
}).describe("A named deadline within a phase. Anchors deliverables and information requirements to a specific date in the project timeline."), rt = a.object({
|
|
85
85
|
id: a.string().min(1).describe("Used in deliverables nomenclature."),
|
|
86
86
|
name: a.string().min(1),
|
|
87
|
-
type:
|
|
87
|
+
type: Qe,
|
|
88
88
|
description: a.string().optional(),
|
|
89
89
|
lbsNodeIds: a.array(a.string()).optional().describe("ref LBSNode.id[]")
|
|
90
|
-
}).describe("A spatial or functional subdivision of the project. LBS nodes form a hierarchy that scopes deliverables to specific spatial or functional areas."), be =
|
|
90
|
+
}).describe("A spatial or functional subdivision of the project. LBS nodes form a hierarchy that scopes deliverables to specific spatial or functional areas."), be = rt.refine((s) => !(s.lbsNodeIds ?? []).includes(s.id), {
|
|
91
91
|
message: "A node cannot reference itself in lbsNodeIds.",
|
|
92
92
|
path: ["lbsNodeIds"]
|
|
93
93
|
}), we = a.object({
|
|
@@ -142,10 +142,10 @@ const Ye = a.enum([
|
|
|
142
142
|
description: a.string().min(1).describe("Describe what this handler checks and what decision it produces: what condition or business rule it evaluates and where that data comes from."),
|
|
143
143
|
payload: a.array(L).optional().describe("Fields consumed from instance context and passed to the handler."),
|
|
144
144
|
output: a.array(L).describe("Fields the handler must return. Guards on outgoing edges reference these.")
|
|
145
|
-
}).describe("A system-executed node in a workflow. Runs a handler automatically, produces a typed output, and must be followed by a decision node that branches on that output."),
|
|
145
|
+
}).describe("A system-executed node in a workflow. Runs a handler automatically, produces a typed output, and must be followed by a decision node that branches on that output."), at = a.object({
|
|
146
146
|
hours: a.number().positive(),
|
|
147
147
|
effectId: a.string().min(1).describe("ref FlowEffect.id")
|
|
148
|
-
}).describe("A time-based escalation on a process or automation node. Fires a declared effect if the node has not been advanced within the given number of hours."),
|
|
148
|
+
}).describe("A time-based escalation on a process or automation node. Fires a declared effect if the node has not been advanced within the given number of hours."), dt = a.object({
|
|
149
149
|
responsibleRoleIds: a.array(a.string()).optional().describe("ref Role.id[]"),
|
|
150
150
|
accountableRoleIds: a.array(a.string()).optional().describe("ref Role.id[]"),
|
|
151
151
|
consultedRoleIds: a.array(a.string()).optional().describe("ref Role.id[]"),
|
|
@@ -158,46 +158,46 @@ const Ye = a.enum([
|
|
|
158
158
|
accountableEmails: a.array(a.string()).optional().describe("ref Member.email[]"),
|
|
159
159
|
consultedEmails: a.array(a.string()).optional().describe("ref Member.email[]"),
|
|
160
160
|
informedEmails: a.array(a.string()).optional().describe("ref Member.email[]")
|
|
161
|
-
}),
|
|
162
|
-
timeouts: a.array(
|
|
163
|
-
}),
|
|
161
|
+
}), je = a.object({
|
|
162
|
+
timeouts: a.array(at).optional()
|
|
163
|
+
}), lt = a.object({
|
|
164
164
|
type: a.literal("start")
|
|
165
|
-
}),
|
|
165
|
+
}), ct = a.object({
|
|
166
166
|
type: a.literal("end")
|
|
167
|
-
}),
|
|
167
|
+
}), ft = a.object({
|
|
168
168
|
type: a.literal("decision"),
|
|
169
169
|
label: a.string().min(1)
|
|
170
|
-
}),
|
|
170
|
+
}), ut = a.object({
|
|
171
171
|
type: a.literal("automation"),
|
|
172
172
|
automationId: a.string().min(1).describe("ref FlowAutomation.id")
|
|
173
|
-
}).extend(
|
|
173
|
+
}).extend(je.shape), mt = a.object({
|
|
174
174
|
type: a.literal("process"),
|
|
175
175
|
actionId: a.string().optional().describe("ref Action.id"),
|
|
176
176
|
workflowId: a.string().optional().describe("ref Workflow.id — spawns child instances of this workflow when the node is entered."),
|
|
177
177
|
blocking: a.boolean().optional().describe("If true, waits for all spawned child instances to complete before accepting outgoing transitions.")
|
|
178
|
-
}).extend(
|
|
178
|
+
}).extend(dt.shape).extend(je.shape).refine((s) => !!s.actionId != !!s.workflowId, {
|
|
179
179
|
message: "process nodes require exactly one of actionId or workflowId.",
|
|
180
180
|
path: ["actionId"]
|
|
181
|
-
}).refine((
|
|
181
|
+
}).refine((s) => !s.blocking || !!s.workflowId, {
|
|
182
182
|
message: "blocking requires workflowId to be set.",
|
|
183
183
|
path: ["blocking"]
|
|
184
184
|
}).refine(
|
|
185
|
-
(
|
|
185
|
+
(s) => (s.responsibleRoleIds?.length ?? 0) > 0 || (s.responsibleTeamIds?.length ?? 0) > 0 || (s.responsibleEmails?.length ?? 0) > 0,
|
|
186
186
|
{
|
|
187
187
|
message: "process nodes require at least one responsible (role, team, or email).",
|
|
188
188
|
path: ["responsibleRoleIds"]
|
|
189
189
|
}
|
|
190
|
-
),
|
|
190
|
+
), pt = a.union([
|
|
191
|
+
lt,
|
|
191
192
|
ct,
|
|
192
193
|
ft,
|
|
193
194
|
ut,
|
|
194
|
-
mt
|
|
195
|
-
|
|
196
|
-
]).describe("A node in a workflow diagram used to describe steps."), gt = a.object({
|
|
195
|
+
mt
|
|
196
|
+
]).describe("A node in a workflow diagram used to describe steps."), ht = a.object({
|
|
197
197
|
field: a.string().min(1),
|
|
198
198
|
operator: a.enum(["eq", "neq", "gt", "lt", "contains", "exists"]),
|
|
199
199
|
value: a.union([a.string(), a.number(), a.boolean()]).optional()
|
|
200
|
-
}).refine((
|
|
200
|
+
}).refine((s) => s.operator === "exists" || s.value !== void 0, {
|
|
201
201
|
message: 'value is required when operator is not "exists".',
|
|
202
202
|
path: ["value"]
|
|
203
203
|
}), ee = a.object({
|
|
@@ -205,38 +205,38 @@ const Ye = a.enum([
|
|
|
205
205
|
to: a.string().describe("ref FlowNode key"),
|
|
206
206
|
label: a.string().optional(),
|
|
207
207
|
effectIds: a.array(a.string().min(1)).optional().describe("ref FlowEffect.id[]")
|
|
208
|
-
}).refine((
|
|
208
|
+
}).refine((s) => s.from !== s.to, {
|
|
209
209
|
message: "A flow edge cannot point from a node to itself.",
|
|
210
210
|
path: ["to"]
|
|
211
|
-
}),
|
|
211
|
+
}), gt = ee.extend({
|
|
212
212
|
triggerEventId: a.string().min(1).describe("ref FlowEvent.id — the event that fires this transition")
|
|
213
|
-
}),
|
|
214
|
-
guard:
|
|
215
|
-
}),
|
|
216
|
-
direction:
|
|
217
|
-
nodes: a.record(a.string(),
|
|
218
|
-
edges: a.record(a.string(),
|
|
219
|
-
}).superRefine((
|
|
220
|
-
const t = Object.entries(
|
|
221
|
-
|
|
213
|
+
}), yt = ee.extend({
|
|
214
|
+
guard: ht.describe("Condition evaluated against the instance context to determine which path to take.")
|
|
215
|
+
}), bt = ee, wt = a.union([gt, yt, bt]), vt = a.object({
|
|
216
|
+
direction: et.default("LR"),
|
|
217
|
+
nodes: a.record(a.string(), pt),
|
|
218
|
+
edges: a.record(a.string(), wt)
|
|
219
|
+
}).superRefine((s, e) => {
|
|
220
|
+
const t = Object.entries(s.nodes), n = t.filter(([, r]) => r.type === "start").length, i = t.filter(([, r]) => r.type === "end").length;
|
|
221
|
+
n !== 1 && e.addIssue({
|
|
222
222
|
code: "custom",
|
|
223
|
-
message: `Diagram must have exactly one start node (found ${
|
|
223
|
+
message: `Diagram must have exactly one start node (found ${n}).`,
|
|
224
224
|
path: ["nodes"]
|
|
225
|
-
}),
|
|
225
|
+
}), i !== 1 && e.addIssue({
|
|
226
226
|
code: "custom",
|
|
227
|
-
message: `Diagram must have exactly one end node (found ${
|
|
227
|
+
message: `Diagram must have exactly one end node (found ${i}).`,
|
|
228
228
|
path: ["nodes"]
|
|
229
229
|
});
|
|
230
|
-
const
|
|
231
|
-
for (const [r, d] of Object.entries(
|
|
232
|
-
|
|
230
|
+
const o = {};
|
|
231
|
+
for (const [r, d] of Object.entries(s.edges))
|
|
232
|
+
o[d.from] ??= [], o[d.from].push({ edgeId: r, toKey: d.to });
|
|
233
233
|
for (const [r, d] of t) {
|
|
234
|
-
const l =
|
|
234
|
+
const l = o[r] ?? [];
|
|
235
235
|
d.type === "automation" && (l.length !== 1 ? e.addIssue({
|
|
236
236
|
code: "custom",
|
|
237
237
|
message: `automation node must have exactly one outgoing edge (found ${l.length}).`,
|
|
238
238
|
path: ["nodes", r]
|
|
239
|
-
}) :
|
|
239
|
+
}) : s.nodes[l[0].toKey]?.type !== "decision" && e.addIssue({
|
|
240
240
|
code: "custom",
|
|
241
241
|
message: "automation node must connect directly to a decision node.",
|
|
242
242
|
path: ["nodes", r]
|
|
@@ -246,8 +246,8 @@ const Ye = a.enum([
|
|
|
246
246
|
path: ["nodes", r]
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
-
for (const [r, d] of Object.entries(
|
|
250
|
-
const l =
|
|
249
|
+
for (const [r, d] of Object.entries(s.edges)) {
|
|
250
|
+
const l = s.nodes[d.from];
|
|
251
251
|
if (!l) continue;
|
|
252
252
|
const c = "triggerEventId" in d, u = "guard" in d;
|
|
253
253
|
l.type === "start" && (c || u) && e.addIssue({
|
|
@@ -272,17 +272,17 @@ const Ye = a.enum([
|
|
|
272
272
|
path: ["edges", r, "guard"]
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
|
-
}).describe("The visual and structural definition of a workflow."),
|
|
275
|
+
}).describe("The visual and structural definition of a workflow."), Ae = a.object({
|
|
276
276
|
id: a.uuid(),
|
|
277
277
|
name: a.string().min(1),
|
|
278
278
|
description: a.string().optional(),
|
|
279
279
|
example: a.string().optional().describe("Narrative example showcasing one cycle of this workflow."),
|
|
280
280
|
trackedAssetTypeId: a.string().optional().describe("ref AssetType.id"),
|
|
281
|
-
diagram:
|
|
281
|
+
diagram: vt
|
|
282
282
|
}).describe("A reusable process definition associated with one or more BIM uses. Describes the ordered steps, responsibilities, and transitions that govern how work is carried out."), Oe = a.object({
|
|
283
283
|
id: a.uuid(),
|
|
284
284
|
name: a.string().min(1),
|
|
285
|
-
type:
|
|
285
|
+
type: Ye,
|
|
286
286
|
url: a.string().min(1),
|
|
287
287
|
description: a.string().optional()
|
|
288
288
|
}).describe("Supporting material attached to the BEP, such as a reference document or instructional video."), _e = a.object({
|
|
@@ -303,7 +303,7 @@ const Ye = a.enum([
|
|
|
303
303
|
id: a.string().min(1),
|
|
304
304
|
name: a.string().min(1),
|
|
305
305
|
checklist: a.array(a.string()).optional()
|
|
306
|
-
}).describe("An information detail level assigned to model elements in LOIN requirements. Specifies the non-geometric properties required of a model element at a given milestone."),
|
|
306
|
+
}).describe("An information detail level assigned to model elements in LOIN requirements. Specifies the non-geometric properties required of a model element at a given milestone."), It = a.object({
|
|
307
307
|
milestoneId: a.string(),
|
|
308
308
|
lodId: a.string().min(1),
|
|
309
309
|
loiId: a.string().min(1),
|
|
@@ -312,22 +312,22 @@ const Ye = a.enum([
|
|
|
312
312
|
id: a.uuid(),
|
|
313
313
|
element: a.string().min(1),
|
|
314
314
|
disciplineId: a.string(),
|
|
315
|
-
milestones: a.array(
|
|
315
|
+
milestones: a.array(It).optional()
|
|
316
316
|
}).describe("An information requirement for a model element. Declares what geometric detail and information properties are required for a specific model element and discipline across project milestones."), Fe = a.object({
|
|
317
317
|
id: a.uuid(),
|
|
318
318
|
message: a.string().min(1),
|
|
319
319
|
memberEmail: a.email(),
|
|
320
320
|
createdAt: a.iso.datetime()
|
|
321
|
-
}).describe("A timestamped comment left by a project member on the BEP."),
|
|
321
|
+
}).describe("A timestamped comment left by a project member on the BEP."), Et = a.object({
|
|
322
322
|
id: a.uuid(),
|
|
323
|
-
entity:
|
|
323
|
+
entity: st.nullable().describe("null = BEP-level flag"),
|
|
324
324
|
entityId: a.string().nullable(),
|
|
325
|
-
severity:
|
|
325
|
+
severity: tt,
|
|
326
326
|
message: a.string().min(1),
|
|
327
327
|
generatedAt: a.iso.datetime()
|
|
328
|
-
}).describe("A diagnostic message attached to the BEP or one of its entities. Indicates an issue or observation with a severity level that guides the author."), Ce =
|
|
328
|
+
}).describe("A diagnostic message attached to the BEP or one of its entities. Indicates an issue or observation with a severity level that guides the author."), Ce = Et.refine((s) => s.entity === null == (s.entityId === null), {
|
|
329
329
|
message: "entity and entityId must both be null (BEP-level) or both be non-null (entity-level)."
|
|
330
|
-
}),
|
|
330
|
+
}), Nt = a.object({
|
|
331
331
|
id: a.uuid(),
|
|
332
332
|
description: a.string().optional(),
|
|
333
333
|
lbsNodeId: a.string().optional(),
|
|
@@ -340,29 +340,25 @@ const Ye = a.enum([
|
|
|
340
340
|
predecessorId: a.string().optional(),
|
|
341
341
|
url: a.url().optional(),
|
|
342
342
|
resolverId: a.string().min(1).optional()
|
|
343
|
-
}).describe("A formal output committed by a team at a milestone. Defines what must be delivered, in what format, by whom, and by when."), De =
|
|
343
|
+
}).describe("A formal output committed by a team at a milestone. Defines what must be delivered, in what format, by whom, and by when."), De = Nt.refine((s) => !s.predecessorId || s.predecessorId !== s.id, {
|
|
344
344
|
message: "predecessorId cannot reference the deliverable itself.",
|
|
345
345
|
path: ["predecessorId"]
|
|
346
346
|
}), Le = a.object({
|
|
347
|
-
key: a.string().min(1)
|
|
348
|
-
description: a.string().
|
|
349
|
-
|
|
350
|
-
}).describe("A runtime configuration entry for
|
|
347
|
+
key: a.string().min(1),
|
|
348
|
+
description: a.string().min(1).describe("Describe what this variable holds and which service it belongs to."),
|
|
349
|
+
sensitive: a.boolean().optional()
|
|
350
|
+
}).describe("A runtime configuration entry for handlers. Used to store credentials, endpoints, or other runtime settings without hardcoding them."), Ue = a.object({
|
|
351
351
|
id: a.string().min(1).describe('Human-readable slug, e.g. "google-sheet"'),
|
|
352
352
|
name: a.string().min(1),
|
|
353
|
-
description: a.string().min(1).describe("Describe what external data this fetches, from where, and what format it returns: which service or API it calls, what credentials it needs, and the shape of the raw payload it returns
|
|
353
|
+
description: a.string().min(1).describe("Describe what external data this fetches, from where, and what format it returns: which service or API it calls, what credentials it needs, and the shape of the raw payload it returns."),
|
|
354
354
|
envKeys: a.array(a.string().min(1)).describe("ref EnvVar.key[] — env vars required by this resolver handler.")
|
|
355
355
|
}).describe("A server-side handler declared in the BEP bundle that authenticates against an external service, fetches data, and returns a raw payload for a live resource."), ze = a.object({
|
|
356
|
-
id: a.string().min(1).describe('Human-readable slug, e.g. "discipline-progress"'),
|
|
357
|
-
name: a.string().min(1),
|
|
358
|
-
description: a.string().min(1).describe("Describe the input format (resolver output shape), the transformation applied, and the output format (lens-compatible shape) so the runtime developer can implement the correct mapping.")
|
|
359
|
-
}).describe("A transformation function declared in the BEP bundle that converts resolver output into a compatible format."), Ze = a.object({
|
|
360
356
|
id: a.uuid(),
|
|
361
357
|
name: a.string().min(1),
|
|
362
358
|
description: a.string().min(1).describe("Describe what this data source represents in the project context: what information it holds, how it is used in the BEP, and who or what system produces it."),
|
|
363
359
|
url: a.url(),
|
|
364
360
|
resolverId: a.string().min(1).optional().describe("ref Resolver.id")
|
|
365
|
-
}).describe("A reference to an external data source that is fetched at runtime. The BEP does not store the data — it only declares where it lives and how to access it using a resolver."),
|
|
361
|
+
}).describe("A reference to an external data source that is fetched at runtime. The BEP does not store the data — it only declares where it lives and how to access it using a resolver."), Ls = a.object({
|
|
366
362
|
project: fe,
|
|
367
363
|
deliverableNamingConvention: he.optional(),
|
|
368
364
|
roles: a.array(ue),
|
|
@@ -383,9 +379,8 @@ const Ye = a.enum([
|
|
|
383
379
|
automations: a.array(Te),
|
|
384
380
|
env: a.array(Le),
|
|
385
381
|
resolvers: a.array(Ue),
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
workflows: a.array(je),
|
|
382
|
+
remoteData: a.array(ze),
|
|
383
|
+
workflows: a.array(Ae),
|
|
389
384
|
guides: a.array(_e),
|
|
390
385
|
annexes: a.array(Oe),
|
|
391
386
|
standards: a.array(Be),
|
|
@@ -401,46 +396,46 @@ const Ye = a.enum([
|
|
|
401
396
|
author: a.email().describe("ref Member.email"),
|
|
402
397
|
description: a.string().min(1),
|
|
403
398
|
diff: a.string().nullable().describe("Relative path to inverse diff (RFC 6902). null on v0.0.")
|
|
404
|
-
}),
|
|
399
|
+
}), St = a.discriminatedUnion("type", [
|
|
405
400
|
re.extend({ type: a.literal("patch") }),
|
|
406
401
|
re.extend({
|
|
407
402
|
type: a.literal("version"),
|
|
408
403
|
approvedBy: a.array(a.email()).describe("ref Member.email[]")
|
|
409
404
|
})
|
|
410
|
-
]),
|
|
405
|
+
]), Us = a.object({
|
|
411
406
|
current: a.string().regex(/^\d+\.\d+$/).describe('Current version in "{major}.{minor}" format.'),
|
|
412
|
-
versions: a.array(
|
|
407
|
+
versions: a.array(St)
|
|
413
408
|
});
|
|
414
|
-
function B(
|
|
415
|
-
return
|
|
409
|
+
function B(s) {
|
|
410
|
+
return s.roles ??= [], s.members ??= [], s.teams ??= [], s.phases ??= [], s.milestones ??= [], s.lbs ??= [], s.disciplines ??= [], s.extensions ??= [], s.assetTypes ??= [], s.softwares ??= [], s.objectives ??= [], s.bimUses ??= [], s.actions ??= [], s.events ??= [], s.effects ??= [], s.workflows ??= [], s.guides ??= [], s.annexes ??= [], s.standards ??= [], s.lods ??= [], s.lois ??= [], s.loin ??= [], s.deliverables ??= [], s.notes ??= [], s.flags ??= [], s.env ??= [], s.automations ??= [], s.resolvers ??= [], s.remoteData ??= [], s;
|
|
416
411
|
}
|
|
417
|
-
const
|
|
418
|
-
function
|
|
412
|
+
const kt = "-", $t = "^[A-Z0-9]{3}$";
|
|
413
|
+
function Rt(s, e) {
|
|
419
414
|
if (e) {
|
|
420
|
-
const t = e.segments.find((
|
|
415
|
+
const t = e.segments.find((n) => n.type === "field" && n.token === s);
|
|
421
416
|
if (t?.type === "field" && t.pattern) return t.pattern;
|
|
422
417
|
}
|
|
423
|
-
return
|
|
418
|
+
return $t;
|
|
424
419
|
}
|
|
425
|
-
function x(
|
|
426
|
-
const
|
|
427
|
-
return new RegExp(
|
|
420
|
+
function x(s, e, t) {
|
|
421
|
+
const n = t?.delimiter ?? kt, i = Rt(s, t);
|
|
422
|
+
return new RegExp(i).test(e) ? e.includes(n) ? `"${e}" contains the naming delimiter "${n}"` : null : `"${e}" does not match naming pattern ${i} for token "${s}"`;
|
|
428
423
|
}
|
|
429
|
-
function
|
|
430
|
-
const t = [],
|
|
431
|
-
const r = x(
|
|
424
|
+
function Tt(s, e) {
|
|
425
|
+
const t = [], n = (i, o) => {
|
|
426
|
+
const r = x(i, o, e);
|
|
432
427
|
r && t.push(r);
|
|
433
428
|
};
|
|
434
|
-
|
|
435
|
-
for (const
|
|
436
|
-
for (const
|
|
437
|
-
for (const
|
|
438
|
-
for (const
|
|
429
|
+
n("project", s.project.code);
|
|
430
|
+
for (const i of s.teams) n("team", i.id);
|
|
431
|
+
for (const i of s.disciplines) n("discipline", i.id);
|
|
432
|
+
for (const i of s.assetTypes) n("assetType", i.id);
|
|
433
|
+
for (const i of s.lbs) n(i.type === "zone" ? "lbsZone" : "lbsLocation", i.id);
|
|
439
434
|
return t;
|
|
440
435
|
}
|
|
441
436
|
class jt {
|
|
442
|
-
constructor(e, t,
|
|
443
|
-
this.getItem = e, this.setItem = t, this.schema =
|
|
437
|
+
constructor(e, t, n, i, o) {
|
|
438
|
+
this.getItem = e, this.setItem = t, this.schema = n, this.validate = i, this.getBep = o;
|
|
444
439
|
}
|
|
445
440
|
getItem;
|
|
446
441
|
setItem;
|
|
@@ -453,13 +448,13 @@ class jt {
|
|
|
453
448
|
update(e) {
|
|
454
449
|
const t = this.schema.parse({ ...this.getItem(), ...e });
|
|
455
450
|
if (this.validate && this.getBep) {
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
451
|
+
const n = this.validate(t, this.getBep());
|
|
452
|
+
if (n.length) throw new Error(n.join("; "));
|
|
458
453
|
}
|
|
459
454
|
return this.setItem(t), t;
|
|
460
455
|
}
|
|
461
456
|
}
|
|
462
|
-
const
|
|
457
|
+
const Ze = [
|
|
463
458
|
// roles
|
|
464
459
|
{ entity: "members", references: "roles", inField: "roleId" },
|
|
465
460
|
// members
|
|
@@ -499,29 +494,29 @@ const Je = [
|
|
|
499
494
|
// lbs (self-referential)
|
|
500
495
|
{ entity: "lbs", references: "lbs", inField: "lbsNodeIds", array: !0 }
|
|
501
496
|
];
|
|
502
|
-
function
|
|
503
|
-
return
|
|
504
|
-
const r =
|
|
505
|
-
return
|
|
506
|
-
}).map((
|
|
507
|
-
const r =
|
|
508
|
-
return `${String(
|
|
497
|
+
function At(s, e, t) {
|
|
498
|
+
return Ze.filter((n) => n.references === e).flatMap((n) => t[n.entity].filter((o) => {
|
|
499
|
+
const r = o[n.inField];
|
|
500
|
+
return n.array ? Array.isArray(r) && r.includes(s) : r === s;
|
|
501
|
+
}).map((o) => {
|
|
502
|
+
const r = o.id ?? o.email ?? "?";
|
|
503
|
+
return `${String(n.entity)}["${r}"].${String(n.inField)}`;
|
|
509
504
|
}));
|
|
510
505
|
}
|
|
511
|
-
function ae(
|
|
512
|
-
return
|
|
513
|
-
const
|
|
514
|
-
if (
|
|
515
|
-
const
|
|
516
|
-
return
|
|
506
|
+
function ae(s, e, t) {
|
|
507
|
+
return Ze.filter((n) => n.entity === e).flatMap((n) => {
|
|
508
|
+
const i = s[n.inField];
|
|
509
|
+
if (i == null || i === "") return [];
|
|
510
|
+
const o = n.array ? i : [i], r = t[n.references];
|
|
511
|
+
return o.filter((d) => !r.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(n.references)}["${d}"] not found`);
|
|
517
512
|
});
|
|
518
513
|
}
|
|
519
|
-
function K(
|
|
520
|
-
return
|
|
514
|
+
function K(s) {
|
|
515
|
+
return s instanceof Ve ? s.issues.map((e) => (e.path.length ? e.path.join(".") + ": " : "") + e.message).join("; ") : s.message;
|
|
521
516
|
}
|
|
522
517
|
class y {
|
|
523
|
-
constructor(e, t,
|
|
524
|
-
this.getItems = e, this.getBep = t, this.config =
|
|
518
|
+
constructor(e, t, n) {
|
|
519
|
+
this.getItems = e, this.getBep = t, this.config = n, this.idField = n.idField ?? "id";
|
|
525
520
|
}
|
|
526
521
|
getItems;
|
|
527
522
|
getBep;
|
|
@@ -534,21 +529,21 @@ class y {
|
|
|
534
529
|
return this.getItems();
|
|
535
530
|
}
|
|
536
531
|
get(e) {
|
|
537
|
-
const t = [],
|
|
538
|
-
for (const
|
|
539
|
-
const
|
|
540
|
-
|
|
532
|
+
const t = [], n = [];
|
|
533
|
+
for (const i of e) {
|
|
534
|
+
const o = this.getItems().find((r) => this.getId(r) === i);
|
|
535
|
+
o ? t.push(o) : n.push({ id: i, error: `Not found: ${i}` });
|
|
541
536
|
}
|
|
542
|
-
return { succeeded: t, failed:
|
|
537
|
+
return { succeeded: t, failed: n };
|
|
543
538
|
}
|
|
544
539
|
add(e) {
|
|
545
|
-
const t = [],
|
|
546
|
-
for (const
|
|
547
|
-
const
|
|
548
|
-
this.config.autoId && !
|
|
549
|
-
const r = String(
|
|
540
|
+
const t = [], n = [];
|
|
541
|
+
for (const i of e) {
|
|
542
|
+
const o = { ...i };
|
|
543
|
+
this.config.autoId && !o[this.idField] && (o[this.idField] = globalThis.crypto.randomUUID());
|
|
544
|
+
const r = String(o[this.idField] ?? "(unknown)");
|
|
550
545
|
try {
|
|
551
|
-
const d = this.config.schema.parse(
|
|
546
|
+
const d = this.config.schema.parse(o);
|
|
552
547
|
if (this.getItems().some((u) => this.getId(u) === this.getId(d)))
|
|
553
548
|
throw new Error(`Already exists: ${this.getId(d)}`);
|
|
554
549
|
const l = ae(d, this.config.key, this.getBep());
|
|
@@ -557,54 +552,54 @@ class y {
|
|
|
557
552
|
if (c.length) throw new Error(c.join("; "));
|
|
558
553
|
this.getItems().push(d), t.push(d);
|
|
559
554
|
} catch (d) {
|
|
560
|
-
|
|
555
|
+
n.push({ id: r, error: K(d) });
|
|
561
556
|
}
|
|
562
557
|
}
|
|
563
|
-
return { succeeded: t, failed:
|
|
558
|
+
return { succeeded: t, failed: n };
|
|
564
559
|
}
|
|
565
560
|
update(e) {
|
|
566
|
-
const t = [],
|
|
567
|
-
for (const
|
|
568
|
-
const
|
|
561
|
+
const t = [], n = [];
|
|
562
|
+
for (const i of e) {
|
|
563
|
+
const o = String(i[this.idField]), r = this.getItems(), d = r.findIndex((c) => this.getId(c) === o);
|
|
569
564
|
if (d === -1) {
|
|
570
|
-
|
|
565
|
+
n.push({ id: o, error: `Not found: ${o}` });
|
|
571
566
|
continue;
|
|
572
567
|
}
|
|
573
|
-
const l = ae(
|
|
568
|
+
const l = ae(i, this.config.key, this.getBep());
|
|
574
569
|
if (l.length) {
|
|
575
|
-
|
|
570
|
+
n.push({ id: o, error: l.join("; ") });
|
|
576
571
|
continue;
|
|
577
572
|
}
|
|
578
573
|
try {
|
|
579
|
-
const c = this.config.schema.parse({ ...r[d], ...
|
|
574
|
+
const c = this.config.schema.parse({ ...r[d], ...i }), u = this.config.validate?.(c, this.getBep()) ?? [];
|
|
580
575
|
if (u.length) throw new Error(u.join("; "));
|
|
581
576
|
r[d] = c, t.push(r[d]);
|
|
582
577
|
} catch (c) {
|
|
583
|
-
|
|
578
|
+
n.push({ id: o, error: K(c) });
|
|
584
579
|
}
|
|
585
580
|
}
|
|
586
|
-
return { succeeded: t, failed:
|
|
581
|
+
return { succeeded: t, failed: n };
|
|
587
582
|
}
|
|
588
583
|
remove(e) {
|
|
589
|
-
const t = [],
|
|
590
|
-
for (const
|
|
591
|
-
const
|
|
584
|
+
const t = [], n = [];
|
|
585
|
+
for (const i of e) {
|
|
586
|
+
const o = this.getItems(), r = o.findIndex((d) => this.getId(d) === i);
|
|
592
587
|
if (r === -1) {
|
|
593
|
-
|
|
588
|
+
n.push({ id: i, error: `Not found: ${i}` });
|
|
594
589
|
continue;
|
|
595
590
|
}
|
|
596
591
|
try {
|
|
597
|
-
const d =
|
|
592
|
+
const d = At(i, this.config.key, this.getBep());
|
|
598
593
|
if (d.length) throw new Error(`Referenced by: ${d.join(", ")}`);
|
|
599
|
-
this.config.beforeRemove?.(
|
|
594
|
+
this.config.beforeRemove?.(i, this.getBep()), o.splice(r, 1), t.push(i);
|
|
600
595
|
} catch (d) {
|
|
601
|
-
|
|
596
|
+
n.push({ id: i, error: K(d) });
|
|
602
597
|
}
|
|
603
598
|
}
|
|
604
|
-
return { succeeded: t, failed:
|
|
599
|
+
return { succeeded: t, failed: n };
|
|
605
600
|
}
|
|
606
601
|
}
|
|
607
|
-
class
|
|
602
|
+
class Ot extends y {
|
|
608
603
|
constructor(e) {
|
|
609
604
|
super(
|
|
610
605
|
() => e().actions,
|
|
@@ -613,29 +608,17 @@ class _t extends y {
|
|
|
613
608
|
key: "actions",
|
|
614
609
|
schema: ke,
|
|
615
610
|
autoId: !0,
|
|
616
|
-
beforeRemove: (t,
|
|
617
|
-
for (const
|
|
618
|
-
for (const [
|
|
611
|
+
beforeRemove: (t, n) => {
|
|
612
|
+
for (const i of n.workflows)
|
|
613
|
+
for (const [o, r] of Object.entries(i.diagram.nodes))
|
|
619
614
|
if (r.type === "process" && r.actionId === t)
|
|
620
|
-
throw new Error(`Referenced by: workflows["${
|
|
615
|
+
throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].actionId`);
|
|
621
616
|
}
|
|
622
617
|
}
|
|
623
618
|
);
|
|
624
619
|
}
|
|
625
620
|
}
|
|
626
|
-
class
|
|
627
|
-
constructor(e) {
|
|
628
|
-
super(
|
|
629
|
-
() => e().adapters,
|
|
630
|
-
e,
|
|
631
|
-
{
|
|
632
|
-
key: "adapters",
|
|
633
|
-
schema: ze
|
|
634
|
-
}
|
|
635
|
-
);
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
class Mt extends y {
|
|
621
|
+
class _t extends y {
|
|
639
622
|
constructor(e) {
|
|
640
623
|
super(
|
|
641
624
|
() => e().annexes,
|
|
@@ -648,7 +631,7 @@ class Mt extends y {
|
|
|
648
631
|
);
|
|
649
632
|
}
|
|
650
633
|
}
|
|
651
|
-
class
|
|
634
|
+
class Bt extends y {
|
|
652
635
|
constructor(e) {
|
|
653
636
|
super(
|
|
654
637
|
() => e().effects,
|
|
@@ -656,21 +639,21 @@ class xt extends y {
|
|
|
656
639
|
{
|
|
657
640
|
key: "effects",
|
|
658
641
|
schema: Re,
|
|
659
|
-
beforeRemove: (t,
|
|
660
|
-
for (const
|
|
661
|
-
for (const [
|
|
642
|
+
beforeRemove: (t, n) => {
|
|
643
|
+
for (const i of n.workflows) {
|
|
644
|
+
for (const [o, r] of Object.entries(i.diagram.nodes))
|
|
662
645
|
if ((r.type === "process" || r.type === "automation") && r.timeouts?.some((d) => d.effectId === t))
|
|
663
|
-
throw new Error(`Referenced by: workflows["${
|
|
664
|
-
for (const [
|
|
646
|
+
throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].timeouts[].effectId`);
|
|
647
|
+
for (const [o, r] of Object.entries(i.diagram.edges))
|
|
665
648
|
if (r.effectIds?.includes(t))
|
|
666
|
-
throw new Error(`Referenced by: workflows["${
|
|
649
|
+
throw new Error(`Referenced by: workflows["${i.id}"].diagram.edges["${o}"].effectIds`);
|
|
667
650
|
}
|
|
668
651
|
}
|
|
669
652
|
}
|
|
670
653
|
);
|
|
671
654
|
}
|
|
672
655
|
}
|
|
673
|
-
class
|
|
656
|
+
class Mt extends y {
|
|
674
657
|
constructor(e) {
|
|
675
658
|
super(
|
|
676
659
|
() => e().automations,
|
|
@@ -678,17 +661,17 @@ class Pt extends y {
|
|
|
678
661
|
{
|
|
679
662
|
key: "automations",
|
|
680
663
|
schema: Te,
|
|
681
|
-
beforeRemove: (t,
|
|
682
|
-
for (const
|
|
683
|
-
for (const [
|
|
664
|
+
beforeRemove: (t, n) => {
|
|
665
|
+
for (const i of n.workflows)
|
|
666
|
+
for (const [o, r] of Object.entries(i.diagram.nodes))
|
|
684
667
|
if (r.type === "automation" && r.automationId === t)
|
|
685
|
-
throw new Error(`Referenced by: workflows["${
|
|
668
|
+
throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${o}"].automationId`);
|
|
686
669
|
}
|
|
687
670
|
}
|
|
688
671
|
);
|
|
689
672
|
}
|
|
690
673
|
}
|
|
691
|
-
class
|
|
674
|
+
class xt extends y {
|
|
692
675
|
constructor(e) {
|
|
693
676
|
super(
|
|
694
677
|
() => e().env,
|
|
@@ -701,7 +684,7 @@ class Ft extends y {
|
|
|
701
684
|
);
|
|
702
685
|
}
|
|
703
686
|
}
|
|
704
|
-
class
|
|
687
|
+
class Pt extends y {
|
|
705
688
|
constructor(e) {
|
|
706
689
|
super(
|
|
707
690
|
() => e().events,
|
|
@@ -709,113 +692,113 @@ class Ct extends y {
|
|
|
709
692
|
{
|
|
710
693
|
key: "events",
|
|
711
694
|
schema: $e,
|
|
712
|
-
beforeRemove: (t,
|
|
713
|
-
for (const
|
|
714
|
-
for (const [
|
|
695
|
+
beforeRemove: (t, n) => {
|
|
696
|
+
for (const i of n.workflows)
|
|
697
|
+
for (const [o, r] of Object.entries(i.diagram.edges))
|
|
715
698
|
if ("triggerEventId" in r && r.triggerEventId === t)
|
|
716
|
-
throw new Error(`Referenced by: workflows["${
|
|
699
|
+
throw new Error(`Referenced by: workflows["${i.id}"].diagram.edges["${o}"].trigger`);
|
|
717
700
|
}
|
|
718
701
|
}
|
|
719
702
|
);
|
|
720
703
|
}
|
|
721
704
|
}
|
|
722
|
-
function C(
|
|
705
|
+
function C(s) {
|
|
723
706
|
const e = /* @__PURE__ */ new Map();
|
|
724
|
-
for (const t of
|
|
725
|
-
for (const
|
|
726
|
-
e.set(
|
|
707
|
+
for (const t of s)
|
|
708
|
+
for (const n of t.lbsNodeIds ?? [])
|
|
709
|
+
e.set(n, t.id);
|
|
727
710
|
return e;
|
|
728
711
|
}
|
|
729
|
-
function te(
|
|
712
|
+
function te(s) {
|
|
730
713
|
const e = /* @__PURE__ */ new Set();
|
|
731
|
-
for (const t of
|
|
732
|
-
for (const
|
|
733
|
-
return new Set(
|
|
734
|
-
}
|
|
735
|
-
function
|
|
736
|
-
if (!
|
|
737
|
-
const t = new Map(e.map((d) => [d.id, d])),
|
|
738
|
-
if (!
|
|
739
|
-
if (
|
|
740
|
-
if (
|
|
741
|
-
let r =
|
|
714
|
+
for (const t of s)
|
|
715
|
+
for (const n of t.lbsNodeIds ?? []) e.add(n);
|
|
716
|
+
return new Set(s.map((t) => t.id).filter((t) => !e.has(t)));
|
|
717
|
+
}
|
|
718
|
+
function Je(s, e) {
|
|
719
|
+
if (!s) return { zoneCode: "XXX", locationCode: "XXX" };
|
|
720
|
+
const t = new Map(e.map((d) => [d.id, d])), n = C(e), i = te(e), o = t.get(s);
|
|
721
|
+
if (!o) return { zoneCode: "XXX", locationCode: "XXX" };
|
|
722
|
+
if (i.has(o.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
|
|
723
|
+
if (o.type === "zone") return { zoneCode: o.id, locationCode: "ZZZ" };
|
|
724
|
+
let r = n.get(o.id);
|
|
742
725
|
for (; r; ) {
|
|
743
726
|
const d = t.get(r);
|
|
744
727
|
if (!d) break;
|
|
745
|
-
if (d.type === "zone" && !
|
|
746
|
-
return { zoneCode: d.id, locationCode:
|
|
747
|
-
r =
|
|
728
|
+
if (d.type === "zone" && !i.has(d.id))
|
|
729
|
+
return { zoneCode: d.id, locationCode: o.id };
|
|
730
|
+
r = n.get(r);
|
|
748
731
|
}
|
|
749
|
-
return { zoneCode: "ZZZ", locationCode:
|
|
732
|
+
return { zoneCode: "ZZZ", locationCode: o.id };
|
|
750
733
|
}
|
|
751
|
-
function
|
|
752
|
-
const e = [], t = new Map(
|
|
753
|
-
for (const d of
|
|
734
|
+
function Ft(s) {
|
|
735
|
+
const e = [], t = new Map(s.map((d) => [d.id, d])), n = te(s);
|
|
736
|
+
for (const d of n) {
|
|
754
737
|
const l = t.get(d);
|
|
755
738
|
l && l.type !== "zone" && e.push(`Root node "${d}" must be of type "zone".`);
|
|
756
739
|
}
|
|
757
|
-
for (const d of
|
|
740
|
+
for (const d of s)
|
|
758
741
|
if (d.type === "location")
|
|
759
742
|
for (const l of d.lbsNodeIds ?? [])
|
|
760
743
|
t.get(l)?.type === "zone" && e.push(`Node "${d.id}" (location) cannot have a zone child ("${l}").`);
|
|
761
|
-
const
|
|
744
|
+
const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
762
745
|
function r(d) {
|
|
763
|
-
if (
|
|
764
|
-
if (
|
|
765
|
-
|
|
746
|
+
if (o.has(d)) return !0;
|
|
747
|
+
if (i.has(d)) return !1;
|
|
748
|
+
i.add(d), o.add(d);
|
|
766
749
|
for (const l of t.get(d)?.lbsNodeIds ?? [])
|
|
767
750
|
if (r(l))
|
|
768
751
|
return e.push(`Cycle detected in LBS tree at node "${d}".`), !0;
|
|
769
|
-
return
|
|
752
|
+
return o.delete(d), !1;
|
|
770
753
|
}
|
|
771
|
-
for (const d of
|
|
772
|
-
|
|
754
|
+
for (const d of s)
|
|
755
|
+
i.has(d.id) || r(d.id);
|
|
773
756
|
return e;
|
|
774
757
|
}
|
|
775
|
-
function W(
|
|
758
|
+
function W(s) {
|
|
776
759
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
777
|
-
for (const
|
|
778
|
-
const
|
|
779
|
-
t.set(
|
|
760
|
+
for (const n of s) {
|
|
761
|
+
const i = (t.get(n.responsibleId) ?? 0) + 1;
|
|
762
|
+
t.set(n.responsibleId, i), e.set(n.id, i);
|
|
780
763
|
}
|
|
781
764
|
return e;
|
|
782
765
|
}
|
|
783
766
|
const F = "XXX";
|
|
784
|
-
function
|
|
785
|
-
const { zoneCode:
|
|
786
|
-
if (!
|
|
787
|
-
const l = String(t.get(
|
|
788
|
-
return [e,
|
|
767
|
+
function Ke(s, e, t, n, i) {
|
|
768
|
+
const { zoneCode: o, locationCode: r } = Je(s.lbsNodeId, n);
|
|
769
|
+
if (!i) {
|
|
770
|
+
const l = String(t.get(s.id) ?? 0).padStart(3, "0");
|
|
771
|
+
return [e, s.responsibleId, o, r, s.assetTypeId, s.disciplineId, l].join("-");
|
|
789
772
|
}
|
|
790
|
-
return
|
|
773
|
+
return i.segments.map((l) => {
|
|
791
774
|
if (l.type === "sequence") {
|
|
792
775
|
const c = l.padding ?? 3;
|
|
793
|
-
return String(t.get(
|
|
776
|
+
return String(t.get(s.id) ?? 0).padStart(c, "0");
|
|
794
777
|
}
|
|
795
778
|
switch (l.token) {
|
|
796
779
|
case "project":
|
|
797
780
|
return e || F;
|
|
798
781
|
case "team":
|
|
799
|
-
return
|
|
782
|
+
return s.responsibleId || F;
|
|
800
783
|
case "discipline":
|
|
801
|
-
return
|
|
784
|
+
return s.disciplineId || F;
|
|
802
785
|
case "assetType":
|
|
803
|
-
return
|
|
786
|
+
return s.assetTypeId || F;
|
|
804
787
|
case "lbsZone":
|
|
805
|
-
return
|
|
788
|
+
return o;
|
|
806
789
|
case "lbsLocation":
|
|
807
790
|
return r;
|
|
808
791
|
}
|
|
809
|
-
}).join(
|
|
792
|
+
}).join(i.delimiter);
|
|
810
793
|
}
|
|
811
|
-
function
|
|
812
|
-
const
|
|
813
|
-
return new Map(
|
|
814
|
-
|
|
815
|
-
|
|
794
|
+
function qe(s, e, t, n) {
|
|
795
|
+
const i = W(s);
|
|
796
|
+
return new Map(s.map((o) => [
|
|
797
|
+
o.id,
|
|
798
|
+
Ke(o, e, i, t, n)
|
|
816
799
|
]));
|
|
817
800
|
}
|
|
818
|
-
class
|
|
801
|
+
class Ct {
|
|
819
802
|
constructor(e) {
|
|
820
803
|
this.getBep = e;
|
|
821
804
|
}
|
|
@@ -829,19 +812,19 @@ class Lt {
|
|
|
829
812
|
* Returns null if the deliverable id is not found.
|
|
830
813
|
*/
|
|
831
814
|
getCode(e) {
|
|
832
|
-
const t = this.getBep(),
|
|
833
|
-
if (!
|
|
834
|
-
const
|
|
835
|
-
return
|
|
815
|
+
const t = this.getBep(), n = t.deliverables.find((o) => o.id === e);
|
|
816
|
+
if (!n) return null;
|
|
817
|
+
const i = W(t.deliverables);
|
|
818
|
+
return Ke(n, t.project.code, i, t.lbs, t.deliverableNamingConvention);
|
|
836
819
|
}
|
|
837
820
|
/** Builds the complete map of deliverable.id → nomenclature code. */
|
|
838
821
|
buildCodeMap() {
|
|
839
822
|
const e = this.getBep();
|
|
840
|
-
return
|
|
823
|
+
return qe(e.deliverables, e.project.code, e.lbs, e.deliverableNamingConvention);
|
|
841
824
|
}
|
|
842
825
|
}
|
|
843
|
-
class
|
|
844
|
-
constructor(e, t,
|
|
826
|
+
class Dt extends y {
|
|
827
|
+
constructor(e, t, n, i, o) {
|
|
845
828
|
super(
|
|
846
829
|
() => e().deliverables,
|
|
847
830
|
e,
|
|
@@ -850,25 +833,25 @@ class Ut extends y {
|
|
|
850
833
|
schema: De,
|
|
851
834
|
autoId: !0
|
|
852
835
|
}
|
|
853
|
-
), this.getTeams = t, this.getAssetTypes =
|
|
836
|
+
), this.getTeams = t, this.getAssetTypes = n, this.getLBSNodes = i, this.getMilestones = o;
|
|
854
837
|
}
|
|
855
838
|
getTeams;
|
|
856
839
|
getAssetTypes;
|
|
857
840
|
getLBSNodes;
|
|
858
841
|
getMilestones;
|
|
859
842
|
listResolved() {
|
|
860
|
-
const e = this.getBep(), t =
|
|
843
|
+
const e = this.getBep(), t = qe(e.deliverables, e.project.code, e.lbs), n = new Map(this.getTeams().listResolved().map((l) => [l.id, l])), i = new Map(this.getAssetTypes().listResolved().map((l) => [l.id, l])), o = new Map(this.getLBSNodes().listResolved().map((l) => [l.id, l])), r = new Map(this.getMilestones().listResolved().map((l) => [l.id, l])), d = /* @__PURE__ */ new Map();
|
|
861
844
|
for (const l of e.deliverables) {
|
|
862
845
|
const c = r.get(l.milestoneId) ?? null;
|
|
863
846
|
d.set(l.id, {
|
|
864
847
|
...l,
|
|
865
848
|
nomenclatureCode: t.get(l.id) ?? "",
|
|
866
849
|
effectiveDate: l.dueDate ?? c?.date ?? "",
|
|
867
|
-
lbsNode: l.lbsNodeId ?
|
|
850
|
+
lbsNode: l.lbsNodeId ? o.get(l.lbsNodeId) ?? null : null,
|
|
868
851
|
discipline: e.disciplines.find((u) => u.id === l.disciplineId) ?? null,
|
|
869
|
-
assetType:
|
|
852
|
+
assetType: i.get(l.assetTypeId) ?? null,
|
|
870
853
|
extensions: (l.extensionIds ?? []).map((u) => e.extensions.find((f) => f.id === u)).filter(Boolean),
|
|
871
|
-
responsible:
|
|
854
|
+
responsible: n.get(l.responsibleId) ?? null,
|
|
872
855
|
milestone: c,
|
|
873
856
|
predecessor: null
|
|
874
857
|
});
|
|
@@ -881,7 +864,7 @@ class Ut extends y {
|
|
|
881
864
|
return [...d.values()];
|
|
882
865
|
}
|
|
883
866
|
}
|
|
884
|
-
class
|
|
867
|
+
class Lt extends y {
|
|
885
868
|
constructor(e) {
|
|
886
869
|
super(
|
|
887
870
|
() => e().flags,
|
|
@@ -894,7 +877,7 @@ class zt extends y {
|
|
|
894
877
|
);
|
|
895
878
|
}
|
|
896
879
|
}
|
|
897
|
-
class
|
|
880
|
+
class Ut extends y {
|
|
898
881
|
constructor(e, t) {
|
|
899
882
|
super(
|
|
900
883
|
() => e().notes,
|
|
@@ -915,7 +898,7 @@ class Zt extends y {
|
|
|
915
898
|
}));
|
|
916
899
|
}
|
|
917
900
|
}
|
|
918
|
-
class
|
|
901
|
+
class zt extends y {
|
|
919
902
|
constructor(e, t) {
|
|
920
903
|
super(
|
|
921
904
|
() => e().bimUses,
|
|
@@ -924,34 +907,34 @@ class Jt extends y {
|
|
|
924
907
|
key: "bimUses",
|
|
925
908
|
schema: Se,
|
|
926
909
|
autoId: !0,
|
|
927
|
-
validate: (
|
|
928
|
-
const
|
|
929
|
-
for (const r of
|
|
930
|
-
|
|
931
|
-
for (const r of
|
|
932
|
-
|
|
933
|
-
for (const r of
|
|
934
|
-
|
|
935
|
-
return
|
|
910
|
+
validate: (n, i) => {
|
|
911
|
+
const o = [];
|
|
912
|
+
for (const r of n.objectiveIds ?? [])
|
|
913
|
+
i.objectives.some((d) => d.id === r) || o.push(`objectives["${r}"] not found`);
|
|
914
|
+
for (const r of n.milestoneIds ?? [])
|
|
915
|
+
i.milestones.some((d) => d.id === r) || o.push(`milestones["${r}"] not found`);
|
|
916
|
+
for (const r of n.workflowIds ?? [])
|
|
917
|
+
i.workflows.some((d) => d.id === r) || o.push(`workflows["${r}"] not found`);
|
|
918
|
+
return o;
|
|
936
919
|
}
|
|
937
920
|
}
|
|
938
921
|
), this.getWorkflows = t;
|
|
939
922
|
}
|
|
940
923
|
getWorkflows;
|
|
941
924
|
listResolved() {
|
|
942
|
-
const e = this.getBep(), t = new Map(this.getWorkflows().listResolved().map((
|
|
943
|
-
return e.bimUses.map((
|
|
944
|
-
...
|
|
945
|
-
objectives: (
|
|
946
|
-
milestones: (
|
|
947
|
-
const
|
|
948
|
-
return
|
|
925
|
+
const e = this.getBep(), t = new Map(this.getWorkflows().listResolved().map((n) => [n.id, n]));
|
|
926
|
+
return e.bimUses.map((n) => ({
|
|
927
|
+
...n,
|
|
928
|
+
objectives: (n.objectiveIds ?? []).map((i) => e.objectives.find((o) => o.id === i)).filter(Boolean),
|
|
929
|
+
milestones: (n.milestoneIds ?? []).map((i) => {
|
|
930
|
+
const o = e.milestones.find((r) => r.id === i);
|
|
931
|
+
return o ? { ...o, phase: e.phases.find((r) => r.id === o.phaseId) ?? null } : null;
|
|
949
932
|
}).filter(Boolean),
|
|
950
|
-
workflows: (
|
|
933
|
+
workflows: (n.workflowIds ?? []).map((i) => t.get(i)).filter(Boolean)
|
|
951
934
|
}));
|
|
952
935
|
}
|
|
953
936
|
}
|
|
954
|
-
class
|
|
937
|
+
class Zt extends y {
|
|
955
938
|
constructor(e) {
|
|
956
939
|
super(
|
|
957
940
|
() => e().disciplines,
|
|
@@ -959,15 +942,15 @@ class Kt extends y {
|
|
|
959
942
|
{
|
|
960
943
|
key: "disciplines",
|
|
961
944
|
schema: we,
|
|
962
|
-
validate: (t,
|
|
963
|
-
const
|
|
964
|
-
return
|
|
945
|
+
validate: (t, n) => {
|
|
946
|
+
const i = x("discipline", t.id, n.deliverableNamingConvention);
|
|
947
|
+
return i ? [i] : [];
|
|
965
948
|
}
|
|
966
949
|
}
|
|
967
950
|
);
|
|
968
951
|
}
|
|
969
952
|
}
|
|
970
|
-
class
|
|
953
|
+
class Jt extends y {
|
|
971
954
|
constructor(e) {
|
|
972
955
|
super(
|
|
973
956
|
() => e().guides,
|
|
@@ -983,11 +966,11 @@ class qt extends y {
|
|
|
983
966
|
const e = this.getBep();
|
|
984
967
|
return e.guides.map((t) => ({
|
|
985
968
|
...t,
|
|
986
|
-
annexes: (t.annexIds ?? []).map((
|
|
969
|
+
annexes: (t.annexIds ?? []).map((n) => e.annexes.find((i) => i.id === n)).filter(Boolean)
|
|
987
970
|
}));
|
|
988
971
|
}
|
|
989
972
|
}
|
|
990
|
-
class
|
|
973
|
+
class Kt extends y {
|
|
991
974
|
constructor(e) {
|
|
992
975
|
super(
|
|
993
976
|
() => e().lods,
|
|
@@ -995,15 +978,15 @@ class Wt extends y {
|
|
|
995
978
|
{
|
|
996
979
|
key: "lods",
|
|
997
980
|
schema: Me,
|
|
998
|
-
beforeRemove: (t,
|
|
999
|
-
for (const
|
|
1000
|
-
if (
|
|
981
|
+
beforeRemove: (t, n) => {
|
|
982
|
+
for (const i of n.loin)
|
|
983
|
+
if (i.milestones?.find((r) => r.lodId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[lodId=${t}]`);
|
|
1001
984
|
}
|
|
1002
985
|
}
|
|
1003
986
|
);
|
|
1004
987
|
}
|
|
1005
988
|
}
|
|
1006
|
-
class
|
|
989
|
+
class qt extends y {
|
|
1007
990
|
constructor(e) {
|
|
1008
991
|
super(
|
|
1009
992
|
() => e().lois,
|
|
@@ -1011,15 +994,15 @@ class Gt extends y {
|
|
|
1011
994
|
{
|
|
1012
995
|
key: "lois",
|
|
1013
996
|
schema: xe,
|
|
1014
|
-
beforeRemove: (t,
|
|
1015
|
-
for (const
|
|
1016
|
-
if (
|
|
997
|
+
beforeRemove: (t, n) => {
|
|
998
|
+
for (const i of n.loin)
|
|
999
|
+
if (i.milestones?.find((r) => r.loiId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[loiId=${t}]`);
|
|
1017
1000
|
}
|
|
1018
1001
|
}
|
|
1019
1002
|
);
|
|
1020
1003
|
}
|
|
1021
1004
|
}
|
|
1022
|
-
class
|
|
1005
|
+
class Wt extends y {
|
|
1023
1006
|
constructor(e) {
|
|
1024
1007
|
super(
|
|
1025
1008
|
() => e().loin,
|
|
@@ -1028,102 +1011,102 @@ class Vt extends y {
|
|
|
1028
1011
|
key: "loin",
|
|
1029
1012
|
schema: Pe,
|
|
1030
1013
|
autoId: !0,
|
|
1031
|
-
validate: (t,
|
|
1032
|
-
const
|
|
1033
|
-
for (const
|
|
1034
|
-
|
|
1035
|
-
return
|
|
1014
|
+
validate: (t, n) => {
|
|
1015
|
+
const i = [];
|
|
1016
|
+
for (const o of t.milestones ?? [])
|
|
1017
|
+
n.milestones.some((r) => r.id === o.milestoneId) || i.push(`milestones["${o.milestoneId}"] not found`), n.lods.some((r) => r.id === o.lodId) || i.push(`lods[${o.lodId}] not found`), n.lois.some((r) => r.id === o.loiId) || i.push(`lois[${o.loiId}] not found`);
|
|
1018
|
+
return i;
|
|
1036
1019
|
}
|
|
1037
1020
|
}
|
|
1038
1021
|
);
|
|
1039
1022
|
}
|
|
1040
1023
|
addMilestones(e) {
|
|
1041
|
-
const t = [],
|
|
1042
|
-
for (const
|
|
1043
|
-
const
|
|
1044
|
-
if (!
|
|
1045
|
-
|
|
1024
|
+
const t = [], n = [];
|
|
1025
|
+
for (const i of e) {
|
|
1026
|
+
const o = this.getBep().loin.find((c) => c.id === i.loinId);
|
|
1027
|
+
if (!o) {
|
|
1028
|
+
n.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
|
|
1046
1029
|
continue;
|
|
1047
1030
|
}
|
|
1048
|
-
const r =
|
|
1031
|
+
const r = i.milestones.find((c) => (o.milestones ?? []).some((u) => u.milestoneId === c.milestoneId));
|
|
1049
1032
|
if (r) {
|
|
1050
|
-
|
|
1033
|
+
n.push({ loinId: i.loinId, error: `Milestone "${r.milestoneId}" already exists. Use updateMilestones to modify it.` });
|
|
1051
1034
|
continue;
|
|
1052
1035
|
}
|
|
1053
|
-
const d = [...
|
|
1036
|
+
const d = [...o.milestones ?? [], ...i.milestones], l = this.update([{ id: i.loinId, milestones: d }]);
|
|
1054
1037
|
if (l.failed.length > 0) {
|
|
1055
|
-
|
|
1038
|
+
n.push({ loinId: i.loinId, error: l.failed[0].error });
|
|
1056
1039
|
continue;
|
|
1057
1040
|
}
|
|
1058
|
-
t.push({ loinId:
|
|
1041
|
+
t.push({ loinId: i.loinId, element: o.element, addedMilestones: i.milestones.map((c) => c.milestoneId) });
|
|
1059
1042
|
}
|
|
1060
|
-
return { succeeded: t, failed:
|
|
1043
|
+
return { succeeded: t, failed: n };
|
|
1061
1044
|
}
|
|
1062
1045
|
updateMilestones(e) {
|
|
1063
|
-
const t = [],
|
|
1064
|
-
for (const
|
|
1065
|
-
const
|
|
1066
|
-
if (!
|
|
1067
|
-
|
|
1046
|
+
const t = [], n = [];
|
|
1047
|
+
for (const i of e) {
|
|
1048
|
+
const o = this.getBep().loin.find((f) => f.id === i.loinId);
|
|
1049
|
+
if (!o) {
|
|
1050
|
+
n.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
|
|
1068
1051
|
continue;
|
|
1069
1052
|
}
|
|
1070
|
-
const r =
|
|
1053
|
+
const r = i.milestones.find((f) => !(o.milestones ?? []).some((m) => m.milestoneId === f.milestoneId));
|
|
1071
1054
|
if (r) {
|
|
1072
|
-
|
|
1055
|
+
n.push({ loinId: i.loinId, error: `Milestone "${r.milestoneId}" not found. Use addMilestones to create it.` });
|
|
1073
1056
|
continue;
|
|
1074
1057
|
}
|
|
1075
|
-
const d = new Map(
|
|
1076
|
-
const m =
|
|
1058
|
+
const d = new Map(o.milestones.map((f) => [f.milestoneId, { lodId: f.lodId, loiId: f.loiId, idsPath: f.idsPath }])), l = (o.milestones ?? []).map((f) => {
|
|
1059
|
+
const m = i.milestones.find((p) => p.milestoneId === f.milestoneId);
|
|
1077
1060
|
return m ? { ...f, ...m } : f;
|
|
1078
|
-
}), c = this.update([{ id:
|
|
1061
|
+
}), c = this.update([{ id: i.loinId, milestones: l }]);
|
|
1079
1062
|
if (c.failed.length > 0) {
|
|
1080
|
-
|
|
1063
|
+
n.push({ loinId: i.loinId, error: c.failed[0].error });
|
|
1081
1064
|
continue;
|
|
1082
1065
|
}
|
|
1083
|
-
const u = this.getBep().loin.find((f) => f.id ===
|
|
1066
|
+
const u = this.getBep().loin.find((f) => f.id === i.loinId);
|
|
1084
1067
|
t.push({
|
|
1085
|
-
loinId:
|
|
1086
|
-
element:
|
|
1087
|
-
milestones:
|
|
1068
|
+
loinId: i.loinId,
|
|
1069
|
+
element: o.element,
|
|
1070
|
+
milestones: i.milestones.map((f) => {
|
|
1088
1071
|
const m = u.milestones.find((g) => g.milestoneId === f.milestoneId), p = d.get(f.milestoneId);
|
|
1089
1072
|
return { milestoneId: f.milestoneId, before: p, after: { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath } };
|
|
1090
1073
|
})
|
|
1091
1074
|
});
|
|
1092
1075
|
}
|
|
1093
|
-
return { succeeded: t, failed:
|
|
1076
|
+
return { succeeded: t, failed: n };
|
|
1094
1077
|
}
|
|
1095
1078
|
removeMilestones(e) {
|
|
1096
|
-
const t = [],
|
|
1097
|
-
for (const
|
|
1098
|
-
const
|
|
1099
|
-
if (!
|
|
1100
|
-
|
|
1079
|
+
const t = [], n = [];
|
|
1080
|
+
for (const i of e) {
|
|
1081
|
+
const o = this.getBep().loin.find((d) => d.id === i.loinId);
|
|
1082
|
+
if (!o) {
|
|
1083
|
+
n.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
|
|
1101
1084
|
continue;
|
|
1102
1085
|
}
|
|
1103
|
-
const r =
|
|
1086
|
+
const r = i.milestoneIds.filter((d) => !(o.milestones ?? []).some((l) => l.milestoneId === d));
|
|
1104
1087
|
if (r.length > 0) {
|
|
1105
|
-
|
|
1088
|
+
n.push({ loinId: i.loinId, error: `Milestones not found in this LOIN: ${r.join(", ")}` });
|
|
1106
1089
|
continue;
|
|
1107
1090
|
}
|
|
1108
|
-
|
|
1091
|
+
o.milestones = (o.milestones ?? []).filter((d) => !i.milestoneIds.includes(d.milestoneId)), t.push({ loinId: i.loinId, element: o.element, removedMilestones: i.milestoneIds });
|
|
1109
1092
|
}
|
|
1110
|
-
return { succeeded: t, failed:
|
|
1093
|
+
return { succeeded: t, failed: n };
|
|
1111
1094
|
}
|
|
1112
1095
|
listResolved() {
|
|
1113
1096
|
const e = this.getBep();
|
|
1114
1097
|
return e.loin.map((t) => ({
|
|
1115
1098
|
...t,
|
|
1116
|
-
discipline: e.disciplines.find((
|
|
1117
|
-
milestones: (t.milestones ?? []).map((
|
|
1118
|
-
...
|
|
1119
|
-
milestone: e.milestones.find((
|
|
1120
|
-
lod: e.lods.find((
|
|
1121
|
-
loi: e.lois.find((
|
|
1099
|
+
discipline: e.disciplines.find((n) => n.id === t.disciplineId) ?? null,
|
|
1100
|
+
milestones: (t.milestones ?? []).map((n) => ({
|
|
1101
|
+
...n,
|
|
1102
|
+
milestone: e.milestones.find((i) => i.id === n.milestoneId) ?? null,
|
|
1103
|
+
lod: e.lods.find((i) => i.id === n.lodId) ?? null,
|
|
1104
|
+
loi: e.lois.find((i) => i.id === n.loiId) ?? null
|
|
1122
1105
|
}))
|
|
1123
1106
|
}));
|
|
1124
1107
|
}
|
|
1125
1108
|
}
|
|
1126
|
-
class
|
|
1109
|
+
class Gt extends y {
|
|
1127
1110
|
constructor(e) {
|
|
1128
1111
|
super(
|
|
1129
1112
|
() => e().assetTypes,
|
|
@@ -1131,9 +1114,9 @@ class Xt extends y {
|
|
|
1131
1114
|
{
|
|
1132
1115
|
key: "assetTypes",
|
|
1133
1116
|
schema: Ie,
|
|
1134
|
-
validate: (t,
|
|
1135
|
-
const
|
|
1136
|
-
return
|
|
1117
|
+
validate: (t, n) => {
|
|
1118
|
+
const i = x("assetType", t.id, n.deliverableNamingConvention);
|
|
1119
|
+
return i ? [i] : [];
|
|
1137
1120
|
}
|
|
1138
1121
|
}
|
|
1139
1122
|
);
|
|
@@ -1142,11 +1125,11 @@ class Xt extends y {
|
|
|
1142
1125
|
const e = this.getBep();
|
|
1143
1126
|
return e.assetTypes.map((t) => ({
|
|
1144
1127
|
...t,
|
|
1145
|
-
extensions: (t.extensionIds ?? []).map((
|
|
1128
|
+
extensions: (t.extensionIds ?? []).map((n) => e.extensions.find((i) => i.id === n)).filter(Boolean)
|
|
1146
1129
|
}));
|
|
1147
1130
|
}
|
|
1148
1131
|
}
|
|
1149
|
-
class
|
|
1132
|
+
class Xt extends y {
|
|
1150
1133
|
constructor(e) {
|
|
1151
1134
|
super(
|
|
1152
1135
|
() => e().extensions,
|
|
@@ -1158,7 +1141,7 @@ class Ht extends y {
|
|
|
1158
1141
|
);
|
|
1159
1142
|
}
|
|
1160
1143
|
}
|
|
1161
|
-
class
|
|
1144
|
+
class Vt extends y {
|
|
1162
1145
|
constructor(e) {
|
|
1163
1146
|
super(
|
|
1164
1147
|
() => e().roles,
|
|
@@ -1167,21 +1150,21 @@ class Yt extends y {
|
|
|
1167
1150
|
key: "roles",
|
|
1168
1151
|
schema: ue,
|
|
1169
1152
|
autoId: !0,
|
|
1170
|
-
beforeRemove: (t,
|
|
1171
|
-
const
|
|
1172
|
-
for (const
|
|
1173
|
-
for (const [r, d] of Object.entries(
|
|
1153
|
+
beforeRemove: (t, n) => {
|
|
1154
|
+
const i = ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"];
|
|
1155
|
+
for (const o of n.workflows)
|
|
1156
|
+
for (const [r, d] of Object.entries(o.diagram.nodes))
|
|
1174
1157
|
if (d.type === "process") {
|
|
1175
|
-
for (const l of
|
|
1158
|
+
for (const l of i)
|
|
1176
1159
|
if (d[l]?.includes(t))
|
|
1177
|
-
throw new Error(`Referenced by: workflows["${
|
|
1160
|
+
throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${r}"].${l}`);
|
|
1178
1161
|
}
|
|
1179
1162
|
}
|
|
1180
1163
|
}
|
|
1181
1164
|
);
|
|
1182
1165
|
}
|
|
1183
1166
|
}
|
|
1184
|
-
class
|
|
1167
|
+
class Ht extends y {
|
|
1185
1168
|
constructor(e) {
|
|
1186
1169
|
super(
|
|
1187
1170
|
() => e().lbs,
|
|
@@ -1189,110 +1172,110 @@ class Qt extends y {
|
|
|
1189
1172
|
{
|
|
1190
1173
|
key: "lbs",
|
|
1191
1174
|
schema: be,
|
|
1192
|
-
validate: (t,
|
|
1193
|
-
const
|
|
1194
|
-
if (r &&
|
|
1195
|
-
const d = new Map(
|
|
1175
|
+
validate: (t, n) => {
|
|
1176
|
+
const i = [], o = t.type === "zone" ? "lbsZone" : "lbsLocation", r = x(o, t.id, n.deliverableNamingConvention);
|
|
1177
|
+
if (r && i.push(r), t.type === "location" && t.lbsNodeIds?.length) {
|
|
1178
|
+
const d = new Map(n.lbs.map((l) => [l.id, l]));
|
|
1196
1179
|
for (const l of t.lbsNodeIds ?? [])
|
|
1197
|
-
d.get(l)?.type === "zone" &&
|
|
1180
|
+
d.get(l)?.type === "zone" && i.push(`Node "${t.id}" (location) cannot have a zone child ("${l}").`);
|
|
1198
1181
|
}
|
|
1199
|
-
return
|
|
1182
|
+
return i;
|
|
1200
1183
|
}
|
|
1201
1184
|
}
|
|
1202
1185
|
);
|
|
1203
1186
|
}
|
|
1204
1187
|
listResolved() {
|
|
1205
|
-
const e = this.getBep(), t = C(e.lbs),
|
|
1206
|
-
return e.lbs.map((
|
|
1207
|
-
const r = t.get(
|
|
1188
|
+
const e = this.getBep(), t = C(e.lbs), n = te(e.lbs), i = new Map(e.lbs.map((o) => [o.id, o]));
|
|
1189
|
+
return e.lbs.map((o) => {
|
|
1190
|
+
const r = t.get(o.id), d = r ? i.get(r) : void 0;
|
|
1208
1191
|
return {
|
|
1209
|
-
...
|
|
1210
|
-
isRoot:
|
|
1192
|
+
...o,
|
|
1193
|
+
isRoot: n.has(o.id),
|
|
1211
1194
|
parent: d ? { id: d.id, name: d.name, type: d.type } : null,
|
|
1212
|
-
children: (
|
|
1195
|
+
children: (o.lbsNodeIds ?? []).map((l) => i.get(l)).filter(Boolean)
|
|
1213
1196
|
};
|
|
1214
1197
|
});
|
|
1215
1198
|
}
|
|
1216
1199
|
addNodes(e) {
|
|
1217
|
-
const t = this.getBep(),
|
|
1218
|
-
for (const
|
|
1219
|
-
if (!
|
|
1220
|
-
|
|
1200
|
+
const t = this.getBep(), n = [], i = [];
|
|
1201
|
+
for (const o of e) {
|
|
1202
|
+
if (!o.parentId && o.type !== "zone") {
|
|
1203
|
+
i.push({ input: o, error: 'Root nodes (no parentId) must be type "zone".' });
|
|
1221
1204
|
continue;
|
|
1222
1205
|
}
|
|
1223
|
-
if (
|
|
1224
|
-
|
|
1206
|
+
if (o.parentId && !t.lbs.find((f) => f.id === o.parentId)) {
|
|
1207
|
+
i.push({ input: o, error: `No LBS node found with ID "${o.parentId}".` });
|
|
1225
1208
|
continue;
|
|
1226
1209
|
}
|
|
1227
|
-
const { parentId: r, ...d } =
|
|
1210
|
+
const { parentId: r, ...d } = o, l = this.add([d]);
|
|
1228
1211
|
if (l.failed.length > 0) {
|
|
1229
|
-
|
|
1212
|
+
i.push({ input: o, error: l.failed[0].error });
|
|
1230
1213
|
continue;
|
|
1231
1214
|
}
|
|
1232
1215
|
let c;
|
|
1233
|
-
r && (c = t.lbs.find((f) => f.id === r), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(
|
|
1216
|
+
r && (c = t.lbs.find((f) => f.id === r), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(o.id)));
|
|
1234
1217
|
const u = this.validateTree();
|
|
1235
1218
|
if (u.length > 0) {
|
|
1236
|
-
t.lbs.splice(t.lbs.findIndex((f) => f.id ===
|
|
1219
|
+
t.lbs.splice(t.lbs.findIndex((f) => f.id === o.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((f) => f !== o.id)), i.push({ input: o, error: u.join("; ") });
|
|
1237
1220
|
continue;
|
|
1238
1221
|
}
|
|
1239
|
-
|
|
1222
|
+
n.push({ ...t.lbs.find((f) => f.id === o.id), parentId: r ?? null });
|
|
1240
1223
|
}
|
|
1241
|
-
return { succeeded:
|
|
1224
|
+
return { succeeded: n, failed: i };
|
|
1242
1225
|
}
|
|
1243
1226
|
updateNodes(e) {
|
|
1244
|
-
const t = this.getBep(),
|
|
1245
|
-
for (const
|
|
1246
|
-
if (
|
|
1247
|
-
|
|
1227
|
+
const t = this.getBep(), n = [], i = [];
|
|
1228
|
+
for (const o of e) {
|
|
1229
|
+
if (o.parentId && !t.lbs.find((h) => h.id === o.parentId)) {
|
|
1230
|
+
i.push({ id: o.id, error: `No LBS node found with ID "${o.parentId}".` });
|
|
1248
1231
|
continue;
|
|
1249
1232
|
}
|
|
1250
|
-
if (
|
|
1251
|
-
|
|
1233
|
+
if (o.parentId === o.id) {
|
|
1234
|
+
i.push({ id: o.id, error: "A node cannot be its own parent." });
|
|
1252
1235
|
continue;
|
|
1253
1236
|
}
|
|
1254
|
-
const r = t.lbs.find((h) => h.id ===
|
|
1237
|
+
const r = t.lbs.find((h) => h.id === o.id), d = C(t.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, u = this.update([c]);
|
|
1255
1238
|
if (u.failed.length > 0) {
|
|
1256
|
-
|
|
1239
|
+
i.push({ id: o.id, error: u.failed[0].error });
|
|
1257
1240
|
continue;
|
|
1258
1241
|
}
|
|
1259
|
-
const f = { name: r.name, type: r.type, description: r.description, parentId: d }, m = t.lbs.find((h) => h.id ===
|
|
1242
|
+
const f = { name: r.name, type: r.type, description: r.description, parentId: d }, m = t.lbs.find((h) => h.id === o.id);
|
|
1260
1243
|
if (l !== void 0) {
|
|
1261
1244
|
for (const h of t.lbs)
|
|
1262
|
-
h.lbsNodeIds?.includes(
|
|
1245
|
+
h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== o.id));
|
|
1263
1246
|
if (l) {
|
|
1264
1247
|
const h = t.lbs.find((b) => b.id === l);
|
|
1265
|
-
h.lbsNodeIds ??= [], h.lbsNodeIds.push(
|
|
1248
|
+
h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id);
|
|
1266
1249
|
}
|
|
1267
1250
|
}
|
|
1268
1251
|
const p = this.validateTree();
|
|
1269
1252
|
if (p.length > 0) {
|
|
1270
1253
|
if (m.name = f.name, m.type = f.type, f.description !== void 0 ? m.description = f.description : delete m.description, l !== void 0) {
|
|
1271
1254
|
for (const h of t.lbs)
|
|
1272
|
-
h.lbsNodeIds?.includes(
|
|
1255
|
+
h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((b) => b !== o.id));
|
|
1273
1256
|
if (f.parentId) {
|
|
1274
1257
|
const h = t.lbs.find((b) => b.id === f.parentId);
|
|
1275
|
-
h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(
|
|
1258
|
+
h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id));
|
|
1276
1259
|
}
|
|
1277
1260
|
}
|
|
1278
|
-
|
|
1261
|
+
i.push({ id: o.id, error: p.join("; ") });
|
|
1279
1262
|
continue;
|
|
1280
1263
|
}
|
|
1281
1264
|
const g = C(t.lbs).get(m.id) ?? null;
|
|
1282
|
-
|
|
1265
|
+
n.push({ id: o.id, before: f, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
|
|
1283
1266
|
}
|
|
1284
|
-
return { succeeded:
|
|
1267
|
+
return { succeeded: n, failed: i };
|
|
1285
1268
|
}
|
|
1286
1269
|
/** Resolves zone and location codes for nomenclature given a node id. */
|
|
1287
1270
|
resolveCodes(e) {
|
|
1288
|
-
return
|
|
1271
|
+
return Je(e, this.list());
|
|
1289
1272
|
}
|
|
1290
1273
|
/** Validates the full LBS tree and returns a list of structural errors. */
|
|
1291
1274
|
validateTree() {
|
|
1292
|
-
return
|
|
1275
|
+
return Ft(this.list());
|
|
1293
1276
|
}
|
|
1294
1277
|
}
|
|
1295
|
-
class
|
|
1278
|
+
class Yt extends y {
|
|
1296
1279
|
constructor(e) {
|
|
1297
1280
|
super(
|
|
1298
1281
|
() => e().members,
|
|
@@ -1307,85 +1290,85 @@ class es extends y {
|
|
|
1307
1290
|
listResolved() {
|
|
1308
1291
|
const e = this.getBep();
|
|
1309
1292
|
return e.members.map((t) => {
|
|
1310
|
-
const
|
|
1293
|
+
const n = e.teams.find((i) => (i.memberEmails ?? []).includes(t.email));
|
|
1311
1294
|
return {
|
|
1312
1295
|
...t,
|
|
1313
|
-
role: e.roles.find((
|
|
1314
|
-
team:
|
|
1315
|
-
isRepresentative:
|
|
1296
|
+
role: e.roles.find((i) => i.id === t.roleId) ?? null,
|
|
1297
|
+
team: n ? { id: n.id, name: n.name } : null,
|
|
1298
|
+
isRepresentative: n?.representativeEmail === t.email
|
|
1316
1299
|
};
|
|
1317
1300
|
});
|
|
1318
1301
|
}
|
|
1319
1302
|
addToTeam(e) {
|
|
1320
|
-
const t = [],
|
|
1321
|
-
for (const
|
|
1322
|
-
const r = this.getBep().teams.find((m) => m.id ===
|
|
1303
|
+
const t = [], n = [];
|
|
1304
|
+
for (const i of e) {
|
|
1305
|
+
const r = this.getBep().teams.find((m) => m.id === i.teamId);
|
|
1323
1306
|
if (!r) {
|
|
1324
|
-
|
|
1307
|
+
n.push({ input: i, error: `Team not found: ${i.teamId}` });
|
|
1325
1308
|
continue;
|
|
1326
1309
|
}
|
|
1327
|
-
const { teamId: d, isRepresentative: l, ...c } =
|
|
1310
|
+
const { teamId: d, isRepresentative: l, ...c } = i, u = this.add([c]);
|
|
1328
1311
|
if (u.failed.length > 0) {
|
|
1329
|
-
|
|
1312
|
+
n.push({ input: i, error: u.failed[0].error });
|
|
1330
1313
|
continue;
|
|
1331
1314
|
}
|
|
1332
|
-
r.memberEmails ??= [], r.memberEmails.includes(
|
|
1333
|
-
const f = this.listResolved().find((m) => m.email ===
|
|
1315
|
+
r.memberEmails ??= [], r.memberEmails.includes(i.email) || r.memberEmails.push(i.email), l && (r.representativeEmail = i.email);
|
|
1316
|
+
const f = this.listResolved().find((m) => m.email === i.email);
|
|
1334
1317
|
t.push(f);
|
|
1335
1318
|
}
|
|
1336
|
-
return { succeeded: t, failed:
|
|
1319
|
+
return { succeeded: t, failed: n };
|
|
1337
1320
|
}
|
|
1338
1321
|
updateInTeam(e) {
|
|
1339
|
-
const t = [],
|
|
1340
|
-
for (const
|
|
1341
|
-
const
|
|
1342
|
-
if (r !== void 0 && !
|
|
1343
|
-
|
|
1322
|
+
const t = [], n = [];
|
|
1323
|
+
for (const i of e) {
|
|
1324
|
+
const o = this.getBep(), { teamId: r, isRepresentative: d, ...l } = i;
|
|
1325
|
+
if (r !== void 0 && !o.teams.find((f) => f.id === r)) {
|
|
1326
|
+
n.push({ email: i.email, error: `Team not found: ${r}` });
|
|
1344
1327
|
continue;
|
|
1345
1328
|
}
|
|
1346
1329
|
const c = this.update([l]);
|
|
1347
1330
|
if (c.failed.length > 0) {
|
|
1348
|
-
|
|
1331
|
+
n.push({ email: i.email, error: c.failed[0].error });
|
|
1349
1332
|
continue;
|
|
1350
1333
|
}
|
|
1351
1334
|
if (r !== void 0) {
|
|
1352
|
-
const f =
|
|
1353
|
-
m && m.id !== r && (m.memberEmails = (m.memberEmails ?? []).filter((p) => p !==
|
|
1335
|
+
const f = o.teams.find((p) => p.id === r), m = o.teams.find((p) => (p.memberEmails ?? []).includes(i.email));
|
|
1336
|
+
m && m.id !== r && (m.memberEmails = (m.memberEmails ?? []).filter((p) => p !== i.email), m.representativeEmail === i.email && (m.representativeEmail = void 0)), f.memberEmails ??= [], f.memberEmails.includes(i.email) || f.memberEmails.push(i.email);
|
|
1354
1337
|
}
|
|
1355
1338
|
if (d !== void 0) {
|
|
1356
|
-
const f =
|
|
1357
|
-
f && (f.representativeEmail = d ?
|
|
1339
|
+
const f = o.teams.find((m) => (m.memberEmails ?? []).includes(i.email));
|
|
1340
|
+
f && (f.representativeEmail = d ? i.email : f.representativeEmail === i.email ? void 0 : f.representativeEmail);
|
|
1358
1341
|
}
|
|
1359
|
-
const u = this.listResolved().find((f) => f.email ===
|
|
1360
|
-
t.push({ email:
|
|
1342
|
+
const u = this.listResolved().find((f) => f.email === i.email);
|
|
1343
|
+
t.push({ email: i.email, after: u });
|
|
1361
1344
|
}
|
|
1362
|
-
return { succeeded: t, failed:
|
|
1345
|
+
return { succeeded: t, failed: n };
|
|
1363
1346
|
}
|
|
1364
1347
|
removeFromBep(e) {
|
|
1365
|
-
const t = [],
|
|
1366
|
-
for (const
|
|
1367
|
-
const
|
|
1348
|
+
const t = [], n = [];
|
|
1349
|
+
for (const i of e) {
|
|
1350
|
+
const o = this.getBep(), r = this.listResolved().find((l) => l.email === i);
|
|
1368
1351
|
if (!r) {
|
|
1369
|
-
|
|
1352
|
+
n.push({ email: i, error: `Not found: ${i}` });
|
|
1370
1353
|
continue;
|
|
1371
1354
|
}
|
|
1372
|
-
for (const l of
|
|
1373
|
-
l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !==
|
|
1374
|
-
const d = this.remove([
|
|
1355
|
+
for (const l of o.teams)
|
|
1356
|
+
l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !== i)), l.representativeEmail === i && (l.representativeEmail = void 0);
|
|
1357
|
+
const d = this.remove([i]);
|
|
1375
1358
|
if (d.failed.length > 0) {
|
|
1376
1359
|
if (r.team) {
|
|
1377
|
-
const l =
|
|
1378
|
-
l && (l.memberEmails ??= [], l.memberEmails.includes(
|
|
1360
|
+
const l = o.teams.find((c) => c.id === r.team.id);
|
|
1361
|
+
l && (l.memberEmails ??= [], l.memberEmails.includes(i) || l.memberEmails.push(i), r.isRepresentative && (l.representativeEmail = i));
|
|
1379
1362
|
}
|
|
1380
|
-
|
|
1363
|
+
n.push({ email: i, error: d.failed[0].error });
|
|
1381
1364
|
continue;
|
|
1382
1365
|
}
|
|
1383
1366
|
t.push(r);
|
|
1384
1367
|
}
|
|
1385
|
-
return { succeeded: t, failed:
|
|
1368
|
+
return { succeeded: t, failed: n };
|
|
1386
1369
|
}
|
|
1387
1370
|
}
|
|
1388
|
-
class
|
|
1371
|
+
class Qt extends y {
|
|
1389
1372
|
constructor(e) {
|
|
1390
1373
|
super(
|
|
1391
1374
|
() => e().milestones,
|
|
@@ -1394,9 +1377,9 @@ class ts extends y {
|
|
|
1394
1377
|
key: "milestones",
|
|
1395
1378
|
schema: ye,
|
|
1396
1379
|
autoId: !0,
|
|
1397
|
-
beforeRemove: (t,
|
|
1398
|
-
for (const
|
|
1399
|
-
if (
|
|
1380
|
+
beforeRemove: (t, n) => {
|
|
1381
|
+
for (const i of n.loin)
|
|
1382
|
+
if (i.milestones?.find((r) => r.milestoneId === t)) throw new Error(`Referenced by: loin["${i.id}"].milestones[milestoneId="${t}"]`);
|
|
1400
1383
|
}
|
|
1401
1384
|
}
|
|
1402
1385
|
);
|
|
@@ -1405,11 +1388,11 @@ class ts extends y {
|
|
|
1405
1388
|
const e = this.getBep();
|
|
1406
1389
|
return e.milestones.map((t) => ({
|
|
1407
1390
|
...t,
|
|
1408
|
-
phase: e.phases.find((
|
|
1391
|
+
phase: e.phases.find((n) => n.id === t.phaseId) ?? null
|
|
1409
1392
|
}));
|
|
1410
1393
|
}
|
|
1411
1394
|
}
|
|
1412
|
-
class
|
|
1395
|
+
class es extends y {
|
|
1413
1396
|
constructor(e) {
|
|
1414
1397
|
super(
|
|
1415
1398
|
() => e().objectives,
|
|
@@ -1422,7 +1405,7 @@ class ss extends y {
|
|
|
1422
1405
|
);
|
|
1423
1406
|
}
|
|
1424
1407
|
}
|
|
1425
|
-
class
|
|
1408
|
+
class ts extends y {
|
|
1426
1409
|
constructor(e) {
|
|
1427
1410
|
super(
|
|
1428
1411
|
() => e().phases,
|
|
@@ -1435,20 +1418,20 @@ class ns extends y {
|
|
|
1435
1418
|
);
|
|
1436
1419
|
}
|
|
1437
1420
|
}
|
|
1438
|
-
class
|
|
1421
|
+
class ss extends y {
|
|
1439
1422
|
constructor(e) {
|
|
1440
1423
|
super(
|
|
1441
1424
|
() => e().remoteData,
|
|
1442
1425
|
e,
|
|
1443
1426
|
{
|
|
1444
1427
|
key: "remoteData",
|
|
1445
|
-
schema:
|
|
1428
|
+
schema: ze,
|
|
1446
1429
|
autoId: !0
|
|
1447
1430
|
}
|
|
1448
1431
|
);
|
|
1449
1432
|
}
|
|
1450
1433
|
}
|
|
1451
|
-
class
|
|
1434
|
+
class ns extends y {
|
|
1452
1435
|
constructor(e) {
|
|
1453
1436
|
super(
|
|
1454
1437
|
() => e().resolvers,
|
|
@@ -1456,15 +1439,15 @@ class is extends y {
|
|
|
1456
1439
|
{
|
|
1457
1440
|
key: "resolvers",
|
|
1458
1441
|
schema: Ue,
|
|
1459
|
-
beforeRemove: (t,
|
|
1460
|
-
const
|
|
1461
|
-
if (
|
|
1442
|
+
beforeRemove: (t, n) => {
|
|
1443
|
+
const i = n.remoteData.find((o) => o.resolverId === t);
|
|
1444
|
+
if (i) throw new Error(`Referenced by: remoteData["${i.id}"].resolverId`);
|
|
1462
1445
|
}
|
|
1463
1446
|
}
|
|
1464
1447
|
);
|
|
1465
1448
|
}
|
|
1466
1449
|
}
|
|
1467
|
-
class
|
|
1450
|
+
class is extends y {
|
|
1468
1451
|
constructor(e, t) {
|
|
1469
1452
|
super(
|
|
1470
1453
|
() => e().softwares,
|
|
@@ -1480,11 +1463,11 @@ class rs extends y {
|
|
|
1480
1463
|
const e = new Map(this.getAssetTypes().listResolved().map((t) => [t.id, t]));
|
|
1481
1464
|
return this.getBep().softwares.map((t) => ({
|
|
1482
1465
|
...t,
|
|
1483
|
-
assetTypes: (t.assetTypeIds ?? []).map((
|
|
1466
|
+
assetTypes: (t.assetTypeIds ?? []).map((n) => e.get(n)).filter(Boolean)
|
|
1484
1467
|
}));
|
|
1485
1468
|
}
|
|
1486
1469
|
}
|
|
1487
|
-
class
|
|
1470
|
+
class os extends y {
|
|
1488
1471
|
constructor(e, t) {
|
|
1489
1472
|
super(
|
|
1490
1473
|
() => e().standards,
|
|
@@ -1500,43 +1483,43 @@ class as extends y {
|
|
|
1500
1483
|
* Union with AddInput<Standard> satisfies the base class contract.
|
|
1501
1484
|
*/
|
|
1502
1485
|
add(e) {
|
|
1503
|
-
const t = e.map((
|
|
1504
|
-
const
|
|
1505
|
-
if ("content" in
|
|
1506
|
-
const { content:
|
|
1507
|
-
return this.getZip().file(
|
|
1486
|
+
const t = e.map((n) => {
|
|
1487
|
+
const i = `standards/${globalThis.crypto.randomUUID()}.md`;
|
|
1488
|
+
if ("content" in n) {
|
|
1489
|
+
const { content: o, ...r } = n;
|
|
1490
|
+
return this.getZip().file(i, o), { ...r, contentPath: i };
|
|
1508
1491
|
}
|
|
1509
|
-
return this.getZip().file(
|
|
1492
|
+
return this.getZip().file(i, ""), { ...n, contentPath: i };
|
|
1510
1493
|
});
|
|
1511
1494
|
return super.add(t);
|
|
1512
1495
|
}
|
|
1513
1496
|
/** Removes standards and deletes their .md files from the zip. */
|
|
1514
1497
|
remove(e) {
|
|
1515
1498
|
const t = new Map(
|
|
1516
|
-
e.map((
|
|
1517
|
-
),
|
|
1518
|
-
for (const
|
|
1519
|
-
const
|
|
1520
|
-
|
|
1499
|
+
e.map((i) => [i, this.list().find((o) => o.id === i)?.contentPath]).filter((i) => i[1] !== void 0)
|
|
1500
|
+
), n = super.remove(e);
|
|
1501
|
+
for (const i of n.succeeded) {
|
|
1502
|
+
const o = t.get(i);
|
|
1503
|
+
o && this.getZip().remove(o);
|
|
1521
1504
|
}
|
|
1522
|
-
return
|
|
1505
|
+
return n;
|
|
1523
1506
|
}
|
|
1524
1507
|
/** Returns the markdown text content of the given standard. */
|
|
1525
1508
|
async getContent(e) {
|
|
1526
|
-
const t = this.list().find((
|
|
1509
|
+
const t = this.list().find((i) => i.id === e);
|
|
1527
1510
|
if (!t) throw new Error(`Standard not found: ${e}`);
|
|
1528
|
-
const
|
|
1529
|
-
if (!
|
|
1530
|
-
return
|
|
1511
|
+
const n = this.getZip().file(t.contentPath);
|
|
1512
|
+
if (!n) throw new Error(`Content file not found: ${t.contentPath}`);
|
|
1513
|
+
return n.async("string");
|
|
1531
1514
|
}
|
|
1532
1515
|
/** Writes new markdown text content for the given standard. */
|
|
1533
1516
|
setContent(e, t) {
|
|
1534
|
-
const
|
|
1535
|
-
if (!
|
|
1536
|
-
this.getZip().file(
|
|
1517
|
+
const n = this.list().find((i) => i.id === e);
|
|
1518
|
+
if (!n) throw new Error(`Standard not found: ${e}`);
|
|
1519
|
+
this.getZip().file(n.contentPath, t);
|
|
1537
1520
|
}
|
|
1538
1521
|
}
|
|
1539
|
-
class
|
|
1522
|
+
class rs extends y {
|
|
1540
1523
|
constructor(e, t) {
|
|
1541
1524
|
super(
|
|
1542
1525
|
() => e().teams,
|
|
@@ -1544,12 +1527,12 @@ class ds extends y {
|
|
|
1544
1527
|
{
|
|
1545
1528
|
key: "teams",
|
|
1546
1529
|
schema: pe,
|
|
1547
|
-
validate: (
|
|
1548
|
-
const
|
|
1549
|
-
return r &&
|
|
1530
|
+
validate: (n, i) => {
|
|
1531
|
+
const o = [], r = x("team", n.id, i.deliverableNamingConvention);
|
|
1532
|
+
return r && o.push(r), n.representativeEmail && !(n.memberEmails ?? []).includes(n.representativeEmail) && o.push(`representativeEmail "${n.representativeEmail}" is not a member of this team`), o;
|
|
1550
1533
|
},
|
|
1551
|
-
beforeRemove: (
|
|
1552
|
-
if (
|
|
1534
|
+
beforeRemove: (n, i) => {
|
|
1535
|
+
if (i.project.clientId === n)
|
|
1553
1536
|
throw new Error("Referenced by: project.clientId");
|
|
1554
1537
|
}
|
|
1555
1538
|
}
|
|
@@ -1557,48 +1540,48 @@ class ds extends y {
|
|
|
1557
1540
|
}
|
|
1558
1541
|
getMembers;
|
|
1559
1542
|
listResolved() {
|
|
1560
|
-
const e = this.getBep(), t = new Map(this.getMembers().listResolved().map((
|
|
1561
|
-
return e.teams.map((
|
|
1562
|
-
...
|
|
1563
|
-
representative: t.get(
|
|
1564
|
-
members: (
|
|
1565
|
-
disciplines: (
|
|
1543
|
+
const e = this.getBep(), t = new Map(this.getMembers().listResolved().map((n) => [n.email, n]));
|
|
1544
|
+
return e.teams.map((n) => ({
|
|
1545
|
+
...n,
|
|
1546
|
+
representative: t.get(n.representativeEmail ?? "") ?? null,
|
|
1547
|
+
members: (n.memberEmails ?? []).map((i) => t.get(i)).filter(Boolean),
|
|
1548
|
+
disciplines: (n.disciplineIds ?? []).map((i) => e.disciplines.find((o) => o.id === i)).filter(Boolean)
|
|
1566
1549
|
}));
|
|
1567
1550
|
}
|
|
1568
1551
|
}
|
|
1569
|
-
function
|
|
1570
|
-
const
|
|
1571
|
-
for (const [l, c] of Object.entries(
|
|
1552
|
+
function as(s, e, t) {
|
|
1553
|
+
const n = [];
|
|
1554
|
+
for (const [l, c] of Object.entries(s.nodes))
|
|
1572
1555
|
if (c.type === "process") {
|
|
1573
|
-
c.actionId && !e.actions.some((u) => u.id === c.actionId) &&
|
|
1556
|
+
c.actionId && !e.actions.some((u) => u.id === c.actionId) && n.push(`actions["${c.actionId}"] not found (node: ${l})`);
|
|
1574
1557
|
for (const u of ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"])
|
|
1575
1558
|
for (const f of c[u] ?? [])
|
|
1576
|
-
e.roles.some((m) => m.id === f) ||
|
|
1559
|
+
e.roles.some((m) => m.id === f) || n.push(`roles["${f}"] not found (node: ${l}.${u})`);
|
|
1577
1560
|
}
|
|
1578
|
-
for (const [l, c] of Object.entries(
|
|
1579
|
-
|
|
1561
|
+
for (const [l, c] of Object.entries(s.edges)) {
|
|
1562
|
+
s.nodes[c.from] || n.push(`edge "${l}": from node "${c.from}" not found`), s.nodes[c.to] || n.push(`edge "${l}": to node "${c.to}" not found`), "triggerEventId" in c && !e.events.some((u) => u.id === c.triggerEventId) && n.push(`events["${c.triggerEventId}"] not found (edge: ${l})`);
|
|
1580
1563
|
for (const u of c.effectIds ?? [])
|
|
1581
|
-
e.effects.some((f) => f.id === u) ||
|
|
1564
|
+
e.effects.some((f) => f.id === u) || n.push(`effects["${u}"] not found (edge: ${l})`);
|
|
1582
1565
|
}
|
|
1583
|
-
for (const [l, c] of Object.entries(
|
|
1584
|
-
if (c.type === "automation" && !e.automations.some((u) => u.id === c.automationId) &&
|
|
1566
|
+
for (const [l, c] of Object.entries(s.nodes))
|
|
1567
|
+
if (c.type === "automation" && !e.automations.some((u) => u.id === c.automationId) && n.push(`automations["${c.automationId}"] not found (node: ${l})`), c.type === "process" && c.workflowId && (c.workflowId === t ? n.push(`node "${l}" references its own workflow — would cause infinite recursion`) : e.workflows.some((u) => u.id === c.workflowId) || n.push(`workflows["${c.workflowId}"] not found (node: ${l})`)), (c.type === "process" || c.type === "automation") && c.timeouts)
|
|
1585
1568
|
for (const u of c.timeouts)
|
|
1586
|
-
e.effects.some((f) => f.id === u.effectId) ||
|
|
1587
|
-
const
|
|
1588
|
-
for (const l of
|
|
1589
|
-
|
|
1590
|
-
for (const l of
|
|
1591
|
-
|
|
1569
|
+
e.effects.some((f) => f.id === u.effectId) || n.push(`effects["${u.effectId}"] not found (node: ${l}.timeouts)`);
|
|
1570
|
+
const i = Object.keys(s.nodes), o = new Set(Object.values(s.edges).map((l) => l.to)), r = new Set(Object.values(s.edges).map((l) => l.from));
|
|
1571
|
+
for (const l of i)
|
|
1572
|
+
s.nodes[l].type !== "start" && (o.has(l) || n.push(`node "${l}" is unreachable — no edges point to it`));
|
|
1573
|
+
for (const l of i)
|
|
1574
|
+
s.nodes[l].type !== "end" && (r.has(l) || n.push(`node "${l}" has no outgoing edges — workflow would get stuck here`));
|
|
1592
1575
|
const d = {};
|
|
1593
|
-
for (const l of Object.keys(
|
|
1594
|
-
const c =
|
|
1576
|
+
for (const l of Object.keys(s.edges)) {
|
|
1577
|
+
const c = s.edges[l];
|
|
1595
1578
|
d[c.to] ??= [], d[c.to].push(l);
|
|
1596
1579
|
}
|
|
1597
|
-
for (const [l, c] of Object.entries(
|
|
1580
|
+
for (const [l, c] of Object.entries(s.nodes)) {
|
|
1598
1581
|
if (c.type !== "decision") continue;
|
|
1599
1582
|
const u = /* @__PURE__ */ new Set();
|
|
1600
1583
|
for (const f of d[l] ?? []) {
|
|
1601
|
-
const m =
|
|
1584
|
+
const m = s.edges[f], p = s.nodes[m.from];
|
|
1602
1585
|
if (p) {
|
|
1603
1586
|
if (p.type === "automation") {
|
|
1604
1587
|
const g = e.automations.find((h) => h.id === p.automationId);
|
|
@@ -1611,32 +1594,32 @@ function ls(n, e, t) {
|
|
|
1611
1594
|
}
|
|
1612
1595
|
}
|
|
1613
1596
|
if (u.size !== 0)
|
|
1614
|
-
for (const [f, m] of Object.entries(
|
|
1615
|
-
m.from === l && "guard" in m && (u.has(m.guard.field) ||
|
|
1597
|
+
for (const [f, m] of Object.entries(s.edges))
|
|
1598
|
+
m.from === l && "guard" in m && (u.has(m.guard.field) || n.push(`guard field "${m.guard.field}" on edge "${f}" is not declared in any direct predecessor's output or payload (node: ${l})`));
|
|
1616
1599
|
}
|
|
1617
|
-
return
|
|
1600
|
+
return n;
|
|
1618
1601
|
}
|
|
1619
|
-
class
|
|
1620
|
-
constructor(e, t,
|
|
1602
|
+
class ds extends y {
|
|
1603
|
+
constructor(e, t, n) {
|
|
1621
1604
|
super(
|
|
1622
1605
|
() => e().workflows,
|
|
1623
1606
|
e,
|
|
1624
1607
|
{
|
|
1625
1608
|
key: "workflows",
|
|
1626
|
-
schema:
|
|
1609
|
+
schema: Ae,
|
|
1627
1610
|
autoId: !0,
|
|
1628
|
-
validate: (
|
|
1611
|
+
validate: (i, o) => as(i.diagram, o, i.id)
|
|
1629
1612
|
}
|
|
1630
|
-
), this.getMembers = t, this.getTeams =
|
|
1613
|
+
), this.getMembers = t, this.getTeams = n;
|
|
1631
1614
|
}
|
|
1632
1615
|
getMembers;
|
|
1633
1616
|
getTeams;
|
|
1634
1617
|
getRaciMatrix() {
|
|
1635
|
-
const e = this.getBep(), t = [],
|
|
1618
|
+
const e = this.getBep(), t = [], n = /* @__PURE__ */ new Set(), i = this.getMembers().listResolved(), o = this.getTeams().listResolved(), r = (l) => (l ?? []).flatMap((c) => {
|
|
1636
1619
|
const u = e.roles.find((p) => p.id === c);
|
|
1637
1620
|
if (!u) return [];
|
|
1638
|
-
|
|
1639
|
-
const f =
|
|
1621
|
+
n.add(c);
|
|
1622
|
+
const f = i.filter((p) => p.role?.id === c), m = o.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
|
|
1640
1623
|
return [{ role: u, members: f, team: m }];
|
|
1641
1624
|
});
|
|
1642
1625
|
for (const l of e.workflows)
|
|
@@ -1655,16 +1638,16 @@ class cs extends y {
|
|
|
1655
1638
|
informed: r(u.informedRoleIds)
|
|
1656
1639
|
});
|
|
1657
1640
|
}
|
|
1658
|
-
return { roles: [...
|
|
1641
|
+
return { roles: [...n].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: t };
|
|
1659
1642
|
}
|
|
1660
1643
|
getRaciMatrixForWorkflow(e) {
|
|
1661
|
-
const t = this.getRaciMatrix(),
|
|
1662
|
-
|
|
1644
|
+
const t = this.getRaciMatrix(), n = t.rows.filter((o) => o.workflow.id === e), i = new Set(
|
|
1645
|
+
n.flatMap((o) => [...o.responsible, ...o.accountable, ...o.consulted, ...o.informed].map((r) => r.role.id))
|
|
1663
1646
|
);
|
|
1664
|
-
return { roles: t.roles.filter((
|
|
1647
|
+
return { roles: t.roles.filter((o) => i.has(o.id)), rows: n };
|
|
1665
1648
|
}
|
|
1666
1649
|
getConsolidatedRaciMatrix() {
|
|
1667
|
-
const e = this.getRaciMatrix(), t = /* @__PURE__ */ new Map(),
|
|
1650
|
+
const e = this.getRaciMatrix(), t = /* @__PURE__ */ new Map(), n = (r, d) => {
|
|
1668
1651
|
const l = new Map(r.map((c) => [c.role.id, { ...c, members: [...c.members] }]));
|
|
1669
1652
|
for (const c of d)
|
|
1670
1653
|
if (!l.has(c.role.id))
|
|
@@ -1681,92 +1664,92 @@ class cs extends y {
|
|
|
1681
1664
|
t.set(d, { ...r, workflow: { id: "", name: "" } });
|
|
1682
1665
|
else {
|
|
1683
1666
|
const l = t.get(d);
|
|
1684
|
-
l.responsible =
|
|
1667
|
+
l.responsible = n(l.responsible, r.responsible), l.accountable = n(l.accountable, r.accountable), l.consulted = n(l.consulted, r.consulted), l.informed = n(l.informed, r.informed);
|
|
1685
1668
|
}
|
|
1686
1669
|
}
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1670
|
+
const i = [...t.values()], o = new Set(
|
|
1671
|
+
i.flatMap((r) => [...r.responsible, ...r.accountable, ...r.consulted, ...r.informed].map((d) => d.role.id))
|
|
1689
1672
|
);
|
|
1690
|
-
return { roles: e.roles.filter((r) =>
|
|
1673
|
+
return { roles: e.roles.filter((r) => o.has(r.id)), rows: i };
|
|
1691
1674
|
}
|
|
1692
1675
|
listResolved() {
|
|
1693
1676
|
const e = this.getBep();
|
|
1694
1677
|
return e.workflows.map((t) => {
|
|
1695
|
-
const
|
|
1696
|
-
for (const [
|
|
1678
|
+
const n = {};
|
|
1679
|
+
for (const [i, o] of Object.entries(t.diagram.nodes)) {
|
|
1697
1680
|
const r = (d) => ({
|
|
1698
1681
|
roles: (d ?? []).map((l) => e.roles.find((c) => c.id === l)).filter(Boolean),
|
|
1699
1682
|
teams: [],
|
|
1700
1683
|
members: []
|
|
1701
1684
|
});
|
|
1702
|
-
|
|
1703
|
-
type:
|
|
1704
|
-
label:
|
|
1705
|
-
timeouts:
|
|
1706
|
-
workflowId:
|
|
1707
|
-
blocking:
|
|
1708
|
-
action:
|
|
1709
|
-
automation:
|
|
1710
|
-
responsible: r(
|
|
1711
|
-
accountable: r(
|
|
1712
|
-
consulted: r(
|
|
1713
|
-
informed: r(
|
|
1685
|
+
n[i] = {
|
|
1686
|
+
type: o.type,
|
|
1687
|
+
label: o.type === "decision" ? o.label : void 0,
|
|
1688
|
+
timeouts: o.type === "process" || o.type === "automation" ? o.timeouts : void 0,
|
|
1689
|
+
workflowId: o.type === "process" ? o.workflowId : void 0,
|
|
1690
|
+
blocking: o.type === "process" ? o.blocking : void 0,
|
|
1691
|
+
action: o.type === "process" && o.actionId ? e.actions.find((d) => d.id === o.actionId) ?? null : null,
|
|
1692
|
+
automation: o.type === "automation" ? e.automations.find((d) => d.id === o.automationId) ?? null : null,
|
|
1693
|
+
responsible: r(o.type === "process" ? o.responsibleRoleIds : void 0),
|
|
1694
|
+
accountable: r(o.type === "process" ? o.accountableRoleIds : void 0),
|
|
1695
|
+
consulted: r(o.type === "process" ? o.consultedRoleIds : void 0),
|
|
1696
|
+
informed: r(o.type === "process" ? o.informedRoleIds : void 0)
|
|
1714
1697
|
};
|
|
1715
1698
|
}
|
|
1716
1699
|
return {
|
|
1717
1700
|
...t,
|
|
1718
|
-
diagram: { ...t.diagram, nodes:
|
|
1701
|
+
diagram: { ...t.diagram, nodes: n }
|
|
1719
1702
|
};
|
|
1720
1703
|
});
|
|
1721
1704
|
}
|
|
1722
1705
|
}
|
|
1723
|
-
var
|
|
1724
|
-
var
|
|
1725
|
-
return
|
|
1726
|
-
|
|
1727
|
-
} || function(
|
|
1728
|
-
for (var
|
|
1729
|
-
},
|
|
1706
|
+
var ls = /* @__PURE__ */ (function() {
|
|
1707
|
+
var s = function(e, t) {
|
|
1708
|
+
return s = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, i) {
|
|
1709
|
+
n.__proto__ = i;
|
|
1710
|
+
} || function(n, i) {
|
|
1711
|
+
for (var o in i) i.hasOwnProperty(o) && (n[o] = i[o]);
|
|
1712
|
+
}, s(e, t);
|
|
1730
1713
|
};
|
|
1731
1714
|
return function(e, t) {
|
|
1732
|
-
|
|
1733
|
-
function
|
|
1715
|
+
s(e, t);
|
|
1716
|
+
function n() {
|
|
1734
1717
|
this.constructor = e;
|
|
1735
1718
|
}
|
|
1736
|
-
e.prototype = t === null ? Object.create(t) : (
|
|
1719
|
+
e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
|
|
1737
1720
|
};
|
|
1738
|
-
})(),
|
|
1739
|
-
function G(
|
|
1740
|
-
return
|
|
1721
|
+
})(), cs = Object.prototype.hasOwnProperty;
|
|
1722
|
+
function G(s, e) {
|
|
1723
|
+
return cs.call(s, e);
|
|
1741
1724
|
}
|
|
1742
|
-
function
|
|
1743
|
-
if (Array.isArray(
|
|
1744
|
-
for (var e = new Array(
|
|
1725
|
+
function X(s) {
|
|
1726
|
+
if (Array.isArray(s)) {
|
|
1727
|
+
for (var e = new Array(s.length), t = 0; t < e.length; t++)
|
|
1745
1728
|
e[t] = "" + t;
|
|
1746
1729
|
return e;
|
|
1747
1730
|
}
|
|
1748
1731
|
if (Object.keys)
|
|
1749
|
-
return Object.keys(
|
|
1750
|
-
var
|
|
1751
|
-
for (var
|
|
1752
|
-
G(
|
|
1753
|
-
return
|
|
1754
|
-
}
|
|
1755
|
-
function R(
|
|
1756
|
-
switch (typeof
|
|
1732
|
+
return Object.keys(s);
|
|
1733
|
+
var n = [];
|
|
1734
|
+
for (var i in s)
|
|
1735
|
+
G(s, i) && n.push(i);
|
|
1736
|
+
return n;
|
|
1737
|
+
}
|
|
1738
|
+
function R(s) {
|
|
1739
|
+
switch (typeof s) {
|
|
1757
1740
|
case "object":
|
|
1758
|
-
return JSON.parse(JSON.stringify(
|
|
1741
|
+
return JSON.parse(JSON.stringify(s));
|
|
1759
1742
|
//Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
|
|
1760
1743
|
case "undefined":
|
|
1761
1744
|
return null;
|
|
1762
1745
|
//this is how JSON.stringify behaves for array items
|
|
1763
1746
|
default:
|
|
1764
|
-
return
|
|
1747
|
+
return s;
|
|
1765
1748
|
}
|
|
1766
1749
|
}
|
|
1767
|
-
function
|
|
1768
|
-
for (var e = 0, t =
|
|
1769
|
-
if (
|
|
1750
|
+
function V(s) {
|
|
1751
|
+
for (var e = 0, t = s.length, n; e < t; ) {
|
|
1752
|
+
if (n = s.charCodeAt(e), n >= 48 && n <= 57) {
|
|
1770
1753
|
e++;
|
|
1771
1754
|
continue;
|
|
1772
1755
|
}
|
|
@@ -1774,423 +1757,423 @@ function X(n) {
|
|
|
1774
1757
|
}
|
|
1775
1758
|
return !0;
|
|
1776
1759
|
}
|
|
1777
|
-
function
|
|
1778
|
-
return
|
|
1760
|
+
function A(s) {
|
|
1761
|
+
return s.indexOf("/") === -1 && s.indexOf("~") === -1 ? s : s.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
1779
1762
|
}
|
|
1780
|
-
function
|
|
1781
|
-
return
|
|
1763
|
+
function We(s) {
|
|
1764
|
+
return s.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1782
1765
|
}
|
|
1783
|
-
function H(
|
|
1784
|
-
if (
|
|
1766
|
+
function H(s) {
|
|
1767
|
+
if (s === void 0)
|
|
1785
1768
|
return !0;
|
|
1786
|
-
if (
|
|
1787
|
-
if (Array.isArray(
|
|
1788
|
-
for (var e = 0, t =
|
|
1789
|
-
if (H(
|
|
1769
|
+
if (s) {
|
|
1770
|
+
if (Array.isArray(s)) {
|
|
1771
|
+
for (var e = 0, t = s.length; e < t; e++)
|
|
1772
|
+
if (H(s[e]))
|
|
1790
1773
|
return !0;
|
|
1791
|
-
} else if (typeof
|
|
1792
|
-
for (var
|
|
1793
|
-
if (H(n[
|
|
1774
|
+
} else if (typeof s == "object") {
|
|
1775
|
+
for (var n = X(s), i = n.length, o = 0; o < i; o++)
|
|
1776
|
+
if (H(s[n[o]]))
|
|
1794
1777
|
return !0;
|
|
1795
1778
|
}
|
|
1796
1779
|
}
|
|
1797
1780
|
return !1;
|
|
1798
1781
|
}
|
|
1799
|
-
function de(
|
|
1800
|
-
var t = [
|
|
1801
|
-
for (var
|
|
1802
|
-
var
|
|
1803
|
-
typeof
|
|
1782
|
+
function de(s, e) {
|
|
1783
|
+
var t = [s];
|
|
1784
|
+
for (var n in e) {
|
|
1785
|
+
var i = typeof e[n] == "object" ? JSON.stringify(e[n], null, 2) : e[n];
|
|
1786
|
+
typeof i < "u" && t.push(n + ": " + i);
|
|
1804
1787
|
}
|
|
1805
1788
|
return t.join(`
|
|
1806
1789
|
`);
|
|
1807
1790
|
}
|
|
1808
|
-
var
|
|
1791
|
+
var Ge = (
|
|
1809
1792
|
/** @class */
|
|
1810
|
-
(function(
|
|
1811
|
-
|
|
1812
|
-
function e(t,
|
|
1813
|
-
var d = this.constructor, l =
|
|
1814
|
-
return l.name =
|
|
1793
|
+
(function(s) {
|
|
1794
|
+
ls(e, s);
|
|
1795
|
+
function e(t, n, i, o, r) {
|
|
1796
|
+
var d = this.constructor, l = s.call(this, de(t, { name: n, index: i, operation: o, tree: r })) || this;
|
|
1797
|
+
return l.name = n, l.index = i, l.operation = o, l.tree = r, Object.setPrototypeOf(l, d.prototype), l.message = de(t, { name: n, index: i, operation: o, tree: r }), l;
|
|
1815
1798
|
}
|
|
1816
1799
|
return e;
|
|
1817
1800
|
})(Error)
|
|
1818
|
-
), E =
|
|
1819
|
-
add: function(
|
|
1820
|
-
return
|
|
1801
|
+
), E = Ge, fs = R, M = {
|
|
1802
|
+
add: function(s, e, t) {
|
|
1803
|
+
return s[e] = this.value, { newDocument: t };
|
|
1821
1804
|
},
|
|
1822
|
-
remove: function(
|
|
1823
|
-
var
|
|
1824
|
-
return delete
|
|
1805
|
+
remove: function(s, e, t) {
|
|
1806
|
+
var n = s[e];
|
|
1807
|
+
return delete s[e], { newDocument: t, removed: n };
|
|
1825
1808
|
},
|
|
1826
|
-
replace: function(
|
|
1827
|
-
var
|
|
1828
|
-
return
|
|
1809
|
+
replace: function(s, e, t) {
|
|
1810
|
+
var n = s[e];
|
|
1811
|
+
return s[e] = this.value, { newDocument: t, removed: n };
|
|
1829
1812
|
},
|
|
1830
|
-
move: function(
|
|
1831
|
-
var
|
|
1832
|
-
|
|
1833
|
-
var
|
|
1834
|
-
return O(t, { op: "add", path: this.path, value:
|
|
1813
|
+
move: function(s, e, t) {
|
|
1814
|
+
var n = U(t, this.path);
|
|
1815
|
+
n && (n = R(n));
|
|
1816
|
+
var i = O(t, { op: "remove", path: this.from }).removed;
|
|
1817
|
+
return O(t, { op: "add", path: this.path, value: i }), { newDocument: t, removed: n };
|
|
1835
1818
|
},
|
|
1836
|
-
copy: function(
|
|
1837
|
-
var
|
|
1838
|
-
return O(t, { op: "add", path: this.path, value: R(
|
|
1819
|
+
copy: function(s, e, t) {
|
|
1820
|
+
var n = U(t, this.from);
|
|
1821
|
+
return O(t, { op: "add", path: this.path, value: R(n) }), { newDocument: t };
|
|
1839
1822
|
},
|
|
1840
|
-
test: function(
|
|
1841
|
-
return { newDocument: t, test: P(
|
|
1823
|
+
test: function(s, e, t) {
|
|
1824
|
+
return { newDocument: t, test: P(s[e], this.value) };
|
|
1842
1825
|
},
|
|
1843
|
-
_get: function(
|
|
1844
|
-
return this.value =
|
|
1826
|
+
_get: function(s, e, t) {
|
|
1827
|
+
return this.value = s[e], { newDocument: t };
|
|
1845
1828
|
}
|
|
1846
|
-
},
|
|
1847
|
-
add: function(
|
|
1848
|
-
return
|
|
1829
|
+
}, us = {
|
|
1830
|
+
add: function(s, e, t) {
|
|
1831
|
+
return V(e) ? s.splice(e, 0, this.value) : s[e] = this.value, { newDocument: t, index: e };
|
|
1849
1832
|
},
|
|
1850
|
-
remove: function(
|
|
1851
|
-
var
|
|
1852
|
-
return { newDocument: t, removed:
|
|
1833
|
+
remove: function(s, e, t) {
|
|
1834
|
+
var n = s.splice(e, 1);
|
|
1835
|
+
return { newDocument: t, removed: n[0] };
|
|
1853
1836
|
},
|
|
1854
|
-
replace: function(
|
|
1855
|
-
var
|
|
1856
|
-
return
|
|
1837
|
+
replace: function(s, e, t) {
|
|
1838
|
+
var n = s[e];
|
|
1839
|
+
return s[e] = this.value, { newDocument: t, removed: n };
|
|
1857
1840
|
},
|
|
1858
1841
|
move: M.move,
|
|
1859
1842
|
copy: M.copy,
|
|
1860
1843
|
test: M.test,
|
|
1861
1844
|
_get: M._get
|
|
1862
1845
|
};
|
|
1863
|
-
function U(
|
|
1846
|
+
function U(s, e) {
|
|
1864
1847
|
if (e == "")
|
|
1865
|
-
return
|
|
1848
|
+
return s;
|
|
1866
1849
|
var t = { op: "_get", path: e };
|
|
1867
|
-
return O(
|
|
1850
|
+
return O(s, t), t.value;
|
|
1868
1851
|
}
|
|
1869
|
-
function O(
|
|
1870
|
-
if (t === void 0 && (t = !1),
|
|
1871
|
-
var r = { newDocument:
|
|
1852
|
+
function O(s, e, t, n, i, o) {
|
|
1853
|
+
if (t === void 0 && (t = !1), n === void 0 && (n = !0), i === void 0 && (i = !0), o === void 0 && (o = 0), t && (typeof t == "function" ? t(e, 0, s, e.path) : z(e, 0)), e.path === "") {
|
|
1854
|
+
var r = { newDocument: s };
|
|
1872
1855
|
if (e.op === "add")
|
|
1873
1856
|
return r.newDocument = e.value, r;
|
|
1874
1857
|
if (e.op === "replace")
|
|
1875
|
-
return r.newDocument = e.value, r.removed =
|
|
1858
|
+
return r.newDocument = e.value, r.removed = s, r;
|
|
1876
1859
|
if (e.op === "move" || e.op === "copy")
|
|
1877
|
-
return r.newDocument = U(
|
|
1860
|
+
return r.newDocument = U(s, e.from), e.op === "move" && (r.removed = s), r;
|
|
1878
1861
|
if (e.op === "test") {
|
|
1879
|
-
if (r.test = P(
|
|
1880
|
-
throw new E("Test operation failed", "TEST_OPERATION_FAILED",
|
|
1881
|
-
return r.newDocument =
|
|
1862
|
+
if (r.test = P(s, e.value), r.test === !1)
|
|
1863
|
+
throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, s);
|
|
1864
|
+
return r.newDocument = s, r;
|
|
1882
1865
|
} else {
|
|
1883
1866
|
if (e.op === "remove")
|
|
1884
|
-
return r.removed =
|
|
1867
|
+
return r.removed = s, r.newDocument = null, r;
|
|
1885
1868
|
if (e.op === "_get")
|
|
1886
|
-
return e.value =
|
|
1869
|
+
return e.value = s, r;
|
|
1887
1870
|
if (t)
|
|
1888
|
-
throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID",
|
|
1871
|
+
throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", o, e, s);
|
|
1889
1872
|
return r;
|
|
1890
1873
|
}
|
|
1891
1874
|
} else {
|
|
1892
|
-
|
|
1893
|
-
var d = e.path || "", l = d.split("/"), c =
|
|
1875
|
+
n || (s = R(s));
|
|
1876
|
+
var d = e.path || "", l = d.split("/"), c = s, u = 1, f = l.length, m = void 0, p = void 0, g = void 0;
|
|
1894
1877
|
for (typeof t == "function" ? g = t : g = z; ; ) {
|
|
1895
|
-
if (p = l[u], p && p.indexOf("~") != -1 && (p =
|
|
1878
|
+
if (p = l[u], p && p.indexOf("~") != -1 && (p = We(p)), i && (p == "__proto__" || p == "prototype" && u > 0 && l[u - 1] == "constructor"))
|
|
1896
1879
|
throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");
|
|
1897
|
-
if (t && m === void 0 && (c[p] === void 0 ? m = l.slice(0, u).join("/") : u == f - 1 && (m = e.path), m !== void 0 && g(e, 0,
|
|
1880
|
+
if (t && m === void 0 && (c[p] === void 0 ? m = l.slice(0, u).join("/") : u == f - 1 && (m = e.path), m !== void 0 && g(e, 0, s, m)), u++, Array.isArray(c)) {
|
|
1898
1881
|
if (p === "-")
|
|
1899
1882
|
p = c.length;
|
|
1900
1883
|
else {
|
|
1901
|
-
if (t && !
|
|
1902
|
-
throw new E("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX",
|
|
1903
|
-
|
|
1884
|
+
if (t && !V(p))
|
|
1885
|
+
throw new E("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", o, e, s);
|
|
1886
|
+
V(p) && (p = ~~p);
|
|
1904
1887
|
}
|
|
1905
1888
|
if (u >= f) {
|
|
1906
1889
|
if (t && e.op === "add" && p > c.length)
|
|
1907
|
-
throw new E("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS",
|
|
1908
|
-
var r =
|
|
1890
|
+
throw new E("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", o, e, s);
|
|
1891
|
+
var r = us[e.op].call(e, c, p, s);
|
|
1909
1892
|
if (r.test === !1)
|
|
1910
|
-
throw new E("Test operation failed", "TEST_OPERATION_FAILED",
|
|
1893
|
+
throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, s);
|
|
1911
1894
|
return r;
|
|
1912
1895
|
}
|
|
1913
1896
|
} else if (u >= f) {
|
|
1914
|
-
var r = M[e.op].call(e, c, p,
|
|
1897
|
+
var r = M[e.op].call(e, c, p, s);
|
|
1915
1898
|
if (r.test === !1)
|
|
1916
|
-
throw new E("Test operation failed", "TEST_OPERATION_FAILED",
|
|
1899
|
+
throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, s);
|
|
1917
1900
|
return r;
|
|
1918
1901
|
}
|
|
1919
1902
|
if (c = c[p], t && u < f && (!c || typeof c != "object"))
|
|
1920
|
-
throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE",
|
|
1903
|
+
throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", o, e, s);
|
|
1921
1904
|
}
|
|
1922
1905
|
}
|
|
1923
1906
|
}
|
|
1924
|
-
function Z(
|
|
1925
|
-
if (
|
|
1907
|
+
function Z(s, e, t, n, i) {
|
|
1908
|
+
if (n === void 0 && (n = !0), i === void 0 && (i = !0), t && !Array.isArray(e))
|
|
1926
1909
|
throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
1927
|
-
|
|
1928
|
-
for (var
|
|
1929
|
-
|
|
1930
|
-
return
|
|
1931
|
-
}
|
|
1932
|
-
function
|
|
1933
|
-
var
|
|
1934
|
-
if (
|
|
1935
|
-
throw new E("Test operation failed", "TEST_OPERATION_FAILED", t, e,
|
|
1936
|
-
return
|
|
1937
|
-
}
|
|
1938
|
-
function z(
|
|
1939
|
-
if (typeof
|
|
1940
|
-
throw new E("Operation is not an object", "OPERATION_NOT_AN_OBJECT", e,
|
|
1941
|
-
if (M[
|
|
1942
|
-
if (typeof
|
|
1943
|
-
throw new E("Operation `path` property is not a string", "OPERATION_PATH_INVALID", e,
|
|
1944
|
-
if (
|
|
1945
|
-
throw new E('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", e,
|
|
1946
|
-
if ((
|
|
1947
|
-
throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e,
|
|
1948
|
-
if ((
|
|
1949
|
-
throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e,
|
|
1950
|
-
if ((
|
|
1951
|
-
throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e,
|
|
1910
|
+
n || (s = R(s));
|
|
1911
|
+
for (var o = new Array(e.length), r = 0, d = e.length; r < d; r++)
|
|
1912
|
+
o[r] = O(s, e[r], t, !0, i, r), s = o[r].newDocument;
|
|
1913
|
+
return o.newDocument = s, o;
|
|
1914
|
+
}
|
|
1915
|
+
function ms(s, e, t) {
|
|
1916
|
+
var n = O(s, e);
|
|
1917
|
+
if (n.test === !1)
|
|
1918
|
+
throw new E("Test operation failed", "TEST_OPERATION_FAILED", t, e, s);
|
|
1919
|
+
return n.newDocument;
|
|
1920
|
+
}
|
|
1921
|
+
function z(s, e, t, n) {
|
|
1922
|
+
if (typeof s != "object" || s === null || Array.isArray(s))
|
|
1923
|
+
throw new E("Operation is not an object", "OPERATION_NOT_AN_OBJECT", e, s, t);
|
|
1924
|
+
if (M[s.op]) {
|
|
1925
|
+
if (typeof s.path != "string")
|
|
1926
|
+
throw new E("Operation `path` property is not a string", "OPERATION_PATH_INVALID", e, s, t);
|
|
1927
|
+
if (s.path.indexOf("/") !== 0 && s.path.length > 0)
|
|
1928
|
+
throw new E('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", e, s, t);
|
|
1929
|
+
if ((s.op === "move" || s.op === "copy") && typeof s.from != "string")
|
|
1930
|
+
throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, s, t);
|
|
1931
|
+
if ((s.op === "add" || s.op === "replace" || s.op === "test") && s.value === void 0)
|
|
1932
|
+
throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e, s, t);
|
|
1933
|
+
if ((s.op === "add" || s.op === "replace" || s.op === "test") && H(s.value))
|
|
1934
|
+
throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, s, t);
|
|
1952
1935
|
if (t) {
|
|
1953
|
-
if (
|
|
1954
|
-
var
|
|
1955
|
-
if (
|
|
1956
|
-
throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e,
|
|
1957
|
-
} else if (
|
|
1958
|
-
if (
|
|
1959
|
-
throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e,
|
|
1960
|
-
} else if (
|
|
1961
|
-
var r = { op: "_get", path:
|
|
1936
|
+
if (s.op == "add") {
|
|
1937
|
+
var i = s.path.split("/").length, o = n.split("/").length;
|
|
1938
|
+
if (i !== o + 1 && i !== o)
|
|
1939
|
+
throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, s, t);
|
|
1940
|
+
} else if (s.op === "replace" || s.op === "remove" || s.op === "_get") {
|
|
1941
|
+
if (s.path !== n)
|
|
1942
|
+
throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, s, t);
|
|
1943
|
+
} else if (s.op === "move" || s.op === "copy") {
|
|
1944
|
+
var r = { op: "_get", path: s.from, value: void 0 }, d = Xe([r], t);
|
|
1962
1945
|
if (d && d.name === "OPERATION_PATH_UNRESOLVABLE")
|
|
1963
|
-
throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e,
|
|
1946
|
+
throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, s, t);
|
|
1964
1947
|
}
|
|
1965
1948
|
}
|
|
1966
|
-
} else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e,
|
|
1949
|
+
} else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, s, t);
|
|
1967
1950
|
}
|
|
1968
|
-
function Xe(
|
|
1951
|
+
function Xe(s, e, t) {
|
|
1969
1952
|
try {
|
|
1970
|
-
if (!Array.isArray(
|
|
1953
|
+
if (!Array.isArray(s))
|
|
1971
1954
|
throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
1972
1955
|
if (e)
|
|
1973
|
-
Z(R(e), R(
|
|
1956
|
+
Z(R(e), R(s), t || !0);
|
|
1974
1957
|
else {
|
|
1975
1958
|
t = t || z;
|
|
1976
|
-
for (var
|
|
1977
|
-
t(n
|
|
1959
|
+
for (var n = 0; n < s.length; n++)
|
|
1960
|
+
t(s[n], n, e, void 0);
|
|
1978
1961
|
}
|
|
1979
|
-
} catch (
|
|
1980
|
-
if (
|
|
1981
|
-
return
|
|
1982
|
-
throw
|
|
1962
|
+
} catch (i) {
|
|
1963
|
+
if (i instanceof E)
|
|
1964
|
+
return i;
|
|
1965
|
+
throw i;
|
|
1983
1966
|
}
|
|
1984
1967
|
}
|
|
1985
|
-
function P(
|
|
1986
|
-
if (
|
|
1968
|
+
function P(s, e) {
|
|
1969
|
+
if (s === e)
|
|
1987
1970
|
return !0;
|
|
1988
|
-
if (
|
|
1989
|
-
var t = Array.isArray(
|
|
1990
|
-
if (t &&
|
|
1991
|
-
if (
|
|
1971
|
+
if (s && e && typeof s == "object" && typeof e == "object") {
|
|
1972
|
+
var t = Array.isArray(s), n = Array.isArray(e), i, o, r;
|
|
1973
|
+
if (t && n) {
|
|
1974
|
+
if (o = s.length, o != e.length)
|
|
1992
1975
|
return !1;
|
|
1993
|
-
for (
|
|
1994
|
-
if (!P(
|
|
1976
|
+
for (i = o; i-- !== 0; )
|
|
1977
|
+
if (!P(s[i], e[i]))
|
|
1995
1978
|
return !1;
|
|
1996
1979
|
return !0;
|
|
1997
1980
|
}
|
|
1998
|
-
if (t !=
|
|
1981
|
+
if (t != n)
|
|
1999
1982
|
return !1;
|
|
2000
|
-
var d = Object.keys(
|
|
2001
|
-
if (
|
|
1983
|
+
var d = Object.keys(s);
|
|
1984
|
+
if (o = d.length, o !== Object.keys(e).length)
|
|
2002
1985
|
return !1;
|
|
2003
|
-
for (
|
|
2004
|
-
if (!e.hasOwnProperty(d[
|
|
1986
|
+
for (i = o; i-- !== 0; )
|
|
1987
|
+
if (!e.hasOwnProperty(d[i]))
|
|
2005
1988
|
return !1;
|
|
2006
|
-
for (
|
|
2007
|
-
if (r = d[
|
|
1989
|
+
for (i = o; i-- !== 0; )
|
|
1990
|
+
if (r = d[i], !P(s[r], e[r]))
|
|
2008
1991
|
return !1;
|
|
2009
1992
|
return !0;
|
|
2010
1993
|
}
|
|
2011
|
-
return
|
|
1994
|
+
return s !== s && e !== e;
|
|
2012
1995
|
}
|
|
2013
|
-
const
|
|
1996
|
+
const ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2014
1997
|
__proto__: null,
|
|
2015
1998
|
JsonPatchError: E,
|
|
2016
1999
|
_areEquals: P,
|
|
2017
2000
|
applyOperation: O,
|
|
2018
2001
|
applyPatch: Z,
|
|
2019
|
-
applyReducer:
|
|
2020
|
-
deepClone:
|
|
2002
|
+
applyReducer: ms,
|
|
2003
|
+
deepClone: fs,
|
|
2021
2004
|
getValueByPointer: U,
|
|
2022
2005
|
validate: Xe,
|
|
2023
2006
|
validator: z
|
|
2024
2007
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2025
|
-
var se = /* @__PURE__ */ new WeakMap(),
|
|
2008
|
+
var se = /* @__PURE__ */ new WeakMap(), hs = (
|
|
2026
2009
|
/** @class */
|
|
2027
2010
|
/* @__PURE__ */ (function() {
|
|
2028
|
-
function
|
|
2011
|
+
function s(e) {
|
|
2029
2012
|
this.observers = /* @__PURE__ */ new Map(), this.obj = e;
|
|
2030
2013
|
}
|
|
2031
|
-
return
|
|
2014
|
+
return s;
|
|
2032
2015
|
})()
|
|
2033
|
-
),
|
|
2016
|
+
), gs = (
|
|
2034
2017
|
/** @class */
|
|
2035
2018
|
/* @__PURE__ */ (function() {
|
|
2036
|
-
function
|
|
2019
|
+
function s(e, t) {
|
|
2037
2020
|
this.callback = e, this.observer = t;
|
|
2038
2021
|
}
|
|
2039
|
-
return
|
|
2022
|
+
return s;
|
|
2040
2023
|
})()
|
|
2041
2024
|
);
|
|
2042
|
-
function
|
|
2043
|
-
return se.get(
|
|
2025
|
+
function ys(s) {
|
|
2026
|
+
return se.get(s);
|
|
2044
2027
|
}
|
|
2045
|
-
function
|
|
2046
|
-
return
|
|
2028
|
+
function bs(s, e) {
|
|
2029
|
+
return s.observers.get(e);
|
|
2047
2030
|
}
|
|
2048
|
-
function
|
|
2049
|
-
|
|
2031
|
+
function ws(s, e) {
|
|
2032
|
+
s.observers.delete(e.callback);
|
|
2050
2033
|
}
|
|
2051
|
-
function
|
|
2034
|
+
function vs(s, e) {
|
|
2052
2035
|
e.unobserve();
|
|
2053
2036
|
}
|
|
2054
|
-
function
|
|
2055
|
-
var t = [],
|
|
2056
|
-
if (!
|
|
2057
|
-
|
|
2037
|
+
function Is(s, e) {
|
|
2038
|
+
var t = [], n, i = ys(s);
|
|
2039
|
+
if (!i)
|
|
2040
|
+
i = new hs(s), se.set(s, i);
|
|
2058
2041
|
else {
|
|
2059
|
-
var
|
|
2060
|
-
|
|
2042
|
+
var o = bs(i, e);
|
|
2043
|
+
n = o && o.observer;
|
|
2061
2044
|
}
|
|
2062
|
-
if (
|
|
2063
|
-
return
|
|
2064
|
-
if (
|
|
2065
|
-
|
|
2045
|
+
if (n)
|
|
2046
|
+
return n;
|
|
2047
|
+
if (n = {}, i.value = R(s), e) {
|
|
2048
|
+
n.callback = e, n.next = null;
|
|
2066
2049
|
var r = function() {
|
|
2067
|
-
Y(
|
|
2050
|
+
Y(n);
|
|
2068
2051
|
}, d = function() {
|
|
2069
|
-
clearTimeout(
|
|
2052
|
+
clearTimeout(n.next), n.next = setTimeout(r);
|
|
2070
2053
|
};
|
|
2071
2054
|
typeof window < "u" && (window.addEventListener("mouseup", d), window.addEventListener("keyup", d), window.addEventListener("mousedown", d), window.addEventListener("keydown", d), window.addEventListener("change", d));
|
|
2072
2055
|
}
|
|
2073
|
-
return
|
|
2074
|
-
Y(
|
|
2075
|
-
},
|
|
2056
|
+
return n.patches = t, n.object = s, n.unobserve = function() {
|
|
2057
|
+
Y(n), clearTimeout(n.next), ws(i, n), typeof window < "u" && (window.removeEventListener("mouseup", d), window.removeEventListener("keyup", d), window.removeEventListener("mousedown", d), window.removeEventListener("keydown", d), window.removeEventListener("change", d));
|
|
2058
|
+
}, i.observers.set(e, new gs(e, n)), n;
|
|
2076
2059
|
}
|
|
2077
|
-
function Y(
|
|
2060
|
+
function Y(s, e) {
|
|
2078
2061
|
e === void 0 && (e = !1);
|
|
2079
|
-
var t = se.get(
|
|
2080
|
-
ne(t.value,
|
|
2081
|
-
var
|
|
2082
|
-
return
|
|
2062
|
+
var t = se.get(s.object);
|
|
2063
|
+
ne(t.value, s.object, s.patches, "", e), s.patches.length && Z(t.value, s.patches);
|
|
2064
|
+
var n = s.patches;
|
|
2065
|
+
return n.length > 0 && (s.patches = [], s.callback && s.callback(n)), n;
|
|
2083
2066
|
}
|
|
2084
|
-
function ne(
|
|
2085
|
-
if (e !==
|
|
2067
|
+
function ne(s, e, t, n, i) {
|
|
2068
|
+
if (e !== s) {
|
|
2086
2069
|
typeof e.toJSON == "function" && (e = e.toJSON());
|
|
2087
|
-
for (var
|
|
2088
|
-
var c = r[l], u =
|
|
2070
|
+
for (var o = X(e), r = X(s), d = !1, l = r.length - 1; l >= 0; l--) {
|
|
2071
|
+
var c = r[l], u = s[c];
|
|
2089
2072
|
if (G(e, c) && !(e[c] === void 0 && u !== void 0 && Array.isArray(e) === !1)) {
|
|
2090
2073
|
var f = e[c];
|
|
2091
|
-
typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? ne(u, f, t,
|
|
2092
|
-
} else Array.isArray(
|
|
2074
|
+
typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? ne(u, f, t, n + "/" + A(c), i) : u !== f && (i && t.push({ op: "test", path: n + "/" + A(c), value: R(u) }), t.push({ op: "replace", path: n + "/" + A(c), value: R(f) }));
|
|
2075
|
+
} else Array.isArray(s) === Array.isArray(e) ? (i && t.push({ op: "test", path: n + "/" + A(c), value: R(u) }), t.push({ op: "remove", path: n + "/" + A(c) }), d = !0) : (i && t.push({ op: "test", path: n, value: s }), t.push({ op: "replace", path: n, value: e }));
|
|
2093
2076
|
}
|
|
2094
|
-
if (!(!d &&
|
|
2095
|
-
for (var l = 0; l <
|
|
2096
|
-
var c =
|
|
2097
|
-
!G(
|
|
2077
|
+
if (!(!d && o.length == r.length))
|
|
2078
|
+
for (var l = 0; l < o.length; l++) {
|
|
2079
|
+
var c = o[l];
|
|
2080
|
+
!G(s, c) && e[c] !== void 0 && t.push({ op: "add", path: n + "/" + A(c), value: R(e[c]) });
|
|
2098
2081
|
}
|
|
2099
2082
|
}
|
|
2100
2083
|
}
|
|
2101
|
-
function Q(
|
|
2084
|
+
function Q(s, e, t) {
|
|
2102
2085
|
t === void 0 && (t = !1);
|
|
2103
|
-
var
|
|
2104
|
-
return ne(
|
|
2086
|
+
var n = [];
|
|
2087
|
+
return ne(s, e, n, "", t), n;
|
|
2105
2088
|
}
|
|
2106
|
-
const
|
|
2089
|
+
const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2107
2090
|
__proto__: null,
|
|
2108
2091
|
compare: Q,
|
|
2109
2092
|
generate: Y,
|
|
2110
|
-
observe:
|
|
2111
|
-
unobserve:
|
|
2093
|
+
observe: Is,
|
|
2094
|
+
unobserve: vs
|
|
2112
2095
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2113
|
-
Object.assign({},
|
|
2114
|
-
JsonPatchError:
|
|
2096
|
+
Object.assign({}, ps, Es, {
|
|
2097
|
+
JsonPatchError: Ge,
|
|
2115
2098
|
deepClone: R,
|
|
2116
|
-
escapePathComponent:
|
|
2117
|
-
unescapePathComponent:
|
|
2099
|
+
escapePathComponent: A,
|
|
2100
|
+
unescapePathComponent: We
|
|
2118
2101
|
});
|
|
2119
|
-
function I(
|
|
2120
|
-
return { key:
|
|
2121
|
-
}
|
|
2122
|
-
const
|
|
2123
|
-
I("roles", (
|
|
2124
|
-
I("members", (
|
|
2125
|
-
I("teams", (
|
|
2126
|
-
I("phases", (
|
|
2127
|
-
I("milestones", (
|
|
2128
|
-
I("lbs", (
|
|
2129
|
-
I("disciplines", (
|
|
2130
|
-
I("extensions", (
|
|
2131
|
-
I("assetTypes", (
|
|
2132
|
-
I("softwares", (
|
|
2133
|
-
I("objectives", (
|
|
2134
|
-
I("bimUses", (
|
|
2135
|
-
I("actions", (
|
|
2136
|
-
I("events", (
|
|
2137
|
-
I("effects", (
|
|
2138
|
-
I("automations", (
|
|
2139
|
-
I("workflows", (
|
|
2140
|
-
I("guides", (
|
|
2141
|
-
I("annexes", (
|
|
2142
|
-
I("standards", (
|
|
2143
|
-
I("lods", (
|
|
2144
|
-
I("lois", (
|
|
2145
|
-
I("loin", (
|
|
2146
|
-
I("deliverables", (
|
|
2147
|
-
I("notes", (
|
|
2148
|
-
I("env", (
|
|
2102
|
+
function I(s, e, t) {
|
|
2103
|
+
return { key: s, getId: (n) => e(n), getLabel: (n) => t(n) };
|
|
2104
|
+
}
|
|
2105
|
+
const Ns = [
|
|
2106
|
+
I("roles", (s) => s.id, (s) => s.name),
|
|
2107
|
+
I("members", (s) => s.email, (s) => `${s.name} (${s.email})`),
|
|
2108
|
+
I("teams", (s) => s.id, (s) => `${s.id} — ${s.name}`),
|
|
2109
|
+
I("phases", (s) => s.id, (s) => s.name),
|
|
2110
|
+
I("milestones", (s) => s.id, (s) => s.name),
|
|
2111
|
+
I("lbs", (s) => s.id, (s) => `${s.id} — ${s.name} (${s.type})`),
|
|
2112
|
+
I("disciplines", (s) => s.id, (s) => `${s.id} — ${s.name}`),
|
|
2113
|
+
I("extensions", (s) => s.id, (s) => s.id),
|
|
2114
|
+
I("assetTypes", (s) => s.id, (s) => `${s.id} — ${s.name}`),
|
|
2115
|
+
I("softwares", (s) => s.id, (s) => s.name),
|
|
2116
|
+
I("objectives", (s) => s.id, (s) => s.description),
|
|
2117
|
+
I("bimUses", (s) => s.id, (s) => s.name),
|
|
2118
|
+
I("actions", (s) => s.id, (s) => s.name),
|
|
2119
|
+
I("events", (s) => s.id, (s) => s.name),
|
|
2120
|
+
I("effects", (s) => s.id, (s) => s.name),
|
|
2121
|
+
I("automations", (s) => s.id, (s) => s.name),
|
|
2122
|
+
I("workflows", (s) => s.id, (s) => s.name),
|
|
2123
|
+
I("guides", (s) => s.id, (s) => s.name),
|
|
2124
|
+
I("annexes", (s) => s.id, (s) => s.name),
|
|
2125
|
+
I("standards", (s) => s.id, (s) => s.name),
|
|
2126
|
+
I("lods", (s) => String(s.id), (s) => `${s.id} — ${s.name}`),
|
|
2127
|
+
I("lois", (s) => String(s.id), (s) => `${s.id} — ${s.name}`),
|
|
2128
|
+
I("loin", (s) => s.id, (s) => s.element),
|
|
2129
|
+
I("deliverables", (s) => s.id, (s) => s.description ?? s.id),
|
|
2130
|
+
I("notes", (s) => s.id, (s) => s.message),
|
|
2131
|
+
I("env", (s) => s.key, (s) => s.key)
|
|
2149
2132
|
];
|
|
2150
|
-
function
|
|
2151
|
-
const
|
|
2133
|
+
function Ss(s, e, t, n) {
|
|
2134
|
+
const i = new Map(s.map((r) => [t(r), r])), o = new Map(e.map((r) => [t(r), r]));
|
|
2152
2135
|
return {
|
|
2153
|
-
added: e.filter((r) => !
|
|
2154
|
-
removed:
|
|
2136
|
+
added: e.filter((r) => !i.has(t(r))).map(n),
|
|
2137
|
+
removed: s.filter((r) => !o.has(t(r))).map(n),
|
|
2155
2138
|
modified: e.filter((r) => {
|
|
2156
|
-
const d =
|
|
2139
|
+
const d = i.get(t(r));
|
|
2157
2140
|
return d !== void 0 && JSON.stringify(d) !== JSON.stringify(r);
|
|
2158
|
-
}).map(
|
|
2141
|
+
}).map(n)
|
|
2159
2142
|
};
|
|
2160
2143
|
}
|
|
2161
|
-
function
|
|
2144
|
+
function ks(s, e) {
|
|
2162
2145
|
let t = null;
|
|
2163
|
-
JSON.stringify(
|
|
2164
|
-
const d =
|
|
2146
|
+
JSON.stringify(s.project) !== JSON.stringify(e.project) && (t = { changed: !0, fields: Object.keys({ ...s.project, ...e.project }).filter((r) => {
|
|
2147
|
+
const d = s.project[r], l = e.project[r];
|
|
2165
2148
|
return JSON.stringify(d) !== JSON.stringify(l);
|
|
2166
2149
|
}) });
|
|
2167
|
-
const
|
|
2168
|
-
for (const { key:
|
|
2169
|
-
const l = e[
|
|
2170
|
-
(u.added.length || u.removed.length || u.modified.length) && (
|
|
2150
|
+
const n = {};
|
|
2151
|
+
for (const { key: o, getId: r, getLabel: d } of Ns) {
|
|
2152
|
+
const l = e[o] ?? [], c = s[o] ?? [], u = Ss(l, c, r, d);
|
|
2153
|
+
(u.added.length || u.removed.length || u.modified.length) && (n[o] = u);
|
|
2171
2154
|
}
|
|
2172
|
-
const
|
|
2173
|
-
return { project: t, sections:
|
|
2155
|
+
const i = [...t ? ["project"] : [], ...Object.keys(n)];
|
|
2156
|
+
return { project: t, sections: n, changedKeys: i };
|
|
2174
2157
|
}
|
|
2175
2158
|
class k {
|
|
2176
|
-
constructor(e, t,
|
|
2177
|
-
this.getBep = e, this.setBep = t, this.getZip =
|
|
2159
|
+
constructor(e, t, n) {
|
|
2160
|
+
this.getBep = e, this.setBep = t, this.getZip = n;
|
|
2178
2161
|
}
|
|
2179
2162
|
getBep;
|
|
2180
2163
|
setBep;
|
|
2181
2164
|
getZip;
|
|
2182
2165
|
// ─── Version helpers ──────────────────────────────────────────────────────
|
|
2183
2166
|
static parseVersion(e) {
|
|
2184
|
-
const [t,
|
|
2185
|
-
return { major: t, minor:
|
|
2167
|
+
const [t, n] = e.split(".").map(Number);
|
|
2168
|
+
return { major: t, minor: n };
|
|
2186
2169
|
}
|
|
2187
2170
|
static compareVersions(e, t) {
|
|
2188
|
-
const
|
|
2189
|
-
return
|
|
2171
|
+
const n = k.parseVersion(e), i = k.parseVersion(t);
|
|
2172
|
+
return n.major !== i.major ? n.major - i.major : n.minor - i.minor;
|
|
2190
2173
|
}
|
|
2191
2174
|
static bumpVersion(e, t) {
|
|
2192
|
-
const [
|
|
2193
|
-
return t === "version" ? `${
|
|
2175
|
+
const [n, i] = e.split(".").map(Number);
|
|
2176
|
+
return t === "version" ? `${n + 1}.0` : `${n}.${i + 1}`;
|
|
2194
2177
|
}
|
|
2195
2178
|
// ─── Zip helpers ──────────────────────────────────────────────────────────
|
|
2196
2179
|
async readChangelog() {
|
|
@@ -2207,17 +2190,17 @@ class k {
|
|
|
2207
2190
|
* snapshot, saves changelog/standards/{id}/v{version}.md.
|
|
2208
2191
|
*/
|
|
2209
2192
|
async snapshotChangedStandards(e, t) {
|
|
2210
|
-
const
|
|
2211
|
-
for (const
|
|
2212
|
-
const
|
|
2213
|
-
if (!
|
|
2214
|
-
const r = await
|
|
2193
|
+
const n = this.getZip();
|
|
2194
|
+
for (const i of e.standards) {
|
|
2195
|
+
const o = n.file(i.contentPath);
|
|
2196
|
+
if (!o) continue;
|
|
2197
|
+
const r = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(n.files).filter((u) => u.startsWith(d) && u.endsWith(".md") && u.slice(d.length).startsWith("v")).map((u) => u.slice(d.length + 1, -3));
|
|
2215
2198
|
let c = null;
|
|
2216
2199
|
if (l.length > 0) {
|
|
2217
|
-
const u = l.sort((m, p) => k.compareVersions(p, m))[0], f =
|
|
2200
|
+
const u = l.sort((m, p) => k.compareVersions(p, m))[0], f = n.file(`${d}v${u}.md`);
|
|
2218
2201
|
f && (c = await f.async("string"));
|
|
2219
2202
|
}
|
|
2220
|
-
c !== r &&
|
|
2203
|
+
c !== r && n.file(`${d}v${t}.md`, r);
|
|
2221
2204
|
}
|
|
2222
2205
|
}
|
|
2223
2206
|
/**
|
|
@@ -2226,11 +2209,11 @@ class k {
|
|
|
2226
2209
|
*/
|
|
2227
2210
|
async snapshotBaseStandards(e) {
|
|
2228
2211
|
const t = this.getZip();
|
|
2229
|
-
for (const
|
|
2230
|
-
const
|
|
2231
|
-
if (!
|
|
2232
|
-
const
|
|
2233
|
-
t.file(`baseline/standards/${
|
|
2212
|
+
for (const n of e.standards) {
|
|
2213
|
+
const i = t.file(n.contentPath);
|
|
2214
|
+
if (!i) continue;
|
|
2215
|
+
const o = await i.async("string");
|
|
2216
|
+
t.file(`baseline/standards/${n.id}.md`, o);
|
|
2234
2217
|
}
|
|
2235
2218
|
}
|
|
2236
2219
|
/**
|
|
@@ -2239,12 +2222,12 @@ class k {
|
|
|
2239
2222
|
* Falls back to the current file if no snapshot exists (content never changed).
|
|
2240
2223
|
*/
|
|
2241
2224
|
async resolveStandardContent(e, t) {
|
|
2242
|
-
const
|
|
2243
|
-
if (
|
|
2244
|
-
const d =
|
|
2225
|
+
const n = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(n.files).filter((d) => d.startsWith(i) && d.endsWith(".md") && d.slice(i.length).startsWith("v")).map((d) => d.slice(i.length + 1, -3)).filter((d) => k.compareVersions(d, t) <= 0).sort((d, l) => k.compareVersions(l, d));
|
|
2226
|
+
if (o.length === 0) {
|
|
2227
|
+
const d = n.file(e.contentPath);
|
|
2245
2228
|
return d ? d.async("string") : null;
|
|
2246
2229
|
}
|
|
2247
|
-
const r =
|
|
2230
|
+
const r = n.file(`${i}v${o[0]}.md`);
|
|
2248
2231
|
return r ? r.async("string") : null;
|
|
2249
2232
|
}
|
|
2250
2233
|
// ─── Public API ───────────────────────────────────────────────────────────
|
|
@@ -2255,19 +2238,19 @@ class k {
|
|
|
2255
2238
|
return (await this.readChangelog())?.versions ?? [];
|
|
2256
2239
|
}
|
|
2257
2240
|
async commit(e, t = !1) {
|
|
2258
|
-
const
|
|
2241
|
+
const n = this.getZip(), i = this.getBep(), o = await this.readChangelog(), r = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
|
|
2259
2242
|
if (!r) throw new Error("No baseline found — create a BEP with Bep.create() or open one with Bep.open()");
|
|
2260
2243
|
if (e.type === "version") {
|
|
2261
|
-
const g = e.approvedBy.filter((h) => !
|
|
2244
|
+
const g = e.approvedBy.filter((h) => !i.members.some((b) => b.email === h));
|
|
2262
2245
|
if (g.length) throw new Error(`Members not found: ${g.join(", ")}`);
|
|
2263
2246
|
}
|
|
2264
2247
|
if (!t && !await this.hasPendingChanges())
|
|
2265
2248
|
throw new Error("No pending changes since last commit");
|
|
2266
|
-
const l =
|
|
2249
|
+
const l = o?.current ?? "0.0", c = k.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, f = Q(i, r), m = e.type === "patch" ? { version: c, type: "patch", date: d, author: e.author, description: e.description, diff: u } : { version: c, type: "version", date: d, author: e.author, description: e.description, approvedBy: e.approvedBy, diff: u }, p = {
|
|
2267
2250
|
current: c,
|
|
2268
|
-
versions: [...
|
|
2251
|
+
versions: [...o?.versions ?? [], m]
|
|
2269
2252
|
};
|
|
2270
|
-
return
|
|
2253
|
+
return n.file(u, JSON.stringify(f, null, 2)), await this.snapshotChangedStandards(i, c), n.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i), n.file("changelog.json", JSON.stringify(p, null, 2)), m;
|
|
2271
2254
|
}
|
|
2272
2255
|
/**
|
|
2273
2256
|
* Reconstructs the BEP state at the given version (read-only).
|
|
@@ -2278,35 +2261,35 @@ class k {
|
|
|
2278
2261
|
if (!t) throw new Error("No changelog found — call commit() first");
|
|
2279
2262
|
if (e === t.current)
|
|
2280
2263
|
return JSON.parse(JSON.stringify(this.getBep()));
|
|
2281
|
-
const
|
|
2282
|
-
if (
|
|
2264
|
+
const n = t.versions.findIndex((r) => r.version === e);
|
|
2265
|
+
if (n === -1) {
|
|
2283
2266
|
const r = this.getZip().file(`changelog/v${e}.json`);
|
|
2284
2267
|
if (!r) throw new Error(`Version not found: ${e}`);
|
|
2285
2268
|
return B(JSON.parse(await r.async("string")));
|
|
2286
2269
|
}
|
|
2287
|
-
if (t.versions[
|
|
2270
|
+
if (t.versions[n].diff === null) {
|
|
2288
2271
|
const r = this.getZip().file(`changelog/v${e}.json`);
|
|
2289
2272
|
if (!r) throw new Error(`Missing terminus: changelog/v${e}.json`);
|
|
2290
2273
|
return B(JSON.parse(await r.async("string")));
|
|
2291
2274
|
}
|
|
2292
|
-
const
|
|
2293
|
-
for (const r of
|
|
2275
|
+
const i = t.versions.filter((r) => k.compareVersions(r.version, e) > 0).sort((r, d) => k.compareVersions(d.version, r.version)), o = JSON.parse(JSON.stringify(this.getBep()));
|
|
2276
|
+
for (const r of i) {
|
|
2294
2277
|
if (!r.diff) break;
|
|
2295
2278
|
const d = this.getZip().file(r.diff);
|
|
2296
2279
|
if (!d) throw new Error(`Missing diff file: ${r.diff}`);
|
|
2297
2280
|
const l = JSON.parse(await d.async("string"));
|
|
2298
|
-
Z(
|
|
2281
|
+
Z(o, l);
|
|
2299
2282
|
}
|
|
2300
|
-
return B(
|
|
2283
|
+
return B(o);
|
|
2301
2284
|
}
|
|
2302
2285
|
/** Returns the RFC 6902 diff and standards summary between two versions. */
|
|
2303
2286
|
async compare(e, t) {
|
|
2304
|
-
const [
|
|
2287
|
+
const [n, i, o] = await Promise.all([
|
|
2305
2288
|
this.get(e),
|
|
2306
2289
|
this.get(t),
|
|
2307
2290
|
this.readChangelog()
|
|
2308
|
-
]), r = Q(
|
|
2309
|
-
|
|
2291
|
+
]), r = Q(n, i), d = new Set(n.standards.map((h) => h.id)), l = new Set(i.standards.map((h) => h.id)), c = i.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), u = n.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (o?.versions ?? []).filter((h) => k.compareVersions(h.version, e) > 0 && k.compareVersions(h.version, t) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
|
|
2292
|
+
i.standards.filter((h) => d.has(h.id)).map(async (h) => {
|
|
2310
2293
|
const b = (await Promise.all(
|
|
2311
2294
|
m.map(async ($) => p.file(`changelog/standards/${h.id}/v${$}.md`) !== null ? $ : null)
|
|
2312
2295
|
)).filter(($) => $ !== null);
|
|
@@ -2322,14 +2305,14 @@ class k {
|
|
|
2322
2305
|
async discard() {
|
|
2323
2306
|
const e = this.getZip(), t = await this.readBaseline();
|
|
2324
2307
|
if (!t) throw new Error("No baseline found — call commit() first");
|
|
2325
|
-
const
|
|
2326
|
-
for (const
|
|
2327
|
-
|
|
2328
|
-
for (const
|
|
2329
|
-
const
|
|
2330
|
-
if (!
|
|
2331
|
-
const r = await
|
|
2332
|
-
e.file(
|
|
2308
|
+
const n = new Set(t.standards.map((i) => i.id));
|
|
2309
|
+
for (const i of this.getBep().standards)
|
|
2310
|
+
n.has(i.id) || e.remove(i.contentPath);
|
|
2311
|
+
for (const i of t.standards) {
|
|
2312
|
+
const o = e.file(`baseline/standards/${i.id}.md`);
|
|
2313
|
+
if (!o) continue;
|
|
2314
|
+
const r = await o.async("string");
|
|
2315
|
+
e.file(i.contentPath, r);
|
|
2333
2316
|
}
|
|
2334
2317
|
this.setBep(t);
|
|
2335
2318
|
}
|
|
@@ -2338,12 +2321,12 @@ class k {
|
|
|
2338
2321
|
* version and immediately commits it as a new version.
|
|
2339
2322
|
*/
|
|
2340
2323
|
async revert(e, t) {
|
|
2341
|
-
const
|
|
2342
|
-
for (const
|
|
2343
|
-
const r = await this.resolveStandardContent(
|
|
2344
|
-
r !== null &&
|
|
2324
|
+
const n = this.getZip(), i = await this.get(e);
|
|
2325
|
+
for (const o of i.standards) {
|
|
2326
|
+
const r = await this.resolveStandardContent(o, e);
|
|
2327
|
+
r !== null && n.file(o.contentPath, r);
|
|
2345
2328
|
}
|
|
2346
|
-
return this.setBep(
|
|
2329
|
+
return this.setBep(i), this.commit(t);
|
|
2347
2330
|
}
|
|
2348
2331
|
/**
|
|
2349
2332
|
* Returns a structured diff of the current BEP state vs the last committed baseline.
|
|
@@ -2352,17 +2335,17 @@ class k {
|
|
|
2352
2335
|
async status() {
|
|
2353
2336
|
const e = this.getZip(), t = await this.readBaseline();
|
|
2354
2337
|
if (!t) return { hasPendingChanges: !1, project: null, sections: {}, changedKeys: [], standards: [] };
|
|
2355
|
-
const
|
|
2356
|
-
for (const c of
|
|
2338
|
+
const n = this.getBep(), i = ks(n, t), o = [], r = new Map(t.standards.map((c) => [c.id, c])), d = new Set(n.standards.map((c) => c.id));
|
|
2339
|
+
for (const c of n.standards)
|
|
2357
2340
|
if (!r.has(c.id))
|
|
2358
|
-
|
|
2341
|
+
o.push({ id: c.id, name: c.name, status: "added" });
|
|
2359
2342
|
else {
|
|
2360
2343
|
const u = JSON.stringify(r.get(c.id)) !== JSON.stringify(c), f = e.file(`baseline/standards/${c.id}.md`), m = e.file(c.contentPath), p = f ? await f.async("string") : "", g = m ? await m.async("string") : "";
|
|
2361
|
-
u ?
|
|
2344
|
+
u ? o.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && o.push({ id: c.id, name: c.name, status: "content-modified" });
|
|
2362
2345
|
}
|
|
2363
2346
|
for (const c of t.standards)
|
|
2364
|
-
d.has(c.id) ||
|
|
2365
|
-
return { hasPendingChanges:
|
|
2347
|
+
d.has(c.id) || o.push({ id: c.id, name: c.name, status: "removed" });
|
|
2348
|
+
return { hasPendingChanges: i.changedKeys.length > 0 || o.length > 0, standards: o, ...i };
|
|
2366
2349
|
}
|
|
2367
2350
|
/** Shorthand — true if there are uncommitted changes since the last commit. */
|
|
2368
2351
|
async hasPendingChanges() {
|
|
@@ -2370,19 +2353,19 @@ class k {
|
|
|
2370
2353
|
}
|
|
2371
2354
|
/** Returns all versions sorted ascending, with author/approvedBy resolved to { email, name } objects. */
|
|
2372
2355
|
async listResolved() {
|
|
2373
|
-
const [e, t] = await Promise.all([this.list(), this.current()]),
|
|
2374
|
-
return e.sort((
|
|
2375
|
-
version:
|
|
2376
|
-
type:
|
|
2377
|
-
date:
|
|
2378
|
-
description:
|
|
2379
|
-
diff:
|
|
2380
|
-
isCurrent:
|
|
2381
|
-
author:
|
|
2382
|
-
...
|
|
2383
|
-
approvedBy:
|
|
2384
|
-
email:
|
|
2385
|
-
name:
|
|
2356
|
+
const [e, t] = await Promise.all([this.list(), this.current()]), n = this.getBep().members;
|
|
2357
|
+
return e.sort((i, o) => k.compareVersions(i.version, o.version)).map((i) => ({
|
|
2358
|
+
version: i.version,
|
|
2359
|
+
type: i.type,
|
|
2360
|
+
date: i.date,
|
|
2361
|
+
description: i.description,
|
|
2362
|
+
diff: i.diff,
|
|
2363
|
+
isCurrent: i.version === t,
|
|
2364
|
+
author: i.author ? { email: i.author, name: n.find((o) => o.email === i.author)?.name ?? null } : null,
|
|
2365
|
+
...i.type === "version" ? {
|
|
2366
|
+
approvedBy: i.approvedBy.map((o) => ({
|
|
2367
|
+
email: o,
|
|
2368
|
+
name: n.find((r) => r.email === o)?.name ?? null
|
|
2386
2369
|
}))
|
|
2387
2370
|
} : {}
|
|
2388
2371
|
}));
|
|
@@ -2392,22 +2375,22 @@ class k {
|
|
|
2392
2375
|
* Returns null if the standard did not exist at that version.
|
|
2393
2376
|
*/
|
|
2394
2377
|
async getStandardContent(e, t) {
|
|
2395
|
-
const
|
|
2396
|
-
return
|
|
2378
|
+
const i = (await this.get(t)).standards.find((o) => o.id === e);
|
|
2379
|
+
return i ? this.resolveStandardContent(i, t) : null;
|
|
2397
2380
|
}
|
|
2398
2381
|
/**
|
|
2399
2382
|
* ⚠️ Destructive: resets the BEP to a historical version and permanently
|
|
2400
2383
|
* deletes all subsequent diffs, standard snapshots, and changelog entries.
|
|
2401
2384
|
*/
|
|
2402
2385
|
async reset(e) {
|
|
2403
|
-
const t = this.getZip(),
|
|
2404
|
-
if (!
|
|
2405
|
-
const
|
|
2406
|
-
if (!
|
|
2386
|
+
const t = this.getZip(), n = await this.readChangelog();
|
|
2387
|
+
if (!n) throw new Error("No changelog found");
|
|
2388
|
+
const i = n.versions.find((c) => c.version === e), o = !!this.getZip().file(`changelog/v${e}.json`);
|
|
2389
|
+
if (!i && !o)
|
|
2407
2390
|
throw new Error(`Version not found: ${e}`);
|
|
2408
|
-
if (e ===
|
|
2391
|
+
if (e === n.current)
|
|
2409
2392
|
throw new Error(`Already at version ${e}`);
|
|
2410
|
-
const r =
|
|
2393
|
+
const r = n.versions.filter((c) => k.compareVersions(c.version, e) > 0), d = await this.get(e);
|
|
2411
2394
|
for (const c of d.standards) {
|
|
2412
2395
|
const u = await this.resolveStandardContent(c, e);
|
|
2413
2396
|
u !== null && t.file(c.contentPath, u);
|
|
@@ -2418,7 +2401,7 @@ class k {
|
|
|
2418
2401
|
const l = JSON.stringify(d, null, 2);
|
|
2419
2402
|
t.file("changelog.json", JSON.stringify({
|
|
2420
2403
|
current: e,
|
|
2421
|
-
versions:
|
|
2404
|
+
versions: n.versions.filter((c) => k.compareVersions(c.version, e) <= 0)
|
|
2422
2405
|
}, null, 2)), t.file("bep.json", l), t.file("baseline/bep.json", l), this.setBep(d);
|
|
2423
2406
|
}
|
|
2424
2407
|
/**
|
|
@@ -2427,24 +2410,24 @@ class k {
|
|
|
2427
2410
|
* newBase must be in X.0 format and greater than the current version.
|
|
2428
2411
|
*/
|
|
2429
2412
|
async squash(e) {
|
|
2430
|
-
const t = this.getZip(),
|
|
2431
|
-
if (!
|
|
2413
|
+
const t = this.getZip(), n = await this.readChangelog();
|
|
2414
|
+
if (!n) throw new Error("No changelog found");
|
|
2432
2415
|
if (!/^\d+\.0$/.test(e.newBase))
|
|
2433
2416
|
throw new Error(`newBase must be in X.0 format (e.g. "2.0"), got "${e.newBase}"`);
|
|
2434
|
-
if (k.compareVersions(e.newBase,
|
|
2435
|
-
throw new Error(`newBase "${e.newBase}" must be greater than current version "${
|
|
2436
|
-
const
|
|
2437
|
-
if (
|
|
2438
|
-
for (const d of
|
|
2417
|
+
if (k.compareVersions(e.newBase, n.current) <= 0)
|
|
2418
|
+
throw new Error(`newBase "${e.newBase}" must be greater than current version "${n.current}"`);
|
|
2419
|
+
const i = this.getBep(), o = e.approvedBy.filter((d) => !i.members.some((l) => l.email === d));
|
|
2420
|
+
if (o.length) throw new Error(`Members not found: ${o.join(", ")}`);
|
|
2421
|
+
for (const d of n.versions)
|
|
2439
2422
|
d.diff && t.remove(d.diff);
|
|
2440
|
-
Object.keys(t.files).filter((d) => /^changelog\/v[\d.]+\.json$/.test(d)).forEach((d) => t.remove(d)), Object.keys(t.files).filter((d) => d.startsWith("changelog/standards/") && d.endsWith(".md")).forEach((d) => t.remove(d)), t.file(`changelog/v${e.newBase}.json`, JSON.stringify(
|
|
2441
|
-
for (const d of
|
|
2423
|
+
Object.keys(t.files).filter((d) => /^changelog\/v[\d.]+\.json$/.test(d)).forEach((d) => t.remove(d)), Object.keys(t.files).filter((d) => d.startsWith("changelog/standards/") && d.endsWith(".md")).forEach((d) => t.remove(d)), t.file(`changelog/v${e.newBase}.json`, JSON.stringify(i, null, 2));
|
|
2424
|
+
for (const d of i.standards) {
|
|
2442
2425
|
const l = t.file(d.contentPath);
|
|
2443
2426
|
if (!l) continue;
|
|
2444
2427
|
const c = await l.async("string");
|
|
2445
2428
|
t.file(`changelog/standards/${d.id}/v${e.newBase}.md`, c);
|
|
2446
2429
|
}
|
|
2447
|
-
t.file("baseline/bep.json", JSON.stringify(
|
|
2430
|
+
t.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i);
|
|
2448
2431
|
const r = {
|
|
2449
2432
|
version: e.newBase,
|
|
2450
2433
|
type: "version",
|
|
@@ -2473,113 +2456,113 @@ class q {
|
|
|
2473
2456
|
this.getZip().file(this.path, e);
|
|
2474
2457
|
}
|
|
2475
2458
|
}
|
|
2476
|
-
const
|
|
2477
|
-
function
|
|
2478
|
-
const t = e[
|
|
2479
|
-
switch (
|
|
2459
|
+
const $s = 10;
|
|
2460
|
+
function Rs(s, e) {
|
|
2461
|
+
const t = e[s.field];
|
|
2462
|
+
switch (s.operator) {
|
|
2480
2463
|
case "exists":
|
|
2481
2464
|
return t != null;
|
|
2482
2465
|
case "eq":
|
|
2483
|
-
return t ===
|
|
2466
|
+
return t === s.value;
|
|
2484
2467
|
case "neq":
|
|
2485
|
-
return t !==
|
|
2468
|
+
return t !== s.value;
|
|
2486
2469
|
case "gt":
|
|
2487
|
-
return typeof t == "number" && typeof
|
|
2470
|
+
return typeof t == "number" && typeof s.value == "number" && t > s.value;
|
|
2488
2471
|
case "lt":
|
|
2489
|
-
return typeof t == "number" && typeof
|
|
2472
|
+
return typeof t == "number" && typeof s.value == "number" && t < s.value;
|
|
2490
2473
|
case "contains":
|
|
2491
|
-
return typeof t == "string" && typeof
|
|
2474
|
+
return typeof t == "string" && typeof s.value == "string" || Array.isArray(t) ? t.includes(s.value) : !1;
|
|
2492
2475
|
default:
|
|
2493
2476
|
return !1;
|
|
2494
2477
|
}
|
|
2495
2478
|
}
|
|
2496
|
-
function
|
|
2497
|
-
const
|
|
2498
|
-
if (!
|
|
2499
|
-
const r = !!(
|
|
2479
|
+
function Ts(s, e, t, n) {
|
|
2480
|
+
const o = s.workflows.find((m) => m.id === t)?.diagram.nodes[e];
|
|
2481
|
+
if (!o || o.type !== "process") return !0;
|
|
2482
|
+
const r = !!(o.responsibleRoleIds?.length || o.responsibleTeamIds?.length || o.responsibleEmails?.length), d = !!(o.accountableRoleIds?.length || o.accountableTeamIds?.length || o.accountableEmails?.length);
|
|
2500
2483
|
if (!r && !d) return !0;
|
|
2501
|
-
const c =
|
|
2502
|
-
if (g?.includes(
|
|
2484
|
+
const c = s.members.find((m) => m.email === n)?.roleId, u = new Set(s.teams.filter((m) => (m.memberEmails ?? []).includes(n)).map((m) => m.id)), f = (m, p, g) => {
|
|
2485
|
+
if (g?.includes(n)) return !0;
|
|
2503
2486
|
const h = !!m?.length, b = !!p?.length;
|
|
2504
2487
|
return b && h ? !!c && m.includes(c) && p.some(($) => u.has($)) : b ? p.some(($) => u.has($)) : h ? !!c && m.includes(c) : !1;
|
|
2505
2488
|
};
|
|
2506
|
-
return r && f(
|
|
2507
|
-
}
|
|
2508
|
-
const
|
|
2509
|
-
function
|
|
2510
|
-
const
|
|
2511
|
-
if (!
|
|
2512
|
-
const
|
|
2513
|
-
for (const d of
|
|
2514
|
-
const l =
|
|
2489
|
+
return r && f(o.responsibleRoleIds, o.responsibleTeamIds, o.responsibleEmails) || d && f(o.accountableRoleIds, o.accountableTeamIds, o.accountableEmails);
|
|
2490
|
+
}
|
|
2491
|
+
const js = { string: "string", number: "number", boolean: "boolean" };
|
|
2492
|
+
function As(s, e, t) {
|
|
2493
|
+
const n = s.events.find((d) => d.id === e);
|
|
2494
|
+
if (!n?.payload?.length) return [];
|
|
2495
|
+
const i = [], o = t ?? {};
|
|
2496
|
+
for (const d of n.payload) {
|
|
2497
|
+
const l = o[d.key];
|
|
2515
2498
|
if (l == null)
|
|
2516
|
-
d.required &&
|
|
2499
|
+
d.required && i.push({ field: d.key, reason: "missing" });
|
|
2517
2500
|
else {
|
|
2518
|
-
const c =
|
|
2519
|
-
c && typeof l !== c &&
|
|
2501
|
+
const c = js[d.type];
|
|
2502
|
+
c && typeof l !== c && i.push({ field: d.key, reason: "wrong_type" });
|
|
2520
2503
|
}
|
|
2521
2504
|
}
|
|
2522
|
-
const r = new Set(
|
|
2523
|
-
for (const d of Object.keys(
|
|
2524
|
-
r.has(d) ||
|
|
2525
|
-
return
|
|
2505
|
+
const r = new Set(n.payload.map((d) => d.key));
|
|
2506
|
+
for (const d of Object.keys(o))
|
|
2507
|
+
r.has(d) || i.push({ field: d, reason: "unknown_field" });
|
|
2508
|
+
return i;
|
|
2526
2509
|
}
|
|
2527
|
-
function
|
|
2528
|
-
return !(!("triggerEventId" in
|
|
2510
|
+
function Os(s, e) {
|
|
2511
|
+
return !(!("triggerEventId" in s) || s.triggerEventId !== e.eventId);
|
|
2529
2512
|
}
|
|
2530
|
-
function
|
|
2531
|
-
const
|
|
2532
|
-
if (!
|
|
2533
|
-
const r = Object.keys(
|
|
2534
|
-
(f) =>
|
|
2513
|
+
function _s(s, e, t, n, i) {
|
|
2514
|
+
const o = s.workflows.find((f) => f.id === e);
|
|
2515
|
+
if (!o) return null;
|
|
2516
|
+
const r = Object.keys(o.diagram.nodes).find(
|
|
2517
|
+
(f) => o.diagram.nodes[f].type === "start"
|
|
2535
2518
|
);
|
|
2536
2519
|
if (!r) return null;
|
|
2537
|
-
const d = Object.entries(
|
|
2520
|
+
const d = Object.entries(o.diagram.edges).find(([, f]) => f.from === r), l = d?.[1].to ?? r, c = d ? (d[1].effectIds ?? []).map((f) => ({ effectId: f, fromEdgeId: d[0] })) : [], u = (/* @__PURE__ */ new Date()).toISOString();
|
|
2538
2521
|
return {
|
|
2539
2522
|
instance: {
|
|
2540
2523
|
id: globalThis.crypto.randomUUID(),
|
|
2541
2524
|
workflowId: e,
|
|
2542
|
-
bepVersion:
|
|
2525
|
+
bepVersion: i,
|
|
2543
2526
|
trackedAsset: t,
|
|
2544
2527
|
currentNodeId: l,
|
|
2545
2528
|
status: "active",
|
|
2546
2529
|
history: [],
|
|
2547
2530
|
createdAt: u,
|
|
2548
2531
|
updatedAt: u,
|
|
2549
|
-
initiatedBy:
|
|
2532
|
+
initiatedBy: n
|
|
2550
2533
|
},
|
|
2551
2534
|
startEffects: c
|
|
2552
2535
|
};
|
|
2553
2536
|
}
|
|
2554
|
-
function le(
|
|
2537
|
+
function le(s, e, t, n) {
|
|
2555
2538
|
if (e.status !== "active")
|
|
2556
2539
|
return { ok: !1, error: "INSTANCE_NOT_ACTIVE" };
|
|
2557
|
-
if (!
|
|
2540
|
+
if (!n?.skipRaci && !Ts(s, e.currentNodeId, e.workflowId, t.actor))
|
|
2558
2541
|
return { ok: !1, error: "UNAUTHORIZED" };
|
|
2559
|
-
const
|
|
2560
|
-
if (!
|
|
2561
|
-
const { nodes:
|
|
2542
|
+
const i = s.workflows.find((N) => N.id === e.workflowId);
|
|
2543
|
+
if (!i) return { ok: !1, error: "NO_MATCHING_EDGE" };
|
|
2544
|
+
const { nodes: o, edges: r } = i.diagram;
|
|
2562
2545
|
let d = e.currentNodeId;
|
|
2563
2546
|
const l = [], c = [], u = [], f = Object.entries(r).filter(
|
|
2564
|
-
([, N]) => N.from === d &&
|
|
2547
|
+
([, N]) => N.from === d && Os(N, t)
|
|
2565
2548
|
);
|
|
2566
2549
|
if (f.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
|
|
2567
2550
|
if (f.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
|
|
2568
2551
|
const [m, p] = f[0];
|
|
2569
2552
|
if ("triggerEventId" in p) {
|
|
2570
|
-
const N =
|
|
2553
|
+
const N = As(s, p.triggerEventId, t.payload);
|
|
2571
2554
|
if (N.length > 0) return { ok: !1, error: "INVALID_PAYLOAD", payloadErrors: N };
|
|
2572
2555
|
}
|
|
2573
2556
|
l.push(ce(m, d, p.to, t)), c.push(...(p.effectIds ?? []).map((N) => ({ effectId: N, fromEdgeId: m }))), u.push({ edgeId: m, fromNodeId: d, toNodeId: p.to }), d = p.to;
|
|
2574
2557
|
let g = 0;
|
|
2575
|
-
for (;
|
|
2576
|
-
if (++g >
|
|
2577
|
-
const N = Object.entries(r).filter(([, v]) => v.from !== d || !("guard" in v) ? !1 :
|
|
2558
|
+
for (; o[d]?.type === "decision"; ) {
|
|
2559
|
+
if (++g > $s) return { ok: !1, error: "DECISION_LOOP" };
|
|
2560
|
+
const N = Object.entries(r).filter(([, v]) => v.from !== d || !("guard" in v) ? !1 : Rs(v.guard, t.payload ?? {}));
|
|
2578
2561
|
if (N.length === 0) break;
|
|
2579
|
-
const [
|
|
2580
|
-
l.push(ce(
|
|
2562
|
+
const [j, w] = N[0];
|
|
2563
|
+
l.push(ce(j, d, w.to, t, !0)), c.push(...(w.effectIds ?? []).map((v) => ({ effectId: v, fromEdgeId: j }))), u.push({ edgeId: j, fromNodeId: d, toNodeId: w.to }), d = w.to;
|
|
2581
2564
|
}
|
|
2582
|
-
const h =
|
|
2565
|
+
const h = o[d], b = h?.type === "end" ? "completed" : "active", $ = {
|
|
2583
2566
|
...e,
|
|
2584
2567
|
currentNodeId: d,
|
|
2585
2568
|
status: b,
|
|
@@ -2588,14 +2571,14 @@ function le(n, e, t, s) {
|
|
|
2588
2571
|
}, T = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId } : void 0;
|
|
2589
2572
|
return { ok: !0, instance: $, transitionsApplied: u, effectsToFire: c, automationNodePending: T };
|
|
2590
2573
|
}
|
|
2591
|
-
function
|
|
2592
|
-
const
|
|
2593
|
-
|
|
2574
|
+
function Bs(s, e, t) {
|
|
2575
|
+
const n = s.workflows.find((w) => w.id === e.workflowId), { nodes: i, edges: o } = n.diagram, r = i[e.currentNodeId], l = s.members.find((w) => w.email === t)?.roleId, c = new Set(
|
|
2576
|
+
s.teams.filter((w) => (w.memberEmails ?? []).includes(t)).map((w) => w.id)
|
|
2594
2577
|
), u = (w) => (w ?? []).flatMap((v) => {
|
|
2595
|
-
const S =
|
|
2578
|
+
const S = s.roles.find((_) => _.id === v);
|
|
2596
2579
|
return S ? [{ id: S.id, name: S.name }] : [];
|
|
2597
2580
|
}), f = (w) => (w ?? []).flatMap((v) => {
|
|
2598
|
-
const S =
|
|
2581
|
+
const S = s.teams.find((_) => _.id === v);
|
|
2599
2582
|
return S ? [{ id: S.id, name: S.name }] : [];
|
|
2600
2583
|
}), m = (w, v, S) => ({
|
|
2601
2584
|
roles: u(w),
|
|
@@ -2603,14 +2586,14 @@ function xs(n, e, t) {
|
|
|
2603
2586
|
emails: S ?? []
|
|
2604
2587
|
}), p = (w, v, S) => {
|
|
2605
2588
|
if (S?.includes(t)) return !0;
|
|
2606
|
-
const _ = !!w?.length,
|
|
2607
|
-
return
|
|
2608
|
-
}, g = r.type === "process" ? r : null, h = !!(g?.responsibleRoleIds?.length || g?.responsibleTeamIds?.length || g?.responsibleEmails?.length), b = !!(g?.accountableRoleIds?.length || g?.accountableTeamIds?.length || g?.accountableEmails?.length), $ = !h && !b || h && p(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails) || b && p(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails), T = (w) => (
|
|
2589
|
+
const _ = !!w?.length, ie = !!v?.length;
|
|
2590
|
+
return ie && _ ? !!l && w.includes(l) && v.some((J) => c.has(J)) : ie ? v.some((J) => c.has(J)) : _ ? !!l && w.includes(l) : !1;
|
|
2591
|
+
}, g = r.type === "process" ? r : null, h = !!(g?.responsibleRoleIds?.length || g?.responsibleTeamIds?.length || g?.responsibleEmails?.length), b = !!(g?.accountableRoleIds?.length || g?.accountableTeamIds?.length || g?.accountableEmails?.length), $ = !h && !b || h && p(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails) || b && p(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails), T = (w) => (s.events.find((v) => v.id === w)?.payload ?? []).map((v) => ({
|
|
2609
2592
|
key: v.key,
|
|
2610
2593
|
type: v.type,
|
|
2611
2594
|
required: v.required
|
|
2612
|
-
})), N = [],
|
|
2613
|
-
for (const [w, v] of Object.entries(
|
|
2595
|
+
})), N = [], j = [];
|
|
2596
|
+
for (const [w, v] of Object.entries(o)) {
|
|
2614
2597
|
if (v.from !== e.currentNodeId || !("triggerEventId" in v)) continue;
|
|
2615
2598
|
const S = v.triggerEventId;
|
|
2616
2599
|
$ ? N.push({
|
|
@@ -2618,7 +2601,7 @@ function xs(n, e, t) {
|
|
|
2618
2601
|
label: v.label ?? S,
|
|
2619
2602
|
emits: S,
|
|
2620
2603
|
requiredPayload: T(S)
|
|
2621
|
-
}) :
|
|
2604
|
+
}) : j.push({
|
|
2622
2605
|
edgeId: w,
|
|
2623
2606
|
label: v.label ?? S,
|
|
2624
2607
|
reason: "UNAUTHORIZED",
|
|
@@ -2636,7 +2619,7 @@ function xs(n, e, t) {
|
|
|
2636
2619
|
label: e.currentNodeId
|
|
2637
2620
|
},
|
|
2638
2621
|
availableTransitions: N,
|
|
2639
|
-
blockedTransitions:
|
|
2622
|
+
blockedTransitions: j,
|
|
2640
2623
|
raci: {
|
|
2641
2624
|
responsible: m(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails),
|
|
2642
2625
|
accountable: m(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails),
|
|
@@ -2646,23 +2629,23 @@ function xs(n, e, t) {
|
|
|
2646
2629
|
isTerminal: r.type === "end"
|
|
2647
2630
|
};
|
|
2648
2631
|
}
|
|
2649
|
-
function ce(
|
|
2632
|
+
function ce(s, e, t, n, i) {
|
|
2650
2633
|
return {
|
|
2651
2634
|
id: globalThis.crypto.randomUUID(),
|
|
2652
|
-
edgeId:
|
|
2635
|
+
edgeId: s,
|
|
2653
2636
|
fromNodeId: e,
|
|
2654
2637
|
toNodeId: t,
|
|
2655
|
-
trigger:
|
|
2656
|
-
actor:
|
|
2638
|
+
trigger: n,
|
|
2639
|
+
actor: n.actor,
|
|
2657
2640
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2658
|
-
...
|
|
2641
|
+
...i ? { auto: !0 } : {}
|
|
2659
2642
|
};
|
|
2660
2643
|
}
|
|
2661
|
-
class
|
|
2644
|
+
class Ms {
|
|
2662
2645
|
instances = /* @__PURE__ */ new Map();
|
|
2663
2646
|
async listInstances(e) {
|
|
2664
2647
|
let t = [...this.instances.values()];
|
|
2665
|
-
return e?.workflowId && (t = t.filter((
|
|
2648
|
+
return e?.workflowId && (t = t.filter((n) => n.workflowId === e.workflowId)), e?.status && (t = t.filter((n) => n.status === e.status)), e?.trackedAssetTypeId && (t = t.filter((n) => n.trackedAsset.assetTypeId === e.trackedAssetTypeId)), e?.trackedAssetId && (t = t.filter((n) => n.trackedAsset.id === e.trackedAssetId)), t;
|
|
2666
2649
|
}
|
|
2667
2650
|
async getInstance(e) {
|
|
2668
2651
|
return this.instances.get(e) ?? null;
|
|
@@ -2674,18 +2657,18 @@ class Ps {
|
|
|
2674
2657
|
this.instances.delete(e);
|
|
2675
2658
|
}
|
|
2676
2659
|
}
|
|
2677
|
-
function
|
|
2678
|
-
if (
|
|
2679
|
-
if (typeof
|
|
2680
|
-
const e =
|
|
2681
|
-
if (
|
|
2660
|
+
function xs(s) {
|
|
2661
|
+
if (s == null) return "Unknown error";
|
|
2662
|
+
if (typeof s == "string") return s;
|
|
2663
|
+
const e = s, t = typeof e.name == "string" ? e.name : "Error", n = typeof e.message == "string" ? e.message : void 0;
|
|
2664
|
+
if (n !== void 0) return n ? `${t}: ${n}` : t;
|
|
2682
2665
|
try {
|
|
2683
|
-
return String(
|
|
2666
|
+
return String(s);
|
|
2684
2667
|
} catch {
|
|
2685
2668
|
return "Unknown error";
|
|
2686
2669
|
}
|
|
2687
2670
|
}
|
|
2688
|
-
class
|
|
2671
|
+
class Ps {
|
|
2689
2672
|
getBep;
|
|
2690
2673
|
getHistoricalBep;
|
|
2691
2674
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2709,7 +2692,7 @@ class Cs {
|
|
|
2709
2692
|
* Returns `this` for chaining.
|
|
2710
2693
|
*/
|
|
2711
2694
|
init(e) {
|
|
2712
|
-
return this.runtime = e.runtime, this.storage = e.storage ?? new
|
|
2695
|
+
return this.runtime = e.runtime, this.storage = e.storage ?? new Ms(), this.skipRaci = e.events?.skipRaci ?? !1, this;
|
|
2713
2696
|
}
|
|
2714
2697
|
// ─── Lifecycle listeners ─────────────────────────────────────────────────────
|
|
2715
2698
|
/** Fires after every successful emit() — all listeners run concurrently. */
|
|
@@ -2734,9 +2717,9 @@ class Cs {
|
|
|
2734
2717
|
* Records the current BEP version on the instance for historical resolution.
|
|
2735
2718
|
* Returns null if the workflowId does not exist or has no start node.
|
|
2736
2719
|
*/
|
|
2737
|
-
async createInstance(e, t,
|
|
2720
|
+
async createInstance(e, t, n) {
|
|
2738
2721
|
this._assertInit();
|
|
2739
|
-
const
|
|
2722
|
+
const i = this.getBep(), r = _s(i, e, t, n, "unversioned");
|
|
2740
2723
|
if (!r) return null;
|
|
2741
2724
|
const { instance: d, startEffects: l } = r;
|
|
2742
2725
|
for (const c of l)
|
|
@@ -2756,27 +2739,27 @@ class Cs {
|
|
|
2756
2739
|
*/
|
|
2757
2740
|
async emit(e, t) {
|
|
2758
2741
|
this._assertInit();
|
|
2759
|
-
const
|
|
2760
|
-
if (!
|
|
2761
|
-
const
|
|
2762
|
-
let
|
|
2763
|
-
if (!
|
|
2764
|
-
const r = [...
|
|
2765
|
-
let l =
|
|
2766
|
-
for (const f of
|
|
2742
|
+
const n = await this.storage.getInstance(e);
|
|
2743
|
+
if (!n) return { ok: !1, error: "NO_MATCHING_EDGE" };
|
|
2744
|
+
const i = await this._resolveBep(n.bepVersion);
|
|
2745
|
+
let o = le(i, n, t, { skipRaci: this.skipRaci });
|
|
2746
|
+
if (!o.ok) return { ok: !1, error: o.error, payloadErrors: o.payloadErrors };
|
|
2747
|
+
const r = [...o.transitionsApplied ?? []], d = [];
|
|
2748
|
+
let l = o.instance;
|
|
2749
|
+
for (const f of o.effectsToFire ?? [])
|
|
2767
2750
|
d.push(await this._executeEffect(l, f));
|
|
2768
2751
|
const c = 10;
|
|
2769
2752
|
let u = 0;
|
|
2770
|
-
for (;
|
|
2771
|
-
const { automationId: f } =
|
|
2772
|
-
if (
|
|
2753
|
+
for (; o.automationNodePending && u++ < c; ) {
|
|
2754
|
+
const { automationId: f } = o.automationNodePending, { eventId: m, ...p } = await this._executeAutomationNode(l, f);
|
|
2755
|
+
if (o = le(i, l, {
|
|
2773
2756
|
eventId: m,
|
|
2774
2757
|
actor: "_system",
|
|
2775
2758
|
softwareId: "_system",
|
|
2776
2759
|
payload: p
|
|
2777
|
-
}), !
|
|
2778
|
-
l =
|
|
2779
|
-
for (const g of
|
|
2760
|
+
}), !o.ok) break;
|
|
2761
|
+
l = o.instance, r.push(...o.transitionsApplied ?? []);
|
|
2762
|
+
for (const g of o.effectsToFire ?? [])
|
|
2780
2763
|
d.push(await this._executeEffect(l, g));
|
|
2781
2764
|
}
|
|
2782
2765
|
return await this.storage.saveInstance(l), await this._fire(this.transitionListeners, l, r, d), l.status === "completed" && await this._fire(this.completedListeners, l), {
|
|
@@ -2797,11 +2780,11 @@ class Cs {
|
|
|
2797
2780
|
*/
|
|
2798
2781
|
async getInstances(e) {
|
|
2799
2782
|
this._assertInit();
|
|
2800
|
-
const { pendingActionFor: t, ...
|
|
2801
|
-
if (!t) return
|
|
2802
|
-
const
|
|
2803
|
-
return r ?
|
|
2804
|
-
const l =
|
|
2783
|
+
const { pendingActionFor: t, ...n } = e ?? {}, i = await this.storage.listInstances(n);
|
|
2784
|
+
if (!t) return i;
|
|
2785
|
+
const o = this.getBep(), r = o.members.find((d) => d.email === t);
|
|
2786
|
+
return r ? i.filter((d) => {
|
|
2787
|
+
const l = o.workflows.find((m) => m.id === d.workflowId);
|
|
2805
2788
|
if (!l) return !1;
|
|
2806
2789
|
const c = l.diagram.nodes[d.currentNodeId];
|
|
2807
2790
|
if (!c) return !1;
|
|
@@ -2818,10 +2801,10 @@ class Cs {
|
|
|
2818
2801
|
*/
|
|
2819
2802
|
async getNodeConfig(e, t) {
|
|
2820
2803
|
this._assertInit();
|
|
2821
|
-
const
|
|
2822
|
-
if (!
|
|
2823
|
-
const
|
|
2824
|
-
return
|
|
2804
|
+
const n = await this.storage.getInstance(e);
|
|
2805
|
+
if (!n) return null;
|
|
2806
|
+
const i = await this._resolveBep(n.bepVersion);
|
|
2807
|
+
return Bs(i, n, t);
|
|
2825
2808
|
}
|
|
2826
2809
|
async deleteInstance(e) {
|
|
2827
2810
|
this._assertInit(), await this.storage.deleteInstance(e);
|
|
@@ -2832,17 +2815,10 @@ class Cs {
|
|
|
2832
2815
|
*/
|
|
2833
2816
|
async getRemoteData(e) {
|
|
2834
2817
|
this._assertInit();
|
|
2835
|
-
const
|
|
2836
|
-
if (!
|
|
2837
|
-
if (!
|
|
2838
|
-
return this.runtime._runResolver(
|
|
2839
|
-
}
|
|
2840
|
-
/**
|
|
2841
|
-
* Runs an adapter to transform data into a lens-compatible format.
|
|
2842
|
-
* Throws if the adapterId has no registered handler.
|
|
2843
|
-
*/
|
|
2844
|
-
useAdapter(e, t) {
|
|
2845
|
-
return this._assertInit(), this.runtime._runAdapter(e, t);
|
|
2818
|
+
const n = this.getBep().remoteData.find((i) => i.id === e);
|
|
2819
|
+
if (!n) throw new Error(`Remote data "${e}" not found in BEP`);
|
|
2820
|
+
if (!n.resolverId) throw new Error(`Remote data "${e}" has no resolver assigned`);
|
|
2821
|
+
return this.runtime._runResolver(n.resolverId, n.url);
|
|
2846
2822
|
}
|
|
2847
2823
|
// ─── Internal ────────────────────────────────────────────────────────────────
|
|
2848
2824
|
_assertInit() {
|
|
@@ -2853,54 +2829,54 @@ class Cs {
|
|
|
2853
2829
|
return this.getHistoricalBep && e !== "unversioned" ? this.getHistoricalBep(e) : this.getBep();
|
|
2854
2830
|
}
|
|
2855
2831
|
async _fire(e, ...t) {
|
|
2856
|
-
await Promise.allSettled(e.map((
|
|
2832
|
+
await Promise.allSettled(e.map((n) => n(...t)));
|
|
2857
2833
|
}
|
|
2858
2834
|
_resolveFromHistory(e, t) {
|
|
2859
|
-
for (let
|
|
2860
|
-
const
|
|
2861
|
-
if (e in
|
|
2835
|
+
for (let n = t.length - 1; n >= 0; n--) {
|
|
2836
|
+
const i = t[n].trigger.payload ?? {};
|
|
2837
|
+
if (e in i) return i[e];
|
|
2862
2838
|
}
|
|
2863
2839
|
}
|
|
2864
2840
|
async _executeAutomationNode(e, t) {
|
|
2865
|
-
const
|
|
2841
|
+
const o = this.getBep().automations.find((l) => l.id === t)?.payload ?? [], r = Object.fromEntries(o.map((l) => [l.key, this._resolveFromHistory(l.key, e.history)])), d = this.runtime.automations[t];
|
|
2866
2842
|
if (!d) throw new Error(`No handler declared for automation "${t}"`);
|
|
2867
2843
|
return d(e, r);
|
|
2868
2844
|
}
|
|
2869
2845
|
async _executeEffect(e, t) {
|
|
2870
|
-
const
|
|
2846
|
+
const o = this.getBep().effects.find((c) => c.id === t.effectId)?.payload ?? [], r = o.filter((c) => c.required && this._resolveFromHistory(c.key, e.history) === void 0).map((c) => c.key);
|
|
2871
2847
|
if (r.length > 0)
|
|
2872
2848
|
return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped", missingFields: r };
|
|
2873
2849
|
const d = this.runtime.effects[t.effectId];
|
|
2874
2850
|
if (!d)
|
|
2875
2851
|
return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped" };
|
|
2876
|
-
const l = Object.fromEntries(
|
|
2852
|
+
const l = Object.fromEntries(o.map((c) => [c.key, this._resolveFromHistory(c.key, e.history)]));
|
|
2877
2853
|
try {
|
|
2878
2854
|
return await d(e, l), { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "executed" };
|
|
2879
2855
|
} catch (c) {
|
|
2880
|
-
const u = { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "failed", error:
|
|
2856
|
+
const u = { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "failed", error: xs(c) };
|
|
2881
2857
|
return await this._fire(this.effectFailedListeners, e, u), u;
|
|
2882
2858
|
}
|
|
2883
2859
|
}
|
|
2884
2860
|
}
|
|
2885
|
-
function
|
|
2861
|
+
function zs(s, e) {
|
|
2886
2862
|
const t = /* @__PURE__ */ new Map();
|
|
2887
|
-
for (const
|
|
2888
|
-
const
|
|
2889
|
-
for (const
|
|
2890
|
-
t.has(
|
|
2863
|
+
for (const n of s) {
|
|
2864
|
+
const i = [e(n)].flat();
|
|
2865
|
+
for (const o of i)
|
|
2866
|
+
t.has(o) || t.set(o, []), t.get(o).push(n);
|
|
2891
2867
|
}
|
|
2892
|
-
return Array.from(t.entries()).map(([
|
|
2868
|
+
return Array.from(t.entries()).map(([n, i]) => ({ key: n, rows: i }));
|
|
2893
2869
|
}
|
|
2894
|
-
function
|
|
2895
|
-
const { topologicalSort:
|
|
2870
|
+
function Zs(s, e = "responsible", t = {}) {
|
|
2871
|
+
const { topologicalSort: n = !1 } = t, i = (m) => `_${m}`, o = "#444444", r = Object.entries(s.nodes), d = r.find(([, m]) => m.type === "start")?.[0], l = r.find(([, m]) => m.type === "end")?.[0];
|
|
2896
2872
|
let c;
|
|
2897
|
-
if (
|
|
2873
|
+
if (n && d) {
|
|
2898
2874
|
const m = /* @__PURE__ */ new Set(), p = [d], g = [];
|
|
2899
2875
|
for (; p.length; ) {
|
|
2900
2876
|
const h = p.shift();
|
|
2901
2877
|
if (!m.has(h)) {
|
|
2902
2878
|
m.add(h), g.push(h);
|
|
2903
|
-
for (const b of Object.values(
|
|
2879
|
+
for (const b of Object.values(s.edges))
|
|
2904
2880
|
b.from === h && !m.has(b.to) && p.push(b.to);
|
|
2905
2881
|
}
|
|
2906
2882
|
}
|
|
@@ -2915,27 +2891,26 @@ function Ks(n, e = "responsible", t = {}) {
|
|
|
2915
2891
|
...l ? [l] : []
|
|
2916
2892
|
];
|
|
2917
2893
|
}
|
|
2918
|
-
const u = [`flowchart ${
|
|
2894
|
+
const u = [`flowchart ${s.direction}`];
|
|
2919
2895
|
for (const m of c) {
|
|
2920
|
-
const p =
|
|
2896
|
+
const p = s.nodes[m];
|
|
2921
2897
|
if (!p) continue;
|
|
2922
|
-
const g = p.type === "start" || p.type === "end", b = (p.type === "decision" ? p.label ?? m : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, """), $ = g || p.type === "decision" ? [] : p[e].roles.map((
|
|
2923
|
-
g ? u.push(` ${
|
|
2924
|
-
const N = p[e].roles[0]?.color ??
|
|
2925
|
-
g ? u.push(` style ${
|
|
2898
|
+
const g = p.type === "start" || p.type === "end", b = (p.type === "decision" ? p.label ?? m : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, """), $ = g || p.type === "decision" ? [] : p[e].roles.map((j) => j.name), T = $.length > 0 ? `"<b>${$.join(" · ")}</b><br/>${b}"` : `"${b || m}"`;
|
|
2899
|
+
g ? u.push(` ${i(m)}([${b || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${i(m)}{${T}}`) : p.type === "automation" ? u.push(` ${i(m)}[[${T}]]`) : u.push(` ${i(m)}(${T})`);
|
|
2900
|
+
const N = p[e].roles[0]?.color ?? o;
|
|
2901
|
+
g ? u.push(` style ${i(m)} fill:#2962FF,stroke:none`) : u.push(` style ${i(m)} fill:none,stroke:${N},stroke-width:3px`);
|
|
2926
2902
|
}
|
|
2927
|
-
const f =
|
|
2903
|
+
const f = n ? c.flatMap((m) => Object.values(s.edges).filter((p) => p.from === m)) : Object.values(s.edges);
|
|
2928
2904
|
for (const m of f)
|
|
2929
|
-
m.label ? u.push(` ${
|
|
2905
|
+
m.label ? u.push(` ${i(m.from)} -->|${m.label}| ${i(m.to)}`) : u.push(` ${i(m.from)} --> ${i(m.to)}`);
|
|
2930
2906
|
return u.join(`
|
|
2931
2907
|
`);
|
|
2932
2908
|
}
|
|
2933
|
-
class
|
|
2909
|
+
class Js {
|
|
2934
2910
|
env;
|
|
2935
2911
|
effects = {};
|
|
2936
2912
|
automations = {};
|
|
2937
2913
|
resolvers = {};
|
|
2938
|
-
adapters = {};
|
|
2939
2914
|
constructor({ env: e = {} } = {}) {
|
|
2940
2915
|
this.env = e;
|
|
2941
2916
|
}
|
|
@@ -2948,47 +2923,38 @@ class qs {
|
|
|
2948
2923
|
resolver(e, t) {
|
|
2949
2924
|
return this.resolvers[e] = t, this;
|
|
2950
2925
|
}
|
|
2951
|
-
adapter(e, t) {
|
|
2952
|
-
return this.adapters[e] = t, this;
|
|
2953
|
-
}
|
|
2954
2926
|
/** @internal Called by Engine.getRemoteData — keeps env encapsulated inside the Runtime. */
|
|
2955
2927
|
_runResolver(e, t) {
|
|
2956
|
-
const
|
|
2957
|
-
if (!
|
|
2958
|
-
return
|
|
2959
|
-
}
|
|
2960
|
-
/** @internal Called by Engine.useAdapter — keeps handler lookup inside the Runtime. */
|
|
2961
|
-
_runAdapter(e, t) {
|
|
2962
|
-
const s = this.adapters[e];
|
|
2963
|
-
if (!s) throw new Error(`No handler declared for adapter "${e}"`);
|
|
2964
|
-
return s(t);
|
|
2928
|
+
const n = this.resolvers[e];
|
|
2929
|
+
if (!n) throw new Error(`No handler declared for resolver "${e}"`);
|
|
2930
|
+
return n(t, this.env);
|
|
2965
2931
|
}
|
|
2966
2932
|
}
|
|
2967
2933
|
class D {
|
|
2968
2934
|
constructor(e, t) {
|
|
2969
2935
|
this._data = e, this._zip = t;
|
|
2970
|
-
const
|
|
2936
|
+
const n = () => this._data;
|
|
2971
2937
|
this.project = new jt(
|
|
2972
2938
|
() => this._data.project,
|
|
2973
|
-
(
|
|
2974
|
-
this._data.project =
|
|
2939
|
+
(i) => {
|
|
2940
|
+
this._data.project = i;
|
|
2975
2941
|
},
|
|
2976
2942
|
fe,
|
|
2977
|
-
(
|
|
2978
|
-
const r = [], d = x("project",
|
|
2979
|
-
return d && r.push(d),
|
|
2943
|
+
(i, o) => {
|
|
2944
|
+
const r = [], d = x("project", i.code, o.deliverableNamingConvention);
|
|
2945
|
+
return d && r.push(d), i.clientId && !o.teams.some((l) => l.id === i.clientId) && r.push(`teams["${i.clientId}"] not found`), r;
|
|
2980
2946
|
},
|
|
2981
|
-
|
|
2982
|
-
), this.actions = new
|
|
2947
|
+
n
|
|
2948
|
+
), this.actions = new Ot(n), this.annexes = new _t(n), this.env = new xt(n), this.events = new Pt(n), this.effects = new Bt(n), this.automations = new Mt(n), this.bimUses = new zt(n, () => this.workflows), this.disciplines = new Zt(n), this.guides = new Jt(n), this.lods = new Kt(n), this.lois = new qt(n), this.loin = new Wt(n), this.lbsNodes = new Ht(n), this.assetTypes = new Gt(n), this.extensions = new Xt(n), this.roles = new Vt(n), this.members = new Yt(n), this.milestones = new Qt(n), this.objectives = new es(n), this.phases = new ts(n), this.remoteData = new ss(n), this.resolvers = new ns(n), this.softwares = new is(n, () => this.assetTypes), this.standards = new os(n, () => this._zip), this.teams = new rs(n, () => this.members), this.workflows = new ds(n, () => this.members, () => this.teams), this.deliverables = new Dt(n, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Ut(n, () => this.members), this.flags = new Lt(n), this.engine = new Ps(
|
|
2983
2949
|
() => this._data,
|
|
2984
|
-
(
|
|
2950
|
+
(i) => this.history.get(i)
|
|
2985
2951
|
), this.history = new k(
|
|
2986
|
-
|
|
2987
|
-
(
|
|
2988
|
-
this._data =
|
|
2952
|
+
n,
|
|
2953
|
+
(i) => {
|
|
2954
|
+
this._data = i;
|
|
2989
2955
|
},
|
|
2990
2956
|
() => this._zip
|
|
2991
|
-
), this.nomenclature = new
|
|
2957
|
+
), this.nomenclature = new Ct(n), this.memory = new q("memory.md", () => this._zip), this.skill = new q("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new q("icon.svg", () => this._zip);
|
|
2992
2958
|
}
|
|
2993
2959
|
_data;
|
|
2994
2960
|
_zip;
|
|
@@ -2996,7 +2962,6 @@ class D {
|
|
|
2996
2962
|
project;
|
|
2997
2963
|
// ─── Entities ─────────────────────────────────────────────────────────────
|
|
2998
2964
|
actions;
|
|
2999
|
-
adapters;
|
|
3000
2965
|
annexes;
|
|
3001
2966
|
deliverables;
|
|
3002
2967
|
effects;
|
|
@@ -3046,10 +3011,10 @@ class D {
|
|
|
3046
3011
|
* fully operational after open(). Idempotent — existing files are untouched.
|
|
3047
3012
|
*/
|
|
3048
3013
|
static async open(e) {
|
|
3049
|
-
const t = await
|
|
3050
|
-
if (!
|
|
3051
|
-
const
|
|
3052
|
-
return await D._initialize(
|
|
3014
|
+
const t = await oe.loadAsync(e), n = t.file("bep.json");
|
|
3015
|
+
if (!n) throw new Error("Invalid .bep file: missing bep.json");
|
|
3016
|
+
const i = await n.async("string"), o = B(JSON.parse(i));
|
|
3017
|
+
return await D._initialize(o, t), new D(o, t);
|
|
3053
3018
|
}
|
|
3054
3019
|
/**
|
|
3055
3020
|
* Ensures all expected files exist in the zip.
|
|
@@ -3064,14 +3029,14 @@ class D {
|
|
|
3064
3029
|
*/
|
|
3065
3030
|
static async _initialize(e, t) {
|
|
3066
3031
|
t.file("memory.md") || t.file("memory.md", ""), t.file("skills/bep-authoring/SKILL.md") || t.file("skills/bep-authoring/SKILL.md", "");
|
|
3067
|
-
for (const
|
|
3068
|
-
t.file(
|
|
3032
|
+
for (const n of e.standards)
|
|
3033
|
+
t.file(n.contentPath) || t.file(n.contentPath, "");
|
|
3069
3034
|
if (!t.file("baseline/bep.json")) {
|
|
3070
|
-
const
|
|
3071
|
-
t.file("baseline/bep.json",
|
|
3072
|
-
for (const
|
|
3073
|
-
const
|
|
3074
|
-
t.file(`baseline/standards/${
|
|
3035
|
+
const n = JSON.stringify(e, null, 2);
|
|
3036
|
+
t.file("baseline/bep.json", n), t.file("changelog/v0.0.json", n);
|
|
3037
|
+
for (const i of e.standards) {
|
|
3038
|
+
const o = await t.file(i.contentPath).async("string");
|
|
3039
|
+
t.file(`baseline/standards/${i.id}.md`, o), t.file(`changelog/standards/${i.id}/v0.0.md`, o);
|
|
3075
3040
|
}
|
|
3076
3041
|
}
|
|
3077
3042
|
}
|
|
@@ -3105,8 +3070,8 @@ class D {
|
|
|
3105
3070
|
flags: [],
|
|
3106
3071
|
env: [],
|
|
3107
3072
|
automations: []
|
|
3108
|
-
}),
|
|
3109
|
-
return
|
|
3073
|
+
}), n = new oe(), i = JSON.stringify(t, null, 2);
|
|
3074
|
+
return n.file("memory.md", ""), n.file("skills/bep-authoring/SKILL.md", ""), n.file("baseline/bep.json", i), n.file("changelog/v0.0.json", i), new D(t, n);
|
|
3110
3075
|
}
|
|
3111
3076
|
// ─── Accessors ────────────────────────────────────────────────────────────
|
|
3112
3077
|
get data() {
|
|
@@ -3122,9 +3087,9 @@ class D {
|
|
|
3122
3087
|
delete this._data.deliverableNamingConvention;
|
|
3123
3088
|
return;
|
|
3124
3089
|
}
|
|
3125
|
-
const t = he.parse(e),
|
|
3126
|
-
if (
|
|
3127
|
-
${
|
|
3090
|
+
const t = he.parse(e), n = Tt(this._data, t);
|
|
3091
|
+
if (n.length) throw new Error(`Naming convention incompatible with existing data:
|
|
3092
|
+
${n.join(`
|
|
3128
3093
|
`)}`);
|
|
3129
3094
|
this._data.deliverableNamingConvention = t;
|
|
3130
3095
|
}
|
|
@@ -3139,8 +3104,8 @@ ${s.join(`
|
|
|
3139
3104
|
listSkills() {
|
|
3140
3105
|
const e = /* @__PURE__ */ new Set();
|
|
3141
3106
|
return this._zip.forEach((t) => {
|
|
3142
|
-
const
|
|
3143
|
-
|
|
3107
|
+
const n = t.match(/^skills\/([^/]+)\/SKILL\.md$/);
|
|
3108
|
+
n && e.add(n[1]);
|
|
3144
3109
|
}), [...e];
|
|
3145
3110
|
}
|
|
3146
3111
|
/** Returns the SKILL.md content for the given skill, or null if it does not exist. */
|
|
@@ -3154,26 +3119,26 @@ ${s.join(`
|
|
|
3154
3119
|
}
|
|
3155
3120
|
/** Returns the names of all resource files for the given skill. */
|
|
3156
3121
|
listSkillResources(e) {
|
|
3157
|
-
const t = `skills/${e}/resources/`,
|
|
3158
|
-
return this._zip.forEach((
|
|
3159
|
-
|
|
3160
|
-
}),
|
|
3122
|
+
const t = `skills/${e}/resources/`, n = [];
|
|
3123
|
+
return this._zip.forEach((i) => {
|
|
3124
|
+
i.startsWith(t) && i !== t && n.push(i.slice(t.length));
|
|
3125
|
+
}), n;
|
|
3161
3126
|
}
|
|
3162
3127
|
/** Returns the content of a resource file for the given skill, or null if it does not exist. */
|
|
3163
3128
|
async getSkillResource(e, t) {
|
|
3164
|
-
const
|
|
3165
|
-
return
|
|
3129
|
+
const n = this._zip.file(`skills/${e}/resources/${t}`);
|
|
3130
|
+
return n ? n.async("string") : null;
|
|
3166
3131
|
}
|
|
3167
3132
|
/** Writes a resource file for the given skill, creating it if needed. */
|
|
3168
|
-
async setSkillResource(e, t,
|
|
3169
|
-
this._zip.file(`skills/${e}/resources/${t}`,
|
|
3133
|
+
async setSkillResource(e, t, n) {
|
|
3134
|
+
this._zip.file(`skills/${e}/resources/${t}`, n);
|
|
3170
3135
|
}
|
|
3171
3136
|
/** Removes a skill's SKILL.md and all its resources from the archive. No-op if not found. */
|
|
3172
3137
|
removeSkill(e) {
|
|
3173
|
-
const t = `skills/${e}/`,
|
|
3174
|
-
this._zip.forEach((
|
|
3175
|
-
|
|
3176
|
-
}),
|
|
3138
|
+
const t = `skills/${e}/`, n = [];
|
|
3139
|
+
this._zip.forEach((i) => {
|
|
3140
|
+
i.startsWith(t) && n.push(i);
|
|
3141
|
+
}), n.forEach((i) => this._zip.remove(i));
|
|
3177
3142
|
}
|
|
3178
3143
|
/** Removes a single resource file from a skill. No-op if not found. */
|
|
3179
3144
|
removeSkillResource(e, t) {
|
|
@@ -3191,14 +3156,14 @@ ${s.join(`
|
|
|
3191
3156
|
*/
|
|
3192
3157
|
generateRuntimeTypes() {
|
|
3193
3158
|
const e = (f) => f === "url" ? "string" : f, t = (f) => ` /** ${f} */
|
|
3194
|
-
`,
|
|
3195
|
-
const m = f.payload && f.payload.length > 0 ? `payload: ${
|
|
3159
|
+
`, n = (f) => `{ ${f.map((m) => `${m.key}${m.required ? "" : "?"}: ${e(m.type)}`).join("; ")} }`, i = (f) => !f.payload || f.payload.length === 0 ? "() => void" : `(payload: ${n(f.payload)}) => void`, o = (f) => {
|
|
3160
|
+
const m = f.payload && f.payload.length > 0 ? `payload: ${n(f.payload)}` : "", p = f.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${f.output.map((g) => `${g.key}${g.required ? "" : "?"}: ${e(g.type)}`).join("; ")} }`;
|
|
3196
3161
|
return `(${m}) => ${p}`;
|
|
3197
|
-
}, r = (f) => f.envKeys.length === 0 ? "(url: string) => unknown" : `(url: string, env: ${`{ ${f.envKeys.map((p) => `${p}: string`).join("; ")} }`}) => unknown`, d = this._data.effects.length ? this._data.effects.map((f) => `${t(f.description)} '${f.id}': ${
|
|
3198
|
-
`) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${
|
|
3162
|
+
}, r = (f) => f.envKeys.length === 0 ? "(url: string) => unknown" : `(url: string, env: ${`{ ${f.envKeys.map((p) => `${p}: string`).join("; ")} }`}) => unknown`, d = this._data.effects.length ? this._data.effects.map((f) => `${t(f.description)} '${f.id}': ${i(f)}`).join(`
|
|
3163
|
+
`) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${o(f)}`).join(`
|
|
3199
3164
|
`) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((f) => `${t(f.description)} '${f.id}': ${r(f)}`).join(`
|
|
3200
|
-
`) : " [key: string]: (url: string) => unknown", u = this._data.
|
|
3201
|
-
`) : " [key: string]:
|
|
3165
|
+
`) : " [key: string]: (url: string) => unknown", u = this._data.env.length ? this._data.env.map((f) => `${t(f.description)} ${f.key}: string`).join(`
|
|
3166
|
+
`) : " [key: string]: string";
|
|
3202
3167
|
return [
|
|
3203
3168
|
"// Generated by bep.generateRuntimeTypes() — do not edit manually",
|
|
3204
3169
|
"",
|
|
@@ -3220,9 +3185,9 @@ ${s.join(`
|
|
|
3220
3185
|
c,
|
|
3221
3186
|
"}",
|
|
3222
3187
|
"",
|
|
3223
|
-
"// ───
|
|
3188
|
+
"// ─── Env ──────────────────────────────────────────────────────────────────────",
|
|
3224
3189
|
"",
|
|
3225
|
-
"export interface
|
|
3190
|
+
"export interface BepEnv {",
|
|
3226
3191
|
u,
|
|
3227
3192
|
"}",
|
|
3228
3193
|
"",
|
|
@@ -3232,7 +3197,7 @@ ${s.join(`
|
|
|
3232
3197
|
" effects: BepEffects",
|
|
3233
3198
|
" automations: BepAutomations",
|
|
3234
3199
|
" resolvers: BepResolvers",
|
|
3235
|
-
"
|
|
3200
|
+
" env: BepEnv",
|
|
3236
3201
|
"}",
|
|
3237
3202
|
""
|
|
3238
3203
|
].join(`
|
|
@@ -3250,124 +3215,122 @@ ${s.join(`
|
|
|
3250
3215
|
}
|
|
3251
3216
|
export {
|
|
3252
3217
|
ke as ActionSchema,
|
|
3253
|
-
|
|
3254
|
-
ze as AdapterSchema,
|
|
3255
|
-
Bt as Adapters,
|
|
3218
|
+
Ot as Actions,
|
|
3256
3219
|
Oe as AnnexSchema,
|
|
3257
|
-
|
|
3258
|
-
|
|
3220
|
+
Ye as AnnexType,
|
|
3221
|
+
_t as Annexes,
|
|
3259
3222
|
Ie as AssetTypeSchema,
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3223
|
+
Gt as AssetTypes,
|
|
3224
|
+
Mt as Automations,
|
|
3225
|
+
Ls as BEPSchema,
|
|
3263
3226
|
re as BEPVersionBase,
|
|
3264
|
-
|
|
3227
|
+
St as BEPVersionSchema,
|
|
3265
3228
|
Se as BIMUseSchema,
|
|
3266
|
-
|
|
3229
|
+
zt as BIMUses,
|
|
3267
3230
|
D as Bep,
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3231
|
+
Us as ChangelogSchema,
|
|
3232
|
+
kt as DEFAULT_DELIMITER,
|
|
3233
|
+
$t as DEFAULT_TOKEN_PATTERN,
|
|
3234
|
+
Nt as DeliverableBaseSchema,
|
|
3272
3235
|
De as DeliverableSchema,
|
|
3273
|
-
|
|
3236
|
+
Dt as Deliverables,
|
|
3274
3237
|
we as DisciplineSchema,
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3238
|
+
Zt as Disciplines,
|
|
3239
|
+
ht as EdgeGuardSchema,
|
|
3240
|
+
Bt as Effects,
|
|
3241
|
+
Ps as Engine,
|
|
3279
3242
|
y as Entity,
|
|
3280
|
-
|
|
3243
|
+
xt as Env,
|
|
3281
3244
|
Le as EnvVarSchema,
|
|
3282
|
-
|
|
3245
|
+
Pt as Events,
|
|
3283
3246
|
ve as ExtensionSchema,
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3247
|
+
Xt as Extensions,
|
|
3248
|
+
Et as FlagBaseSchema,
|
|
3249
|
+
st as FlagEntityType,
|
|
3287
3250
|
Ce as FlagSchema,
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3251
|
+
tt as FlagSeverity,
|
|
3252
|
+
Lt as Flags,
|
|
3253
|
+
ut as FlowAutomationNodeSchema,
|
|
3291
3254
|
Te as FlowAutomationSchema,
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3255
|
+
yt as FlowDecisionEdgeSchema,
|
|
3256
|
+
ft as FlowDecisionNodeSchema,
|
|
3257
|
+
vt as FlowDiagramSchema,
|
|
3258
|
+
bt as FlowDirectEdgeSchema,
|
|
3259
|
+
et as FlowDirection,
|
|
3260
|
+
wt as FlowEdgeSchema,
|
|
3298
3261
|
Re as FlowEffectSchema,
|
|
3299
|
-
|
|
3262
|
+
ct as FlowEndNodeSchema,
|
|
3300
3263
|
$e as FlowEventSchema,
|
|
3301
|
-
|
|
3264
|
+
pt as FlowNodeSchema,
|
|
3302
3265
|
L as FlowPayloadFieldSchema,
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3266
|
+
mt as FlowProcessNodeSchema,
|
|
3267
|
+
lt as FlowStartNodeSchema,
|
|
3268
|
+
gt as FlowTransitionEdgeSchema,
|
|
3306
3269
|
_e as GuideSchema,
|
|
3307
|
-
|
|
3270
|
+
Jt as Guides,
|
|
3308
3271
|
k as History,
|
|
3309
|
-
|
|
3310
|
-
|
|
3272
|
+
He as ISORole,
|
|
3273
|
+
rt as LBSNodeBaseSchema,
|
|
3311
3274
|
be as LBSNodeSchema,
|
|
3312
|
-
|
|
3313
|
-
|
|
3275
|
+
Qe as LBSNodeType,
|
|
3276
|
+
Ht as LBSNodes,
|
|
3314
3277
|
Me as LODSchema,
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3278
|
+
Kt as LODs,
|
|
3279
|
+
Wt as LOINEntity,
|
|
3280
|
+
It as LOINMilestoneSchema,
|
|
3318
3281
|
Pe as LOINSchema,
|
|
3319
3282
|
xe as LOISchema,
|
|
3320
|
-
|
|
3283
|
+
qt as LOIs,
|
|
3321
3284
|
me as MemberSchema,
|
|
3322
|
-
|
|
3323
|
-
|
|
3285
|
+
Yt as Members,
|
|
3286
|
+
Ms as MemoryStorage,
|
|
3324
3287
|
ye as MilestoneSchema,
|
|
3325
|
-
|
|
3288
|
+
Qt as Milestones,
|
|
3326
3289
|
he as NamingConventionSchema,
|
|
3327
|
-
|
|
3290
|
+
ot as NamingSegmentSchema,
|
|
3328
3291
|
it as NamingTokenSchema,
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3292
|
+
at as NodeTimeoutSchema,
|
|
3293
|
+
Ds as NodeType,
|
|
3294
|
+
Ct as Nomenclature,
|
|
3332
3295
|
Fe as NoteSchema,
|
|
3333
|
-
|
|
3296
|
+
Ut as Notes,
|
|
3334
3297
|
Ne as ObjectiveSchema,
|
|
3335
|
-
|
|
3298
|
+
es as Objectives,
|
|
3336
3299
|
ge as PhaseSchema,
|
|
3337
|
-
|
|
3300
|
+
ts as Phases,
|
|
3338
3301
|
fe as ProjectSchema,
|
|
3339
|
-
|
|
3340
|
-
|
|
3302
|
+
ss as RemoteDataEntity,
|
|
3303
|
+
ze as RemoteDataSchema,
|
|
3341
3304
|
Ue as ResolverSchema,
|
|
3342
|
-
|
|
3305
|
+
ns as Resolvers,
|
|
3343
3306
|
ue as RoleSchema,
|
|
3344
|
-
|
|
3345
|
-
|
|
3307
|
+
Vt as Roles,
|
|
3308
|
+
Js as Runtime,
|
|
3346
3309
|
jt as Singleton,
|
|
3347
3310
|
Ee as SoftwareSchema,
|
|
3348
|
-
|
|
3311
|
+
is as Softwares,
|
|
3349
3312
|
Be as StandardSchema,
|
|
3350
|
-
|
|
3351
|
-
|
|
3313
|
+
os as Standards,
|
|
3314
|
+
nt as TeamBaseSchema,
|
|
3352
3315
|
pe as TeamSchema,
|
|
3353
|
-
|
|
3316
|
+
rs as Teams,
|
|
3354
3317
|
q as TextFile,
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3318
|
+
Ae as WorkflowSchema,
|
|
3319
|
+
ds as Workflows,
|
|
3320
|
+
Ns as arrayDefs,
|
|
3321
|
+
qe as buildCodeMap,
|
|
3359
3322
|
W as buildConsecutivoMap,
|
|
3360
3323
|
C as buildParentMap,
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3324
|
+
ks as diffBep,
|
|
3325
|
+
Ss as diffEntities,
|
|
3326
|
+
Zs as flowDiagramToMermaid,
|
|
3327
|
+
Ke as getNomenCode,
|
|
3365
3328
|
te as getRootIds,
|
|
3366
|
-
|
|
3367
|
-
|
|
3329
|
+
Rt as getTokenPattern,
|
|
3330
|
+
zs as groupRaciRows,
|
|
3368
3331
|
B as normalizeBep,
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3332
|
+
Je as resolveLBSCodes,
|
|
3333
|
+
Tt as validateAllTokens,
|
|
3334
|
+
Ft as validateLBS,
|
|
3372
3335
|
x as validateTokenValue
|
|
3373
3336
|
};
|