@knkcs/contenthub-ui 0.3.0 → 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 +18 -0
- package/README.md +7 -6
- package/dist/{branch-content-fields-LyF6sD2e.js → branch-content-fields-BQG6U0yl.js} +2 -2
- package/dist/{branch-content-fields-LyF6sD2e.js.map → branch-content-fields-BQG6U0yl.js.map} +1 -1
- package/dist/{content-library-v0mjVD4J.js → content-library-DFIk09bD.js} +278 -26
- 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 +734 -9
- package/dist/index.js +3586 -2634
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +185 -3
- package/dist/testing.js +636 -396
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/content-library-v0mjVD4J.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,12 +31,13 @@ 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",
|
|
38
38
|
name: "In Bearbeitung",
|
|
39
|
-
color: "steelblue"
|
|
39
|
+
color: "steelblue",
|
|
40
|
+
isDefault: !0
|
|
40
41
|
},
|
|
41
42
|
{
|
|
42
43
|
slug: "in_review",
|
|
@@ -55,7 +56,7 @@ function E() {
|
|
|
55
56
|
}
|
|
56
57
|
];
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function ue() {
|
|
59
60
|
return {
|
|
60
61
|
in_progress: ["in_review", "on_hold"],
|
|
61
62
|
in_review: [
|
|
@@ -67,7 +68,7 @@ function se() {
|
|
|
67
68
|
on_hold: ["in_progress"]
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
+
function de() {
|
|
71
72
|
return [
|
|
72
73
|
{
|
|
73
74
|
id: "cs_bgbl_270",
|
|
@@ -193,7 +194,7 @@ function ce() {
|
|
|
193
194
|
}
|
|
194
195
|
];
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
+
function fe() {
|
|
197
198
|
return [{
|
|
198
199
|
id: "rc_print",
|
|
199
200
|
name: "Druckprobe",
|
|
@@ -208,7 +209,7 @@ function le() {
|
|
|
208
209
|
independent: !0
|
|
209
210
|
}];
|
|
210
211
|
}
|
|
211
|
-
function
|
|
212
|
+
function pe() {
|
|
212
213
|
return [
|
|
213
214
|
{
|
|
214
215
|
id: "col_bgb",
|
|
@@ -236,7 +237,7 @@ function ue() {
|
|
|
236
237
|
}
|
|
237
238
|
];
|
|
238
239
|
}
|
|
239
|
-
function
|
|
240
|
+
function me() {
|
|
240
241
|
return [
|
|
241
242
|
{
|
|
242
243
|
id: "bp_commentary",
|
|
@@ -252,7 +253,7 @@ function de() {
|
|
|
252
253
|
}
|
|
253
254
|
];
|
|
254
255
|
}
|
|
255
|
-
function
|
|
256
|
+
function he() {
|
|
256
257
|
return [
|
|
257
258
|
{
|
|
258
259
|
id: "bpr_paragraph_2",
|
|
@@ -274,7 +275,7 @@ function fe() {
|
|
|
274
275
|
}
|
|
275
276
|
];
|
|
276
277
|
}
|
|
277
|
-
function
|
|
278
|
+
function ge() {
|
|
278
279
|
let e = (e, t) => ({
|
|
279
280
|
field_type: "text",
|
|
280
281
|
config: {
|
|
@@ -286,6 +287,7 @@ function pe() {
|
|
|
286
287
|
system: !1
|
|
287
288
|
}), t = {
|
|
288
289
|
displayName: "Paragraph",
|
|
290
|
+
accessor: "paragraph",
|
|
289
291
|
dated: !0,
|
|
290
292
|
fields: [e("number", "Number"), e("heading", "Heading")],
|
|
291
293
|
parts: {}
|
|
@@ -295,13 +297,51 @@ function pe() {
|
|
|
295
297
|
bpr_paragraph_2: t,
|
|
296
298
|
bpr_footnote_1: {
|
|
297
299
|
displayName: "Footnote",
|
|
300
|
+
accessor: "footnote",
|
|
298
301
|
dated: !0,
|
|
299
302
|
fields: [e("text", "Text")],
|
|
300
303
|
parts: {}
|
|
304
|
+
},
|
|
305
|
+
bpr_note_1: {
|
|
306
|
+
displayName: "Note",
|
|
307
|
+
accessor: "note",
|
|
308
|
+
dated: !1,
|
|
309
|
+
fields: [e("title", "Title")],
|
|
310
|
+
parts: {}
|
|
301
311
|
}
|
|
302
312
|
};
|
|
303
313
|
}
|
|
304
|
-
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() {
|
|
305
345
|
let e = "2001-11-01T08:00:00.000Z";
|
|
306
346
|
return {
|
|
307
347
|
id: "content_para_3",
|
|
@@ -332,7 +372,7 @@ function D() {
|
|
|
332
372
|
}]
|
|
333
373
|
};
|
|
334
374
|
}
|
|
335
|
-
function
|
|
375
|
+
function ve() {
|
|
336
376
|
let e = "2026-09-01T08:00:00.000Z";
|
|
337
377
|
return [
|
|
338
378
|
{
|
|
@@ -585,7 +625,7 @@ function me() {
|
|
|
585
625
|
}
|
|
586
626
|
//#endregion
|
|
587
627
|
//#region src/testing/stub-blueprint-source.ts
|
|
588
|
-
function
|
|
628
|
+
function D(e = me(), t = he()) {
|
|
589
629
|
return {
|
|
590
630
|
async searchBlueprints({ query: t }) {
|
|
591
631
|
let n = t.trim().toLocaleLowerCase();
|
|
@@ -604,37 +644,37 @@ function he(e = de(), t = fe()) {
|
|
|
604
644
|
}
|
|
605
645
|
//#endregion
|
|
606
646
|
//#region src/testing/stub-client.ts
|
|
607
|
-
function
|
|
647
|
+
function ye(e, t) {
|
|
608
648
|
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
609
649
|
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
610
650
|
}
|
|
611
651
|
function O(e, t, n) {
|
|
612
652
|
let r = e.trim();
|
|
613
|
-
if (r === "") throw new
|
|
614
|
-
if ([...r].length > n) throw new
|
|
615
|
-
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`);
|
|
616
656
|
return r;
|
|
617
657
|
}
|
|
618
|
-
function
|
|
619
|
-
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`);
|
|
620
660
|
return {
|
|
621
661
|
date: e.date.trim(),
|
|
622
662
|
reference: O(e.reference, "source.reference", 500)
|
|
623
663
|
};
|
|
624
664
|
}
|
|
625
|
-
function
|
|
665
|
+
function xe(e) {
|
|
626
666
|
let t = e.trim();
|
|
627
|
-
if (t === "") throw new
|
|
628
|
-
if ([...t].length > 200) throw new
|
|
629
|
-
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");
|
|
630
670
|
return t;
|
|
631
671
|
}
|
|
632
|
-
function
|
|
672
|
+
function Se(e) {
|
|
633
673
|
let t = O(e.name, "a Required Check's name", 200);
|
|
634
|
-
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");
|
|
635
675
|
let n = e.blueprintAccessors.map((e) => {
|
|
636
676
|
let t = e.trim();
|
|
637
|
-
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`);
|
|
638
678
|
return t;
|
|
639
679
|
});
|
|
640
680
|
return {
|
|
@@ -644,7 +684,7 @@ function ye(e) {
|
|
|
644
684
|
independent: e.independent
|
|
645
685
|
};
|
|
646
686
|
}
|
|
647
|
-
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)";
|
|
648
688
|
function k(e, t) {
|
|
649
689
|
return new y(`${e} ${t}: not found`, v.NotFound);
|
|
650
690
|
}
|
|
@@ -670,25 +710,40 @@ function j(e, t = {}) {
|
|
|
670
710
|
};
|
|
671
711
|
}
|
|
672
712
|
function M(v = {}) {
|
|
673
|
-
let y = v.now ?? (() => "2026-10-01T09:00:00.000Z"), b = v.userId ?? "user_stub", x = v.statuses ??
|
|
674
|
-
if (
|
|
675
|
-
},
|
|
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) ?? {
|
|
676
716
|
everyMember: !0,
|
|
677
717
|
userIds: []
|
|
678
|
-
},
|
|
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) => {
|
|
679
734
|
if (!e) return n();
|
|
680
|
-
let r = JSON.stringify(t), i =
|
|
735
|
+
let r = JSON.stringify(t), i = ze.get(e);
|
|
681
736
|
if (i) {
|
|
682
|
-
if (i.asked !== r) throw new
|
|
737
|
+
if (i.asked !== r) throw new _(`idempotency key ${e} names another request`);
|
|
683
738
|
return structuredClone(i.answer);
|
|
684
739
|
}
|
|
685
|
-
let
|
|
686
|
-
return
|
|
740
|
+
let a = await n();
|
|
741
|
+
return ze.set(e, {
|
|
687
742
|
asked: r,
|
|
688
|
-
answer: structuredClone(
|
|
689
|
-
}),
|
|
690
|
-
},
|
|
691
|
-
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);
|
|
692
747
|
if (!t) throw k("Content", e);
|
|
693
748
|
return t;
|
|
694
749
|
}, W = (e) => structuredClone({
|
|
@@ -696,7 +751,7 @@ function M(v = {}) {
|
|
|
696
751
|
assigneeIds: e.assigneeIds ?? [],
|
|
697
752
|
block: e.block,
|
|
698
753
|
archiveTime: e.archiveTime
|
|
699
|
-
}),
|
|
754
|
+
}), He = () => y().slice(0, 10), G = (e) => M[e.blueprintReleaseId]?.dated ?? !1, K = (e) => {
|
|
700
755
|
let t = [...e.revisions ?? []], n = [...Object.entries(e.branches).map(([e, t]) => ({
|
|
701
756
|
...t,
|
|
702
757
|
changeSetId: e
|
|
@@ -723,58 +778,58 @@ function M(v = {}) {
|
|
|
723
778
|
e.main,
|
|
724
779
|
e.inForce,
|
|
725
780
|
...Object.values(e.branches)
|
|
726
|
-
].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) => {
|
|
727
782
|
let n = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
728
783
|
return (e ?? []).filter((e) => e.config.required === !0 && n(t[e.config.api_accessor])).map((e) => e.config.api_accessor);
|
|
729
784
|
}, J = (e) => {
|
|
730
|
-
if (e.archiveTime) throw new
|
|
731
|
-
if (e.block && !e.block.allowedUserIds.includes(b)) throw new
|
|
732
|
-
},
|
|
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) => ({
|
|
733
788
|
edge: { ...e },
|
|
734
789
|
releaseId: t.inForce?.releaseId ?? ""
|
|
735
|
-
}))),
|
|
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) => {
|
|
736
791
|
let t = T.find((t) => t.id === e);
|
|
737
792
|
if (!t) throw k("Collection", e);
|
|
738
793
|
return t;
|
|
739
|
-
},
|
|
740
|
-
if (
|
|
741
|
-
if (!Y(e).restricted) throw new
|
|
742
|
-
let t = (
|
|
743
|
-
if (!
|
|
744
|
-
},
|
|
745
|
-
if (
|
|
746
|
-
if (!
|
|
747
|
-
if (
|
|
748
|
-
if (!
|
|
749
|
-
return
|
|
750
|
-
},
|
|
751
|
-
let
|
|
752
|
-
if (!
|
|
753
|
-
let
|
|
754
|
-
if (J(
|
|
755
|
-
if (
|
|
756
|
-
if (
|
|
757
|
-
contentId:
|
|
758
|
-
branchId:
|
|
759
|
-
expectedHeadId:
|
|
760
|
-
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
|
|
761
816
|
});
|
|
762
|
-
let
|
|
763
|
-
if (
|
|
764
|
-
let e = Object.keys(
|
|
765
|
-
if (e.length > 0) throw new
|
|
766
|
-
|
|
767
|
-
for (let e of
|
|
768
|
-
} else
|
|
769
|
-
return
|
|
770
|
-
changeSetId:
|
|
771
|
-
chain:
|
|
772
|
-
branch:
|
|
773
|
-
c
|
|
774
|
-
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,
|
|
775
830
|
cause: "save"
|
|
776
831
|
});
|
|
777
|
-
},
|
|
832
|
+
}, Qe = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
|
|
778
833
|
let s = n.id, c = `rev_stub_${H++}`, l = y();
|
|
779
834
|
return r.revisions = [{
|
|
780
835
|
id: c,
|
|
@@ -804,7 +859,7 @@ function M(v = {}) {
|
|
|
804
859
|
revisionCreateTime: l,
|
|
805
860
|
releaseId: ""
|
|
806
861
|
};
|
|
807
|
-
},
|
|
862
|
+
}, $e = (e, t) => {
|
|
808
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);
|
|
809
864
|
if (!r || !i) throw k("Branch", t);
|
|
810
865
|
return {
|
|
@@ -813,7 +868,7 @@ function M(v = {}) {
|
|
|
813
868
|
branch: i,
|
|
814
869
|
c: U(r.contentId)
|
|
815
870
|
};
|
|
816
|
-
},
|
|
871
|
+
}, et = (e, t) => {
|
|
817
872
|
for (let n of w) for (let r of n.chains) {
|
|
818
873
|
let n = r.branches.find((t) => t.id === e);
|
|
819
874
|
if (!n) continue;
|
|
@@ -827,33 +882,33 @@ function M(v = {}) {
|
|
|
827
882
|
fields: structuredClone(t.fields),
|
|
828
883
|
merged: structuredClone(t.merged)
|
|
829
884
|
};
|
|
830
|
-
B.set(e, i), n.hasPendingMerge = !0, delete
|
|
885
|
+
B.set(e, i), n.hasPendingMerge = !0, delete Re[e];
|
|
831
886
|
return;
|
|
832
887
|
}
|
|
833
888
|
throw k("Branch", e);
|
|
834
|
-
},
|
|
889
|
+
}, tt = (e) => {
|
|
835
890
|
B.delete(e);
|
|
836
891
|
for (let t of w) for (let n of t.chains) {
|
|
837
892
|
let t = n.branches.find((t) => t.id === e);
|
|
838
893
|
t && (t.hasPendingMerge = !1);
|
|
839
894
|
}
|
|
840
|
-
},
|
|
895
|
+
}, nt = (e, t) => {
|
|
841
896
|
let n = t.validityPeriod;
|
|
842
897
|
if (G(e)) {
|
|
843
|
-
if (!n || !
|
|
844
|
-
if (n.lastDay !== "" && (!
|
|
845
|
-
} else if (n) throw new
|
|
846
|
-
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) => ({
|
|
847
902
|
source: "fieldkit",
|
|
848
903
|
code: "required",
|
|
849
904
|
path: `/${e}`
|
|
850
905
|
}));
|
|
851
|
-
if (r.length > 0) throw new
|
|
906
|
+
if (r.length > 0) throw new se("the Release Spec values break the Blueprint Release", r);
|
|
852
907
|
if (n && n.lastDay !== "") {
|
|
853
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);
|
|
854
|
-
if (r.length > 0) throw new
|
|
909
|
+
if (r.length > 0) throw new u(e.id, r);
|
|
855
910
|
}
|
|
856
|
-
},
|
|
911
|
+
}, rt = (e, t) => {
|
|
857
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) => {
|
|
858
913
|
let o = n.find((t) => t.proposedForReleaseId === e.releaseId && t.splitFromReleaseId === a);
|
|
859
914
|
i.push({
|
|
@@ -876,9 +931,9 @@ function M(v = {}) {
|
|
|
876
931
|
let t = r.validityPeriod;
|
|
877
932
|
t && !e.supersedesReleaseIds.includes(r.releaseId) && t.firstDay < n.firstDay && (t.lastDay === "" || t.lastDay >= n.firstDay) && (a(r, {
|
|
878
933
|
firstDay: t.firstDay,
|
|
879
|
-
lastDay:
|
|
934
|
+
lastDay: ye(n.firstDay, -1)
|
|
880
935
|
}, ""), n.lastDay !== "" && (t.lastDay === "" || t.lastDay > n.lastDay) && a(r, {
|
|
881
|
-
firstDay:
|
|
936
|
+
firstDay: ye(n.lastDay, 1),
|
|
882
937
|
lastDay: t.lastDay
|
|
883
938
|
}, r.releaseId));
|
|
884
939
|
}
|
|
@@ -890,9 +945,9 @@ function M(v = {}) {
|
|
|
890
945
|
return t;
|
|
891
946
|
}, Z = (e) => {
|
|
892
947
|
let t = X(e);
|
|
893
|
-
if (t.state !== "open") throw new
|
|
948
|
+
if (t.state !== "open") throw new p(t.state);
|
|
894
949
|
return t;
|
|
895
|
-
},
|
|
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) => ({
|
|
896
951
|
key: t.id,
|
|
897
952
|
branchless: !1,
|
|
898
953
|
contentId: e.contentId,
|
|
@@ -902,9 +957,9 @@ function M(v = {}) {
|
|
|
902
957
|
branchless: !0,
|
|
903
958
|
contentId: e.contentId,
|
|
904
959
|
revision: e.revisionId
|
|
905
|
-
}))],
|
|
906
|
-
let t =
|
|
907
|
-
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;
|
|
908
963
|
return {
|
|
909
964
|
check: structuredClone(e),
|
|
910
965
|
...t,
|
|
@@ -913,8 +968,8 @@ function M(v = {}) {
|
|
|
913
968
|
cleared: !!r && !i && r.outcome !== "failed"
|
|
914
969
|
};
|
|
915
970
|
}, i = [], a = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
|
|
916
|
-
for (let e of [...
|
|
917
|
-
let a = t.filter((t) =>
|
|
971
|
+
for (let e of [...N].sort(a)) {
|
|
972
|
+
let a = t.filter((t) => ct(e, t.contentId));
|
|
918
973
|
if (e.scope === "change_set") {
|
|
919
974
|
if (a.length === 0) continue;
|
|
920
975
|
let o = Object.fromEntries(t.map((e) => [e.key, e.revision]));
|
|
@@ -934,8 +989,8 @@ function M(v = {}) {
|
|
|
934
989
|
}, n(e, t.key)));
|
|
935
990
|
}
|
|
936
991
|
return i;
|
|
937
|
-
},
|
|
938
|
-
let n = [], r =
|
|
992
|
+
}, ut = (e, t) => {
|
|
993
|
+
let n = [], r = re(e);
|
|
939
994
|
for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(j("moved_head", {
|
|
940
995
|
contentId: r.contentId,
|
|
941
996
|
branchId: e.id,
|
|
@@ -950,26 +1005,26 @@ function M(v = {}) {
|
|
|
950
1005
|
let e = w.find((e) => e.id === t)?.state;
|
|
951
1006
|
e === "open" ? n.push(j("unpublished_dependency", { dependencyChangeSetId: t })) : e === "discarded" && n.push(j("discarded_dependency", { dependencyChangeSetId: t }));
|
|
952
1007
|
}
|
|
953
|
-
for (let t of
|
|
1008
|
+
for (let t of lt(e)) t.cleared || n.push(j("outstanding_check", {
|
|
954
1009
|
requiredCheckId: t.check.id,
|
|
955
1010
|
contentId: t.contentId,
|
|
956
1011
|
branchId: t.branchId,
|
|
957
1012
|
releaseId: t.releaseId
|
|
958
1013
|
}));
|
|
959
1014
|
for (let t of e.chains) {
|
|
960
|
-
let e =
|
|
1015
|
+
let e = E.find((e) => e.id === t.contentId);
|
|
961
1016
|
for (let r of t.branches) {
|
|
962
1017
|
let t = e && q(e, r.headRevisionId);
|
|
963
|
-
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", {
|
|
964
1019
|
contentId: e.id,
|
|
965
1020
|
revisionId: r.headRevisionId,
|
|
966
1021
|
path: `/${i}`
|
|
967
1022
|
}));
|
|
968
1023
|
}
|
|
969
1024
|
}
|
|
970
|
-
return [...n, ...structuredClone(
|
|
1025
|
+
return [...n, ...structuredClone(Ie[e.id] ?? [])];
|
|
971
1026
|
}, Q = (e) => {
|
|
972
|
-
let t =
|
|
1027
|
+
let t = re(e);
|
|
973
1028
|
return e.plannedReleases.filter((e) => !e.withheld).map((n) => ({
|
|
974
1029
|
id: n.id,
|
|
975
1030
|
contentId: n.contentId,
|
|
@@ -981,14 +1036,14 @@ function M(v = {}) {
|
|
|
981
1036
|
validityPeriod: n.validityPeriod ? { ...n.validityPeriod } : void 0
|
|
982
1037
|
}));
|
|
983
1038
|
};
|
|
984
|
-
for (let [e, t] of Object.entries(
|
|
985
|
-
|
|
1039
|
+
for (let [e, t] of Object.entries(Re)) t.pending && et(e, t);
|
|
1040
|
+
let $ = {
|
|
986
1041
|
async listBlockReasons() {
|
|
987
|
-
return [...C].sort(
|
|
1042
|
+
return [...C].sort(Ge).map((e) => ({ ...e }));
|
|
988
1043
|
},
|
|
989
1044
|
async createBlockReason({ name: e }) {
|
|
990
|
-
let t =
|
|
991
|
-
if (
|
|
1045
|
+
let t = xe(e);
|
|
1046
|
+
if (Ke(t)) throw new ie(t);
|
|
992
1047
|
let n = {
|
|
993
1048
|
id: `br_stub_${H++}`,
|
|
994
1049
|
name: t,
|
|
@@ -998,9 +1053,9 @@ function M(v = {}) {
|
|
|
998
1053
|
return C.push(n), { ...n };
|
|
999
1054
|
},
|
|
1000
1055
|
async renameBlockReason({ id: e, name: t }) {
|
|
1001
|
-
let n =
|
|
1056
|
+
let n = xe(t), r = C.find((t) => t.id === e);
|
|
1002
1057
|
if (!r) throw k("Block Reason", e);
|
|
1003
|
-
if (
|
|
1058
|
+
if (Ke(n, e)) throw new ie(n);
|
|
1004
1059
|
return r.name = n, r.updateTime = y(), { ...r };
|
|
1005
1060
|
},
|
|
1006
1061
|
async deleteBlockReason({ id: e }) {
|
|
@@ -1008,7 +1063,7 @@ function M(v = {}) {
|
|
|
1008
1063
|
C = C.filter((t) => t.id !== e);
|
|
1009
1064
|
},
|
|
1010
1065
|
async listChangeSets(e = {}) {
|
|
1011
|
-
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;
|
|
1012
1067
|
return {
|
|
1013
1068
|
changeSets: t.slice(r, r + n).map((e) => ({
|
|
1014
1069
|
...A(e),
|
|
@@ -1020,7 +1075,7 @@ function M(v = {}) {
|
|
|
1020
1075
|
};
|
|
1021
1076
|
},
|
|
1022
1077
|
async createChangeSet({ name: e, source: t }) {
|
|
1023
|
-
let n = O(e, "name", 200), r = t ?
|
|
1078
|
+
let n = O(e, "name", 200), r = t ? be(t) : void 0, i = {
|
|
1024
1079
|
id: `cs_stub_${H++}`,
|
|
1025
1080
|
name: n,
|
|
1026
1081
|
source: r,
|
|
@@ -1040,33 +1095,33 @@ function M(v = {}) {
|
|
|
1040
1095
|
},
|
|
1041
1096
|
async updateChangeSet({ id: e, updateMask: t, name: n, source: r }) {
|
|
1042
1097
|
let i = Z(e);
|
|
1043
|
-
if (t.length === 0) throw new
|
|
1044
|
-
let
|
|
1045
|
-
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);
|
|
1046
1101
|
},
|
|
1047
1102
|
async setChangeSetStatus({ id: e, expectedStatus: t, status: n }) {
|
|
1048
|
-
let
|
|
1049
|
-
if (
|
|
1050
|
-
if (
|
|
1051
|
-
if (!x.some((e) => e.slug === n)) throw new
|
|
1052
|
-
if (x.some((e) => e.slug ===
|
|
1053
|
-
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,
|
|
1054
1109
|
toStatus: n,
|
|
1055
|
-
reason: `There is no transition from ${
|
|
1110
|
+
reason: `There is no transition from ${it(r.status)} to ${it(n)}.`,
|
|
1056
1111
|
requiresPermission: !1
|
|
1057
1112
|
});
|
|
1058
|
-
return
|
|
1113
|
+
return r.status = n, A(r);
|
|
1059
1114
|
},
|
|
1060
1115
|
async setChangeSetAssignees({ id: e, assigneeIds: t }) {
|
|
1061
1116
|
let n = X(e);
|
|
1062
|
-
if (new Set(t).size !== t.length) throw new
|
|
1063
|
-
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");
|
|
1064
1119
|
return n.assigneeIds = [...t], A(n);
|
|
1065
1120
|
},
|
|
1066
1121
|
async addDependency({ id: e, dependsOnId: t }) {
|
|
1067
1122
|
let n = Z(e), r = X(t);
|
|
1068
|
-
if (r.state !== "open") throw new
|
|
1069
|
-
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");
|
|
1070
1125
|
return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t), A(n);
|
|
1071
1126
|
},
|
|
1072
1127
|
async removeDependency({ id: e, dependsOnId: t }) {
|
|
@@ -1076,39 +1131,102 @@ function M(v = {}) {
|
|
|
1076
1131
|
},
|
|
1077
1132
|
async validatePublish({ id: e, reviewedHeads: t }) {
|
|
1078
1133
|
let n = X(e);
|
|
1079
|
-
|
|
1080
|
-
let r =
|
|
1081
|
-
if (r &&
|
|
1134
|
+
F(e);
|
|
1135
|
+
let r = Be.get(e);
|
|
1136
|
+
if (r && h(r, t)) return {
|
|
1082
1137
|
blockers: [],
|
|
1083
1138
|
releases: Q(n),
|
|
1084
1139
|
published: !0
|
|
1085
1140
|
};
|
|
1086
|
-
if (n.state !== "open") throw new
|
|
1141
|
+
if (n.state !== "open") throw new p(n.state);
|
|
1087
1142
|
return {
|
|
1088
|
-
blockers:
|
|
1143
|
+
blockers: ut(n, t),
|
|
1089
1144
|
releases: Q(n),
|
|
1090
1145
|
published: !1
|
|
1091
1146
|
};
|
|
1092
1147
|
},
|
|
1093
|
-
async publish({ id: e, reviewedHeads:
|
|
1094
|
-
let
|
|
1095
|
-
|
|
1096
|
-
let
|
|
1097
|
-
if (
|
|
1098
|
-
changeSet: A(
|
|
1099
|
-
publishTime:
|
|
1100
|
-
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)
|
|
1101
1156
|
};
|
|
1102
|
-
if (
|
|
1103
|
-
let
|
|
1104
|
-
if (
|
|
1105
|
-
let
|
|
1106
|
-
return
|
|
1107
|
-
changeSet: A(
|
|
1108
|
-
publishTime:
|
|
1109
|
-
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
|
|
1110
1165
|
};
|
|
1111
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
|
+
},
|
|
1112
1230
|
async updateFromMain({ id: e, chainId: t, idempotencyKey: n }) {
|
|
1113
1231
|
return V(n, [
|
|
1114
1232
|
"updateFromMain",
|
|
@@ -1116,16 +1234,16 @@ function M(v = {}) {
|
|
|
1116
1234
|
t
|
|
1117
1235
|
], async () => {
|
|
1118
1236
|
let n = Z(e);
|
|
1119
|
-
t ||
|
|
1237
|
+
t || F(e);
|
|
1120
1238
|
let r = t ? n.chains.filter((e) => e.id === t) : n.chains;
|
|
1121
1239
|
if (t && r.length === 0) throw k("Chain", t);
|
|
1122
|
-
let i = structuredClone(
|
|
1240
|
+
let i = structuredClone(Le[e] ?? []), a = [];
|
|
1123
1241
|
for (let e of r) for (let t of e.branches) {
|
|
1124
1242
|
let n = {
|
|
1125
1243
|
branchId: t.id,
|
|
1126
1244
|
contentId: e.contentId
|
|
1127
|
-
}, r =
|
|
1128
|
-
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));
|
|
1129
1247
|
}
|
|
1130
1248
|
return {
|
|
1131
1249
|
changeSet: A(n),
|
|
@@ -1138,90 +1256,126 @@ function M(v = {}) {
|
|
|
1138
1256
|
},
|
|
1139
1257
|
async discardChangeSet(e) {
|
|
1140
1258
|
let t = Z(e);
|
|
1141
|
-
return
|
|
1259
|
+
return F(e), t.state = "discarded", t.closeTime = y(), t.chains = [], A(t);
|
|
1142
1260
|
},
|
|
1143
1261
|
async listCheckResults(e) {
|
|
1144
|
-
return
|
|
1145
|
-
},
|
|
1146
|
-
async recordCheckResult({ changeSetId:
|
|
1147
|
-
let
|
|
1148
|
-
if (
|
|
1149
|
-
if ([...
|
|
1150
|
-
let
|
|
1151
|
-
if (!
|
|
1152
|
-
let
|
|
1153
|
-
if (
|
|
1154
|
-
let
|
|
1155
|
-
if (
|
|
1156
|
-
if (
|
|
1157
|
-
for (let
|
|
1158
|
-
let
|
|
1159
|
-
if (!
|
|
1160
|
-
if (
|
|
1161
|
-
contentId:
|
|
1162
|
-
branchId:
|
|
1163
|
-
expectedHeadId:
|
|
1164
|
-
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
|
|
1165
1283
|
});
|
|
1166
1284
|
}
|
|
1167
|
-
let
|
|
1285
|
+
let p = {
|
|
1168
1286
|
id: `cr_stub_${H++}`,
|
|
1169
|
-
requiredCheckId:
|
|
1170
|
-
heads: { ...
|
|
1171
|
-
outcome:
|
|
1172
|
-
note:
|
|
1287
|
+
requiredCheckId: t,
|
|
1288
|
+
heads: { ...n },
|
|
1289
|
+
outcome: r,
|
|
1290
|
+
note: a,
|
|
1173
1291
|
recordedBy: b,
|
|
1174
1292
|
recordTime: y()
|
|
1175
1293
|
};
|
|
1176
|
-
return
|
|
1177
|
-
...
|
|
1178
|
-
changeSetId:
|
|
1179
|
-
}), 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);
|
|
1180
1334
|
},
|
|
1181
1335
|
async listRequiredChecks() {
|
|
1182
1336
|
let e = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
|
|
1183
|
-
return structuredClone([...
|
|
1337
|
+
return structuredClone([...N].sort(e));
|
|
1184
1338
|
},
|
|
1185
1339
|
async createRequiredCheck(e) {
|
|
1186
|
-
let t =
|
|
1187
|
-
if (
|
|
1188
|
-
let
|
|
1340
|
+
let t = Se(e);
|
|
1341
|
+
if (N.some((e) => e.name === t.name)) throw new n(t.name);
|
|
1342
|
+
let r = {
|
|
1189
1343
|
id: `rc_stub_${H++}`,
|
|
1190
1344
|
...t
|
|
1191
1345
|
};
|
|
1192
|
-
return
|
|
1346
|
+
return N.push(r), structuredClone(r);
|
|
1193
1347
|
},
|
|
1194
1348
|
async updateRequiredCheck({ id: e, ...t }) {
|
|
1195
|
-
let
|
|
1196
|
-
if (!
|
|
1197
|
-
if (
|
|
1198
|
-
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);
|
|
1199
1353
|
},
|
|
1200
1354
|
async deleteRequiredCheck({ id: e }) {
|
|
1201
|
-
if (!
|
|
1202
|
-
|
|
1355
|
+
if (!N.some((t) => t.id === e)) throw k("Required Check", e);
|
|
1356
|
+
N = N.filter((t) => t.id !== e), L.delete(e);
|
|
1203
1357
|
},
|
|
1204
1358
|
async listRequiredCheckRecorders(e) {
|
|
1205
|
-
return structuredClone(
|
|
1359
|
+
return structuredClone(Xe(e));
|
|
1206
1360
|
},
|
|
1207
1361
|
async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1208
|
-
let n =
|
|
1362
|
+
let n = Xe(e);
|
|
1209
1363
|
if ("everyMember" in t) {
|
|
1210
|
-
|
|
1364
|
+
L.set(e, {
|
|
1211
1365
|
...n,
|
|
1212
1366
|
everyMember: !0
|
|
1213
1367
|
});
|
|
1214
1368
|
return;
|
|
1215
1369
|
}
|
|
1216
|
-
if (!
|
|
1217
|
-
|
|
1370
|
+
if (!ke.includes(t.userId)) throw new _(`user ${t.userId} is not a member of the workspace`);
|
|
1371
|
+
L.set(e, {
|
|
1218
1372
|
...n,
|
|
1219
1373
|
userIds: [.../* @__PURE__ */ new Set([...n.userIds, t.userId])].sort()
|
|
1220
1374
|
});
|
|
1221
1375
|
},
|
|
1222
1376
|
async revokeRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1223
|
-
let n =
|
|
1224
|
-
|
|
1377
|
+
let n = Xe(e);
|
|
1378
|
+
L.set(e, "everyMember" in t ? {
|
|
1225
1379
|
...n,
|
|
1226
1380
|
everyMember: !1
|
|
1227
1381
|
} : {
|
|
@@ -1232,7 +1386,7 @@ function M(v = {}) {
|
|
|
1232
1386
|
async searchBlueprints({ query: e }) {
|
|
1233
1387
|
let t = e.trim().toLocaleLowerCase();
|
|
1234
1388
|
return {
|
|
1235
|
-
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) => ({
|
|
1236
1390
|
id: e.id,
|
|
1237
1391
|
name: e.name
|
|
1238
1392
|
})),
|
|
@@ -1240,14 +1394,14 @@ function M(v = {}) {
|
|
|
1240
1394
|
};
|
|
1241
1395
|
},
|
|
1242
1396
|
async getBlueprints(e) {
|
|
1243
|
-
if (e.length > 1e3) throw new
|
|
1244
|
-
return
|
|
1397
|
+
if (e.length > 1e3) throw new _(`at most ${c} Blueprint ids`);
|
|
1398
|
+
return _e.filter((t) => e.includes(t.id)).map((e) => ({
|
|
1245
1399
|
id: e.id,
|
|
1246
1400
|
name: e.name
|
|
1247
1401
|
}));
|
|
1248
1402
|
},
|
|
1249
1403
|
async listBlueprintReleases(e) {
|
|
1250
|
-
return
|
|
1404
|
+
return D.filter((t) => t.blueprintId === e).map((e) => ({
|
|
1251
1405
|
id: e.id,
|
|
1252
1406
|
blueprintId: e.blueprintId,
|
|
1253
1407
|
name: e.name ?? e.id,
|
|
@@ -1256,94 +1410,94 @@ function M(v = {}) {
|
|
|
1256
1410
|
}));
|
|
1257
1411
|
},
|
|
1258
1412
|
async listCollections() {
|
|
1259
|
-
return [...T].sort(
|
|
1413
|
+
return [...T].sort(qe).map((e) => ({ ...e }));
|
|
1260
1414
|
},
|
|
1261
1415
|
async createCollection({ name: e, parentId: t = "", restricted: r = !1 }) {
|
|
1262
1416
|
let i = O(e, "a Collection's name", 200);
|
|
1263
|
-
if (t !== "" && Y(t), r &&
|
|
1264
|
-
if (
|
|
1417
|
+
if (t !== "" && Y(t), r && P === "workspace") throw new m(Te);
|
|
1418
|
+
if (Je(t, i)) throw new n(i);
|
|
1265
1419
|
let a = {
|
|
1266
1420
|
id: `col_stub_${H++}`,
|
|
1267
1421
|
name: i,
|
|
1268
1422
|
parentId: t,
|
|
1269
1423
|
restricted: r
|
|
1270
1424
|
};
|
|
1271
|
-
return T.push(a), r &&
|
|
1425
|
+
return T.push(a), r && I.set(a.id, [{
|
|
1272
1426
|
userId: b,
|
|
1273
1427
|
level: "owner"
|
|
1274
1428
|
}]), { ...a };
|
|
1275
1429
|
},
|
|
1276
1430
|
async renameCollection({ id: e, name: t }) {
|
|
1277
|
-
let
|
|
1278
|
-
if (
|
|
1279
|
-
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 };
|
|
1280
1434
|
},
|
|
1281
1435
|
async moveCollection({ id: e, parentId: t }) {
|
|
1282
|
-
let
|
|
1283
|
-
for (let n = t; n !== ""; n = Y(n).parentId) if (n === e) throw new
|
|
1284
|
-
if (
|
|
1285
|
-
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 };
|
|
1286
1440
|
},
|
|
1287
1441
|
async removeCollection({ id: e }) {
|
|
1288
|
-
if (Y(e), T.some((t) => t.parentId === e)) throw new
|
|
1289
|
-
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);
|
|
1290
1444
|
let t = [];
|
|
1291
|
-
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));
|
|
1292
1446
|
return t;
|
|
1293
1447
|
},
|
|
1294
|
-
async setCollectionRestricted({ id: e, restricted: t, acknowledgeDisclosure:
|
|
1295
|
-
if (t &&
|
|
1296
|
-
let
|
|
1297
|
-
if (
|
|
1298
|
-
if (!t && !
|
|
1299
|
-
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, [{
|
|
1300
1454
|
userId: b,
|
|
1301
1455
|
level: "owner"
|
|
1302
|
-
}]) :
|
|
1456
|
+
}]) : I.delete(e), { ...r };
|
|
1303
1457
|
},
|
|
1304
1458
|
async listCollectionGrants(e) {
|
|
1305
|
-
return
|
|
1459
|
+
return Ye(e), structuredClone(I.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
|
|
1306
1460
|
},
|
|
1307
1461
|
async grantCollectionAccess({ collectionId: e, userId: t, level: n }) {
|
|
1308
|
-
if (
|
|
1309
|
-
if (!
|
|
1310
|
-
let r =
|
|
1311
|
-
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), {
|
|
1312
1466
|
userId: t,
|
|
1313
1467
|
level: n
|
|
1314
1468
|
}]);
|
|
1315
1469
|
},
|
|
1316
1470
|
async revokeCollectionAccess({ collectionId: e, userId: t }) {
|
|
1317
|
-
|
|
1471
|
+
Ye(e), I.set(e, (I.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
|
|
1318
1472
|
},
|
|
1319
1473
|
async listContents(e = {}) {
|
|
1320
1474
|
let t = e.view ?? { kind: "main" }, n = (e.search ?? "").trim();
|
|
1321
|
-
if (n !== "" && t.kind === "in_force") throw new
|
|
1322
|
-
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");
|
|
1323
1477
|
if (e.collectionId && !T.some((t) => t.id === e.collectionId)) throw k("Collection", e.collectionId);
|
|
1324
1478
|
t.kind === "change_set" && X(t.changeSetId);
|
|
1325
|
-
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;
|
|
1326
1480
|
return {
|
|
1327
|
-
contents: r.slice(
|
|
1328
|
-
nextPageToken:
|
|
1481
|
+
contents: r.slice(a, a + i),
|
|
1482
|
+
nextPageToken: a + i < r.length ? String(a + i) : ""
|
|
1329
1483
|
};
|
|
1330
1484
|
},
|
|
1331
1485
|
async createContent({ changeSetId: e, blueprintReleaseId: t, copyFrom: n }) {
|
|
1332
1486
|
let r = Z(e), i = {}, a = t;
|
|
1333
1487
|
if (n) {
|
|
1334
|
-
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));
|
|
1335
1489
|
if (!r || !e) throw k("copy source", JSON.stringify(n));
|
|
1336
1490
|
i = structuredClone(q(r, e) ?? {}), a = t || r.blueprintReleaseId;
|
|
1337
1491
|
}
|
|
1338
|
-
let o =
|
|
1339
|
-
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`, [{
|
|
1340
1494
|
source: "contenthub",
|
|
1341
1495
|
code: "release_not_found",
|
|
1342
1496
|
path: ""
|
|
1343
1497
|
}]);
|
|
1344
|
-
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 })));
|
|
1345
1499
|
let s = H++, c = `content_stub_${s}`, l = `br_stub_${s}`, u = `rev_stub_${s}`;
|
|
1346
|
-
return
|
|
1500
|
+
return E.push({
|
|
1347
1501
|
id: c,
|
|
1348
1502
|
blueprintId: o.blueprintId,
|
|
1349
1503
|
blueprintReleaseId: a,
|
|
@@ -1377,29 +1531,43 @@ function M(v = {}) {
|
|
|
1377
1531
|
};
|
|
1378
1532
|
},
|
|
1379
1533
|
async saveRevision({ idempotencyKey: e, ...t }) {
|
|
1380
|
-
if (!e) return
|
|
1381
|
-
let n = JSON.stringify(t), r =
|
|
1534
|
+
if (!e) return Ze(t);
|
|
1535
|
+
let n = JSON.stringify(t), r = Ve.get(e);
|
|
1382
1536
|
if (r) {
|
|
1383
|
-
if (r.asked !== n) throw new
|
|
1537
|
+
if (r.asked !== n) throw new _(`idempotency key ${e} names another save`);
|
|
1384
1538
|
return structuredClone(r.content);
|
|
1385
1539
|
}
|
|
1386
|
-
let i = await
|
|
1387
|
-
return
|
|
1540
|
+
let i = await Ze(t);
|
|
1541
|
+
return Ve.set(e, {
|
|
1388
1542
|
asked: n,
|
|
1389
1543
|
content: structuredClone(i)
|
|
1390
1544
|
}), i;
|
|
1391
1545
|
},
|
|
1392
|
-
async getContent({ id: e, changeSetId: t }) {
|
|
1393
|
-
let
|
|
1546
|
+
async getContent({ id: e, changeSetId: t, branchId: n }) {
|
|
1547
|
+
let r = U(e), i = t ? {
|
|
1394
1548
|
kind: "change_set",
|
|
1395
1549
|
changeSetId: t
|
|
1396
|
-
} : { kind: "main" }
|
|
1397
|
-
if (!
|
|
1398
|
-
let
|
|
1550
|
+
} : { kind: "main" };
|
|
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) {
|
|
1555
|
+
let i = w.find((e) => e.id === t)?.chains.find((t) => t.contentId === e)?.branches.find((e) => e.id === n);
|
|
1556
|
+
if (!i) throw k("Branch", n);
|
|
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,
|
|
1560
|
+
revisionId: i.headRevisionId,
|
|
1561
|
+
data: structuredClone(s),
|
|
1562
|
+
branchId: n,
|
|
1563
|
+
revisionCreateTime: o?.createTime ?? a.revisionCreateTime
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
let o = M[r.blueprintReleaseId];
|
|
1399
1567
|
return {
|
|
1400
|
-
content:
|
|
1401
|
-
blueprintRelease:
|
|
1402
|
-
attributes: W(
|
|
1568
|
+
content: a,
|
|
1569
|
+
blueprintRelease: o ? structuredClone(o) : void 0,
|
|
1570
|
+
attributes: W(r)
|
|
1403
1571
|
};
|
|
1404
1572
|
},
|
|
1405
1573
|
async getTimeline(e) {
|
|
@@ -1416,7 +1584,7 @@ function M(v = {}) {
|
|
|
1416
1584
|
if (!t.main) throw k("Content", e.contentId);
|
|
1417
1585
|
r = K(t);
|
|
1418
1586
|
} else {
|
|
1419
|
-
let t =
|
|
1587
|
+
let t = E.find((t) => K(t).some((t) => t.branchId === e.branchId));
|
|
1420
1588
|
if (!t) throw k("Branch", e.branchId);
|
|
1421
1589
|
r = K(t).filter((t) => t.branchId === e.branchId);
|
|
1422
1590
|
}
|
|
@@ -1427,36 +1595,36 @@ function M(v = {}) {
|
|
|
1427
1595
|
};
|
|
1428
1596
|
},
|
|
1429
1597
|
async compare({ revisionId: e, base: t }) {
|
|
1430
|
-
let n =
|
|
1598
|
+
let n = E.find((t) => K(t).some((t) => t.id === e));
|
|
1431
1599
|
if (!n) throw k("Revision", e);
|
|
1432
|
-
let r = K(n), i = r.find((t) => t.id === e),
|
|
1433
|
-
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;
|
|
1434
1602
|
else if (t.kind === "main_head") {
|
|
1435
|
-
if (!n.main) throw new
|
|
1436
|
-
|
|
1437
|
-
} else
|
|
1438
|
-
let
|
|
1439
|
-
if (!
|
|
1440
|
-
let
|
|
1441
|
-
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({
|
|
1442
1610
|
path: `/${e}`,
|
|
1443
1611
|
kind: "changed",
|
|
1444
|
-
before:
|
|
1445
|
-
after:
|
|
1446
|
-
}) :
|
|
1612
|
+
before: c[e],
|
|
1613
|
+
after: s[e]
|
|
1614
|
+
}) : l.push({
|
|
1447
1615
|
path: `/${e}`,
|
|
1448
1616
|
kind: "removed",
|
|
1449
|
-
before:
|
|
1450
|
-
}) :
|
|
1617
|
+
before: c[e]
|
|
1618
|
+
}) : l.push({
|
|
1451
1619
|
path: `/${e}`,
|
|
1452
1620
|
kind: "added",
|
|
1453
|
-
after:
|
|
1621
|
+
after: s[e]
|
|
1454
1622
|
});
|
|
1455
|
-
let
|
|
1623
|
+
let u = ({ data: e, ...t }) => t;
|
|
1456
1624
|
return {
|
|
1457
|
-
base:
|
|
1458
|
-
revision:
|
|
1459
|
-
changes:
|
|
1625
|
+
base: u(o),
|
|
1626
|
+
revision: u(i),
|
|
1627
|
+
changes: l
|
|
1460
1628
|
};
|
|
1461
1629
|
},
|
|
1462
1630
|
async listReferences({ contentId: e, revisionId: t }) {
|
|
@@ -1470,14 +1638,14 @@ function M(v = {}) {
|
|
|
1470
1638
|
referrers: e.slice(i, i + t),
|
|
1471
1639
|
nextPageToken: i + t < e.length ? String(i + t) : ""
|
|
1472
1640
|
};
|
|
1473
|
-
}, a =
|
|
1641
|
+
}, a = E.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
|
|
1474
1642
|
edge: { ...e },
|
|
1475
1643
|
releaseId: t.inForce?.releaseId ?? "",
|
|
1476
1644
|
changeSetId: "",
|
|
1477
1645
|
branchId: ""
|
|
1478
1646
|
})));
|
|
1479
1647
|
if (!t) return i(a);
|
|
1480
|
-
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) => ({
|
|
1481
1649
|
edge: { ...e },
|
|
1482
1650
|
releaseId: "",
|
|
1483
1651
|
changeSetId: n,
|
|
@@ -1489,14 +1657,14 @@ function M(v = {}) {
|
|
|
1489
1657
|
let t;
|
|
1490
1658
|
if ("revisionId" in e) t = e.revisionId;
|
|
1491
1659
|
else {
|
|
1492
|
-
for (let n of
|
|
1660
|
+
for (let n of E) {
|
|
1493
1661
|
let r = Object.values(n.branches).find((t) => t.branchId === e.branchId);
|
|
1494
1662
|
r && (t = r.revisionId);
|
|
1495
1663
|
}
|
|
1496
1664
|
if (!t) throw k("Branch", e.branchId);
|
|
1497
1665
|
}
|
|
1498
|
-
return
|
|
1499
|
-
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 ?? "";
|
|
1500
1668
|
return t === e.pinReleaseId ? [] : [{
|
|
1501
1669
|
edge: { ...e },
|
|
1502
1670
|
supersededByReleaseId: t,
|
|
@@ -1506,20 +1674,20 @@ function M(v = {}) {
|
|
|
1506
1674
|
},
|
|
1507
1675
|
async setContentCollections({ contentId: e, collectionIds: t }) {
|
|
1508
1676
|
let n = U(e), r = [...new Set(t)];
|
|
1509
|
-
if (r.length > 100) throw new
|
|
1677
|
+
if (r.length > 100) throw new _("at most 100 Collections");
|
|
1510
1678
|
for (let e of r) if (!T.some((t) => t.id === e)) throw k("Collection", e);
|
|
1511
1679
|
return n.collectionIds = r.sort(), [...n.collectionIds];
|
|
1512
1680
|
},
|
|
1513
1681
|
async setContentAssignees({ contentId: e, assigneeIds: t }) {
|
|
1514
1682
|
let n = U(e);
|
|
1515
|
-
if (new Set(t).size !== t.length) throw new
|
|
1516
|
-
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");
|
|
1517
1685
|
return n.assigneeIds = [...t], W(n);
|
|
1518
1686
|
},
|
|
1519
1687
|
async blockContent({ contentId: e, blockReasonId: t, allowedUserIds: n }) {
|
|
1520
1688
|
let r = U(e);
|
|
1521
1689
|
if (!C.some((e) => e.id === t)) throw k("Block Reason", t);
|
|
1522
|
-
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");
|
|
1523
1691
|
return r.block = {
|
|
1524
1692
|
blockReasonId: t,
|
|
1525
1693
|
allowedUserIds: [...n],
|
|
@@ -1534,25 +1702,96 @@ function M(v = {}) {
|
|
|
1534
1702
|
async archiveContent(e) {
|
|
1535
1703
|
let t = U(e);
|
|
1536
1704
|
if (t.archiveTime) return W(t);
|
|
1537
|
-
if (!t.main) throw new
|
|
1538
|
-
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`);
|
|
1539
1707
|
return t.archiveTime = y(), W(t);
|
|
1540
1708
|
},
|
|
1541
1709
|
async unarchiveContent(e) {
|
|
1542
1710
|
let t = U(e);
|
|
1543
1711
|
return t.archiveTime = void 0, W(t);
|
|
1544
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
|
+
},
|
|
1545
1783
|
async startEditing({ contentId: e, changeSetId: t, effectiveOn: n = "", changeSetName: r = "" }) {
|
|
1546
1784
|
let i = U(e);
|
|
1547
|
-
if (!i.main) throw new
|
|
1548
|
-
if (J(i), G(i) && !
|
|
1549
|
-
if (!G(i) && n !== "") throw new
|
|
1550
|
-
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;
|
|
1551
1789
|
if (t) {
|
|
1552
|
-
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`);
|
|
1553
1792
|
} else {
|
|
1554
1793
|
let t = Object.values(i.main.data).filter((e) => typeof e == "string").slice(0, 2).join(" ");
|
|
1555
|
-
|
|
1794
|
+
a = {
|
|
1556
1795
|
id: `cs_stub_${H++}`,
|
|
1557
1796
|
name: r.trim() ? O(r, "change_set_name", 200) : t || e,
|
|
1558
1797
|
state: "open",
|
|
@@ -1563,56 +1802,56 @@ function M(v = {}) {
|
|
|
1563
1802
|
status: "",
|
|
1564
1803
|
assigneeIds: [],
|
|
1565
1804
|
plannedReleases: []
|
|
1566
|
-
}, w.unshift(
|
|
1805
|
+
}, w.unshift(a);
|
|
1567
1806
|
}
|
|
1568
|
-
let
|
|
1807
|
+
let o = H++, s = `br_stub_${o}`, c = {
|
|
1569
1808
|
...structuredClone(i.main),
|
|
1570
|
-
branchId:
|
|
1809
|
+
branchId: s
|
|
1571
1810
|
};
|
|
1572
|
-
i.branches[
|
|
1573
|
-
id: `chain_stub_${
|
|
1811
|
+
i.branches[a.id] = c, a.chains.push({
|
|
1812
|
+
id: `chain_stub_${o}`,
|
|
1574
1813
|
contentId: e,
|
|
1575
1814
|
born: !1,
|
|
1576
1815
|
branches: [{
|
|
1577
|
-
id:
|
|
1816
|
+
id: s,
|
|
1578
1817
|
position: 0,
|
|
1579
1818
|
kind: "editorial",
|
|
1580
|
-
headRevisionId:
|
|
1819
|
+
headRevisionId: c.revisionId
|
|
1581
1820
|
}]
|
|
1582
1821
|
});
|
|
1583
|
-
let [
|
|
1822
|
+
let [l] = ft(i, {
|
|
1584
1823
|
kind: "change_set",
|
|
1585
|
-
changeSetId:
|
|
1824
|
+
changeSetId: a.id
|
|
1586
1825
|
}, "");
|
|
1587
1826
|
return {
|
|
1588
|
-
changeSet: A(
|
|
1589
|
-
content:
|
|
1827
|
+
changeSet: A(a),
|
|
1828
|
+
content: l
|
|
1590
1829
|
};
|
|
1591
1830
|
},
|
|
1592
1831
|
async previewChain({ changeSetId: e, contentId: t, effectiveOn: n, validityPeriod: r }) {
|
|
1593
1832
|
Z(e);
|
|
1594
1833
|
let i = U(t);
|
|
1595
|
-
if (!i.main) throw new
|
|
1596
|
-
if (!G(i)) throw new
|
|
1597
|
-
if (!
|
|
1598
|
-
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));
|
|
1599
1838
|
return {
|
|
1600
|
-
forkReleaseId:
|
|
1601
|
-
carryForwardReleaseIds:
|
|
1839
|
+
forkReleaseId: o?.releaseId ?? "",
|
|
1840
|
+
carryForwardReleaseIds: a.filter((e) => e.validityPeriod && e.validityPeriod.firstDay > n).map((e) => e.releaseId),
|
|
1602
1841
|
mergesMain: !1,
|
|
1603
|
-
cutIntoReleaseIds:
|
|
1604
|
-
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) : []
|
|
1605
1844
|
};
|
|
1606
1845
|
},
|
|
1607
1846
|
async planRepeal({ changeSetId: e, contentId: t, lastDay: n }) {
|
|
1608
1847
|
Z(e);
|
|
1609
1848
|
let r = U(t);
|
|
1610
|
-
if (J(r), !G(r)) throw new
|
|
1611
|
-
if (!
|
|
1612
|
-
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, {
|
|
1613
1852
|
kind: "repeal",
|
|
1614
1853
|
validityPeriod: {
|
|
1615
|
-
firstDay:
|
|
1854
|
+
firstDay: te(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
|
|
1616
1855
|
lastDay: n
|
|
1617
1856
|
}
|
|
1618
1857
|
});
|
|
@@ -1620,71 +1859,71 @@ function M(v = {}) {
|
|
|
1620
1859
|
async planWithdrawal({ changeSetId: e, contentId: t }) {
|
|
1621
1860
|
Z(e);
|
|
1622
1861
|
let n = U(t);
|
|
1623
|
-
if (J(n), G(n)) throw new
|
|
1624
|
-
return
|
|
1862
|
+
if (J(n), G(n)) throw new _("a Withdrawal is for undated Content");
|
|
1863
|
+
return dt(n, e, { kind: "withdrawal" });
|
|
1625
1864
|
},
|
|
1626
1865
|
async planRelease({ idempotencyKey: e, ...t }) {
|
|
1627
1866
|
return V(e, ["planRelease", t], async () => {
|
|
1628
|
-
let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds:
|
|
1629
|
-
if (J(
|
|
1630
|
-
if (
|
|
1631
|
-
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 = {
|
|
1632
1871
|
id: `rls_stub_${H++}`,
|
|
1633
|
-
contentId:
|
|
1872
|
+
contentId: s.contentId,
|
|
1634
1873
|
kind: "revision",
|
|
1635
1874
|
branchId: n,
|
|
1636
1875
|
revisionId: "",
|
|
1637
1876
|
validityPeriod: r ? { ...r } : void 0,
|
|
1638
1877
|
releaseSpec: structuredClone(i ?? {}),
|
|
1639
|
-
supersedesReleaseIds: [...
|
|
1878
|
+
supersedesReleaseIds: [...a ?? []],
|
|
1640
1879
|
proposed: !1,
|
|
1641
1880
|
proposedForReleaseId: "",
|
|
1642
1881
|
splitFromReleaseId: "",
|
|
1643
1882
|
withheld: !1
|
|
1644
1883
|
};
|
|
1645
|
-
return
|
|
1884
|
+
return nt(l, u), o.plannedReleases.push(u), rt(o, l), structuredClone(u);
|
|
1646
1885
|
});
|
|
1647
1886
|
},
|
|
1648
1887
|
async updatePlannedRelease({ idempotencyKey: e, ...t }) {
|
|
1649
1888
|
return V(e, ["updatePlannedRelease", t], async () => {
|
|
1650
|
-
let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds:
|
|
1651
|
-
if (
|
|
1652
|
-
let
|
|
1653
|
-
if (
|
|
1654
|
-
let
|
|
1655
|
-
J(
|
|
1656
|
-
let
|
|
1657
|
-
...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),
|
|
1658
1897
|
...r ? { validityPeriod: { ...r } } : {},
|
|
1659
1898
|
...i ? { releaseSpec: structuredClone(i) } : {},
|
|
1660
|
-
...
|
|
1899
|
+
...a ? { supersedesReleaseIds: [...a] } : {}
|
|
1661
1900
|
};
|
|
1662
|
-
return
|
|
1901
|
+
return nt(l, u), o.plannedReleases[s] = u, rt(o, l), structuredClone(u);
|
|
1663
1902
|
});
|
|
1664
1903
|
},
|
|
1665
1904
|
async appendBranch({ idempotencyKey: e, ...t }) {
|
|
1666
1905
|
return V(e, ["appendBranch", t], async () => {
|
|
1667
|
-
let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = Z(e),
|
|
1668
|
-
if (!
|
|
1669
|
-
let
|
|
1670
|
-
if (
|
|
1671
|
-
let
|
|
1672
|
-
if (!
|
|
1673
|
-
let
|
|
1674
|
-
|
|
1675
|
-
id:
|
|
1676
|
-
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,
|
|
1677
1916
|
kind: "editorial",
|
|
1678
|
-
headRevisionId:
|
|
1917
|
+
headRevisionId: c?.headRevisionId ?? "",
|
|
1679
1918
|
effectiveOn: r
|
|
1680
1919
|
});
|
|
1681
|
-
let
|
|
1682
|
-
return
|
|
1683
|
-
...
|
|
1684
|
-
branchId:
|
|
1920
|
+
let u = o.branches[e];
|
|
1921
|
+
return u && (o.branches[e] = {
|
|
1922
|
+
...u,
|
|
1923
|
+
branchId: l
|
|
1685
1924
|
}), {
|
|
1686
1925
|
changeSet: A(i),
|
|
1687
|
-
branchId:
|
|
1926
|
+
branchId: l
|
|
1688
1927
|
};
|
|
1689
1928
|
});
|
|
1690
1929
|
},
|
|
@@ -1692,8 +1931,8 @@ function M(v = {}) {
|
|
|
1692
1931
|
return V(e, ["dropChain", t], async () => {
|
|
1693
1932
|
let { changeSetId: e, chainId: n } = t, r = Z(e), i = r.chains.find((e) => e.id === n);
|
|
1694
1933
|
if (!i) throw k("Chain", n);
|
|
1695
|
-
if (i.born) throw new
|
|
1696
|
-
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);
|
|
1697
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);
|
|
1698
1937
|
});
|
|
1699
1938
|
},
|
|
@@ -1701,43 +1940,43 @@ function M(v = {}) {
|
|
|
1701
1940
|
let t = B.get(e);
|
|
1702
1941
|
return t ? structuredClone(t) : null;
|
|
1703
1942
|
},
|
|
1704
|
-
async resolveMerge({ idempotencyKey:
|
|
1705
|
-
return V(
|
|
1706
|
-
let { changeSetId:
|
|
1707
|
-
if (!
|
|
1708
|
-
if (
|
|
1709
|
-
contentId:
|
|
1710
|
-
branchId:
|
|
1711
|
-
expectedHeadId:
|
|
1712
|
-
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
|
|
1713
1952
|
});
|
|
1714
|
-
let
|
|
1715
|
-
if (new Set(
|
|
1716
|
-
let
|
|
1717
|
-
for (let e of
|
|
1718
|
-
let t =
|
|
1719
|
-
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);
|
|
1720
1959
|
}
|
|
1721
|
-
let
|
|
1722
|
-
changeSetId:
|
|
1723
|
-
chain:
|
|
1724
|
-
branch:
|
|
1725
|
-
c
|
|
1726
|
-
data:
|
|
1960
|
+
let p = Qe({
|
|
1961
|
+
changeSetId: e,
|
|
1962
|
+
chain: o,
|
|
1963
|
+
branch: s,
|
|
1964
|
+
c,
|
|
1965
|
+
data: f,
|
|
1727
1966
|
cause: "resolve",
|
|
1728
|
-
secondParentId:
|
|
1967
|
+
secondParentId: l.theirsRevisionId
|
|
1729
1968
|
});
|
|
1730
|
-
return
|
|
1969
|
+
return tt(n), p;
|
|
1731
1970
|
});
|
|
1732
1971
|
},
|
|
1733
1972
|
async abortMerge({ idempotencyKey: e, ...t }) {
|
|
1734
1973
|
return V(e, ["abortMerge", t], async () => {
|
|
1735
|
-
if (
|
|
1736
|
-
|
|
1974
|
+
if ($e(t.changeSetId, t.branchId), !B.has(t.branchId)) throw new _(`Branch ${t.branchId} has no Pending Merge`);
|
|
1975
|
+
tt(t.branchId);
|
|
1737
1976
|
});
|
|
1738
1977
|
},
|
|
1739
1978
|
async previewInForce({ contentId: e, changeSetId: t, validOn: n }) {
|
|
1740
|
-
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));
|
|
1741
1980
|
if (c) {
|
|
1742
1981
|
let e = c.branchId ? o?.branches.find((e) => e.id === c.branchId)?.headRevisionId ?? "" : c.revisionId;
|
|
1743
1982
|
return {
|
|
@@ -1749,7 +1988,7 @@ function M(v = {}) {
|
|
|
1749
1988
|
data: structuredClone(q(i, e) ?? {})
|
|
1750
1989
|
};
|
|
1751
1990
|
}
|
|
1752
|
-
let l =
|
|
1991
|
+
let l = te(i.timeline ?? [], a);
|
|
1753
1992
|
return l ? {
|
|
1754
1993
|
releaseId: l.releaseId,
|
|
1755
1994
|
revisionId: l.revisionId,
|
|
@@ -1760,7 +1999,8 @@ function M(v = {}) {
|
|
|
1760
1999
|
} : null;
|
|
1761
2000
|
}
|
|
1762
2001
|
};
|
|
1763
|
-
|
|
2002
|
+
return $;
|
|
2003
|
+
function dt(e, t, n) {
|
|
1764
2004
|
let r = {
|
|
1765
2005
|
id: `rls_stub_${H++}`,
|
|
1766
2006
|
contentId: e.id,
|
|
@@ -1778,10 +2018,10 @@ function M(v = {}) {
|
|
|
1778
2018
|
plannedRelease: r
|
|
1779
2019
|
}], structuredClone({
|
|
1780
2020
|
plannedRelease: r,
|
|
1781
|
-
gapReferrers:
|
|
2021
|
+
gapReferrers: We(e.id)
|
|
1782
2022
|
});
|
|
1783
2023
|
}
|
|
1784
|
-
function
|
|
2024
|
+
function ft(e, t, n) {
|
|
1785
2025
|
let r = (t, n) => ({
|
|
1786
2026
|
id: e.id,
|
|
1787
2027
|
blueprintId: e.blueprintId,
|
|
@@ -1796,33 +2036,33 @@ function M(v = {}) {
|
|
|
1796
2036
|
if (t.kind === "in_force") return e.inForce ? [r(e.inForce, { releaseId: e.inForce.releaseId })] : [];
|
|
1797
2037
|
if (t.kind === "change_set") {
|
|
1798
2038
|
let i = e.branches[t.changeSetId];
|
|
1799
|
-
return !i || n && !
|
|
2039
|
+
return !i || n && !Ee(i.data, n) ? [] : [r(i, {
|
|
1800
2040
|
changeSetId: t.changeSetId,
|
|
1801
2041
|
branchId: i.branchId
|
|
1802
2042
|
})];
|
|
1803
2043
|
}
|
|
1804
2044
|
if (!n) return e.main ? [r(e.main, {})] : [];
|
|
1805
2045
|
let i = [];
|
|
1806
|
-
e.main &&
|
|
1807
|
-
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, {
|
|
1808
2048
|
changeSetId: t,
|
|
1809
2049
|
branchId: a.branchId
|
|
1810
2050
|
}));
|
|
1811
2051
|
return i;
|
|
1812
2052
|
}
|
|
1813
2053
|
}
|
|
1814
|
-
function
|
|
2054
|
+
function Ee(e, t) {
|
|
1815
2055
|
let n = (e) => e.toLocaleLowerCase().replace(/\s+/g, " "), r = n(t);
|
|
1816
2056
|
return Object.values(e).some((e) => typeof e == "string" && n(e).includes(r));
|
|
1817
2057
|
}
|
|
1818
2058
|
//#endregion
|
|
1819
2059
|
//#region src/testing/stub-status-source.ts
|
|
1820
|
-
function
|
|
2060
|
+
function N(e = le()) {
|
|
1821
2061
|
return { async listChangeSetStatuses() {
|
|
1822
2062
|
return e.map((e) => ({ ...e }));
|
|
1823
2063
|
} };
|
|
1824
2064
|
}
|
|
1825
2065
|
//#endregion
|
|
1826
|
-
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 };
|
|
1827
2067
|
|
|
1828
2068
|
//# sourceMappingURL=testing.js.map
|