@dotbep/core 0.2.9 → 0.2.11
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 +67 -12
- package/dist/index.js +685 -654
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import re from "jszip";
|
|
2
2
|
import { z as a, ZodError as Ve } from "zod";
|
|
3
3
|
const He = a.enum([
|
|
4
4
|
"appointing-party",
|
|
@@ -55,19 +55,19 @@ const He = a.enum([
|
|
|
55
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
|
+
}), ot = a.enum([
|
|
59
59
|
"project",
|
|
60
60
|
"team",
|
|
61
61
|
"discipline",
|
|
62
62
|
"assetType",
|
|
63
63
|
"lbsZone",
|
|
64
64
|
"lbsLocation"
|
|
65
|
-
]),
|
|
66
|
-
a.object({ type: a.literal("field"), token:
|
|
65
|
+
]), it = a.discriminatedUnion("type", [
|
|
66
|
+
a.object({ type: a.literal("field"), token: ot, 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(
|
|
70
|
+
segments: a.array(it).min(1)
|
|
71
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"]
|
|
@@ -87,10 +87,10 @@ const He = a.enum([
|
|
|
87
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."),
|
|
90
|
+
}).describe("A spatial or functional subdivision of the project. LBS nodes form a hierarchy that scopes deliverables to specific spatial or functional areas."), we = rt.refine((s) => !(s.lbsNodeIds ?? []).includes(s.id), {
|
|
91
91
|
message: "A node cannot reference itself in lbsNodeIds.",
|
|
92
92
|
path: ["lbsNodeIds"]
|
|
93
|
-
}),
|
|
93
|
+
}), be = a.object({
|
|
94
94
|
id: a.string().min(1).describe("Used in deliverables nomenclature."),
|
|
95
95
|
name: a.string().min(1)
|
|
96
96
|
}).describe("A project discipline used to classify deliverables and information requirements. Represents a technical domain such as structure, architecture, or MEP."), ve = a.object({
|
|
@@ -125,8 +125,12 @@ const He = a.enum([
|
|
|
125
125
|
guideIds: a.array(a.string()).optional().describe("ref Guide.id[]")
|
|
126
126
|
}).describe("A human-performed activity referenced by workflow process nodes. Actions represent what a person in a given role does at a specific step."), L = a.object({
|
|
127
127
|
key: a.string().min(1),
|
|
128
|
-
type: a.enum(["string", "number", "boolean"
|
|
129
|
-
required: a.boolean()
|
|
128
|
+
type: a.enum(["string", "number", "boolean"]),
|
|
129
|
+
required: a.boolean(),
|
|
130
|
+
label: a.string().min(1).optional(),
|
|
131
|
+
description: a.string().optional(),
|
|
132
|
+
validation: a.object({ pattern: a.string().min(1), flags: a.string().optional() }).optional(),
|
|
133
|
+
options: a.array(a.string().min(1)).optional()
|
|
130
134
|
}), $e = a.object({
|
|
131
135
|
id: a.string().min(1).describe('Human-readable slug, e.g. "status-changed".'),
|
|
132
136
|
name: a.string().min(1),
|
|
@@ -200,7 +204,7 @@ const He = a.enum([
|
|
|
200
204
|
}).refine((s) => s.operator === "exists" || s.value !== void 0, {
|
|
201
205
|
message: 'value is required when operator is not "exists".',
|
|
202
206
|
path: ["value"]
|
|
203
|
-
}),
|
|
207
|
+
}), te = a.object({
|
|
204
208
|
from: a.string().describe("ref FlowNode key"),
|
|
205
209
|
to: a.string().describe("ref FlowNode key"),
|
|
206
210
|
label: a.string().optional(),
|
|
@@ -208,30 +212,30 @@ const He = a.enum([
|
|
|
208
212
|
}).refine((s) => s.from !== s.to, {
|
|
209
213
|
message: "A flow edge cannot point from a node to itself.",
|
|
210
214
|
path: ["to"]
|
|
211
|
-
}), gt =
|
|
215
|
+
}), gt = te.extend({
|
|
212
216
|
triggerEventId: a.string().min(1).describe("ref FlowEvent.id — the event that fires this transition")
|
|
213
|
-
}), yt =
|
|
217
|
+
}), yt = te.extend({
|
|
214
218
|
guard: ht.describe("Condition evaluated against the instance context to determine which path to take.")
|
|
215
|
-
}),
|
|
219
|
+
}), wt = te, bt = a.union([gt, yt, wt]), vt = a.object({
|
|
216
220
|
direction: et.default("LR"),
|
|
217
221
|
nodes: a.record(a.string(), pt),
|
|
218
|
-
edges: a.record(a.string(),
|
|
222
|
+
edges: a.record(a.string(), bt)
|
|
219
223
|
}).superRefine((s, e) => {
|
|
220
|
-
const t = Object.entries(s.nodes), n = t.filter(([, r]) => r.type === "start").length,
|
|
224
|
+
const t = Object.entries(s.nodes), n = t.filter(([, r]) => r.type === "start").length, o = t.filter(([, r]) => r.type === "end").length;
|
|
221
225
|
n !== 1 && e.addIssue({
|
|
222
226
|
code: "custom",
|
|
223
227
|
message: `Diagram must have exactly one start node (found ${n}).`,
|
|
224
228
|
path: ["nodes"]
|
|
225
|
-
}),
|
|
229
|
+
}), o !== 1 && e.addIssue({
|
|
226
230
|
code: "custom",
|
|
227
|
-
message: `Diagram must have exactly one end node (found ${
|
|
231
|
+
message: `Diagram must have exactly one end node (found ${o}).`,
|
|
228
232
|
path: ["nodes"]
|
|
229
233
|
});
|
|
230
|
-
const
|
|
234
|
+
const i = {};
|
|
231
235
|
for (const [r, d] of Object.entries(s.edges))
|
|
232
|
-
|
|
236
|
+
i[d.from] ??= [], i[d.from].push({ edgeId: r, toKey: d.to });
|
|
233
237
|
for (const [r, d] of t) {
|
|
234
|
-
const l =
|
|
238
|
+
const l = i[r] ?? [];
|
|
235
239
|
d.type === "automation" && (l.length !== 1 ? e.addIssue({
|
|
236
240
|
code: "custom",
|
|
237
241
|
message: `automation node must have exactly one outgoing edge (found ${l.length}).`,
|
|
@@ -366,8 +370,8 @@ const He = a.enum([
|
|
|
366
370
|
teams: a.array(pe),
|
|
367
371
|
phases: a.array(ge),
|
|
368
372
|
milestones: a.array(ye),
|
|
369
|
-
lbs: a.array(
|
|
370
|
-
disciplines: a.array(
|
|
373
|
+
lbs: a.array(we),
|
|
374
|
+
disciplines: a.array(be),
|
|
371
375
|
extensions: a.array(ve),
|
|
372
376
|
assetTypes: a.array(Ie),
|
|
373
377
|
softwares: a.array(Ee),
|
|
@@ -390,15 +394,15 @@ const He = a.enum([
|
|
|
390
394
|
deliverables: a.array(De),
|
|
391
395
|
notes: a.array(Fe),
|
|
392
396
|
flags: a.array(Ce)
|
|
393
|
-
}),
|
|
397
|
+
}), ae = a.object({
|
|
394
398
|
version: a.string().regex(/^\d+\.\d+$/).describe('Format: "{major}.{minor}" (e.g. "1.0", "2.3").'),
|
|
395
399
|
date: a.iso.datetime(),
|
|
396
400
|
author: a.email().describe("ref Member.email"),
|
|
397
401
|
description: a.string().min(1),
|
|
398
402
|
diff: a.string().nullable().describe("Relative path to inverse diff (RFC 6902). null on v0.0.")
|
|
399
403
|
}), St = a.discriminatedUnion("type", [
|
|
400
|
-
|
|
401
|
-
|
|
404
|
+
ae.extend({ type: a.literal("patch") }),
|
|
405
|
+
ae.extend({
|
|
402
406
|
type: a.literal("version"),
|
|
403
407
|
approvedBy: a.array(a.email()).describe("ref Member.email[]")
|
|
404
408
|
})
|
|
@@ -418,24 +422,24 @@ function Rt(s, e) {
|
|
|
418
422
|
return $t;
|
|
419
423
|
}
|
|
420
424
|
function x(s, e, t) {
|
|
421
|
-
const n = t?.delimiter ?? kt,
|
|
422
|
-
return new RegExp(
|
|
425
|
+
const n = t?.delimiter ?? kt, o = Rt(s, t);
|
|
426
|
+
return new RegExp(o).test(e) ? e.includes(n) ? `"${e}" contains the naming delimiter "${n}"` : null : `"${e}" does not match naming pattern ${o} for token "${s}"`;
|
|
423
427
|
}
|
|
424
428
|
function Tt(s, e) {
|
|
425
|
-
const t = [], n = (
|
|
426
|
-
const r = x(
|
|
429
|
+
const t = [], n = (o, i) => {
|
|
430
|
+
const r = x(o, i, e);
|
|
427
431
|
r && t.push(r);
|
|
428
432
|
};
|
|
429
433
|
n("project", s.project.code);
|
|
430
|
-
for (const
|
|
431
|
-
for (const
|
|
432
|
-
for (const
|
|
433
|
-
for (const
|
|
434
|
+
for (const o of s.teams) n("team", o.id);
|
|
435
|
+
for (const o of s.disciplines) n("discipline", o.id);
|
|
436
|
+
for (const o of s.assetTypes) n("assetType", o.id);
|
|
437
|
+
for (const o of s.lbs) n(o.type === "zone" ? "lbsZone" : "lbsLocation", o.id);
|
|
434
438
|
return t;
|
|
435
439
|
}
|
|
436
440
|
class jt {
|
|
437
|
-
constructor(e, t, n,
|
|
438
|
-
this.getItem = e, this.setItem = t, this.schema = n, this.validate =
|
|
441
|
+
constructor(e, t, n, o, i) {
|
|
442
|
+
this.getItem = e, this.setItem = t, this.schema = n, this.validate = o, this.getBep = i;
|
|
439
443
|
}
|
|
440
444
|
getItem;
|
|
441
445
|
setItem;
|
|
@@ -495,26 +499,26 @@ const Ze = [
|
|
|
495
499
|
{ entity: "lbs", references: "lbs", inField: "lbsNodeIds", array: !0 }
|
|
496
500
|
];
|
|
497
501
|
function At(s, e, t) {
|
|
498
|
-
return Ze.filter((n) => n.references === e).flatMap((n) => t[n.entity].filter((
|
|
499
|
-
const r =
|
|
502
|
+
return Ze.filter((n) => n.references === e).flatMap((n) => t[n.entity].filter((i) => {
|
|
503
|
+
const r = i[n.inField];
|
|
500
504
|
return n.array ? Array.isArray(r) && r.includes(s) : r === s;
|
|
501
|
-
}).map((
|
|
502
|
-
const r =
|
|
505
|
+
}).map((i) => {
|
|
506
|
+
const r = i.id ?? i.email ?? "?";
|
|
503
507
|
return `${String(n.entity)}["${r}"].${String(n.inField)}`;
|
|
504
508
|
}));
|
|
505
509
|
}
|
|
506
|
-
function
|
|
510
|
+
function de(s, e, t) {
|
|
507
511
|
return Ze.filter((n) => n.entity === e).flatMap((n) => {
|
|
508
|
-
const
|
|
509
|
-
if (
|
|
510
|
-
const
|
|
511
|
-
return
|
|
512
|
+
const o = s[n.inField];
|
|
513
|
+
if (o == null || o === "") return [];
|
|
514
|
+
const i = n.array ? o : [o], r = t[n.references];
|
|
515
|
+
return i.filter((d) => !r.some((l) => (l.id ?? l.email) === d)).map((d) => `${String(n.references)}["${d}"] not found`);
|
|
512
516
|
});
|
|
513
517
|
}
|
|
514
518
|
function K(s) {
|
|
515
519
|
return s instanceof Ve ? s.issues.map((e) => (e.path.length ? e.path.join(".") + ": " : "") + e.message).join("; ") : s.message;
|
|
516
520
|
}
|
|
517
|
-
class
|
|
521
|
+
class w {
|
|
518
522
|
constructor(e, t, n) {
|
|
519
523
|
this.getItems = e, this.getBep = t, this.config = n, this.idField = n.idField ?? "id";
|
|
520
524
|
}
|
|
@@ -530,23 +534,23 @@ class y {
|
|
|
530
534
|
}
|
|
531
535
|
get(e) {
|
|
532
536
|
const t = [], n = [];
|
|
533
|
-
for (const
|
|
534
|
-
const
|
|
535
|
-
|
|
537
|
+
for (const o of e) {
|
|
538
|
+
const i = this.getItems().find((r) => this.getId(r) === o);
|
|
539
|
+
i ? t.push(i) : n.push({ id: o, error: `Not found: ${o}` });
|
|
536
540
|
}
|
|
537
541
|
return { succeeded: t, failed: n };
|
|
538
542
|
}
|
|
539
543
|
add(e) {
|
|
540
544
|
const t = [], n = [];
|
|
541
|
-
for (const
|
|
542
|
-
const
|
|
543
|
-
this.config.autoId && !
|
|
544
|
-
const r = String(
|
|
545
|
+
for (const o of e) {
|
|
546
|
+
const i = { ...o };
|
|
547
|
+
this.config.autoId && !i[this.idField] && (i[this.idField] = globalThis.crypto.randomUUID());
|
|
548
|
+
const r = String(i[this.idField] ?? "(unknown)");
|
|
545
549
|
try {
|
|
546
|
-
const d = this.config.schema.parse(
|
|
550
|
+
const d = this.config.schema.parse(i);
|
|
547
551
|
if (this.getItems().some((u) => this.getId(u) === this.getId(d)))
|
|
548
552
|
throw new Error(`Already exists: ${this.getId(d)}`);
|
|
549
|
-
const l =
|
|
553
|
+
const l = de(d, this.config.key, this.getBep());
|
|
550
554
|
if (l.length) throw new Error(l.join("; "));
|
|
551
555
|
const c = this.config.validate?.(d, this.getBep()) ?? [];
|
|
552
556
|
if (c.length) throw new Error(c.join("; "));
|
|
@@ -559,47 +563,47 @@ class y {
|
|
|
559
563
|
}
|
|
560
564
|
update(e) {
|
|
561
565
|
const t = [], n = [];
|
|
562
|
-
for (const
|
|
563
|
-
const
|
|
566
|
+
for (const o of e) {
|
|
567
|
+
const i = String(o[this.idField]), r = this.getItems(), d = r.findIndex((c) => this.getId(c) === i);
|
|
564
568
|
if (d === -1) {
|
|
565
|
-
n.push({ id:
|
|
569
|
+
n.push({ id: i, error: `Not found: ${i}` });
|
|
566
570
|
continue;
|
|
567
571
|
}
|
|
568
|
-
const l =
|
|
572
|
+
const l = de(o, this.config.key, this.getBep());
|
|
569
573
|
if (l.length) {
|
|
570
|
-
n.push({ id:
|
|
574
|
+
n.push({ id: i, error: l.join("; ") });
|
|
571
575
|
continue;
|
|
572
576
|
}
|
|
573
577
|
try {
|
|
574
|
-
const c = this.config.schema.parse({ ...r[d], ...
|
|
578
|
+
const c = this.config.schema.parse({ ...r[d], ...o }), u = this.config.validate?.(c, this.getBep()) ?? [];
|
|
575
579
|
if (u.length) throw new Error(u.join("; "));
|
|
576
580
|
r[d] = c, t.push(r[d]);
|
|
577
581
|
} catch (c) {
|
|
578
|
-
n.push({ id:
|
|
582
|
+
n.push({ id: i, error: K(c) });
|
|
579
583
|
}
|
|
580
584
|
}
|
|
581
585
|
return { succeeded: t, failed: n };
|
|
582
586
|
}
|
|
583
587
|
remove(e) {
|
|
584
588
|
const t = [], n = [];
|
|
585
|
-
for (const
|
|
586
|
-
const
|
|
589
|
+
for (const o of e) {
|
|
590
|
+
const i = this.getItems(), r = i.findIndex((d) => this.getId(d) === o);
|
|
587
591
|
if (r === -1) {
|
|
588
|
-
n.push({ id:
|
|
592
|
+
n.push({ id: o, error: `Not found: ${o}` });
|
|
589
593
|
continue;
|
|
590
594
|
}
|
|
591
595
|
try {
|
|
592
|
-
const d = At(
|
|
596
|
+
const d = At(o, this.config.key, this.getBep());
|
|
593
597
|
if (d.length) throw new Error(`Referenced by: ${d.join(", ")}`);
|
|
594
|
-
this.config.beforeRemove?.(
|
|
598
|
+
this.config.beforeRemove?.(o, this.getBep()), i.splice(r, 1), t.push(o);
|
|
595
599
|
} catch (d) {
|
|
596
|
-
n.push({ id:
|
|
600
|
+
n.push({ id: o, error: K(d) });
|
|
597
601
|
}
|
|
598
602
|
}
|
|
599
603
|
return { succeeded: t, failed: n };
|
|
600
604
|
}
|
|
601
605
|
}
|
|
602
|
-
class Ot extends
|
|
606
|
+
class Ot extends w {
|
|
603
607
|
constructor(e) {
|
|
604
608
|
super(
|
|
605
609
|
() => e().actions,
|
|
@@ -609,16 +613,16 @@ class Ot extends y {
|
|
|
609
613
|
schema: ke,
|
|
610
614
|
autoId: !0,
|
|
611
615
|
beforeRemove: (t, n) => {
|
|
612
|
-
for (const
|
|
613
|
-
for (const [
|
|
616
|
+
for (const o of n.workflows)
|
|
617
|
+
for (const [i, r] of Object.entries(o.diagram.nodes))
|
|
614
618
|
if (r.type === "process" && r.actionId === t)
|
|
615
|
-
throw new Error(`Referenced by: workflows["${
|
|
619
|
+
throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].actionId`);
|
|
616
620
|
}
|
|
617
621
|
}
|
|
618
622
|
);
|
|
619
623
|
}
|
|
620
624
|
}
|
|
621
|
-
class _t extends
|
|
625
|
+
class _t extends w {
|
|
622
626
|
constructor(e) {
|
|
623
627
|
super(
|
|
624
628
|
() => e().annexes,
|
|
@@ -631,7 +635,7 @@ class _t extends y {
|
|
|
631
635
|
);
|
|
632
636
|
}
|
|
633
637
|
}
|
|
634
|
-
class Bt extends
|
|
638
|
+
class Bt extends w {
|
|
635
639
|
constructor(e) {
|
|
636
640
|
super(
|
|
637
641
|
() => e().effects,
|
|
@@ -640,20 +644,20 @@ class Bt extends y {
|
|
|
640
644
|
key: "effects",
|
|
641
645
|
schema: Re,
|
|
642
646
|
beforeRemove: (t, n) => {
|
|
643
|
-
for (const
|
|
644
|
-
for (const [
|
|
647
|
+
for (const o of n.workflows) {
|
|
648
|
+
for (const [i, r] of Object.entries(o.diagram.nodes))
|
|
645
649
|
if ((r.type === "process" || r.type === "automation") && r.timeouts?.some((d) => d.effectId === t))
|
|
646
|
-
throw new Error(`Referenced by: workflows["${
|
|
647
|
-
for (const [
|
|
650
|
+
throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].timeouts[].effectId`);
|
|
651
|
+
for (const [i, r] of Object.entries(o.diagram.edges))
|
|
648
652
|
if (r.effectIds?.includes(t))
|
|
649
|
-
throw new Error(`Referenced by: workflows["${
|
|
653
|
+
throw new Error(`Referenced by: workflows["${o.id}"].diagram.edges["${i}"].effectIds`);
|
|
650
654
|
}
|
|
651
655
|
}
|
|
652
656
|
}
|
|
653
657
|
);
|
|
654
658
|
}
|
|
655
659
|
}
|
|
656
|
-
class Mt extends
|
|
660
|
+
class Mt extends w {
|
|
657
661
|
constructor(e) {
|
|
658
662
|
super(
|
|
659
663
|
() => e().automations,
|
|
@@ -662,16 +666,16 @@ class Mt extends y {
|
|
|
662
666
|
key: "automations",
|
|
663
667
|
schema: Te,
|
|
664
668
|
beforeRemove: (t, n) => {
|
|
665
|
-
for (const
|
|
666
|
-
for (const [
|
|
669
|
+
for (const o of n.workflows)
|
|
670
|
+
for (const [i, r] of Object.entries(o.diagram.nodes))
|
|
667
671
|
if (r.type === "automation" && r.automationId === t)
|
|
668
|
-
throw new Error(`Referenced by: workflows["${
|
|
672
|
+
throw new Error(`Referenced by: workflows["${o.id}"].diagram.nodes["${i}"].automationId`);
|
|
669
673
|
}
|
|
670
674
|
}
|
|
671
675
|
);
|
|
672
676
|
}
|
|
673
677
|
}
|
|
674
|
-
class xt extends
|
|
678
|
+
class xt extends w {
|
|
675
679
|
constructor(e) {
|
|
676
680
|
super(
|
|
677
681
|
() => e().env,
|
|
@@ -684,7 +688,7 @@ class xt extends y {
|
|
|
684
688
|
);
|
|
685
689
|
}
|
|
686
690
|
}
|
|
687
|
-
class Pt extends
|
|
691
|
+
class Pt extends w {
|
|
688
692
|
constructor(e) {
|
|
689
693
|
super(
|
|
690
694
|
() => e().events,
|
|
@@ -693,10 +697,10 @@ class Pt extends y {
|
|
|
693
697
|
key: "events",
|
|
694
698
|
schema: $e,
|
|
695
699
|
beforeRemove: (t, n) => {
|
|
696
|
-
for (const
|
|
697
|
-
for (const [
|
|
700
|
+
for (const o of n.workflows)
|
|
701
|
+
for (const [i, r] of Object.entries(o.diagram.edges))
|
|
698
702
|
if ("triggerEventId" in r && r.triggerEventId === t)
|
|
699
|
-
throw new Error(`Referenced by: workflows["${
|
|
703
|
+
throw new Error(`Referenced by: workflows["${o.id}"].diagram.edges["${i}"].trigger`);
|
|
700
704
|
}
|
|
701
705
|
}
|
|
702
706
|
);
|
|
@@ -709,7 +713,7 @@ function C(s) {
|
|
|
709
713
|
e.set(n, t.id);
|
|
710
714
|
return e;
|
|
711
715
|
}
|
|
712
|
-
function
|
|
716
|
+
function se(s) {
|
|
713
717
|
const e = /* @__PURE__ */ new Set();
|
|
714
718
|
for (const t of s)
|
|
715
719
|
for (const n of t.lbsNodeIds ?? []) e.add(n);
|
|
@@ -717,22 +721,22 @@ function te(s) {
|
|
|
717
721
|
}
|
|
718
722
|
function Je(s, e) {
|
|
719
723
|
if (!s) return { zoneCode: "XXX", locationCode: "XXX" };
|
|
720
|
-
const t = new Map(e.map((d) => [d.id, d])), n = C(e),
|
|
721
|
-
if (!
|
|
722
|
-
if (
|
|
723
|
-
if (
|
|
724
|
-
let r = n.get(
|
|
724
|
+
const t = new Map(e.map((d) => [d.id, d])), n = C(e), o = se(e), i = t.get(s);
|
|
725
|
+
if (!i) return { zoneCode: "XXX", locationCode: "XXX" };
|
|
726
|
+
if (o.has(i.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
|
|
727
|
+
if (i.type === "zone") return { zoneCode: i.id, locationCode: "ZZZ" };
|
|
728
|
+
let r = n.get(i.id);
|
|
725
729
|
for (; r; ) {
|
|
726
730
|
const d = t.get(r);
|
|
727
731
|
if (!d) break;
|
|
728
|
-
if (d.type === "zone" && !
|
|
729
|
-
return { zoneCode: d.id, locationCode:
|
|
732
|
+
if (d.type === "zone" && !o.has(d.id))
|
|
733
|
+
return { zoneCode: d.id, locationCode: i.id };
|
|
730
734
|
r = n.get(r);
|
|
731
735
|
}
|
|
732
|
-
return { zoneCode: "ZZZ", locationCode:
|
|
736
|
+
return { zoneCode: "ZZZ", locationCode: i.id };
|
|
733
737
|
}
|
|
734
738
|
function Ft(s) {
|
|
735
|
-
const e = [], t = new Map(s.map((d) => [d.id, d])), n =
|
|
739
|
+
const e = [], t = new Map(s.map((d) => [d.id, d])), n = se(s);
|
|
736
740
|
for (const d of n) {
|
|
737
741
|
const l = t.get(d);
|
|
738
742
|
l && l.type !== "zone" && e.push(`Root node "${d}" must be of type "zone".`);
|
|
@@ -741,36 +745,36 @@ function Ft(s) {
|
|
|
741
745
|
if (d.type === "location")
|
|
742
746
|
for (const l of d.lbsNodeIds ?? [])
|
|
743
747
|
t.get(l)?.type === "zone" && e.push(`Node "${d.id}" (location) cannot have a zone child ("${l}").`);
|
|
744
|
-
const
|
|
748
|
+
const o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
745
749
|
function r(d) {
|
|
746
|
-
if (
|
|
747
|
-
if (
|
|
748
|
-
|
|
750
|
+
if (i.has(d)) return !0;
|
|
751
|
+
if (o.has(d)) return !1;
|
|
752
|
+
o.add(d), i.add(d);
|
|
749
753
|
for (const l of t.get(d)?.lbsNodeIds ?? [])
|
|
750
754
|
if (r(l))
|
|
751
755
|
return e.push(`Cycle detected in LBS tree at node "${d}".`), !0;
|
|
752
|
-
return
|
|
756
|
+
return i.delete(d), !1;
|
|
753
757
|
}
|
|
754
758
|
for (const d of s)
|
|
755
|
-
|
|
759
|
+
o.has(d.id) || r(d.id);
|
|
756
760
|
return e;
|
|
757
761
|
}
|
|
758
|
-
function
|
|
762
|
+
function X(s) {
|
|
759
763
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
760
764
|
for (const n of s) {
|
|
761
|
-
const
|
|
762
|
-
t.set(n.responsibleId,
|
|
765
|
+
const o = (t.get(n.responsibleId) ?? 0) + 1;
|
|
766
|
+
t.set(n.responsibleId, o), e.set(n.id, o);
|
|
763
767
|
}
|
|
764
768
|
return e;
|
|
765
769
|
}
|
|
766
770
|
const F = "XXX";
|
|
767
|
-
function Ke(s, e, t, n,
|
|
768
|
-
const { zoneCode:
|
|
769
|
-
if (!
|
|
771
|
+
function Ke(s, e, t, n, o) {
|
|
772
|
+
const { zoneCode: i, locationCode: r } = Je(s.lbsNodeId, n);
|
|
773
|
+
if (!o) {
|
|
770
774
|
const l = String(t.get(s.id) ?? 0).padStart(3, "0");
|
|
771
|
-
return [e, s.responsibleId,
|
|
775
|
+
return [e, s.responsibleId, i, r, s.assetTypeId, s.disciplineId, l].join("-");
|
|
772
776
|
}
|
|
773
|
-
return
|
|
777
|
+
return o.segments.map((l) => {
|
|
774
778
|
if (l.type === "sequence") {
|
|
775
779
|
const c = l.padding ?? 3;
|
|
776
780
|
return String(t.get(s.id) ?? 0).padStart(c, "0");
|
|
@@ -785,17 +789,17 @@ function Ke(s, e, t, n, i) {
|
|
|
785
789
|
case "assetType":
|
|
786
790
|
return s.assetTypeId || F;
|
|
787
791
|
case "lbsZone":
|
|
788
|
-
return
|
|
792
|
+
return i;
|
|
789
793
|
case "lbsLocation":
|
|
790
794
|
return r;
|
|
791
795
|
}
|
|
792
|
-
}).join(
|
|
796
|
+
}).join(o.delimiter);
|
|
793
797
|
}
|
|
794
798
|
function qe(s, e, t, n) {
|
|
795
|
-
const
|
|
796
|
-
return new Map(s.map((
|
|
797
|
-
|
|
798
|
-
Ke(
|
|
799
|
+
const o = X(s);
|
|
800
|
+
return new Map(s.map((i) => [
|
|
801
|
+
i.id,
|
|
802
|
+
Ke(i, e, o, t, n)
|
|
799
803
|
]));
|
|
800
804
|
}
|
|
801
805
|
class Ct {
|
|
@@ -805,17 +809,17 @@ class Ct {
|
|
|
805
809
|
getBep;
|
|
806
810
|
/** Maps every deliverable id to its sequence number within its originator team. */
|
|
807
811
|
buildConsecutivoMap() {
|
|
808
|
-
return
|
|
812
|
+
return X(this.getBep().deliverables);
|
|
809
813
|
}
|
|
810
814
|
/**
|
|
811
815
|
* Returns the nomenclature code for a single deliverable.
|
|
812
816
|
* Returns null if the deliverable id is not found.
|
|
813
817
|
*/
|
|
814
818
|
getCode(e) {
|
|
815
|
-
const t = this.getBep(), n = t.deliverables.find((
|
|
819
|
+
const t = this.getBep(), n = t.deliverables.find((i) => i.id === e);
|
|
816
820
|
if (!n) return null;
|
|
817
|
-
const
|
|
818
|
-
return Ke(n, t.project.code,
|
|
821
|
+
const o = X(t.deliverables);
|
|
822
|
+
return Ke(n, t.project.code, o, t.lbs, t.deliverableNamingConvention);
|
|
819
823
|
}
|
|
820
824
|
/** Builds the complete map of deliverable.id → nomenclature code. */
|
|
821
825
|
buildCodeMap() {
|
|
@@ -823,8 +827,8 @@ class Ct {
|
|
|
823
827
|
return qe(e.deliverables, e.project.code, e.lbs, e.deliverableNamingConvention);
|
|
824
828
|
}
|
|
825
829
|
}
|
|
826
|
-
class Dt extends
|
|
827
|
-
constructor(e, t, n,
|
|
830
|
+
class Dt extends w {
|
|
831
|
+
constructor(e, t, n, o, i) {
|
|
828
832
|
super(
|
|
829
833
|
() => e().deliverables,
|
|
830
834
|
e,
|
|
@@ -833,23 +837,23 @@ class Dt extends y {
|
|
|
833
837
|
schema: De,
|
|
834
838
|
autoId: !0
|
|
835
839
|
}
|
|
836
|
-
), this.getTeams = t, this.getAssetTypes = n, this.getLBSNodes =
|
|
840
|
+
), this.getTeams = t, this.getAssetTypes = n, this.getLBSNodes = o, this.getMilestones = i;
|
|
837
841
|
}
|
|
838
842
|
getTeams;
|
|
839
843
|
getAssetTypes;
|
|
840
844
|
getLBSNodes;
|
|
841
845
|
getMilestones;
|
|
842
846
|
listResolved() {
|
|
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])),
|
|
847
|
+
const e = this.getBep(), t = qe(e.deliverables, e.project.code, e.lbs), n = new Map(this.getTeams().listResolved().map((l) => [l.id, l])), o = new Map(this.getAssetTypes().listResolved().map((l) => [l.id, l])), i = 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();
|
|
844
848
|
for (const l of e.deliverables) {
|
|
845
849
|
const c = r.get(l.milestoneId) ?? null;
|
|
846
850
|
d.set(l.id, {
|
|
847
851
|
...l,
|
|
848
852
|
nomenclatureCode: t.get(l.id) ?? "",
|
|
849
853
|
effectiveDate: l.dueDate ?? c?.date ?? "",
|
|
850
|
-
lbsNode: l.lbsNodeId ?
|
|
854
|
+
lbsNode: l.lbsNodeId ? i.get(l.lbsNodeId) ?? null : null,
|
|
851
855
|
discipline: e.disciplines.find((u) => u.id === l.disciplineId) ?? null,
|
|
852
|
-
assetType:
|
|
856
|
+
assetType: o.get(l.assetTypeId) ?? null,
|
|
853
857
|
extensions: (l.extensionIds ?? []).map((u) => e.extensions.find((f) => f.id === u)).filter(Boolean),
|
|
854
858
|
responsible: n.get(l.responsibleId) ?? null,
|
|
855
859
|
milestone: c,
|
|
@@ -864,7 +868,7 @@ class Dt extends y {
|
|
|
864
868
|
return [...d.values()];
|
|
865
869
|
}
|
|
866
870
|
}
|
|
867
|
-
class Lt extends
|
|
871
|
+
class Lt extends w {
|
|
868
872
|
constructor(e) {
|
|
869
873
|
super(
|
|
870
874
|
() => e().flags,
|
|
@@ -877,7 +881,7 @@ class Lt extends y {
|
|
|
877
881
|
);
|
|
878
882
|
}
|
|
879
883
|
}
|
|
880
|
-
class Ut extends
|
|
884
|
+
class Ut extends w {
|
|
881
885
|
constructor(e, t) {
|
|
882
886
|
super(
|
|
883
887
|
() => e().notes,
|
|
@@ -898,7 +902,7 @@ class Ut extends y {
|
|
|
898
902
|
}));
|
|
899
903
|
}
|
|
900
904
|
}
|
|
901
|
-
class zt extends
|
|
905
|
+
class zt extends w {
|
|
902
906
|
constructor(e, t) {
|
|
903
907
|
super(
|
|
904
908
|
() => e().bimUses,
|
|
@@ -907,15 +911,15 @@ class zt extends y {
|
|
|
907
911
|
key: "bimUses",
|
|
908
912
|
schema: Se,
|
|
909
913
|
autoId: !0,
|
|
910
|
-
validate: (n,
|
|
911
|
-
const
|
|
914
|
+
validate: (n, o) => {
|
|
915
|
+
const i = [];
|
|
912
916
|
for (const r of n.objectiveIds ?? [])
|
|
913
|
-
|
|
917
|
+
o.objectives.some((d) => d.id === r) || i.push(`objectives["${r}"] not found`);
|
|
914
918
|
for (const r of n.milestoneIds ?? [])
|
|
915
|
-
|
|
919
|
+
o.milestones.some((d) => d.id === r) || i.push(`milestones["${r}"] not found`);
|
|
916
920
|
for (const r of n.workflowIds ?? [])
|
|
917
|
-
|
|
918
|
-
return
|
|
921
|
+
o.workflows.some((d) => d.id === r) || i.push(`workflows["${r}"] not found`);
|
|
922
|
+
return i;
|
|
919
923
|
}
|
|
920
924
|
}
|
|
921
925
|
), this.getWorkflows = t;
|
|
@@ -925,32 +929,32 @@ class zt extends y {
|
|
|
925
929
|
const e = this.getBep(), t = new Map(this.getWorkflows().listResolved().map((n) => [n.id, n]));
|
|
926
930
|
return e.bimUses.map((n) => ({
|
|
927
931
|
...n,
|
|
928
|
-
objectives: (n.objectiveIds ?? []).map((
|
|
929
|
-
milestones: (n.milestoneIds ?? []).map((
|
|
930
|
-
const
|
|
931
|
-
return
|
|
932
|
+
objectives: (n.objectiveIds ?? []).map((o) => e.objectives.find((i) => i.id === o)).filter(Boolean),
|
|
933
|
+
milestones: (n.milestoneIds ?? []).map((o) => {
|
|
934
|
+
const i = e.milestones.find((r) => r.id === o);
|
|
935
|
+
return i ? { ...i, phase: e.phases.find((r) => r.id === i.phaseId) ?? null } : null;
|
|
932
936
|
}).filter(Boolean),
|
|
933
|
-
workflows: (n.workflowIds ?? []).map((
|
|
937
|
+
workflows: (n.workflowIds ?? []).map((o) => t.get(o)).filter(Boolean)
|
|
934
938
|
}));
|
|
935
939
|
}
|
|
936
940
|
}
|
|
937
|
-
class Zt extends
|
|
941
|
+
class Zt extends w {
|
|
938
942
|
constructor(e) {
|
|
939
943
|
super(
|
|
940
944
|
() => e().disciplines,
|
|
941
945
|
e,
|
|
942
946
|
{
|
|
943
947
|
key: "disciplines",
|
|
944
|
-
schema:
|
|
948
|
+
schema: be,
|
|
945
949
|
validate: (t, n) => {
|
|
946
|
-
const
|
|
947
|
-
return
|
|
950
|
+
const o = x("discipline", t.id, n.deliverableNamingConvention);
|
|
951
|
+
return o ? [o] : [];
|
|
948
952
|
}
|
|
949
953
|
}
|
|
950
954
|
);
|
|
951
955
|
}
|
|
952
956
|
}
|
|
953
|
-
class Jt extends
|
|
957
|
+
class Jt extends w {
|
|
954
958
|
constructor(e) {
|
|
955
959
|
super(
|
|
956
960
|
() => e().guides,
|
|
@@ -966,11 +970,11 @@ class Jt extends y {
|
|
|
966
970
|
const e = this.getBep();
|
|
967
971
|
return e.guides.map((t) => ({
|
|
968
972
|
...t,
|
|
969
|
-
annexes: (t.annexIds ?? []).map((n) => e.annexes.find((
|
|
973
|
+
annexes: (t.annexIds ?? []).map((n) => e.annexes.find((o) => o.id === n)).filter(Boolean)
|
|
970
974
|
}));
|
|
971
975
|
}
|
|
972
976
|
}
|
|
973
|
-
class Kt extends
|
|
977
|
+
class Kt extends w {
|
|
974
978
|
constructor(e) {
|
|
975
979
|
super(
|
|
976
980
|
() => e().lods,
|
|
@@ -979,14 +983,14 @@ class Kt extends y {
|
|
|
979
983
|
key: "lods",
|
|
980
984
|
schema: Me,
|
|
981
985
|
beforeRemove: (t, n) => {
|
|
982
|
-
for (const
|
|
983
|
-
if (
|
|
986
|
+
for (const o of n.loin)
|
|
987
|
+
if (o.milestones?.find((r) => r.lodId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[lodId=${t}]`);
|
|
984
988
|
}
|
|
985
989
|
}
|
|
986
990
|
);
|
|
987
991
|
}
|
|
988
992
|
}
|
|
989
|
-
class qt extends
|
|
993
|
+
class qt extends w {
|
|
990
994
|
constructor(e) {
|
|
991
995
|
super(
|
|
992
996
|
() => e().lois,
|
|
@@ -995,14 +999,14 @@ class qt extends y {
|
|
|
995
999
|
key: "lois",
|
|
996
1000
|
schema: xe,
|
|
997
1001
|
beforeRemove: (t, n) => {
|
|
998
|
-
for (const
|
|
999
|
-
if (
|
|
1002
|
+
for (const o of n.loin)
|
|
1003
|
+
if (o.milestones?.find((r) => r.loiId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[loiId=${t}]`);
|
|
1000
1004
|
}
|
|
1001
1005
|
}
|
|
1002
1006
|
);
|
|
1003
1007
|
}
|
|
1004
1008
|
}
|
|
1005
|
-
class Wt extends
|
|
1009
|
+
class Wt extends w {
|
|
1006
1010
|
constructor(e) {
|
|
1007
1011
|
super(
|
|
1008
1012
|
() => e().loin,
|
|
@@ -1012,62 +1016,62 @@ class Wt extends y {
|
|
|
1012
1016
|
schema: Pe,
|
|
1013
1017
|
autoId: !0,
|
|
1014
1018
|
validate: (t, n) => {
|
|
1015
|
-
const
|
|
1016
|
-
for (const
|
|
1017
|
-
n.milestones.some((r) => r.id ===
|
|
1018
|
-
return
|
|
1019
|
+
const o = [];
|
|
1020
|
+
for (const i of t.milestones ?? [])
|
|
1021
|
+
n.milestones.some((r) => r.id === i.milestoneId) || o.push(`milestones["${i.milestoneId}"] not found`), n.lods.some((r) => r.id === i.lodId) || o.push(`lods[${i.lodId}] not found`), n.lois.some((r) => r.id === i.loiId) || o.push(`lois[${i.loiId}] not found`);
|
|
1022
|
+
return o;
|
|
1019
1023
|
}
|
|
1020
1024
|
}
|
|
1021
1025
|
);
|
|
1022
1026
|
}
|
|
1023
1027
|
addMilestones(e) {
|
|
1024
1028
|
const t = [], n = [];
|
|
1025
|
-
for (const
|
|
1026
|
-
const
|
|
1027
|
-
if (!
|
|
1028
|
-
n.push({ loinId:
|
|
1029
|
+
for (const o of e) {
|
|
1030
|
+
const i = this.getBep().loin.find((c) => c.id === o.loinId);
|
|
1031
|
+
if (!i) {
|
|
1032
|
+
n.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
|
|
1029
1033
|
continue;
|
|
1030
1034
|
}
|
|
1031
|
-
const r =
|
|
1035
|
+
const r = o.milestones.find((c) => (i.milestones ?? []).some((u) => u.milestoneId === c.milestoneId));
|
|
1032
1036
|
if (r) {
|
|
1033
|
-
n.push({ loinId:
|
|
1037
|
+
n.push({ loinId: o.loinId, error: `Milestone "${r.milestoneId}" already exists. Use updateMilestones to modify it.` });
|
|
1034
1038
|
continue;
|
|
1035
1039
|
}
|
|
1036
|
-
const d = [...
|
|
1040
|
+
const d = [...i.milestones ?? [], ...o.milestones], l = this.update([{ id: o.loinId, milestones: d }]);
|
|
1037
1041
|
if (l.failed.length > 0) {
|
|
1038
|
-
n.push({ loinId:
|
|
1042
|
+
n.push({ loinId: o.loinId, error: l.failed[0].error });
|
|
1039
1043
|
continue;
|
|
1040
1044
|
}
|
|
1041
|
-
t.push({ loinId:
|
|
1045
|
+
t.push({ loinId: o.loinId, element: i.element, addedMilestones: o.milestones.map((c) => c.milestoneId) });
|
|
1042
1046
|
}
|
|
1043
1047
|
return { succeeded: t, failed: n };
|
|
1044
1048
|
}
|
|
1045
1049
|
updateMilestones(e) {
|
|
1046
1050
|
const t = [], n = [];
|
|
1047
|
-
for (const
|
|
1048
|
-
const
|
|
1049
|
-
if (!
|
|
1050
|
-
n.push({ loinId:
|
|
1051
|
+
for (const o of e) {
|
|
1052
|
+
const i = this.getBep().loin.find((f) => f.id === o.loinId);
|
|
1053
|
+
if (!i) {
|
|
1054
|
+
n.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
|
|
1051
1055
|
continue;
|
|
1052
1056
|
}
|
|
1053
|
-
const r =
|
|
1057
|
+
const r = o.milestones.find((f) => !(i.milestones ?? []).some((m) => m.milestoneId === f.milestoneId));
|
|
1054
1058
|
if (r) {
|
|
1055
|
-
n.push({ loinId:
|
|
1059
|
+
n.push({ loinId: o.loinId, error: `Milestone "${r.milestoneId}" not found. Use addMilestones to create it.` });
|
|
1056
1060
|
continue;
|
|
1057
1061
|
}
|
|
1058
|
-
const d = new Map(
|
|
1059
|
-
const m =
|
|
1062
|
+
const d = new Map(i.milestones.map((f) => [f.milestoneId, { lodId: f.lodId, loiId: f.loiId, idsPath: f.idsPath }])), l = (i.milestones ?? []).map((f) => {
|
|
1063
|
+
const m = o.milestones.find((p) => p.milestoneId === f.milestoneId);
|
|
1060
1064
|
return m ? { ...f, ...m } : f;
|
|
1061
|
-
}), c = this.update([{ id:
|
|
1065
|
+
}), c = this.update([{ id: o.loinId, milestones: l }]);
|
|
1062
1066
|
if (c.failed.length > 0) {
|
|
1063
|
-
n.push({ loinId:
|
|
1067
|
+
n.push({ loinId: o.loinId, error: c.failed[0].error });
|
|
1064
1068
|
continue;
|
|
1065
1069
|
}
|
|
1066
|
-
const u = this.getBep().loin.find((f) => f.id ===
|
|
1070
|
+
const u = this.getBep().loin.find((f) => f.id === o.loinId);
|
|
1067
1071
|
t.push({
|
|
1068
|
-
loinId:
|
|
1069
|
-
element:
|
|
1070
|
-
milestones:
|
|
1072
|
+
loinId: o.loinId,
|
|
1073
|
+
element: i.element,
|
|
1074
|
+
milestones: o.milestones.map((f) => {
|
|
1071
1075
|
const m = u.milestones.find((g) => g.milestoneId === f.milestoneId), p = d.get(f.milestoneId);
|
|
1072
1076
|
return { milestoneId: f.milestoneId, before: p, after: { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath } };
|
|
1073
1077
|
})
|
|
@@ -1077,18 +1081,18 @@ class Wt extends y {
|
|
|
1077
1081
|
}
|
|
1078
1082
|
removeMilestones(e) {
|
|
1079
1083
|
const t = [], n = [];
|
|
1080
|
-
for (const
|
|
1081
|
-
const
|
|
1082
|
-
if (!
|
|
1083
|
-
n.push({ loinId:
|
|
1084
|
+
for (const o of e) {
|
|
1085
|
+
const i = this.getBep().loin.find((d) => d.id === o.loinId);
|
|
1086
|
+
if (!i) {
|
|
1087
|
+
n.push({ loinId: o.loinId, error: `Not found: ${o.loinId}` });
|
|
1084
1088
|
continue;
|
|
1085
1089
|
}
|
|
1086
|
-
const r =
|
|
1090
|
+
const r = o.milestoneIds.filter((d) => !(i.milestones ?? []).some((l) => l.milestoneId === d));
|
|
1087
1091
|
if (r.length > 0) {
|
|
1088
|
-
n.push({ loinId:
|
|
1092
|
+
n.push({ loinId: o.loinId, error: `Milestones not found in this LOIN: ${r.join(", ")}` });
|
|
1089
1093
|
continue;
|
|
1090
1094
|
}
|
|
1091
|
-
|
|
1095
|
+
i.milestones = (i.milestones ?? []).filter((d) => !o.milestoneIds.includes(d.milestoneId)), t.push({ loinId: o.loinId, element: i.element, removedMilestones: o.milestoneIds });
|
|
1092
1096
|
}
|
|
1093
1097
|
return { succeeded: t, failed: n };
|
|
1094
1098
|
}
|
|
@@ -1099,14 +1103,14 @@ class Wt extends y {
|
|
|
1099
1103
|
discipline: e.disciplines.find((n) => n.id === t.disciplineId) ?? null,
|
|
1100
1104
|
milestones: (t.milestones ?? []).map((n) => ({
|
|
1101
1105
|
...n,
|
|
1102
|
-
milestone: e.milestones.find((
|
|
1103
|
-
lod: e.lods.find((
|
|
1104
|
-
loi: e.lois.find((
|
|
1106
|
+
milestone: e.milestones.find((o) => o.id === n.milestoneId) ?? null,
|
|
1107
|
+
lod: e.lods.find((o) => o.id === n.lodId) ?? null,
|
|
1108
|
+
loi: e.lois.find((o) => o.id === n.loiId) ?? null
|
|
1105
1109
|
}))
|
|
1106
1110
|
}));
|
|
1107
1111
|
}
|
|
1108
1112
|
}
|
|
1109
|
-
class
|
|
1113
|
+
class Xt extends w {
|
|
1110
1114
|
constructor(e) {
|
|
1111
1115
|
super(
|
|
1112
1116
|
() => e().assetTypes,
|
|
@@ -1115,8 +1119,8 @@ class Gt extends y {
|
|
|
1115
1119
|
key: "assetTypes",
|
|
1116
1120
|
schema: Ie,
|
|
1117
1121
|
validate: (t, n) => {
|
|
1118
|
-
const
|
|
1119
|
-
return
|
|
1122
|
+
const o = x("assetType", t.id, n.deliverableNamingConvention);
|
|
1123
|
+
return o ? [o] : [];
|
|
1120
1124
|
}
|
|
1121
1125
|
}
|
|
1122
1126
|
);
|
|
@@ -1125,11 +1129,11 @@ class Gt extends y {
|
|
|
1125
1129
|
const e = this.getBep();
|
|
1126
1130
|
return e.assetTypes.map((t) => ({
|
|
1127
1131
|
...t,
|
|
1128
|
-
extensions: (t.extensionIds ?? []).map((n) => e.extensions.find((
|
|
1132
|
+
extensions: (t.extensionIds ?? []).map((n) => e.extensions.find((o) => o.id === n)).filter(Boolean)
|
|
1129
1133
|
}));
|
|
1130
1134
|
}
|
|
1131
1135
|
}
|
|
1132
|
-
class
|
|
1136
|
+
class Gt extends w {
|
|
1133
1137
|
constructor(e) {
|
|
1134
1138
|
super(
|
|
1135
1139
|
() => e().extensions,
|
|
@@ -1141,7 +1145,7 @@ class Xt extends y {
|
|
|
1141
1145
|
);
|
|
1142
1146
|
}
|
|
1143
1147
|
}
|
|
1144
|
-
class Vt extends
|
|
1148
|
+
class Vt extends w {
|
|
1145
1149
|
constructor(e) {
|
|
1146
1150
|
super(
|
|
1147
1151
|
() => e().roles,
|
|
@@ -1151,120 +1155,120 @@ class Vt extends y {
|
|
|
1151
1155
|
schema: ue,
|
|
1152
1156
|
autoId: !0,
|
|
1153
1157
|
beforeRemove: (t, n) => {
|
|
1154
|
-
const
|
|
1155
|
-
for (const
|
|
1156
|
-
for (const [r, d] of Object.entries(
|
|
1158
|
+
const o = ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"];
|
|
1159
|
+
for (const i of n.workflows)
|
|
1160
|
+
for (const [r, d] of Object.entries(i.diagram.nodes))
|
|
1157
1161
|
if (d.type === "process") {
|
|
1158
|
-
for (const l of
|
|
1162
|
+
for (const l of o)
|
|
1159
1163
|
if (d[l]?.includes(t))
|
|
1160
|
-
throw new Error(`Referenced by: workflows["${
|
|
1164
|
+
throw new Error(`Referenced by: workflows["${i.id}"].diagram.nodes["${r}"].${l}`);
|
|
1161
1165
|
}
|
|
1162
1166
|
}
|
|
1163
1167
|
}
|
|
1164
1168
|
);
|
|
1165
1169
|
}
|
|
1166
1170
|
}
|
|
1167
|
-
class Ht extends
|
|
1171
|
+
class Ht extends w {
|
|
1168
1172
|
constructor(e) {
|
|
1169
1173
|
super(
|
|
1170
1174
|
() => e().lbs,
|
|
1171
1175
|
e,
|
|
1172
1176
|
{
|
|
1173
1177
|
key: "lbs",
|
|
1174
|
-
schema:
|
|
1178
|
+
schema: we,
|
|
1175
1179
|
validate: (t, n) => {
|
|
1176
|
-
const
|
|
1177
|
-
if (r &&
|
|
1180
|
+
const o = [], i = t.type === "zone" ? "lbsZone" : "lbsLocation", r = x(i, t.id, n.deliverableNamingConvention);
|
|
1181
|
+
if (r && o.push(r), t.type === "location" && t.lbsNodeIds?.length) {
|
|
1178
1182
|
const d = new Map(n.lbs.map((l) => [l.id, l]));
|
|
1179
1183
|
for (const l of t.lbsNodeIds ?? [])
|
|
1180
|
-
d.get(l)?.type === "zone" &&
|
|
1184
|
+
d.get(l)?.type === "zone" && o.push(`Node "${t.id}" (location) cannot have a zone child ("${l}").`);
|
|
1181
1185
|
}
|
|
1182
|
-
return
|
|
1186
|
+
return o;
|
|
1183
1187
|
}
|
|
1184
1188
|
}
|
|
1185
1189
|
);
|
|
1186
1190
|
}
|
|
1187
1191
|
listResolved() {
|
|
1188
|
-
const e = this.getBep(), t = C(e.lbs), n =
|
|
1189
|
-
return e.lbs.map((
|
|
1190
|
-
const r = t.get(
|
|
1192
|
+
const e = this.getBep(), t = C(e.lbs), n = se(e.lbs), o = new Map(e.lbs.map((i) => [i.id, i]));
|
|
1193
|
+
return e.lbs.map((i) => {
|
|
1194
|
+
const r = t.get(i.id), d = r ? o.get(r) : void 0;
|
|
1191
1195
|
return {
|
|
1192
|
-
...
|
|
1193
|
-
isRoot: n.has(
|
|
1196
|
+
...i,
|
|
1197
|
+
isRoot: n.has(i.id),
|
|
1194
1198
|
parent: d ? { id: d.id, name: d.name, type: d.type } : null,
|
|
1195
|
-
children: (
|
|
1199
|
+
children: (i.lbsNodeIds ?? []).map((l) => o.get(l)).filter(Boolean)
|
|
1196
1200
|
};
|
|
1197
1201
|
});
|
|
1198
1202
|
}
|
|
1199
1203
|
addNodes(e) {
|
|
1200
|
-
const t = this.getBep(), n = [],
|
|
1201
|
-
for (const
|
|
1202
|
-
if (!
|
|
1203
|
-
|
|
1204
|
+
const t = this.getBep(), n = [], o = [];
|
|
1205
|
+
for (const i of e) {
|
|
1206
|
+
if (!i.parentId && i.type !== "zone") {
|
|
1207
|
+
o.push({ input: i, error: 'Root nodes (no parentId) must be type "zone".' });
|
|
1204
1208
|
continue;
|
|
1205
1209
|
}
|
|
1206
|
-
if (
|
|
1207
|
-
|
|
1210
|
+
if (i.parentId && !t.lbs.find((f) => f.id === i.parentId)) {
|
|
1211
|
+
o.push({ input: i, error: `No LBS node found with ID "${i.parentId}".` });
|
|
1208
1212
|
continue;
|
|
1209
1213
|
}
|
|
1210
|
-
const { parentId: r, ...d } =
|
|
1214
|
+
const { parentId: r, ...d } = i, l = this.add([d]);
|
|
1211
1215
|
if (l.failed.length > 0) {
|
|
1212
|
-
|
|
1216
|
+
o.push({ input: i, error: l.failed[0].error });
|
|
1213
1217
|
continue;
|
|
1214
1218
|
}
|
|
1215
1219
|
let c;
|
|
1216
|
-
r && (c = t.lbs.find((f) => f.id === r), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(
|
|
1220
|
+
r && (c = t.lbs.find((f) => f.id === r), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(i.id)));
|
|
1217
1221
|
const u = this.validateTree();
|
|
1218
1222
|
if (u.length > 0) {
|
|
1219
|
-
t.lbs.splice(t.lbs.findIndex((f) => f.id ===
|
|
1223
|
+
t.lbs.splice(t.lbs.findIndex((f) => f.id === i.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((f) => f !== i.id)), o.push({ input: i, error: u.join("; ") });
|
|
1220
1224
|
continue;
|
|
1221
1225
|
}
|
|
1222
|
-
n.push({ ...t.lbs.find((f) => f.id ===
|
|
1226
|
+
n.push({ ...t.lbs.find((f) => f.id === i.id), parentId: r ?? null });
|
|
1223
1227
|
}
|
|
1224
|
-
return { succeeded: n, failed:
|
|
1228
|
+
return { succeeded: n, failed: o };
|
|
1225
1229
|
}
|
|
1226
1230
|
updateNodes(e) {
|
|
1227
|
-
const t = this.getBep(), n = [],
|
|
1228
|
-
for (const
|
|
1229
|
-
if (
|
|
1230
|
-
|
|
1231
|
+
const t = this.getBep(), n = [], o = [];
|
|
1232
|
+
for (const i of e) {
|
|
1233
|
+
if (i.parentId && !t.lbs.find((h) => h.id === i.parentId)) {
|
|
1234
|
+
o.push({ id: i.id, error: `No LBS node found with ID "${i.parentId}".` });
|
|
1231
1235
|
continue;
|
|
1232
1236
|
}
|
|
1233
|
-
if (
|
|
1234
|
-
|
|
1237
|
+
if (i.parentId === i.id) {
|
|
1238
|
+
o.push({ id: i.id, error: "A node cannot be its own parent." });
|
|
1235
1239
|
continue;
|
|
1236
1240
|
}
|
|
1237
|
-
const r = t.lbs.find((h) => h.id ===
|
|
1241
|
+
const r = t.lbs.find((h) => h.id === i.id), d = C(t.lbs).get(i.id) ?? null, { parentId: l, ...c } = i, u = this.update([c]);
|
|
1238
1242
|
if (u.failed.length > 0) {
|
|
1239
|
-
|
|
1243
|
+
o.push({ id: i.id, error: u.failed[0].error });
|
|
1240
1244
|
continue;
|
|
1241
1245
|
}
|
|
1242
|
-
const f = { name: r.name, type: r.type, description: r.description, parentId: d }, m = t.lbs.find((h) => h.id ===
|
|
1246
|
+
const f = { name: r.name, type: r.type, description: r.description, parentId: d }, m = t.lbs.find((h) => h.id === i.id);
|
|
1243
1247
|
if (l !== void 0) {
|
|
1244
1248
|
for (const h of t.lbs)
|
|
1245
|
-
h.lbsNodeIds?.includes(
|
|
1249
|
+
h.lbsNodeIds?.includes(i.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((y) => y !== i.id));
|
|
1246
1250
|
if (l) {
|
|
1247
|
-
const h = t.lbs.find((
|
|
1248
|
-
h.lbsNodeIds ??= [], h.lbsNodeIds.push(
|
|
1251
|
+
const h = t.lbs.find((y) => y.id === l);
|
|
1252
|
+
h.lbsNodeIds ??= [], h.lbsNodeIds.push(i.id);
|
|
1249
1253
|
}
|
|
1250
1254
|
}
|
|
1251
1255
|
const p = this.validateTree();
|
|
1252
1256
|
if (p.length > 0) {
|
|
1253
1257
|
if (m.name = f.name, m.type = f.type, f.description !== void 0 ? m.description = f.description : delete m.description, l !== void 0) {
|
|
1254
1258
|
for (const h of t.lbs)
|
|
1255
|
-
h.lbsNodeIds?.includes(
|
|
1259
|
+
h.lbsNodeIds?.includes(i.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((y) => y !== i.id));
|
|
1256
1260
|
if (f.parentId) {
|
|
1257
|
-
const h = t.lbs.find((
|
|
1258
|
-
h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(
|
|
1261
|
+
const h = t.lbs.find((y) => y.id === f.parentId);
|
|
1262
|
+
h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(i.id));
|
|
1259
1263
|
}
|
|
1260
1264
|
}
|
|
1261
|
-
|
|
1265
|
+
o.push({ id: i.id, error: p.join("; ") });
|
|
1262
1266
|
continue;
|
|
1263
1267
|
}
|
|
1264
1268
|
const g = C(t.lbs).get(m.id) ?? null;
|
|
1265
|
-
n.push({ id:
|
|
1269
|
+
n.push({ id: i.id, before: f, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
|
|
1266
1270
|
}
|
|
1267
|
-
return { succeeded: n, failed:
|
|
1271
|
+
return { succeeded: n, failed: o };
|
|
1268
1272
|
}
|
|
1269
1273
|
/** Resolves zone and location codes for nomenclature given a node id. */
|
|
1270
1274
|
resolveCodes(e) {
|
|
@@ -1275,7 +1279,7 @@ class Ht extends y {
|
|
|
1275
1279
|
return Ft(this.list());
|
|
1276
1280
|
}
|
|
1277
1281
|
}
|
|
1278
|
-
class Yt extends
|
|
1282
|
+
class Yt extends w {
|
|
1279
1283
|
constructor(e) {
|
|
1280
1284
|
super(
|
|
1281
1285
|
() => e().members,
|
|
@@ -1290,10 +1294,10 @@ class Yt extends y {
|
|
|
1290
1294
|
listResolved() {
|
|
1291
1295
|
const e = this.getBep();
|
|
1292
1296
|
return e.members.map((t) => {
|
|
1293
|
-
const n = e.teams.find((
|
|
1297
|
+
const n = e.teams.find((o) => (o.memberEmails ?? []).includes(t.email));
|
|
1294
1298
|
return {
|
|
1295
1299
|
...t,
|
|
1296
|
-
role: e.roles.find((
|
|
1300
|
+
role: e.roles.find((o) => o.id === t.roleId) ?? null,
|
|
1297
1301
|
team: n ? { id: n.id, name: n.name } : null,
|
|
1298
1302
|
isRepresentative: n?.representativeEmail === t.email
|
|
1299
1303
|
};
|
|
@@ -1301,66 +1305,66 @@ class Yt extends y {
|
|
|
1301
1305
|
}
|
|
1302
1306
|
addToTeam(e) {
|
|
1303
1307
|
const t = [], n = [];
|
|
1304
|
-
for (const
|
|
1305
|
-
const r = this.getBep().teams.find((m) => m.id ===
|
|
1308
|
+
for (const o of e) {
|
|
1309
|
+
const r = this.getBep().teams.find((m) => m.id === o.teamId);
|
|
1306
1310
|
if (!r) {
|
|
1307
|
-
n.push({ input:
|
|
1311
|
+
n.push({ input: o, error: `Team not found: ${o.teamId}` });
|
|
1308
1312
|
continue;
|
|
1309
1313
|
}
|
|
1310
|
-
const { teamId: d, isRepresentative: l, ...c } =
|
|
1314
|
+
const { teamId: d, isRepresentative: l, ...c } = o, u = this.add([c]);
|
|
1311
1315
|
if (u.failed.length > 0) {
|
|
1312
|
-
n.push({ input:
|
|
1316
|
+
n.push({ input: o, error: u.failed[0].error });
|
|
1313
1317
|
continue;
|
|
1314
1318
|
}
|
|
1315
|
-
r.memberEmails ??= [], r.memberEmails.includes(
|
|
1316
|
-
const f = this.listResolved().find((m) => m.email ===
|
|
1319
|
+
r.memberEmails ??= [], r.memberEmails.includes(o.email) || r.memberEmails.push(o.email), l && (r.representativeEmail = o.email);
|
|
1320
|
+
const f = this.listResolved().find((m) => m.email === o.email);
|
|
1317
1321
|
t.push(f);
|
|
1318
1322
|
}
|
|
1319
1323
|
return { succeeded: t, failed: n };
|
|
1320
1324
|
}
|
|
1321
1325
|
updateInTeam(e) {
|
|
1322
1326
|
const t = [], n = [];
|
|
1323
|
-
for (const
|
|
1324
|
-
const
|
|
1325
|
-
if (r !== void 0 && !
|
|
1326
|
-
n.push({ email:
|
|
1327
|
+
for (const o of e) {
|
|
1328
|
+
const i = this.getBep(), { teamId: r, isRepresentative: d, ...l } = o;
|
|
1329
|
+
if (r !== void 0 && !i.teams.find((f) => f.id === r)) {
|
|
1330
|
+
n.push({ email: o.email, error: `Team not found: ${r}` });
|
|
1327
1331
|
continue;
|
|
1328
1332
|
}
|
|
1329
1333
|
const c = this.update([l]);
|
|
1330
1334
|
if (c.failed.length > 0) {
|
|
1331
|
-
n.push({ email:
|
|
1335
|
+
n.push({ email: o.email, error: c.failed[0].error });
|
|
1332
1336
|
continue;
|
|
1333
1337
|
}
|
|
1334
1338
|
if (r !== void 0) {
|
|
1335
|
-
const f =
|
|
1336
|
-
m && m.id !== r && (m.memberEmails = (m.memberEmails ?? []).filter((p) => p !==
|
|
1339
|
+
const f = i.teams.find((p) => p.id === r), m = i.teams.find((p) => (p.memberEmails ?? []).includes(o.email));
|
|
1340
|
+
m && m.id !== r && (m.memberEmails = (m.memberEmails ?? []).filter((p) => p !== o.email), m.representativeEmail === o.email && (m.representativeEmail = void 0)), f.memberEmails ??= [], f.memberEmails.includes(o.email) || f.memberEmails.push(o.email);
|
|
1337
1341
|
}
|
|
1338
1342
|
if (d !== void 0) {
|
|
1339
|
-
const f =
|
|
1340
|
-
f && (f.representativeEmail = d ?
|
|
1343
|
+
const f = i.teams.find((m) => (m.memberEmails ?? []).includes(o.email));
|
|
1344
|
+
f && (f.representativeEmail = d ? o.email : f.representativeEmail === o.email ? void 0 : f.representativeEmail);
|
|
1341
1345
|
}
|
|
1342
|
-
const u = this.listResolved().find((f) => f.email ===
|
|
1343
|
-
t.push({ email:
|
|
1346
|
+
const u = this.listResolved().find((f) => f.email === o.email);
|
|
1347
|
+
t.push({ email: o.email, after: u });
|
|
1344
1348
|
}
|
|
1345
1349
|
return { succeeded: t, failed: n };
|
|
1346
1350
|
}
|
|
1347
1351
|
removeFromBep(e) {
|
|
1348
1352
|
const t = [], n = [];
|
|
1349
|
-
for (const
|
|
1350
|
-
const
|
|
1353
|
+
for (const o of e) {
|
|
1354
|
+
const i = this.getBep(), r = this.listResolved().find((l) => l.email === o);
|
|
1351
1355
|
if (!r) {
|
|
1352
|
-
n.push({ email:
|
|
1356
|
+
n.push({ email: o, error: `Not found: ${o}` });
|
|
1353
1357
|
continue;
|
|
1354
1358
|
}
|
|
1355
|
-
for (const l of
|
|
1356
|
-
l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !==
|
|
1357
|
-
const d = this.remove([
|
|
1359
|
+
for (const l of i.teams)
|
|
1360
|
+
l.memberEmails && (l.memberEmails = l.memberEmails.filter((c) => c !== o)), l.representativeEmail === o && (l.representativeEmail = void 0);
|
|
1361
|
+
const d = this.remove([o]);
|
|
1358
1362
|
if (d.failed.length > 0) {
|
|
1359
1363
|
if (r.team) {
|
|
1360
|
-
const l =
|
|
1361
|
-
l && (l.memberEmails ??= [], l.memberEmails.includes(
|
|
1364
|
+
const l = i.teams.find((c) => c.id === r.team.id);
|
|
1365
|
+
l && (l.memberEmails ??= [], l.memberEmails.includes(o) || l.memberEmails.push(o), r.isRepresentative && (l.representativeEmail = o));
|
|
1362
1366
|
}
|
|
1363
|
-
n.push({ email:
|
|
1367
|
+
n.push({ email: o, error: d.failed[0].error });
|
|
1364
1368
|
continue;
|
|
1365
1369
|
}
|
|
1366
1370
|
t.push(r);
|
|
@@ -1368,7 +1372,7 @@ class Yt extends y {
|
|
|
1368
1372
|
return { succeeded: t, failed: n };
|
|
1369
1373
|
}
|
|
1370
1374
|
}
|
|
1371
|
-
class Qt extends
|
|
1375
|
+
class Qt extends w {
|
|
1372
1376
|
constructor(e) {
|
|
1373
1377
|
super(
|
|
1374
1378
|
() => e().milestones,
|
|
@@ -1378,8 +1382,8 @@ class Qt extends y {
|
|
|
1378
1382
|
schema: ye,
|
|
1379
1383
|
autoId: !0,
|
|
1380
1384
|
beforeRemove: (t, n) => {
|
|
1381
|
-
for (const
|
|
1382
|
-
if (
|
|
1385
|
+
for (const o of n.loin)
|
|
1386
|
+
if (o.milestones?.find((r) => r.milestoneId === t)) throw new Error(`Referenced by: loin["${o.id}"].milestones[milestoneId="${t}"]`);
|
|
1383
1387
|
}
|
|
1384
1388
|
}
|
|
1385
1389
|
);
|
|
@@ -1392,7 +1396,7 @@ class Qt extends y {
|
|
|
1392
1396
|
}));
|
|
1393
1397
|
}
|
|
1394
1398
|
}
|
|
1395
|
-
class es extends
|
|
1399
|
+
class es extends w {
|
|
1396
1400
|
constructor(e) {
|
|
1397
1401
|
super(
|
|
1398
1402
|
() => e().objectives,
|
|
@@ -1405,7 +1409,7 @@ class es extends y {
|
|
|
1405
1409
|
);
|
|
1406
1410
|
}
|
|
1407
1411
|
}
|
|
1408
|
-
class ts extends
|
|
1412
|
+
class ts extends w {
|
|
1409
1413
|
constructor(e) {
|
|
1410
1414
|
super(
|
|
1411
1415
|
() => e().phases,
|
|
@@ -1418,7 +1422,7 @@ class ts extends y {
|
|
|
1418
1422
|
);
|
|
1419
1423
|
}
|
|
1420
1424
|
}
|
|
1421
|
-
class ss extends
|
|
1425
|
+
class ss extends w {
|
|
1422
1426
|
constructor(e) {
|
|
1423
1427
|
super(
|
|
1424
1428
|
() => e().remoteData,
|
|
@@ -1431,7 +1435,7 @@ class ss extends y {
|
|
|
1431
1435
|
);
|
|
1432
1436
|
}
|
|
1433
1437
|
}
|
|
1434
|
-
class ns extends
|
|
1438
|
+
class ns extends w {
|
|
1435
1439
|
constructor(e) {
|
|
1436
1440
|
super(
|
|
1437
1441
|
() => e().resolvers,
|
|
@@ -1440,14 +1444,14 @@ class ns extends y {
|
|
|
1440
1444
|
key: "resolvers",
|
|
1441
1445
|
schema: Ue,
|
|
1442
1446
|
beforeRemove: (t, n) => {
|
|
1443
|
-
const
|
|
1444
|
-
if (
|
|
1447
|
+
const o = n.remoteData.find((i) => i.resolverId === t);
|
|
1448
|
+
if (o) throw new Error(`Referenced by: remoteData["${o.id}"].resolverId`);
|
|
1445
1449
|
}
|
|
1446
1450
|
}
|
|
1447
1451
|
);
|
|
1448
1452
|
}
|
|
1449
1453
|
}
|
|
1450
|
-
class
|
|
1454
|
+
class os extends w {
|
|
1451
1455
|
constructor(e, t) {
|
|
1452
1456
|
super(
|
|
1453
1457
|
() => e().softwares,
|
|
@@ -1467,7 +1471,7 @@ class is extends y {
|
|
|
1467
1471
|
}));
|
|
1468
1472
|
}
|
|
1469
1473
|
}
|
|
1470
|
-
class
|
|
1474
|
+
class is extends w {
|
|
1471
1475
|
constructor(e, t) {
|
|
1472
1476
|
super(
|
|
1473
1477
|
() => e().standards,
|
|
@@ -1484,29 +1488,29 @@ class os extends y {
|
|
|
1484
1488
|
*/
|
|
1485
1489
|
add(e) {
|
|
1486
1490
|
const t = e.map((n) => {
|
|
1487
|
-
const
|
|
1491
|
+
const o = `standards/${globalThis.crypto.randomUUID()}.md`;
|
|
1488
1492
|
if ("content" in n) {
|
|
1489
|
-
const { content:
|
|
1490
|
-
return this.getZip().file(
|
|
1493
|
+
const { content: i, ...r } = n;
|
|
1494
|
+
return this.getZip().file(o, i), { ...r, contentPath: o };
|
|
1491
1495
|
}
|
|
1492
|
-
return this.getZip().file(
|
|
1496
|
+
return this.getZip().file(o, ""), { ...n, contentPath: o };
|
|
1493
1497
|
});
|
|
1494
1498
|
return super.add(t);
|
|
1495
1499
|
}
|
|
1496
1500
|
/** Removes standards and deletes their .md files from the zip. */
|
|
1497
1501
|
remove(e) {
|
|
1498
1502
|
const t = new Map(
|
|
1499
|
-
e.map((
|
|
1503
|
+
e.map((o) => [o, this.list().find((i) => i.id === o)?.contentPath]).filter((o) => o[1] !== void 0)
|
|
1500
1504
|
), n = super.remove(e);
|
|
1501
|
-
for (const
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1505
|
+
for (const o of n.succeeded) {
|
|
1506
|
+
const i = t.get(o);
|
|
1507
|
+
i && this.getZip().remove(i);
|
|
1504
1508
|
}
|
|
1505
1509
|
return n;
|
|
1506
1510
|
}
|
|
1507
1511
|
/** Returns the markdown text content of the given standard. */
|
|
1508
1512
|
async getContent(e) {
|
|
1509
|
-
const t = this.list().find((
|
|
1513
|
+
const t = this.list().find((o) => o.id === e);
|
|
1510
1514
|
if (!t) throw new Error(`Standard not found: ${e}`);
|
|
1511
1515
|
const n = this.getZip().file(t.contentPath);
|
|
1512
1516
|
if (!n) throw new Error(`Content file not found: ${t.contentPath}`);
|
|
@@ -1514,12 +1518,12 @@ class os extends y {
|
|
|
1514
1518
|
}
|
|
1515
1519
|
/** Writes new markdown text content for the given standard. */
|
|
1516
1520
|
setContent(e, t) {
|
|
1517
|
-
const n = this.list().find((
|
|
1521
|
+
const n = this.list().find((o) => o.id === e);
|
|
1518
1522
|
if (!n) throw new Error(`Standard not found: ${e}`);
|
|
1519
1523
|
this.getZip().file(n.contentPath, t);
|
|
1520
1524
|
}
|
|
1521
1525
|
}
|
|
1522
|
-
class rs extends
|
|
1526
|
+
class rs extends w {
|
|
1523
1527
|
constructor(e, t) {
|
|
1524
1528
|
super(
|
|
1525
1529
|
() => e().teams,
|
|
@@ -1527,12 +1531,12 @@ class rs extends y {
|
|
|
1527
1531
|
{
|
|
1528
1532
|
key: "teams",
|
|
1529
1533
|
schema: pe,
|
|
1530
|
-
validate: (n,
|
|
1531
|
-
const
|
|
1532
|
-
return r &&
|
|
1534
|
+
validate: (n, o) => {
|
|
1535
|
+
const i = [], r = x("team", n.id, o.deliverableNamingConvention);
|
|
1536
|
+
return r && i.push(r), n.representativeEmail && !(n.memberEmails ?? []).includes(n.representativeEmail) && i.push(`representativeEmail "${n.representativeEmail}" is not a member of this team`), i;
|
|
1533
1537
|
},
|
|
1534
|
-
beforeRemove: (n,
|
|
1535
|
-
if (
|
|
1538
|
+
beforeRemove: (n, o) => {
|
|
1539
|
+
if (o.project.clientId === n)
|
|
1536
1540
|
throw new Error("Referenced by: project.clientId");
|
|
1537
1541
|
}
|
|
1538
1542
|
}
|
|
@@ -1544,8 +1548,8 @@ class rs extends y {
|
|
|
1544
1548
|
return e.teams.map((n) => ({
|
|
1545
1549
|
...n,
|
|
1546
1550
|
representative: t.get(n.representativeEmail ?? "") ?? null,
|
|
1547
|
-
members: (n.memberEmails ?? []).map((
|
|
1548
|
-
disciplines: (n.disciplineIds ?? []).map((
|
|
1551
|
+
members: (n.memberEmails ?? []).map((o) => t.get(o)).filter(Boolean),
|
|
1552
|
+
disciplines: (n.disciplineIds ?? []).map((o) => e.disciplines.find((i) => i.id === o)).filter(Boolean)
|
|
1549
1553
|
}));
|
|
1550
1554
|
}
|
|
1551
1555
|
}
|
|
@@ -1567,10 +1571,10 @@ function as(s, e, t) {
|
|
|
1567
1571
|
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)
|
|
1568
1572
|
for (const u of c.timeouts)
|
|
1569
1573
|
e.effects.some((f) => f.id === u.effectId) || n.push(`effects["${u.effectId}"] not found (node: ${l}.timeouts)`);
|
|
1570
|
-
const
|
|
1571
|
-
for (const l of
|
|
1572
|
-
s.nodes[l].type !== "start" && (
|
|
1573
|
-
for (const l of
|
|
1574
|
+
const o = Object.keys(s.nodes), i = new Set(Object.values(s.edges).map((l) => l.to)), r = new Set(Object.values(s.edges).map((l) => l.from));
|
|
1575
|
+
for (const l of o)
|
|
1576
|
+
s.nodes[l].type !== "start" && (i.has(l) || n.push(`node "${l}" is unreachable — no edges point to it`));
|
|
1577
|
+
for (const l of o)
|
|
1574
1578
|
s.nodes[l].type !== "end" && (r.has(l) || n.push(`node "${l}" has no outgoing edges — workflow would get stuck here`));
|
|
1575
1579
|
const d = {};
|
|
1576
1580
|
for (const l of Object.keys(s.edges)) {
|
|
@@ -1599,7 +1603,7 @@ function as(s, e, t) {
|
|
|
1599
1603
|
}
|
|
1600
1604
|
return n;
|
|
1601
1605
|
}
|
|
1602
|
-
class ds extends
|
|
1606
|
+
class ds extends w {
|
|
1603
1607
|
constructor(e, t, n) {
|
|
1604
1608
|
super(
|
|
1605
1609
|
() => e().workflows,
|
|
@@ -1608,18 +1612,18 @@ class ds extends y {
|
|
|
1608
1612
|
key: "workflows",
|
|
1609
1613
|
schema: Ae,
|
|
1610
1614
|
autoId: !0,
|
|
1611
|
-
validate: (
|
|
1615
|
+
validate: (o, i) => as(o.diagram, i, o.id)
|
|
1612
1616
|
}
|
|
1613
1617
|
), this.getMembers = t, this.getTeams = n;
|
|
1614
1618
|
}
|
|
1615
1619
|
getMembers;
|
|
1616
1620
|
getTeams;
|
|
1617
1621
|
getRaciMatrix() {
|
|
1618
|
-
const e = this.getBep(), t = [], n = /* @__PURE__ */ new Set(),
|
|
1622
|
+
const e = this.getBep(), t = [], n = /* @__PURE__ */ new Set(), o = this.getMembers().listResolved(), i = this.getTeams().listResolved(), r = (l) => (l ?? []).flatMap((c) => {
|
|
1619
1623
|
const u = e.roles.find((p) => p.id === c);
|
|
1620
1624
|
if (!u) return [];
|
|
1621
1625
|
n.add(c);
|
|
1622
|
-
const f =
|
|
1626
|
+
const f = o.filter((p) => p.role?.id === c), m = i.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
|
|
1623
1627
|
return [{ role: u, members: f, team: m }];
|
|
1624
1628
|
});
|
|
1625
1629
|
for (const l of e.workflows)
|
|
@@ -1641,10 +1645,10 @@ class ds extends y {
|
|
|
1641
1645
|
return { roles: [...n].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: t };
|
|
1642
1646
|
}
|
|
1643
1647
|
getRaciMatrixForWorkflow(e) {
|
|
1644
|
-
const t = this.getRaciMatrix(), n = t.rows.filter((
|
|
1645
|
-
n.flatMap((
|
|
1648
|
+
const t = this.getRaciMatrix(), n = t.rows.filter((i) => i.workflow.id === e), o = new Set(
|
|
1649
|
+
n.flatMap((i) => [...i.responsible, ...i.accountable, ...i.consulted, ...i.informed].map((r) => r.role.id))
|
|
1646
1650
|
);
|
|
1647
|
-
return { roles: t.roles.filter((
|
|
1651
|
+
return { roles: t.roles.filter((i) => o.has(i.id)), rows: n };
|
|
1648
1652
|
}
|
|
1649
1653
|
getConsolidatedRaciMatrix() {
|
|
1650
1654
|
const e = this.getRaciMatrix(), t = /* @__PURE__ */ new Map(), n = (r, d) => {
|
|
@@ -1667,33 +1671,33 @@ class ds extends y {
|
|
|
1667
1671
|
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);
|
|
1668
1672
|
}
|
|
1669
1673
|
}
|
|
1670
|
-
const
|
|
1671
|
-
|
|
1674
|
+
const o = [...t.values()], i = new Set(
|
|
1675
|
+
o.flatMap((r) => [...r.responsible, ...r.accountable, ...r.consulted, ...r.informed].map((d) => d.role.id))
|
|
1672
1676
|
);
|
|
1673
|
-
return { roles: e.roles.filter((r) =>
|
|
1677
|
+
return { roles: e.roles.filter((r) => i.has(r.id)), rows: o };
|
|
1674
1678
|
}
|
|
1675
1679
|
listResolved() {
|
|
1676
1680
|
const e = this.getBep();
|
|
1677
1681
|
return e.workflows.map((t) => {
|
|
1678
1682
|
const n = {};
|
|
1679
|
-
for (const [
|
|
1683
|
+
for (const [o, i] of Object.entries(t.diagram.nodes)) {
|
|
1680
1684
|
const r = (d) => ({
|
|
1681
1685
|
roles: (d ?? []).map((l) => e.roles.find((c) => c.id === l)).filter(Boolean),
|
|
1682
1686
|
teams: [],
|
|
1683
1687
|
members: []
|
|
1684
1688
|
});
|
|
1685
|
-
n[
|
|
1686
|
-
type:
|
|
1687
|
-
label:
|
|
1688
|
-
timeouts:
|
|
1689
|
-
workflowId:
|
|
1690
|
-
blocking:
|
|
1691
|
-
action:
|
|
1692
|
-
automation:
|
|
1693
|
-
responsible: r(
|
|
1694
|
-
accountable: r(
|
|
1695
|
-
consulted: r(
|
|
1696
|
-
informed: r(
|
|
1689
|
+
n[o] = {
|
|
1690
|
+
type: i.type,
|
|
1691
|
+
label: i.type === "decision" ? i.label : void 0,
|
|
1692
|
+
timeouts: i.type === "process" || i.type === "automation" ? i.timeouts : void 0,
|
|
1693
|
+
workflowId: i.type === "process" ? i.workflowId : void 0,
|
|
1694
|
+
blocking: i.type === "process" ? i.blocking : void 0,
|
|
1695
|
+
action: i.type === "process" && i.actionId ? e.actions.find((d) => d.id === i.actionId) ?? null : null,
|
|
1696
|
+
automation: i.type === "automation" ? e.automations.find((d) => d.id === i.automationId) ?? null : null,
|
|
1697
|
+
responsible: r(i.type === "process" ? i.responsibleRoleIds : void 0),
|
|
1698
|
+
accountable: r(i.type === "process" ? i.accountableRoleIds : void 0),
|
|
1699
|
+
consulted: r(i.type === "process" ? i.consultedRoleIds : void 0),
|
|
1700
|
+
informed: r(i.type === "process" ? i.informedRoleIds : void 0)
|
|
1697
1701
|
};
|
|
1698
1702
|
}
|
|
1699
1703
|
return {
|
|
@@ -1705,10 +1709,10 @@ class ds extends y {
|
|
|
1705
1709
|
}
|
|
1706
1710
|
var ls = /* @__PURE__ */ (function() {
|
|
1707
1711
|
var s = function(e, t) {
|
|
1708
|
-
return s = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n,
|
|
1709
|
-
n.__proto__ =
|
|
1710
|
-
} || function(n,
|
|
1711
|
-
for (var
|
|
1712
|
+
return s = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, o) {
|
|
1713
|
+
n.__proto__ = o;
|
|
1714
|
+
} || function(n, o) {
|
|
1715
|
+
for (var i in o) o.hasOwnProperty(i) && (n[i] = o[i]);
|
|
1712
1716
|
}, s(e, t);
|
|
1713
1717
|
};
|
|
1714
1718
|
return function(e, t) {
|
|
@@ -1722,7 +1726,7 @@ var ls = /* @__PURE__ */ (function() {
|
|
|
1722
1726
|
function G(s, e) {
|
|
1723
1727
|
return cs.call(s, e);
|
|
1724
1728
|
}
|
|
1725
|
-
function
|
|
1729
|
+
function V(s) {
|
|
1726
1730
|
if (Array.isArray(s)) {
|
|
1727
1731
|
for (var e = new Array(s.length), t = 0; t < e.length; t++)
|
|
1728
1732
|
e[t] = "" + t;
|
|
@@ -1731,11 +1735,11 @@ function X(s) {
|
|
|
1731
1735
|
if (Object.keys)
|
|
1732
1736
|
return Object.keys(s);
|
|
1733
1737
|
var n = [];
|
|
1734
|
-
for (var
|
|
1735
|
-
G(s,
|
|
1738
|
+
for (var o in s)
|
|
1739
|
+
G(s, o) && n.push(o);
|
|
1736
1740
|
return n;
|
|
1737
1741
|
}
|
|
1738
|
-
function
|
|
1742
|
+
function T(s) {
|
|
1739
1743
|
switch (typeof s) {
|
|
1740
1744
|
case "object":
|
|
1741
1745
|
return JSON.parse(JSON.stringify(s));
|
|
@@ -1747,7 +1751,7 @@ function R(s) {
|
|
|
1747
1751
|
return s;
|
|
1748
1752
|
}
|
|
1749
1753
|
}
|
|
1750
|
-
function
|
|
1754
|
+
function H(s) {
|
|
1751
1755
|
for (var e = 0, t = s.length, n; e < t; ) {
|
|
1752
1756
|
if (n = s.charCodeAt(e), n >= 48 && n <= 57) {
|
|
1753
1757
|
e++;
|
|
@@ -1763,42 +1767,42 @@ function A(s) {
|
|
|
1763
1767
|
function We(s) {
|
|
1764
1768
|
return s.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1765
1769
|
}
|
|
1766
|
-
function
|
|
1770
|
+
function Y(s) {
|
|
1767
1771
|
if (s === void 0)
|
|
1768
1772
|
return !0;
|
|
1769
1773
|
if (s) {
|
|
1770
1774
|
if (Array.isArray(s)) {
|
|
1771
1775
|
for (var e = 0, t = s.length; e < t; e++)
|
|
1772
|
-
if (
|
|
1776
|
+
if (Y(s[e]))
|
|
1773
1777
|
return !0;
|
|
1774
1778
|
} else if (typeof s == "object") {
|
|
1775
|
-
for (var n =
|
|
1776
|
-
if (
|
|
1779
|
+
for (var n = V(s), o = n.length, i = 0; i < o; i++)
|
|
1780
|
+
if (Y(s[n[i]]))
|
|
1777
1781
|
return !0;
|
|
1778
1782
|
}
|
|
1779
1783
|
}
|
|
1780
1784
|
return !1;
|
|
1781
1785
|
}
|
|
1782
|
-
function
|
|
1786
|
+
function le(s, e) {
|
|
1783
1787
|
var t = [s];
|
|
1784
1788
|
for (var n in e) {
|
|
1785
|
-
var
|
|
1786
|
-
typeof
|
|
1789
|
+
var o = typeof e[n] == "object" ? JSON.stringify(e[n], null, 2) : e[n];
|
|
1790
|
+
typeof o < "u" && t.push(n + ": " + o);
|
|
1787
1791
|
}
|
|
1788
1792
|
return t.join(`
|
|
1789
1793
|
`);
|
|
1790
1794
|
}
|
|
1791
|
-
var
|
|
1795
|
+
var Xe = (
|
|
1792
1796
|
/** @class */
|
|
1793
1797
|
(function(s) {
|
|
1794
1798
|
ls(e, s);
|
|
1795
|
-
function e(t, n,
|
|
1796
|
-
var d = this.constructor, l = s.call(this,
|
|
1797
|
-
return l.name = n, l.index =
|
|
1799
|
+
function e(t, n, o, i, r) {
|
|
1800
|
+
var d = this.constructor, l = s.call(this, le(t, { name: n, index: o, operation: i, tree: r })) || this;
|
|
1801
|
+
return l.name = n, l.index = o, l.operation = i, l.tree = r, Object.setPrototypeOf(l, d.prototype), l.message = le(t, { name: n, index: o, operation: i, tree: r }), l;
|
|
1798
1802
|
}
|
|
1799
1803
|
return e;
|
|
1800
1804
|
})(Error)
|
|
1801
|
-
), E =
|
|
1805
|
+
), E = Xe, fs = T, M = {
|
|
1802
1806
|
add: function(s, e, t) {
|
|
1803
1807
|
return s[e] = this.value, { newDocument: t };
|
|
1804
1808
|
},
|
|
@@ -1812,13 +1816,13 @@ var Ge = (
|
|
|
1812
1816
|
},
|
|
1813
1817
|
move: function(s, e, t) {
|
|
1814
1818
|
var n = U(t, this.path);
|
|
1815
|
-
n && (n =
|
|
1816
|
-
var
|
|
1817
|
-
return O(t, { op: "add", path: this.path, value:
|
|
1819
|
+
n && (n = T(n));
|
|
1820
|
+
var o = O(t, { op: "remove", path: this.from }).removed;
|
|
1821
|
+
return O(t, { op: "add", path: this.path, value: o }), { newDocument: t, removed: n };
|
|
1818
1822
|
},
|
|
1819
1823
|
copy: function(s, e, t) {
|
|
1820
1824
|
var n = U(t, this.from);
|
|
1821
|
-
return O(t, { op: "add", path: this.path, value:
|
|
1825
|
+
return O(t, { op: "add", path: this.path, value: T(n) }), { newDocument: t };
|
|
1822
1826
|
},
|
|
1823
1827
|
test: function(s, e, t) {
|
|
1824
1828
|
return { newDocument: t, test: P(s[e], this.value) };
|
|
@@ -1828,7 +1832,7 @@ var Ge = (
|
|
|
1828
1832
|
}
|
|
1829
1833
|
}, us = {
|
|
1830
1834
|
add: function(s, e, t) {
|
|
1831
|
-
return
|
|
1835
|
+
return H(e) ? s.splice(e, 0, this.value) : s[e] = this.value, { newDocument: t, index: e };
|
|
1832
1836
|
},
|
|
1833
1837
|
remove: function(s, e, t) {
|
|
1834
1838
|
var n = s.splice(e, 1);
|
|
@@ -1849,8 +1853,8 @@ function U(s, e) {
|
|
|
1849
1853
|
var t = { op: "_get", path: e };
|
|
1850
1854
|
return O(s, t), t.value;
|
|
1851
1855
|
}
|
|
1852
|
-
function O(s, e, t, n,
|
|
1853
|
-
if (t === void 0 && (t = !1), n === void 0 && (n = !0),
|
|
1856
|
+
function O(s, e, t, n, o, i) {
|
|
1857
|
+
if (t === void 0 && (t = !1), n === void 0 && (n = !0), o === void 0 && (o = !0), i === void 0 && (i = 0), t && (typeof t == "function" ? t(e, 0, s, e.path) : z(e, 0)), e.path === "") {
|
|
1854
1858
|
var r = { newDocument: s };
|
|
1855
1859
|
if (e.op === "add")
|
|
1856
1860
|
return r.newDocument = e.value, r;
|
|
@@ -1860,7 +1864,7 @@ function O(s, e, t, n, i, o) {
|
|
|
1860
1864
|
return r.newDocument = U(s, e.from), e.op === "move" && (r.removed = s), r;
|
|
1861
1865
|
if (e.op === "test") {
|
|
1862
1866
|
if (r.test = P(s, e.value), r.test === !1)
|
|
1863
|
-
throw new E("Test operation failed", "TEST_OPERATION_FAILED",
|
|
1867
|
+
throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
|
|
1864
1868
|
return r.newDocument = s, r;
|
|
1865
1869
|
} else {
|
|
1866
1870
|
if (e.op === "remove")
|
|
@@ -1868,49 +1872,49 @@ function O(s, e, t, n, i, o) {
|
|
|
1868
1872
|
if (e.op === "_get")
|
|
1869
1873
|
return e.value = s, r;
|
|
1870
1874
|
if (t)
|
|
1871
|
-
throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID",
|
|
1875
|
+
throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", i, e, s);
|
|
1872
1876
|
return r;
|
|
1873
1877
|
}
|
|
1874
1878
|
} else {
|
|
1875
|
-
n || (s =
|
|
1879
|
+
n || (s = T(s));
|
|
1876
1880
|
var d = e.path || "", l = d.split("/"), c = s, u = 1, f = l.length, m = void 0, p = void 0, g = void 0;
|
|
1877
1881
|
for (typeof t == "function" ? g = t : g = z; ; ) {
|
|
1878
|
-
if (p = l[u], p && p.indexOf("~") != -1 && (p = We(p)),
|
|
1882
|
+
if (p = l[u], p && p.indexOf("~") != -1 && (p = We(p)), o && (p == "__proto__" || p == "prototype" && u > 0 && l[u - 1] == "constructor"))
|
|
1879
1883
|
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");
|
|
1880
1884
|
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)) {
|
|
1881
1885
|
if (p === "-")
|
|
1882
1886
|
p = c.length;
|
|
1883
1887
|
else {
|
|
1884
|
-
if (t && !
|
|
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",
|
|
1886
|
-
|
|
1888
|
+
if (t && !H(p))
|
|
1889
|
+
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", i, e, s);
|
|
1890
|
+
H(p) && (p = ~~p);
|
|
1887
1891
|
}
|
|
1888
1892
|
if (u >= f) {
|
|
1889
1893
|
if (t && e.op === "add" && p > c.length)
|
|
1890
|
-
throw new E("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS",
|
|
1894
|
+
throw new E("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", i, e, s);
|
|
1891
1895
|
var r = us[e.op].call(e, c, p, s);
|
|
1892
1896
|
if (r.test === !1)
|
|
1893
|
-
throw new E("Test operation failed", "TEST_OPERATION_FAILED",
|
|
1897
|
+
throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
|
|
1894
1898
|
return r;
|
|
1895
1899
|
}
|
|
1896
1900
|
} else if (u >= f) {
|
|
1897
1901
|
var r = M[e.op].call(e, c, p, s);
|
|
1898
1902
|
if (r.test === !1)
|
|
1899
|
-
throw new E("Test operation failed", "TEST_OPERATION_FAILED",
|
|
1903
|
+
throw new E("Test operation failed", "TEST_OPERATION_FAILED", i, e, s);
|
|
1900
1904
|
return r;
|
|
1901
1905
|
}
|
|
1902
1906
|
if (c = c[p], t && u < f && (!c || typeof c != "object"))
|
|
1903
|
-
throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE",
|
|
1907
|
+
throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", i, e, s);
|
|
1904
1908
|
}
|
|
1905
1909
|
}
|
|
1906
1910
|
}
|
|
1907
|
-
function Z(s, e, t, n,
|
|
1908
|
-
if (n === void 0 && (n = !0),
|
|
1911
|
+
function Z(s, e, t, n, o) {
|
|
1912
|
+
if (n === void 0 && (n = !0), o === void 0 && (o = !0), t && !Array.isArray(e))
|
|
1909
1913
|
throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
1910
|
-
n || (s =
|
|
1911
|
-
for (var
|
|
1912
|
-
|
|
1913
|
-
return
|
|
1914
|
+
n || (s = T(s));
|
|
1915
|
+
for (var i = new Array(e.length), r = 0, d = e.length; r < d; r++)
|
|
1916
|
+
i[r] = O(s, e[r], t, !0, o, r), s = i[r].newDocument;
|
|
1917
|
+
return i.newDocument = s, i;
|
|
1914
1918
|
}
|
|
1915
1919
|
function ms(s, e, t) {
|
|
1916
1920
|
var n = O(s, e);
|
|
@@ -1930,64 +1934,64 @@ function z(s, e, t, n) {
|
|
|
1930
1934
|
throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, s, t);
|
|
1931
1935
|
if ((s.op === "add" || s.op === "replace" || s.op === "test") && s.value === void 0)
|
|
1932
1936
|
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") &&
|
|
1937
|
+
if ((s.op === "add" || s.op === "replace" || s.op === "test") && Y(s.value))
|
|
1934
1938
|
throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, s, t);
|
|
1935
1939
|
if (t) {
|
|
1936
1940
|
if (s.op == "add") {
|
|
1937
|
-
var
|
|
1938
|
-
if (
|
|
1941
|
+
var o = s.path.split("/").length, i = n.split("/").length;
|
|
1942
|
+
if (o !== i + 1 && o !== i)
|
|
1939
1943
|
throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, s, t);
|
|
1940
1944
|
} else if (s.op === "replace" || s.op === "remove" || s.op === "_get") {
|
|
1941
1945
|
if (s.path !== n)
|
|
1942
1946
|
throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, s, t);
|
|
1943
1947
|
} else if (s.op === "move" || s.op === "copy") {
|
|
1944
|
-
var r = { op: "_get", path: s.from, value: void 0 }, d =
|
|
1948
|
+
var r = { op: "_get", path: s.from, value: void 0 }, d = Ge([r], t);
|
|
1945
1949
|
if (d && d.name === "OPERATION_PATH_UNRESOLVABLE")
|
|
1946
1950
|
throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, s, t);
|
|
1947
1951
|
}
|
|
1948
1952
|
}
|
|
1949
1953
|
} else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, s, t);
|
|
1950
1954
|
}
|
|
1951
|
-
function
|
|
1955
|
+
function Ge(s, e, t) {
|
|
1952
1956
|
try {
|
|
1953
1957
|
if (!Array.isArray(s))
|
|
1954
1958
|
throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
1955
1959
|
if (e)
|
|
1956
|
-
Z(
|
|
1960
|
+
Z(T(e), T(s), t || !0);
|
|
1957
1961
|
else {
|
|
1958
1962
|
t = t || z;
|
|
1959
1963
|
for (var n = 0; n < s.length; n++)
|
|
1960
1964
|
t(s[n], n, e, void 0);
|
|
1961
1965
|
}
|
|
1962
|
-
} catch (
|
|
1963
|
-
if (
|
|
1964
|
-
return
|
|
1965
|
-
throw
|
|
1966
|
+
} catch (o) {
|
|
1967
|
+
if (o instanceof E)
|
|
1968
|
+
return o;
|
|
1969
|
+
throw o;
|
|
1966
1970
|
}
|
|
1967
1971
|
}
|
|
1968
1972
|
function P(s, e) {
|
|
1969
1973
|
if (s === e)
|
|
1970
1974
|
return !0;
|
|
1971
1975
|
if (s && e && typeof s == "object" && typeof e == "object") {
|
|
1972
|
-
var t = Array.isArray(s), n = Array.isArray(e),
|
|
1976
|
+
var t = Array.isArray(s), n = Array.isArray(e), o, i, r;
|
|
1973
1977
|
if (t && n) {
|
|
1974
|
-
if (
|
|
1978
|
+
if (i = s.length, i != e.length)
|
|
1975
1979
|
return !1;
|
|
1976
|
-
for (
|
|
1977
|
-
if (!P(s[
|
|
1980
|
+
for (o = i; o-- !== 0; )
|
|
1981
|
+
if (!P(s[o], e[o]))
|
|
1978
1982
|
return !1;
|
|
1979
1983
|
return !0;
|
|
1980
1984
|
}
|
|
1981
1985
|
if (t != n)
|
|
1982
1986
|
return !1;
|
|
1983
1987
|
var d = Object.keys(s);
|
|
1984
|
-
if (
|
|
1988
|
+
if (i = d.length, i !== Object.keys(e).length)
|
|
1985
1989
|
return !1;
|
|
1986
|
-
for (
|
|
1987
|
-
if (!e.hasOwnProperty(d[
|
|
1990
|
+
for (o = i; o-- !== 0; )
|
|
1991
|
+
if (!e.hasOwnProperty(d[o]))
|
|
1988
1992
|
return !1;
|
|
1989
|
-
for (
|
|
1990
|
-
if (r = d[
|
|
1993
|
+
for (o = i; o-- !== 0; )
|
|
1994
|
+
if (r = d[o], !P(s[r], e[r]))
|
|
1991
1995
|
return !1;
|
|
1992
1996
|
return !0;
|
|
1993
1997
|
}
|
|
@@ -2002,10 +2006,10 @@ const ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2002
2006
|
applyReducer: ms,
|
|
2003
2007
|
deepClone: fs,
|
|
2004
2008
|
getValueByPointer: U,
|
|
2005
|
-
validate:
|
|
2009
|
+
validate: Ge,
|
|
2006
2010
|
validator: z
|
|
2007
2011
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2008
|
-
var
|
|
2012
|
+
var ne = /* @__PURE__ */ new WeakMap(), hs = (
|
|
2009
2013
|
/** @class */
|
|
2010
2014
|
/* @__PURE__ */ (function() {
|
|
2011
2015
|
function s(e) {
|
|
@@ -2023,79 +2027,79 @@ var se = /* @__PURE__ */ new WeakMap(), hs = (
|
|
|
2023
2027
|
})()
|
|
2024
2028
|
);
|
|
2025
2029
|
function ys(s) {
|
|
2026
|
-
return
|
|
2030
|
+
return ne.get(s);
|
|
2027
2031
|
}
|
|
2028
|
-
function
|
|
2032
|
+
function ws(s, e) {
|
|
2029
2033
|
return s.observers.get(e);
|
|
2030
2034
|
}
|
|
2031
|
-
function
|
|
2035
|
+
function bs(s, e) {
|
|
2032
2036
|
s.observers.delete(e.callback);
|
|
2033
2037
|
}
|
|
2034
2038
|
function vs(s, e) {
|
|
2035
2039
|
e.unobserve();
|
|
2036
2040
|
}
|
|
2037
2041
|
function Is(s, e) {
|
|
2038
|
-
var t = [], n,
|
|
2039
|
-
if (!
|
|
2040
|
-
|
|
2042
|
+
var t = [], n, o = ys(s);
|
|
2043
|
+
if (!o)
|
|
2044
|
+
o = new hs(s), ne.set(s, o);
|
|
2041
2045
|
else {
|
|
2042
|
-
var
|
|
2043
|
-
n =
|
|
2046
|
+
var i = ws(o, e);
|
|
2047
|
+
n = i && i.observer;
|
|
2044
2048
|
}
|
|
2045
2049
|
if (n)
|
|
2046
2050
|
return n;
|
|
2047
|
-
if (n = {},
|
|
2051
|
+
if (n = {}, o.value = T(s), e) {
|
|
2048
2052
|
n.callback = e, n.next = null;
|
|
2049
2053
|
var r = function() {
|
|
2050
|
-
|
|
2054
|
+
Q(n);
|
|
2051
2055
|
}, d = function() {
|
|
2052
2056
|
clearTimeout(n.next), n.next = setTimeout(r);
|
|
2053
2057
|
};
|
|
2054
2058
|
typeof window < "u" && (window.addEventListener("mouseup", d), window.addEventListener("keyup", d), window.addEventListener("mousedown", d), window.addEventListener("keydown", d), window.addEventListener("change", d));
|
|
2055
2059
|
}
|
|
2056
2060
|
return n.patches = t, n.object = s, n.unobserve = function() {
|
|
2057
|
-
|
|
2058
|
-
},
|
|
2061
|
+
Q(n), clearTimeout(n.next), bs(o, n), typeof window < "u" && (window.removeEventListener("mouseup", d), window.removeEventListener("keyup", d), window.removeEventListener("mousedown", d), window.removeEventListener("keydown", d), window.removeEventListener("change", d));
|
|
2062
|
+
}, o.observers.set(e, new gs(e, n)), n;
|
|
2059
2063
|
}
|
|
2060
|
-
function
|
|
2064
|
+
function Q(s, e) {
|
|
2061
2065
|
e === void 0 && (e = !1);
|
|
2062
|
-
var t =
|
|
2063
|
-
|
|
2066
|
+
var t = ne.get(s.object);
|
|
2067
|
+
oe(t.value, s.object, s.patches, "", e), s.patches.length && Z(t.value, s.patches);
|
|
2064
2068
|
var n = s.patches;
|
|
2065
2069
|
return n.length > 0 && (s.patches = [], s.callback && s.callback(n)), n;
|
|
2066
2070
|
}
|
|
2067
|
-
function
|
|
2071
|
+
function oe(s, e, t, n, o) {
|
|
2068
2072
|
if (e !== s) {
|
|
2069
2073
|
typeof e.toJSON == "function" && (e = e.toJSON());
|
|
2070
|
-
for (var
|
|
2074
|
+
for (var i = V(e), r = V(s), d = !1, l = r.length - 1; l >= 0; l--) {
|
|
2071
2075
|
var c = r[l], u = s[c];
|
|
2072
2076
|
if (G(e, c) && !(e[c] === void 0 && u !== void 0 && Array.isArray(e) === !1)) {
|
|
2073
2077
|
var f = e[c];
|
|
2074
|
-
typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ?
|
|
2075
|
-
} else Array.isArray(s) === Array.isArray(e) ? (
|
|
2078
|
+
typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? oe(u, f, t, n + "/" + A(c), o) : u !== f && (o && t.push({ op: "test", path: n + "/" + A(c), value: T(u) }), t.push({ op: "replace", path: n + "/" + A(c), value: T(f) }));
|
|
2079
|
+
} else Array.isArray(s) === Array.isArray(e) ? (o && t.push({ op: "test", path: n + "/" + A(c), value: T(u) }), t.push({ op: "remove", path: n + "/" + A(c) }), d = !0) : (o && t.push({ op: "test", path: n, value: s }), t.push({ op: "replace", path: n, value: e }));
|
|
2076
2080
|
}
|
|
2077
|
-
if (!(!d &&
|
|
2078
|
-
for (var l = 0; l <
|
|
2079
|
-
var c =
|
|
2080
|
-
!G(s, c) && e[c] !== void 0 && t.push({ op: "add", path: n + "/" + A(c), value:
|
|
2081
|
+
if (!(!d && i.length == r.length))
|
|
2082
|
+
for (var l = 0; l < i.length; l++) {
|
|
2083
|
+
var c = i[l];
|
|
2084
|
+
!G(s, c) && e[c] !== void 0 && t.push({ op: "add", path: n + "/" + A(c), value: T(e[c]) });
|
|
2081
2085
|
}
|
|
2082
2086
|
}
|
|
2083
2087
|
}
|
|
2084
|
-
function
|
|
2088
|
+
function ee(s, e, t) {
|
|
2085
2089
|
t === void 0 && (t = !1);
|
|
2086
2090
|
var n = [];
|
|
2087
|
-
return
|
|
2091
|
+
return oe(s, e, n, "", t), n;
|
|
2088
2092
|
}
|
|
2089
2093
|
const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2090
2094
|
__proto__: null,
|
|
2091
|
-
compare:
|
|
2092
|
-
generate:
|
|
2095
|
+
compare: ee,
|
|
2096
|
+
generate: Q,
|
|
2093
2097
|
observe: Is,
|
|
2094
2098
|
unobserve: vs
|
|
2095
2099
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2096
2100
|
Object.assign({}, ps, Es, {
|
|
2097
|
-
JsonPatchError:
|
|
2098
|
-
deepClone:
|
|
2101
|
+
JsonPatchError: Xe,
|
|
2102
|
+
deepClone: T,
|
|
2099
2103
|
escapePathComponent: A,
|
|
2100
2104
|
unescapePathComponent: We
|
|
2101
2105
|
});
|
|
@@ -2131,12 +2135,12 @@ const Ns = [
|
|
|
2131
2135
|
I("env", (s) => s.key, (s) => s.key)
|
|
2132
2136
|
];
|
|
2133
2137
|
function Ss(s, e, t, n) {
|
|
2134
|
-
const
|
|
2138
|
+
const o = new Map(s.map((r) => [t(r), r])), i = new Map(e.map((r) => [t(r), r]));
|
|
2135
2139
|
return {
|
|
2136
|
-
added: e.filter((r) => !
|
|
2137
|
-
removed: s.filter((r) => !
|
|
2140
|
+
added: e.filter((r) => !o.has(t(r))).map(n),
|
|
2141
|
+
removed: s.filter((r) => !i.has(t(r))).map(n),
|
|
2138
2142
|
modified: e.filter((r) => {
|
|
2139
|
-
const d =
|
|
2143
|
+
const d = o.get(t(r));
|
|
2140
2144
|
return d !== void 0 && JSON.stringify(d) !== JSON.stringify(r);
|
|
2141
2145
|
}).map(n)
|
|
2142
2146
|
};
|
|
@@ -2148,14 +2152,14 @@ function ks(s, e) {
|
|
|
2148
2152
|
return JSON.stringify(d) !== JSON.stringify(l);
|
|
2149
2153
|
}) });
|
|
2150
2154
|
const n = {};
|
|
2151
|
-
for (const { key:
|
|
2152
|
-
const l = e[
|
|
2153
|
-
(u.added.length || u.removed.length || u.modified.length) && (n[
|
|
2155
|
+
for (const { key: i, getId: r, getLabel: d } of Ns) {
|
|
2156
|
+
const l = e[i] ?? [], c = s[i] ?? [], u = Ss(l, c, r, d);
|
|
2157
|
+
(u.added.length || u.removed.length || u.modified.length) && (n[i] = u);
|
|
2154
2158
|
}
|
|
2155
|
-
const
|
|
2156
|
-
return { project: t, sections: n, changedKeys:
|
|
2159
|
+
const o = [...t ? ["project"] : [], ...Object.keys(n)];
|
|
2160
|
+
return { project: t, sections: n, changedKeys: o };
|
|
2157
2161
|
}
|
|
2158
|
-
class
|
|
2162
|
+
class $ {
|
|
2159
2163
|
constructor(e, t, n) {
|
|
2160
2164
|
this.getBep = e, this.setBep = t, this.getZip = n;
|
|
2161
2165
|
}
|
|
@@ -2168,12 +2172,12 @@ class k {
|
|
|
2168
2172
|
return { major: t, minor: n };
|
|
2169
2173
|
}
|
|
2170
2174
|
static compareVersions(e, t) {
|
|
2171
|
-
const n =
|
|
2172
|
-
return n.major !==
|
|
2175
|
+
const n = $.parseVersion(e), o = $.parseVersion(t);
|
|
2176
|
+
return n.major !== o.major ? n.major - o.major : n.minor - o.minor;
|
|
2173
2177
|
}
|
|
2174
2178
|
static bumpVersion(e, t) {
|
|
2175
|
-
const [n,
|
|
2176
|
-
return t === "version" ? `${n + 1}.0` : `${n}.${
|
|
2179
|
+
const [n, o] = e.split(".").map(Number);
|
|
2180
|
+
return t === "version" ? `${n + 1}.0` : `${n}.${o + 1}`;
|
|
2177
2181
|
}
|
|
2178
2182
|
// ─── Zip helpers ──────────────────────────────────────────────────────────
|
|
2179
2183
|
async readChangelog() {
|
|
@@ -2191,13 +2195,13 @@ class k {
|
|
|
2191
2195
|
*/
|
|
2192
2196
|
async snapshotChangedStandards(e, t) {
|
|
2193
2197
|
const n = this.getZip();
|
|
2194
|
-
for (const
|
|
2195
|
-
const
|
|
2196
|
-
if (!
|
|
2197
|
-
const r = await
|
|
2198
|
+
for (const o of e.standards) {
|
|
2199
|
+
const i = n.file(o.contentPath);
|
|
2200
|
+
if (!i) continue;
|
|
2201
|
+
const r = await i.async("string"), d = `changelog/standards/${o.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));
|
|
2198
2202
|
let c = null;
|
|
2199
2203
|
if (l.length > 0) {
|
|
2200
|
-
const u = l.sort((m, p) =>
|
|
2204
|
+
const u = l.sort((m, p) => $.compareVersions(p, m))[0], f = n.file(`${d}v${u}.md`);
|
|
2201
2205
|
f && (c = await f.async("string"));
|
|
2202
2206
|
}
|
|
2203
2207
|
c !== r && n.file(`${d}v${t}.md`, r);
|
|
@@ -2210,10 +2214,10 @@ class k {
|
|
|
2210
2214
|
async snapshotBaseStandards(e) {
|
|
2211
2215
|
const t = this.getZip();
|
|
2212
2216
|
for (const n of e.standards) {
|
|
2213
|
-
const
|
|
2214
|
-
if (!
|
|
2215
|
-
const
|
|
2216
|
-
t.file(`baseline/standards/${n.id}.md`,
|
|
2217
|
+
const o = t.file(n.contentPath);
|
|
2218
|
+
if (!o) continue;
|
|
2219
|
+
const i = await o.async("string");
|
|
2220
|
+
t.file(`baseline/standards/${n.id}.md`, i);
|
|
2217
2221
|
}
|
|
2218
2222
|
}
|
|
2219
2223
|
/**
|
|
@@ -2222,12 +2226,12 @@ class k {
|
|
|
2222
2226
|
* Falls back to the current file if no snapshot exists (content never changed).
|
|
2223
2227
|
*/
|
|
2224
2228
|
async resolveStandardContent(e, t) {
|
|
2225
|
-
const n = this.getZip(),
|
|
2226
|
-
if (
|
|
2229
|
+
const n = this.getZip(), o = `changelog/standards/${e.id}/`, i = Object.keys(n.files).filter((d) => d.startsWith(o) && d.endsWith(".md") && d.slice(o.length).startsWith("v")).map((d) => d.slice(o.length + 1, -3)).filter((d) => $.compareVersions(d, t) <= 0).sort((d, l) => $.compareVersions(l, d));
|
|
2230
|
+
if (i.length === 0) {
|
|
2227
2231
|
const d = n.file(e.contentPath);
|
|
2228
2232
|
return d ? d.async("string") : null;
|
|
2229
2233
|
}
|
|
2230
|
-
const r = n.file(`${
|
|
2234
|
+
const r = n.file(`${o}v${i[0]}.md`);
|
|
2231
2235
|
return r ? r.async("string") : null;
|
|
2232
2236
|
}
|
|
2233
2237
|
// ─── Public API ───────────────────────────────────────────────────────────
|
|
@@ -2238,19 +2242,19 @@ class k {
|
|
|
2238
2242
|
return (await this.readChangelog())?.versions ?? [];
|
|
2239
2243
|
}
|
|
2240
2244
|
async commit(e, t = !1) {
|
|
2241
|
-
const n = this.getZip(),
|
|
2245
|
+
const n = this.getZip(), o = this.getBep(), i = await this.readChangelog(), r = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
|
|
2242
2246
|
if (!r) throw new Error("No baseline found — create a BEP with Bep.create() or open one with Bep.open()");
|
|
2243
2247
|
if (e.type === "version") {
|
|
2244
|
-
const g = e.approvedBy.filter((h) => !
|
|
2248
|
+
const g = e.approvedBy.filter((h) => !o.members.some((y) => y.email === h));
|
|
2245
2249
|
if (g.length) throw new Error(`Members not found: ${g.join(", ")}`);
|
|
2246
2250
|
}
|
|
2247
2251
|
if (!t && !await this.hasPendingChanges())
|
|
2248
2252
|
throw new Error("No pending changes since last commit");
|
|
2249
|
-
const l =
|
|
2253
|
+
const l = i?.current ?? "0.0", c = $.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, f = ee(o, 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 = {
|
|
2250
2254
|
current: c,
|
|
2251
|
-
versions: [...
|
|
2255
|
+
versions: [...i?.versions ?? [], m]
|
|
2252
2256
|
};
|
|
2253
|
-
return n.file(u, JSON.stringify(f, null, 2)), await this.snapshotChangedStandards(
|
|
2257
|
+
return n.file(u, JSON.stringify(f, null, 2)), await this.snapshotChangedStandards(o, c), n.file("baseline/bep.json", JSON.stringify(o, null, 2)), await this.snapshotBaseStandards(o), n.file("changelog.json", JSON.stringify(p, null, 2)), m;
|
|
2254
2258
|
}
|
|
2255
2259
|
/**
|
|
2256
2260
|
* Reconstructs the BEP state at the given version (read-only).
|
|
@@ -2272,28 +2276,28 @@ class k {
|
|
|
2272
2276
|
if (!r) throw new Error(`Missing terminus: changelog/v${e}.json`);
|
|
2273
2277
|
return B(JSON.parse(await r.async("string")));
|
|
2274
2278
|
}
|
|
2275
|
-
const
|
|
2276
|
-
for (const r of
|
|
2279
|
+
const o = t.versions.filter((r) => $.compareVersions(r.version, e) > 0).sort((r, d) => $.compareVersions(d.version, r.version)), i = JSON.parse(JSON.stringify(this.getBep()));
|
|
2280
|
+
for (const r of o) {
|
|
2277
2281
|
if (!r.diff) break;
|
|
2278
2282
|
const d = this.getZip().file(r.diff);
|
|
2279
2283
|
if (!d) throw new Error(`Missing diff file: ${r.diff}`);
|
|
2280
2284
|
const l = JSON.parse(await d.async("string"));
|
|
2281
|
-
Z(
|
|
2285
|
+
Z(i, l);
|
|
2282
2286
|
}
|
|
2283
|
-
return B(
|
|
2287
|
+
return B(i);
|
|
2284
2288
|
}
|
|
2285
2289
|
/** Returns the RFC 6902 diff and standards summary between two versions. */
|
|
2286
2290
|
async compare(e, t) {
|
|
2287
|
-
const [n,
|
|
2291
|
+
const [n, o, i] = await Promise.all([
|
|
2288
2292
|
this.get(e),
|
|
2289
2293
|
this.get(t),
|
|
2290
2294
|
this.readChangelog()
|
|
2291
|
-
]), r =
|
|
2292
|
-
|
|
2293
|
-
const
|
|
2294
|
-
m.map(async (
|
|
2295
|
-
)).filter((
|
|
2296
|
-
return
|
|
2295
|
+
]), r = ee(n, o), d = new Set(n.standards.map((h) => h.id)), l = new Set(o.standards.map((h) => h.id)), c = o.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 = (i?.versions ?? []).filter((h) => $.compareVersions(h.version, e) > 0 && $.compareVersions(h.version, t) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
|
|
2296
|
+
o.standards.filter((h) => d.has(h.id)).map(async (h) => {
|
|
2297
|
+
const y = (await Promise.all(
|
|
2298
|
+
m.map(async (S) => p.file(`changelog/standards/${h.id}/v${S}.md`) !== null ? S : null)
|
|
2299
|
+
)).filter((S) => S !== null);
|
|
2300
|
+
return y.length > 0 ? { id: h.id, name: h.name, changedIn: y } : null;
|
|
2297
2301
|
})
|
|
2298
2302
|
)).filter((h) => h !== null);
|
|
2299
2303
|
return { diff: r, standards: { added: c, removed: u, contentModified: g } };
|
|
@@ -2305,14 +2309,14 @@ class k {
|
|
|
2305
2309
|
async discard() {
|
|
2306
2310
|
const e = this.getZip(), t = await this.readBaseline();
|
|
2307
2311
|
if (!t) throw new Error("No baseline found — call commit() first");
|
|
2308
|
-
const n = new Set(t.standards.map((
|
|
2309
|
-
for (const
|
|
2310
|
-
n.has(
|
|
2311
|
-
for (const
|
|
2312
|
-
const
|
|
2313
|
-
if (!
|
|
2314
|
-
const r = await
|
|
2315
|
-
e.file(
|
|
2312
|
+
const n = new Set(t.standards.map((o) => o.id));
|
|
2313
|
+
for (const o of this.getBep().standards)
|
|
2314
|
+
n.has(o.id) || e.remove(o.contentPath);
|
|
2315
|
+
for (const o of t.standards) {
|
|
2316
|
+
const i = e.file(`baseline/standards/${o.id}.md`);
|
|
2317
|
+
if (!i) continue;
|
|
2318
|
+
const r = await i.async("string");
|
|
2319
|
+
e.file(o.contentPath, r);
|
|
2316
2320
|
}
|
|
2317
2321
|
this.setBep(t);
|
|
2318
2322
|
}
|
|
@@ -2321,12 +2325,12 @@ class k {
|
|
|
2321
2325
|
* version and immediately commits it as a new version.
|
|
2322
2326
|
*/
|
|
2323
2327
|
async revert(e, t) {
|
|
2324
|
-
const n = this.getZip(),
|
|
2325
|
-
for (const
|
|
2326
|
-
const r = await this.resolveStandardContent(
|
|
2327
|
-
r !== null && n.file(
|
|
2328
|
+
const n = this.getZip(), o = await this.get(e);
|
|
2329
|
+
for (const i of o.standards) {
|
|
2330
|
+
const r = await this.resolveStandardContent(i, e);
|
|
2331
|
+
r !== null && n.file(i.contentPath, r);
|
|
2328
2332
|
}
|
|
2329
|
-
return this.setBep(
|
|
2333
|
+
return this.setBep(o), this.commit(t);
|
|
2330
2334
|
}
|
|
2331
2335
|
/**
|
|
2332
2336
|
* Returns a structured diff of the current BEP state vs the last committed baseline.
|
|
@@ -2335,17 +2339,17 @@ class k {
|
|
|
2335
2339
|
async status() {
|
|
2336
2340
|
const e = this.getZip(), t = await this.readBaseline();
|
|
2337
2341
|
if (!t) return { hasPendingChanges: !1, project: null, sections: {}, changedKeys: [], standards: [] };
|
|
2338
|
-
const n = this.getBep(),
|
|
2342
|
+
const n = this.getBep(), o = ks(n, t), i = [], r = new Map(t.standards.map((c) => [c.id, c])), d = new Set(n.standards.map((c) => c.id));
|
|
2339
2343
|
for (const c of n.standards)
|
|
2340
2344
|
if (!r.has(c.id))
|
|
2341
|
-
|
|
2345
|
+
i.push({ id: c.id, name: c.name, status: "added" });
|
|
2342
2346
|
else {
|
|
2343
2347
|
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") : "";
|
|
2344
|
-
u ?
|
|
2348
|
+
u ? i.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && i.push({ id: c.id, name: c.name, status: "content-modified" });
|
|
2345
2349
|
}
|
|
2346
2350
|
for (const c of t.standards)
|
|
2347
|
-
d.has(c.id) ||
|
|
2348
|
-
return { hasPendingChanges:
|
|
2351
|
+
d.has(c.id) || i.push({ id: c.id, name: c.name, status: "removed" });
|
|
2352
|
+
return { hasPendingChanges: o.changedKeys.length > 0 || i.length > 0, standards: i, ...o };
|
|
2349
2353
|
}
|
|
2350
2354
|
/** Shorthand — true if there are uncommitted changes since the last commit. */
|
|
2351
2355
|
async hasPendingChanges() {
|
|
@@ -2354,18 +2358,18 @@ class k {
|
|
|
2354
2358
|
/** Returns all versions sorted ascending, with author/approvedBy resolved to { email, name } objects. */
|
|
2355
2359
|
async listResolved() {
|
|
2356
2360
|
const [e, t] = await Promise.all([this.list(), this.current()]), n = this.getBep().members;
|
|
2357
|
-
return e.sort((
|
|
2358
|
-
version:
|
|
2359
|
-
type:
|
|
2360
|
-
date:
|
|
2361
|
-
description:
|
|
2362
|
-
diff:
|
|
2363
|
-
isCurrent:
|
|
2364
|
-
author:
|
|
2365
|
-
...
|
|
2366
|
-
approvedBy:
|
|
2367
|
-
email:
|
|
2368
|
-
name: n.find((r) => r.email ===
|
|
2361
|
+
return e.sort((o, i) => $.compareVersions(o.version, i.version)).map((o) => ({
|
|
2362
|
+
version: o.version,
|
|
2363
|
+
type: o.type,
|
|
2364
|
+
date: o.date,
|
|
2365
|
+
description: o.description,
|
|
2366
|
+
diff: o.diff,
|
|
2367
|
+
isCurrent: o.version === t,
|
|
2368
|
+
author: o.author ? { email: o.author, name: n.find((i) => i.email === o.author)?.name ?? null } : null,
|
|
2369
|
+
...o.type === "version" ? {
|
|
2370
|
+
approvedBy: o.approvedBy.map((i) => ({
|
|
2371
|
+
email: i,
|
|
2372
|
+
name: n.find((r) => r.email === i)?.name ?? null
|
|
2369
2373
|
}))
|
|
2370
2374
|
} : {}
|
|
2371
2375
|
}));
|
|
@@ -2375,8 +2379,8 @@ class k {
|
|
|
2375
2379
|
* Returns null if the standard did not exist at that version.
|
|
2376
2380
|
*/
|
|
2377
2381
|
async getStandardContent(e, t) {
|
|
2378
|
-
const
|
|
2379
|
-
return
|
|
2382
|
+
const o = (await this.get(t)).standards.find((i) => i.id === e);
|
|
2383
|
+
return o ? this.resolveStandardContent(o, t) : null;
|
|
2380
2384
|
}
|
|
2381
2385
|
/**
|
|
2382
2386
|
* ⚠️ Destructive: resets the BEP to a historical version and permanently
|
|
@@ -2385,12 +2389,12 @@ class k {
|
|
|
2385
2389
|
async reset(e) {
|
|
2386
2390
|
const t = this.getZip(), n = await this.readChangelog();
|
|
2387
2391
|
if (!n) throw new Error("No changelog found");
|
|
2388
|
-
const
|
|
2389
|
-
if (!
|
|
2392
|
+
const o = n.versions.find((c) => c.version === e), i = !!this.getZip().file(`changelog/v${e}.json`);
|
|
2393
|
+
if (!o && !i)
|
|
2390
2394
|
throw new Error(`Version not found: ${e}`);
|
|
2391
2395
|
if (e === n.current)
|
|
2392
2396
|
throw new Error(`Already at version ${e}`);
|
|
2393
|
-
const r = n.versions.filter((c) =>
|
|
2397
|
+
const r = n.versions.filter((c) => $.compareVersions(c.version, e) > 0), d = await this.get(e);
|
|
2394
2398
|
for (const c of d.standards) {
|
|
2395
2399
|
const u = await this.resolveStandardContent(c, e);
|
|
2396
2400
|
u !== null && t.file(c.contentPath, u);
|
|
@@ -2401,7 +2405,7 @@ class k {
|
|
|
2401
2405
|
const l = JSON.stringify(d, null, 2);
|
|
2402
2406
|
t.file("changelog.json", JSON.stringify({
|
|
2403
2407
|
current: e,
|
|
2404
|
-
versions: n.versions.filter((c) =>
|
|
2408
|
+
versions: n.versions.filter((c) => $.compareVersions(c.version, e) <= 0)
|
|
2405
2409
|
}, null, 2)), t.file("bep.json", l), t.file("baseline/bep.json", l), this.setBep(d);
|
|
2406
2410
|
}
|
|
2407
2411
|
/**
|
|
@@ -2414,20 +2418,20 @@ class k {
|
|
|
2414
2418
|
if (!n) throw new Error("No changelog found");
|
|
2415
2419
|
if (!/^\d+\.0$/.test(e.newBase))
|
|
2416
2420
|
throw new Error(`newBase must be in X.0 format (e.g. "2.0"), got "${e.newBase}"`);
|
|
2417
|
-
if (
|
|
2421
|
+
if ($.compareVersions(e.newBase, n.current) <= 0)
|
|
2418
2422
|
throw new Error(`newBase "${e.newBase}" must be greater than current version "${n.current}"`);
|
|
2419
|
-
const
|
|
2420
|
-
if (
|
|
2423
|
+
const o = this.getBep(), i = e.approvedBy.filter((d) => !o.members.some((l) => l.email === d));
|
|
2424
|
+
if (i.length) throw new Error(`Members not found: ${i.join(", ")}`);
|
|
2421
2425
|
for (const d of n.versions)
|
|
2422
2426
|
d.diff && t.remove(d.diff);
|
|
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(
|
|
2424
|
-
for (const d of
|
|
2427
|
+
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(o, null, 2));
|
|
2428
|
+
for (const d of o.standards) {
|
|
2425
2429
|
const l = t.file(d.contentPath);
|
|
2426
2430
|
if (!l) continue;
|
|
2427
2431
|
const c = await l.async("string");
|
|
2428
2432
|
t.file(`changelog/standards/${d.id}/v${e.newBase}.md`, c);
|
|
2429
2433
|
}
|
|
2430
|
-
t.file("baseline/bep.json", JSON.stringify(
|
|
2434
|
+
t.file("baseline/bep.json", JSON.stringify(o, null, 2)), await this.snapshotBaseStandards(o);
|
|
2431
2435
|
const r = {
|
|
2432
2436
|
version: e.newBase,
|
|
2433
2437
|
type: "version",
|
|
@@ -2477,52 +2481,58 @@ function Rs(s, e) {
|
|
|
2477
2481
|
}
|
|
2478
2482
|
}
|
|
2479
2483
|
function Ts(s, e, t, n) {
|
|
2480
|
-
const
|
|
2481
|
-
if (!
|
|
2482
|
-
const r = !!(
|
|
2484
|
+
const i = s.workflows.find((m) => m.id === t)?.diagram.nodes[e];
|
|
2485
|
+
if (!i || i.type !== "process") return !0;
|
|
2486
|
+
const r = !!(i.responsibleRoleIds?.length || i.responsibleTeamIds?.length || i.responsibleEmails?.length), d = !!(i.accountableRoleIds?.length || i.accountableTeamIds?.length || i.accountableEmails?.length);
|
|
2483
2487
|
if (!r && !d) return !0;
|
|
2484
2488
|
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
2489
|
if (g?.includes(n)) return !0;
|
|
2486
|
-
const h = !!m?.length,
|
|
2487
|
-
return
|
|
2490
|
+
const h = !!m?.length, y = !!p?.length;
|
|
2491
|
+
return y && h ? !!c && m.includes(c) && p.some((S) => u.has(S)) : y ? p.some((S) => u.has(S)) : h ? !!c && m.includes(c) : !1;
|
|
2488
2492
|
};
|
|
2489
|
-
return r && f(
|
|
2493
|
+
return r && f(i.responsibleRoleIds, i.responsibleTeamIds, i.responsibleEmails) || d && f(i.accountableRoleIds, i.accountableTeamIds, i.accountableEmails);
|
|
2490
2494
|
}
|
|
2491
2495
|
const js = { string: "string", number: "number", boolean: "boolean" };
|
|
2492
2496
|
function As(s, e, t) {
|
|
2493
2497
|
const n = s.events.find((d) => d.id === e);
|
|
2494
2498
|
if (!n?.payload?.length) return [];
|
|
2495
|
-
const
|
|
2499
|
+
const o = [], i = t ?? {};
|
|
2496
2500
|
for (const d of n.payload) {
|
|
2497
|
-
const l =
|
|
2501
|
+
const l = i[d.key];
|
|
2498
2502
|
if (l == null)
|
|
2499
|
-
d.required &&
|
|
2503
|
+
d.required && o.push({ field: d.key, reason: "missing" });
|
|
2500
2504
|
else {
|
|
2501
2505
|
const c = js[d.type];
|
|
2502
|
-
c && typeof l !== c
|
|
2506
|
+
if (c && typeof l !== c)
|
|
2507
|
+
o.push({ field: d.key, reason: "wrong_type" });
|
|
2508
|
+
else if (d.type === "string" && d.validation)
|
|
2509
|
+
try {
|
|
2510
|
+
new RegExp(d.validation.pattern, d.validation.flags).test(l) || o.push({ field: d.key, reason: "invalid_format" });
|
|
2511
|
+
} catch {
|
|
2512
|
+
}
|
|
2503
2513
|
}
|
|
2504
2514
|
}
|
|
2505
2515
|
const r = new Set(n.payload.map((d) => d.key));
|
|
2506
|
-
for (const d of Object.keys(
|
|
2507
|
-
r.has(d) ||
|
|
2508
|
-
return
|
|
2516
|
+
for (const d of Object.keys(i))
|
|
2517
|
+
r.has(d) || o.push({ field: d, reason: "unknown_field" });
|
|
2518
|
+
return o;
|
|
2509
2519
|
}
|
|
2510
2520
|
function Os(s, e) {
|
|
2511
2521
|
return !(!("triggerEventId" in s) || s.triggerEventId !== e.eventId);
|
|
2512
2522
|
}
|
|
2513
|
-
function _s(s, e, t, n,
|
|
2514
|
-
const
|
|
2515
|
-
if (!
|
|
2516
|
-
const r = Object.keys(
|
|
2517
|
-
(f) =>
|
|
2523
|
+
function _s(s, e, t, n, o) {
|
|
2524
|
+
const i = s.workflows.find((f) => f.id === e);
|
|
2525
|
+
if (!i) return null;
|
|
2526
|
+
const r = Object.keys(i.diagram.nodes).find(
|
|
2527
|
+
(f) => i.diagram.nodes[f].type === "start"
|
|
2518
2528
|
);
|
|
2519
2529
|
if (!r) return null;
|
|
2520
|
-
const d = Object.entries(
|
|
2530
|
+
const d = Object.entries(i.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();
|
|
2521
2531
|
return {
|
|
2522
2532
|
instance: {
|
|
2523
2533
|
id: globalThis.crypto.randomUUID(),
|
|
2524
2534
|
workflowId: e,
|
|
2525
|
-
bepVersion:
|
|
2535
|
+
bepVersion: o,
|
|
2526
2536
|
trackedAsset: t,
|
|
2527
2537
|
currentNodeId: l,
|
|
2528
2538
|
status: "active",
|
|
@@ -2534,14 +2544,14 @@ function _s(s, e, t, n, i) {
|
|
|
2534
2544
|
startEffects: c
|
|
2535
2545
|
};
|
|
2536
2546
|
}
|
|
2537
|
-
function
|
|
2547
|
+
function W(s, e, t, n) {
|
|
2538
2548
|
if (e.status !== "active")
|
|
2539
2549
|
return { ok: !1, error: "INSTANCE_NOT_ACTIVE" };
|
|
2540
2550
|
if (!n?.skipRaci && !Ts(s, e.currentNodeId, e.workflowId, t.actor))
|
|
2541
2551
|
return { ok: !1, error: "UNAUTHORIZED" };
|
|
2542
|
-
const
|
|
2543
|
-
if (!
|
|
2544
|
-
const { nodes:
|
|
2552
|
+
const o = s.workflows.find((N) => N.id === e.workflowId);
|
|
2553
|
+
if (!o) return { ok: !1, error: "NO_MATCHING_EDGE" };
|
|
2554
|
+
const { nodes: i, edges: r } = o.diagram;
|
|
2545
2555
|
let d = e.currentNodeId;
|
|
2546
2556
|
const l = [], c = [], u = [], f = Object.entries(r).filter(
|
|
2547
2557
|
([, N]) => N.from === d && Os(N, t)
|
|
@@ -2555,55 +2565,55 @@ function le(s, e, t, n) {
|
|
|
2555
2565
|
}
|
|
2556
2566
|
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;
|
|
2557
2567
|
let g = 0;
|
|
2558
|
-
for (;
|
|
2568
|
+
for (; i[d]?.type === "decision"; ) {
|
|
2559
2569
|
if (++g > $s) return { ok: !1, error: "DECISION_LOOP" };
|
|
2560
2570
|
const N = Object.entries(r).filter(([, v]) => v.from !== d || !("guard" in v) ? !1 : Rs(v.guard, t.payload ?? {}));
|
|
2561
2571
|
if (N.length === 0) break;
|
|
2562
|
-
const [j,
|
|
2563
|
-
l.push(ce(j, d,
|
|
2572
|
+
const [j, b] = N[0];
|
|
2573
|
+
l.push(ce(j, d, b.to, t, !0)), c.push(...(b.effectIds ?? []).map((v) => ({ effectId: v, fromEdgeId: j }))), u.push({ edgeId: j, fromNodeId: d, toNodeId: b.to }), d = b.to;
|
|
2564
2574
|
}
|
|
2565
|
-
const h =
|
|
2575
|
+
const h = i[d], y = h?.type === "end" ? "completed" : "active", S = {
|
|
2566
2576
|
...e,
|
|
2567
2577
|
currentNodeId: d,
|
|
2568
|
-
status:
|
|
2578
|
+
status: y,
|
|
2569
2579
|
history: [...e.history, ...l],
|
|
2570
2580
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2571
|
-
},
|
|
2572
|
-
return { ok: !0, instance:
|
|
2581
|
+
}, R = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId } : void 0;
|
|
2582
|
+
return { ok: !0, instance: S, transitionsApplied: u, effectsToFire: c, automationNodePending: R };
|
|
2573
2583
|
}
|
|
2574
2584
|
function Bs(s, e, t) {
|
|
2575
|
-
const n = s.workflows.find((
|
|
2576
|
-
s.teams.filter((
|
|
2577
|
-
), u = (
|
|
2578
|
-
const
|
|
2579
|
-
return
|
|
2580
|
-
}), f = (
|
|
2581
|
-
const
|
|
2582
|
-
return
|
|
2583
|
-
}), m = (
|
|
2584
|
-
roles: u(
|
|
2585
|
+
const n = s.workflows.find((b) => b.id === e.workflowId), { nodes: o, edges: i } = n.diagram, r = o[e.currentNodeId], l = s.members.find((b) => b.email === t)?.roleId, c = new Set(
|
|
2586
|
+
s.teams.filter((b) => (b.memberEmails ?? []).includes(t)).map((b) => b.id)
|
|
2587
|
+
), u = (b) => (b ?? []).flatMap((v) => {
|
|
2588
|
+
const k = s.roles.find((_) => _.id === v);
|
|
2589
|
+
return k ? [{ id: k.id, name: k.name }] : [];
|
|
2590
|
+
}), f = (b) => (b ?? []).flatMap((v) => {
|
|
2591
|
+
const k = s.teams.find((_) => _.id === v);
|
|
2592
|
+
return k ? [{ id: k.id, name: k.name }] : [];
|
|
2593
|
+
}), m = (b, v, k) => ({
|
|
2594
|
+
roles: u(b),
|
|
2585
2595
|
teams: f(v),
|
|
2586
|
-
emails:
|
|
2587
|
-
}), p = (
|
|
2588
|
-
if (
|
|
2589
|
-
const _ = !!
|
|
2590
|
-
return ie && _ ? !!l &&
|
|
2591
|
-
}, g = r.type === "process" ? r : null, h = !!(g?.responsibleRoleIds?.length || g?.responsibleTeamIds?.length || g?.responsibleEmails?.length),
|
|
2596
|
+
emails: k ?? []
|
|
2597
|
+
}), p = (b, v, k) => {
|
|
2598
|
+
if (k?.includes(t)) return !0;
|
|
2599
|
+
const _ = !!b?.length, ie = !!v?.length;
|
|
2600
|
+
return ie && _ ? !!l && b.includes(l) && v.some((J) => c.has(J)) : ie ? v.some((J) => c.has(J)) : _ ? !!l && b.includes(l) : !1;
|
|
2601
|
+
}, g = r.type === "process" ? r : null, h = !!(g?.responsibleRoleIds?.length || g?.responsibleTeamIds?.length || g?.responsibleEmails?.length), y = !!(g?.accountableRoleIds?.length || g?.accountableTeamIds?.length || g?.accountableEmails?.length), S = !h && !y || h && p(g?.responsibleRoleIds, g?.responsibleTeamIds, g?.responsibleEmails) || y && p(g?.accountableRoleIds, g?.accountableTeamIds, g?.accountableEmails), R = (b) => (s.events.find((v) => v.id === b)?.payload ?? []).map((v) => ({
|
|
2592
2602
|
key: v.key,
|
|
2593
2603
|
type: v.type,
|
|
2594
2604
|
required: v.required
|
|
2595
2605
|
})), N = [], j = [];
|
|
2596
|
-
for (const [
|
|
2606
|
+
for (const [b, v] of Object.entries(i)) {
|
|
2597
2607
|
if (v.from !== e.currentNodeId || !("triggerEventId" in v)) continue;
|
|
2598
|
-
const
|
|
2599
|
-
|
|
2600
|
-
edgeId:
|
|
2601
|
-
label: v.label ??
|
|
2602
|
-
emits:
|
|
2603
|
-
requiredPayload:
|
|
2608
|
+
const k = v.triggerEventId;
|
|
2609
|
+
S ? N.push({
|
|
2610
|
+
edgeId: b,
|
|
2611
|
+
label: v.label ?? k,
|
|
2612
|
+
emits: k,
|
|
2613
|
+
requiredPayload: R(k)
|
|
2604
2614
|
}) : j.push({
|
|
2605
|
-
edgeId:
|
|
2606
|
-
label: v.label ??
|
|
2615
|
+
edgeId: b,
|
|
2616
|
+
label: v.label ?? k,
|
|
2607
2617
|
reason: "UNAUTHORIZED",
|
|
2608
2618
|
required: m(
|
|
2609
2619
|
[...g?.responsibleRoleIds ?? [], ...g?.accountableRoleIds ?? []],
|
|
@@ -2629,7 +2639,7 @@ function Bs(s, e, t) {
|
|
|
2629
2639
|
isTerminal: r.type === "end"
|
|
2630
2640
|
};
|
|
2631
2641
|
}
|
|
2632
|
-
function ce(s, e, t, n,
|
|
2642
|
+
function ce(s, e, t, n, o) {
|
|
2633
2643
|
return {
|
|
2634
2644
|
id: globalThis.crypto.randomUUID(),
|
|
2635
2645
|
edgeId: s,
|
|
@@ -2638,7 +2648,7 @@ function ce(s, e, t, n, i) {
|
|
|
2638
2648
|
trigger: n,
|
|
2639
2649
|
actor: n.actor,
|
|
2640
2650
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2641
|
-
...
|
|
2651
|
+
...o ? { auto: !0 } : {}
|
|
2642
2652
|
};
|
|
2643
2653
|
}
|
|
2644
2654
|
class Ms {
|
|
@@ -2672,8 +2682,12 @@ class Ps {
|
|
|
2672
2682
|
getBep;
|
|
2673
2683
|
getHistoricalBep;
|
|
2674
2684
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2675
|
-
|
|
2685
|
+
_runtime;
|
|
2676
2686
|
storage;
|
|
2687
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2688
|
+
get runtime() {
|
|
2689
|
+
return this._runtime;
|
|
2690
|
+
}
|
|
2677
2691
|
skipRaci = !1;
|
|
2678
2692
|
transitionListeners = [];
|
|
2679
2693
|
createdListeners = [];
|
|
@@ -2692,7 +2706,7 @@ class Ps {
|
|
|
2692
2706
|
* Returns `this` for chaining.
|
|
2693
2707
|
*/
|
|
2694
2708
|
init(e) {
|
|
2695
|
-
return this.
|
|
2709
|
+
return this._runtime = e.runtime, this.storage = e.storage ?? new Ms(), this.skipRaci = e.events?.skipRaci ?? !1, this;
|
|
2696
2710
|
}
|
|
2697
2711
|
// ─── Lifecycle listeners ─────────────────────────────────────────────────────
|
|
2698
2712
|
/** Fires after every successful emit() — all listeners run concurrently. */
|
|
@@ -2719,12 +2733,29 @@ class Ps {
|
|
|
2719
2733
|
*/
|
|
2720
2734
|
async createInstance(e, t, n) {
|
|
2721
2735
|
this._assertInit();
|
|
2722
|
-
const
|
|
2736
|
+
const o = this.getBep(), r = _s(o, e, t, n, "unversioned");
|
|
2723
2737
|
if (!r) return null;
|
|
2724
2738
|
const { instance: d, startEffects: l } = r;
|
|
2725
|
-
for (const
|
|
2726
|
-
await this._executeEffect(d,
|
|
2727
|
-
|
|
2739
|
+
for (const h of l)
|
|
2740
|
+
await this._executeEffect(d, h);
|
|
2741
|
+
const u = o.workflows.find((h) => h.id === e)?.diagram.nodes[d.currentNodeId];
|
|
2742
|
+
let f = u?.type === "automation" && u.automationId ? { automationId: u.automationId } : void 0, m = d;
|
|
2743
|
+
const p = 10;
|
|
2744
|
+
let g = 0;
|
|
2745
|
+
for (; f && g++ < p; ) {
|
|
2746
|
+
const { automationId: h } = f, { eventId: y, ...S } = await this._executeAutomationNode(m, h), R = W(o, m, {
|
|
2747
|
+
eventId: y,
|
|
2748
|
+
actor: "_system",
|
|
2749
|
+
softwareId: "_system",
|
|
2750
|
+
payload: S
|
|
2751
|
+
});
|
|
2752
|
+
if (!R.ok) break;
|
|
2753
|
+
m = R.instance;
|
|
2754
|
+
for (const N of R.effectsToFire ?? [])
|
|
2755
|
+
await this._executeEffect(m, N);
|
|
2756
|
+
f = R.automationNodePending;
|
|
2757
|
+
}
|
|
2758
|
+
return await this.storage.saveInstance(m), await this._fire(this.createdListeners, m), m;
|
|
2728
2759
|
}
|
|
2729
2760
|
/**
|
|
2730
2761
|
* Emits an event against a workflow instance.
|
|
@@ -2741,25 +2772,25 @@ class Ps {
|
|
|
2741
2772
|
this._assertInit();
|
|
2742
2773
|
const n = await this.storage.getInstance(e);
|
|
2743
2774
|
if (!n) return { ok: !1, error: "NO_MATCHING_EDGE" };
|
|
2744
|
-
const
|
|
2745
|
-
let
|
|
2746
|
-
if (!
|
|
2747
|
-
const r = [...
|
|
2748
|
-
let l =
|
|
2749
|
-
for (const f of
|
|
2775
|
+
const o = await this._resolveBep(n.bepVersion);
|
|
2776
|
+
let i = W(o, n, t, { skipRaci: this.skipRaci });
|
|
2777
|
+
if (!i.ok) return { ok: !1, error: i.error, payloadErrors: i.payloadErrors };
|
|
2778
|
+
const r = [...i.transitionsApplied ?? []], d = [];
|
|
2779
|
+
let l = i.instance;
|
|
2780
|
+
for (const f of i.effectsToFire ?? [])
|
|
2750
2781
|
d.push(await this._executeEffect(l, f));
|
|
2751
2782
|
const c = 10;
|
|
2752
2783
|
let u = 0;
|
|
2753
|
-
for (;
|
|
2754
|
-
const { automationId: f } =
|
|
2755
|
-
if (
|
|
2784
|
+
for (; i.automationNodePending && u++ < c; ) {
|
|
2785
|
+
const { automationId: f } = i.automationNodePending, { eventId: m, ...p } = await this._executeAutomationNode(l, f);
|
|
2786
|
+
if (i = W(o, l, {
|
|
2756
2787
|
eventId: m,
|
|
2757
2788
|
actor: "_system",
|
|
2758
2789
|
softwareId: "_system",
|
|
2759
2790
|
payload: p
|
|
2760
|
-
}), !
|
|
2761
|
-
l =
|
|
2762
|
-
for (const g of
|
|
2791
|
+
}), !i.ok) break;
|
|
2792
|
+
l = i.instance, r.push(...i.transitionsApplied ?? []);
|
|
2793
|
+
for (const g of i.effectsToFire ?? [])
|
|
2763
2794
|
d.push(await this._executeEffect(l, g));
|
|
2764
2795
|
}
|
|
2765
2796
|
return await this.storage.saveInstance(l), await this._fire(this.transitionListeners, l, r, d), l.status === "completed" && await this._fire(this.completedListeners, l), {
|
|
@@ -2780,11 +2811,11 @@ class Ps {
|
|
|
2780
2811
|
*/
|
|
2781
2812
|
async getInstances(e) {
|
|
2782
2813
|
this._assertInit();
|
|
2783
|
-
const { pendingActionFor: t, ...n } = e ?? {},
|
|
2784
|
-
if (!t) return
|
|
2785
|
-
const
|
|
2786
|
-
return r ?
|
|
2787
|
-
const l =
|
|
2814
|
+
const { pendingActionFor: t, ...n } = e ?? {}, o = await this.storage.listInstances(n);
|
|
2815
|
+
if (!t) return o;
|
|
2816
|
+
const i = this.getBep(), r = i.members.find((d) => d.email === t);
|
|
2817
|
+
return r ? o.filter((d) => {
|
|
2818
|
+
const l = i.workflows.find((m) => m.id === d.workflowId);
|
|
2788
2819
|
if (!l) return !1;
|
|
2789
2820
|
const c = l.diagram.nodes[d.currentNodeId];
|
|
2790
2821
|
if (!c) return !1;
|
|
@@ -2803,8 +2834,8 @@ class Ps {
|
|
|
2803
2834
|
this._assertInit();
|
|
2804
2835
|
const n = await this.storage.getInstance(e);
|
|
2805
2836
|
if (!n) return null;
|
|
2806
|
-
const
|
|
2807
|
-
return Bs(
|
|
2837
|
+
const o = await this._resolveBep(n.bepVersion);
|
|
2838
|
+
return Bs(o, n, t);
|
|
2808
2839
|
}
|
|
2809
2840
|
async deleteInstance(e) {
|
|
2810
2841
|
this._assertInit(), await this.storage.deleteInstance(e);
|
|
@@ -2815,10 +2846,10 @@ class Ps {
|
|
|
2815
2846
|
*/
|
|
2816
2847
|
async getRemoteData(e) {
|
|
2817
2848
|
this._assertInit();
|
|
2818
|
-
const n = this.getBep().remoteData.find((
|
|
2849
|
+
const n = this.getBep().remoteData.find((o) => o.id === e);
|
|
2819
2850
|
if (!n) throw new Error(`Remote data "${e}" not found in BEP`);
|
|
2820
2851
|
if (!n.resolverId) throw new Error(`Remote data "${e}" has no resolver assigned`);
|
|
2821
|
-
return this.
|
|
2852
|
+
return this._runtime._runResolver(n.resolverId, n.url);
|
|
2822
2853
|
}
|
|
2823
2854
|
// ─── Internal ────────────────────────────────────────────────────────────────
|
|
2824
2855
|
_assertInit() {
|
|
@@ -2833,23 +2864,23 @@ class Ps {
|
|
|
2833
2864
|
}
|
|
2834
2865
|
_resolveFromHistory(e, t) {
|
|
2835
2866
|
for (let n = t.length - 1; n >= 0; n--) {
|
|
2836
|
-
const
|
|
2837
|
-
if (e in
|
|
2867
|
+
const o = t[n].trigger.payload ?? {};
|
|
2868
|
+
if (e in o) return o[e];
|
|
2838
2869
|
}
|
|
2839
2870
|
}
|
|
2840
2871
|
async _executeAutomationNode(e, t) {
|
|
2841
|
-
const
|
|
2872
|
+
const i = this.getBep().automations.find((l) => l.id === t)?.payload ?? [], r = Object.fromEntries(i.map((l) => [l.key, this._resolveFromHistory(l.key, e.history)])), d = this._runtime.automations[t];
|
|
2842
2873
|
if (!d) throw new Error(`No handler declared for automation "${t}"`);
|
|
2843
2874
|
return d(e, r);
|
|
2844
2875
|
}
|
|
2845
2876
|
async _executeEffect(e, t) {
|
|
2846
|
-
const
|
|
2877
|
+
const i = this.getBep().effects.find((c) => c.id === t.effectId)?.payload ?? [], r = i.filter((c) => c.required && this._resolveFromHistory(c.key, e.history) === void 0).map((c) => c.key);
|
|
2847
2878
|
if (r.length > 0)
|
|
2848
2879
|
return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped", missingFields: r };
|
|
2849
|
-
const d = this.
|
|
2880
|
+
const d = this._runtime.effects[t.effectId];
|
|
2850
2881
|
if (!d)
|
|
2851
2882
|
return { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "skipped" };
|
|
2852
|
-
const l = Object.fromEntries(
|
|
2883
|
+
const l = Object.fromEntries(i.map((c) => [c.key, this._resolveFromHistory(c.key, e.history)]));
|
|
2853
2884
|
try {
|
|
2854
2885
|
return await d(e, l), { effectId: t.effectId, fromEdgeId: t.fromEdgeId, status: "executed" };
|
|
2855
2886
|
} catch (c) {
|
|
@@ -2861,14 +2892,14 @@ class Ps {
|
|
|
2861
2892
|
function zs(s, e) {
|
|
2862
2893
|
const t = /* @__PURE__ */ new Map();
|
|
2863
2894
|
for (const n of s) {
|
|
2864
|
-
const
|
|
2865
|
-
for (const
|
|
2866
|
-
t.has(
|
|
2895
|
+
const o = [e(n)].flat();
|
|
2896
|
+
for (const i of o)
|
|
2897
|
+
t.has(i) || t.set(i, []), t.get(i).push(n);
|
|
2867
2898
|
}
|
|
2868
|
-
return Array.from(t.entries()).map(([n,
|
|
2899
|
+
return Array.from(t.entries()).map(([n, o]) => ({ key: n, rows: o }));
|
|
2869
2900
|
}
|
|
2870
2901
|
function Zs(s, e = "responsible", t = {}) {
|
|
2871
|
-
const { topologicalSort: n = !1 } = t,
|
|
2902
|
+
const { topologicalSort: n = !1 } = t, o = (m) => `_${m}`, i = "#444444", r = Object.entries(s.nodes), d = r.find(([, m]) => m.type === "start")?.[0], l = r.find(([, m]) => m.type === "end")?.[0];
|
|
2872
2903
|
let c;
|
|
2873
2904
|
if (n && d) {
|
|
2874
2905
|
const m = /* @__PURE__ */ new Set(), p = [d], g = [];
|
|
@@ -2876,8 +2907,8 @@ function Zs(s, e = "responsible", t = {}) {
|
|
|
2876
2907
|
const h = p.shift();
|
|
2877
2908
|
if (!m.has(h)) {
|
|
2878
2909
|
m.add(h), g.push(h);
|
|
2879
|
-
for (const
|
|
2880
|
-
|
|
2910
|
+
for (const y of Object.values(s.edges))
|
|
2911
|
+
y.from === h && !m.has(y.to) && p.push(y.to);
|
|
2881
2912
|
}
|
|
2882
2913
|
}
|
|
2883
2914
|
for (const [h] of r)
|
|
@@ -2895,14 +2926,14 @@ function Zs(s, e = "responsible", t = {}) {
|
|
|
2895
2926
|
for (const m of c) {
|
|
2896
2927
|
const p = s.nodes[m];
|
|
2897
2928
|
if (!p) continue;
|
|
2898
|
-
const g = p.type === "start" || p.type === "end",
|
|
2899
|
-
g ? u.push(` ${
|
|
2900
|
-
const N = p[e].roles[0]?.color ??
|
|
2901
|
-
g ? u.push(` style ${
|
|
2929
|
+
const g = p.type === "start" || p.type === "end", y = (p.type === "decision" ? p.label ?? m : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, """), S = g || p.type === "decision" ? [] : p[e].roles.map((j) => j.name), R = S.length > 0 ? `"<b>${S.join(" · ")}</b><br/>${y}"` : `"${y || m}"`;
|
|
2930
|
+
g ? u.push(` ${o(m)}([${y || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${o(m)}{${R}}`) : p.type === "automation" ? u.push(` ${o(m)}[[${R}]]`) : u.push(` ${o(m)}(${R})`);
|
|
2931
|
+
const N = p[e].roles[0]?.color ?? i;
|
|
2932
|
+
g ? u.push(` style ${o(m)} fill:#2962FF,stroke:none`) : u.push(` style ${o(m)} fill:none,stroke:${N},stroke-width:3px`);
|
|
2902
2933
|
}
|
|
2903
2934
|
const f = n ? c.flatMap((m) => Object.values(s.edges).filter((p) => p.from === m)) : Object.values(s.edges);
|
|
2904
2935
|
for (const m of f)
|
|
2905
|
-
m.label ? u.push(` ${
|
|
2936
|
+
m.label ? u.push(` ${o(m.from)} -->|${m.label}| ${o(m.to)}`) : u.push(` ${o(m.from)} --> ${o(m.to)}`);
|
|
2906
2937
|
return u.join(`
|
|
2907
2938
|
`);
|
|
2908
2939
|
}
|
|
@@ -2936,22 +2967,22 @@ class D {
|
|
|
2936
2967
|
const n = () => this._data;
|
|
2937
2968
|
this.project = new jt(
|
|
2938
2969
|
() => this._data.project,
|
|
2939
|
-
(
|
|
2940
|
-
this._data.project =
|
|
2970
|
+
(o) => {
|
|
2971
|
+
this._data.project = o;
|
|
2941
2972
|
},
|
|
2942
2973
|
fe,
|
|
2943
|
-
(
|
|
2944
|
-
const r = [], d = x("project",
|
|
2945
|
-
return d && r.push(d),
|
|
2974
|
+
(o, i) => {
|
|
2975
|
+
const r = [], d = x("project", o.code, i.deliverableNamingConvention);
|
|
2976
|
+
return d && r.push(d), o.clientId && !i.teams.some((l) => l.id === o.clientId) && r.push(`teams["${o.clientId}"] not found`), r;
|
|
2946
2977
|
},
|
|
2947
2978
|
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
|
|
2979
|
+
), 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 Xt(n), this.extensions = new Gt(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 os(n, () => this.assetTypes), this.standards = new is(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(
|
|
2949
2980
|
() => this._data,
|
|
2950
|
-
(
|
|
2951
|
-
), this.history = new
|
|
2981
|
+
(o) => this.history.get(o)
|
|
2982
|
+
), this.history = new $(
|
|
2952
2983
|
n,
|
|
2953
|
-
(
|
|
2954
|
-
this._data =
|
|
2984
|
+
(o) => {
|
|
2985
|
+
this._data = o;
|
|
2955
2986
|
},
|
|
2956
2987
|
() => this._zip
|
|
2957
2988
|
), 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);
|
|
@@ -3011,10 +3042,10 @@ class D {
|
|
|
3011
3042
|
* fully operational after open(). Idempotent — existing files are untouched.
|
|
3012
3043
|
*/
|
|
3013
3044
|
static async open(e) {
|
|
3014
|
-
const t = await
|
|
3045
|
+
const t = await re.loadAsync(e), n = t.file("bep.json");
|
|
3015
3046
|
if (!n) throw new Error("Invalid .bep file: missing bep.json");
|
|
3016
|
-
const
|
|
3017
|
-
return await D._initialize(
|
|
3047
|
+
const o = await n.async("string"), i = B(JSON.parse(o));
|
|
3048
|
+
return await D._initialize(i, t), new D(i, t);
|
|
3018
3049
|
}
|
|
3019
3050
|
/**
|
|
3020
3051
|
* Ensures all expected files exist in the zip.
|
|
@@ -3034,9 +3065,9 @@ class D {
|
|
|
3034
3065
|
if (!t.file("baseline/bep.json")) {
|
|
3035
3066
|
const n = JSON.stringify(e, null, 2);
|
|
3036
3067
|
t.file("baseline/bep.json", n), t.file("changelog/v0.0.json", n);
|
|
3037
|
-
for (const
|
|
3038
|
-
const
|
|
3039
|
-
t.file(`baseline/standards/${
|
|
3068
|
+
for (const o of e.standards) {
|
|
3069
|
+
const i = await t.file(o.contentPath).async("string");
|
|
3070
|
+
t.file(`baseline/standards/${o.id}.md`, i), t.file(`changelog/standards/${o.id}/v0.0.md`, i);
|
|
3040
3071
|
}
|
|
3041
3072
|
}
|
|
3042
3073
|
}
|
|
@@ -3070,8 +3101,8 @@ class D {
|
|
|
3070
3101
|
flags: [],
|
|
3071
3102
|
env: [],
|
|
3072
3103
|
automations: []
|
|
3073
|
-
}), n = new
|
|
3074
|
-
return n.file("memory.md", ""), n.file("skills/bep-authoring/SKILL.md", ""), n.file("baseline/bep.json",
|
|
3104
|
+
}), n = new re(), o = JSON.stringify(t, null, 2);
|
|
3105
|
+
return n.file("memory.md", ""), n.file("skills/bep-authoring/SKILL.md", ""), n.file("baseline/bep.json", o), n.file("changelog/v0.0.json", o), new D(t, n);
|
|
3075
3106
|
}
|
|
3076
3107
|
// ─── Accessors ────────────────────────────────────────────────────────────
|
|
3077
3108
|
get data() {
|
|
@@ -3120,8 +3151,8 @@ ${n.join(`
|
|
|
3120
3151
|
/** Returns the names of all resource files for the given skill. */
|
|
3121
3152
|
listSkillResources(e) {
|
|
3122
3153
|
const t = `skills/${e}/resources/`, n = [];
|
|
3123
|
-
return this._zip.forEach((
|
|
3124
|
-
|
|
3154
|
+
return this._zip.forEach((o) => {
|
|
3155
|
+
o.startsWith(t) && o !== t && n.push(o.slice(t.length));
|
|
3125
3156
|
}), n;
|
|
3126
3157
|
}
|
|
3127
3158
|
/** Returns the content of a resource file for the given skill, or null if it does not exist. */
|
|
@@ -3136,9 +3167,9 @@ ${n.join(`
|
|
|
3136
3167
|
/** Removes a skill's SKILL.md and all its resources from the archive. No-op if not found. */
|
|
3137
3168
|
removeSkill(e) {
|
|
3138
3169
|
const t = `skills/${e}/`, n = [];
|
|
3139
|
-
this._zip.forEach((
|
|
3140
|
-
|
|
3141
|
-
}), n.forEach((
|
|
3170
|
+
this._zip.forEach((o) => {
|
|
3171
|
+
o.startsWith(t) && n.push(o);
|
|
3172
|
+
}), n.forEach((o) => this._zip.remove(o));
|
|
3142
3173
|
}
|
|
3143
3174
|
/** Removes a single resource file from a skill. No-op if not found. */
|
|
3144
3175
|
removeSkillResource(e, t) {
|
|
@@ -3155,12 +3186,12 @@ ${n.join(`
|
|
|
3155
3186
|
* writeFileSync('bep.d.ts', bep.generateRuntimeTypes())
|
|
3156
3187
|
*/
|
|
3157
3188
|
generateRuntimeTypes() {
|
|
3158
|
-
const e = (f) => f
|
|
3159
|
-
`, n = (f) => `{ ${f.map((m) => `${m.key}${m.required ? "" : "?"}: ${e(m.type)}`).join("; ")} }`,
|
|
3189
|
+
const e = (f) => f, t = (f) => ` /** ${f} */
|
|
3190
|
+
`, n = (f) => `{ ${f.map((m) => `${m.key}${m.required ? "" : "?"}: ${e(m.type)}`).join("; ")} }`, o = (f) => !f.payload || f.payload.length === 0 ? "() => void" : `(payload: ${n(f.payload)}) => void`, i = (f) => {
|
|
3160
3191
|
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("; ")} }`;
|
|
3161
3192
|
return `(${m}) => ${p}`;
|
|
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}': ${
|
|
3163
|
-
`) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${
|
|
3193
|
+
}, 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}': ${o(f)}`).join(`
|
|
3194
|
+
`) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${t(f.description)} '${f.id}': ${i(f)}`).join(`
|
|
3164
3195
|
`) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((f) => `${t(f.description)} '${f.id}': ${r(f)}`).join(`
|
|
3165
3196
|
`) : " [key: string]: (url: string) => unknown", u = this._data.env.length ? this._data.env.map((f) => `${t(f.description)} ${f.key}: string`).join(`
|
|
3166
3197
|
`) : " [key: string]: string";
|
|
@@ -3220,10 +3251,10 @@ export {
|
|
|
3220
3251
|
Ye as AnnexType,
|
|
3221
3252
|
_t as Annexes,
|
|
3222
3253
|
Ie as AssetTypeSchema,
|
|
3223
|
-
|
|
3254
|
+
Xt as AssetTypes,
|
|
3224
3255
|
Mt as Automations,
|
|
3225
3256
|
Ls as BEPSchema,
|
|
3226
|
-
|
|
3257
|
+
ae as BEPVersionBase,
|
|
3227
3258
|
St as BEPVersionSchema,
|
|
3228
3259
|
Se as BIMUseSchema,
|
|
3229
3260
|
zt as BIMUses,
|
|
@@ -3234,17 +3265,17 @@ export {
|
|
|
3234
3265
|
Nt as DeliverableBaseSchema,
|
|
3235
3266
|
De as DeliverableSchema,
|
|
3236
3267
|
Dt as Deliverables,
|
|
3237
|
-
|
|
3268
|
+
be as DisciplineSchema,
|
|
3238
3269
|
Zt as Disciplines,
|
|
3239
3270
|
ht as EdgeGuardSchema,
|
|
3240
3271
|
Bt as Effects,
|
|
3241
3272
|
Ps as Engine,
|
|
3242
|
-
|
|
3273
|
+
w as Entity,
|
|
3243
3274
|
xt as Env,
|
|
3244
3275
|
Le as EnvVarSchema,
|
|
3245
3276
|
Pt as Events,
|
|
3246
3277
|
ve as ExtensionSchema,
|
|
3247
|
-
|
|
3278
|
+
Gt as Extensions,
|
|
3248
3279
|
Et as FlagBaseSchema,
|
|
3249
3280
|
st as FlagEntityType,
|
|
3250
3281
|
Ce as FlagSchema,
|
|
@@ -3255,9 +3286,9 @@ export {
|
|
|
3255
3286
|
yt as FlowDecisionEdgeSchema,
|
|
3256
3287
|
ft as FlowDecisionNodeSchema,
|
|
3257
3288
|
vt as FlowDiagramSchema,
|
|
3258
|
-
|
|
3289
|
+
wt as FlowDirectEdgeSchema,
|
|
3259
3290
|
et as FlowDirection,
|
|
3260
|
-
|
|
3291
|
+
bt as FlowEdgeSchema,
|
|
3261
3292
|
Re as FlowEffectSchema,
|
|
3262
3293
|
ct as FlowEndNodeSchema,
|
|
3263
3294
|
$e as FlowEventSchema,
|
|
@@ -3268,10 +3299,10 @@ export {
|
|
|
3268
3299
|
gt as FlowTransitionEdgeSchema,
|
|
3269
3300
|
_e as GuideSchema,
|
|
3270
3301
|
Jt as Guides,
|
|
3271
|
-
|
|
3302
|
+
$ as History,
|
|
3272
3303
|
He as ISORole,
|
|
3273
3304
|
rt as LBSNodeBaseSchema,
|
|
3274
|
-
|
|
3305
|
+
we as LBSNodeSchema,
|
|
3275
3306
|
Qe as LBSNodeType,
|
|
3276
3307
|
Ht as LBSNodes,
|
|
3277
3308
|
Me as LODSchema,
|
|
@@ -3287,8 +3318,8 @@ export {
|
|
|
3287
3318
|
ye as MilestoneSchema,
|
|
3288
3319
|
Qt as Milestones,
|
|
3289
3320
|
he as NamingConventionSchema,
|
|
3290
|
-
|
|
3291
|
-
|
|
3321
|
+
it as NamingSegmentSchema,
|
|
3322
|
+
ot as NamingTokenSchema,
|
|
3292
3323
|
at as NodeTimeoutSchema,
|
|
3293
3324
|
Ds as NodeType,
|
|
3294
3325
|
Ct as Nomenclature,
|
|
@@ -3308,9 +3339,9 @@ export {
|
|
|
3308
3339
|
Js as Runtime,
|
|
3309
3340
|
jt as Singleton,
|
|
3310
3341
|
Ee as SoftwareSchema,
|
|
3311
|
-
|
|
3342
|
+
os as Softwares,
|
|
3312
3343
|
Be as StandardSchema,
|
|
3313
|
-
|
|
3344
|
+
is as Standards,
|
|
3314
3345
|
nt as TeamBaseSchema,
|
|
3315
3346
|
pe as TeamSchema,
|
|
3316
3347
|
rs as Teams,
|
|
@@ -3319,13 +3350,13 @@ export {
|
|
|
3319
3350
|
ds as Workflows,
|
|
3320
3351
|
Ns as arrayDefs,
|
|
3321
3352
|
qe as buildCodeMap,
|
|
3322
|
-
|
|
3353
|
+
X as buildConsecutivoMap,
|
|
3323
3354
|
C as buildParentMap,
|
|
3324
3355
|
ks as diffBep,
|
|
3325
3356
|
Ss as diffEntities,
|
|
3326
3357
|
Zs as flowDiagramToMermaid,
|
|
3327
3358
|
Ke as getNomenCode,
|
|
3328
|
-
|
|
3359
|
+
se as getRootIds,
|
|
3329
3360
|
Rt as getTokenPattern,
|
|
3330
3361
|
zs as groupRaciRows,
|
|
3331
3362
|
B as normalizeBep,
|