@dotbep/core 0.2.15 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +20 -18
  2. package/dist/index.js +378 -385
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ const Ge = r.enum([
4
4
  "appointing-party",
5
5
  "lead-appointed-party",
6
6
  "appointed-party"
7
- ]), Xe = r.enum(["video", "document"]), Ve = r.enum(["zone", "location"]), He = r.enum(["LR", "TB"]), xs = r.enum(["start", "end", "process", "decision", "automation"]), Ye = r.enum(["info", "warning", "blocking"]), Qe = r.enum([
7
+ ]), Xe = r.enum(["video", "document"]), Ve = r.enum(["zone", "location"]), He = r.enum(["LR", "TB"]), Ms = r.enum(["start", "end", "process", "decision", "automation"]), Ye = r.enum(["info", "warning", "blocking"]), Qe = r.enum([
8
8
  "roles",
9
9
  "members",
10
10
  "teams",
@@ -98,10 +98,10 @@ const Ge = r.enum([
98
98
  }), ge = r.object({
99
99
  id: r.string().min(1).describe("Used in deliverables nomenclature."),
100
100
  name: r.string().min(1)
101
- }).describe("A project discipline used to classify deliverables and information requirements. Represents a technical domain such as structure, architecture, or MEP."), ye = r.object({
101
+ }).describe("A project discipline used to classify deliverables and information requirements. Represents a technical domain such as structure, architecture, or MEP."), we = r.object({
102
102
  id: r.string().min(1),
103
103
  name: r.string().min(1)
104
- }).describe("A file format or extension accepted for deliverables, such as IFC, PDF, or DWG. Used to specify the required output formats per deliverable."), we = r.object({
104
+ }).describe("A file format or extension accepted for deliverables, such as IFC, PDF, or DWG. Used to specify the required output formats per deliverable."), ye = r.object({
105
105
  id: r.string().min(1).describe("Used in deliverables nomenclature."),
106
106
  name: r.string().min(1),
107
107
  extensionIds: r.array(r.string()).optional()
@@ -137,16 +137,16 @@ const Ge = r.enum([
137
137
  validation: r.object({ pattern: r.string().min(1), flags: r.string().optional() }).optional(),
138
138
  validationMessage: r.string().optional(),
139
139
  options: r.array(r.string().min(1)).optional()
140
- }), Se = r.object({
140
+ }), ke = r.object({
141
141
  id: r.string().min(1).describe('Human-readable slug, e.g. "status-changed".'),
142
142
  name: r.string().min(1),
143
143
  payload: r.array(L).optional()
144
- }).describe("A signal that advances a workflow instance from one node to the next. Carries a typed payload that moves the workflow instance forward and can be evaluated by decision guards."), Ne = r.object({
144
+ }).describe("A signal that advances a workflow instance from one node to the next. Carries a typed payload that moves the workflow instance forward and can be evaluated by decision guards."), Se = r.object({
145
145
  id: r.string().min(1).describe('Human-readable slug, e.g. "notify".'),
146
146
  name: r.string().min(1),
147
147
  description: r.string().min(1).describe("Describe exactly what this effect must do so the runtime developer knows what to implement: what action it performs and what external system or service it calls."),
148
148
  payload: r.array(L).optional()
149
- }).describe("A fire-and-forget side effect triggered on a workflow edge. Executed by the runtime when the edge is traversed, using fields from the instance context as payload."), ke = r.object({
149
+ }).describe("A fire-and-forget side effect triggered on a workflow edge. Executed by the runtime when the edge is traversed, using fields from the instance context as payload."), Ne = r.object({
150
150
  id: r.string().min(1).describe('Human-readable slug, e.g. "verify-tolerances".'),
151
151
  name: r.string().min(1),
152
152
  description: r.string().min(1).describe("Describe what this handler checks and what decision it produces: what condition or business rule it evaluates and where that data comes from."),
@@ -222,7 +222,7 @@ const Ge = r.enum([
222
222
  triggerEventId: r.string().min(1).describe("ref FlowEvent.id — the event that fires this transition")
223
223
  }), pt = Y.extend({
224
224
  guard: ut.describe("Condition evaluated against the instance context to determine which path to take.")
225
- }), ht = Y, gt = r.union([mt, pt, ht]), yt = r.object({
225
+ }), ht = Y, gt = r.union([mt, pt, ht]), wt = r.object({
226
226
  direction: He.default("LR"),
227
227
  nodes: r.record(r.string(), ft),
228
228
  edges: r.record(r.string(), gt)
@@ -259,12 +259,12 @@ const Ge = r.enum([
259
259
  for (const [a, d] of Object.entries(n.edges)) {
260
260
  const l = n.nodes[d.from];
261
261
  if (!l) continue;
262
- const c = "triggerEventId" in d, u = "guard" in d;
263
- l.type === "start" && (c || u) && e.addIssue({
262
+ const c = "triggerEventId" in d, f = "guard" in d;
263
+ l.type === "start" && (c || f) && e.addIssue({
264
264
  code: "custom",
265
265
  message: "Edges from start nodes cannot have a trigger or guard — instance creation is the implicit trigger.",
266
266
  path: ["edges", a]
267
- }), l.type === "decision" && !u && e.addIssue({
267
+ }), l.type === "decision" && !f && e.addIssue({
268
268
  code: "custom",
269
269
  message: "Edges from decision nodes must have a guard — all paths must be explicit.",
270
270
  path: ["edges", a, "guard"]
@@ -276,7 +276,7 @@ const Ge = r.enum([
276
276
  code: "custom",
277
277
  message: `Edges from ${l.type} nodes must have a trigger.`,
278
278
  path: ["edges", a, "triggerEventId"]
279
- }), (l.type === "process" || l.type === "automation") && u && e.addIssue({
279
+ }), (l.type === "process" || l.type === "automation") && f && e.addIssue({
280
280
  code: "custom",
281
281
  message: `Edges from ${l.type} nodes cannot have a guard — use a decision node to branch.`,
282
282
  path: ["edges", a, "guard"]
@@ -288,14 +288,14 @@ const Ge = r.enum([
288
288
  description: r.string().optional(),
289
289
  example: r.string().optional().describe("Narrative example showcasing one cycle of this workflow."),
290
290
  trackedAssetTypeId: r.string().optional().describe("ref AssetType.id"),
291
- diagram: yt
291
+ diagram: wt
292
292
  }).describe("A reusable process definition associated with one or more BIM uses. Describes the ordered steps, responsibilities, and transitions that govern how work is carried out."), Re = r.object({
293
293
  id: r.uuid(),
294
294
  name: r.string().min(1),
295
295
  type: Xe,
296
296
  url: r.string().min(1),
297
297
  description: r.string().optional()
298
- }).describe("Supporting material attached to the BEP, such as a reference document or instructional video."), je = r.object({
298
+ }).describe("Supporting material attached to the BEP, such as a reference document or instructional video."), Te = r.object({
299
299
  id: r.uuid(),
300
300
  name: r.string().min(1),
301
301
  description: r.string().optional().describe("Short guide description, not it's content"),
@@ -305,7 +305,7 @@ const Ge = r.enum([
305
305
  name: r.string().min(1),
306
306
  description: r.string().optional(),
307
307
  contentPath: r.string().describe("Relative path to the .md file inside the .bep archive.")
308
- }).describe("A normative reference or rule that governs how work is carried out on the project. Standards define what must be followed, as opposed to guides which explain how."), Te = r.object({
308
+ }).describe("A normative reference or rule that governs how work is carried out on the project. Standards define what must be followed, as opposed to guides which explain how."), je = r.object({
309
309
  id: r.string().min(1),
310
310
  name: r.string().min(1),
311
311
  checklist: r.array(r.string()).optional()
@@ -313,17 +313,17 @@ const Ge = r.enum([
313
313
  id: r.string().min(1),
314
314
  name: r.string().min(1),
315
315
  checklist: r.array(r.string()).optional()
316
- }).describe("An information detail level assigned to model elements in LOIN requirements. Specifies the non-geometric properties required of a model element at a given milestone."), wt = r.object({
316
+ }).describe("An information detail level assigned to model elements in LOIN requirements. Specifies the non-geometric properties required of a model element at a given milestone."), yt = r.object({
317
317
  milestoneId: r.string(),
318
318
  lodId: r.string().min(1),
319
319
  loiId: r.string().min(1),
320
320
  idsPath: r.string().optional().describe("Relative path to the .ids (Information Delivery Specification) file inside the .bep archive.")
321
- }), Me = r.object({
321
+ }), Be = r.object({
322
322
  id: r.uuid(),
323
323
  element: r.string().min(1),
324
324
  disciplineId: r.string(),
325
- milestones: r.array(wt).optional()
326
- }).describe("An information requirement for a model element. Declares what geometric detail and information properties are required for a specific model element and discipline across project milestones."), Be = r.object({
325
+ milestones: r.array(yt).optional()
326
+ }).describe("An information requirement for a model element. Declares what geometric detail and information properties are required for a specific model element and discipline across project milestones."), xe = r.object({
327
327
  id: r.uuid(),
328
328
  message: r.string().min(1),
329
329
  memberEmail: r.email(),
@@ -335,7 +335,7 @@ const Ge = r.enum([
335
335
  severity: Ye,
336
336
  message: r.string().min(1),
337
337
  generatedAt: r.iso.datetime()
338
- }).describe("A diagnostic message attached to the BEP or one of its entities. Indicates an issue or observation with a severity level that guides the author."), xe = vt.refine((n) => n.entity === null == (n.entityId === null), {
338
+ }).describe("A diagnostic message attached to the BEP or one of its entities. Indicates an issue or observation with a severity level that guides the author."), Me = vt.refine((n) => n.entity === null == (n.entityId === null), {
339
339
  message: "entity and entityId must both be null (BEP-level) or both be non-null (entity-level)."
340
340
  }), bt = r.object({
341
341
  id: r.uuid(),
@@ -378,28 +378,28 @@ const Ge = r.enum([
378
378
  milestones: r.array(pe),
379
379
  lbs: r.array(he),
380
380
  disciplines: r.array(ge),
381
- extensions: r.array(ye),
382
- assetTypes: r.array(we),
381
+ extensions: r.array(we),
382
+ assetTypes: r.array(ye),
383
383
  softwares: r.array(ve),
384
384
  objectives: r.array(be),
385
385
  bimUses: r.array(Ie),
386
386
  actions: r.array(Ee),
387
- events: r.array(Se),
388
- effects: r.array(Ne),
389
- automations: r.array(ke),
387
+ events: r.array(ke),
388
+ effects: r.array(Se),
389
+ automations: r.array(Ne),
390
390
  env: r.array(Fe),
391
391
  resolvers: r.array(Le),
392
392
  remoteData: r.array(Ce),
393
393
  workflows: r.array($e),
394
- guides: r.array(je),
394
+ guides: r.array(Te),
395
395
  annexes: r.array(Re),
396
396
  standards: r.array(Ae),
397
- lods: r.array(Te),
397
+ lods: r.array(je),
398
398
  lois: r.array(Oe),
399
- loin: r.array(Me),
399
+ loin: r.array(Be),
400
400
  deliverables: r.array(Pe),
401
- notes: r.array(Be),
402
- flags: r.array(xe)
401
+ notes: r.array(xe),
402
+ flags: r.array(Me)
403
403
  }), ne = r.object({
404
404
  version: r.string().regex(/^\d+\.\d+$/).describe('Format: "{major}.{minor}" (e.g. "1.0", "2.3").'),
405
405
  date: r.iso.datetime(),
@@ -419,21 +419,21 @@ const Ge = r.enum([
419
419
  function j(n) {
420
420
  return n.roles ??= [], n.members ??= [], n.teams ??= [], n.phases ??= [], n.milestones ??= [], n.lbs ??= [], n.disciplines ??= [], n.extensions ??= [], n.assetTypes ??= [], n.softwares ??= [], n.objectives ??= [], n.bimUses ??= [], n.actions ??= [], n.events ??= [], n.effects ??= [], n.workflows ??= [], n.guides ??= [], n.annexes ??= [], n.standards ??= [], n.lods ??= [], n.lois ??= [], n.loin ??= [], n.deliverables ??= [], n.notes ??= [], n.flags ??= [], n.env ??= [], n.automations ??= [], n.resolvers ??= [], n.remoteData ??= [], n;
421
421
  }
422
- const Et = "-", St = "^[A-Z0-9]{3}$";
423
- function Nt(n, e) {
422
+ const Et = "-", kt = "^[A-Z0-9]{3}$";
423
+ function St(n, e) {
424
424
  if (e) {
425
425
  const s = e.segments.find((t) => t.type === "field" && t.token === n);
426
426
  if (s?.type === "field" && s.pattern) return s.pattern;
427
427
  }
428
- return St;
428
+ return kt;
429
429
  }
430
- function T(n, e, s) {
431
- const t = s?.delimiter ?? Et, i = Nt(n, s);
430
+ function B(n, e, s) {
431
+ const t = s?.delimiter ?? Et, i = St(n, s);
432
432
  return new RegExp(i).test(e) ? e.includes(t) ? `"${e}" contains the naming delimiter "${t}"` : null : `"${e}" does not match naming pattern ${i} for token "${n}"`;
433
433
  }
434
- function kt(n, e) {
434
+ function Nt(n, e) {
435
435
  const s = [], t = (i, o) => {
436
- const a = T(i, o, e);
436
+ const a = B(i, o, e);
437
437
  a && s.push(a);
438
438
  };
439
439
  t("project", n.project.code);
@@ -554,7 +554,7 @@ class y {
554
554
  const a = String(o[this.idField] ?? "(unknown)");
555
555
  try {
556
556
  const d = this.config.schema.parse(o);
557
- if (this.getItems().some((u) => this.getId(u) === this.getId(d)))
557
+ if (this.getItems().some((f) => this.getId(f) === this.getId(d)))
558
558
  throw new Error(`Already exists: ${this.getId(d)}`);
559
559
  const l = ie(d, this.config.key, this.getBep());
560
560
  if (l.length) throw new Error(l.join("; "));
@@ -581,8 +581,8 @@ class y {
581
581
  continue;
582
582
  }
583
583
  try {
584
- const c = this.config.schema.parse({ ...a[d], ...i }), u = this.config.validate?.(c, this.getBep()) ?? [];
585
- if (u.length) throw new Error(u.join("; "));
584
+ const c = this.config.schema.parse({ ...a[d], ...i }), f = this.config.validate?.(c, this.getBep()) ?? [];
585
+ if (f.length) throw new Error(f.join("; "));
586
586
  a[d] = c, s.push(a[d]);
587
587
  } catch (c) {
588
588
  t.push({ id: o, error: z(c) });
@@ -628,7 +628,7 @@ class Rt extends y {
628
628
  );
629
629
  }
630
630
  }
631
- class jt extends y {
631
+ class Tt extends y {
632
632
  constructor(e) {
633
633
  super(
634
634
  () => e().annexes,
@@ -648,7 +648,7 @@ class At extends y {
648
648
  e,
649
649
  {
650
650
  key: "effects",
651
- schema: Ne,
651
+ schema: Se,
652
652
  beforeRemove: (s, t) => {
653
653
  for (const i of t.workflows) {
654
654
  for (const [o, a] of Object.entries(i.diagram.nodes))
@@ -663,14 +663,14 @@ class At extends y {
663
663
  );
664
664
  }
665
665
  }
666
- class Tt extends y {
666
+ class jt extends y {
667
667
  constructor(e) {
668
668
  super(
669
669
  () => e().automations,
670
670
  e,
671
671
  {
672
672
  key: "automations",
673
- schema: ke,
673
+ schema: Ne,
674
674
  beforeRemove: (s, t) => {
675
675
  for (const i of t.workflows)
676
676
  for (const [o, a] of Object.entries(i.diagram.nodes))
@@ -694,14 +694,14 @@ class Ot extends y {
694
694
  );
695
695
  }
696
696
  }
697
- class Mt extends y {
697
+ class Bt extends y {
698
698
  constructor(e) {
699
699
  super(
700
700
  () => e().events,
701
701
  e,
702
702
  {
703
703
  key: "events",
704
- schema: Se,
704
+ schema: ke,
705
705
  beforeRemove: (s, t) => {
706
706
  for (const i of t.workflows)
707
707
  for (const [o, a] of Object.entries(i.diagram.edges))
@@ -741,7 +741,7 @@ function Ue(n, e) {
741
741
  }
742
742
  return { zoneCode: "ZZZ", locationCode: o.id };
743
743
  }
744
- function Bt(n) {
744
+ function xt(n) {
745
745
  const e = [], s = new Map(n.map((d) => [d.id, d])), t = Q(n);
746
746
  for (const d of t) {
747
747
  const l = s.get(d);
@@ -773,7 +773,7 @@ function K(n) {
773
773
  }
774
774
  return e;
775
775
  }
776
- const x = "XXX";
776
+ const M = "XXX";
777
777
  function ze(n, e, s, t, i) {
778
778
  const { zoneCode: o, locationCode: a } = Ue(n.lbsNodeId, t);
779
779
  if (!i) {
@@ -787,13 +787,13 @@ function ze(n, e, s, t, i) {
787
787
  }
788
788
  switch (l.token) {
789
789
  case "project":
790
- return e || x;
790
+ return e || M;
791
791
  case "team":
792
- return n.responsibleId || x;
792
+ return n.responsibleId || M;
793
793
  case "discipline":
794
- return n.disciplineId || x;
794
+ return n.disciplineId || M;
795
795
  case "assetType":
796
- return n.assetTypeId || x;
796
+ return n.assetTypeId || M;
797
797
  case "lbsZone":
798
798
  return o;
799
799
  case "lbsLocation":
@@ -808,7 +808,7 @@ function Ze(n, e, s, t) {
808
808
  ze(o, e, i, s, t)
809
809
  ]));
810
810
  }
811
- class xt {
811
+ class Mt {
812
812
  constructor(e) {
813
813
  this.getBep = e;
814
814
  }
@@ -858,9 +858,9 @@ class Pt extends y {
858
858
  nomenclatureCode: s.get(l.id) ?? "",
859
859
  effectiveDate: l.dueDate ?? c?.date ?? "",
860
860
  lbsNode: l.lbsNodeId ? o.get(l.lbsNodeId) ?? null : null,
861
- discipline: e.disciplines.find((u) => u.id === l.disciplineId) ?? null,
861
+ discipline: e.disciplines.find((f) => f.id === l.disciplineId) ?? null,
862
862
  assetType: i.get(l.assetTypeId) ?? null,
863
- extensions: (l.extensionIds ?? []).map((u) => e.extensions.find((f) => f.id === u)).filter(Boolean),
863
+ extensions: (l.extensionIds ?? []).map((f) => e.extensions.find((u) => u.id === f)).filter(Boolean),
864
864
  responsible: t.get(l.responsibleId) ?? null,
865
865
  milestone: c,
866
866
  predecessor: null
@@ -881,7 +881,7 @@ class Ft extends y {
881
881
  e,
882
882
  {
883
883
  key: "flags",
884
- schema: xe,
884
+ schema: Me,
885
885
  autoId: !0
886
886
  }
887
887
  );
@@ -894,7 +894,7 @@ class Lt extends y {
894
894
  e,
895
895
  {
896
896
  key: "notes",
897
- schema: Be,
897
+ schema: xe,
898
898
  autoId: !0
899
899
  }
900
900
  ), this.getMembers = s;
@@ -953,7 +953,7 @@ class Dt extends y {
953
953
  key: "disciplines",
954
954
  schema: ge,
955
955
  validate: (s, t) => {
956
- const i = T("discipline", s.id, t.deliverableNamingConvention);
956
+ const i = B("discipline", s.id, t.deliverableNamingConvention);
957
957
  return i ? [i] : [];
958
958
  }
959
959
  }
@@ -967,7 +967,7 @@ class Ut extends y {
967
967
  e,
968
968
  {
969
969
  key: "guides",
970
- schema: je,
970
+ schema: Te,
971
971
  autoId: !0
972
972
  }
973
973
  );
@@ -987,7 +987,7 @@ class zt extends y {
987
987
  e,
988
988
  {
989
989
  key: "lods",
990
- schema: Te,
990
+ schema: je,
991
991
  beforeRemove: (s, t) => {
992
992
  for (const i of t.loin)
993
993
  if (i.milestones?.find((a) => a.lodId === s)) throw new Error(`Referenced by: loin["${i.id}"].milestones[lodId=${s}]`);
@@ -1019,7 +1019,7 @@ class Jt extends y {
1019
1019
  e,
1020
1020
  {
1021
1021
  key: "loin",
1022
- schema: Me,
1022
+ schema: Be,
1023
1023
  autoId: !0,
1024
1024
  validate: (s, t) => {
1025
1025
  const i = [];
@@ -1038,7 +1038,7 @@ class Jt extends y {
1038
1038
  t.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1039
1039
  continue;
1040
1040
  }
1041
- const a = i.milestones.find((c) => (o.milestones ?? []).some((u) => u.milestoneId === c.milestoneId));
1041
+ const a = i.milestones.find((c) => (o.milestones ?? []).some((f) => f.milestoneId === c.milestoneId));
1042
1042
  if (a) {
1043
1043
  t.push({ loinId: i.loinId, error: `Milestone "${a.milestoneId}" already exists. Use updateMilestones to modify it.` });
1044
1044
  continue;
@@ -1055,31 +1055,31 @@ class Jt extends y {
1055
1055
  updateMilestones(e) {
1056
1056
  const s = [], t = [];
1057
1057
  for (const i of e) {
1058
- const o = this.getBep().loin.find((f) => f.id === i.loinId);
1058
+ const o = this.getBep().loin.find((u) => u.id === i.loinId);
1059
1059
  if (!o) {
1060
1060
  t.push({ loinId: i.loinId, error: `Not found: ${i.loinId}` });
1061
1061
  continue;
1062
1062
  }
1063
- const a = i.milestones.find((f) => !(o.milestones ?? []).some((m) => m.milestoneId === f.milestoneId));
1063
+ const a = i.milestones.find((u) => !(o.milestones ?? []).some((m) => m.milestoneId === u.milestoneId));
1064
1064
  if (a) {
1065
1065
  t.push({ loinId: i.loinId, error: `Milestone "${a.milestoneId}" not found. Use addMilestones to create it.` });
1066
1066
  continue;
1067
1067
  }
1068
- const d = new Map(o.milestones.map((f) => [f.milestoneId, { lodId: f.lodId, loiId: f.loiId, idsPath: f.idsPath }])), l = (o.milestones ?? []).map((f) => {
1069
- const m = i.milestones.find((p) => p.milestoneId === f.milestoneId);
1070
- return m ? { ...f, ...m } : f;
1068
+ const d = new Map(o.milestones.map((u) => [u.milestoneId, { lodId: u.lodId, loiId: u.loiId, idsPath: u.idsPath }])), l = (o.milestones ?? []).map((u) => {
1069
+ const m = i.milestones.find((p) => p.milestoneId === u.milestoneId);
1070
+ return m ? { ...u, ...m } : u;
1071
1071
  }), c = this.update([{ id: i.loinId, milestones: l }]);
1072
1072
  if (c.failed.length > 0) {
1073
1073
  t.push({ loinId: i.loinId, error: c.failed[0].error });
1074
1074
  continue;
1075
1075
  }
1076
- const u = this.getBep().loin.find((f) => f.id === i.loinId);
1076
+ const f = this.getBep().loin.find((u) => u.id === i.loinId);
1077
1077
  s.push({
1078
1078
  loinId: i.loinId,
1079
1079
  element: o.element,
1080
- milestones: i.milestones.map((f) => {
1081
- const m = u.milestones.find((g) => g.milestoneId === f.milestoneId), p = d.get(f.milestoneId);
1082
- return { milestoneId: f.milestoneId, before: p, after: { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath } };
1080
+ milestones: i.milestones.map((u) => {
1081
+ const m = f.milestones.find((g) => g.milestoneId === u.milestoneId), p = d.get(u.milestoneId);
1082
+ return { milestoneId: u.milestoneId, before: p, after: { lodId: m.lodId, loiId: m.loiId, idsPath: m.idsPath } };
1083
1083
  })
1084
1084
  });
1085
1085
  }
@@ -1123,9 +1123,9 @@ class Kt extends y {
1123
1123
  e,
1124
1124
  {
1125
1125
  key: "assetTypes",
1126
- schema: we,
1126
+ schema: ye,
1127
1127
  validate: (s, t) => {
1128
- const i = T("assetType", s.id, t.deliverableNamingConvention);
1128
+ const i = B("assetType", s.id, t.deliverableNamingConvention);
1129
1129
  return i ? [i] : [];
1130
1130
  }
1131
1131
  }
@@ -1146,7 +1146,7 @@ class qt extends y {
1146
1146
  e,
1147
1147
  {
1148
1148
  key: "extensions",
1149
- schema: ye
1149
+ schema: we
1150
1150
  }
1151
1151
  );
1152
1152
  }
@@ -1183,7 +1183,7 @@ class Gt extends y {
1183
1183
  key: "lbs",
1184
1184
  schema: he,
1185
1185
  validate: (s, t) => {
1186
- const i = [], o = s.type === "zone" ? "lbsZone" : "lbsLocation", a = T(o, s.id, t.deliverableNamingConvention);
1186
+ const i = [], o = s.type === "zone" ? "lbsZone" : "lbsLocation", a = B(o, s.id, t.deliverableNamingConvention);
1187
1187
  if (a && i.push(a), s.type === "location" && s.lbsNodeIds?.length) {
1188
1188
  const d = new Map(t.lbs.map((l) => [l.id, l]));
1189
1189
  for (const l of s.lbsNodeIds ?? [])
@@ -1213,7 +1213,7 @@ class Gt extends y {
1213
1213
  i.push({ input: o, error: 'Root nodes (no parentId) must be type "zone".' });
1214
1214
  continue;
1215
1215
  }
1216
- if (o.parentId && !s.lbs.find((f) => f.id === o.parentId)) {
1216
+ if (o.parentId && !s.lbs.find((u) => u.id === o.parentId)) {
1217
1217
  i.push({ input: o, error: `No LBS node found with ID "${o.parentId}".` });
1218
1218
  continue;
1219
1219
  }
@@ -1223,13 +1223,13 @@ class Gt extends y {
1223
1223
  continue;
1224
1224
  }
1225
1225
  let c;
1226
- a && (c = s.lbs.find((f) => f.id === a), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(o.id)));
1227
- const u = this.validateTree();
1228
- if (u.length > 0) {
1229
- s.lbs.splice(s.lbs.findIndex((f) => f.id === o.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((f) => f !== o.id)), i.push({ input: o, error: u.join("; ") });
1226
+ a && (c = s.lbs.find((u) => u.id === a), c && (c.lbsNodeIds ??= [], c.lbsNodeIds.push(o.id)));
1227
+ const f = this.validateTree();
1228
+ if (f.length > 0) {
1229
+ s.lbs.splice(s.lbs.findIndex((u) => u.id === o.id), 1), c?.lbsNodeIds && (c.lbsNodeIds = c.lbsNodeIds.filter((u) => u !== o.id)), i.push({ input: o, error: f.join("; ") });
1230
1230
  continue;
1231
1231
  }
1232
- t.push({ ...s.lbs.find((f) => f.id === o.id), parentId: a ?? null });
1232
+ t.push({ ...s.lbs.find((u) => u.id === o.id), parentId: a ?? null });
1233
1233
  }
1234
1234
  return { succeeded: t, failed: i };
1235
1235
  }
@@ -1244,27 +1244,27 @@ class Gt extends y {
1244
1244
  i.push({ id: o.id, error: "A node cannot be its own parent." });
1245
1245
  continue;
1246
1246
  }
1247
- const a = s.lbs.find((h) => h.id === o.id), d = P(s.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, u = this.update([c]);
1248
- if (u.failed.length > 0) {
1249
- i.push({ id: o.id, error: u.failed[0].error });
1247
+ const a = s.lbs.find((h) => h.id === o.id), d = P(s.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, f = this.update([c]);
1248
+ if (f.failed.length > 0) {
1249
+ i.push({ id: o.id, error: f.failed[0].error });
1250
1250
  continue;
1251
1251
  }
1252
- const f = { name: a.name, type: a.type, description: a.description, parentId: d }, m = s.lbs.find((h) => h.id === o.id);
1252
+ const u = { name: a.name, type: a.type, description: a.description, parentId: d }, m = s.lbs.find((h) => h.id === o.id);
1253
1253
  if (l !== void 0) {
1254
1254
  for (const h of s.lbs)
1255
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((w) => w !== o.id));
1255
+ h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((k) => k !== o.id));
1256
1256
  if (l) {
1257
- const h = s.lbs.find((w) => w.id === l);
1257
+ const h = s.lbs.find((k) => k.id === l);
1258
1258
  h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id);
1259
1259
  }
1260
1260
  }
1261
1261
  const p = this.validateTree();
1262
1262
  if (p.length > 0) {
1263
- if (m.name = f.name, m.type = f.type, f.description !== void 0 ? m.description = f.description : delete m.description, l !== void 0) {
1263
+ if (m.name = u.name, m.type = u.type, u.description !== void 0 ? m.description = u.description : delete m.description, l !== void 0) {
1264
1264
  for (const h of s.lbs)
1265
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((w) => w !== o.id));
1266
- if (f.parentId) {
1267
- const h = s.lbs.find((w) => w.id === f.parentId);
1265
+ h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((k) => k !== o.id));
1266
+ if (u.parentId) {
1267
+ const h = s.lbs.find((k) => k.id === u.parentId);
1268
1268
  h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id));
1269
1269
  }
1270
1270
  }
@@ -1272,7 +1272,7 @@ class Gt extends y {
1272
1272
  continue;
1273
1273
  }
1274
1274
  const g = P(s.lbs).get(m.id) ?? null;
1275
- t.push({ id: o.id, before: f, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
1275
+ t.push({ id: o.id, before: u, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
1276
1276
  }
1277
1277
  return { succeeded: t, failed: i };
1278
1278
  }
@@ -1282,7 +1282,7 @@ class Gt extends y {
1282
1282
  }
1283
1283
  /** Validates the full LBS tree and returns a list of structural errors. */
1284
1284
  validateTree() {
1285
- return Bt(this.list());
1285
+ return xt(this.list());
1286
1286
  }
1287
1287
  }
1288
1288
  class Xt extends y {
@@ -1317,14 +1317,14 @@ class Xt extends y {
1317
1317
  t.push({ input: i, error: `Team not found: ${i.teamId}` });
1318
1318
  continue;
1319
1319
  }
1320
- const { teamId: d, isRepresentative: l, ...c } = i, u = this.add([c]);
1321
- if (u.failed.length > 0) {
1322
- t.push({ input: i, error: u.failed[0].error });
1320
+ const { teamId: d, isRepresentative: l, ...c } = i, f = this.add([c]);
1321
+ if (f.failed.length > 0) {
1322
+ t.push({ input: i, error: f.failed[0].error });
1323
1323
  continue;
1324
1324
  }
1325
1325
  a.memberEmails ??= [], a.memberEmails.includes(i.email) || a.memberEmails.push(i.email), l && (a.representativeEmail = i.email);
1326
- const f = this.listResolved().find((m) => m.email === i.email);
1327
- s.push(f);
1326
+ const u = this.listResolved().find((m) => m.email === i.email);
1327
+ s.push(u);
1328
1328
  }
1329
1329
  return { succeeded: s, failed: t };
1330
1330
  }
@@ -1332,7 +1332,7 @@ class Xt extends y {
1332
1332
  const s = [], t = [];
1333
1333
  for (const i of e) {
1334
1334
  const o = this.getBep(), { teamId: a, isRepresentative: d, ...l } = i;
1335
- if (a !== void 0 && !o.teams.find((f) => f.id === a)) {
1335
+ if (a !== void 0 && !o.teams.find((u) => u.id === a)) {
1336
1336
  t.push({ email: i.email, error: `Team not found: ${a}` });
1337
1337
  continue;
1338
1338
  }
@@ -1342,15 +1342,15 @@ class Xt extends y {
1342
1342
  continue;
1343
1343
  }
1344
1344
  if (a !== void 0) {
1345
- const f = o.teams.find((p) => p.id === a), m = o.teams.find((p) => (p.memberEmails ?? []).includes(i.email));
1346
- m && m.id !== a && (m.memberEmails = (m.memberEmails ?? []).filter((p) => p !== i.email), m.representativeEmail === i.email && (m.representativeEmail = void 0)), f.memberEmails ??= [], f.memberEmails.includes(i.email) || f.memberEmails.push(i.email);
1345
+ const u = o.teams.find((p) => p.id === a), m = o.teams.find((p) => (p.memberEmails ?? []).includes(i.email));
1346
+ m && m.id !== a && (m.memberEmails = (m.memberEmails ?? []).filter((p) => p !== i.email), m.representativeEmail === i.email && (m.representativeEmail = void 0)), u.memberEmails ??= [], u.memberEmails.includes(i.email) || u.memberEmails.push(i.email);
1347
1347
  }
1348
1348
  if (d !== void 0) {
1349
- const f = o.teams.find((m) => (m.memberEmails ?? []).includes(i.email));
1350
- f && (f.representativeEmail = d ? i.email : f.representativeEmail === i.email ? void 0 : f.representativeEmail);
1349
+ const u = o.teams.find((m) => (m.memberEmails ?? []).includes(i.email));
1350
+ u && (u.representativeEmail = d ? i.email : u.representativeEmail === i.email ? void 0 : u.representativeEmail);
1351
1351
  }
1352
- const u = this.listResolved().find((f) => f.email === i.email);
1353
- s.push({ email: i.email, after: u });
1352
+ const f = this.listResolved().find((u) => u.email === i.email);
1353
+ s.push({ email: i.email, after: f });
1354
1354
  }
1355
1355
  return { succeeded: s, failed: t };
1356
1356
  }
@@ -1538,7 +1538,7 @@ class ns extends y {
1538
1538
  key: "teams",
1539
1539
  schema: fe,
1540
1540
  validate: (t, i) => {
1541
- const o = [], a = T("team", t.id, i.deliverableNamingConvention);
1541
+ const o = [], a = B("team", t.id, i.deliverableNamingConvention);
1542
1542
  return a && o.push(a), t.representativeEmail && !(t.memberEmails ?? []).includes(t.representativeEmail) && o.push(`representativeEmail "${t.representativeEmail}" is not a member of this team`), o;
1543
1543
  },
1544
1544
  beforeRemove: (t, i) => {
@@ -1563,20 +1563,20 @@ function is(n, e, s) {
1563
1563
  const t = [];
1564
1564
  for (const [l, c] of Object.entries(n.nodes))
1565
1565
  if (c.type === "process") {
1566
- c.actionId && !e.actions.some((u) => u.id === c.actionId) && t.push(`actions["${c.actionId}"] not found (node: ${l})`);
1567
- for (const u of ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"])
1568
- for (const f of c[u] ?? [])
1569
- e.roles.some((m) => m.id === f) || t.push(`roles["${f}"] not found (node: ${l}.${u})`);
1566
+ c.actionId && !e.actions.some((f) => f.id === c.actionId) && t.push(`actions["${c.actionId}"] not found (node: ${l})`);
1567
+ for (const f of ["responsibleRoleIds", "accountableRoleIds", "consultedRoleIds", "informedRoleIds"])
1568
+ for (const u of c[f] ?? [])
1569
+ e.roles.some((m) => m.id === u) || t.push(`roles["${u}"] not found (node: ${l}.${f})`);
1570
1570
  }
1571
1571
  for (const [l, c] of Object.entries(n.edges)) {
1572
- n.nodes[c.from] || t.push(`edge "${l}": from node "${c.from}" not found`), n.nodes[c.to] || t.push(`edge "${l}": to node "${c.to}" not found`), "triggerEventId" in c && !e.events.some((u) => u.id === c.triggerEventId) && t.push(`events["${c.triggerEventId}"] not found (edge: ${l})`);
1573
- for (const u of c.effectIds ?? [])
1574
- e.effects.some((f) => f.id === u) || t.push(`effects["${u}"] not found (edge: ${l})`);
1572
+ n.nodes[c.from] || t.push(`edge "${l}": from node "${c.from}" not found`), n.nodes[c.to] || t.push(`edge "${l}": to node "${c.to}" not found`), "triggerEventId" in c && !e.events.some((f) => f.id === c.triggerEventId) && t.push(`events["${c.triggerEventId}"] not found (edge: ${l})`);
1573
+ for (const f of c.effectIds ?? [])
1574
+ e.effects.some((u) => u.id === f) || t.push(`effects["${f}"] not found (edge: ${l})`);
1575
1575
  }
1576
1576
  for (const [l, c] of Object.entries(n.nodes))
1577
- if (c.type === "automation" && !e.automations.some((u) => u.id === c.automationId) && t.push(`automations["${c.automationId}"] not found (node: ${l})`), c.type === "process" && c.workflowId && (c.workflowId === s ? t.push(`node "${l}" references its own workflow — would cause infinite recursion`) : e.workflows.some((u) => u.id === c.workflowId) || t.push(`workflows["${c.workflowId}"] not found (node: ${l})`)), (c.type === "process" || c.type === "automation") && c.timeouts)
1578
- for (const u of c.timeouts)
1579
- e.effects.some((f) => f.id === u.effectId) || t.push(`effects["${u.effectId}"] not found (node: ${l}.timeouts)`);
1577
+ if (c.type === "automation" && !e.automations.some((f) => f.id === c.automationId) && t.push(`automations["${c.automationId}"] not found (node: ${l})`), c.type === "process" && c.workflowId && (c.workflowId === s ? t.push(`node "${l}" references its own workflow — would cause infinite recursion`) : e.workflows.some((f) => f.id === c.workflowId) || t.push(`workflows["${c.workflowId}"] not found (node: ${l})`)), (c.type === "process" || c.type === "automation") && c.timeouts)
1578
+ for (const f of c.timeouts)
1579
+ e.effects.some((u) => u.id === f.effectId) || t.push(`effects["${f.effectId}"] not found (node: ${l}.timeouts)`);
1580
1580
  const i = Object.keys(n.nodes), o = new Set(Object.values(n.edges).map((l) => l.to)), a = new Set(Object.values(n.edges).map((l) => l.from));
1581
1581
  for (const l of i)
1582
1582
  n.nodes[l].type !== "start" && (o.has(l) || t.push(`node "${l}" is unreachable — no edges point to it`));
@@ -1589,23 +1589,23 @@ function is(n, e, s) {
1589
1589
  }
1590
1590
  for (const [l, c] of Object.entries(n.nodes)) {
1591
1591
  if (c.type !== "decision") continue;
1592
- const u = /* @__PURE__ */ new Set();
1593
- for (const f of d[l] ?? []) {
1594
- const m = n.edges[f], p = n.nodes[m.from];
1592
+ const f = /* @__PURE__ */ new Set();
1593
+ for (const u of d[l] ?? []) {
1594
+ const m = n.edges[u], p = n.nodes[m.from];
1595
1595
  if (p) {
1596
1596
  if (p.type === "automation") {
1597
1597
  const g = e.automations.find((h) => h.id === p.automationId);
1598
- for (const h of g?.output ?? []) u.add(h.key);
1598
+ for (const h of g?.output ?? []) f.add(h.key);
1599
1599
  }
1600
1600
  if (p.type === "process" && "triggerEventId" in m) {
1601
1601
  const g = e.events.find((h) => h.id === m.triggerEventId);
1602
- for (const h of g?.payload ?? []) u.add(h.key);
1602
+ for (const h of g?.payload ?? []) f.add(h.key);
1603
1603
  }
1604
1604
  }
1605
1605
  }
1606
- if (u.size !== 0)
1607
- for (const [f, m] of Object.entries(n.edges))
1608
- m.from === l && "guard" in m && (u.has(m.guard.field) || t.push(`guard field "${m.guard.field}" on edge "${f}" is not declared in any direct predecessor's output or payload (node: ${l})`));
1606
+ if (f.size !== 0)
1607
+ for (const [u, m] of Object.entries(n.edges))
1608
+ m.from === l && "guard" in m && (f.has(m.guard.field) || t.push(`guard field "${m.guard.field}" on edge "${u}" is not declared in any direct predecessor's output or payload (node: ${l})`));
1609
1609
  }
1610
1610
  return t;
1611
1611
  }
@@ -1626,26 +1626,26 @@ class os extends y {
1626
1626
  getTeams;
1627
1627
  getRaciMatrix() {
1628
1628
  const e = this.getBep(), s = [], t = /* @__PURE__ */ new Set(), i = this.getMembers().listResolved(), o = this.getTeams().listResolved(), a = (l) => (l ?? []).flatMap((c) => {
1629
- const u = e.roles.find((p) => p.id === c);
1630
- if (!u) return [];
1629
+ const f = e.roles.find((p) => p.id === c);
1630
+ if (!f) return [];
1631
1631
  t.add(c);
1632
- const f = i.filter((p) => p.role?.id === c), m = o.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1633
- return [{ role: u, members: f, team: m }];
1632
+ const u = i.filter((p) => p.role?.id === c), m = o.find((p) => p.members.some((g) => g.role?.id === c)) ?? null;
1633
+ return [{ role: f, members: u, team: m }];
1634
1634
  });
1635
1635
  for (const l of e.workflows)
1636
- for (const [c, u] of Object.entries(l.diagram.nodes)) {
1637
- if (u.type !== "process") continue;
1638
- const f = u.actionId ? e.actions.find((m) => m.id === u.actionId) : void 0;
1636
+ for (const [c, f] of Object.entries(l.diagram.nodes)) {
1637
+ if (f.type !== "process") continue;
1638
+ const u = f.actionId ? e.actions.find((m) => m.id === f.actionId) : void 0;
1639
1639
  s.push({
1640
1640
  workflow: { id: l.id, name: l.name },
1641
1641
  nodeId: c,
1642
- label: f?.name ?? c,
1643
- ...f?.description ? { description: f.description } : {},
1644
- ...u.actionId ? { actionId: u.actionId } : {},
1645
- responsible: a(u.responsibleRoleIds),
1646
- accountable: a(u.accountableRoleIds),
1647
- consulted: a(u.consultedRoleIds),
1648
- informed: a(u.informedRoleIds)
1642
+ label: u?.name ?? c,
1643
+ ...u?.description ? { description: u.description } : {},
1644
+ ...f.actionId ? { actionId: f.actionId } : {},
1645
+ responsible: a(f.responsibleRoleIds),
1646
+ accountable: a(f.accountableRoleIds),
1647
+ consulted: a(f.consultedRoleIds),
1648
+ informed: a(f.informedRoleIds)
1649
1649
  });
1650
1650
  }
1651
1651
  return { roles: [...t].map((l) => e.roles.find((c) => c.id === l)).filter(Boolean), rows: s };
@@ -1663,8 +1663,8 @@ class os extends y {
1663
1663
  if (!l.has(c.role.id))
1664
1664
  l.set(c.role.id, { ...c, members: [...c.members] });
1665
1665
  else {
1666
- const u = l.get(c.role.id), f = new Set(u.members.map((m) => m.email));
1667
- for (const m of c.members) f.has(m.email) || u.members.push(m);
1666
+ const f = l.get(c.role.id), u = new Set(f.members.map((m) => m.email));
1667
+ for (const m of c.members) u.has(m.email) || f.members.push(m);
1668
1668
  }
1669
1669
  return [...l.values()];
1670
1670
  };
@@ -1745,7 +1745,7 @@ function W(n) {
1745
1745
  q(n, i) && t.push(i);
1746
1746
  return t;
1747
1747
  }
1748
- function N(n) {
1748
+ function _(n) {
1749
1749
  switch (typeof n) {
1750
1750
  case "object":
1751
1751
  return JSON.parse(JSON.stringify(n));
@@ -1767,7 +1767,7 @@ function G(n) {
1767
1767
  }
1768
1768
  return !0;
1769
1769
  }
1770
- function $(n) {
1770
+ function T(n) {
1771
1771
  return n.indexOf("/") === -1 && n.indexOf("~") === -1 ? n : n.replace(/~/g, "~0").replace(/\//g, "~1");
1772
1772
  }
1773
1773
  function Je(n) {
@@ -1808,7 +1808,7 @@ var Ke = (
1808
1808
  }
1809
1809
  return e;
1810
1810
  })(Error)
1811
- ), b = Ke, ds = N, A = {
1811
+ ), E = Ke, ds = _, O = {
1812
1812
  add: function(n, e, s) {
1813
1813
  return n[e] = this.value, { newDocument: s };
1814
1814
  },
@@ -1822,16 +1822,16 @@ var Ke = (
1822
1822
  },
1823
1823
  move: function(n, e, s) {
1824
1824
  var t = C(s, this.path);
1825
- t && (t = N(t));
1826
- var i = R(s, { op: "remove", path: this.from }).removed;
1827
- return R(s, { op: "add", path: this.path, value: i }), { newDocument: s, removed: t };
1825
+ t && (t = _(t));
1826
+ var i = A(s, { op: "remove", path: this.from }).removed;
1827
+ return A(s, { op: "add", path: this.path, value: i }), { newDocument: s, removed: t };
1828
1828
  },
1829
1829
  copy: function(n, e, s) {
1830
1830
  var t = C(s, this.from);
1831
- return R(s, { op: "add", path: this.path, value: N(t) }), { newDocument: s };
1831
+ return A(s, { op: "add", path: this.path, value: _(t) }), { newDocument: s };
1832
1832
  },
1833
1833
  test: function(n, e, s) {
1834
- return { newDocument: s, test: M(n[e], this.value) };
1834
+ return { newDocument: s, test: x(n[e], this.value) };
1835
1835
  },
1836
1836
  _get: function(n, e, s) {
1837
1837
  return this.value = n[e], { newDocument: s };
@@ -1848,18 +1848,18 @@ var Ke = (
1848
1848
  var t = n[e];
1849
1849
  return n[e] = this.value, { newDocument: s, removed: t };
1850
1850
  },
1851
- move: A.move,
1852
- copy: A.copy,
1853
- test: A.test,
1854
- _get: A._get
1851
+ move: O.move,
1852
+ copy: O.copy,
1853
+ test: O.test,
1854
+ _get: O._get
1855
1855
  };
1856
1856
  function C(n, e) {
1857
1857
  if (e == "")
1858
1858
  return n;
1859
1859
  var s = { op: "_get", path: e };
1860
- return R(n, s), s.value;
1860
+ return A(n, s), s.value;
1861
1861
  }
1862
- function R(n, e, s, t, i, o) {
1862
+ function A(n, e, s, t, i, o) {
1863
1863
  if (s === void 0 && (s = !1), t === void 0 && (t = !0), i === void 0 && (i = !0), o === void 0 && (o = 0), s && (typeof s == "function" ? s(e, 0, n, e.path) : D(e, 0)), e.path === "") {
1864
1864
  var a = { newDocument: n };
1865
1865
  if (e.op === "add")
@@ -1869,8 +1869,8 @@ function R(n, e, s, t, i, o) {
1869
1869
  if (e.op === "move" || e.op === "copy")
1870
1870
  return a.newDocument = C(n, e.from), e.op === "move" && (a.removed = n), a;
1871
1871
  if (e.op === "test") {
1872
- if (a.test = M(n, e.value), a.test === !1)
1873
- throw new b("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1872
+ if (a.test = x(n, e.value), a.test === !1)
1873
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1874
1874
  return a.newDocument = n, a;
1875
1875
  } else {
1876
1876
  if (e.op === "remove")
@@ -1878,104 +1878,104 @@ function R(n, e, s, t, i, o) {
1878
1878
  if (e.op === "_get")
1879
1879
  return e.value = n, a;
1880
1880
  if (s)
1881
- throw new b("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", o, e, n);
1881
+ throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", o, e, n);
1882
1882
  return a;
1883
1883
  }
1884
1884
  } else {
1885
- t || (n = N(n));
1886
- var d = e.path || "", l = d.split("/"), c = n, u = 1, f = l.length, m = void 0, p = void 0, g = void 0;
1885
+ t || (n = _(n));
1886
+ var d = e.path || "", l = d.split("/"), c = n, f = 1, u = l.length, m = void 0, p = void 0, g = void 0;
1887
1887
  for (typeof s == "function" ? g = s : g = D; ; ) {
1888
- if (p = l[u], p && p.indexOf("~") != -1 && (p = Je(p)), i && (p == "__proto__" || p == "prototype" && u > 0 && l[u - 1] == "constructor"))
1888
+ if (p = l[f], p && p.indexOf("~") != -1 && (p = Je(p)), i && (p == "__proto__" || p == "prototype" && f > 0 && l[f - 1] == "constructor"))
1889
1889
  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");
1890
- if (s && 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, n, m)), u++, Array.isArray(c)) {
1890
+ if (s && m === void 0 && (c[p] === void 0 ? m = l.slice(0, f).join("/") : f == u - 1 && (m = e.path), m !== void 0 && g(e, 0, n, m)), f++, Array.isArray(c)) {
1891
1891
  if (p === "-")
1892
1892
  p = c.length;
1893
1893
  else {
1894
1894
  if (s && !G(p))
1895
- throw new b("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", o, e, n);
1895
+ throw new E("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", o, e, n);
1896
1896
  G(p) && (p = ~~p);
1897
1897
  }
1898
- if (u >= f) {
1898
+ if (f >= u) {
1899
1899
  if (s && e.op === "add" && p > c.length)
1900
- throw new b("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", o, e, n);
1900
+ throw new E("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", o, e, n);
1901
1901
  var a = ls[e.op].call(e, c, p, n);
1902
1902
  if (a.test === !1)
1903
- throw new b("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1903
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1904
1904
  return a;
1905
1905
  }
1906
- } else if (u >= f) {
1907
- var a = A[e.op].call(e, c, p, n);
1906
+ } else if (f >= u) {
1907
+ var a = O[e.op].call(e, c, p, n);
1908
1908
  if (a.test === !1)
1909
- throw new b("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1909
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1910
1910
  return a;
1911
1911
  }
1912
- if (c = c[p], s && u < f && (!c || typeof c != "object"))
1913
- throw new b("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", o, e, n);
1912
+ if (c = c[p], s && f < u && (!c || typeof c != "object"))
1913
+ throw new E("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", o, e, n);
1914
1914
  }
1915
1915
  }
1916
1916
  }
1917
1917
  function U(n, e, s, t, i) {
1918
1918
  if (t === void 0 && (t = !0), i === void 0 && (i = !0), s && !Array.isArray(e))
1919
- throw new b("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1920
- t || (n = N(n));
1919
+ throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1920
+ t || (n = _(n));
1921
1921
  for (var o = new Array(e.length), a = 0, d = e.length; a < d; a++)
1922
- o[a] = R(n, e[a], s, !0, i, a), n = o[a].newDocument;
1922
+ o[a] = A(n, e[a], s, !0, i, a), n = o[a].newDocument;
1923
1923
  return o.newDocument = n, o;
1924
1924
  }
1925
1925
  function cs(n, e, s) {
1926
- var t = R(n, e);
1926
+ var t = A(n, e);
1927
1927
  if (t.test === !1)
1928
- throw new b("Test operation failed", "TEST_OPERATION_FAILED", s, e, n);
1928
+ throw new E("Test operation failed", "TEST_OPERATION_FAILED", s, e, n);
1929
1929
  return t.newDocument;
1930
1930
  }
1931
1931
  function D(n, e, s, t) {
1932
1932
  if (typeof n != "object" || n === null || Array.isArray(n))
1933
- throw new b("Operation is not an object", "OPERATION_NOT_AN_OBJECT", e, n, s);
1934
- if (A[n.op]) {
1933
+ throw new E("Operation is not an object", "OPERATION_NOT_AN_OBJECT", e, n, s);
1934
+ if (O[n.op]) {
1935
1935
  if (typeof n.path != "string")
1936
- throw new b("Operation `path` property is not a string", "OPERATION_PATH_INVALID", e, n, s);
1936
+ throw new E("Operation `path` property is not a string", "OPERATION_PATH_INVALID", e, n, s);
1937
1937
  if (n.path.indexOf("/") !== 0 && n.path.length > 0)
1938
- throw new b('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", e, n, s);
1938
+ throw new E('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", e, n, s);
1939
1939
  if ((n.op === "move" || n.op === "copy") && typeof n.from != "string")
1940
- throw new b("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, n, s);
1940
+ throw new E("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, n, s);
1941
1941
  if ((n.op === "add" || n.op === "replace" || n.op === "test") && n.value === void 0)
1942
- throw new b("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e, n, s);
1942
+ throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e, n, s);
1943
1943
  if ((n.op === "add" || n.op === "replace" || n.op === "test") && X(n.value))
1944
- throw new b("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, n, s);
1944
+ throw new E("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, n, s);
1945
1945
  if (s) {
1946
1946
  if (n.op == "add") {
1947
1947
  var i = n.path.split("/").length, o = t.split("/").length;
1948
1948
  if (i !== o + 1 && i !== o)
1949
- throw new b("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, n, s);
1949
+ throw new E("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", e, n, s);
1950
1950
  } else if (n.op === "replace" || n.op === "remove" || n.op === "_get") {
1951
1951
  if (n.path !== t)
1952
- throw new b("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, n, s);
1952
+ throw new E("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", e, n, s);
1953
1953
  } else if (n.op === "move" || n.op === "copy") {
1954
1954
  var a = { op: "_get", path: n.from, value: void 0 }, d = qe([a], s);
1955
1955
  if (d && d.name === "OPERATION_PATH_UNRESOLVABLE")
1956
- throw new b("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, n, s);
1956
+ throw new E("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", e, n, s);
1957
1957
  }
1958
1958
  }
1959
- } else throw new b("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, n, s);
1959
+ } else throw new E("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", e, n, s);
1960
1960
  }
1961
1961
  function qe(n, e, s) {
1962
1962
  try {
1963
1963
  if (!Array.isArray(n))
1964
- throw new b("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1964
+ throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1965
1965
  if (e)
1966
- U(N(e), N(n), s || !0);
1966
+ U(_(e), _(n), s || !0);
1967
1967
  else {
1968
1968
  s = s || D;
1969
1969
  for (var t = 0; t < n.length; t++)
1970
1970
  s(n[t], t, e, void 0);
1971
1971
  }
1972
1972
  } catch (i) {
1973
- if (i instanceof b)
1973
+ if (i instanceof E)
1974
1974
  return i;
1975
1975
  throw i;
1976
1976
  }
1977
1977
  }
1978
- function M(n, e) {
1978
+ function x(n, e) {
1979
1979
  if (n === e)
1980
1980
  return !0;
1981
1981
  if (n && e && typeof n == "object" && typeof e == "object") {
@@ -1984,7 +1984,7 @@ function M(n, e) {
1984
1984
  if (o = n.length, o != e.length)
1985
1985
  return !1;
1986
1986
  for (i = o; i-- !== 0; )
1987
- if (!M(n[i], e[i]))
1987
+ if (!x(n[i], e[i]))
1988
1988
  return !1;
1989
1989
  return !0;
1990
1990
  }
@@ -1997,7 +1997,7 @@ function M(n, e) {
1997
1997
  if (!e.hasOwnProperty(d[i]))
1998
1998
  return !1;
1999
1999
  for (i = o; i-- !== 0; )
2000
- if (a = d[i], !M(n[a], e[a]))
2000
+ if (a = d[i], !x(n[a], e[a]))
2001
2001
  return !1;
2002
2002
  return !0;
2003
2003
  }
@@ -2005,9 +2005,9 @@ function M(n, e) {
2005
2005
  }
2006
2006
  const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2007
2007
  __proto__: null,
2008
- JsonPatchError: b,
2009
- _areEquals: M,
2010
- applyOperation: R,
2008
+ JsonPatchError: E,
2009
+ _areEquals: x,
2010
+ applyOperation: A,
2011
2011
  applyPatch: U,
2012
2012
  applyReducer: cs,
2013
2013
  deepClone: ds,
@@ -2041,10 +2041,10 @@ function hs(n, e) {
2041
2041
  function gs(n, e) {
2042
2042
  n.observers.delete(e.callback);
2043
2043
  }
2044
- function ys(n, e) {
2044
+ function ws(n, e) {
2045
2045
  e.unobserve();
2046
2046
  }
2047
- function ws(n, e) {
2047
+ function ys(n, e) {
2048
2048
  var s = [], t, i = ps(n);
2049
2049
  if (!i)
2050
2050
  i = new us(n), ee.set(n, i);
@@ -2054,7 +2054,7 @@ function ws(n, e) {
2054
2054
  }
2055
2055
  if (t)
2056
2056
  return t;
2057
- if (t = {}, i.value = N(n), e) {
2057
+ if (t = {}, i.value = _(n), e) {
2058
2058
  t.callback = e, t.next = null;
2059
2059
  var a = function() {
2060
2060
  V(t);
@@ -2078,16 +2078,16 @@ function te(n, e, s, t, i) {
2078
2078
  if (e !== n) {
2079
2079
  typeof e.toJSON == "function" && (e = e.toJSON());
2080
2080
  for (var o = W(e), a = W(n), d = !1, l = a.length - 1; l >= 0; l--) {
2081
- var c = a[l], u = n[c];
2082
- if (q(e, c) && !(e[c] === void 0 && u !== void 0 && Array.isArray(e) === !1)) {
2083
- var f = e[c];
2084
- typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? te(u, f, s, t + "/" + $(c), i) : u !== f && (i && s.push({ op: "test", path: t + "/" + $(c), value: N(u) }), s.push({ op: "replace", path: t + "/" + $(c), value: N(f) }));
2085
- } else Array.isArray(n) === Array.isArray(e) ? (i && s.push({ op: "test", path: t + "/" + $(c), value: N(u) }), s.push({ op: "remove", path: t + "/" + $(c) }), d = !0) : (i && s.push({ op: "test", path: t, value: n }), s.push({ op: "replace", path: t, value: e }));
2081
+ var c = a[l], f = n[c];
2082
+ if (q(e, c) && !(e[c] === void 0 && f !== void 0 && Array.isArray(e) === !1)) {
2083
+ var u = e[c];
2084
+ typeof f == "object" && f != null && typeof u == "object" && u != null && Array.isArray(f) === Array.isArray(u) ? te(f, u, s, t + "/" + T(c), i) : f !== u && (i && s.push({ op: "test", path: t + "/" + T(c), value: _(f) }), s.push({ op: "replace", path: t + "/" + T(c), value: _(u) }));
2085
+ } else Array.isArray(n) === Array.isArray(e) ? (i && s.push({ op: "test", path: t + "/" + T(c), value: _(f) }), s.push({ op: "remove", path: t + "/" + T(c) }), d = !0) : (i && s.push({ op: "test", path: t, value: n }), s.push({ op: "replace", path: t, value: e }));
2086
2086
  }
2087
2087
  if (!(!d && o.length == a.length))
2088
2088
  for (var l = 0; l < o.length; l++) {
2089
2089
  var c = o[l];
2090
- !q(n, c) && e[c] !== void 0 && s.push({ op: "add", path: t + "/" + $(c), value: N(e[c]) });
2090
+ !q(n, c) && e[c] !== void 0 && s.push({ op: "add", path: t + "/" + T(c), value: _(e[c]) });
2091
2091
  }
2092
2092
  }
2093
2093
  }
@@ -2100,13 +2100,13 @@ const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2100
2100
  __proto__: null,
2101
2101
  compare: H,
2102
2102
  generate: V,
2103
- observe: ws,
2104
- unobserve: ys
2103
+ observe: ys,
2104
+ unobserve: ws
2105
2105
  }, Symbol.toStringTag, { value: "Module" }));
2106
2106
  Object.assign({}, fs, vs, {
2107
2107
  JsonPatchError: Ke,
2108
- deepClone: N,
2109
- escapePathComponent: $,
2108
+ deepClone: _,
2109
+ escapePathComponent: T,
2110
2110
  unescapePathComponent: Je
2111
2111
  });
2112
2112
  function v(n, e, s) {
@@ -2159,13 +2159,13 @@ function Es(n, e) {
2159
2159
  }) });
2160
2160
  const t = {};
2161
2161
  for (const { key: o, getId: a, getLabel: d } of bs) {
2162
- const l = e[o] ?? [], c = n[o] ?? [], u = Is(l, c, a, d);
2163
- (u.added.length || u.removed.length || u.modified.length) && (t[o] = u);
2162
+ const l = e[o] ?? [], c = n[o] ?? [], f = Is(l, c, a, d);
2163
+ (f.added.length || f.removed.length || f.modified.length) && (t[o] = f);
2164
2164
  }
2165
2165
  const i = [...s ? ["project"] : [], ...Object.keys(t)];
2166
2166
  return { project: s, sections: t, changedKeys: i };
2167
2167
  }
2168
- class E {
2168
+ class S {
2169
2169
  constructor(e, s, t) {
2170
2170
  this.getBep = e, this.setBep = s, this.getZip = t;
2171
2171
  }
@@ -2178,7 +2178,7 @@ class E {
2178
2178
  return { major: s, minor: t };
2179
2179
  }
2180
2180
  static compareVersions(e, s) {
2181
- const t = E.parseVersion(e), i = E.parseVersion(s);
2181
+ const t = S.parseVersion(e), i = S.parseVersion(s);
2182
2182
  return t.major !== i.major ? t.major - i.major : t.minor - i.minor;
2183
2183
  }
2184
2184
  static bumpVersion(e, s) {
@@ -2204,11 +2204,11 @@ class E {
2204
2204
  for (const i of e.standards) {
2205
2205
  const o = t.file(i.contentPath);
2206
2206
  if (!o) continue;
2207
- const a = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(t.files).filter((u) => u.startsWith(d) && u.endsWith(".md") && u.slice(d.length).startsWith("v")).map((u) => u.slice(d.length + 1, -3));
2207
+ const a = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(t.files).filter((f) => f.startsWith(d) && f.endsWith(".md") && f.slice(d.length).startsWith("v")).map((f) => f.slice(d.length + 1, -3));
2208
2208
  let c = null;
2209
2209
  if (l.length > 0) {
2210
- const u = l.sort((m, p) => E.compareVersions(p, m))[0], f = t.file(`${d}v${u}.md`);
2211
- f && (c = await f.async("string"));
2210
+ const f = l.sort((m, p) => S.compareVersions(p, m))[0], u = t.file(`${d}v${f}.md`);
2211
+ u && (c = await u.async("string"));
2212
2212
  }
2213
2213
  c !== a && t.file(`${d}v${s}.md`, a);
2214
2214
  }
@@ -2232,7 +2232,7 @@ class E {
2232
2232
  * Falls back to the current file if no snapshot exists (content never changed).
2233
2233
  */
2234
2234
  async resolveStandardContent(e, s) {
2235
- const t = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(t.files).filter((d) => d.startsWith(i) && d.endsWith(".md") && d.slice(i.length).startsWith("v")).map((d) => d.slice(i.length + 1, -3)).filter((d) => E.compareVersions(d, s) <= 0).sort((d, l) => E.compareVersions(l, d));
2235
+ const t = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(t.files).filter((d) => d.startsWith(i) && d.endsWith(".md") && d.slice(i.length).startsWith("v")).map((d) => d.slice(i.length + 1, -3)).filter((d) => S.compareVersions(d, s) <= 0).sort((d, l) => S.compareVersions(l, d));
2236
2236
  if (o.length === 0) {
2237
2237
  const d = t.file(e.contentPath);
2238
2238
  return d ? d.async("string") : null;
@@ -2251,16 +2251,16 @@ class E {
2251
2251
  const t = this.getZip(), i = this.getBep(), o = await this.readChangelog(), a = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
2252
2252
  if (!a) throw new Error("No baseline found — create a BEP with Bep.create() or open one with Bep.open()");
2253
2253
  if (e.type === "version") {
2254
- const g = e.approvedBy.filter((h) => !i.members.some((w) => w.email === h));
2254
+ const g = e.approvedBy.filter((h) => !i.members.some((k) => k.email === h));
2255
2255
  if (g.length) throw new Error(`Members not found: ${g.join(", ")}`);
2256
2256
  }
2257
2257
  if (!s && !await this.hasPendingChanges())
2258
2258
  throw new Error("No pending changes since last commit");
2259
- const l = o?.current ?? "0.0", c = E.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, f = H(i, a), 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 = {
2259
+ const l = o?.current ?? "0.0", c = S.bumpVersion(l, e.type), f = `changelog/v${c}.diff.json`, u = H(i, a), m = e.type === "patch" ? { version: c, type: "patch", date: d, author: e.author, description: e.description, diff: f } : { version: c, type: "version", date: d, author: e.author, description: e.description, approvedBy: e.approvedBy, diff: f }, p = {
2260
2260
  current: c,
2261
2261
  versions: [...o?.versions ?? [], m]
2262
2262
  };
2263
- return t.file(u, JSON.stringify(f, null, 2)), await this.snapshotChangedStandards(i, c), t.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i), t.file("changelog.json", JSON.stringify(p, null, 2)), m;
2263
+ return t.file(f, JSON.stringify(u, null, 2)), await this.snapshotChangedStandards(i, c), t.file("baseline/bep.json", JSON.stringify(i, null, 2)), await this.snapshotBaseStandards(i), t.file("changelog.json", JSON.stringify(p, null, 2)), m;
2264
2264
  }
2265
2265
  /**
2266
2266
  * Reconstructs the BEP state at the given version (read-only).
@@ -2282,7 +2282,7 @@ class E {
2282
2282
  if (!a) throw new Error(`Missing terminus: changelog/v${e}.json`);
2283
2283
  return j(JSON.parse(await a.async("string")));
2284
2284
  }
2285
- const i = s.versions.filter((a) => E.compareVersions(a.version, e) > 0).sort((a, d) => E.compareVersions(d.version, a.version)), o = JSON.parse(JSON.stringify(this.getBep()));
2285
+ const i = s.versions.filter((a) => S.compareVersions(a.version, e) > 0).sort((a, d) => S.compareVersions(d.version, a.version)), o = JSON.parse(JSON.stringify(this.getBep()));
2286
2286
  for (const a of i) {
2287
2287
  if (!a.diff) break;
2288
2288
  const d = this.getZip().file(a.diff);
@@ -2298,15 +2298,15 @@ class E {
2298
2298
  this.get(e),
2299
2299
  this.get(s),
2300
2300
  this.readChangelog()
2301
- ]), a = H(t, i), d = new Set(t.standards.map((h) => h.id)), l = new Set(i.standards.map((h) => h.id)), c = i.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), u = t.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (o?.versions ?? []).filter((h) => E.compareVersions(h.version, e) > 0 && E.compareVersions(h.version, s) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2301
+ ]), a = H(t, i), d = new Set(t.standards.map((h) => h.id)), l = new Set(i.standards.map((h) => h.id)), c = i.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), f = t.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (o?.versions ?? []).filter((h) => S.compareVersions(h.version, e) > 0 && S.compareVersions(h.version, s) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2302
2302
  i.standards.filter((h) => d.has(h.id)).map(async (h) => {
2303
- const w = (await Promise.all(
2304
- m.map(async (S) => p.file(`changelog/standards/${h.id}/v${S}.md`) !== null ? S : null)
2305
- )).filter((S) => S !== null);
2306
- return w.length > 0 ? { id: h.id, name: h.name, changedIn: w } : null;
2303
+ const k = (await Promise.all(
2304
+ m.map(async (b) => p.file(`changelog/standards/${h.id}/v${b}.md`) !== null ? b : null)
2305
+ )).filter((b) => b !== null);
2306
+ return k.length > 0 ? { id: h.id, name: h.name, changedIn: k } : null;
2307
2307
  })
2308
2308
  )).filter((h) => h !== null);
2309
- return { diff: a, standards: { added: c, removed: u, contentModified: g } };
2309
+ return { diff: a, standards: { added: c, removed: f, contentModified: g } };
2310
2310
  }
2311
2311
  /**
2312
2312
  * Resets in-memory BEP and restores .md files to the last committed baseline.
@@ -2350,8 +2350,8 @@ class E {
2350
2350
  if (!a.has(c.id))
2351
2351
  o.push({ id: c.id, name: c.name, status: "added" });
2352
2352
  else {
2353
- const u = JSON.stringify(a.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") : "";
2354
- u ? o.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && o.push({ id: c.id, name: c.name, status: "content-modified" });
2353
+ const f = JSON.stringify(a.get(c.id)) !== JSON.stringify(c), u = e.file(`baseline/standards/${c.id}.md`), m = e.file(c.contentPath), p = u ? await u.async("string") : "", g = m ? await m.async("string") : "";
2354
+ f ? o.push({ id: c.id, name: c.name, status: "modified" }) : p !== g && o.push({ id: c.id, name: c.name, status: "content-modified" });
2355
2355
  }
2356
2356
  for (const c of s.standards)
2357
2357
  d.has(c.id) || o.push({ id: c.id, name: c.name, status: "removed" });
@@ -2364,7 +2364,7 @@ class E {
2364
2364
  /** Returns all versions sorted ascending, with author/approvedBy resolved to { email, name } objects. */
2365
2365
  async listResolved() {
2366
2366
  const [e, s] = await Promise.all([this.list(), this.current()]), t = this.getBep().members;
2367
- return e.sort((i, o) => E.compareVersions(i.version, o.version)).map((i) => ({
2367
+ return e.sort((i, o) => S.compareVersions(i.version, o.version)).map((i) => ({
2368
2368
  version: i.version,
2369
2369
  type: i.type,
2370
2370
  date: i.date,
@@ -2400,18 +2400,18 @@ class E {
2400
2400
  throw new Error(`Version not found: ${e}`);
2401
2401
  if (e === t.current)
2402
2402
  throw new Error(`Already at version ${e}`);
2403
- const a = t.versions.filter((c) => E.compareVersions(c.version, e) > 0), d = await this.get(e);
2403
+ const a = t.versions.filter((c) => S.compareVersions(c.version, e) > 0), d = await this.get(e);
2404
2404
  for (const c of d.standards) {
2405
- const u = await this.resolveStandardContent(c, e);
2406
- u !== null && s.file(c.contentPath, u);
2405
+ const f = await this.resolveStandardContent(c, e);
2406
+ f !== null && s.file(c.contentPath, f);
2407
2407
  }
2408
2408
  await this.snapshotBaseStandards(d);
2409
2409
  for (const c of a)
2410
- c.diff && s.remove(c.diff), Object.keys(s.files).filter((u) => u.startsWith("changelog/standards/") && u.includes(`/v${c.version}.md`)).forEach((u) => s.remove(u));
2410
+ c.diff && s.remove(c.diff), Object.keys(s.files).filter((f) => f.startsWith("changelog/standards/") && f.includes(`/v${c.version}.md`)).forEach((f) => s.remove(f));
2411
2411
  const l = JSON.stringify(d, null, 2);
2412
2412
  s.file("changelog.json", JSON.stringify({
2413
2413
  current: e,
2414
- versions: t.versions.filter((c) => E.compareVersions(c.version, e) <= 0)
2414
+ versions: t.versions.filter((c) => S.compareVersions(c.version, e) <= 0)
2415
2415
  }, null, 2)), s.file("bep.json", l), s.file("baseline/bep.json", l), this.setBep(d);
2416
2416
  }
2417
2417
  /**
@@ -2424,7 +2424,7 @@ class E {
2424
2424
  if (!t) throw new Error("No changelog found");
2425
2425
  if (!/^\d+\.0$/.test(e.newBase))
2426
2426
  throw new Error(`newBase must be in X.0 format (e.g. "2.0"), got "${e.newBase}"`);
2427
- if (E.compareVersions(e.newBase, t.current) <= 0)
2427
+ if (S.compareVersions(e.newBase, t.current) <= 0)
2428
2428
  throw new Error(`newBase "${e.newBase}" must be greater than current version "${t.current}"`);
2429
2429
  const i = this.getBep(), o = e.approvedBy.filter((d) => !i.members.some((l) => l.email === d));
2430
2430
  if (o.length) throw new Error(`Members not found: ${o.join(", ")}`);
@@ -2466,8 +2466,8 @@ class Z {
2466
2466
  this.getZip().file(this.path, e);
2467
2467
  }
2468
2468
  }
2469
- const Ss = 10;
2470
- function Ns(n, e) {
2469
+ const ks = 10;
2470
+ function Ss(n, e) {
2471
2471
  const s = e[n.field];
2472
2472
  switch (n.operator) {
2473
2473
  case "exists":
@@ -2486,17 +2486,17 @@ function Ns(n, e) {
2486
2486
  return !1;
2487
2487
  }
2488
2488
  }
2489
- function ks(n, e, s, t) {
2489
+ function Ns(n, e, s, t) {
2490
2490
  const o = n.workflows.find((m) => m.id === s)?.diagram.nodes[e];
2491
2491
  if (!o || o.type !== "process") return !0;
2492
2492
  const a = !!(o.responsibleRoleIds?.length || o.responsibleTeamIds?.length || o.responsibleEmails?.length), d = !!(o.accountableRoleIds?.length || o.accountableTeamIds?.length || o.accountableEmails?.length);
2493
2493
  if (!a && !d) return !0;
2494
- const c = n.members.find((m) => m.email === t)?.roleId, u = new Set(n.teams.filter((m) => (m.memberEmails ?? []).includes(t)).map((m) => m.id)), f = (m, p, g) => {
2494
+ const c = n.members.find((m) => m.email === t)?.roleId, f = new Set(n.teams.filter((m) => (m.memberEmails ?? []).includes(t)).map((m) => m.id)), u = (m, p, g) => {
2495
2495
  if (g?.includes(t)) return !0;
2496
- const h = !!m?.length, w = !!p?.length;
2497
- return w && h ? !!c && m.includes(c) && p.some((S) => u.has(S)) : w ? p.some((S) => u.has(S)) : h ? !!c && m.includes(c) : !1;
2496
+ const h = !!m?.length, k = !!p?.length;
2497
+ return k && h ? !!c && m.includes(c) && p.some((b) => f.has(b)) : k ? p.some((b) => f.has(b)) : h ? !!c && m.includes(c) : !1;
2498
2498
  };
2499
- return a && f(o.responsibleRoleIds, o.responsibleTeamIds, o.responsibleEmails) || d && f(o.accountableRoleIds, o.accountableTeamIds, o.accountableEmails);
2499
+ return a && u(o.responsibleRoleIds, o.responsibleTeamIds, o.responsibleEmails) || d && u(o.accountableRoleIds, o.accountableTeamIds, o.accountableEmails);
2500
2500
  }
2501
2501
  const _s = { string: "string", number: "number", boolean: "boolean" };
2502
2502
  function $s(n, e, s) {
@@ -2526,14 +2526,14 @@ function $s(n, e, s) {
2526
2526
  function Rs(n, e) {
2527
2527
  return !(!("triggerEventId" in n) || n.triggerEventId !== e.eventId);
2528
2528
  }
2529
- function js(n, e, s, t, i) {
2530
- const o = n.workflows.find((f) => f.id === e);
2529
+ function Ts(n, e, s, t, i) {
2530
+ const o = n.workflows.find((u) => u.id === e);
2531
2531
  if (!o) return null;
2532
2532
  const a = Object.keys(o.diagram.nodes).find(
2533
- (f) => o.diagram.nodes[f].type === "start"
2533
+ (u) => o.diagram.nodes[u].type === "start"
2534
2534
  );
2535
2535
  if (!a) return null;
2536
- const d = Object.entries(o.diagram.edges).find(([, f]) => f.from === a), l = d?.[1].to ?? a, c = d ? (d[1].effectIds ?? []).map((f) => ({ effectId: f, fromEdgeId: d[0], triggerPayload: {} })) : [], u = (/* @__PURE__ */ new Date()).toISOString();
2536
+ const d = Object.entries(o.diagram.edges).find(([, u]) => u.from === a), l = d?.[1].to ?? a, c = d ? (d[1].effectIds ?? []).map((u) => ({ effectId: u, fromEdgeId: d[0], triggerPayload: {} })) : [], f = (/* @__PURE__ */ new Date()).toISOString();
2537
2537
  return {
2538
2538
  instance: {
2539
2539
  id: globalThis.crypto.randomUUID(),
@@ -2543,8 +2543,8 @@ function js(n, e, s, t, i) {
2543
2543
  currentNodeId: l,
2544
2544
  status: "active",
2545
2545
  history: [],
2546
- createdAt: u,
2547
- updatedAt: u,
2546
+ createdAt: f,
2547
+ updatedAt: f,
2548
2548
  initiatedBy: t
2549
2549
  },
2550
2550
  startEffects: c
@@ -2553,39 +2553,39 @@ function js(n, e, s, t, i) {
2553
2553
  function J(n, e, s, t) {
2554
2554
  if (e.status !== "active")
2555
2555
  return { ok: !1, error: "INSTANCE_NOT_ACTIVE" };
2556
- if (!t?.skipRaci && !ks(n, e.currentNodeId, e.workflowId, s.actor))
2556
+ if (!t?.skipRaci && !Ns(n, e.currentNodeId, e.workflowId, s.actor))
2557
2557
  return { ok: !1, error: "UNAUTHORIZED" };
2558
2558
  const i = n.workflows.find((I) => I.id === e.workflowId);
2559
2559
  if (!i) return { ok: !1, error: "NO_MATCHING_EDGE" };
2560
2560
  const { nodes: o, edges: a } = i.diagram;
2561
2561
  let d = e.currentNodeId;
2562
- const l = [], c = [], u = [], f = Object.entries(a).filter(
2562
+ const l = [], c = [], f = [], u = Object.entries(a).filter(
2563
2563
  ([, I]) => I.from === d && Rs(I, s)
2564
2564
  );
2565
- if (f.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
2566
- if (f.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
2567
- const [m, p] = f[0];
2565
+ if (u.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
2566
+ if (u.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
2567
+ const [m, p] = u[0];
2568
2568
  if ("triggerEventId" in p) {
2569
2569
  const I = $s(n, p.triggerEventId, s.payload);
2570
2570
  if (I.length > 0) return { ok: !1, error: "INVALID_PAYLOAD", payloadErrors: I };
2571
2571
  }
2572
- l.push(re(m, d, p.to, s)), c.push(...(p.effectIds ?? []).map((I) => ({ effectId: I, fromEdgeId: m, triggerPayload: s.payload ?? {} }))), u.push({ edgeId: m, fromNodeId: d, toNodeId: p.to }), d = p.to;
2572
+ l.push(re(m, d, p.to, s)), c.push(...(p.effectIds ?? []).map((I) => ({ effectId: I, fromEdgeId: m, triggerPayload: s.payload ?? {} }))), f.push({ edgeId: m, fromNodeId: d, toNodeId: p.to }), d = p.to;
2573
2573
  let g = 0;
2574
2574
  for (; o[d]?.type === "decision"; ) {
2575
- if (++g > Ss) return { ok: !1, error: "DECISION_LOOP" };
2576
- const I = Object.entries(a).filter(([, O]) => O.from !== d || !("guard" in O) ? !1 : Ns(O.guard, s.payload ?? {}));
2575
+ if (++g > ks) return { ok: !1, error: "DECISION_LOOP" };
2576
+ const I = Object.entries(a).filter(([, R]) => R.from !== d || !("guard" in R) ? !1 : Ss(R.guard, s.payload ?? {}));
2577
2577
  if (I.length === 0) break;
2578
- const [_, B] = I[0];
2579
- l.push(re(_, d, B.to, s, !0)), c.push(...(B.effectIds ?? []).map((O) => ({ effectId: O, fromEdgeId: _, triggerPayload: s.payload ?? {} }))), u.push({ edgeId: _, fromNodeId: d, toNodeId: B.to }), d = B.to;
2578
+ const [$, N] = I[0];
2579
+ l.push(re($, d, N.to, s, !0)), c.push(...(N.effectIds ?? []).map((R) => ({ effectId: R, fromEdgeId: $, triggerPayload: s.payload ?? {} }))), f.push({ edgeId: $, fromNodeId: d, toNodeId: N.to }), d = N.to;
2580
2580
  }
2581
- const h = o[d], w = h?.type === "end" ? "completed" : "active", S = {
2581
+ const h = o[d], k = h?.type === "end" ? "completed" : "active", b = {
2582
2582
  ...e,
2583
2583
  currentNodeId: d,
2584
- status: w,
2584
+ status: k,
2585
2585
  history: [...e.history, ...l],
2586
2586
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2587
- }, k = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId, triggerPayload: s.payload ?? {} } : void 0;
2588
- return { ok: !0, instance: S, transitionsApplied: u, effectsToFire: c, automationNodePending: k };
2587
+ }, w = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId, triggerPayload: s.payload ?? {} } : void 0;
2588
+ return { ok: !0, instance: b, transitionsApplied: f, effectsToFire: c, automationNodePending: w };
2589
2589
  }
2590
2590
  function As(n, e) {
2591
2591
  const s = n.workflows.find((m) => m.id === e.workflowId), { nodes: t, edges: i } = s.diagram, o = t[e.currentNodeId], a = (m) => (m ?? []).flatMap((p) => {
@@ -2603,11 +2603,11 @@ function As(n, e) {
2603
2603
  type: p.type,
2604
2604
  required: p.required,
2605
2605
  label: p.label
2606
- })), u = o.type === "process" ? o : null, f = [];
2606
+ })), f = o.type === "process" ? o : null, u = [];
2607
2607
  for (const [m, p] of Object.entries(i)) {
2608
2608
  if (p.from !== e.currentNodeId || !("triggerEventId" in p)) continue;
2609
2609
  const g = p.triggerEventId;
2610
- f.push({
2610
+ u.push({
2611
2611
  edgeId: m,
2612
2612
  label: p.label ?? g,
2613
2613
  emits: g,
@@ -2621,12 +2621,12 @@ function As(n, e) {
2621
2621
  label: e.currentNodeId
2622
2622
  },
2623
2623
  status: e.status,
2624
- transitions: f,
2624
+ transitions: u,
2625
2625
  raci: {
2626
- responsible: l(u?.responsibleRoleIds, u?.responsibleTeamIds, u?.responsibleEmails),
2627
- accountable: l(u?.accountableRoleIds, u?.accountableTeamIds, u?.accountableEmails),
2628
- consulted: l(u?.consultedRoleIds, u?.consultedTeamIds, u?.consultedEmails),
2629
- informed: l(u?.informedRoleIds, u?.informedTeamIds, u?.informedEmails)
2626
+ responsible: l(f?.responsibleRoleIds, f?.responsibleTeamIds, f?.responsibleEmails),
2627
+ accountable: l(f?.accountableRoleIds, f?.accountableTeamIds, f?.accountableEmails),
2628
+ consulted: l(f?.consultedRoleIds, f?.consultedTeamIds, f?.consultedEmails),
2629
+ informed: l(f?.informedRoleIds, f?.informedTeamIds, f?.informedEmails)
2630
2630
  },
2631
2631
  isTerminal: o.type === "end"
2632
2632
  };
@@ -2643,7 +2643,7 @@ function re(n, e, s, t, i) {
2643
2643
  ...i ? { auto: !0 } : {}
2644
2644
  };
2645
2645
  }
2646
- class Ts {
2646
+ class js {
2647
2647
  instances = /* @__PURE__ */ new Map();
2648
2648
  async listInstances(e) {
2649
2649
  let s = [...this.instances.values()];
@@ -2714,7 +2714,7 @@ class Os {
2714
2714
  * Returns `this` for chaining.
2715
2715
  */
2716
2716
  init(e) {
2717
- return this._runtime = e.runtime, this.storage = e.storage ?? new Ts(), this.skipRaci = e.events?.skipRaci ?? !1, e.runtime._engine = this, this;
2717
+ return this._runtime = e.runtime, this.storage = e.storage ?? new js(), this.skipRaci = e.events?.skipRaci ?? !1, e.runtime._engine = this, this;
2718
2718
  }
2719
2719
  // ─── Remote data ──────────────────────────────────────────────────────────
2720
2720
  async getRemoteData(e) {
@@ -2727,29 +2727,37 @@ class Os {
2727
2727
  // ─── Private workflow instance operations ─────────────────────────────────
2728
2728
  async _create(e, s, t) {
2729
2729
  this._assertInit();
2730
- const i = this.getBep(), a = js(i, e, s, t, "unversioned");
2731
- if (!a) return null;
2732
- const { instance: d, startEffects: l } = a;
2733
- for (const h of l)
2734
- await this._executeEffect(d, h);
2735
- const u = i.workflows.find((h) => h.id === e)?.diagram.nodes[d.currentNodeId];
2736
- let f = u?.type === "automation" && u.automationId ? { automationId: u.automationId, triggerPayload: {} } : void 0, m = d;
2737
- const p = 10;
2738
- let g = 0;
2739
- for (; f && g++ < p; ) {
2740
- const { automationId: h, triggerPayload: w } = f, { eventId: S, ...k } = await this._executeAutomationNode(m, h, w), I = J(i, m, {
2741
- eventId: S,
2742
- actor: "_system",
2743
- softwareId: "_system",
2744
- payload: k
2730
+ let i, o;
2731
+ if ("rawPayload" in s) {
2732
+ const b = this._runtime.triggers[e];
2733
+ if (!b) throw new Error(`No trigger handler declared for software "${e}"`);
2734
+ const w = await b(s.rawPayload);
2735
+ i = w.trackedAsset, o = w.workflowId, t = "dotBEP";
2736
+ } else
2737
+ i = s, o = e;
2738
+ const a = this.getBep(), l = Ts(a, o, i, t, "unversioned");
2739
+ if (!l) return null;
2740
+ const { instance: c, startEffects: f } = l;
2741
+ for (const b of f)
2742
+ await this._executeEffect(c, b);
2743
+ const m = a.workflows.find((b) => b.id === o)?.diagram.nodes[c.currentNodeId];
2744
+ let p = m?.type === "automation" && m.automationId ? { automationId: m.automationId, triggerPayload: {} } : void 0, g = c;
2745
+ const h = 10;
2746
+ let k = 0;
2747
+ for (; p && k++ < h; ) {
2748
+ const { automationId: b, triggerPayload: w } = p, { eventId: I, ...$ } = await this._executeAutomationNode(g, b, w), N = J(a, g, {
2749
+ eventId: I,
2750
+ actor: "dotBEP",
2751
+ softwareId: "dotBEP",
2752
+ payload: $
2745
2753
  });
2746
- if (!I.ok) break;
2747
- m = I.instance;
2748
- for (const _ of I.effectsToFire ?? [])
2749
- await this._executeEffect(m, _);
2750
- f = I.automationNodePending;
2754
+ if (!N.ok) break;
2755
+ g = N.instance;
2756
+ for (const R of N.effectsToFire ?? [])
2757
+ await this._executeEffect(g, R);
2758
+ p = N.automationNodePending;
2751
2759
  }
2752
- return await this.storage.saveInstance(m), await this._fire(this._createdListeners, m), m;
2760
+ return await this.storage.saveInstance(g), await this._fire(this._createdListeners, g), g;
2753
2761
  }
2754
2762
  async _emit(e, s) {
2755
2763
  this._assertInit();
@@ -2760,16 +2768,16 @@ class Os {
2760
2768
  if (!o.ok) return { ok: !1, error: o.error, payloadErrors: o.payloadErrors };
2761
2769
  const a = [...o.transitionsApplied ?? []], d = [];
2762
2770
  let l = o.instance;
2763
- for (const f of o.effectsToFire ?? [])
2764
- d.push(await this._executeEffect(l, f));
2771
+ for (const u of o.effectsToFire ?? [])
2772
+ d.push(await this._executeEffect(l, u));
2765
2773
  const c = 10;
2766
- let u = 0;
2767
- for (; o.automationNodePending && u++ < c; ) {
2768
- const { automationId: f, triggerPayload: m } = o.automationNodePending, { eventId: p, ...g } = await this._executeAutomationNode(l, f, m);
2774
+ let f = 0;
2775
+ for (; o.automationNodePending && f++ < c; ) {
2776
+ const { automationId: u, triggerPayload: m } = o.automationNodePending, { eventId: p, ...g } = await this._executeAutomationNode(l, u, m);
2769
2777
  if (o = J(i, l, {
2770
2778
  eventId: p,
2771
- actor: "_system",
2772
- softwareId: "_system",
2779
+ actor: "dotBEP",
2780
+ softwareId: "dotBEP",
2773
2781
  payload: g
2774
2782
  }), !o.ok) break;
2775
2783
  l = o.instance, a.push(...o.transitionsApplied ?? []);
@@ -2796,11 +2804,11 @@ class Os {
2796
2804
  if (!l) return !1;
2797
2805
  const c = l.diagram.nodes[d.currentNodeId];
2798
2806
  if (!c) return !1;
2799
- const u = c.type === "process" ? c : null, f = [
2800
- ...u?.responsibleRoleIds ?? [],
2801
- ...u?.accountableRoleIds ?? []
2807
+ const f = c.type === "process" ? c : null, u = [
2808
+ ...f?.responsibleRoleIds ?? [],
2809
+ ...f?.accountableRoleIds ?? []
2802
2810
  ];
2803
- return f.length === 0 || f.includes(a.roleId);
2811
+ return u.length === 0 || u.includes(a.roleId);
2804
2812
  }) : [];
2805
2813
  }
2806
2814
  async _delete(e) {
@@ -2879,50 +2887,12 @@ function Ls(n, e) {
2879
2887
  }
2880
2888
  return Array.from(s.entries()).map(([t, i]) => ({ key: t, rows: i }));
2881
2889
  }
2882
- function Cs(n, e = "responsible", s = {}) {
2883
- const { topologicalSort: t = !1 } = s, i = (m) => `_${m}`, o = "#444444", a = Object.entries(n.nodes), d = a.find(([, m]) => m.type === "start")?.[0], l = a.find(([, m]) => m.type === "end")?.[0];
2884
- let c;
2885
- if (t && d) {
2886
- const m = /* @__PURE__ */ new Set(), p = [d], g = [];
2887
- for (; p.length; ) {
2888
- const h = p.shift();
2889
- if (!m.has(h)) {
2890
- m.add(h), g.push(h);
2891
- for (const w of Object.values(n.edges))
2892
- w.from === h && !m.has(w.to) && p.push(w.to);
2893
- }
2894
- }
2895
- for (const [h] of a)
2896
- m.has(h) || g.push(h);
2897
- c = g;
2898
- } else {
2899
- const m = a.map(([p]) => p).filter((p) => p !== d && p !== l);
2900
- c = [
2901
- ...d ? [d] : [],
2902
- ...m,
2903
- ...l ? [l] : []
2904
- ];
2905
- }
2906
- const u = [`flowchart ${n.direction}`];
2907
- for (const m of c) {
2908
- const p = n.nodes[m];
2909
- if (!p) continue;
2910
- const g = p.type === "start" || p.type === "end", w = (p.type === "decision" ? p.label ?? m : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, "&quot;"), S = g || p.type === "decision" ? [] : p[e].roles.map((_) => _.name), k = S.length > 0 ? `"<b>${S.join(" · ")}</b><br/>${w}"` : `"${w || m}"`;
2911
- g ? u.push(` ${i(m)}([${w || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${i(m)}{${k}}`) : p.type === "automation" ? u.push(` ${i(m)}[[${k}]]`) : u.push(` ${i(m)}(${k})`);
2912
- const I = p[e].roles[0]?.color ?? o;
2913
- g ? u.push(` style ${i(m)} fill:#2962FF,stroke:none`) : u.push(` style ${i(m)} fill:none,stroke:${I},stroke-width:3px`);
2914
- }
2915
- const f = t ? c.flatMap((m) => Object.values(n.edges).filter((p) => p.from === m)) : Object.values(n.edges);
2916
- for (const m of f)
2917
- m.label ? u.push(` ${i(m.from)} -->|${m.label}| ${i(m.to)}`) : u.push(` ${i(m.from)} --> ${i(m.to)}`);
2918
- return u.join(`
2919
- `);
2920
- }
2921
- class Ds {
2890
+ class Cs {
2922
2891
  env;
2923
2892
  effects = {};
2924
2893
  automations = {};
2925
2894
  resolvers = {};
2895
+ triggers = {};
2926
2896
  /** Set by Engine.init() — available inside handlers via this.engine */
2927
2897
  _engine = null;
2928
2898
  get engine() {
@@ -2941,6 +2911,9 @@ class Ds {
2941
2911
  resolver(e, s) {
2942
2912
  return this.resolvers[e] = s, this;
2943
2913
  }
2914
+ trigger(e, s) {
2915
+ return this.triggers[e] = s, this;
2916
+ }
2944
2917
  /** @internal Called by Engine.getRemoteData — keeps env encapsulated inside the Runtime. */
2945
2918
  _runResolver(e, s) {
2946
2919
  const t = this.resolvers[e];
@@ -2959,20 +2932,20 @@ class F {
2959
2932
  },
2960
2933
  de,
2961
2934
  (i, o) => {
2962
- const a = [], d = T("project", i.code, o.deliverableNamingConvention);
2935
+ const a = [], d = B("project", i.code, o.deliverableNamingConvention);
2963
2936
  return d && a.push(d), i.clientId && !o.teams.some((l) => l.id === i.clientId) && a.push(`teams["${i.clientId}"] not found`), a;
2964
2937
  },
2965
2938
  t
2966
- ), this.actions = new Rt(t), this.annexes = new jt(t), this.env = new Ot(t), this.events = new Mt(t), this.effects = new At(t), this.automations = new Tt(t), this.bimUses = new Ct(t, () => this.workflows), this.disciplines = new Dt(t), this.guides = new Ut(t), this.lods = new zt(t), this.lois = new Zt(t), this.loin = new Jt(t), this.lbsNodes = new Gt(t), this.assetTypes = new Kt(t), this.extensions = new qt(t), this.roles = new Wt(t), this.members = new Xt(t), this.milestones = new Vt(t), this.objectives = new Ht(t), this.phases = new Yt(t), this.remoteData = new Qt(t), this.resolvers = new es(t), this.softwares = new ts(t, () => this.assetTypes), this.standards = new ss(t, () => this._zip), this.teams = new ns(t, () => this.members), this.workflows = new os(t, () => this.members, () => this.teams), this.deliverables = new Pt(t, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Lt(t, () => this.members), this.flags = new Ft(t), this.engine = new Os(
2939
+ ), this.actions = new Rt(t), this.annexes = new Tt(t), this.env = new Ot(t), this.events = new Bt(t), this.effects = new At(t), this.automations = new jt(t), this.bimUses = new Ct(t, () => this.workflows), this.disciplines = new Dt(t), this.guides = new Ut(t), this.lods = new zt(t), this.lois = new Zt(t), this.loin = new Jt(t), this.lbsNodes = new Gt(t), this.assetTypes = new Kt(t), this.extensions = new qt(t), this.roles = new Wt(t), this.members = new Xt(t), this.milestones = new Vt(t), this.objectives = new Ht(t), this.phases = new Yt(t), this.remoteData = new Qt(t), this.resolvers = new es(t), this.softwares = new ts(t, () => this.assetTypes), this.standards = new ss(t, () => this._zip), this.teams = new ns(t, () => this.members), this.workflows = new os(t, () => this.members, () => this.teams), this.deliverables = new Pt(t, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Lt(t, () => this.members), this.flags = new Ft(t), this.engine = new Os(
2967
2940
  () => this._data,
2968
2941
  (i) => this.history.get(i)
2969
- ), this.history = new E(
2942
+ ), this.history = new S(
2970
2943
  t,
2971
2944
  (i) => {
2972
2945
  this._data = i;
2973
2946
  },
2974
2947
  () => this._zip
2975
- ), this.nomenclature = new xt(t), this.memory = new Z("memory.md", () => this._zip), this.skill = new Z("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new Z("icon.svg", () => this._zip);
2948
+ ), this.nomenclature = new Mt(t), this.memory = new Z("memory.md", () => this._zip), this.skill = new Z("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new Z("icon.svg", () => this._zip);
2976
2949
  }
2977
2950
  _data;
2978
2951
  _zip;
@@ -3105,7 +3078,7 @@ class F {
3105
3078
  delete this._data.deliverableNamingConvention;
3106
3079
  return;
3107
3080
  }
3108
- const s = ue.parse(e), t = kt(this._data, s);
3081
+ const s = ue.parse(e), t = Nt(this._data, s);
3109
3082
  if (t.length) throw new Error(`Naming convention incompatible with existing data:
3110
3083
  ${t.join(`
3111
3084
  `)}`);
@@ -3173,18 +3146,32 @@ ${t.join(`
3173
3146
  * writeFileSync('bep.d.ts', bep.generateRuntimeTypes())
3174
3147
  */
3175
3148
  generateRuntimeTypes() {
3176
- const e = (f) => f, s = (f) => ` /** ${f} */
3177
- `, t = (f) => `{ ${f.map((m) => `${m.key}${m.required ? "" : "?"}: ${e(m.type)}`).join("; ")} }`, i = (f) => !f.payload || f.payload.length === 0 ? "() => void" : `(payload: ${t(f.payload)}) => void`, o = (f) => {
3178
- const m = f.payload && f.payload.length > 0 ? `payload: ${t(f.payload)}` : "", p = f.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${f.output.map((g) => `${g.key}${g.required ? "" : "?"}: ${e(g.type)}`).join("; ")} }`;
3179
- return `(${m}) => ${p}`;
3180
- }, a = (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) => `${s(f.description)} '${f.id}': ${i(f)}`).join(`
3181
- `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((f) => `${s(f.description)} '${f.id}': ${o(f)}`).join(`
3182
- `) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((f) => `${s(f.description)} '${f.id}': ${a(f)}`).join(`
3183
- `) : " [key: string]: (url: string) => unknown", u = this._data.env.length ? this._data.env.map((f) => `${s(f.description)} ${f.key}: string`).join(`
3184
- `) : " [key: string]: string";
3185
- return [
3149
+ const e = (w) => w, s = (w) => ` /** ${w} */
3150
+ `, t = (w) => `{ ${w.map((I) => `${I.key}${I.required ? "" : "?"}: ${e(I.type)}`).join("; ")} }`, i = (w) => !w.payload || w.payload.length === 0 ? "() => void" : `(payload: ${t(w.payload)}) => void`, o = (w) => {
3151
+ const I = w.payload && w.payload.length > 0 ? `payload: ${t(w.payload)}` : "", $ = w.output.length === 0 ? "{ eventId: string }" : `{ eventId: string; ${w.output.map((N) => `${N.key}${N.required ? "" : "?"}: ${e(N.type)}`).join("; ")} }`;
3152
+ return `(${I}) => ${$}`;
3153
+ }, a = (w) => w.envKeys.length === 0 ? "(url: string) => unknown" : `(url: string, env: ${`{ ${w.envKeys.map(($) => `${$}: string`).join("; ")} }`}) => unknown`, d = this._data.effects.length ? this._data.effects.map((w) => `${s(w.description)} '${w.id}': ${i(w)}`).join(`
3154
+ `) : " [key: string]: () => void", l = this._data.automations.length ? this._data.automations.map((w) => `${s(w.description)} '${w.id}': ${o(w)}`).join(`
3155
+ `) : " [key: string]: () => { eventId: string }", c = this._data.resolvers.length ? this._data.resolvers.map((w) => `${s(w.description)} '${w.id}': ${a(w)}`).join(`
3156
+ `) : " [key: string]: (url: string) => unknown", f = this._data.env.length ? this._data.env.map((w) => `${s(w.description)} ${w.key}: string`).join(`
3157
+ `) : " [key: string]: string", u = this._data.workflows.length > 0, m = u ? this._data.workflows.map((w) => {
3158
+ const I = w.description ? `${w.name} — ${w.description}` : w.name;
3159
+ return `${s(I)} '${w.id}': never`;
3160
+ }).join(`
3161
+ `) : null, h = `(rawPayload: unknown) => ${`Promise<{ trackedAsset: import('@dotbep/core').WorkflowInstance['trackedAsset']; workflowId: ${u ? "WorkflowId" : "string"} }>`}`, k = this._data.softwares.length ? this._data.softwares.map((w) => `${s(w.name)} '${w.id}': ${h}`).join(`
3162
+ `) : ` [key: string]: ${h}`, b = [
3186
3163
  "// Generated by bep.generateRuntimeTypes() — do not edit manually",
3164
+ ""
3165
+ ];
3166
+ return m && b.push(
3167
+ "// ─── Workflows ───────────────────────────────────────────────────────────────",
3187
3168
  "",
3169
+ "export interface BepWorkflows {",
3170
+ m,
3171
+ "}",
3172
+ "export type WorkflowId = keyof BepWorkflows | (string & {})",
3173
+ ""
3174
+ ), b.push(
3188
3175
  "// ─── Effects ──────────────────────────────────────────────────────────────────",
3189
3176
  "",
3190
3177
  "export interface BepEffects {",
@@ -3203,10 +3190,16 @@ ${t.join(`
3203
3190
  c,
3204
3191
  "}",
3205
3192
  "",
3193
+ "// ─── Triggers ─────────────────────────────────────────────────────────────────",
3194
+ "",
3195
+ "export interface BepTriggers {",
3196
+ k,
3197
+ "}",
3198
+ "",
3206
3199
  "// ─── Env ──────────────────────────────────────────────────────────────────────",
3207
3200
  "",
3208
3201
  "export interface BepEnv {",
3209
- u,
3202
+ f,
3210
3203
  "}",
3211
3204
  "",
3212
3205
  "// ─── Combined ─────────────────────────────────────────────────────────────────",
@@ -3215,10 +3208,11 @@ ${t.join(`
3215
3208
  " effects: BepEffects",
3216
3209
  " automations: BepAutomations",
3217
3210
  " resolvers: BepResolvers",
3211
+ " triggers: BepTriggers",
3218
3212
  " env: BepEnv",
3219
3213
  "}",
3220
3214
  ""
3221
- ].join(`
3215
+ ), b.join(`
3222
3216
  `);
3223
3217
  }
3224
3218
  // ─── Serialization ────────────────────────────────────────────────────────
@@ -3236,10 +3230,10 @@ export {
3236
3230
  Rt as Actions,
3237
3231
  Re as AnnexSchema,
3238
3232
  Xe as AnnexType,
3239
- jt as Annexes,
3240
- we as AssetTypeSchema,
3233
+ Tt as Annexes,
3234
+ ye as AssetTypeSchema,
3241
3235
  Kt as AssetTypes,
3242
- Tt as Automations,
3236
+ jt as Automations,
3243
3237
  Ps as BEPSchema,
3244
3238
  ne as BEPVersionBase,
3245
3239
  It as BEPVersionSchema,
@@ -3248,7 +3242,7 @@ export {
3248
3242
  F as Bep,
3249
3243
  Fs as ChangelogSchema,
3250
3244
  Et as DEFAULT_DELIMITER,
3251
- St as DEFAULT_TOKEN_PATTERN,
3245
+ kt as DEFAULT_TOKEN_PATTERN,
3252
3246
  bt as DeliverableBaseSchema,
3253
3247
  Pe as DeliverableSchema,
3254
3248
  Pt as Deliverables,
@@ -3260,57 +3254,57 @@ export {
3260
3254
  y as Entity,
3261
3255
  Ot as Env,
3262
3256
  Fe as EnvVarSchema,
3263
- Mt as Events,
3264
- ye as ExtensionSchema,
3257
+ Bt as Events,
3258
+ we as ExtensionSchema,
3265
3259
  qt as Extensions,
3266
3260
  vt as FlagBaseSchema,
3267
3261
  Qe as FlagEntityType,
3268
- xe as FlagSchema,
3262
+ Me as FlagSchema,
3269
3263
  Ye as FlagSeverity,
3270
3264
  Ft as Flags,
3271
3265
  lt as FlowAutomationNodeSchema,
3272
- ke as FlowAutomationSchema,
3266
+ Ne as FlowAutomationSchema,
3273
3267
  pt as FlowDecisionEdgeSchema,
3274
3268
  dt as FlowDecisionNodeSchema,
3275
- yt as FlowDiagramSchema,
3269
+ wt as FlowDiagramSchema,
3276
3270
  ht as FlowDirectEdgeSchema,
3277
3271
  He as FlowDirection,
3278
3272
  gt as FlowEdgeSchema,
3279
- Ne as FlowEffectSchema,
3273
+ Se as FlowEffectSchema,
3280
3274
  at as FlowEndNodeSchema,
3281
- Se as FlowEventSchema,
3275
+ ke as FlowEventSchema,
3282
3276
  ft as FlowNodeSchema,
3283
3277
  L as FlowPayloadFieldSchema,
3284
3278
  ct as FlowProcessNodeSchema,
3285
3279
  rt as FlowStartNodeSchema,
3286
3280
  mt as FlowTransitionEdgeSchema,
3287
- je as GuideSchema,
3281
+ Te as GuideSchema,
3288
3282
  Ut as Guides,
3289
- E as History,
3283
+ S as History,
3290
3284
  Ge as ISORole,
3291
3285
  nt as LBSNodeBaseSchema,
3292
3286
  he as LBSNodeSchema,
3293
3287
  Ve as LBSNodeType,
3294
3288
  Gt as LBSNodes,
3295
- Te as LODSchema,
3289
+ je as LODSchema,
3296
3290
  zt as LODs,
3297
3291
  Jt as LOINEntity,
3298
- wt as LOINMilestoneSchema,
3299
- Me as LOINSchema,
3292
+ yt as LOINMilestoneSchema,
3293
+ Be as LOINSchema,
3300
3294
  Oe as LOISchema,
3301
3295
  Zt as LOIs,
3302
3296
  ce as MemberSchema,
3303
3297
  Xt as Members,
3304
- Ts as MemoryStorage,
3298
+ js as MemoryStorage,
3305
3299
  pe as MilestoneSchema,
3306
3300
  Vt as Milestones,
3307
3301
  ue as NamingConventionSchema,
3308
3302
  st as NamingSegmentSchema,
3309
3303
  tt as NamingTokenSchema,
3310
3304
  it as NodeTimeoutSchema,
3311
- xs as NodeType,
3312
- xt as Nomenclature,
3313
- Be as NoteSchema,
3305
+ Ms as NodeType,
3306
+ Mt as Nomenclature,
3307
+ xe as NoteSchema,
3314
3308
  Lt as Notes,
3315
3309
  be as ObjectiveSchema,
3316
3310
  Ht as Objectives,
@@ -3323,7 +3317,7 @@ export {
3323
3317
  es as Resolvers,
3324
3318
  le as RoleSchema,
3325
3319
  Wt as Roles,
3326
- Ds as Runtime,
3320
+ Cs as Runtime,
3327
3321
  _t as Singleton,
3328
3322
  ve as SoftwareSchema,
3329
3323
  ts as Softwares,
@@ -3341,14 +3335,13 @@ export {
3341
3335
  P as buildParentMap,
3342
3336
  Es as diffBep,
3343
3337
  Is as diffEntities,
3344
- Cs as flowDiagramToMermaid,
3345
3338
  ze as getNomenCode,
3346
3339
  Q as getRootIds,
3347
- Nt as getTokenPattern,
3340
+ St as getTokenPattern,
3348
3341
  Ls as groupRaciRows,
3349
3342
  j as normalizeBep,
3350
3343
  Ue as resolveLBSCodes,
3351
- kt as validateAllTokens,
3352
- Bt as validateLBS,
3353
- T as validateTokenValue
3344
+ Nt as validateAllTokens,
3345
+ xt as validateLBS,
3346
+ B as validateTokenValue
3354
3347
  };