@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/CHANGELOG.md +9 -0
- package/README.md +5 -4
- package/dist/{branch-content-fields-CiAVF2F3.js → branch-content-fields-BQG6U0yl.js} +2 -2
- package/dist/{branch-content-fields-CiAVF2F3.js.map → branch-content-fields-BQG6U0yl.js.map} +1 -1
- package/dist/{content-library-DoiD_FOJ.js → content-library-DFIk09bD.js} +269 -25
- package/dist/content-library-DFIk09bD.js.map +1 -0
- package/dist/{heads-dBmqNcOB.js → heads-DqHmAW0n.js} +38 -24
- package/dist/heads-DqHmAW0n.js.map +1 -0
- package/dist/index.d.ts +709 -6
- package/dist/index.js +3092 -2148
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +173 -0
- package/dist/testing.js +623 -398
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/content-library-DoiD_FOJ.js.map +0 -1
- package/dist/heads-dBmqNcOB.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
615
|
-
if ([...r].length > n) throw new
|
|
616
|
-
if (/[\u0000-\u001f\u007f]/.test(r)) throw new
|
|
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
|
|
620
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new
|
|
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
|
|
665
|
+
function xe(e) {
|
|
627
666
|
let t = e.trim();
|
|
628
|
-
if (t === "") throw new
|
|
629
|
-
if ([...t].length > 200) throw new
|
|
630
|
-
if (/[\u0000-\u001f\u007f]/.test(t)) throw new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 ??
|
|
675
|
-
if (
|
|
676
|
-
},
|
|
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
|
-
},
|
|
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 =
|
|
735
|
+
let r = JSON.stringify(t), i = ze.get(e);
|
|
682
736
|
if (i) {
|
|
683
|
-
if (i.asked !== r) throw new
|
|
737
|
+
if (i.asked !== r) throw new _(`idempotency key ${e} names another request`);
|
|
684
738
|
return structuredClone(i.answer);
|
|
685
739
|
}
|
|
686
|
-
let
|
|
687
|
-
return
|
|
740
|
+
let a = await n();
|
|
741
|
+
return ze.set(e, {
|
|
688
742
|
asked: r,
|
|
689
|
-
answer: structuredClone(
|
|
690
|
-
}),
|
|
691
|
-
},
|
|
692
|
-
let t =
|
|
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
|
-
}),
|
|
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,
|
|
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
|
|
732
|
-
if (e.block && !e.block.allowedUserIds.includes(b)) throw new
|
|
733
|
-
},
|
|
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
|
-
}))),
|
|
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
|
-
},
|
|
741
|
-
if (
|
|
742
|
-
if (!Y(e).restricted) throw new
|
|
743
|
-
let t = (
|
|
744
|
-
if (!
|
|
745
|
-
},
|
|
746
|
-
if (
|
|
747
|
-
if (!
|
|
748
|
-
if (
|
|
749
|
-
if (!
|
|
750
|
-
return
|
|
751
|
-
},
|
|
752
|
-
let
|
|
753
|
-
if (!
|
|
754
|
-
let
|
|
755
|
-
if (J(
|
|
756
|
-
if (
|
|
757
|
-
if (
|
|
758
|
-
contentId:
|
|
759
|
-
branchId:
|
|
760
|
-
expectedHeadId:
|
|
761
|
-
currentHeadId:
|
|
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
|
|
764
|
-
if (
|
|
765
|
-
let e = Object.keys(
|
|
766
|
-
if (e.length > 0) throw new
|
|
767
|
-
|
|
768
|
-
for (let e of
|
|
769
|
-
} else
|
|
770
|
-
return
|
|
771
|
-
changeSetId:
|
|
772
|
-
chain:
|
|
773
|
-
branch:
|
|
774
|
-
c
|
|
775
|
-
data:
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
|
885
|
+
B.set(e, i), n.hasPendingMerge = !0, delete Re[e];
|
|
832
886
|
return;
|
|
833
887
|
}
|
|
834
888
|
throw k("Branch", e);
|
|
835
|
-
},
|
|
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
|
-
},
|
|
895
|
+
}, nt = (e, t) => {
|
|
842
896
|
let n = t.validityPeriod;
|
|
843
897
|
if (G(e)) {
|
|
844
|
-
if (!n || !
|
|
845
|
-
if (n.lastDay !== "" && (!
|
|
846
|
-
} else if (n) throw new
|
|
847
|
-
let r =
|
|
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
|
|
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
|
|
909
|
+
if (r.length > 0) throw new u(e.id, r);
|
|
856
910
|
}
|
|
857
|
-
},
|
|
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:
|
|
934
|
+
lastDay: ye(n.firstDay, -1)
|
|
881
935
|
}, ""), n.lastDay !== "" && (t.lastDay === "" || t.lastDay > n.lastDay) && a(r, {
|
|
882
|
-
firstDay:
|
|
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
|
|
948
|
+
if (t.state !== "open") throw new p(t.state);
|
|
895
949
|
return t;
|
|
896
|
-
},
|
|
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
|
-
}))],
|
|
907
|
-
let t =
|
|
908
|
-
let r = n[0], i = r ? !
|
|
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 [...
|
|
918
|
-
let a = t.filter((t) =>
|
|
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
|
-
},
|
|
939
|
-
let n = [], r =
|
|
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
|
|
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 =
|
|
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
|
|
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(
|
|
1025
|
+
return [...n, ...structuredClone(Ie[e.id] ?? [])];
|
|
972
1026
|
}, Q = (e) => {
|
|
973
|
-
let t =
|
|
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(
|
|
986
|
-
|
|
1039
|
+
for (let [e, t] of Object.entries(Re)) t.pending && et(e, t);
|
|
1040
|
+
let $ = {
|
|
987
1041
|
async listBlockReasons() {
|
|
988
|
-
return [...C].sort(
|
|
1042
|
+
return [...C].sort(Ge).map((e) => ({ ...e }));
|
|
989
1043
|
},
|
|
990
1044
|
async createBlockReason({ name: e }) {
|
|
991
|
-
let t =
|
|
992
|
-
if (
|
|
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 =
|
|
1056
|
+
let n = xe(t), r = C.find((t) => t.id === e);
|
|
1003
1057
|
if (!r) throw k("Block Reason", e);
|
|
1004
|
-
if (
|
|
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 ?
|
|
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
|
|
1045
|
-
let
|
|
1046
|
-
return t.includes("source") && (
|
|
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
|
|
1050
|
-
if (
|
|
1051
|
-
if (
|
|
1052
|
-
if (!x.some((e) => e.slug === n)) throw new
|
|
1053
|
-
if (x.some((e) => e.slug ===
|
|
1054
|
-
fromStatus:
|
|
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 ${
|
|
1110
|
+
reason: `There is no transition from ${it(r.status)} to ${it(n)}.`,
|
|
1057
1111
|
requiresPermission: !1
|
|
1058
1112
|
});
|
|
1059
|
-
return
|
|
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
|
|
1064
|
-
if (t.length > 50) throw new
|
|
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
|
|
1070
|
-
if (
|
|
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
|
-
|
|
1081
|
-
let r =
|
|
1082
|
-
if (r &&
|
|
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
|
|
1141
|
+
if (n.state !== "open") throw new p(n.state);
|
|
1088
1142
|
return {
|
|
1089
|
-
blockers:
|
|
1143
|
+
blockers: ut(n, t),
|
|
1090
1144
|
releases: Q(n),
|
|
1091
1145
|
published: !1
|
|
1092
1146
|
};
|
|
1093
1147
|
},
|
|
1094
|
-
async publish({ id: e, reviewedHeads:
|
|
1095
|
-
let
|
|
1096
|
-
|
|
1097
|
-
let
|
|
1098
|
-
if (
|
|
1099
|
-
changeSet: A(
|
|
1100
|
-
publishTime:
|
|
1101
|
-
releases: Q(
|
|
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 (
|
|
1104
|
-
let
|
|
1105
|
-
if (
|
|
1106
|
-
let
|
|
1107
|
-
return
|
|
1108
|
-
changeSet: A(
|
|
1109
|
-
publishTime:
|
|
1110
|
-
releases:
|
|
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 ||
|
|
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(
|
|
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 =
|
|
1129
|
-
B.has(t.id) ? a.push(n) : r && (
|
|
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
|
|
1259
|
+
return F(e), t.state = "discarded", t.closeTime = y(), t.chains = [], A(t);
|
|
1143
1260
|
},
|
|
1144
1261
|
async listCheckResults(e) {
|
|
1145
|
-
return
|
|
1146
|
-
},
|
|
1147
|
-
async recordCheckResult({ changeSetId:
|
|
1148
|
-
let
|
|
1149
|
-
if (
|
|
1150
|
-
if ([...
|
|
1151
|
-
let
|
|
1152
|
-
if (!
|
|
1153
|
-
let
|
|
1154
|
-
if (
|
|
1155
|
-
let
|
|
1156
|
-
if (
|
|
1157
|
-
if (
|
|
1158
|
-
for (let
|
|
1159
|
-
let
|
|
1160
|
-
if (!
|
|
1161
|
-
if (
|
|
1162
|
-
contentId:
|
|
1163
|
-
branchId:
|
|
1164
|
-
expectedHeadId:
|
|
1165
|
-
currentHeadId:
|
|
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
|
|
1285
|
+
let p = {
|
|
1169
1286
|
id: `cr_stub_${H++}`,
|
|
1170
|
-
requiredCheckId:
|
|
1171
|
-
heads: { ...
|
|
1172
|
-
outcome:
|
|
1173
|
-
note:
|
|
1287
|
+
requiredCheckId: t,
|
|
1288
|
+
heads: { ...n },
|
|
1289
|
+
outcome: r,
|
|
1290
|
+
note: a,
|
|
1174
1291
|
recordedBy: b,
|
|
1175
1292
|
recordTime: y()
|
|
1176
1293
|
};
|
|
1177
|
-
return
|
|
1178
|
-
...
|
|
1179
|
-
changeSetId:
|
|
1180
|
-
}), structuredClone(
|
|
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([...
|
|
1337
|
+
return structuredClone([...N].sort(e));
|
|
1185
1338
|
},
|
|
1186
1339
|
async createRequiredCheck(e) {
|
|
1187
|
-
let t =
|
|
1188
|
-
if (
|
|
1189
|
-
let
|
|
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
|
|
1346
|
+
return N.push(r), structuredClone(r);
|
|
1194
1347
|
},
|
|
1195
1348
|
async updateRequiredCheck({ id: e, ...t }) {
|
|
1196
|
-
let
|
|
1197
|
-
if (!
|
|
1198
|
-
if (
|
|
1199
|
-
return Object.assign(
|
|
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 (!
|
|
1203
|
-
|
|
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(
|
|
1359
|
+
return structuredClone(Xe(e));
|
|
1207
1360
|
},
|
|
1208
1361
|
async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1209
|
-
let n =
|
|
1362
|
+
let n = Xe(e);
|
|
1210
1363
|
if ("everyMember" in t) {
|
|
1211
|
-
|
|
1364
|
+
L.set(e, {
|
|
1212
1365
|
...n,
|
|
1213
1366
|
everyMember: !0
|
|
1214
1367
|
});
|
|
1215
1368
|
return;
|
|
1216
1369
|
}
|
|
1217
|
-
if (!
|
|
1218
|
-
|
|
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 =
|
|
1225
|
-
|
|
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:
|
|
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
|
|
1245
|
-
return
|
|
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
|
|
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(
|
|
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 &&
|
|
1265
|
-
if (
|
|
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 &&
|
|
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
|
|
1279
|
-
if (
|
|
1280
|
-
return
|
|
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
|
|
1284
|
-
for (let n = t; n !== ""; n = Y(n).parentId) if (n === e) throw new
|
|
1285
|
-
if (
|
|
1286
|
-
return
|
|
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
|
|
1290
|
-
T.splice(T.findIndex((t) => t.id === e), 1),
|
|
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
|
|
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:
|
|
1296
|
-
if (t &&
|
|
1297
|
-
let
|
|
1298
|
-
if (
|
|
1299
|
-
if (!t && !
|
|
1300
|
-
return
|
|
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
|
-
}]) :
|
|
1456
|
+
}]) : I.delete(e), { ...r };
|
|
1304
1457
|
},
|
|
1305
1458
|
async listCollectionGrants(e) {
|
|
1306
|
-
return
|
|
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 (
|
|
1310
|
-
if (!
|
|
1311
|
-
let r =
|
|
1312
|
-
r.some((e) => e.level === "owner" && 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
|
-
|
|
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
|
|
1323
|
-
if ([...n].length > 200) throw new
|
|
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 =
|
|
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(
|
|
1329
|
-
nextPageToken:
|
|
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 :
|
|
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 =
|
|
1340
|
-
if (!o) throw new
|
|
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
|
|
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
|
|
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
|
|
1382
|
-
let n = JSON.stringify(t), r =
|
|
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
|
|
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
|
|
1388
|
-
return
|
|
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
|
|
1399
|
-
let [
|
|
1400
|
-
if (!
|
|
1401
|
-
if (n && n !==
|
|
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
|
|
1405
|
-
|
|
1406
|
-
...
|
|
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:
|
|
1563
|
+
revisionCreateTime: o?.createTime ?? a.revisionCreateTime
|
|
1411
1564
|
};
|
|
1412
1565
|
}
|
|
1413
|
-
let
|
|
1566
|
+
let o = M[r.blueprintReleaseId];
|
|
1414
1567
|
return {
|
|
1415
|
-
content:
|
|
1416
|
-
blueprintRelease:
|
|
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 =
|
|
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 =
|
|
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),
|
|
1448
|
-
if (t.kind === "revision")
|
|
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
|
|
1451
|
-
|
|
1452
|
-
} else
|
|
1453
|
-
let
|
|
1454
|
-
if (!
|
|
1455
|
-
let
|
|
1456
|
-
for (let e of [.../* @__PURE__ */ new Set([...Object.keys(
|
|
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:
|
|
1460
|
-
after:
|
|
1461
|
-
}) :
|
|
1612
|
+
before: c[e],
|
|
1613
|
+
after: s[e]
|
|
1614
|
+
}) : l.push({
|
|
1462
1615
|
path: `/${e}`,
|
|
1463
1616
|
kind: "removed",
|
|
1464
|
-
before:
|
|
1465
|
-
}) :
|
|
1617
|
+
before: c[e]
|
|
1618
|
+
}) : l.push({
|
|
1466
1619
|
path: `/${e}`,
|
|
1467
1620
|
kind: "added",
|
|
1468
|
-
after:
|
|
1621
|
+
after: s[e]
|
|
1469
1622
|
});
|
|
1470
|
-
let
|
|
1623
|
+
let u = ({ data: e, ...t }) => t;
|
|
1471
1624
|
return {
|
|
1472
|
-
base:
|
|
1473
|
-
revision:
|
|
1474
|
-
changes:
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
1514
|
-
let t =
|
|
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
|
|
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
|
|
1531
|
-
if (t.length > 50) throw new
|
|
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
|
|
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
|
|
1553
|
-
if (
|
|
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
|
|
1563
|
-
if (J(i), G(i) && !
|
|
1564
|
-
if (!G(i) && n !== "") throw new
|
|
1565
|
-
let
|
|
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 (
|
|
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
|
-
|
|
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(
|
|
1805
|
+
}, w.unshift(a);
|
|
1582
1806
|
}
|
|
1583
|
-
let
|
|
1807
|
+
let o = H++, s = `br_stub_${o}`, c = {
|
|
1584
1808
|
...structuredClone(i.main),
|
|
1585
|
-
branchId:
|
|
1809
|
+
branchId: s
|
|
1586
1810
|
};
|
|
1587
|
-
i.branches[
|
|
1588
|
-
id: `chain_stub_${
|
|
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:
|
|
1816
|
+
id: s,
|
|
1593
1817
|
position: 0,
|
|
1594
1818
|
kind: "editorial",
|
|
1595
|
-
headRevisionId:
|
|
1819
|
+
headRevisionId: c.revisionId
|
|
1596
1820
|
}]
|
|
1597
1821
|
});
|
|
1598
|
-
let [
|
|
1822
|
+
let [l] = ft(i, {
|
|
1599
1823
|
kind: "change_set",
|
|
1600
|
-
changeSetId:
|
|
1824
|
+
changeSetId: a.id
|
|
1601
1825
|
}, "");
|
|
1602
1826
|
return {
|
|
1603
|
-
changeSet: A(
|
|
1604
|
-
content:
|
|
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
|
|
1611
|
-
if (!G(i)) throw new
|
|
1612
|
-
if (!
|
|
1613
|
-
let
|
|
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:
|
|
1616
|
-
carryForwardReleaseIds:
|
|
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:
|
|
1619
|
-
coveredReleaseIds: r && r.lastDay !== "" ?
|
|
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
|
|
1626
|
-
if (!
|
|
1627
|
-
return
|
|
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:
|
|
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
|
|
1639
|
-
return
|
|
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:
|
|
1644
|
-
if (J(
|
|
1645
|
-
if (
|
|
1646
|
-
let
|
|
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:
|
|
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: [...
|
|
1878
|
+
supersedesReleaseIds: [...a ?? []],
|
|
1655
1879
|
proposed: !1,
|
|
1656
1880
|
proposedForReleaseId: "",
|
|
1657
1881
|
splitFromReleaseId: "",
|
|
1658
1882
|
withheld: !1
|
|
1659
1883
|
};
|
|
1660
|
-
return
|
|
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:
|
|
1666
|
-
if (
|
|
1667
|
-
let
|
|
1668
|
-
if (
|
|
1669
|
-
let
|
|
1670
|
-
J(
|
|
1671
|
-
let
|
|
1672
|
-
...structuredClone(
|
|
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
|
-
...
|
|
1899
|
+
...a ? { supersedesReleaseIds: [...a] } : {}
|
|
1676
1900
|
};
|
|
1677
|
-
return
|
|
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),
|
|
1683
|
-
if (!
|
|
1684
|
-
let
|
|
1685
|
-
if (
|
|
1686
|
-
let
|
|
1687
|
-
if (!
|
|
1688
|
-
let
|
|
1689
|
-
|
|
1690
|
-
id:
|
|
1691
|
-
position:
|
|
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:
|
|
1917
|
+
headRevisionId: c?.headRevisionId ?? "",
|
|
1694
1918
|
effectiveOn: r
|
|
1695
1919
|
});
|
|
1696
|
-
let
|
|
1697
|
-
return
|
|
1698
|
-
...
|
|
1699
|
-
branchId:
|
|
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:
|
|
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
|
|
1711
|
-
for (let e of i.branches)
|
|
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:
|
|
1720
|
-
return V(
|
|
1721
|
-
let { changeSetId:
|
|
1722
|
-
if (!
|
|
1723
|
-
if (
|
|
1724
|
-
contentId:
|
|
1725
|
-
branchId:
|
|
1726
|
-
expectedHeadId:
|
|
1727
|
-
currentHeadId:
|
|
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
|
|
1730
|
-
if (new Set(
|
|
1731
|
-
let
|
|
1732
|
-
for (let e of
|
|
1733
|
-
let t =
|
|
1734
|
-
n === void 0 ? delete
|
|
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
|
|
1737
|
-
changeSetId:
|
|
1738
|
-
chain:
|
|
1739
|
-
branch:
|
|
1740
|
-
c
|
|
1741
|
-
data:
|
|
1960
|
+
let p = Qe({
|
|
1961
|
+
changeSetId: e,
|
|
1962
|
+
chain: o,
|
|
1963
|
+
branch: s,
|
|
1964
|
+
c,
|
|
1965
|
+
data: f,
|
|
1742
1966
|
cause: "resolve",
|
|
1743
|
-
secondParentId:
|
|
1967
|
+
secondParentId: l.theirsRevisionId
|
|
1744
1968
|
});
|
|
1745
|
-
return
|
|
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 (
|
|
1751
|
-
|
|
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 ||
|
|
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 =
|
|
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
|
-
|
|
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:
|
|
2021
|
+
gapReferrers: We(e.id)
|
|
1797
2022
|
});
|
|
1798
2023
|
}
|
|
1799
|
-
function
|
|
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 && !
|
|
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 &&
|
|
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" &&
|
|
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
|
|
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
|
|
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,
|
|
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
|