@knkcs/contenthub-ui 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as e, C as t, D as n, M as r, N as i, S as a, T as o, _ as s, b as c, f as l, g as u, h as d, i as f, j as p, n as m, o as ee, r as h, s as te, t as ne, u as re, v as ie, w as g, x as ae, y as _ } from "./heads-dBmqNcOB.js";
1
+ import { C as e, D as t, E as n, F as r, M as i, N as a, P as o, S as s, T as c, _ as l, b as u, f as d, g as f, h as p, i as ee, k as m, n as h, o as te, r as g, s as ne, t as re, u as ie, v as ae, w as _, x as oe, y as se } from "./heads-DqHmAW0n.js";
2
2
  import { Code as v, ConnectError as y } from "@connectrpc/connect";
3
3
  import { createHostMembers as b } from "@knkcs/anker/host";
4
4
  //#region src/testing/fixtures.ts
@@ -18,7 +18,7 @@ function T() {
18
18
  }])
19
19
  };
20
20
  }
21
- function oe() {
21
+ function ce() {
22
22
  return [{
23
23
  id: "br_author",
24
24
  name: "Being revised by the author",
@@ -31,7 +31,7 @@ function oe() {
31
31
  updateTime: w
32
32
  }];
33
33
  }
34
- function E() {
34
+ function le() {
35
35
  return [
36
36
  {
37
37
  slug: "in_progress",
@@ -56,7 +56,7 @@ function E() {
56
56
  }
57
57
  ];
58
58
  }
59
- function se() {
59
+ function ue() {
60
60
  return {
61
61
  in_progress: ["in_review", "on_hold"],
62
62
  in_review: [
@@ -68,7 +68,7 @@ function se() {
68
68
  on_hold: ["in_progress"]
69
69
  };
70
70
  }
71
- function ce() {
71
+ function de() {
72
72
  return [
73
73
  {
74
74
  id: "cs_bgbl_270",
@@ -194,7 +194,7 @@ function ce() {
194
194
  }
195
195
  ];
196
196
  }
197
- function le() {
197
+ function fe() {
198
198
  return [{
199
199
  id: "rc_print",
200
200
  name: "Druckprobe",
@@ -209,7 +209,7 @@ function le() {
209
209
  independent: !0
210
210
  }];
211
211
  }
212
- function ue() {
212
+ function pe() {
213
213
  return [
214
214
  {
215
215
  id: "col_bgb",
@@ -237,7 +237,7 @@ function ue() {
237
237
  }
238
238
  ];
239
239
  }
240
- function de() {
240
+ function me() {
241
241
  return [
242
242
  {
243
243
  id: "bp_commentary",
@@ -253,7 +253,7 @@ function de() {
253
253
  }
254
254
  ];
255
255
  }
256
- function fe() {
256
+ function he() {
257
257
  return [
258
258
  {
259
259
  id: "bpr_paragraph_2",
@@ -275,7 +275,7 @@ function fe() {
275
275
  }
276
276
  ];
277
277
  }
278
- function pe() {
278
+ function ge() {
279
279
  let e = (e, t) => ({
280
280
  field_type: "text",
281
281
  config: {
@@ -287,6 +287,7 @@ function pe() {
287
287
  system: !1
288
288
  }), t = {
289
289
  displayName: "Paragraph",
290
+ accessor: "paragraph",
290
291
  dated: !0,
291
292
  fields: [e("number", "Number"), e("heading", "Heading")],
292
293
  parts: {}
@@ -296,13 +297,51 @@ function pe() {
296
297
  bpr_paragraph_2: t,
297
298
  bpr_footnote_1: {
298
299
  displayName: "Footnote",
300
+ accessor: "footnote",
299
301
  dated: !0,
300
302
  fields: [e("text", "Text")],
301
303
  parts: {}
304
+ },
305
+ bpr_note_1: {
306
+ displayName: "Note",
307
+ accessor: "note",
308
+ dated: !1,
309
+ fields: [e("title", "Title")],
310
+ parts: {}
302
311
  }
303
312
  };
304
313
  }
305
- function D() {
314
+ function E() {
315
+ let e = "2026-09-01T08:00:00.000Z";
316
+ return {
317
+ id: "content_note_1",
318
+ blueprintId: "bp_note",
319
+ blueprintReleaseId: "bpr_note_1",
320
+ collectionIds: [],
321
+ main: {
322
+ revisionId: "rev_note1_main",
323
+ data: { title: "Hinweis" },
324
+ revisionCreateTime: e
325
+ },
326
+ inForce: {
327
+ revisionId: "rev_note1_main",
328
+ data: { title: "Hinweis" },
329
+ revisionCreateTime: e,
330
+ releaseId: "rls_note1_1"
331
+ },
332
+ branches: {},
333
+ timeline: [{
334
+ ordinal: 1,
335
+ releaseId: "rls_note1_1",
336
+ kind: "revision",
337
+ revisionId: "rev_note1_main",
338
+ blueprintReleaseId: "bpr_note_1",
339
+ publishTime: e,
340
+ first: !0
341
+ }]
342
+ };
343
+ }
344
+ function _e() {
306
345
  let e = "2001-11-01T08:00:00.000Z";
307
346
  return {
308
347
  id: "content_para_3",
@@ -333,7 +372,7 @@ function D() {
333
372
  }]
334
373
  };
335
374
  }
336
- function me() {
375
+ function ve() {
337
376
  let e = "2026-09-01T08:00:00.000Z";
338
377
  return [
339
378
  {
@@ -586,7 +625,7 @@ function me() {
586
625
  }
587
626
  //#endregion
588
627
  //#region src/testing/stub-blueprint-source.ts
589
- function he(e = de(), t = fe()) {
628
+ function D(e = me(), t = he()) {
590
629
  return {
591
630
  async searchBlueprints({ query: t }) {
592
631
  let n = t.trim().toLocaleLowerCase();
@@ -605,37 +644,37 @@ function he(e = de(), t = fe()) {
605
644
  }
606
645
  //#endregion
607
646
  //#region src/testing/stub-client.ts
608
- function ge(e, t) {
647
+ function ye(e, t) {
609
648
  let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
610
649
  return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
611
650
  }
612
651
  function O(e, t, n) {
613
652
  let r = e.trim();
614
- if (r === "") throw new a(`${t} is required`);
615
- if ([...r].length > n) throw new a(`${t} is at most ${n} characters`);
616
- if (/[\u0000-\u001f\u007f]/.test(r)) throw new a(`${t} is one line of text`);
653
+ if (r === "") throw new _(`${t} is required`);
654
+ if ([...r].length > n) throw new _(`${t} is at most ${n} characters`);
655
+ if (/[\u0000-\u001f\u007f]/.test(r)) throw new _(`${t} is one line of text`);
617
656
  return r;
618
657
  }
619
- function _e(e) {
620
- if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new a(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
658
+ function be(e) {
659
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new _(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
621
660
  return {
622
661
  date: e.date.trim(),
623
662
  reference: O(e.reference, "source.reference", 500)
624
663
  };
625
664
  }
626
- function ve(e) {
665
+ function xe(e) {
627
666
  let t = e.trim();
628
- if (t === "") throw new a("a Block Reason needs a name");
629
- if ([...t].length > 200) throw new a("a Block Reason's name is at most 200 characters");
630
- if (/[\u0000-\u001f\u007f]/.test(t)) throw new a("a Block Reason's name is one line of text");
667
+ if (t === "") throw new _("a Block Reason needs a name");
668
+ if ([...t].length > 200) throw new _("a Block Reason's name is at most 200 characters");
669
+ if (/[\u0000-\u001f\u007f]/.test(t)) throw new _("a Block Reason's name is one line of text");
631
670
  return t;
632
671
  }
633
- function ye(e) {
672
+ function Se(e) {
634
673
  let t = O(e.name, "a Required Check's name", 200);
635
- if (e.scope !== "branch" && e.scope !== "change_set") throw new a("a Required Check's scope is Branch or Change Set");
674
+ if (e.scope !== "branch" && e.scope !== "change_set") throw new _("a Required Check's scope is Branch or Change Set");
636
675
  let n = e.blueprintAccessors.map((e) => {
637
676
  let t = e.trim();
638
- if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new a(`"${t}" is not a Blueprint accessor`);
677
+ if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new _(`"${t}" is not a Blueprint accessor`);
639
678
  return t;
640
679
  });
641
680
  return {
@@ -645,7 +684,7 @@ function ye(e) {
645
684
  independent: e.independent
646
685
  };
647
686
  }
648
- var be = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", xe = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it", Se = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
687
+ var Ce = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", we = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it", Te = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
649
688
  function k(e, t) {
650
689
  return new y(`${e} ${t}: not found`, v.NotFound);
651
690
  }
@@ -671,25 +710,40 @@ function j(e, t = {}) {
671
710
  };
672
711
  }
673
712
  function M(v = {}) {
674
- let y = v.now ?? (() => "2026-10-01T09:00:00.000Z"), b = v.userId ?? "user_stub", x = v.statuses ?? E(), S = v.statusTransitions ?? se(), C = (v.blockReasons ?? oe()).map((e) => ({ ...e })), w = (v.changeSets ?? ce()).map(A), T = (v.collections ?? ue()).map((e) => ({ ...e })), D = structuredClone(v.contents ?? me()), he = v.blueprints ?? de(), M = v.blueprintReleases ?? fe(), P = v.resolvedReleases ?? pe(), F = structuredClone(v.requiredChecks ?? le()), I = v.authzMode ?? "guardian", Ce = new Set(v.withheld ?? []), L = (e) => {
675
- if (Ce.has(e)) throw new i(xe);
676
- }, R = new Map(Object.entries(structuredClone(v.collectionGrants ?? {}))), z = new Map(Object.entries(structuredClone(v.recorders ?? {}))), we = (e) => z.get(e) ?? {
713
+ let y = v.now ?? (() => "2026-10-01T09:00:00.000Z"), b = v.userId ?? "user_stub", x = v.statuses ?? le(), S = v.statusTransitions ?? ue(), C = (v.blockReasons ?? ce()).map((e) => ({ ...e })), w = (v.changeSets ?? de()).map(A), T = (v.collections ?? pe()).map((e) => ({ ...e })), E = structuredClone(v.contents ?? ve()), _e = v.blueprints ?? me(), D = v.blueprintReleases ?? he(), M = v.resolvedReleases ?? ge(), N = structuredClone(v.requiredChecks ?? fe()), P = v.authzMode ?? "guardian", De = new Set(v.withheld ?? []), F = (e) => {
714
+ if (De.has(e)) throw new r(we);
715
+ }, I = new Map(Object.entries(structuredClone(v.collectionGrants ?? {}))), L = new Map(Object.entries(structuredClone(v.recorders ?? {}))), Oe = (e) => L.get(e) ?? {
677
716
  everyMember: !0,
678
717
  userIds: []
679
- }, Te = v.memberIds ?? ["user_stub", "user_ben"], Ee = v.admin ?? !0, De = structuredClone(v.checkResults ?? []), Oe = v.publishBlockers ?? {}, ke = v.pendingMerges ?? {}, Ae = structuredClone(v.conflicts ?? {}), B = /* @__PURE__ */ new Map(), je = /* @__PURE__ */ new Map(), V = async (e, t, n) => {
718
+ }, ke = v.memberIds ?? ["user_stub", "user_ben"], Ae = v.admin ?? !0, R = structuredClone(v.editingSettings ?? {
719
+ editingMode: "change_sets",
720
+ editingBlock: !1
721
+ }), z = structuredClone(v.editingOverrides ?? []), je = (e) => ({
722
+ editingMode: e?.editingMode ?? R.editingMode,
723
+ editingBlock: e?.editingBlock ?? R.editingBlock
724
+ }), Me = (e) => ({
725
+ ...structuredClone(e),
726
+ effective: je(e)
727
+ }), Ne = [
728
+ "direct_edits",
729
+ "change_sets",
730
+ "both"
731
+ ], Pe = () => {
732
+ if (!Ae) throw new ne("permission denied");
733
+ }, Fe = structuredClone(v.checkResults ?? []), Ie = v.publishBlockers ?? {}, Le = v.pendingMerges ?? {}, Re = structuredClone(v.conflicts ?? {}), B = /* @__PURE__ */ new Map(), ze = /* @__PURE__ */ new Map(), V = async (e, t, n) => {
680
734
  if (!e) return n();
681
- let r = JSON.stringify(t), i = je.get(e);
735
+ let r = JSON.stringify(t), i = ze.get(e);
682
736
  if (i) {
683
- if (i.asked !== r) throw new a(`idempotency key ${e} names another request`);
737
+ if (i.asked !== r) throw new _(`idempotency key ${e} names another request`);
684
738
  return structuredClone(i.answer);
685
739
  }
686
- let o = await n();
687
- return je.set(e, {
740
+ let a = await n();
741
+ return ze.set(e, {
688
742
  asked: r,
689
- answer: structuredClone(o)
690
- }), o;
691
- }, Me = /* @__PURE__ */ new Map(), Ne = /* @__PURE__ */ new Map(), H = 1, U = (e) => {
692
- let t = D.find((t) => t.id === e);
743
+ answer: structuredClone(a)
744
+ }), a;
745
+ }, Be = /* @__PURE__ */ new Map(), Ve = /* @__PURE__ */ new Map(), H = 1, U = (e) => {
746
+ let t = E.find((t) => t.id === e);
693
747
  if (!t) throw k("Content", e);
694
748
  return t;
695
749
  }, W = (e) => structuredClone({
@@ -697,7 +751,7 @@ function M(v = {}) {
697
751
  assigneeIds: e.assigneeIds ?? [],
698
752
  block: e.block,
699
753
  archiveTime: e.archiveTime
700
- }), Pe = () => y().slice(0, 10), G = (e) => P[e.blueprintReleaseId]?.dated ?? !1, K = (e) => {
754
+ }), He = () => y().slice(0, 10), G = (e) => M[e.blueprintReleaseId]?.dated ?? !1, K = (e) => {
701
755
  let t = [...e.revisions ?? []], n = [...Object.entries(e.branches).map(([e, t]) => ({
702
756
  ...t,
703
757
  changeSetId: e
@@ -724,58 +778,58 @@ function M(v = {}) {
724
778
  e.main,
725
779
  e.inForce,
726
780
  ...Object.values(e.branches)
727
- ].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Fe = (e, t) => {
781
+ ].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Ue = (e, t) => {
728
782
  let n = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
729
783
  return (e ?? []).filter((e) => e.config.required === !0 && n(t[e.config.api_accessor])).map((e) => e.config.api_accessor);
730
784
  }, J = (e) => {
731
- if (e.archiveTime) throw new s(e.id);
732
- if (e.block && !e.block.allowedUserIds.includes(b)) throw new ie(e.id, e.block.blockReasonId);
733
- }, Ie = (e) => D.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
785
+ if (e.archiveTime) throw new l(e.id);
786
+ if (e.block && !e.block.allowedUserIds.includes(b)) throw new ae(e.id, e.block.blockReasonId);
787
+ }, We = (e) => E.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
734
788
  edge: { ...e },
735
789
  releaseId: t.inForce?.releaseId ?? ""
736
- }))), Le = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Re = (e, t) => C.some((n) => n.name === e && n.id !== t), ze = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Y = (e) => {
790
+ }))), Ge = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Ke = (e, t) => C.some((n) => n.name === e && n.id !== t), qe = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Y = (e) => {
737
791
  let t = T.find((t) => t.id === e);
738
792
  if (!t) throw k("Collection", e);
739
793
  return t;
740
- }, Be = (e, t, n) => T.some((r) => r.parentId === e && r.name === t && r.id !== n), Ve = (e) => {
741
- if (I === "workspace") throw new n(Se);
742
- if (!Y(e).restricted) throw new a(`Collection ${e} is open: only a Restricted Collection takes grants`);
743
- let t = (R.get(e) ?? []).some((e) => e.userId === b && e.level === "owner");
744
- if (!Ee && !t) throw new te("only its owner or a workspace admin manages its grants");
745
- }, He = (e) => {
746
- if (I === "workspace") throw new ae("required_check_recorders", be);
747
- if (!Ee) throw new te("permission denied");
748
- if (e === "") throw new a("required_check_id is required");
749
- if (!F.some((t) => t.id === e)) throw k("Required Check", e);
750
- return we(e);
751
- }, Ue = async ({ changeSetId: t, branchId: n, expectedHeadId: r, data: i, fieldMask: o }) => {
752
- let s = Z(t).chains.find((e) => e.branches.some((e) => e.id === n)), c = s?.branches.find((e) => e.id === n);
753
- if (!s || !c) throw k("Branch", n);
754
- let l = U(s.contentId);
755
- if (J(l), B.has(n)) throw new a("a Pending Merge waits on this Branch: resolve or abort it first");
756
- if (r === "") throw new a("expected_head_id is required");
757
- if (c.headRevisionId !== r) throw new e({
758
- contentId: l.id,
759
- branchId: n,
760
- expectedHeadId: r,
761
- currentHeadId: c.headRevisionId
794
+ }, Je = (e, t, n) => T.some((r) => r.parentId === e && r.name === t && r.id !== n), Ye = (e) => {
795
+ if (P === "workspace") throw new m(Te);
796
+ if (!Y(e).restricted) throw new _(`Collection ${e} is open: only a Restricted Collection takes grants`);
797
+ let t = (I.get(e) ?? []).some((e) => e.userId === b && e.level === "owner");
798
+ if (!Ae && !t) throw new ne("only its owner or a workspace admin manages its grants");
799
+ }, Xe = (t) => {
800
+ if (P === "workspace") throw new e("required_check_recorders", Ce);
801
+ if (!Ae) throw new ne("permission denied");
802
+ if (t === "") throw new _("required_check_id is required");
803
+ if (!N.some((e) => e.id === t)) throw k("Required Check", t);
804
+ return Oe(t);
805
+ }, Ze = async ({ changeSetId: e, branchId: t, expectedHeadId: n, data: r, fieldMask: a }) => {
806
+ let o = Z(e).chains.find((e) => e.branches.some((e) => e.id === t)), s = o?.branches.find((e) => e.id === t);
807
+ if (!o || !s) throw k("Branch", t);
808
+ let c = U(o.contentId);
809
+ if (J(c), B.has(t)) throw new _("a Pending Merge waits on this Branch: resolve or abort it first");
810
+ if (n === "") throw new _("expected_head_id is required");
811
+ if (s.headRevisionId !== n) throw new i({
812
+ contentId: c.id,
813
+ branchId: t,
814
+ expectedHeadId: n,
815
+ currentHeadId: s.headRevisionId
762
816
  });
763
- let u = q(l, c.headRevisionId) ?? {}, d = JSON.parse(JSON.stringify(i)), f;
764
- if (o) {
765
- let e = Object.keys(d).filter((e) => !o.includes(e));
766
- if (e.length > 0) throw new a(`data holds ${e.join(", ")}, which the mask doesn't name`);
767
- f = structuredClone(u);
768
- for (let e of o) e in d ? f[e] = d[e] : delete f[e];
769
- } else f = d;
770
- return We({
771
- changeSetId: t,
772
- chain: s,
773
- branch: c,
774
- c: l,
775
- data: f,
817
+ let l = q(c, s.headRevisionId) ?? {}, u = JSON.parse(JSON.stringify(r)), d;
818
+ if (a) {
819
+ let e = Object.keys(u).filter((e) => !a.includes(e));
820
+ if (e.length > 0) throw new _(`data holds ${e.join(", ")}, which the mask doesn't name`);
821
+ d = structuredClone(l);
822
+ for (let e of a) e in u ? d[e] = u[e] : delete d[e];
823
+ } else d = u;
824
+ return Qe({
825
+ changeSetId: e,
826
+ chain: o,
827
+ branch: s,
828
+ c,
829
+ data: d,
776
830
  cause: "save"
777
831
  });
778
- }, We = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
832
+ }, Qe = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
779
833
  let s = n.id, c = `rev_stub_${H++}`, l = y();
780
834
  return r.revisions = [{
781
835
  id: c,
@@ -805,7 +859,7 @@ function M(v = {}) {
805
859
  revisionCreateTime: l,
806
860
  releaseId: ""
807
861
  };
808
- }, Ge = (e, t) => {
862
+ }, $e = (e, t) => {
809
863
  let n = Z(e), r = n.chains.find((e) => e.branches.some((e) => e.id === t)), i = r?.branches.find((e) => e.id === t);
810
864
  if (!r || !i) throw k("Branch", t);
811
865
  return {
@@ -814,7 +868,7 @@ function M(v = {}) {
814
868
  branch: i,
815
869
  c: U(r.contentId)
816
870
  };
817
- }, Ke = (e, t) => {
871
+ }, et = (e, t) => {
818
872
  for (let n of w) for (let r of n.chains) {
819
873
  let n = r.branches.find((t) => t.id === e);
820
874
  if (!n) continue;
@@ -828,33 +882,33 @@ function M(v = {}) {
828
882
  fields: structuredClone(t.fields),
829
883
  merged: structuredClone(t.merged)
830
884
  };
831
- B.set(e, i), n.hasPendingMerge = !0, delete Ae[e];
885
+ B.set(e, i), n.hasPendingMerge = !0, delete Re[e];
832
886
  return;
833
887
  }
834
888
  throw k("Branch", e);
835
- }, qe = (e) => {
889
+ }, tt = (e) => {
836
890
  B.delete(e);
837
891
  for (let t of w) for (let n of t.chains) {
838
892
  let t = n.branches.find((t) => t.id === e);
839
893
  t && (t.hasPendingMerge = !1);
840
894
  }
841
- }, Je = (e, t) => {
895
+ }, nt = (e, t) => {
842
896
  let n = t.validityPeriod;
843
897
  if (G(e)) {
844
- if (!n || !h.test(n.firstDay)) throw new a("validity_period.first_day is required for Dated Content");
845
- if (n.lastDay !== "" && (!h.test(n.lastDay) || n.lastDay < n.firstDay)) throw new a("validity_period.last_day is a day on or after first_day");
846
- } else if (n) throw new a("validity_period is refused for undated Content");
847
- let r = Fe(P[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
898
+ if (!n || !g.test(n.firstDay)) throw new _("validity_period.first_day is required for Dated Content");
899
+ if (n.lastDay !== "" && (!g.test(n.lastDay) || n.lastDay < n.firstDay)) throw new _("validity_period.last_day is a day on or after first_day");
900
+ } else if (n) throw new _("validity_period is refused for undated Content");
901
+ let r = Ue(M[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
848
902
  source: "fieldkit",
849
903
  code: "required",
850
904
  path: `/${e}`
851
905
  }));
852
- if (r.length > 0) throw new _("the Release Spec values break the Blueprint Release", r);
906
+ if (r.length > 0) throw new se("the Release Spec values break the Blueprint Release", r);
853
907
  if (n && n.lastDay !== "") {
854
908
  let r = (e.timeline ?? []).filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && n.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= n.lastDay && !t.supersedesReleaseIds.includes(e.releaseId)).map((e) => e.releaseId);
855
- if (r.length > 0) throw new c(e.id, r);
909
+ if (r.length > 0) throw new u(e.id, r);
856
910
  }
857
- }, Ye = (e, t) => {
911
+ }, rt = (e, t) => {
858
912
  let n = e.plannedReleases.filter((e) => e.contentId === t.id && e.proposed), r = e.plannedReleases.filter((e) => !(e.contentId === t.id && e.proposed)), i = [], a = (e, r, a) => {
859
913
  let o = n.find((t) => t.proposedForReleaseId === e.releaseId && t.splitFromReleaseId === a);
860
914
  i.push({
@@ -877,9 +931,9 @@ function M(v = {}) {
877
931
  let t = r.validityPeriod;
878
932
  t && !e.supersedesReleaseIds.includes(r.releaseId) && t.firstDay < n.firstDay && (t.lastDay === "" || t.lastDay >= n.firstDay) && (a(r, {
879
933
  firstDay: t.firstDay,
880
- lastDay: ge(n.firstDay, -1)
934
+ lastDay: ye(n.firstDay, -1)
881
935
  }, ""), n.lastDay !== "" && (t.lastDay === "" || t.lastDay > n.lastDay) && a(r, {
882
- firstDay: ge(n.lastDay, 1),
936
+ firstDay: ye(n.lastDay, 1),
883
937
  lastDay: t.lastDay
884
938
  }, r.releaseId));
885
939
  }
@@ -891,9 +945,9 @@ function M(v = {}) {
891
945
  return t;
892
946
  }, Z = (e) => {
893
947
  let t = X(e);
894
- if (t.state !== "open") throw new d(t.state);
948
+ if (t.state !== "open") throw new p(t.state);
895
949
  return t;
896
- }, Xe = (e) => x.find((t) => t.slug === e)?.name ?? e, Ze = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (w.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => Ze(e, t, n))), Qe = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
950
+ }, it = (e) => x.find((t) => t.slug === e)?.name ?? e, at = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (w.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => at(e, t, n))), ot = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
897
951
  key: t.id,
898
952
  branchless: !1,
899
953
  contentId: e.contentId,
@@ -903,9 +957,9 @@ function M(v = {}) {
903
957
  branchless: !0,
904
958
  contentId: e.contentId,
905
959
  revision: e.revisionId
906
- }))], $e = (e) => D.find((t) => t.id === e)?.blueprintId, et = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes($e(t) ?? ""), tt = (e) => {
907
- let t = Qe(e), n = (t, n) => De.filter((n) => n.changeSetId === e.id && n.requiredCheckId === t.id).filter((e) => (t.scope === "change_set" ? "" : Object.keys(e.heads)[0]) === n).reverse().map(({ changeSetId: e, ...t }) => structuredClone(t)), r = (e, t, n) => {
908
- let r = n[0], i = r ? !m(r.heads, t.heads) : !1;
960
+ }))], st = (e) => E.find((t) => t.id === e)?.blueprintId, ct = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes(st(t) ?? ""), lt = (e) => {
961
+ let t = ot(e), n = (t, n) => Fe.filter((n) => n.changeSetId === e.id && n.requiredCheckId === t.id).filter((e) => (t.scope === "change_set" ? "" : Object.keys(e.heads)[0]) === n).reverse().map(({ changeSetId: e, ...t }) => structuredClone(t)), r = (e, t, n) => {
962
+ let r = n[0], i = r ? !h(r.heads, t.heads) : !1;
909
963
  return {
910
964
  check: structuredClone(e),
911
965
  ...t,
@@ -914,8 +968,8 @@ function M(v = {}) {
914
968
  cleared: !!r && !i && r.outcome !== "failed"
915
969
  };
916
970
  }, i = [], a = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
917
- for (let e of [...F].sort(a)) {
918
- let a = t.filter((t) => et(e, t.contentId));
971
+ for (let e of [...N].sort(a)) {
972
+ let a = t.filter((t) => ct(e, t.contentId));
919
973
  if (e.scope === "change_set") {
920
974
  if (a.length === 0) continue;
921
975
  let o = Object.fromEntries(t.map((e) => [e.key, e.revision]));
@@ -935,8 +989,8 @@ function M(v = {}) {
935
989
  }, n(e, t.key)));
936
990
  }
937
991
  return i;
938
- }, nt = (e, t) => {
939
- let n = [], r = ne(e);
992
+ }, ut = (e, t) => {
993
+ let n = [], r = re(e);
940
994
  for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(j("moved_head", {
941
995
  contentId: r.contentId,
942
996
  branchId: e.id,
@@ -951,26 +1005,26 @@ function M(v = {}) {
951
1005
  let e = w.find((e) => e.id === t)?.state;
952
1006
  e === "open" ? n.push(j("unpublished_dependency", { dependencyChangeSetId: t })) : e === "discarded" && n.push(j("discarded_dependency", { dependencyChangeSetId: t }));
953
1007
  }
954
- for (let t of tt(e)) t.cleared || n.push(j("outstanding_check", {
1008
+ for (let t of lt(e)) t.cleared || n.push(j("outstanding_check", {
955
1009
  requiredCheckId: t.check.id,
956
1010
  contentId: t.contentId,
957
1011
  branchId: t.branchId,
958
1012
  releaseId: t.releaseId
959
1013
  }));
960
1014
  for (let t of e.chains) {
961
- let e = D.find((e) => e.id === t.contentId);
1015
+ let e = E.find((e) => e.id === t.contentId);
962
1016
  for (let r of t.branches) {
963
1017
  let t = e && q(e, r.headRevisionId);
964
- if (e && t) for (let i of Fe(P[e.blueprintReleaseId]?.fields, t)) n.push(j("missing_required_field", {
1018
+ if (e && t) for (let i of Ue(M[e.blueprintReleaseId]?.fields, t)) n.push(j("missing_required_field", {
965
1019
  contentId: e.id,
966
1020
  revisionId: r.headRevisionId,
967
1021
  path: `/${i}`
968
1022
  }));
969
1023
  }
970
1024
  }
971
- return [...n, ...structuredClone(Oe[e.id] ?? [])];
1025
+ return [...n, ...structuredClone(Ie[e.id] ?? [])];
972
1026
  }, Q = (e) => {
973
- let t = ne(e);
1027
+ let t = re(e);
974
1028
  return e.plannedReleases.filter((e) => !e.withheld).map((n) => ({
975
1029
  id: n.id,
976
1030
  contentId: n.contentId,
@@ -982,14 +1036,14 @@ function M(v = {}) {
982
1036
  validityPeriod: n.validityPeriod ? { ...n.validityPeriod } : void 0
983
1037
  }));
984
1038
  };
985
- for (let [e, t] of Object.entries(Ae)) t.pending && Ke(e, t);
986
- return {
1039
+ for (let [e, t] of Object.entries(Re)) t.pending && et(e, t);
1040
+ let $ = {
987
1041
  async listBlockReasons() {
988
- return [...C].sort(Le).map((e) => ({ ...e }));
1042
+ return [...C].sort(Ge).map((e) => ({ ...e }));
989
1043
  },
990
1044
  async createBlockReason({ name: e }) {
991
- let t = ve(e);
992
- if (Re(t)) throw new re(t);
1045
+ let t = xe(e);
1046
+ if (Ke(t)) throw new ie(t);
993
1047
  let n = {
994
1048
  id: `br_stub_${H++}`,
995
1049
  name: t,
@@ -999,9 +1053,9 @@ function M(v = {}) {
999
1053
  return C.push(n), { ...n };
1000
1054
  },
1001
1055
  async renameBlockReason({ id: e, name: t }) {
1002
- let n = ve(t), r = C.find((t) => t.id === e);
1056
+ let n = xe(t), r = C.find((t) => t.id === e);
1003
1057
  if (!r) throw k("Block Reason", e);
1004
- if (Re(n, e)) throw new re(n);
1058
+ if (Ke(n, e)) throw new ie(n);
1005
1059
  return r.name = n, r.updateTime = y(), { ...r };
1006
1060
  },
1007
1061
  async deleteBlockReason({ id: e }) {
@@ -1009,7 +1063,7 @@ function M(v = {}) {
1009
1063
  C = C.filter((t) => t.id !== e);
1010
1064
  },
1011
1065
  async listChangeSets(e = {}) {
1012
- let t = w.filter((t) => (!e.state || t.state === e.state) && (!e.assigneeId || t.assigneeIds.includes(e.assigneeId)) && (!e.contentId || t.chains.some((t) => t.contentId === e.contentId))), n = Math.min(e.pageSize || 50, 200), r = e.pageToken ? Number(e.pageToken) : 0;
1066
+ let t = w.filter((t) => (!e.state || t.state === e.state) && (!e.assigneeId || t.assigneeIds.includes(e.assigneeId)) && (!e.contentId || t.chains.some((t) => t.contentId === e.contentId)) && (!e.kind || (t.kind ?? "change_set") === e.kind) && (!e.editorId || t.editorId === e.editorId)), n = Math.min(e.pageSize || 50, 200), r = e.pageToken ? Number(e.pageToken) : 0;
1013
1067
  return {
1014
1068
  changeSets: t.slice(r, r + n).map((e) => ({
1015
1069
  ...A(e),
@@ -1021,7 +1075,7 @@ function M(v = {}) {
1021
1075
  };
1022
1076
  },
1023
1077
  async createChangeSet({ name: e, source: t }) {
1024
- let n = O(e, "name", 200), r = t ? _e(t) : void 0, i = {
1078
+ let n = O(e, "name", 200), r = t ? be(t) : void 0, i = {
1025
1079
  id: `cs_stub_${H++}`,
1026
1080
  name: n,
1027
1081
  source: r,
@@ -1041,33 +1095,33 @@ function M(v = {}) {
1041
1095
  },
1042
1096
  async updateChangeSet({ id: e, updateMask: t, name: n, source: r }) {
1043
1097
  let i = Z(e);
1044
- if (t.length === 0) throw new a("update_mask is required");
1045
- let o = t.includes("name") ? O(n ?? "", "name", 200) : i.name, s = i.source;
1046
- return t.includes("source") && (s = r ? _e(r) : void 0), i.name = o, i.source = s, A(i);
1098
+ if (t.length === 0) throw new _("update_mask is required");
1099
+ let a = t.includes("name") ? O(n ?? "", "name", 200) : i.name, o = i.source;
1100
+ return t.includes("source") && (o = r ? be(r) : void 0), i.name = a, i.source = o, A(i);
1047
1101
  },
1048
1102
  async setChangeSetStatus({ id: e, expectedStatus: t, status: n }) {
1049
- let i = Z(e);
1050
- if (i.status !== t) throw new p(i.status);
1051
- if (i.status === n) return A(i);
1052
- if (!x.some((e) => e.slug === n)) throw new a(`status "${n}" is not in the workspace's catalogue`);
1053
- if (x.some((e) => e.slug === i.status) && !(S[i.status] ?? []).includes(n)) throw new r({
1054
- fromStatus: i.status,
1103
+ let r = Z(e);
1104
+ if (r.status !== t) throw new a(r.status);
1105
+ if (r.status === n) return A(r);
1106
+ if (!x.some((e) => e.slug === n)) throw new _(`status "${n}" is not in the workspace's catalogue`);
1107
+ if (x.some((e) => e.slug === r.status) && !(S[r.status] ?? []).includes(n)) throw new o({
1108
+ fromStatus: r.status,
1055
1109
  toStatus: n,
1056
- reason: `There is no transition from ${Xe(i.status)} to ${Xe(n)}.`,
1110
+ reason: `There is no transition from ${it(r.status)} to ${it(n)}.`,
1057
1111
  requiresPermission: !1
1058
1112
  });
1059
- return i.status = n, A(i);
1113
+ return r.status = n, A(r);
1060
1114
  },
1061
1115
  async setChangeSetAssignees({ id: e, assigneeIds: t }) {
1062
1116
  let n = X(e);
1063
- if (new Set(t).size !== t.length) throw new a("each assignee is given once");
1064
- if (t.length > 50) throw new a("at most 50 assignees");
1117
+ if (new Set(t).size !== t.length) throw new _("each assignee is given once");
1118
+ if (t.length > 50) throw new _("at most 50 assignees");
1065
1119
  return n.assigneeIds = [...t], A(n);
1066
1120
  },
1067
1121
  async addDependency({ id: e, dependsOnId: t }) {
1068
1122
  let n = Z(e), r = X(t);
1069
- if (r.state !== "open") throw new a(`Change Set ${t} is ${r.state}`);
1070
- if (Ze(t, e)) throw new a("the dependency would close a cycle");
1123
+ if (r.state !== "open") throw new _(`Change Set ${t} is ${r.state}`);
1124
+ if (at(t, e)) throw new _("the dependency would close a cycle");
1071
1125
  return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t), A(n);
1072
1126
  },
1073
1127
  async removeDependency({ id: e, dependsOnId: t }) {
@@ -1077,39 +1131,102 @@ function M(v = {}) {
1077
1131
  },
1078
1132
  async validatePublish({ id: e, reviewedHeads: t }) {
1079
1133
  let n = X(e);
1080
- L(e);
1081
- let r = Me.get(e);
1082
- if (r && m(r, t)) return {
1134
+ F(e);
1135
+ let r = Be.get(e);
1136
+ if (r && h(r, t)) return {
1083
1137
  blockers: [],
1084
1138
  releases: Q(n),
1085
1139
  published: !0
1086
1140
  };
1087
- if (n.state !== "open") throw new d(n.state);
1141
+ if (n.state !== "open") throw new p(n.state);
1088
1142
  return {
1089
- blockers: nt(n, t),
1143
+ blockers: ut(n, t),
1090
1144
  releases: Q(n),
1091
1145
  published: !1
1092
1146
  };
1093
1147
  },
1094
- async publish({ id: e, reviewedHeads: t }) {
1095
- let n = X(e);
1096
- L(e);
1097
- let r = Me.get(e);
1098
- if (r && m(r, t)) return {
1099
- changeSet: A(n),
1100
- publishTime: n.closeTime ?? y(),
1101
- releases: Q(n)
1148
+ async publish({ id: e, reviewedHeads: n }) {
1149
+ let r = X(e);
1150
+ F(e);
1151
+ let i = Be.get(e);
1152
+ if (i && h(i, n)) return {
1153
+ changeSet: A(r),
1154
+ publishTime: r.closeTime ?? y(),
1155
+ releases: Q(r)
1102
1156
  };
1103
- if (n.state !== "open") throw new d(n.state);
1104
- let i = nt(n, t);
1105
- if (i.length > 0) throw new o(i);
1106
- let a = Q(n);
1107
- return n.state = "published", n.closeTime = y(), Me.set(e, { ...t }), {
1108
- changeSet: A(n),
1109
- publishTime: n.closeTime,
1110
- releases: a
1157
+ if (r.state !== "open") throw new p(r.state);
1158
+ let a = ut(r, n);
1159
+ if (a.length > 0) throw new t(a);
1160
+ let o = Q(r);
1161
+ return r.state = "published", r.closeTime = y(), Be.set(e, { ...n }), {
1162
+ changeSet: A(r),
1163
+ publishTime: r.closeTime,
1164
+ releases: o
1111
1165
  };
1112
1166
  },
1167
+ async changeValidity({ releaseId: e, validityPeriod: n, changeSetName: r, idempotencyKey: i }) {
1168
+ return V(i, [
1169
+ "changeValidity",
1170
+ e,
1171
+ n,
1172
+ r
1173
+ ], async () => {
1174
+ let i = E.find((t) => (t.timeline ?? []).some((t) => t.releaseId === e));
1175
+ if (!i) throw k("Release", e);
1176
+ J(i);
1177
+ let a = i.timeline ?? [], o = a.find((t) => t.releaseId === e);
1178
+ if (!o?.validityPeriod || !G(i)) throw new _("undated Releases carry no Validity Period");
1179
+ let { firstDay: c, lastDay: l = "" } = n;
1180
+ if (!g.test(c) || l !== "" && (!g.test(l) || l < c)) throw new _("validity_period is YYYY-MM-DD, the last day not before the first");
1181
+ let d = M[i.blueprintReleaseId]?.accessor ?? "", f = z.find((e) => e.blueprintAccessor === d);
1182
+ if (je(f).editingMode === "change_sets") throw new s(i.id, d);
1183
+ let p = a.filter((t) => t.releaseId !== e && t.validityPeriod && c <= t.validityPeriod.firstDay && (l === "" || t.validityPeriod.lastDay !== "" && t.validityPeriod.lastDay <= l)).map((e) => e.releaseId);
1184
+ if (p.length > 0) throw new u(i.id, p, !0);
1185
+ let ee = {
1186
+ id: `rls_stub_${H++}`,
1187
+ contentId: i.id,
1188
+ kind: "date_only",
1189
+ branchId: "",
1190
+ revisionId: o.revisionId,
1191
+ validityPeriod: {
1192
+ firstDay: c,
1193
+ lastDay: l
1194
+ },
1195
+ supersedesReleaseIds: [e],
1196
+ proposed: !1,
1197
+ proposedForReleaseId: "",
1198
+ splitFromReleaseId: "",
1199
+ withheld: !1
1200
+ }, m = {
1201
+ id: `cs_stub_${H++}`,
1202
+ name: r?.trim() || `Change of validity of ${i.id}`,
1203
+ state: "open",
1204
+ createdBy: b,
1205
+ createTime: y(),
1206
+ chains: [],
1207
+ dependsOnChangeSetIds: [],
1208
+ status: "",
1209
+ assigneeIds: [],
1210
+ plannedReleases: [ee]
1211
+ }, h = ut(m, {});
1212
+ if (h.length > 0) throw new t(h);
1213
+ let te = Q(m);
1214
+ return m.state = "published", m.closeTime = y(), w.unshift(m), Be.set(m.id, {}), i.timeline = a.map((t) => t.releaseId === e ? {
1215
+ ...t,
1216
+ releaseId: ee.id,
1217
+ kind: "date_only",
1218
+ validityPeriod: {
1219
+ firstDay: c,
1220
+ lastDay: l
1221
+ },
1222
+ publishTime: m.closeTime ?? y()
1223
+ } : t), {
1224
+ changeSet: A(m),
1225
+ publishTime: m.closeTime,
1226
+ releases: te
1227
+ };
1228
+ });
1229
+ },
1113
1230
  async updateFromMain({ id: e, chainId: t, idempotencyKey: n }) {
1114
1231
  return V(n, [
1115
1232
  "updateFromMain",
@@ -1117,16 +1234,16 @@ function M(v = {}) {
1117
1234
  t
1118
1235
  ], async () => {
1119
1236
  let n = Z(e);
1120
- t || L(e);
1237
+ t || F(e);
1121
1238
  let r = t ? n.chains.filter((e) => e.id === t) : n.chains;
1122
1239
  if (t && r.length === 0) throw k("Chain", t);
1123
- let i = structuredClone(ke[e] ?? []), a = [];
1240
+ let i = structuredClone(Le[e] ?? []), a = [];
1124
1241
  for (let e of r) for (let t of e.branches) {
1125
1242
  let n = {
1126
1243
  branchId: t.id,
1127
1244
  contentId: e.contentId
1128
- }, r = Ae[t.id];
1129
- B.has(t.id) ? a.push(n) : r && (Ke(t.id, r), i.push(n));
1245
+ }, r = Re[t.id];
1246
+ B.has(t.id) ? a.push(n) : r && (et(t.id, r), i.push(n));
1130
1247
  }
1131
1248
  return {
1132
1249
  changeSet: A(n),
@@ -1139,90 +1256,126 @@ function M(v = {}) {
1139
1256
  },
1140
1257
  async discardChangeSet(e) {
1141
1258
  let t = Z(e);
1142
- return L(e), t.state = "discarded", t.closeTime = y(), t.chains = [], A(t);
1259
+ return F(e), t.state = "discarded", t.closeTime = y(), t.chains = [], A(t);
1143
1260
  },
1144
1261
  async listCheckResults(e) {
1145
- return tt(X(e));
1146
- },
1147
- async recordCheckResult({ changeSetId: t, requiredCheckId: n, heads: r, outcome: i, note: o }) {
1148
- let s = Z(t);
1149
- if (i === "waived" && o.trim() === "") throw new a("a waived result needs a note saying why");
1150
- if ([...o].length > 2e3) throw new a(`a note is at most ${l} characters`);
1151
- let c = F.find((e) => e.id === n);
1152
- if (!c) throw k("Required Check", n);
1153
- let d = we(n);
1154
- if (I === "guardian" && !d.everyMember && !d.userIds.includes(b)) throw new u(`recording results of Required Check ${n} needs its recorder relation`);
1155
- let f = Qe(s), p = Object.keys(r);
1156
- if (c.scope === "branch" && p.length !== 1) throw new a("a Branch-scope result names one head");
1157
- if (c.scope === "change_set" && p.length !== f.length) throw new a("a Change Set-scope result names every head of the Change Set");
1158
- for (let t of p) {
1159
- let n = f.find((e) => e.key === t);
1160
- if (!n) throw new a(`heads name ${t}, which this Change Set doesn't hold`);
1161
- if (n.revision !== r[t]) throw new e({
1162
- contentId: n.contentId,
1163
- branchId: n.branchless ? "" : n.key,
1164
- expectedHeadId: r[t],
1165
- currentHeadId: n.revision
1262
+ return lt(X(e));
1263
+ },
1264
+ async recordCheckResult({ changeSetId: e, requiredCheckId: t, heads: n, outcome: r, note: a }) {
1265
+ let o = Z(e);
1266
+ if (r === "waived" && a.trim() === "") throw new _("a waived result needs a note saying why");
1267
+ if ([...a].length > 2e3) throw new _(`a note is at most ${d} characters`);
1268
+ let s = N.find((e) => e.id === t);
1269
+ if (!s) throw k("Required Check", t);
1270
+ let c = Oe(t);
1271
+ if (P === "guardian" && !c.everyMember && !c.userIds.includes(b)) throw new f(`recording results of Required Check ${t} needs its recorder relation`);
1272
+ let l = ot(o), u = Object.keys(n);
1273
+ if (s.scope === "branch" && u.length !== 1) throw new _("a Branch-scope result names one head");
1274
+ if (s.scope === "change_set" && u.length !== l.length) throw new _("a Change Set-scope result names every head of the Change Set");
1275
+ for (let e of u) {
1276
+ let t = l.find((t) => t.key === e);
1277
+ if (!t) throw new _(`heads name ${e}, which this Change Set doesn't hold`);
1278
+ if (t.revision !== n[e]) throw new i({
1279
+ contentId: t.contentId,
1280
+ branchId: t.branchless ? "" : t.key,
1281
+ expectedHeadId: n[e],
1282
+ currentHeadId: t.revision
1166
1283
  });
1167
1284
  }
1168
- let m = {
1285
+ let p = {
1169
1286
  id: `cr_stub_${H++}`,
1170
- requiredCheckId: n,
1171
- heads: { ...r },
1172
- outcome: i,
1173
- note: o,
1287
+ requiredCheckId: t,
1288
+ heads: { ...n },
1289
+ outcome: r,
1290
+ note: a,
1174
1291
  recordedBy: b,
1175
1292
  recordTime: y()
1176
1293
  };
1177
- return De.push({
1178
- ...m,
1179
- changeSetId: t
1180
- }), structuredClone(m);
1294
+ return Fe.push({
1295
+ ...p,
1296
+ changeSetId: e
1297
+ }), structuredClone(p);
1298
+ },
1299
+ async getEditingSettings() {
1300
+ let e = [...z].sort((e, t) => e.blueprintAccessor < t.blueprintAccessor ? -1 : 1);
1301
+ return {
1302
+ workspace: { ...R },
1303
+ overrides: e.map(Me)
1304
+ };
1305
+ },
1306
+ async getEffectiveEditingSettings(e) {
1307
+ let t = z.find((t) => t.blueprintAccessor === e.trim());
1308
+ return {
1309
+ effective: je(t),
1310
+ editingModeOverridden: (t?.editingMode ?? null) !== null,
1311
+ editingBlockOverridden: (t?.editingBlock ?? null) !== null
1312
+ };
1313
+ },
1314
+ async setEditingSettings(e) {
1315
+ if (Pe(), !Ne.includes(e.editingMode)) throw new _("the workspace's editing settings need an Editing Mode");
1316
+ return R = { ...e }, { ...R };
1317
+ },
1318
+ async setBlueprintEditingOverride({ blueprintAccessor: e, editingMode: t, editingBlock: n }) {
1319
+ Pe();
1320
+ let r = O(e, "a Blueprint accessor", 200);
1321
+ if (t === null && n === null) throw new _(`an override of "${r}" sets the Editing Mode, the Editing Block or both`);
1322
+ let i = {
1323
+ blueprintAccessor: r,
1324
+ editingMode: t,
1325
+ editingBlock: n
1326
+ };
1327
+ return z = [...z.filter((e) => e.blueprintAccessor !== r), i], Me(i);
1328
+ },
1329
+ async deleteBlueprintEditingOverride({ blueprintAccessor: e }) {
1330
+ Pe();
1331
+ let t = e.trim();
1332
+ if (!z.some((e) => e.blueprintAccessor === t)) throw k("an editing override of", t);
1333
+ z = z.filter((e) => e.blueprintAccessor !== t);
1181
1334
  },
1182
1335
  async listRequiredChecks() {
1183
1336
  let e = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
1184
- return structuredClone([...F].sort(e));
1337
+ return structuredClone([...N].sort(e));
1185
1338
  },
1186
1339
  async createRequiredCheck(e) {
1187
- let t = ye(e);
1188
- if (F.some((e) => e.name === t.name)) throw new g(t.name);
1189
- let n = {
1340
+ let t = Se(e);
1341
+ if (N.some((e) => e.name === t.name)) throw new n(t.name);
1342
+ let r = {
1190
1343
  id: `rc_stub_${H++}`,
1191
1344
  ...t
1192
1345
  };
1193
- return F.push(n), structuredClone(n);
1346
+ return N.push(r), structuredClone(r);
1194
1347
  },
1195
1348
  async updateRequiredCheck({ id: e, ...t }) {
1196
- let n = ye(t), r = F.find((t) => t.id === e);
1197
- if (!r) throw k("Required Check", e);
1198
- if (F.some((t) => t.name === n.name && t.id !== e)) throw new g(n.name);
1199
- return Object.assign(r, n), structuredClone(r);
1349
+ let r = Se(t), i = N.find((t) => t.id === e);
1350
+ if (!i) throw k("Required Check", e);
1351
+ if (N.some((t) => t.name === r.name && t.id !== e)) throw new n(r.name);
1352
+ return Object.assign(i, r), structuredClone(i);
1200
1353
  },
1201
1354
  async deleteRequiredCheck({ id: e }) {
1202
- if (!F.some((t) => t.id === e)) throw k("Required Check", e);
1203
- F = F.filter((t) => t.id !== e), z.delete(e);
1355
+ if (!N.some((t) => t.id === e)) throw k("Required Check", e);
1356
+ N = N.filter((t) => t.id !== e), L.delete(e);
1204
1357
  },
1205
1358
  async listRequiredCheckRecorders(e) {
1206
- return structuredClone(He(e));
1359
+ return structuredClone(Xe(e));
1207
1360
  },
1208
1361
  async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
1209
- let n = He(e);
1362
+ let n = Xe(e);
1210
1363
  if ("everyMember" in t) {
1211
- z.set(e, {
1364
+ L.set(e, {
1212
1365
  ...n,
1213
1366
  everyMember: !0
1214
1367
  });
1215
1368
  return;
1216
1369
  }
1217
- if (!Te.includes(t.userId)) throw new a(`user ${t.userId} is not a member of the workspace`);
1218
- z.set(e, {
1370
+ if (!ke.includes(t.userId)) throw new _(`user ${t.userId} is not a member of the workspace`);
1371
+ L.set(e, {
1219
1372
  ...n,
1220
1373
  userIds: [.../* @__PURE__ */ new Set([...n.userIds, t.userId])].sort()
1221
1374
  });
1222
1375
  },
1223
1376
  async revokeRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
1224
- let n = He(e);
1225
- z.set(e, "everyMember" in t ? {
1377
+ let n = Xe(e);
1378
+ L.set(e, "everyMember" in t ? {
1226
1379
  ...n,
1227
1380
  everyMember: !1
1228
1381
  } : {
@@ -1233,7 +1386,7 @@ function M(v = {}) {
1233
1386
  async searchBlueprints({ query: e }) {
1234
1387
  let t = e.trim().toLocaleLowerCase();
1235
1388
  return {
1236
- blueprints: he.filter((e) => !e.archived).filter((e) => e.name.toLocaleLowerCase().includes(t)).filter((e) => M.some((t) => t.blueprintId === e.id)).map((e) => ({
1389
+ blueprints: _e.filter((e) => !e.archived).filter((e) => e.name.toLocaleLowerCase().includes(t)).filter((e) => D.some((t) => t.blueprintId === e.id)).map((e) => ({
1237
1390
  id: e.id,
1238
1391
  name: e.name
1239
1392
  })),
@@ -1241,14 +1394,14 @@ function M(v = {}) {
1241
1394
  };
1242
1395
  },
1243
1396
  async getBlueprints(e) {
1244
- if (e.length > 1e3) throw new a(`at most ${t} Blueprint ids`);
1245
- return he.filter((t) => e.includes(t.id)).map((e) => ({
1397
+ if (e.length > 1e3) throw new _(`at most ${c} Blueprint ids`);
1398
+ return _e.filter((t) => e.includes(t.id)).map((e) => ({
1246
1399
  id: e.id,
1247
1400
  name: e.name
1248
1401
  }));
1249
1402
  },
1250
1403
  async listBlueprintReleases(e) {
1251
- return M.filter((t) => t.blueprintId === e).map((e) => ({
1404
+ return D.filter((t) => t.blueprintId === e).map((e) => ({
1252
1405
  id: e.id,
1253
1406
  blueprintId: e.blueprintId,
1254
1407
  name: e.name ?? e.id,
@@ -1257,94 +1410,94 @@ function M(v = {}) {
1257
1410
  }));
1258
1411
  },
1259
1412
  async listCollections() {
1260
- return [...T].sort(ze).map((e) => ({ ...e }));
1413
+ return [...T].sort(qe).map((e) => ({ ...e }));
1261
1414
  },
1262
1415
  async createCollection({ name: e, parentId: t = "", restricted: r = !1 }) {
1263
1416
  let i = O(e, "a Collection's name", 200);
1264
- if (t !== "" && Y(t), r && I === "workspace") throw new n(Se);
1265
- if (Be(t, i)) throw new g(i);
1417
+ if (t !== "" && Y(t), r && P === "workspace") throw new m(Te);
1418
+ if (Je(t, i)) throw new n(i);
1266
1419
  let a = {
1267
1420
  id: `col_stub_${H++}`,
1268
1421
  name: i,
1269
1422
  parentId: t,
1270
1423
  restricted: r
1271
1424
  };
1272
- return T.push(a), r && R.set(a.id, [{
1425
+ return T.push(a), r && I.set(a.id, [{
1273
1426
  userId: b,
1274
1427
  level: "owner"
1275
1428
  }]), { ...a };
1276
1429
  },
1277
1430
  async renameCollection({ id: e, name: t }) {
1278
- let n = O(t, "a Collection's name", 200), r = Y(e);
1279
- if (Be(r.parentId, n, e)) throw new g(n);
1280
- return r.name = n, { ...r };
1431
+ let r = O(t, "a Collection's name", 200), i = Y(e);
1432
+ if (Je(i.parentId, r, e)) throw new n(r);
1433
+ return i.name = r, { ...i };
1281
1434
  },
1282
1435
  async moveCollection({ id: e, parentId: t }) {
1283
- let n = Y(e);
1284
- for (let n = t; n !== ""; n = Y(n).parentId) if (n === e) throw new a(`Collection ${e} can't move under itself or a Collection under it`);
1285
- if (Be(t, n.name, e)) throw new g("");
1286
- return n.parentId = t, { ...n };
1436
+ let r = Y(e);
1437
+ for (let n = t; n !== ""; n = Y(n).parentId) if (n === e) throw new _(`Collection ${e} can't move under itself or a Collection under it`);
1438
+ if (Je(t, r.name, e)) throw new n("");
1439
+ return r.parentId = t, { ...r };
1287
1440
  },
1288
1441
  async removeCollection({ id: e }) {
1289
- if (Y(e), T.some((t) => t.parentId === e)) throw new a(`Collection ${e} has Collections under it: remove or move those first`);
1290
- T.splice(T.findIndex((t) => t.id === e), 1), R.delete(e);
1442
+ if (Y(e), T.some((t) => t.parentId === e)) throw new _(`Collection ${e} has Collections under it: remove or move those first`);
1443
+ T.splice(T.findIndex((t) => t.id === e), 1), I.delete(e);
1291
1444
  let t = [];
1292
- for (let n of D) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
1445
+ for (let n of E) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
1293
1446
  return t;
1294
1447
  },
1295
- async setCollectionRestricted({ id: e, restricted: t, acknowledgeDisclosure: r = !1 }) {
1296
- if (t && I === "workspace") throw new n(Se);
1297
- let i = Y(e);
1298
- if (i.restricted === t) return { ...i };
1299
- if (!t && !r) throw new a(`unrestricting Collection ${e} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
1300
- return i.restricted = t, t ? R.set(e, [{
1448
+ async setCollectionRestricted({ id: e, restricted: t, acknowledgeDisclosure: n = !1 }) {
1449
+ if (t && P === "workspace") throw new m(Te);
1450
+ let r = Y(e);
1451
+ if (r.restricted === t) return { ...r };
1452
+ if (!t && !n) throw new _(`unrestricting Collection ${e} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
1453
+ return r.restricted = t, t ? I.set(e, [{
1301
1454
  userId: b,
1302
1455
  level: "owner"
1303
- }]) : R.delete(e), { ...i };
1456
+ }]) : I.delete(e), { ...r };
1304
1457
  },
1305
1458
  async listCollectionGrants(e) {
1306
- return Ve(e), structuredClone(R.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
1459
+ return Ye(e), structuredClone(I.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
1307
1460
  },
1308
1461
  async grantCollectionAccess({ collectionId: e, userId: t, level: n }) {
1309
- if (Ve(e), n !== "viewer" && n !== "editor") throw new a("a grant is viewer or editor");
1310
- if (!Te.includes(t)) throw new a(`${t} is not a member of the workspace`);
1311
- let r = R.get(e) ?? [];
1312
- r.some((e) => e.level === "owner" && e.userId === t) || R.set(e, [...r.filter((e) => e.userId !== t), {
1462
+ if (Ye(e), n !== "viewer" && n !== "editor") throw new _("a grant is viewer or editor");
1463
+ if (!ke.includes(t)) throw new _(`${t} is not a member of the workspace`);
1464
+ let r = I.get(e) ?? [];
1465
+ r.some((e) => e.level === "owner" && e.userId === t) || I.set(e, [...r.filter((e) => e.userId !== t), {
1313
1466
  userId: t,
1314
1467
  level: n
1315
1468
  }]);
1316
1469
  },
1317
1470
  async revokeCollectionAccess({ collectionId: e, userId: t }) {
1318
- Ve(e), R.set(e, (R.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
1471
+ Ye(e), I.set(e, (I.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
1319
1472
  },
1320
1473
  async listContents(e = {}) {
1321
1474
  let t = e.view ?? { kind: "main" }, n = (e.search ?? "").trim();
1322
- if (n !== "" && t.kind === "in_force") throw new a("filter.search: Editor Search covers Main and open Branch heads, never Releases");
1323
- if ([...n].length > 200) throw new a("filter.search is at most 200 characters");
1475
+ if (n !== "" && t.kind === "in_force") throw new _("filter.search: Editor Search covers Main and open Branch heads, never Releases");
1476
+ if ([...n].length > 200) throw new _("filter.search is at most 200 characters");
1324
1477
  if (e.collectionId && !T.some((t) => t.id === e.collectionId)) throw k("Collection", e.collectionId);
1325
1478
  t.kind === "change_set" && X(t.changeSetId);
1326
- let r = D.filter((e) => !e.archiveTime).filter((t) => !e.collectionId || t.collectionIds.includes(e.collectionId)).filter((t) => !e.blueprintIds?.length || e.blueprintIds.includes(t.blueprintId)).filter((t) => !e.assigneeId || (t.assigneeIds ?? []).includes(e.assigneeId)).sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)).flatMap((e) => $(e, t, n)), i = Math.min(e.pageSize || 50, 200), o = e.pageToken ? Number(e.pageToken) : 0;
1479
+ let r = E.filter((e) => !e.archiveTime).filter((t) => !e.collectionId || t.collectionIds.includes(e.collectionId)).filter((t) => !e.blueprintIds?.length || e.blueprintIds.includes(t.blueprintId)).filter((t) => !e.assigneeId || (t.assigneeIds ?? []).includes(e.assigneeId)).sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)).flatMap((e) => ft(e, t, n)), i = Math.min(e.pageSize || 50, 200), a = e.pageToken ? Number(e.pageToken) : 0;
1327
1480
  return {
1328
- contents: r.slice(o, o + i),
1329
- nextPageToken: o + i < r.length ? String(o + i) : ""
1481
+ contents: r.slice(a, a + i),
1482
+ nextPageToken: a + i < r.length ? String(a + i) : ""
1330
1483
  };
1331
1484
  },
1332
1485
  async createContent({ changeSetId: e, blueprintReleaseId: t, copyFrom: n }) {
1333
1486
  let r = Z(e), i = {}, a = t;
1334
1487
  if (n) {
1335
- let e = "revisionId" in n ? n.revisionId : D.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = D.find((t) => e && q(t, e));
1488
+ let e = "revisionId" in n ? n.revisionId : E.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = E.find((t) => e && q(t, e));
1336
1489
  if (!r || !e) throw k("copy source", JSON.stringify(n));
1337
1490
  i = structuredClone(q(r, e) ?? {}), a = t || r.blueprintReleaseId;
1338
1491
  }
1339
- let o = M.find((e) => e.id === a);
1340
- if (!o) throw new _(`Blueprint Release ${a} can't be loaded`, [{
1492
+ let o = D.find((e) => e.id === a);
1493
+ if (!o) throw new se(`Blueprint Release ${a} can't be loaded`, [{
1341
1494
  source: "contenthub",
1342
1495
  code: "release_not_found",
1343
1496
  path: ""
1344
1497
  }]);
1345
- if (o.refusals?.length) throw new _(`Blueprint Release ${a} can't be loaded`, o.refusals.map((e) => ({ ...e })));
1498
+ if (o.refusals?.length) throw new se(`Blueprint Release ${a} can't be loaded`, o.refusals.map((e) => ({ ...e })));
1346
1499
  let s = H++, c = `content_stub_${s}`, l = `br_stub_${s}`, u = `rev_stub_${s}`;
1347
- return D.push({
1500
+ return E.push({
1348
1501
  id: c,
1349
1502
  blueprintId: o.blueprintId,
1350
1503
  blueprintReleaseId: a,
@@ -1378,14 +1531,14 @@ function M(v = {}) {
1378
1531
  };
1379
1532
  },
1380
1533
  async saveRevision({ idempotencyKey: e, ...t }) {
1381
- if (!e) return Ue(t);
1382
- let n = JSON.stringify(t), r = Ne.get(e);
1534
+ if (!e) return Ze(t);
1535
+ let n = JSON.stringify(t), r = Ve.get(e);
1383
1536
  if (r) {
1384
- if (r.asked !== n) throw new a(`idempotency key ${e} names another save`);
1537
+ if (r.asked !== n) throw new _(`idempotency key ${e} names another save`);
1385
1538
  return structuredClone(r.content);
1386
1539
  }
1387
- let i = await Ue(t);
1388
- return Ne.set(e, {
1540
+ let i = await Ze(t);
1541
+ return Ve.set(e, {
1389
1542
  asked: n,
1390
1543
  content: structuredClone(i)
1391
1544
  }), i;
@@ -1395,25 +1548,25 @@ function M(v = {}) {
1395
1548
  kind: "change_set",
1396
1549
  changeSetId: t
1397
1550
  } : { kind: "main" };
1398
- if (n && !t) throw new a("branch_id names a Branch of a Change Set: give its change_set_id too");
1399
- let [o] = $(r, i, "");
1400
- if (!o) throw k("Content", e);
1401
- if (n && n !== o.branchId) {
1551
+ if (n && !t) throw new _("branch_id names a Branch of a Change Set: give its change_set_id too");
1552
+ let [a] = ft(r, i, "");
1553
+ if (!a) throw k("Content", e);
1554
+ if (n && n !== a.branchId) {
1402
1555
  let i = w.find((e) => e.id === t)?.chains.find((t) => t.contentId === e)?.branches.find((e) => e.id === n);
1403
1556
  if (!i) throw k("Branch", n);
1404
- let a = K(r).find((e) => e.id === i.headRevisionId), s = a?.data ?? (r.main?.revisionId === i.headRevisionId ? r.main.data : {});
1405
- o = {
1406
- ...o,
1557
+ let o = K(r).find((e) => e.id === i.headRevisionId), s = o?.data ?? (r.main?.revisionId === i.headRevisionId ? r.main.data : {});
1558
+ a = {
1559
+ ...a,
1407
1560
  revisionId: i.headRevisionId,
1408
1561
  data: structuredClone(s),
1409
1562
  branchId: n,
1410
- revisionCreateTime: a?.createTime ?? o.revisionCreateTime
1563
+ revisionCreateTime: o?.createTime ?? a.revisionCreateTime
1411
1564
  };
1412
1565
  }
1413
- let s = P[r.blueprintReleaseId];
1566
+ let o = M[r.blueprintReleaseId];
1414
1567
  return {
1415
- content: o,
1416
- blueprintRelease: s ? structuredClone(s) : void 0,
1568
+ content: a,
1569
+ blueprintRelease: o ? structuredClone(o) : void 0,
1417
1570
  attributes: W(r)
1418
1571
  };
1419
1572
  },
@@ -1431,7 +1584,7 @@ function M(v = {}) {
1431
1584
  if (!t.main) throw k("Content", e.contentId);
1432
1585
  r = K(t);
1433
1586
  } else {
1434
- let t = D.find((t) => K(t).some((t) => t.branchId === e.branchId));
1587
+ let t = E.find((t) => K(t).some((t) => t.branchId === e.branchId));
1435
1588
  if (!t) throw k("Branch", e.branchId);
1436
1589
  r = K(t).filter((t) => t.branchId === e.branchId);
1437
1590
  }
@@ -1442,36 +1595,36 @@ function M(v = {}) {
1442
1595
  };
1443
1596
  },
1444
1597
  async compare({ revisionId: e, base: t }) {
1445
- let n = D.find((t) => K(t).some((t) => t.id === e));
1598
+ let n = E.find((t) => K(t).some((t) => t.id === e));
1446
1599
  if (!n) throw k("Revision", e);
1447
- let r = K(n), i = r.find((t) => t.id === e), o;
1448
- if (t.kind === "revision") o = t.revisionId;
1600
+ let r = K(n), i = r.find((t) => t.id === e), a;
1601
+ if (t.kind === "revision") a = t.revisionId;
1449
1602
  else if (t.kind === "main_head") {
1450
- if (!n.main) throw new a("the Content is not published: it has no Main Branch");
1451
- o = n.main.revisionId;
1452
- } else o = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
1453
- let s = r.find((e) => e.id === o);
1454
- if (!s) throw k("Revision", o);
1455
- let c = q(n, i.id) ?? {}, l = q(n, s.id) ?? {}, u = [];
1456
- for (let e of [.../* @__PURE__ */ new Set([...Object.keys(c), ...Object.keys(l)])]) e in l ? e in c ? JSON.stringify(c[e]) !== JSON.stringify(l[e]) && u.push({
1603
+ if (!n.main) throw new _("the Content is not published: it has no Main Branch");
1604
+ a = n.main.revisionId;
1605
+ } else a = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
1606
+ let o = r.find((e) => e.id === a);
1607
+ if (!o) throw k("Revision", a);
1608
+ let s = q(n, i.id) ?? {}, c = q(n, o.id) ?? {}, l = [];
1609
+ for (let e of [.../* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(c)])]) e in c ? e in s ? JSON.stringify(s[e]) !== JSON.stringify(c[e]) && l.push({
1457
1610
  path: `/${e}`,
1458
1611
  kind: "changed",
1459
- before: l[e],
1460
- after: c[e]
1461
- }) : u.push({
1612
+ before: c[e],
1613
+ after: s[e]
1614
+ }) : l.push({
1462
1615
  path: `/${e}`,
1463
1616
  kind: "removed",
1464
- before: l[e]
1465
- }) : u.push({
1617
+ before: c[e]
1618
+ }) : l.push({
1466
1619
  path: `/${e}`,
1467
1620
  kind: "added",
1468
- after: c[e]
1621
+ after: s[e]
1469
1622
  });
1470
- let d = ({ data: e, ...t }) => t;
1623
+ let u = ({ data: e, ...t }) => t;
1471
1624
  return {
1472
- base: d(s),
1473
- revision: d(i),
1474
- changes: u
1625
+ base: u(o),
1626
+ revision: u(i),
1627
+ changes: l
1475
1628
  };
1476
1629
  },
1477
1630
  async listReferences({ contentId: e, revisionId: t }) {
@@ -1485,14 +1638,14 @@ function M(v = {}) {
1485
1638
  referrers: e.slice(i, i + t),
1486
1639
  nextPageToken: i + t < e.length ? String(i + t) : ""
1487
1640
  };
1488
- }, a = D.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
1641
+ }, a = E.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
1489
1642
  edge: { ...e },
1490
1643
  releaseId: t.inForce?.releaseId ?? "",
1491
1644
  changeSetId: "",
1492
1645
  branchId: ""
1493
1646
  })));
1494
1647
  if (!t) return i(a);
1495
- let o = D.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => w.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
1648
+ let o = E.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => w.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
1496
1649
  edge: { ...e },
1497
1650
  releaseId: "",
1498
1651
  changeSetId: n,
@@ -1504,14 +1657,14 @@ function M(v = {}) {
1504
1657
  let t;
1505
1658
  if ("revisionId" in e) t = e.revisionId;
1506
1659
  else {
1507
- for (let n of D) {
1660
+ for (let n of E) {
1508
1661
  let r = Object.values(n.branches).find((t) => t.branchId === e.branchId);
1509
1662
  r && (t = r.revisionId);
1510
1663
  }
1511
1664
  if (!t) throw k("Branch", e.branchId);
1512
1665
  }
1513
- return D.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
1514
- let t = D.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
1666
+ return E.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
1667
+ let t = E.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
1515
1668
  return t === e.pinReleaseId ? [] : [{
1516
1669
  edge: { ...e },
1517
1670
  supersededByReleaseId: t,
@@ -1521,20 +1674,20 @@ function M(v = {}) {
1521
1674
  },
1522
1675
  async setContentCollections({ contentId: e, collectionIds: t }) {
1523
1676
  let n = U(e), r = [...new Set(t)];
1524
- if (r.length > 100) throw new a("at most 100 Collections");
1677
+ if (r.length > 100) throw new _("at most 100 Collections");
1525
1678
  for (let e of r) if (!T.some((t) => t.id === e)) throw k("Collection", e);
1526
1679
  return n.collectionIds = r.sort(), [...n.collectionIds];
1527
1680
  },
1528
1681
  async setContentAssignees({ contentId: e, assigneeIds: t }) {
1529
1682
  let n = U(e);
1530
- if (new Set(t).size !== t.length) throw new a("each assignee is given once");
1531
- if (t.length > 50) throw new a("at most 50 assignees");
1683
+ if (new Set(t).size !== t.length) throw new _("each assignee is given once");
1684
+ if (t.length > 50) throw new _("at most 50 assignees");
1532
1685
  return n.assigneeIds = [...t], W(n);
1533
1686
  },
1534
1687
  async blockContent({ contentId: e, blockReasonId: t, allowedUserIds: n }) {
1535
1688
  let r = U(e);
1536
1689
  if (!C.some((e) => e.id === t)) throw k("Block Reason", t);
1537
- if (new Set(n).size !== n.length) throw new a("each allowed user is given once");
1690
+ if (new Set(n).size !== n.length) throw new _("each allowed user is given once");
1538
1691
  return r.block = {
1539
1692
  blockReasonId: t,
1540
1693
  allowedUserIds: [...n],
@@ -1549,25 +1702,96 @@ function M(v = {}) {
1549
1702
  async archiveContent(e) {
1550
1703
  let t = U(e);
1551
1704
  if (t.archiveTime) return W(t);
1552
- if (!t.main) throw new a(`Content ${e} is not published: discard its Change Set instead of archiving it`);
1553
- if (f(t.timeline ?? [], Pe())) throw new a(`Content ${e} has a Release In Force today or later: end its force first`);
1705
+ if (!t.main) throw new _(`Content ${e} is not published: discard its Change Set instead of archiving it`);
1706
+ if (ee(t.timeline ?? [], He())) throw new _(`Content ${e} has a Release In Force today or later: end its force first`);
1554
1707
  return t.archiveTime = y(), W(t);
1555
1708
  },
1556
1709
  async unarchiveContent(e) {
1557
1710
  let t = U(e);
1558
1711
  return t.archiveTime = void 0, W(t);
1559
1712
  },
1713
+ async openDirectEdit({ contentId: e, idempotencyKey: t }) {
1714
+ return V(t, ["openDirectEdit", e], async () => {
1715
+ let t = U(e), n = w.find((t) => t.kind === "direct_edit" && t.state === "open" && t.editorId === b && t.chains[0]?.contentId === e);
1716
+ if (n) {
1717
+ let [e] = ft(t, {
1718
+ kind: "change_set",
1719
+ changeSetId: n.id
1720
+ }, "");
1721
+ return {
1722
+ changeSet: A(n),
1723
+ content: e,
1724
+ reopened: !0
1725
+ };
1726
+ }
1727
+ if (t.main && G(t)) throw new oe("dated_content", `Content ${e} is Dated: change it in a Change Set`, e);
1728
+ let r = M[t.blueprintReleaseId]?.accessor || t.blueprintId, i = je(z.find((e) => e.blueprintAccessor === r)).editingMode;
1729
+ if (t.main && i === "change_sets") throw new s(e, r, i);
1730
+ let a = await $.startEditing({
1731
+ contentId: e,
1732
+ changeSetName: `Direct Edit of ${e}`
1733
+ }), o = X(a.changeSet.id);
1734
+ return o.kind = "direct_edit", o.editorId = b, {
1735
+ changeSet: A(o),
1736
+ content: a.content,
1737
+ reopened: !1
1738
+ };
1739
+ });
1740
+ },
1741
+ async publishDirectEdit({ id: e, expectedHeadId: t, idempotencyKey: n }) {
1742
+ return V(n, [
1743
+ "publishDirectEdit",
1744
+ e,
1745
+ t
1746
+ ], async () => {
1747
+ let n = X(e);
1748
+ if (n.kind !== "direct_edit") throw new oe("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1749
+ let r = n.chains[0], i = r?.branches[0];
1750
+ if (!r || !i) throw Error(`Direct Edit ${e} has no Branch`);
1751
+ n.state === "open" && !n.plannedReleases.some((e) => e.branchId === i.id) && await $.planRelease({
1752
+ changeSetId: e,
1753
+ branchId: i.id
1754
+ });
1755
+ let a = await $.publish({
1756
+ id: e,
1757
+ reviewedHeads: { [i.id]: t }
1758
+ }), o = U(r.contentId), s = o.branches[e], c = a.releases.find((e) => e.branchId === i.id);
1759
+ if (s && c && o.main?.revisionId !== s.revisionId) {
1760
+ let { branchId: e, ...t } = structuredClone(s);
1761
+ o.main = t, o.inForce = {
1762
+ ...structuredClone(t),
1763
+ releaseId: c.id
1764
+ }, o.timeline = [...o.timeline ?? [], {
1765
+ ordinal: (o.timeline?.length ?? 0) + 1,
1766
+ releaseId: c.id,
1767
+ kind: "revision",
1768
+ revisionId: s.revisionId,
1769
+ blueprintReleaseId: o.blueprintReleaseId,
1770
+ publishTime: a.publishTime,
1771
+ first: !1
1772
+ }];
1773
+ }
1774
+ return a;
1775
+ });
1776
+ },
1777
+ async discardDirectEdit({ id: e, idempotencyKey: t }) {
1778
+ return V(t, ["discardDirectEdit", e], async () => {
1779
+ if (X(e).kind !== "direct_edit") throw new oe("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1780
+ return $.discardChangeSet(e);
1781
+ });
1782
+ },
1560
1783
  async startEditing({ contentId: e, changeSetId: t, effectiveOn: n = "", changeSetName: r = "" }) {
1561
1784
  let i = U(e);
1562
- if (!i.main) throw new a(`Content ${e} is not published`);
1563
- if (J(i), G(i) && !h.test(n)) throw new a("effective_on is required for Dated Content, as YYYY-MM-DD");
1564
- if (!G(i) && n !== "") throw new a("effective_on is refused for undated Content");
1565
- let o;
1785
+ if (!i.main) throw new _(`Content ${e} is not published`);
1786
+ if (J(i), G(i) && !g.test(n)) throw new _("effective_on is required for Dated Content, as YYYY-MM-DD");
1787
+ if (!G(i) && n !== "") throw new _("effective_on is refused for undated Content");
1788
+ let a;
1566
1789
  if (t) {
1567
- if (o = Z(t), o.chains.some((t) => t.contentId === e)) throw new a(`Content ${e} already has a Chain in this Change Set`);
1790
+ if (a = Z(t), a.kind === "direct_edit") throw new oe("one_branch", `Change Set ${t} is a Direct Edit`);
1791
+ if (a.chains.some((t) => t.contentId === e)) throw new _(`Content ${e} already has a Chain in this Change Set`);
1568
1792
  } else {
1569
1793
  let t = Object.values(i.main.data).filter((e) => typeof e == "string").slice(0, 2).join(" ");
1570
- o = {
1794
+ a = {
1571
1795
  id: `cs_stub_${H++}`,
1572
1796
  name: r.trim() ? O(r, "change_set_name", 200) : t || e,
1573
1797
  state: "open",
@@ -1578,56 +1802,56 @@ function M(v = {}) {
1578
1802
  status: "",
1579
1803
  assigneeIds: [],
1580
1804
  plannedReleases: []
1581
- }, w.unshift(o);
1805
+ }, w.unshift(a);
1582
1806
  }
1583
- let s = H++, c = `br_stub_${s}`, l = {
1807
+ let o = H++, s = `br_stub_${o}`, c = {
1584
1808
  ...structuredClone(i.main),
1585
- branchId: c
1809
+ branchId: s
1586
1810
  };
1587
- i.branches[o.id] = l, o.chains.push({
1588
- id: `chain_stub_${s}`,
1811
+ i.branches[a.id] = c, a.chains.push({
1812
+ id: `chain_stub_${o}`,
1589
1813
  contentId: e,
1590
1814
  born: !1,
1591
1815
  branches: [{
1592
- id: c,
1816
+ id: s,
1593
1817
  position: 0,
1594
1818
  kind: "editorial",
1595
- headRevisionId: l.revisionId
1819
+ headRevisionId: c.revisionId
1596
1820
  }]
1597
1821
  });
1598
- let [u] = $(i, {
1822
+ let [l] = ft(i, {
1599
1823
  kind: "change_set",
1600
- changeSetId: o.id
1824
+ changeSetId: a.id
1601
1825
  }, "");
1602
1826
  return {
1603
- changeSet: A(o),
1604
- content: u
1827
+ changeSet: A(a),
1828
+ content: l
1605
1829
  };
1606
1830
  },
1607
1831
  async previewChain({ changeSetId: e, contentId: t, effectiveOn: n, validityPeriod: r }) {
1608
1832
  Z(e);
1609
1833
  let i = U(t);
1610
- if (!i.main) throw new a(`Content ${t} is not published`);
1611
- if (!G(i)) throw new a("undated Content's Chain takes no date");
1612
- if (!h.test(n)) throw new a("effective_on is YYYY-MM-DD");
1613
- let o = i.timeline ?? [], s = o.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
1834
+ if (!i.main) throw new _(`Content ${t} is not published`);
1835
+ if (!G(i)) throw new _("undated Content's Chain takes no date");
1836
+ if (!g.test(n)) throw new _("effective_on is YYYY-MM-DD");
1837
+ let a = i.timeline ?? [], o = a.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
1614
1838
  return {
1615
- forkReleaseId: s?.releaseId ?? "",
1616
- carryForwardReleaseIds: o.filter((e) => e.validityPeriod && e.validityPeriod.firstDay > n).map((e) => e.releaseId),
1839
+ forkReleaseId: o?.releaseId ?? "",
1840
+ carryForwardReleaseIds: a.filter((e) => e.validityPeriod && e.validityPeriod.firstDay > n).map((e) => e.releaseId),
1617
1841
  mergesMain: !1,
1618
- cutIntoReleaseIds: s ? [s.releaseId] : [],
1619
- coveredReleaseIds: r && r.lastDay !== "" ? o.filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && r.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= r.lastDay).map((e) => e.releaseId) : []
1842
+ cutIntoReleaseIds: o ? [o.releaseId] : [],
1843
+ coveredReleaseIds: r && r.lastDay !== "" ? a.filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && r.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= r.lastDay).map((e) => e.releaseId) : []
1620
1844
  };
1621
1845
  },
1622
1846
  async planRepeal({ changeSetId: e, contentId: t, lastDay: n }) {
1623
1847
  Z(e);
1624
1848
  let r = U(t);
1625
- if (J(r), !G(r)) throw new a("a Repeal is for Dated Content");
1626
- if (!h.test(n)) throw new a("last_day is YYYY-MM-DD");
1627
- return rt(r, e, {
1849
+ if (J(r), !G(r)) throw new _("a Repeal is for Dated Content");
1850
+ if (!g.test(n)) throw new _("last_day is YYYY-MM-DD");
1851
+ return dt(r, e, {
1628
1852
  kind: "repeal",
1629
1853
  validityPeriod: {
1630
- firstDay: ee(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
1854
+ firstDay: te(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
1631
1855
  lastDay: n
1632
1856
  }
1633
1857
  });
@@ -1635,71 +1859,71 @@ function M(v = {}) {
1635
1859
  async planWithdrawal({ changeSetId: e, contentId: t }) {
1636
1860
  Z(e);
1637
1861
  let n = U(t);
1638
- if (J(n), G(n)) throw new a("a Withdrawal is for undated Content");
1639
- return rt(n, e, { kind: "withdrawal" });
1862
+ if (J(n), G(n)) throw new _("a Withdrawal is for undated Content");
1863
+ return dt(n, e, { kind: "withdrawal" });
1640
1864
  },
1641
1865
  async planRelease({ idempotencyKey: e, ...t }) {
1642
1866
  return V(e, ["planRelease", t], async () => {
1643
- let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: o } = t, { cs: s, chain: c, branch: l, c: u } = Ge(e, n);
1644
- if (J(u), l.kind !== "editorial") throw new a("only an editorial Branch's head is released");
1645
- if (s.plannedReleases.some((e) => e.branchId === n)) throw new a(`Branch ${n} is planned already`);
1646
- let d = {
1867
+ let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, { cs: o, chain: s, branch: c, c: l } = $e(e, n);
1868
+ if (J(l), c.kind !== "editorial") throw new _("only an editorial Branch's head is released");
1869
+ if (o.plannedReleases.some((e) => e.branchId === n)) throw new _(`Branch ${n} is planned already`);
1870
+ let u = {
1647
1871
  id: `rls_stub_${H++}`,
1648
- contentId: c.contentId,
1872
+ contentId: s.contentId,
1649
1873
  kind: "revision",
1650
1874
  branchId: n,
1651
1875
  revisionId: "",
1652
1876
  validityPeriod: r ? { ...r } : void 0,
1653
1877
  releaseSpec: structuredClone(i ?? {}),
1654
- supersedesReleaseIds: [...o ?? []],
1878
+ supersedesReleaseIds: [...a ?? []],
1655
1879
  proposed: !1,
1656
1880
  proposedForReleaseId: "",
1657
1881
  splitFromReleaseId: "",
1658
1882
  withheld: !1
1659
1883
  };
1660
- return Je(u, d), s.plannedReleases.push(d), Ye(s, u), structuredClone(d);
1884
+ return nt(l, u), o.plannedReleases.push(u), rt(o, l), structuredClone(u);
1661
1885
  });
1662
1886
  },
1663
1887
  async updatePlannedRelease({ idempotencyKey: e, ...t }) {
1664
1888
  return V(e, ["updatePlannedRelease", t], async () => {
1665
- let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: o } = t, s = Z(e), c = s.plannedReleases.findIndex((e) => e.id === n);
1666
- if (c < 0) throw k("Planned Release", n);
1667
- let l = s.plannedReleases[c];
1668
- if (l.proposed) throw new a("a proposal is derived from the plans and can't be set");
1669
- let u = U(l.contentId);
1670
- J(u);
1671
- let d = {
1672
- ...structuredClone(l),
1889
+ let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, o = Z(e), s = o.plannedReleases.findIndex((e) => e.id === n);
1890
+ if (s < 0) throw k("Planned Release", n);
1891
+ let c = o.plannedReleases[s];
1892
+ if (c.proposed) throw new _("a proposal is derived from the plans and can't be set");
1893
+ let l = U(c.contentId);
1894
+ J(l);
1895
+ let u = {
1896
+ ...structuredClone(c),
1673
1897
  ...r ? { validityPeriod: { ...r } } : {},
1674
1898
  ...i ? { releaseSpec: structuredClone(i) } : {},
1675
- ...o ? { supersedesReleaseIds: [...o] } : {}
1899
+ ...a ? { supersedesReleaseIds: [...a] } : {}
1676
1900
  };
1677
- return Je(u, d), s.plannedReleases[c] = d, Ye(s, u), structuredClone(d);
1901
+ return nt(l, u), o.plannedReleases[s] = u, rt(o, l), structuredClone(u);
1678
1902
  });
1679
1903
  },
1680
1904
  async appendBranch({ idempotencyKey: e, ...t }) {
1681
1905
  return V(e, ["appendBranch", t], async () => {
1682
- let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = Z(e), o = i.chains.find((e) => e.id === n);
1683
- if (!o) throw k("Chain", n);
1684
- let s = U(o.contentId);
1685
- if (o.born || !G(s)) throw new a("only a Chain on published Dated Content takes dates");
1686
- let c = o.branches.filter((e) => e.kind === "editorial").at(-1);
1687
- if (!h.test(r) || c?.effectiveOn && r <= c.effectiveOn) throw new a("effective_on is a day after the Chain's last editorial Branch's");
1688
- let l = o.branches.at(-1), u = `br_stub_${H++}`;
1689
- o.branches.push({
1690
- id: u,
1691
- position: o.branches.length,
1906
+ let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = Z(e), a = i.chains.find((e) => e.id === n);
1907
+ if (!a) throw k("Chain", n);
1908
+ let o = U(a.contentId);
1909
+ if (a.born || !G(o)) throw new _("only a Chain on published Dated Content takes dates");
1910
+ let s = a.branches.filter((e) => e.kind === "editorial").at(-1);
1911
+ if (!g.test(r) || s?.effectiveOn && r <= s.effectiveOn) throw new _("effective_on is a day after the Chain's last editorial Branch's");
1912
+ let c = a.branches.at(-1), l = `br_stub_${H++}`;
1913
+ a.branches.push({
1914
+ id: l,
1915
+ position: a.branches.length,
1692
1916
  kind: "editorial",
1693
- headRevisionId: l?.headRevisionId ?? "",
1917
+ headRevisionId: c?.headRevisionId ?? "",
1694
1918
  effectiveOn: r
1695
1919
  });
1696
- let d = s.branches[e];
1697
- return d && (s.branches[e] = {
1698
- ...d,
1699
- branchId: u
1920
+ let u = o.branches[e];
1921
+ return u && (o.branches[e] = {
1922
+ ...u,
1923
+ branchId: l
1700
1924
  }), {
1701
1925
  changeSet: A(i),
1702
- branchId: u
1926
+ branchId: l
1703
1927
  };
1704
1928
  });
1705
1929
  },
@@ -1707,8 +1931,8 @@ function M(v = {}) {
1707
1931
  return V(e, ["dropChain", t], async () => {
1708
1932
  let { changeSetId: e, chainId: n } = t, r = Z(e), i = r.chains.find((e) => e.id === n);
1709
1933
  if (!i) throw k("Chain", n);
1710
- if (i.born) throw new a("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
1711
- for (let e of i.branches) qe(e.id);
1934
+ if (i.born) throw new _("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
1935
+ for (let e of i.branches) tt(e.id);
1712
1936
  return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !== i.contentId), delete U(i.contentId).branches[e], A(r);
1713
1937
  });
1714
1938
  },
@@ -1716,43 +1940,43 @@ function M(v = {}) {
1716
1940
  let t = B.get(e);
1717
1941
  return t ? structuredClone(t) : null;
1718
1942
  },
1719
- async resolveMerge({ idempotencyKey: t, ...n }) {
1720
- return V(t, ["resolveMerge", n], async () => {
1721
- let { changeSetId: t, branchId: r, expectedHeadId: i, resolutions: o } = n, { chain: s, branch: c, c: l } = Ge(t, r), u = B.get(r);
1722
- if (!u) throw new a(`Branch ${r} has no Pending Merge`);
1723
- if (c.headRevisionId !== i) throw new e({
1724
- contentId: l.id,
1725
- branchId: r,
1726
- expectedHeadId: i,
1727
- currentHeadId: c.headRevisionId
1943
+ async resolveMerge({ idempotencyKey: e, ...t }) {
1944
+ return V(e, ["resolveMerge", t], async () => {
1945
+ let { changeSetId: e, branchId: n, expectedHeadId: r, resolutions: a } = t, { chain: o, branch: s, c } = $e(e, n), l = B.get(n);
1946
+ if (!l) throw new _(`Branch ${n} has no Pending Merge`);
1947
+ if (s.headRevisionId !== r) throw new i({
1948
+ contentId: c.id,
1949
+ branchId: n,
1950
+ expectedHeadId: r,
1951
+ currentHeadId: s.headRevisionId
1728
1952
  });
1729
- let d = o.map((e) => e.path), f = u.fields.map((e) => e.path);
1730
- if (new Set(d).size !== d.length || d.some((e) => !f.includes(e)) || f.some((e) => !d.includes(e))) throw new a("decide every field the Pending Merge lists, once");
1731
- let p = structuredClone(u.merged);
1732
- for (let e of o) {
1733
- let t = u.fields.find((t) => t.path === e.path), n = "side" in e ? e.side === "ours" ? t.ours : t.theirs : e.value, r = e.path.replace(/^\//, "");
1734
- n === void 0 ? delete p[r] : p[r] = structuredClone(n);
1953
+ let u = a.map((e) => e.path), d = l.fields.map((e) => e.path);
1954
+ if (new Set(u).size !== u.length || u.some((e) => !d.includes(e)) || d.some((e) => !u.includes(e))) throw new _("decide every field the Pending Merge lists, once");
1955
+ let f = structuredClone(l.merged);
1956
+ for (let e of a) {
1957
+ let t = l.fields.find((t) => t.path === e.path), n = "side" in e ? e.side === "ours" ? t.ours : t.theirs : e.value, r = e.path.replace(/^\//, "");
1958
+ n === void 0 ? delete f[r] : f[r] = structuredClone(n);
1735
1959
  }
1736
- let m = We({
1737
- changeSetId: t,
1738
- chain: s,
1739
- branch: c,
1740
- c: l,
1741
- data: p,
1960
+ let p = Qe({
1961
+ changeSetId: e,
1962
+ chain: o,
1963
+ branch: s,
1964
+ c,
1965
+ data: f,
1742
1966
  cause: "resolve",
1743
- secondParentId: u.theirsRevisionId
1967
+ secondParentId: l.theirsRevisionId
1744
1968
  });
1745
- return qe(r), m;
1969
+ return tt(n), p;
1746
1970
  });
1747
1971
  },
1748
1972
  async abortMerge({ idempotencyKey: e, ...t }) {
1749
1973
  return V(e, ["abortMerge", t], async () => {
1750
- if (Ge(t.changeSetId, t.branchId), !B.has(t.branchId)) throw new a(`Branch ${t.branchId} has no Pending Merge`);
1751
- qe(t.branchId);
1974
+ if ($e(t.changeSetId, t.branchId), !B.has(t.branchId)) throw new _(`Branch ${t.branchId} has no Pending Merge`);
1975
+ tt(t.branchId);
1752
1976
  });
1753
1977
  },
1754
1978
  async previewInForce({ contentId: e, changeSetId: t, validOn: n }) {
1755
- let r = Z(t), i = U(e), a = n || Pe(), o = r.chains.find((t) => t.contentId === e), s = (e) => !e.validityPeriod || e.validityPeriod.firstDay <= a && (e.validityPeriod.lastDay === "" || a <= e.validityPeriod.lastDay), c = r.plannedReleases.find((t) => t.contentId === e && t.kind !== "repeal" && s(t));
1979
+ let r = Z(t), i = U(e), a = n || He(), o = r.chains.find((t) => t.contentId === e), s = (e) => !e.validityPeriod || e.validityPeriod.firstDay <= a && (e.validityPeriod.lastDay === "" || a <= e.validityPeriod.lastDay), c = r.plannedReleases.find((t) => t.contentId === e && t.kind !== "repeal" && s(t));
1756
1980
  if (c) {
1757
1981
  let e = c.branchId ? o?.branches.find((e) => e.id === c.branchId)?.headRevisionId ?? "" : c.revisionId;
1758
1982
  return {
@@ -1764,7 +1988,7 @@ function M(v = {}) {
1764
1988
  data: structuredClone(q(i, e) ?? {})
1765
1989
  };
1766
1990
  }
1767
- let l = ee(i.timeline ?? [], a);
1991
+ let l = te(i.timeline ?? [], a);
1768
1992
  return l ? {
1769
1993
  releaseId: l.releaseId,
1770
1994
  revisionId: l.revisionId,
@@ -1775,7 +1999,8 @@ function M(v = {}) {
1775
1999
  } : null;
1776
2000
  }
1777
2001
  };
1778
- function rt(e, t, n) {
2002
+ return $;
2003
+ function dt(e, t, n) {
1779
2004
  let r = {
1780
2005
  id: `rls_stub_${H++}`,
1781
2006
  contentId: e.id,
@@ -1793,10 +2018,10 @@ function M(v = {}) {
1793
2018
  plannedRelease: r
1794
2019
  }], structuredClone({
1795
2020
  plannedRelease: r,
1796
- gapReferrers: Ie(e.id)
2021
+ gapReferrers: We(e.id)
1797
2022
  });
1798
2023
  }
1799
- function $(e, t, n) {
2024
+ function ft(e, t, n) {
1800
2025
  let r = (t, n) => ({
1801
2026
  id: e.id,
1802
2027
  blueprintId: e.blueprintId,
@@ -1811,33 +2036,33 @@ function M(v = {}) {
1811
2036
  if (t.kind === "in_force") return e.inForce ? [r(e.inForce, { releaseId: e.inForce.releaseId })] : [];
1812
2037
  if (t.kind === "change_set") {
1813
2038
  let i = e.branches[t.changeSetId];
1814
- return !i || n && !N(i.data, n) ? [] : [r(i, {
2039
+ return !i || n && !Ee(i.data, n) ? [] : [r(i, {
1815
2040
  changeSetId: t.changeSetId,
1816
2041
  branchId: i.branchId
1817
2042
  })];
1818
2043
  }
1819
2044
  if (!n) return e.main ? [r(e.main, {})] : [];
1820
2045
  let i = [];
1821
- e.main && N(e.main.data, n) && i.push(r(e.main, {}));
1822
- for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1)) w.find((e) => e.id === t)?.state === "open" && N(a.data, n) && i.push(r(a, {
2046
+ e.main && Ee(e.main.data, n) && i.push(r(e.main, {}));
2047
+ for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1)) w.find((e) => e.id === t)?.state === "open" && Ee(a.data, n) && i.push(r(a, {
1823
2048
  changeSetId: t,
1824
2049
  branchId: a.branchId
1825
2050
  }));
1826
2051
  return i;
1827
2052
  }
1828
2053
  }
1829
- function N(e, t) {
2054
+ function Ee(e, t) {
1830
2055
  let n = (e) => e.toLocaleLowerCase().replace(/\s+/g, " "), r = n(t);
1831
2056
  return Object.values(e).some((e) => typeof e == "string" && n(e).includes(r));
1832
2057
  }
1833
2058
  //#endregion
1834
2059
  //#region src/testing/stub-status-source.ts
1835
- function P(e = E()) {
2060
+ function N(e = le()) {
1836
2061
  return { async listChangeSetStatuses() {
1837
2062
  return e.map((e) => ({ ...e }));
1838
2063
  } };
1839
2064
  }
1840
2065
  //#endregion
1841
- export { w as STUB_NOW, C as STUB_OTHER_USER_ID, S as STUB_USER_ID, x as STUB_WORKSPACE_ID, he as createStubBlueprintSource, M as createStubContenthubClient, P as createStubStatusSource, oe as stubBlockReasons, j as stubBlocker, fe as stubBlueprintReleases, de as stubBlueprints, E as stubChangeSetStatuses, ce as stubChangeSets, ue as stubCollections, me as stubContents, T as stubIdentity, D as stubRepealedContent, le as stubRequiredChecks, pe as stubResolvedReleases, se as stubStatusTransitions };
2066
+ export { w as STUB_NOW, C as STUB_OTHER_USER_ID, S as STUB_USER_ID, x as STUB_WORKSPACE_ID, D as createStubBlueprintSource, M as createStubContenthubClient, N as createStubStatusSource, ce as stubBlockReasons, j as stubBlocker, he as stubBlueprintReleases, me as stubBlueprints, le as stubChangeSetStatuses, de as stubChangeSets, pe as stubCollections, ve as stubContents, T as stubIdentity, _e as stubRepealedContent, fe as stubRequiredChecks, ge as stubResolvedReleases, ue as stubStatusTransitions, E as stubUndatedContent };
1842
2067
 
1843
2068
  //# sourceMappingURL=testing.js.map