@knkcs/contenthub-ui 0.4.0 → 0.6.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 +24 -0
- package/README.md +4 -4
- package/dist/{branch-content-fields-BQG6U0yl.js → branch-content-fields-CMa-BJa2.js} +2 -2
- package/dist/{branch-content-fields-BQG6U0yl.js.map → branch-content-fields-CMa-BJa2.js.map} +1 -1
- package/dist/{content-library-DFIk09bD.js → content-library-C5MCRNY0.js} +607 -387
- package/dist/content-library-C5MCRNY0.js.map +1 -0
- package/dist/{heads-DqHmAW0n.js → heads-BT8RZ-Gs.js} +19 -13
- package/dist/heads-BT8RZ-Gs.js.map +1 -0
- package/dist/index.d.ts +616 -50
- package/dist/index.js +3957 -3173
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +226 -28
- package/dist/testing.js +873 -609
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/content-library-DFIk09bD.js.map +0 -1
- package/dist/heads-DqHmAW0n.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as e, C as t, D as n, E as r, F as i, I as a, N as o, O as s, P as c, S as l, T as u, _ as d, b as f, d as p, g as m, i as h, n as g, o as ee, p as te, r as _, s as ne, t as re, u as ie, v as ae, w as oe, x as se, y as ce } from "./heads-BT8RZ-Gs.js";
|
|
2
2
|
import { Code as v, ConnectError as y } from "@connectrpc/connect";
|
|
3
|
-
import { createHostMembers as
|
|
3
|
+
import { createHostMembers as le } from "@knkcs/anker/host";
|
|
4
4
|
//#region src/testing/fixtures.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
5
|
+
var ue = "ws_stub", b = "user_stub", x = "user_ben", S = "2026-10-01T09:00:00.000Z";
|
|
6
|
+
function C() {
|
|
7
7
|
return {
|
|
8
|
-
userId:
|
|
9
|
-
workspaceId:
|
|
10
|
-
members:
|
|
11
|
-
userId:
|
|
8
|
+
userId: b,
|
|
9
|
+
workspaceId: ue,
|
|
10
|
+
members: le([{
|
|
11
|
+
userId: b,
|
|
12
12
|
displayName: "Ada Editor",
|
|
13
13
|
email: "ada@example.com"
|
|
14
14
|
}, {
|
|
15
|
-
userId:
|
|
15
|
+
userId: x,
|
|
16
16
|
displayName: "Ben Reviewer",
|
|
17
17
|
email: "ben@example.com"
|
|
18
18
|
}])
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function de() {
|
|
22
22
|
return [{
|
|
23
23
|
id: "br_author",
|
|
24
24
|
name: "Being revised by the author",
|
|
25
|
-
createTime:
|
|
26
|
-
updateTime:
|
|
25
|
+
createTime: S,
|
|
26
|
+
updateTime: S
|
|
27
27
|
}, {
|
|
28
28
|
id: "br_embargo",
|
|
29
29
|
name: "Embargoed until publication",
|
|
30
|
-
createTime:
|
|
31
|
-
updateTime:
|
|
30
|
+
createTime: S,
|
|
31
|
+
updateTime: S
|
|
32
32
|
}];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function fe() {
|
|
35
35
|
return [
|
|
36
36
|
{
|
|
37
37
|
slug: "in_progress",
|
|
@@ -56,7 +56,7 @@ function le() {
|
|
|
56
56
|
}
|
|
57
57
|
];
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function pe() {
|
|
60
60
|
return {
|
|
61
61
|
in_progress: ["in_review", "on_hold"],
|
|
62
62
|
in_review: [
|
|
@@ -68,7 +68,7 @@ function ue() {
|
|
|
68
68
|
on_hold: ["in_progress"]
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function me() {
|
|
72
72
|
return [
|
|
73
73
|
{
|
|
74
74
|
id: "cs_bgbl_270",
|
|
@@ -78,7 +78,7 @@ function de() {
|
|
|
78
78
|
reference: "BGBl. 2026 I Nr. 270"
|
|
79
79
|
},
|
|
80
80
|
state: "open",
|
|
81
|
-
createdBy:
|
|
81
|
+
createdBy: b,
|
|
82
82
|
createTime: "2026-09-30T08:00:00.000Z",
|
|
83
83
|
chains: [{
|
|
84
84
|
id: "chain_para_1",
|
|
@@ -111,7 +111,7 @@ function de() {
|
|
|
111
111
|
}],
|
|
112
112
|
dependsOnChangeSetIds: [],
|
|
113
113
|
status: "in_progress",
|
|
114
|
-
assigneeIds: [
|
|
114
|
+
assigneeIds: [b],
|
|
115
115
|
plannedReleases: [
|
|
116
116
|
{
|
|
117
117
|
id: "rls_p1_2",
|
|
@@ -171,19 +171,19 @@ function de() {
|
|
|
171
171
|
reference: "BGBl. 2026 I Nr. 255"
|
|
172
172
|
},
|
|
173
173
|
state: "open",
|
|
174
|
-
createdBy:
|
|
174
|
+
createdBy: x,
|
|
175
175
|
createTime: "2026-09-25T08:00:00.000Z",
|
|
176
176
|
chains: [],
|
|
177
177
|
dependsOnChangeSetIds: [],
|
|
178
178
|
status: "",
|
|
179
|
-
assigneeIds: [
|
|
179
|
+
assigneeIds: [x],
|
|
180
180
|
plannedReleases: []
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
id: "cs_correction_3",
|
|
184
184
|
name: "Correction of § 3",
|
|
185
185
|
state: "published",
|
|
186
|
-
createdBy:
|
|
186
|
+
createdBy: b,
|
|
187
187
|
createTime: "2026-09-01T08:00:00.000Z",
|
|
188
188
|
closeTime: "2026-09-02T08:00:00.000Z",
|
|
189
189
|
chains: [],
|
|
@@ -194,7 +194,7 @@ function de() {
|
|
|
194
194
|
}
|
|
195
195
|
];
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function he() {
|
|
198
198
|
return [{
|
|
199
199
|
id: "rc_print",
|
|
200
200
|
name: "Druckprobe",
|
|
@@ -209,7 +209,7 @@ function fe() {
|
|
|
209
209
|
independent: !0
|
|
210
210
|
}];
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function ge() {
|
|
213
213
|
return [
|
|
214
214
|
{
|
|
215
215
|
id: "col_bgb",
|
|
@@ -237,23 +237,26 @@ function pe() {
|
|
|
237
237
|
}
|
|
238
238
|
];
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function _e() {
|
|
241
241
|
return [
|
|
242
242
|
{
|
|
243
243
|
id: "bp_commentary",
|
|
244
|
-
name: "Commentary"
|
|
244
|
+
name: "Commentary",
|
|
245
|
+
accessor: "commentary"
|
|
245
246
|
},
|
|
246
247
|
{
|
|
247
248
|
id: "bp_footnote",
|
|
248
|
-
name: "Footnote"
|
|
249
|
+
name: "Footnote",
|
|
250
|
+
accessor: "footnote"
|
|
249
251
|
},
|
|
250
252
|
{
|
|
251
253
|
id: "bp_paragraph",
|
|
252
|
-
name: "Paragraph"
|
|
254
|
+
name: "Paragraph",
|
|
255
|
+
accessor: "paragraph"
|
|
253
256
|
}
|
|
254
257
|
];
|
|
255
258
|
}
|
|
256
|
-
function
|
|
259
|
+
function ve() {
|
|
257
260
|
return [
|
|
258
261
|
{
|
|
259
262
|
id: "bpr_paragraph_2",
|
|
@@ -275,7 +278,7 @@ function he() {
|
|
|
275
278
|
}
|
|
276
279
|
];
|
|
277
280
|
}
|
|
278
|
-
function
|
|
281
|
+
function ye() {
|
|
279
282
|
let e = (e, t) => ({
|
|
280
283
|
field_type: "text",
|
|
281
284
|
config: {
|
|
@@ -311,7 +314,7 @@ function ge() {
|
|
|
311
314
|
}
|
|
312
315
|
};
|
|
313
316
|
}
|
|
314
|
-
function
|
|
317
|
+
function w() {
|
|
315
318
|
let e = "2026-09-01T08:00:00.000Z";
|
|
316
319
|
return {
|
|
317
320
|
id: "content_note_1",
|
|
@@ -341,7 +344,7 @@ function E() {
|
|
|
341
344
|
}]
|
|
342
345
|
};
|
|
343
346
|
}
|
|
344
|
-
function
|
|
347
|
+
function be() {
|
|
345
348
|
let e = "2001-11-01T08:00:00.000Z";
|
|
346
349
|
return {
|
|
347
350
|
id: "content_para_3",
|
|
@@ -372,7 +375,7 @@ function _e() {
|
|
|
372
375
|
}]
|
|
373
376
|
};
|
|
374
377
|
}
|
|
375
|
-
function
|
|
378
|
+
function xe() {
|
|
376
379
|
let e = "2026-09-01T08:00:00.000Z";
|
|
377
380
|
return [
|
|
378
381
|
{
|
|
@@ -405,7 +408,7 @@ function ve() {
|
|
|
405
408
|
blueprintId: "bp_paragraph",
|
|
406
409
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
407
410
|
collectionIds: ["col_bgb"],
|
|
408
|
-
assigneeIds: [
|
|
411
|
+
assigneeIds: [b, x],
|
|
409
412
|
main: {
|
|
410
413
|
revisionId: "rev_p1_main",
|
|
411
414
|
data: {
|
|
@@ -472,7 +475,7 @@ function ve() {
|
|
|
472
475
|
secondParentId: "",
|
|
473
476
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
474
477
|
createTime: "2026-09-30T09:00:00.000Z",
|
|
475
|
-
author:
|
|
478
|
+
author: b,
|
|
476
479
|
cause: "save",
|
|
477
480
|
branchId: "br_para_1_b",
|
|
478
481
|
changeSetId: "cs_bgbl_270",
|
|
@@ -488,7 +491,7 @@ function ve() {
|
|
|
488
491
|
secondParentId: "",
|
|
489
492
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
490
493
|
createTime: "2026-09-30T08:30:00.000Z",
|
|
491
|
-
author:
|
|
494
|
+
author: x,
|
|
492
495
|
cause: "save",
|
|
493
496
|
branchId: "br_para_1_a",
|
|
494
497
|
changeSetId: "cs_bgbl_270",
|
|
@@ -504,7 +507,7 @@ function ve() {
|
|
|
504
507
|
secondParentId: "",
|
|
505
508
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
506
509
|
createTime: e,
|
|
507
|
-
author:
|
|
510
|
+
author: b,
|
|
508
511
|
cause: "create",
|
|
509
512
|
branchId: "br_para_1_main",
|
|
510
513
|
changeSetId: "cs_correction_3"
|
|
@@ -588,7 +591,7 @@ function ve() {
|
|
|
588
591
|
blueprintId: "bp_paragraph",
|
|
589
592
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
590
593
|
collectionIds: ["col_stgb"],
|
|
591
|
-
assigneeIds: [
|
|
594
|
+
assigneeIds: [x],
|
|
592
595
|
main: {
|
|
593
596
|
revisionId: "rev_s211_main",
|
|
594
597
|
data: {
|
|
@@ -625,7 +628,7 @@ function ve() {
|
|
|
625
628
|
}
|
|
626
629
|
//#endregion
|
|
627
630
|
//#region src/testing/stub-blueprint-source.ts
|
|
628
|
-
function
|
|
631
|
+
function T(e = _e(), t = ve()) {
|
|
629
632
|
return {
|
|
630
633
|
async searchBlueprints({ query: t }) {
|
|
631
634
|
let n = t.trim().toLocaleLowerCase();
|
|
@@ -637,6 +640,9 @@ function D(e = me(), t = he()) {
|
|
|
637
640
|
async getBlueprints(t) {
|
|
638
641
|
return e.filter((e) => t.includes(e.id)).map((e) => ({ ...e }));
|
|
639
642
|
},
|
|
643
|
+
async getBlueprintsByAccessor(t) {
|
|
644
|
+
return e.filter((e) => t.includes(e.accessor)).map((e) => ({ ...e }));
|
|
645
|
+
},
|
|
640
646
|
async listReleases(e) {
|
|
641
647
|
return t.filter((t) => t.blueprintId === e).map((e) => ({ ...e }));
|
|
642
648
|
}
|
|
@@ -644,52 +650,78 @@ function D(e = me(), t = he()) {
|
|
|
644
650
|
}
|
|
645
651
|
//#endregion
|
|
646
652
|
//#region src/testing/stub-client.ts
|
|
647
|
-
function
|
|
653
|
+
function Se(e) {
|
|
654
|
+
let t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
655
|
+
return t.setUTCDate(t.getUTCDate() - 1), t.toISOString().slice(0, 10);
|
|
656
|
+
}
|
|
657
|
+
function Ce(e, t) {
|
|
648
658
|
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
649
659
|
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
650
660
|
}
|
|
651
|
-
function
|
|
661
|
+
function E(e, t, n) {
|
|
652
662
|
let r = e.trim();
|
|
653
|
-
if (r === "") throw new
|
|
654
|
-
if ([...r].length > n) throw new
|
|
655
|
-
if (/[\u0000-\u001f\u007f]/.test(r)) throw new
|
|
663
|
+
if (r === "") throw new u(`${t} is required`);
|
|
664
|
+
if ([...r].length > n) throw new u(`${t} is at most ${n} characters`);
|
|
665
|
+
if (/[\u0000-\u001f\u007f]/.test(r)) throw new u(`${t} is one line of text`);
|
|
656
666
|
return r;
|
|
657
667
|
}
|
|
658
|
-
function
|
|
659
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new
|
|
668
|
+
function we(e) {
|
|
669
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new u(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
|
|
660
670
|
return {
|
|
661
671
|
date: e.date.trim(),
|
|
662
|
-
reference:
|
|
672
|
+
reference: E(e.reference, "source.reference", 500)
|
|
663
673
|
};
|
|
664
674
|
}
|
|
665
|
-
function
|
|
675
|
+
function Te(e) {
|
|
666
676
|
let t = e.trim();
|
|
667
|
-
if (t === "") throw new
|
|
668
|
-
if ([...t].length > 200) throw new
|
|
669
|
-
if (/[\u0000-\u001f\u007f]/.test(t)) throw new
|
|
677
|
+
if (t === "") throw new u("a Block Reason needs a name");
|
|
678
|
+
if ([...t].length > 200) throw new u("a Block Reason's name is at most 200 characters");
|
|
679
|
+
if (/[\u0000-\u001f\u007f]/.test(t)) throw new u("a Block Reason's name is one line of text");
|
|
670
680
|
return t;
|
|
671
681
|
}
|
|
672
|
-
function
|
|
673
|
-
let t =
|
|
674
|
-
if (e.scope !== "branch" && e.scope !== "change_set") throw new
|
|
682
|
+
function Ee(e) {
|
|
683
|
+
let t = E(e.name, "a Required Check's name", 200);
|
|
684
|
+
if (e.scope !== "branch" && e.scope !== "change_set") throw new u("a Required Check's scope is Branch or Change Set");
|
|
675
685
|
let n = e.blueprintAccessors.map((e) => {
|
|
676
686
|
let t = e.trim();
|
|
677
|
-
if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new
|
|
687
|
+
if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new u(`"${t}" is not a Blueprint accessor`);
|
|
678
688
|
return t;
|
|
679
|
-
});
|
|
689
|
+
}), r = [...new Set(n)].sort();
|
|
690
|
+
if (e.everyBlueprint && r.length > 0) throw new u("a Required Check applies to every Blueprint or names Blueprints, not both");
|
|
691
|
+
if (!e.everyBlueprint && r.length === 0) throw new u("a Required Check names the Blueprints it applies to, or applies to every Blueprint");
|
|
680
692
|
return {
|
|
681
693
|
name: t,
|
|
682
694
|
scope: e.scope,
|
|
683
|
-
blueprintAccessors:
|
|
695
|
+
blueprintAccessors: r,
|
|
696
|
+
everyBlueprint: e.everyBlueprint,
|
|
684
697
|
independent: e.independent
|
|
685
698
|
};
|
|
686
699
|
}
|
|
687
|
-
|
|
688
|
-
|
|
700
|
+
function De(e, t) {
|
|
701
|
+
let n = [];
|
|
702
|
+
for (let r of t) {
|
|
703
|
+
let t = e.find((e) => e.accessor === r);
|
|
704
|
+
t ? t.archived && n.push({
|
|
705
|
+
accessor: r,
|
|
706
|
+
reason: "archived"
|
|
707
|
+
}) : n.push({
|
|
708
|
+
accessor: r,
|
|
709
|
+
reason: "unknown"
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
if (n.length > 0) throw new p(n);
|
|
713
|
+
}
|
|
714
|
+
var Oe = (e) => ({
|
|
715
|
+
id: e.id,
|
|
716
|
+
name: e.name,
|
|
717
|
+
accessor: e.accessor,
|
|
718
|
+
archived: e.archived ?? !1
|
|
719
|
+
}), ke = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", Ae = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it", je = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
|
|
720
|
+
function D(e, t) {
|
|
689
721
|
return new y(`${e} ${t}: not found`, v.NotFound);
|
|
690
722
|
}
|
|
691
|
-
var
|
|
692
|
-
function
|
|
723
|
+
var O = (e) => structuredClone(e);
|
|
724
|
+
function k(e, t = {}) {
|
|
693
725
|
return {
|
|
694
726
|
code: e,
|
|
695
727
|
contentId: "",
|
|
@@ -709,49 +741,55 @@ function j(e, t = {}) {
|
|
|
709
741
|
...t
|
|
710
742
|
};
|
|
711
743
|
}
|
|
712
|
-
function
|
|
713
|
-
let
|
|
714
|
-
if (
|
|
715
|
-
},
|
|
744
|
+
function A(p = {}) {
|
|
745
|
+
let v = p.now ?? (() => "2026-10-01T09:00:00.000Z"), y = p.userId ?? "user_stub", le = p.statuses ?? fe(), ue = p.statusTransitions ?? pe(), b = (p.blockReasons ?? de()).map((e) => ({ ...e })), x = (p.changeSets ?? me()).map(O), S = (p.collections ?? ge()).map((e) => ({ ...e })), C = structuredClone(p.contents ?? xe()), w = p.blueprints ?? _e(), be = p.blueprintReleases ?? ve(), T = p.resolvedReleases ?? ye(), A = structuredClone(p.requiredChecks ?? he()), j = p.authzMode ?? "guardian", Ne = new Set(p.withheld ?? []), M = (e) => {
|
|
746
|
+
if (Ne.has(e)) throw new a(Ae);
|
|
747
|
+
}, N = new Map(Object.entries(structuredClone(p.collectionGrants ?? {}))), P = new Map(Object.entries(structuredClone(p.recorders ?? {}))), Pe = (e) => P.get(e) ?? {
|
|
716
748
|
everyMember: !0,
|
|
717
749
|
userIds: []
|
|
718
|
-
},
|
|
750
|
+
}, Fe = p.memberIds ?? ["user_stub", "user_ben"], F = p.admin ?? !0, Ie = p.editingSettings ?? {
|
|
719
751
|
editingMode: "change_sets",
|
|
720
752
|
editingBlock: !1
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}),
|
|
753
|
+
}, I = structuredClone({
|
|
754
|
+
...Ie,
|
|
755
|
+
forceGroup: Ie.forceGroup ?? []
|
|
756
|
+
}), L = structuredClone(p.editingOverrides ?? []), R = (e) => ({
|
|
757
|
+
editingMode: e?.editingMode ?? I.editingMode,
|
|
758
|
+
editingBlock: e?.editingBlock ?? I.editingBlock,
|
|
759
|
+
forceGroup: [...e?.forceGroup ?? I.forceGroup]
|
|
760
|
+
}), Le = (e) => ({
|
|
725
761
|
...structuredClone(e),
|
|
726
|
-
|
|
727
|
-
|
|
762
|
+
forceGroup: e.forceGroup ?? null,
|
|
763
|
+
effective: R(e)
|
|
764
|
+
}), Re = (e) => T[e.blueprintReleaseId]?.accessor || e.blueprintId, ze = (e) => F || e.includes(y), Be = (e) => [...new Set(e.map((e) => E(e, "a user id", 200)))].sort(), Ve = [
|
|
728
765
|
"direct_edits",
|
|
729
766
|
"change_sets",
|
|
730
767
|
"both"
|
|
731
|
-
],
|
|
732
|
-
if (!
|
|
733
|
-
},
|
|
768
|
+
], He = () => {
|
|
769
|
+
if (!F) throw new ne("permission denied");
|
|
770
|
+
}, Ue = structuredClone(p.checkResults ?? []), We = p.publishBlockers ?? {}, Ge = p.pendingMerges ?? {}, Ke = structuredClone(p.conflicts ?? {}), qe = new Set(p.behind ?? []), z = /* @__PURE__ */ new Map(), Je = /* @__PURE__ */ new Map(), B = async (e, t, n) => {
|
|
734
771
|
if (!e) return n();
|
|
735
|
-
let r = JSON.stringify(t), i =
|
|
772
|
+
let r = JSON.stringify(t), i = Je.get(e);
|
|
736
773
|
if (i) {
|
|
737
|
-
if (i.asked !== r) throw new
|
|
774
|
+
if (i.asked !== r) throw new u(`idempotency key ${e} names another request`);
|
|
738
775
|
return structuredClone(i.answer);
|
|
739
776
|
}
|
|
740
777
|
let a = await n();
|
|
741
|
-
return
|
|
778
|
+
return Je.set(e, {
|
|
742
779
|
asked: r,
|
|
743
780
|
answer: structuredClone(a)
|
|
744
781
|
}), a;
|
|
745
|
-
},
|
|
746
|
-
let t =
|
|
747
|
-
if (!t) throw
|
|
782
|
+
}, Ye = /* @__PURE__ */ new Map(), Xe = /* @__PURE__ */ new Map(), V = 1, H = (e) => {
|
|
783
|
+
let t = C.find((t) => t.id === e);
|
|
784
|
+
if (!t) throw D("Content", e);
|
|
748
785
|
return t;
|
|
749
|
-
},
|
|
786
|
+
}, U = (e) => structuredClone({
|
|
750
787
|
collectionIds: [...e.collectionIds].sort(),
|
|
751
788
|
assigneeIds: e.assigneeIds ?? [],
|
|
752
789
|
block: e.block,
|
|
753
|
-
archiveTime: e.archiveTime
|
|
754
|
-
|
|
790
|
+
archiveTime: e.archiveTime,
|
|
791
|
+
editingBlock: e.editingBlock
|
|
792
|
+
}), Ze = () => v().slice(0, 10), W = (e) => T[e.blueprintReleaseId]?.dated ?? !1, G = (e) => {
|
|
755
793
|
let t = [...e.revisions ?? []], n = [...Object.entries(e.branches).map(([e, t]) => ({
|
|
756
794
|
...t,
|
|
757
795
|
changeSetId: e
|
|
@@ -767,70 +805,70 @@ function M(v = {}) {
|
|
|
767
805
|
secondParentId: "",
|
|
768
806
|
blueprintReleaseId: e.blueprintReleaseId,
|
|
769
807
|
createTime: r.revisionCreateTime,
|
|
770
|
-
author:
|
|
808
|
+
author: y,
|
|
771
809
|
cause: "create",
|
|
772
810
|
branchId: r.branchId,
|
|
773
811
|
changeSetId: r.changeSetId,
|
|
774
812
|
data: r.data
|
|
775
813
|
});
|
|
776
814
|
return t.sort((e, t) => e.createTime < t.createTime ? 1 : e.createTime > t.createTime ? -1 : 0);
|
|
777
|
-
},
|
|
815
|
+
}, K = (e, t) => [
|
|
778
816
|
e.main,
|
|
779
817
|
e.inForce,
|
|
780
818
|
...Object.values(e.branches)
|
|
781
|
-
].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data,
|
|
819
|
+
].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Qe = (e, t) => {
|
|
782
820
|
let n = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
783
821
|
return (e ?? []).filter((e) => e.config.required === !0 && n(t[e.config.api_accessor])).map((e) => e.config.api_accessor);
|
|
784
|
-
},
|
|
785
|
-
if (e.archiveTime) throw new
|
|
786
|
-
if (e.block && !e.block.allowedUserIds.includes(
|
|
787
|
-
},
|
|
822
|
+
}, q = (e) => {
|
|
823
|
+
if (e.archiveTime) throw new ae(e.id);
|
|
824
|
+
if (e.block && !e.block.allowedUserIds.includes(y)) throw new ce(e.id, e.block.blockReasonId);
|
|
825
|
+
}, $e = (e) => C.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
|
|
788
826
|
edge: { ...e },
|
|
789
827
|
releaseId: t.inForce?.releaseId ?? ""
|
|
790
|
-
}))),
|
|
791
|
-
let t =
|
|
792
|
-
if (!t) throw
|
|
828
|
+
}))), et = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), tt = (e, t) => b.some((n) => n.name === e && n.id !== t), nt = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), J = (e) => {
|
|
829
|
+
let t = S.find((t) => t.id === e);
|
|
830
|
+
if (!t) throw D("Collection", e);
|
|
793
831
|
return t;
|
|
794
|
-
},
|
|
795
|
-
if (
|
|
796
|
-
if (!
|
|
797
|
-
let
|
|
798
|
-
if (!
|
|
799
|
-
},
|
|
800
|
-
if (
|
|
801
|
-
if (!
|
|
802
|
-
if (
|
|
803
|
-
if (!
|
|
804
|
-
return
|
|
805
|
-
},
|
|
806
|
-
let
|
|
807
|
-
if (!
|
|
808
|
-
let c =
|
|
809
|
-
if (
|
|
810
|
-
if (n === "") throw new
|
|
811
|
-
if (s.headRevisionId !== n) throw new
|
|
832
|
+
}, rt = (e, t, n) => S.some((r) => r.parentId === e && r.name === t && r.id !== n), it = (t) => {
|
|
833
|
+
if (j === "workspace") throw new e(je);
|
|
834
|
+
if (!J(t).restricted) throw new u(`Collection ${t} is open: only a Restricted Collection takes grants`);
|
|
835
|
+
let n = (N.get(t) ?? []).some((e) => e.userId === y && e.level === "owner");
|
|
836
|
+
if (!F && !n) throw new ne("only its owner or a workspace admin manages its grants");
|
|
837
|
+
}, at = (e) => {
|
|
838
|
+
if (j === "workspace") throw new oe("required_check_recorders", ke);
|
|
839
|
+
if (!F) throw new ne("permission denied");
|
|
840
|
+
if (e === "") throw new u("required_check_id is required");
|
|
841
|
+
if (!A.some((t) => t.id === e)) throw D("Required Check", e);
|
|
842
|
+
return Pe(e);
|
|
843
|
+
}, ot = async ({ changeSetId: e, branchId: t, expectedHeadId: n, data: r, fieldMask: i }) => {
|
|
844
|
+
let a = X(e).chains.find((e) => e.branches.some((e) => e.id === t)), s = a?.branches.find((e) => e.id === t);
|
|
845
|
+
if (!a || !s) throw D("Branch", t);
|
|
846
|
+
let c = H(a.contentId);
|
|
847
|
+
if (q(c), z.has(t)) throw new u("a Pending Merge waits on this Branch: resolve or abort it first");
|
|
848
|
+
if (n === "") throw new u("expected_head_id is required");
|
|
849
|
+
if (s.headRevisionId !== n) throw new o({
|
|
812
850
|
contentId: c.id,
|
|
813
851
|
branchId: t,
|
|
814
852
|
expectedHeadId: n,
|
|
815
853
|
currentHeadId: s.headRevisionId
|
|
816
854
|
});
|
|
817
|
-
let l =
|
|
818
|
-
if (
|
|
819
|
-
let e = Object.keys(
|
|
820
|
-
if (e.length > 0) throw new
|
|
821
|
-
|
|
822
|
-
for (let e of
|
|
823
|
-
} else
|
|
824
|
-
return
|
|
855
|
+
let l = K(c, s.headRevisionId) ?? {}, d = JSON.parse(JSON.stringify(r)), f;
|
|
856
|
+
if (i) {
|
|
857
|
+
let e = Object.keys(d).filter((e) => !i.includes(e));
|
|
858
|
+
if (e.length > 0) throw new u(`data holds ${e.join(", ")}, which the mask doesn't name`);
|
|
859
|
+
f = structuredClone(l);
|
|
860
|
+
for (let e of i) e in d ? f[e] = d[e] : delete f[e];
|
|
861
|
+
} else f = d;
|
|
862
|
+
return st({
|
|
825
863
|
changeSetId: e,
|
|
826
|
-
chain:
|
|
864
|
+
chain: a,
|
|
827
865
|
branch: s,
|
|
828
866
|
c,
|
|
829
|
-
data:
|
|
867
|
+
data: f,
|
|
830
868
|
cause: "save"
|
|
831
869
|
});
|
|
832
|
-
},
|
|
833
|
-
let s = n.id, c = `rev_stub_${
|
|
870
|
+
}, st = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
|
|
871
|
+
let s = n.id, c = `rev_stub_${V++}`, l = v();
|
|
834
872
|
return r.revisions = [{
|
|
835
873
|
id: c,
|
|
836
874
|
contentId: r.id,
|
|
@@ -838,7 +876,7 @@ function M(v = {}) {
|
|
|
838
876
|
secondParentId: o,
|
|
839
877
|
blueprintReleaseId: r.blueprintReleaseId,
|
|
840
878
|
createTime: l,
|
|
841
|
-
author:
|
|
879
|
+
author: y,
|
|
842
880
|
cause: a,
|
|
843
881
|
branchId: s,
|
|
844
882
|
changeSetId: e,
|
|
@@ -859,17 +897,17 @@ function M(v = {}) {
|
|
|
859
897
|
revisionCreateTime: l,
|
|
860
898
|
releaseId: ""
|
|
861
899
|
};
|
|
862
|
-
},
|
|
863
|
-
let n =
|
|
864
|
-
if (!r || !i) throw
|
|
900
|
+
}, ct = (e, t) => {
|
|
901
|
+
let n = X(e), r = n.chains.find((e) => e.branches.some((e) => e.id === t)), i = r?.branches.find((e) => e.id === t);
|
|
902
|
+
if (!r || !i) throw D("Branch", t);
|
|
865
903
|
return {
|
|
866
904
|
cs: n,
|
|
867
905
|
chain: r,
|
|
868
906
|
branch: i,
|
|
869
|
-
c:
|
|
907
|
+
c: H(r.contentId)
|
|
870
908
|
};
|
|
871
|
-
},
|
|
872
|
-
for (let n of
|
|
909
|
+
}, lt = (e, t) => {
|
|
910
|
+
for (let n of x) for (let r of n.chains) {
|
|
873
911
|
let n = r.branches.find((t) => t.id === e);
|
|
874
912
|
if (!n) continue;
|
|
875
913
|
let i = {
|
|
@@ -882,37 +920,37 @@ function M(v = {}) {
|
|
|
882
920
|
fields: structuredClone(t.fields),
|
|
883
921
|
merged: structuredClone(t.merged)
|
|
884
922
|
};
|
|
885
|
-
|
|
923
|
+
z.set(e, i), n.hasPendingMerge = !0, delete Ke[e];
|
|
886
924
|
return;
|
|
887
925
|
}
|
|
888
|
-
throw
|
|
889
|
-
},
|
|
890
|
-
|
|
891
|
-
for (let t of
|
|
926
|
+
throw D("Branch", e);
|
|
927
|
+
}, ut = (e) => {
|
|
928
|
+
z.delete(e);
|
|
929
|
+
for (let t of x) for (let n of t.chains) {
|
|
892
930
|
let t = n.branches.find((t) => t.id === e);
|
|
893
931
|
t && (t.hasPendingMerge = !1);
|
|
894
932
|
}
|
|
895
|
-
},
|
|
933
|
+
}, dt = (e, t) => {
|
|
896
934
|
let n = t.validityPeriod;
|
|
897
|
-
if (
|
|
898
|
-
if (!n || !
|
|
899
|
-
if (n.lastDay !== "" && (!
|
|
900
|
-
} else if (n) throw new
|
|
901
|
-
let r =
|
|
935
|
+
if (W(e)) {
|
|
936
|
+
if (!n || !_.test(n.firstDay)) throw new u("validity_period.first_day is required for Dated Content");
|
|
937
|
+
if (n.lastDay !== "" && (!_.test(n.lastDay) || n.lastDay < n.firstDay)) throw new u("validity_period.last_day is a day on or after first_day");
|
|
938
|
+
} else if (n) throw new u("validity_period is refused for undated Content");
|
|
939
|
+
let r = Qe(T[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
|
|
902
940
|
source: "fieldkit",
|
|
903
941
|
code: "required",
|
|
904
942
|
path: `/${e}`
|
|
905
943
|
}));
|
|
906
|
-
if (r.length > 0) throw new
|
|
944
|
+
if (r.length > 0) throw new f("the Release Spec values break the Blueprint Release", r);
|
|
907
945
|
if (n && n.lastDay !== "") {
|
|
908
946
|
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);
|
|
909
|
-
if (r.length > 0) throw new
|
|
947
|
+
if (r.length > 0) throw new se(e.id, r);
|
|
910
948
|
}
|
|
911
|
-
},
|
|
949
|
+
}, ft = (e, t) => {
|
|
912
950
|
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) => {
|
|
913
951
|
let o = n.find((t) => t.proposedForReleaseId === e.releaseId && t.splitFromReleaseId === a);
|
|
914
952
|
i.push({
|
|
915
|
-
id: o?.id ?? `rls_stub_${
|
|
953
|
+
id: o?.id ?? `rls_stub_${V++}`,
|
|
916
954
|
contentId: t.id,
|
|
917
955
|
kind: "date_only",
|
|
918
956
|
branchId: "",
|
|
@@ -931,23 +969,23 @@ function M(v = {}) {
|
|
|
931
969
|
let t = r.validityPeriod;
|
|
932
970
|
t && !e.supersedesReleaseIds.includes(r.releaseId) && t.firstDay < n.firstDay && (t.lastDay === "" || t.lastDay >= n.firstDay) && (a(r, {
|
|
933
971
|
firstDay: t.firstDay,
|
|
934
|
-
lastDay:
|
|
972
|
+
lastDay: Ce(n.firstDay, -1)
|
|
935
973
|
}, ""), n.lastDay !== "" && (t.lastDay === "" || t.lastDay > n.lastDay) && a(r, {
|
|
936
|
-
firstDay:
|
|
974
|
+
firstDay: Ce(n.lastDay, 1),
|
|
937
975
|
lastDay: t.lastDay
|
|
938
976
|
}, r.releaseId));
|
|
939
977
|
}
|
|
940
978
|
}
|
|
941
979
|
e.plannedReleases = [...r, ...i];
|
|
942
|
-
},
|
|
943
|
-
let t =
|
|
944
|
-
if (!t) throw
|
|
980
|
+
}, Y = (e) => {
|
|
981
|
+
let t = x.find((t) => t.id === e);
|
|
982
|
+
if (!t) throw D("Change Set", e);
|
|
945
983
|
return t;
|
|
946
|
-
},
|
|
947
|
-
let t =
|
|
948
|
-
if (t.state !== "open") throw new
|
|
984
|
+
}, X = (e) => {
|
|
985
|
+
let t = Y(e);
|
|
986
|
+
if (t.state !== "open") throw new m(t.state);
|
|
949
987
|
return t;
|
|
950
|
-
},
|
|
988
|
+
}, pt = (e) => le.find((t) => t.slug === e)?.name ?? e, mt = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (x.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => mt(e, t, n))), ht = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
|
|
951
989
|
key: t.id,
|
|
952
990
|
branchless: !1,
|
|
953
991
|
contentId: e.contentId,
|
|
@@ -957,9 +995,12 @@ function M(v = {}) {
|
|
|
957
995
|
branchless: !0,
|
|
958
996
|
contentId: e.contentId,
|
|
959
997
|
revision: e.revisionId
|
|
960
|
-
}))],
|
|
961
|
-
let t =
|
|
962
|
-
|
|
998
|
+
}))], gt = (e) => {
|
|
999
|
+
let t = C.find((t) => t.id === e)?.blueprintId;
|
|
1000
|
+
return w.find((e) => e.id === t)?.accessor;
|
|
1001
|
+
}, _t = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes(gt(t) ?? ""), vt = (e) => {
|
|
1002
|
+
let t = ht(e), n = (t, n) => Ue.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) => {
|
|
1003
|
+
let r = n[0], i = r ? !g(r.heads, t.heads) : !1;
|
|
963
1004
|
return {
|
|
964
1005
|
check: structuredClone(e),
|
|
965
1006
|
...t,
|
|
@@ -968,8 +1009,8 @@ function M(v = {}) {
|
|
|
968
1009
|
cleared: !!r && !i && r.outcome !== "failed"
|
|
969
1010
|
};
|
|
970
1011
|
}, i = [], a = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
|
|
971
|
-
for (let e of [...
|
|
972
|
-
let a = t.filter((t) =>
|
|
1012
|
+
for (let e of [...A].sort(a)) {
|
|
1013
|
+
let a = t.filter((t) => _t(e, t.contentId));
|
|
973
1014
|
if (e.scope === "change_set") {
|
|
974
1015
|
if (a.length === 0) continue;
|
|
975
1016
|
let o = Object.fromEntries(t.map((e) => [e.key, e.revision]));
|
|
@@ -989,41 +1030,48 @@ function M(v = {}) {
|
|
|
989
1030
|
}, n(e, t.key)));
|
|
990
1031
|
}
|
|
991
1032
|
return i;
|
|
992
|
-
},
|
|
1033
|
+
}, yt = (e, t) => {
|
|
993
1034
|
let n = [], r = re(e);
|
|
994
|
-
for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(
|
|
1035
|
+
for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(k("moved_head", {
|
|
995
1036
|
contentId: r.contentId,
|
|
996
1037
|
branchId: e.id,
|
|
997
1038
|
expectedHeadId: t[e.id] ?? "",
|
|
998
1039
|
currentHeadId: e.headRevisionId
|
|
999
1040
|
}));
|
|
1000
|
-
for (let [e, i] of Object.entries(t)) e in r || n.push(
|
|
1041
|
+
for (let [e, i] of Object.entries(t)) e in r || n.push(k("moved_head", {
|
|
1001
1042
|
branchId: e,
|
|
1002
1043
|
expectedHeadId: i
|
|
1003
1044
|
}));
|
|
1045
|
+
for (let t of e.chains) for (let e of t.branches) qe.has(e.id) && n.push(k("behind_base", {
|
|
1046
|
+
contentId: t.contentId,
|
|
1047
|
+
branchId: e.id
|
|
1048
|
+
})), z.has(e.id) && n.push(k("pending_merge", {
|
|
1049
|
+
contentId: t.contentId,
|
|
1050
|
+
branchId: e.id
|
|
1051
|
+
}));
|
|
1004
1052
|
for (let t of e.dependsOnChangeSetIds) {
|
|
1005
|
-
let e =
|
|
1006
|
-
e === "open" ? n.push(
|
|
1053
|
+
let e = x.find((e) => e.id === t)?.state;
|
|
1054
|
+
e === "open" ? n.push(k("unpublished_dependency", { dependencyChangeSetId: t })) : e === "discarded" && n.push(k("discarded_dependency", { dependencyChangeSetId: t }));
|
|
1007
1055
|
}
|
|
1008
|
-
for (let t of
|
|
1056
|
+
for (let t of vt(e)) t.cleared || n.push(k("outstanding_check", {
|
|
1009
1057
|
requiredCheckId: t.check.id,
|
|
1010
1058
|
contentId: t.contentId,
|
|
1011
1059
|
branchId: t.branchId,
|
|
1012
1060
|
releaseId: t.releaseId
|
|
1013
1061
|
}));
|
|
1014
1062
|
for (let t of e.chains) {
|
|
1015
|
-
let e =
|
|
1063
|
+
let e = C.find((e) => e.id === t.contentId);
|
|
1016
1064
|
for (let r of t.branches) {
|
|
1017
|
-
let t = e &&
|
|
1018
|
-
if (e && t) for (let i of
|
|
1065
|
+
let t = e && K(e, r.headRevisionId);
|
|
1066
|
+
if (e && t) for (let i of Qe(T[e.blueprintReleaseId]?.fields, t)) n.push(k("missing_required_field", {
|
|
1019
1067
|
contentId: e.id,
|
|
1020
1068
|
revisionId: r.headRevisionId,
|
|
1021
1069
|
path: `/${i}`
|
|
1022
1070
|
}));
|
|
1023
1071
|
}
|
|
1024
1072
|
}
|
|
1025
|
-
return [...n, ...structuredClone(
|
|
1026
|
-
},
|
|
1073
|
+
return [...n, ...structuredClone(We[e.id] ?? [])];
|
|
1074
|
+
}, Z = (e) => {
|
|
1027
1075
|
let t = re(e);
|
|
1028
1076
|
return e.plannedReleases.filter((e) => !e.withheld).map((n) => ({
|
|
1029
1077
|
id: n.id,
|
|
@@ -1036,37 +1084,148 @@ function M(v = {}) {
|
|
|
1036
1084
|
validityPeriod: n.validityPeriod ? { ...n.validityPeriod } : void 0
|
|
1037
1085
|
}));
|
|
1038
1086
|
};
|
|
1039
|
-
for (let [e, t] of Object.entries(
|
|
1040
|
-
let
|
|
1087
|
+
for (let [e, t] of Object.entries(Ke)) t.pending && lt(e, t);
|
|
1088
|
+
let bt = (e, t) => {
|
|
1089
|
+
for (let n of Object.keys(e)) n in t || delete e[n];
|
|
1090
|
+
Object.assign(e, t);
|
|
1091
|
+
}, xt = (e, t) => {
|
|
1092
|
+
let n = e.chains[0], r = n?.branches[0], i = r?.effectiveOn ?? "";
|
|
1093
|
+
if (!n || !r || !i) throw new u("the Direct Edit's Content is undated: no period to plan");
|
|
1094
|
+
let a = H(n.contentId), o = a.timeline ?? [], s = o.find((e) => e.releaseId === r.carriedReleaseId), c = s?.validityPeriod && i <= e.createTime.slice(0, 10) ? s : void 0, l = c?.validityPeriod ? { ...c.validityPeriod } : {
|
|
1095
|
+
firstDay: i,
|
|
1096
|
+
lastDay: ""
|
|
1097
|
+
};
|
|
1098
|
+
if (t !== void 0) {
|
|
1099
|
+
if (t !== "" && (!_.test(t) || t < l.firstDay)) throw new u("validity_last_day is YYYY-MM-DD, not before the first day");
|
|
1100
|
+
l.lastDay = t;
|
|
1101
|
+
}
|
|
1102
|
+
let d = o.filter((e) => e.releaseId !== c?.releaseId && e.validityPeriod && l.lastDay !== "" && l.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay !== "" && e.validityPeriod.lastDay <= l.lastDay).map((e) => e.releaseId);
|
|
1103
|
+
if (d.length > 0) throw new se(a.id, d, !0);
|
|
1104
|
+
let f = [];
|
|
1105
|
+
!c && s?.validityPeriod && s.validityPeriod.firstDay < i && f.push({
|
|
1106
|
+
id: `rls_stub_${V++}`,
|
|
1107
|
+
contentId: a.id,
|
|
1108
|
+
kind: "date_only",
|
|
1109
|
+
branchId: "",
|
|
1110
|
+
revisionId: s.revisionId,
|
|
1111
|
+
validityPeriod: {
|
|
1112
|
+
firstDay: s.validityPeriod.firstDay,
|
|
1113
|
+
lastDay: Se(i)
|
|
1114
|
+
},
|
|
1115
|
+
supersedesReleaseIds: [s.releaseId],
|
|
1116
|
+
proposed: !0,
|
|
1117
|
+
proposedForReleaseId: s.releaseId,
|
|
1118
|
+
splitFromReleaseId: "",
|
|
1119
|
+
withheld: !1
|
|
1120
|
+
});
|
|
1121
|
+
let p = n.branches.slice(1).flatMap((e) => {
|
|
1122
|
+
let t = o.find((t) => t.releaseId === e.carriedReleaseId);
|
|
1123
|
+
return t ? [{
|
|
1124
|
+
releaseId: t.releaseId,
|
|
1125
|
+
validityPeriod: t.validityPeriod
|
|
1126
|
+
}] : [];
|
|
1127
|
+
});
|
|
1128
|
+
return {
|
|
1129
|
+
validityPeriod: l,
|
|
1130
|
+
correctsReleaseId: c?.releaseId ?? "",
|
|
1131
|
+
dateOnlyReleases: f,
|
|
1132
|
+
laterWordings: p
|
|
1133
|
+
};
|
|
1134
|
+
}, St = async (e, t, n, r = {}) => {
|
|
1135
|
+
let i = e.id, a = e.chains[0], o = a?.branches[0];
|
|
1136
|
+
if (!a || !o) throw Error(`Direct Edit ${i} has no Branch`);
|
|
1137
|
+
let s = !!o.effectiveOn;
|
|
1138
|
+
if (!s && (r.validityLastDay !== void 0 || (r.carryForward ?? []).length > 0)) throw new u("validity_last_day and carry_forward are for Dated Content");
|
|
1139
|
+
if (e.state === "open") {
|
|
1140
|
+
let t = s ? xt(e, r.validityLastDay) : void 0, c = e.plannedReleases.find((e) => e.branchId === o.id && !e.proposed);
|
|
1141
|
+
if (c ? (n || t) && await Q.updatePlannedRelease({
|
|
1142
|
+
changeSetId: i,
|
|
1143
|
+
plannedReleaseId: c.id,
|
|
1144
|
+
releaseSpec: n,
|
|
1145
|
+
validityPeriod: t?.validityPeriod
|
|
1146
|
+
}) : await Q.planRelease({
|
|
1147
|
+
changeSetId: i,
|
|
1148
|
+
branchId: o.id,
|
|
1149
|
+
releaseSpec: n,
|
|
1150
|
+
validityPeriod: t?.validityPeriod,
|
|
1151
|
+
supersedesReleaseIds: t?.correctsReleaseId ? [t.correctsReleaseId] : void 0
|
|
1152
|
+
}), t) {
|
|
1153
|
+
let n = new Map((r.carryForward ?? []).map((e) => [e.releaseId, e.carry])), i = t.laterWordings.filter((e) => !n.has(e.releaseId));
|
|
1154
|
+
if (i.length > 0) throw new u(`carry_forward has no answer for the later wordings ${i.map((e) => e.releaseId).join(", ")}`);
|
|
1155
|
+
e.plannedReleases.push(...t.dateOnlyReleases);
|
|
1156
|
+
for (let r of a.branches.slice(1)) {
|
|
1157
|
+
let i = t.laterWordings.find((e) => e.releaseId === r.carriedReleaseId);
|
|
1158
|
+
i && n.get(i.releaseId) && e.plannedReleases.push({
|
|
1159
|
+
id: `rls_stub_${V++}`,
|
|
1160
|
+
contentId: a.contentId,
|
|
1161
|
+
kind: "revision",
|
|
1162
|
+
branchId: r.id,
|
|
1163
|
+
revisionId: "",
|
|
1164
|
+
validityPeriod: i.validityPeriod,
|
|
1165
|
+
supersedesReleaseIds: [i.releaseId],
|
|
1166
|
+
proposed: !0,
|
|
1167
|
+
proposedForReleaseId: i.releaseId,
|
|
1168
|
+
splitFromReleaseId: "",
|
|
1169
|
+
withheld: !1
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
let c = await Q.publish({
|
|
1175
|
+
id: i,
|
|
1176
|
+
reviewedHeads: {
|
|
1177
|
+
...re(e),
|
|
1178
|
+
[o.id]: t
|
|
1179
|
+
}
|
|
1180
|
+
}), l = H(a.contentId);
|
|
1181
|
+
l.editingBlock?.changeSetId === i && (l.editingBlock = void 0);
|
|
1182
|
+
let d = l.branches[i], f = c.releases.find((e) => e.branchId === o.id), p = a.branches.length > 1;
|
|
1183
|
+
if (d && f && !p && l.main?.revisionId !== d.revisionId) {
|
|
1184
|
+
let { branchId: e, ...t } = structuredClone(d);
|
|
1185
|
+
l.main = t, l.inForce = {
|
|
1186
|
+
...structuredClone(t),
|
|
1187
|
+
releaseId: f.id
|
|
1188
|
+
}, l.timeline = [...l.timeline ?? [], {
|
|
1189
|
+
ordinal: (l.timeline?.length ?? 0) + 1,
|
|
1190
|
+
releaseId: f.id,
|
|
1191
|
+
kind: "revision",
|
|
1192
|
+
revisionId: d.revisionId,
|
|
1193
|
+
blueprintReleaseId: l.blueprintReleaseId,
|
|
1194
|
+
publishTime: c.publishTime,
|
|
1195
|
+
first: !1
|
|
1196
|
+
}];
|
|
1197
|
+
}
|
|
1198
|
+
return c;
|
|
1199
|
+
}, Q = {
|
|
1041
1200
|
async listBlockReasons() {
|
|
1042
|
-
return [...
|
|
1201
|
+
return [...b].sort(et).map((e) => ({ ...e }));
|
|
1043
1202
|
},
|
|
1044
1203
|
async createBlockReason({ name: e }) {
|
|
1045
|
-
let t =
|
|
1046
|
-
if (
|
|
1204
|
+
let t = Te(e);
|
|
1205
|
+
if (tt(t)) throw new ie(t);
|
|
1047
1206
|
let n = {
|
|
1048
|
-
id: `br_stub_${
|
|
1207
|
+
id: `br_stub_${V++}`,
|
|
1049
1208
|
name: t,
|
|
1050
|
-
createTime:
|
|
1051
|
-
updateTime:
|
|
1209
|
+
createTime: v(),
|
|
1210
|
+
updateTime: v()
|
|
1052
1211
|
};
|
|
1053
|
-
return
|
|
1212
|
+
return b.push(n), { ...n };
|
|
1054
1213
|
},
|
|
1055
1214
|
async renameBlockReason({ id: e, name: t }) {
|
|
1056
|
-
let n =
|
|
1057
|
-
if (!r) throw
|
|
1058
|
-
if (
|
|
1059
|
-
return r.name = n, r.updateTime =
|
|
1215
|
+
let n = Te(t), r = b.find((t) => t.id === e);
|
|
1216
|
+
if (!r) throw D("Block Reason", e);
|
|
1217
|
+
if (tt(n, e)) throw new ie(n);
|
|
1218
|
+
return r.name = n, r.updateTime = v(), { ...r };
|
|
1060
1219
|
},
|
|
1061
1220
|
async deleteBlockReason({ id: e }) {
|
|
1062
|
-
if (!
|
|
1063
|
-
|
|
1221
|
+
if (!b.some((t) => t.id === e)) throw D("Block Reason", e);
|
|
1222
|
+
b = b.filter((t) => t.id !== e);
|
|
1064
1223
|
},
|
|
1065
1224
|
async listChangeSets(e = {}) {
|
|
1066
|
-
let t =
|
|
1225
|
+
let t = x.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;
|
|
1067
1226
|
return {
|
|
1068
1227
|
changeSets: t.slice(r, r + n).map((e) => ({
|
|
1069
|
-
...
|
|
1228
|
+
...O(e),
|
|
1070
1229
|
chains: [],
|
|
1071
1230
|
dependsOnChangeSetIds: [],
|
|
1072
1231
|
plannedReleases: []
|
|
@@ -1075,115 +1234,115 @@ function M(v = {}) {
|
|
|
1075
1234
|
};
|
|
1076
1235
|
},
|
|
1077
1236
|
async createChangeSet({ name: e, source: t }) {
|
|
1078
|
-
let n =
|
|
1079
|
-
id: `cs_stub_${
|
|
1237
|
+
let n = E(e, "name", 200), r = t ? we(t) : void 0, i = {
|
|
1238
|
+
id: `cs_stub_${V++}`,
|
|
1080
1239
|
name: n,
|
|
1081
1240
|
source: r,
|
|
1082
1241
|
state: "open",
|
|
1083
|
-
createdBy:
|
|
1084
|
-
createTime:
|
|
1242
|
+
createdBy: y,
|
|
1243
|
+
createTime: v(),
|
|
1085
1244
|
chains: [],
|
|
1086
1245
|
dependsOnChangeSetIds: [],
|
|
1087
1246
|
status: "",
|
|
1088
1247
|
assigneeIds: [],
|
|
1089
1248
|
plannedReleases: []
|
|
1090
1249
|
};
|
|
1091
|
-
return
|
|
1250
|
+
return x.unshift(i), O(i);
|
|
1092
1251
|
},
|
|
1093
1252
|
async getChangeSet(e) {
|
|
1094
|
-
return
|
|
1253
|
+
return O(Y(e));
|
|
1095
1254
|
},
|
|
1096
1255
|
async updateChangeSet({ id: e, updateMask: t, name: n, source: r }) {
|
|
1097
|
-
let i =
|
|
1098
|
-
if (t.length === 0) throw new
|
|
1099
|
-
let a = t.includes("name") ?
|
|
1100
|
-
return t.includes("source") && (o = r ?
|
|
1256
|
+
let i = X(e);
|
|
1257
|
+
if (t.length === 0) throw new u("update_mask is required");
|
|
1258
|
+
let a = t.includes("name") ? E(n ?? "", "name", 200) : i.name, o = i.source;
|
|
1259
|
+
return t.includes("source") && (o = r ? we(r) : void 0), i.name = a, i.source = o, O(i);
|
|
1101
1260
|
},
|
|
1102
1261
|
async setChangeSetStatus({ id: e, expectedStatus: t, status: n }) {
|
|
1103
|
-
let r =
|
|
1104
|
-
if (r.status !== t) throw new
|
|
1105
|
-
if (r.status === n) return
|
|
1106
|
-
if (!
|
|
1107
|
-
if (
|
|
1262
|
+
let r = X(e);
|
|
1263
|
+
if (r.status !== t) throw new c(r.status);
|
|
1264
|
+
if (r.status === n) return O(r);
|
|
1265
|
+
if (!le.some((e) => e.slug === n)) throw new u(`status "${n}" is not in the workspace's catalogue`);
|
|
1266
|
+
if (le.some((e) => e.slug === r.status) && !(ue[r.status] ?? []).includes(n)) throw new i({
|
|
1108
1267
|
fromStatus: r.status,
|
|
1109
1268
|
toStatus: n,
|
|
1110
|
-
reason: `There is no transition from ${
|
|
1269
|
+
reason: `There is no transition from ${pt(r.status)} to ${pt(n)}.`,
|
|
1111
1270
|
requiresPermission: !1
|
|
1112
1271
|
});
|
|
1113
|
-
return r.status = n,
|
|
1272
|
+
return r.status = n, O(r);
|
|
1114
1273
|
},
|
|
1115
1274
|
async setChangeSetAssignees({ id: e, assigneeIds: t }) {
|
|
1116
|
-
let n =
|
|
1117
|
-
if (new Set(t).size !== t.length) throw new
|
|
1118
|
-
if (t.length > 50) throw new
|
|
1119
|
-
return n.assigneeIds = [...t],
|
|
1275
|
+
let n = Y(e);
|
|
1276
|
+
if (new Set(t).size !== t.length) throw new u("each assignee is given once");
|
|
1277
|
+
if (t.length > 50) throw new u("at most 50 assignees");
|
|
1278
|
+
return n.assigneeIds = [...t], O(n);
|
|
1120
1279
|
},
|
|
1121
1280
|
async addDependency({ id: e, dependsOnId: t }) {
|
|
1122
|
-
let n =
|
|
1123
|
-
if (r.state !== "open") throw new
|
|
1124
|
-
if (
|
|
1125
|
-
return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t),
|
|
1281
|
+
let n = X(e), r = Y(t);
|
|
1282
|
+
if (r.state !== "open") throw new u(`Change Set ${t} is ${r.state}`);
|
|
1283
|
+
if (mt(t, e)) throw new u("the dependency would close a cycle");
|
|
1284
|
+
return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t), O(n);
|
|
1126
1285
|
},
|
|
1127
1286
|
async removeDependency({ id: e, dependsOnId: t }) {
|
|
1128
|
-
let n =
|
|
1129
|
-
if (!n.dependsOnChangeSetIds.includes(t)) throw
|
|
1130
|
-
return n.dependsOnChangeSetIds = n.dependsOnChangeSetIds.filter((e) => e !== t),
|
|
1287
|
+
let n = X(e);
|
|
1288
|
+
if (!n.dependsOnChangeSetIds.includes(t)) throw D(`dependency of Change Set ${e} on`, t);
|
|
1289
|
+
return n.dependsOnChangeSetIds = n.dependsOnChangeSetIds.filter((e) => e !== t), O(n);
|
|
1131
1290
|
},
|
|
1132
1291
|
async validatePublish({ id: e, reviewedHeads: t }) {
|
|
1133
|
-
let n =
|
|
1134
|
-
|
|
1135
|
-
let r =
|
|
1136
|
-
if (r &&
|
|
1292
|
+
let n = Y(e);
|
|
1293
|
+
M(e);
|
|
1294
|
+
let r = Ye.get(e);
|
|
1295
|
+
if (r && g(r, t)) return {
|
|
1137
1296
|
blockers: [],
|
|
1138
|
-
releases:
|
|
1297
|
+
releases: Z(n),
|
|
1139
1298
|
published: !0
|
|
1140
1299
|
};
|
|
1141
|
-
if (n.state !== "open") throw new
|
|
1300
|
+
if (n.state !== "open") throw new m(n.state);
|
|
1142
1301
|
return {
|
|
1143
|
-
blockers:
|
|
1144
|
-
releases:
|
|
1302
|
+
blockers: yt(n, t),
|
|
1303
|
+
releases: Z(n),
|
|
1145
1304
|
published: !1
|
|
1146
1305
|
};
|
|
1147
1306
|
},
|
|
1148
|
-
async publish({ id: e, reviewedHeads:
|
|
1149
|
-
let
|
|
1150
|
-
|
|
1151
|
-
let
|
|
1152
|
-
if (
|
|
1153
|
-
changeSet:
|
|
1154
|
-
publishTime:
|
|
1155
|
-
releases:
|
|
1307
|
+
async publish({ id: e, reviewedHeads: t }) {
|
|
1308
|
+
let n = Y(e);
|
|
1309
|
+
M(e);
|
|
1310
|
+
let r = Ye.get(e);
|
|
1311
|
+
if (r && g(r, t)) return {
|
|
1312
|
+
changeSet: O(n),
|
|
1313
|
+
publishTime: n.closeTime ?? v(),
|
|
1314
|
+
releases: Z(n)
|
|
1156
1315
|
};
|
|
1157
|
-
if (
|
|
1158
|
-
let
|
|
1159
|
-
if (
|
|
1160
|
-
let
|
|
1161
|
-
return
|
|
1162
|
-
changeSet:
|
|
1163
|
-
publishTime:
|
|
1164
|
-
releases:
|
|
1316
|
+
if (n.state !== "open") throw new m(n.state);
|
|
1317
|
+
let i = yt(n, t);
|
|
1318
|
+
if (i.length > 0) throw new s(i);
|
|
1319
|
+
let a = Z(n);
|
|
1320
|
+
return n.state = "published", n.closeTime = v(), Ye.set(e, { ...t }), {
|
|
1321
|
+
changeSet: O(n),
|
|
1322
|
+
publishTime: n.closeTime,
|
|
1323
|
+
releases: a
|
|
1165
1324
|
};
|
|
1166
1325
|
},
|
|
1167
1326
|
async changeValidity({ releaseId: e, validityPeriod: n, changeSetName: r, idempotencyKey: i }) {
|
|
1168
|
-
return
|
|
1327
|
+
return B(i, [
|
|
1169
1328
|
"changeValidity",
|
|
1170
1329
|
e,
|
|
1171
1330
|
n,
|
|
1172
1331
|
r
|
|
1173
1332
|
], async () => {
|
|
1174
|
-
let i =
|
|
1175
|
-
if (!i) throw
|
|
1176
|
-
|
|
1333
|
+
let i = C.find((t) => (t.timeline ?? []).some((t) => t.releaseId === e));
|
|
1334
|
+
if (!i) throw D("Release", e);
|
|
1335
|
+
q(i);
|
|
1177
1336
|
let a = i.timeline ?? [], o = a.find((t) => t.releaseId === e);
|
|
1178
|
-
if (!o?.validityPeriod || !
|
|
1337
|
+
if (!o?.validityPeriod || !W(i)) throw new u("undated Releases carry no Validity Period");
|
|
1179
1338
|
let { firstDay: c, lastDay: l = "" } = n;
|
|
1180
|
-
if (!
|
|
1181
|
-
let d =
|
|
1182
|
-
if (
|
|
1339
|
+
if (!_.test(c) || l !== "" && (!_.test(l) || l < c)) throw new u("validity_period is YYYY-MM-DD, the last day not before the first");
|
|
1340
|
+
let d = T[i.blueprintReleaseId]?.accessor ?? "", f = L.find((e) => e.blueprintAccessor === d);
|
|
1341
|
+
if (R(f).editingMode === "change_sets") throw new t(i.id, d);
|
|
1183
1342
|
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
|
|
1185
|
-
let
|
|
1186
|
-
id: `rls_stub_${
|
|
1343
|
+
if (p.length > 0) throw new se(i.id, p, !0);
|
|
1344
|
+
let m = {
|
|
1345
|
+
id: `rls_stub_${V++}`,
|
|
1187
1346
|
contentId: i.id,
|
|
1188
1347
|
kind: "date_only",
|
|
1189
1348
|
branchId: "",
|
|
@@ -1197,57 +1356,69 @@ function M(v = {}) {
|
|
|
1197
1356
|
proposedForReleaseId: "",
|
|
1198
1357
|
splitFromReleaseId: "",
|
|
1199
1358
|
withheld: !1
|
|
1200
|
-
},
|
|
1201
|
-
id: `cs_stub_${
|
|
1359
|
+
}, h = {
|
|
1360
|
+
id: `cs_stub_${V++}`,
|
|
1202
1361
|
name: r?.trim() || `Change of validity of ${i.id}`,
|
|
1203
1362
|
state: "open",
|
|
1204
|
-
createdBy:
|
|
1205
|
-
createTime:
|
|
1363
|
+
createdBy: y,
|
|
1364
|
+
createTime: v(),
|
|
1206
1365
|
chains: [],
|
|
1207
1366
|
dependsOnChangeSetIds: [],
|
|
1208
1367
|
status: "",
|
|
1209
1368
|
assigneeIds: [],
|
|
1210
|
-
plannedReleases: [
|
|
1211
|
-
},
|
|
1212
|
-
if (
|
|
1213
|
-
let
|
|
1214
|
-
return
|
|
1369
|
+
plannedReleases: [m]
|
|
1370
|
+
}, g = yt(h, {});
|
|
1371
|
+
if (g.length > 0) throw new s(g);
|
|
1372
|
+
let ee = Z(h);
|
|
1373
|
+
return h.state = "published", h.closeTime = v(), x.unshift(h), Ye.set(h.id, {}), i.timeline = a.map((t) => t.releaseId === e ? {
|
|
1215
1374
|
...t,
|
|
1216
|
-
releaseId:
|
|
1375
|
+
releaseId: m.id,
|
|
1217
1376
|
kind: "date_only",
|
|
1218
1377
|
validityPeriod: {
|
|
1219
1378
|
firstDay: c,
|
|
1220
1379
|
lastDay: l
|
|
1221
1380
|
},
|
|
1222
|
-
publishTime:
|
|
1381
|
+
publishTime: h.closeTime ?? v()
|
|
1223
1382
|
} : t), {
|
|
1224
|
-
changeSet:
|
|
1225
|
-
publishTime:
|
|
1226
|
-
releases:
|
|
1383
|
+
changeSet: O(h),
|
|
1384
|
+
publishTime: h.closeTime,
|
|
1385
|
+
releases: ee
|
|
1227
1386
|
};
|
|
1228
1387
|
});
|
|
1229
1388
|
},
|
|
1230
1389
|
async updateFromMain({ id: e, chainId: t, idempotencyKey: n }) {
|
|
1231
|
-
return
|
|
1390
|
+
return B(n, [
|
|
1232
1391
|
"updateFromMain",
|
|
1233
1392
|
e,
|
|
1234
1393
|
t
|
|
1235
1394
|
], async () => {
|
|
1236
|
-
let n =
|
|
1237
|
-
t ||
|
|
1395
|
+
let n = X(e);
|
|
1396
|
+
t || M(e);
|
|
1238
1397
|
let r = t ? n.chains.filter((e) => e.id === t) : n.chains;
|
|
1239
|
-
if (t && r.length === 0) throw
|
|
1240
|
-
let i = structuredClone(
|
|
1241
|
-
for (let
|
|
1242
|
-
let
|
|
1243
|
-
branchId:
|
|
1244
|
-
contentId:
|
|
1245
|
-
},
|
|
1246
|
-
|
|
1398
|
+
if (t && r.length === 0) throw D("Chain", t);
|
|
1399
|
+
let i = structuredClone(Ge[e] ?? []), a = [], o = [];
|
|
1400
|
+
for (let t of r) for (let n of t.branches) {
|
|
1401
|
+
let r = {
|
|
1402
|
+
branchId: n.id,
|
|
1403
|
+
contentId: t.contentId
|
|
1404
|
+
}, s = Ke[n.id];
|
|
1405
|
+
if (z.has(n.id)) a.push(r);
|
|
1406
|
+
else if (s) lt(n.id, s), i.push(r);
|
|
1407
|
+
else if (qe.has(n.id)) {
|
|
1408
|
+
let r = H(t.contentId);
|
|
1409
|
+
st({
|
|
1410
|
+
changeSetId: e,
|
|
1411
|
+
chain: t,
|
|
1412
|
+
branch: n,
|
|
1413
|
+
c: r,
|
|
1414
|
+
data: structuredClone(K(r, n.headRevisionId) ?? {}),
|
|
1415
|
+
cause: "merge"
|
|
1416
|
+
}), qe.delete(n.id), o.push(n.id);
|
|
1417
|
+
}
|
|
1247
1418
|
}
|
|
1248
1419
|
return {
|
|
1249
|
-
changeSet:
|
|
1250
|
-
mergedBranchIds:
|
|
1420
|
+
changeSet: O(n),
|
|
1421
|
+
mergedBranchIds: o,
|
|
1251
1422
|
conflicted: i,
|
|
1252
1423
|
pending: a,
|
|
1253
1424
|
endedBranchIds: []
|
|
@@ -1255,27 +1426,27 @@ function M(v = {}) {
|
|
|
1255
1426
|
});
|
|
1256
1427
|
},
|
|
1257
1428
|
async discardChangeSet(e) {
|
|
1258
|
-
let t =
|
|
1259
|
-
return
|
|
1429
|
+
let t = X(e);
|
|
1430
|
+
return M(e), t.state = "discarded", t.closeTime = v(), t.chains = [], O(t);
|
|
1260
1431
|
},
|
|
1261
1432
|
async listCheckResults(e) {
|
|
1262
|
-
return
|
|
1263
|
-
},
|
|
1264
|
-
async recordCheckResult({ changeSetId: e, requiredCheckId: t, heads: n, outcome: r, note:
|
|
1265
|
-
let
|
|
1266
|
-
if (r === "waived" &&
|
|
1267
|
-
if ([...
|
|
1268
|
-
let s =
|
|
1269
|
-
if (!s) throw
|
|
1270
|
-
let c =
|
|
1271
|
-
if (
|
|
1272
|
-
let l =
|
|
1273
|
-
if (s.scope === "branch" &&
|
|
1274
|
-
if (s.scope === "change_set" &&
|
|
1275
|
-
for (let e of
|
|
1433
|
+
return vt(Y(e));
|
|
1434
|
+
},
|
|
1435
|
+
async recordCheckResult({ changeSetId: e, requiredCheckId: t, heads: n, outcome: r, note: i }) {
|
|
1436
|
+
let a = X(e);
|
|
1437
|
+
if (r === "waived" && i.trim() === "") throw new u("a waived result needs a note saying why");
|
|
1438
|
+
if ([...i].length > 2e3) throw new u(`a note is at most ${te} characters`);
|
|
1439
|
+
let s = A.find((e) => e.id === t);
|
|
1440
|
+
if (!s) throw D("Required Check", t);
|
|
1441
|
+
let c = Pe(t);
|
|
1442
|
+
if (j === "guardian" && !c.everyMember && !c.userIds.includes(y)) throw new d(`recording results of Required Check ${t} needs its recorder relation`);
|
|
1443
|
+
let l = ht(a), f = Object.keys(n);
|
|
1444
|
+
if (s.scope === "branch" && f.length !== 1) throw new u("a Branch-scope result names one head");
|
|
1445
|
+
if (s.scope === "change_set" && f.length !== l.length) throw new u("a Change Set-scope result names every head of the Change Set");
|
|
1446
|
+
for (let e of f) {
|
|
1276
1447
|
let t = l.find((t) => t.key === e);
|
|
1277
|
-
if (!t) throw new
|
|
1278
|
-
if (t.revision !== n[e]) throw new
|
|
1448
|
+
if (!t) throw new u(`heads name ${e}, which this Change Set doesn't hold`);
|
|
1449
|
+
if (t.revision !== n[e]) throw new o({
|
|
1279
1450
|
contentId: t.contentId,
|
|
1280
1451
|
branchId: t.branchless ? "" : t.key,
|
|
1281
1452
|
expectedHeadId: n[e],
|
|
@@ -1283,99 +1454,106 @@ function M(v = {}) {
|
|
|
1283
1454
|
});
|
|
1284
1455
|
}
|
|
1285
1456
|
let p = {
|
|
1286
|
-
id: `cr_stub_${
|
|
1457
|
+
id: `cr_stub_${V++}`,
|
|
1287
1458
|
requiredCheckId: t,
|
|
1288
1459
|
heads: { ...n },
|
|
1289
1460
|
outcome: r,
|
|
1290
|
-
note:
|
|
1291
|
-
recordedBy:
|
|
1292
|
-
recordTime:
|
|
1461
|
+
note: i,
|
|
1462
|
+
recordedBy: y,
|
|
1463
|
+
recordTime: v()
|
|
1293
1464
|
};
|
|
1294
|
-
return
|
|
1465
|
+
return Ue.push({
|
|
1295
1466
|
...p,
|
|
1296
1467
|
changeSetId: e
|
|
1297
1468
|
}), structuredClone(p);
|
|
1298
1469
|
},
|
|
1299
1470
|
async getEditingSettings() {
|
|
1300
|
-
let e = [...
|
|
1471
|
+
let e = [...L].sort((e, t) => e.blueprintAccessor < t.blueprintAccessor ? -1 : 1);
|
|
1301
1472
|
return {
|
|
1302
|
-
workspace:
|
|
1303
|
-
overrides: e.map(
|
|
1473
|
+
workspace: structuredClone(I),
|
|
1474
|
+
overrides: e.map(Le)
|
|
1304
1475
|
};
|
|
1305
1476
|
},
|
|
1306
1477
|
async getEffectiveEditingSettings(e) {
|
|
1307
|
-
let t =
|
|
1478
|
+
let t = L.find((t) => t.blueprintAccessor === e.trim());
|
|
1308
1479
|
return {
|
|
1309
|
-
effective:
|
|
1480
|
+
effective: R(t),
|
|
1310
1481
|
editingModeOverridden: (t?.editingMode ?? null) !== null,
|
|
1311
|
-
editingBlockOverridden: (t?.editingBlock ?? null) !== null
|
|
1482
|
+
editingBlockOverridden: (t?.editingBlock ?? null) !== null,
|
|
1483
|
+
forceGroupOverridden: (t?.forceGroup ?? null) !== null,
|
|
1484
|
+
callerInForceGroup: ze(R(t).forceGroup)
|
|
1312
1485
|
};
|
|
1313
1486
|
},
|
|
1314
1487
|
async setEditingSettings(e) {
|
|
1315
|
-
if (
|
|
1316
|
-
return
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1488
|
+
if (He(), !Ve.includes(e.editingMode)) throw new u("the workspace's editing settings need an Editing Mode");
|
|
1489
|
+
return I = {
|
|
1490
|
+
...e,
|
|
1491
|
+
forceGroup: Be(e.forceGroup)
|
|
1492
|
+
}, structuredClone(I);
|
|
1493
|
+
},
|
|
1494
|
+
async setBlueprintEditingOverride({ blueprintAccessor: e, editingMode: t, editingBlock: n, forceGroup: r }) {
|
|
1495
|
+
He();
|
|
1496
|
+
let i = E(e, "a Blueprint accessor", 200);
|
|
1497
|
+
if (t === null && n === null && r === null) throw new u(`an override of "${i}" sets the Editing Mode, the Editing Block, the Force Group or several`);
|
|
1498
|
+
L.some((e) => e.blueprintAccessor === i) || De(w, [i]);
|
|
1499
|
+
let a = {
|
|
1500
|
+
blueprintAccessor: i,
|
|
1324
1501
|
editingMode: t,
|
|
1325
|
-
editingBlock: n
|
|
1502
|
+
editingBlock: n,
|
|
1503
|
+
forceGroup: r === null ? null : Be(r)
|
|
1326
1504
|
};
|
|
1327
|
-
return
|
|
1505
|
+
return L = [...L.filter((e) => e.blueprintAccessor !== i), a], Le(a);
|
|
1328
1506
|
},
|
|
1329
1507
|
async deleteBlueprintEditingOverride({ blueprintAccessor: e }) {
|
|
1330
|
-
|
|
1508
|
+
He();
|
|
1331
1509
|
let t = e.trim();
|
|
1332
|
-
if (!
|
|
1333
|
-
|
|
1510
|
+
if (!L.some((e) => e.blueprintAccessor === t)) throw D("an editing override of", t);
|
|
1511
|
+
L = L.filter((e) => e.blueprintAccessor !== t);
|
|
1334
1512
|
},
|
|
1335
1513
|
async listRequiredChecks() {
|
|
1336
1514
|
let e = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
|
|
1337
|
-
return structuredClone([...
|
|
1515
|
+
return structuredClone([...A].sort(e));
|
|
1338
1516
|
},
|
|
1339
1517
|
async createRequiredCheck(e) {
|
|
1340
|
-
let t =
|
|
1341
|
-
if (
|
|
1342
|
-
let
|
|
1343
|
-
id: `rc_stub_${
|
|
1344
|
-
...
|
|
1518
|
+
let { everyBlueprint: t, ...r } = Ee(e);
|
|
1519
|
+
if (De(w, r.blueprintAccessors), A.some((e) => e.name === r.name)) throw new n(r.name);
|
|
1520
|
+
let i = {
|
|
1521
|
+
id: `rc_stub_${V++}`,
|
|
1522
|
+
...r
|
|
1345
1523
|
};
|
|
1346
|
-
return
|
|
1524
|
+
return A.push(i), structuredClone(i);
|
|
1347
1525
|
},
|
|
1348
1526
|
async updateRequiredCheck({ id: e, ...t }) {
|
|
1349
|
-
let r =
|
|
1350
|
-
if (!
|
|
1351
|
-
if (
|
|
1352
|
-
return Object.assign(
|
|
1527
|
+
let { everyBlueprint: r, ...i } = Ee(t), a = A.find((t) => t.id === e);
|
|
1528
|
+
if (!a) throw D("Required Check", e);
|
|
1529
|
+
if (De(w, i.blueprintAccessors.filter((e) => !a.blueprintAccessors.includes(e))), A.some((t) => t.name === i.name && t.id !== e)) throw new n(i.name);
|
|
1530
|
+
return Object.assign(a, i), structuredClone(a);
|
|
1353
1531
|
},
|
|
1354
1532
|
async deleteRequiredCheck({ id: e }) {
|
|
1355
|
-
if (!
|
|
1356
|
-
|
|
1533
|
+
if (!A.some((t) => t.id === e)) throw D("Required Check", e);
|
|
1534
|
+
A = A.filter((t) => t.id !== e), P.delete(e);
|
|
1357
1535
|
},
|
|
1358
1536
|
async listRequiredCheckRecorders(e) {
|
|
1359
|
-
return structuredClone(
|
|
1537
|
+
return structuredClone(at(e));
|
|
1360
1538
|
},
|
|
1361
1539
|
async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1362
|
-
let n =
|
|
1540
|
+
let n = at(e);
|
|
1363
1541
|
if ("everyMember" in t) {
|
|
1364
|
-
|
|
1542
|
+
P.set(e, {
|
|
1365
1543
|
...n,
|
|
1366
1544
|
everyMember: !0
|
|
1367
1545
|
});
|
|
1368
1546
|
return;
|
|
1369
1547
|
}
|
|
1370
|
-
if (!
|
|
1371
|
-
|
|
1548
|
+
if (!Fe.includes(t.userId)) throw new u(`user ${t.userId} is not a member of the workspace`);
|
|
1549
|
+
P.set(e, {
|
|
1372
1550
|
...n,
|
|
1373
1551
|
userIds: [.../* @__PURE__ */ new Set([...n.userIds, t.userId])].sort()
|
|
1374
1552
|
});
|
|
1375
1553
|
},
|
|
1376
1554
|
async revokeRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1377
|
-
let n =
|
|
1378
|
-
|
|
1555
|
+
let n = at(e);
|
|
1556
|
+
P.set(e, "everyMember" in t ? {
|
|
1379
1557
|
...n,
|
|
1380
1558
|
everyMember: !1
|
|
1381
1559
|
} : {
|
|
@@ -1383,25 +1561,23 @@ function M(v = {}) {
|
|
|
1383
1561
|
userIds: n.userIds.filter((e) => e !== t.userId)
|
|
1384
1562
|
});
|
|
1385
1563
|
},
|
|
1386
|
-
async searchBlueprints({ query: e }) {
|
|
1387
|
-
let
|
|
1564
|
+
async searchBlueprints({ query: e, includeWithoutRelease: t = !1 }) {
|
|
1565
|
+
let n = e.trim().toLocaleLowerCase();
|
|
1388
1566
|
return {
|
|
1389
|
-
blueprints:
|
|
1390
|
-
id: e.id,
|
|
1391
|
-
name: e.name
|
|
1392
|
-
})),
|
|
1567
|
+
blueprints: w.filter((e) => !e.archived).filter((e) => e.name.toLocaleLowerCase().includes(n) || e.accessor.toLocaleLowerCase().includes(n)).filter((e) => t || be.some((t) => t.blueprintId === e.id)).sort((e, t) => e.accessor < t.accessor ? -1 : 1).map(Oe),
|
|
1393
1568
|
nextPageToken: ""
|
|
1394
1569
|
};
|
|
1395
1570
|
},
|
|
1396
1571
|
async getBlueprints(e) {
|
|
1397
|
-
if (e.length > 1e3) throw new
|
|
1398
|
-
return
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
})
|
|
1572
|
+
if (e.length > 1e3) throw new u(`at most ${r} Blueprint ids`);
|
|
1573
|
+
return w.filter((t) => e.includes(t.id)).map(Oe);
|
|
1574
|
+
},
|
|
1575
|
+
async getBlueprintsByAccessor(e) {
|
|
1576
|
+
if (e.length > 1e3) throw new u(`at most ${r} Blueprint accessors`);
|
|
1577
|
+
return w.filter((t) => e.includes(t.accessor)).map(Oe);
|
|
1402
1578
|
},
|
|
1403
1579
|
async listBlueprintReleases(e) {
|
|
1404
|
-
return
|
|
1580
|
+
return be.filter((t) => t.blueprintId === e).map((e) => ({
|
|
1405
1581
|
id: e.id,
|
|
1406
1582
|
blueprintId: e.blueprintId,
|
|
1407
1583
|
name: e.name ?? e.id,
|
|
@@ -1410,94 +1586,94 @@ function M(v = {}) {
|
|
|
1410
1586
|
}));
|
|
1411
1587
|
},
|
|
1412
1588
|
async listCollections() {
|
|
1413
|
-
return [...
|
|
1414
|
-
},
|
|
1415
|
-
async createCollection({ name:
|
|
1416
|
-
let
|
|
1417
|
-
if (
|
|
1418
|
-
if (
|
|
1419
|
-
let
|
|
1420
|
-
id: `col_stub_${
|
|
1421
|
-
name:
|
|
1422
|
-
parentId:
|
|
1423
|
-
restricted:
|
|
1589
|
+
return [...S].sort(nt).map((e) => ({ ...e }));
|
|
1590
|
+
},
|
|
1591
|
+
async createCollection({ name: t, parentId: r = "", restricted: i = !1 }) {
|
|
1592
|
+
let a = E(t, "a Collection's name", 200);
|
|
1593
|
+
if (r !== "" && J(r), i && j === "workspace") throw new e(je);
|
|
1594
|
+
if (rt(r, a)) throw new n(a);
|
|
1595
|
+
let o = {
|
|
1596
|
+
id: `col_stub_${V++}`,
|
|
1597
|
+
name: a,
|
|
1598
|
+
parentId: r,
|
|
1599
|
+
restricted: i
|
|
1424
1600
|
};
|
|
1425
|
-
return
|
|
1426
|
-
userId:
|
|
1601
|
+
return S.push(o), i && N.set(o.id, [{
|
|
1602
|
+
userId: y,
|
|
1427
1603
|
level: "owner"
|
|
1428
|
-
}]), { ...
|
|
1604
|
+
}]), { ...o };
|
|
1429
1605
|
},
|
|
1430
1606
|
async renameCollection({ id: e, name: t }) {
|
|
1431
|
-
let r =
|
|
1432
|
-
if (
|
|
1607
|
+
let r = E(t, "a Collection's name", 200), i = J(e);
|
|
1608
|
+
if (rt(i.parentId, r, e)) throw new n(r);
|
|
1433
1609
|
return i.name = r, { ...i };
|
|
1434
1610
|
},
|
|
1435
1611
|
async moveCollection({ id: e, parentId: t }) {
|
|
1436
|
-
let r =
|
|
1437
|
-
for (let n = t; n !== ""; n =
|
|
1438
|
-
if (
|
|
1612
|
+
let r = J(e);
|
|
1613
|
+
for (let n = t; n !== ""; n = J(n).parentId) if (n === e) throw new u(`Collection ${e} can't move under itself or a Collection under it`);
|
|
1614
|
+
if (rt(t, r.name, e)) throw new n("");
|
|
1439
1615
|
return r.parentId = t, { ...r };
|
|
1440
1616
|
},
|
|
1441
1617
|
async removeCollection({ id: e }) {
|
|
1442
|
-
if (
|
|
1443
|
-
|
|
1618
|
+
if (J(e), S.some((t) => t.parentId === e)) throw new u(`Collection ${e} has Collections under it: remove or move those first`);
|
|
1619
|
+
S.splice(S.findIndex((t) => t.id === e), 1), N.delete(e);
|
|
1444
1620
|
let t = [];
|
|
1445
|
-
for (let n of
|
|
1621
|
+
for (let n of C) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
|
|
1446
1622
|
return t;
|
|
1447
1623
|
},
|
|
1448
|
-
async setCollectionRestricted({ id:
|
|
1449
|
-
if (
|
|
1450
|
-
let
|
|
1451
|
-
if (
|
|
1452
|
-
if (!
|
|
1453
|
-
return
|
|
1454
|
-
userId:
|
|
1624
|
+
async setCollectionRestricted({ id: t, restricted: n, acknowledgeDisclosure: r = !1 }) {
|
|
1625
|
+
if (n && j === "workspace") throw new e(je);
|
|
1626
|
+
let i = J(t);
|
|
1627
|
+
if (i.restricted === n) return { ...i };
|
|
1628
|
+
if (!n && !r) throw new u(`unrestricting Collection ${t} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
|
|
1629
|
+
return i.restricted = n, n ? N.set(t, [{
|
|
1630
|
+
userId: y,
|
|
1455
1631
|
level: "owner"
|
|
1456
|
-
}]) :
|
|
1632
|
+
}]) : N.delete(t), { ...i };
|
|
1457
1633
|
},
|
|
1458
1634
|
async listCollectionGrants(e) {
|
|
1459
|
-
return
|
|
1635
|
+
return it(e), structuredClone(N.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
|
|
1460
1636
|
},
|
|
1461
1637
|
async grantCollectionAccess({ collectionId: e, userId: t, level: n }) {
|
|
1462
|
-
if (
|
|
1463
|
-
if (!
|
|
1464
|
-
let r =
|
|
1465
|
-
r.some((e) => e.level === "owner" && e.userId === t) ||
|
|
1638
|
+
if (it(e), n !== "viewer" && n !== "editor") throw new u("a grant is viewer or editor");
|
|
1639
|
+
if (!Fe.includes(t)) throw new u(`${t} is not a member of the workspace`);
|
|
1640
|
+
let r = N.get(e) ?? [];
|
|
1641
|
+
r.some((e) => e.level === "owner" && e.userId === t) || N.set(e, [...r.filter((e) => e.userId !== t), {
|
|
1466
1642
|
userId: t,
|
|
1467
1643
|
level: n
|
|
1468
1644
|
}]);
|
|
1469
1645
|
},
|
|
1470
1646
|
async revokeCollectionAccess({ collectionId: e, userId: t }) {
|
|
1471
|
-
|
|
1647
|
+
it(e), N.set(e, (N.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
|
|
1472
1648
|
},
|
|
1473
1649
|
async listContents(e = {}) {
|
|
1474
1650
|
let t = e.view ?? { kind: "main" }, n = (e.search ?? "").trim();
|
|
1475
|
-
if (n !== "" && t.kind === "in_force") throw new
|
|
1476
|
-
if ([...n].length > 200) throw new
|
|
1477
|
-
if (e.collectionId && !
|
|
1478
|
-
t.kind === "change_set" &&
|
|
1479
|
-
let r =
|
|
1651
|
+
if (n !== "" && t.kind === "in_force") throw new u("filter.search: Editor Search covers Main and open Branch heads, never Releases");
|
|
1652
|
+
if ([...n].length > 200) throw new u("filter.search is at most 200 characters");
|
|
1653
|
+
if (e.collectionId && !S.some((t) => t.id === e.collectionId)) throw D("Collection", e.collectionId);
|
|
1654
|
+
t.kind === "change_set" && Y(t.changeSetId);
|
|
1655
|
+
let r = C.filter((e) => !e.archiveTime).filter((t) => !e.collectionId || t.collectionIds.includes(e.collectionId)).filter((t) => !e.blueprintIds?.length || e.blueprintIds.includes(t.blueprintId)).filter((t) => !e.assigneeId || (t.assigneeIds ?? []).includes(e.assigneeId)).sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)).flatMap((e) => $(e, t, n)), i = Math.min(e.pageSize || 50, 200), a = e.pageToken ? Number(e.pageToken) : 0;
|
|
1480
1656
|
return {
|
|
1481
1657
|
contents: r.slice(a, a + i),
|
|
1482
1658
|
nextPageToken: a + i < r.length ? String(a + i) : ""
|
|
1483
1659
|
};
|
|
1484
1660
|
},
|
|
1485
1661
|
async createContent({ changeSetId: e, blueprintReleaseId: t, copyFrom: n }) {
|
|
1486
|
-
let r =
|
|
1662
|
+
let r = X(e), i = {}, a = t;
|
|
1487
1663
|
if (n) {
|
|
1488
|
-
let e = "revisionId" in n ? n.revisionId :
|
|
1489
|
-
if (!r || !e) throw
|
|
1490
|
-
i = structuredClone(
|
|
1664
|
+
let e = "revisionId" in n ? n.revisionId : C.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = C.find((t) => e && K(t, e));
|
|
1665
|
+
if (!r || !e) throw D("copy source", JSON.stringify(n));
|
|
1666
|
+
i = structuredClone(K(r, e) ?? {}), a = t || r.blueprintReleaseId;
|
|
1491
1667
|
}
|
|
1492
|
-
let o =
|
|
1493
|
-
if (!o) throw new
|
|
1668
|
+
let o = be.find((e) => e.id === a);
|
|
1669
|
+
if (!o) throw new f(`Blueprint Release ${a} can't be loaded`, [{
|
|
1494
1670
|
source: "contenthub",
|
|
1495
1671
|
code: "release_not_found",
|
|
1496
1672
|
path: ""
|
|
1497
1673
|
}]);
|
|
1498
|
-
if (o.refusals?.length) throw new
|
|
1499
|
-
let s =
|
|
1500
|
-
return
|
|
1674
|
+
if (o.refusals?.length) throw new f(`Blueprint Release ${a} can't be loaded`, o.refusals.map((e) => ({ ...e })));
|
|
1675
|
+
let s = V++, c = `content_stub_${s}`, l = `br_stub_${s}`, u = `rev_stub_${s}`;
|
|
1676
|
+
return C.push({
|
|
1501
1677
|
id: c,
|
|
1502
1678
|
blueprintId: o.blueprintId,
|
|
1503
1679
|
blueprintReleaseId: a,
|
|
@@ -1506,7 +1682,7 @@ function M(v = {}) {
|
|
|
1506
1682
|
branchId: l,
|
|
1507
1683
|
revisionId: u,
|
|
1508
1684
|
data: i,
|
|
1509
|
-
revisionCreateTime:
|
|
1685
|
+
revisionCreateTime: v()
|
|
1510
1686
|
} }
|
|
1511
1687
|
}), r.chains.push({
|
|
1512
1688
|
id: `chain_stub_${s}`,
|
|
@@ -1526,35 +1702,35 @@ function M(v = {}) {
|
|
|
1526
1702
|
data: structuredClone(i),
|
|
1527
1703
|
changeSetId: e,
|
|
1528
1704
|
branchId: l,
|
|
1529
|
-
revisionCreateTime:
|
|
1705
|
+
revisionCreateTime: v(),
|
|
1530
1706
|
releaseId: ""
|
|
1531
1707
|
};
|
|
1532
1708
|
},
|
|
1533
1709
|
async saveRevision({ idempotencyKey: e, ...t }) {
|
|
1534
|
-
if (!e) return
|
|
1535
|
-
let n = JSON.stringify(t), r =
|
|
1710
|
+
if (!e) return ot(t);
|
|
1711
|
+
let n = JSON.stringify(t), r = Xe.get(e);
|
|
1536
1712
|
if (r) {
|
|
1537
|
-
if (r.asked !== n) throw new
|
|
1713
|
+
if (r.asked !== n) throw new u(`idempotency key ${e} names another save`);
|
|
1538
1714
|
return structuredClone(r.content);
|
|
1539
1715
|
}
|
|
1540
|
-
let i = await
|
|
1541
|
-
return
|
|
1716
|
+
let i = await ot(t);
|
|
1717
|
+
return Xe.set(e, {
|
|
1542
1718
|
asked: n,
|
|
1543
1719
|
content: structuredClone(i)
|
|
1544
1720
|
}), i;
|
|
1545
1721
|
},
|
|
1546
1722
|
async getContent({ id: e, changeSetId: t, branchId: n }) {
|
|
1547
|
-
let r =
|
|
1723
|
+
let r = H(e), i = t ? {
|
|
1548
1724
|
kind: "change_set",
|
|
1549
1725
|
changeSetId: t
|
|
1550
1726
|
} : { kind: "main" };
|
|
1551
|
-
if (n && !t) throw new
|
|
1552
|
-
let [a] =
|
|
1553
|
-
if (!a) throw
|
|
1727
|
+
if (n && !t) throw new u("branch_id names a Branch of a Change Set: give its change_set_id too");
|
|
1728
|
+
let [a] = $(r, i, "");
|
|
1729
|
+
if (!a) throw D("Content", e);
|
|
1554
1730
|
if (n && n !== a.branchId) {
|
|
1555
|
-
let i =
|
|
1556
|
-
if (!i) throw
|
|
1557
|
-
let o =
|
|
1731
|
+
let i = x.find((e) => e.id === t)?.chains.find((t) => t.contentId === e)?.branches.find((e) => e.id === n);
|
|
1732
|
+
if (!i) throw D("Branch", n);
|
|
1733
|
+
let o = G(r).find((e) => e.id === i.headRevisionId), s = o?.data ?? (r.main?.revisionId === i.headRevisionId ? r.main.data : {});
|
|
1558
1734
|
a = {
|
|
1559
1735
|
...a,
|
|
1560
1736
|
revisionId: i.headRevisionId,
|
|
@@ -1563,15 +1739,15 @@ function M(v = {}) {
|
|
|
1563
1739
|
revisionCreateTime: o?.createTime ?? a.revisionCreateTime
|
|
1564
1740
|
};
|
|
1565
1741
|
}
|
|
1566
|
-
let o =
|
|
1742
|
+
let o = T[r.blueprintReleaseId];
|
|
1567
1743
|
return {
|
|
1568
1744
|
content: a,
|
|
1569
1745
|
blueprintRelease: o ? structuredClone(o) : void 0,
|
|
1570
|
-
attributes:
|
|
1746
|
+
attributes: U(r)
|
|
1571
1747
|
};
|
|
1572
1748
|
},
|
|
1573
1749
|
async getTimeline(e) {
|
|
1574
|
-
let t =
|
|
1750
|
+
let t = H(e), n = (e) => x.find((t) => t.id === e)?.state === "open";
|
|
1575
1751
|
return structuredClone({
|
|
1576
1752
|
entries: t.timeline ?? [],
|
|
1577
1753
|
plannedReleases: (t.plannedReleases ?? []).filter((e) => n(e.changeSetId))
|
|
@@ -1580,13 +1756,13 @@ function M(v = {}) {
|
|
|
1580
1756
|
async listRevisions({ target: e, pageSize: t, pageToken: n }) {
|
|
1581
1757
|
let r;
|
|
1582
1758
|
if ("contentId" in e) {
|
|
1583
|
-
let t =
|
|
1584
|
-
if (!t.main) throw
|
|
1585
|
-
r =
|
|
1759
|
+
let t = H(e.contentId);
|
|
1760
|
+
if (!t.main) throw D("Content", e.contentId);
|
|
1761
|
+
r = G(t);
|
|
1586
1762
|
} else {
|
|
1587
|
-
let t =
|
|
1588
|
-
if (!t) throw
|
|
1589
|
-
r =
|
|
1763
|
+
let t = C.find((t) => G(t).some((t) => t.branchId === e.branchId));
|
|
1764
|
+
if (!t) throw D("Branch", e.branchId);
|
|
1765
|
+
r = G(t).filter((t) => t.branchId === e.branchId);
|
|
1590
1766
|
}
|
|
1591
1767
|
let i = Math.min(t || 50, 200), a = n ? Number(n) : 0;
|
|
1592
1768
|
return {
|
|
@@ -1595,17 +1771,17 @@ function M(v = {}) {
|
|
|
1595
1771
|
};
|
|
1596
1772
|
},
|
|
1597
1773
|
async compare({ revisionId: e, base: t }) {
|
|
1598
|
-
let n =
|
|
1599
|
-
if (!n) throw
|
|
1600
|
-
let r =
|
|
1774
|
+
let n = C.find((t) => G(t).some((t) => t.id === e));
|
|
1775
|
+
if (!n) throw D("Revision", e);
|
|
1776
|
+
let r = G(n), i = r.find((t) => t.id === e), a;
|
|
1601
1777
|
if (t.kind === "revision") a = t.revisionId;
|
|
1602
1778
|
else if (t.kind === "main_head") {
|
|
1603
|
-
if (!n.main) throw new
|
|
1779
|
+
if (!n.main) throw new u("the Content is not published: it has no Main Branch");
|
|
1604
1780
|
a = n.main.revisionId;
|
|
1605
1781
|
} else a = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
|
|
1606
1782
|
let o = r.find((e) => e.id === a);
|
|
1607
|
-
if (!o) throw
|
|
1608
|
-
let s =
|
|
1783
|
+
if (!o) throw D("Revision", a);
|
|
1784
|
+
let s = K(n, i.id) ?? {}, c = K(n, o.id) ?? {}, l = [];
|
|
1609
1785
|
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({
|
|
1610
1786
|
path: `/${e}`,
|
|
1611
1787
|
kind: "changed",
|
|
@@ -1620,32 +1796,32 @@ function M(v = {}) {
|
|
|
1620
1796
|
kind: "added",
|
|
1621
1797
|
after: s[e]
|
|
1622
1798
|
});
|
|
1623
|
-
let
|
|
1799
|
+
let d = ({ data: e, ...t }) => t;
|
|
1624
1800
|
return {
|
|
1625
|
-
base:
|
|
1626
|
-
revision:
|
|
1801
|
+
base: d(o),
|
|
1802
|
+
revision: d(i),
|
|
1627
1803
|
changes: l
|
|
1628
1804
|
};
|
|
1629
1805
|
},
|
|
1630
1806
|
async listReferences({ contentId: e, revisionId: t }) {
|
|
1631
|
-
return (
|
|
1807
|
+
return (H(e).edges ?? []).filter((e) => e.sourceRevisionId === t).map((e) => ({ ...e }));
|
|
1632
1808
|
},
|
|
1633
1809
|
async listReferrers({ contentId: e, includeOpenChangeSets: t, pageSize: n, pageToken: r }) {
|
|
1634
|
-
|
|
1810
|
+
H(e);
|
|
1635
1811
|
let i = (e) => {
|
|
1636
1812
|
let t = Math.min(n || 100, 1e3), i = r ? Number(r) : 0;
|
|
1637
1813
|
return {
|
|
1638
1814
|
referrers: e.slice(i, i + t),
|
|
1639
1815
|
nextPageToken: i + t < e.length ? String(i + t) : ""
|
|
1640
1816
|
};
|
|
1641
|
-
}, a =
|
|
1817
|
+
}, a = C.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
|
|
1642
1818
|
edge: { ...e },
|
|
1643
1819
|
releaseId: t.inForce?.releaseId ?? "",
|
|
1644
1820
|
changeSetId: "",
|
|
1645
1821
|
branchId: ""
|
|
1646
1822
|
})));
|
|
1647
1823
|
if (!t) return i(a);
|
|
1648
|
-
let o =
|
|
1824
|
+
let o = C.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => x.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
|
|
1649
1825
|
edge: { ...e },
|
|
1650
1826
|
releaseId: "",
|
|
1651
1827
|
changeSetId: n,
|
|
@@ -1657,14 +1833,14 @@ function M(v = {}) {
|
|
|
1657
1833
|
let t;
|
|
1658
1834
|
if ("revisionId" in e) t = e.revisionId;
|
|
1659
1835
|
else {
|
|
1660
|
-
for (let n of
|
|
1836
|
+
for (let n of C) {
|
|
1661
1837
|
let r = Object.values(n.branches).find((t) => t.branchId === e.branchId);
|
|
1662
1838
|
r && (t = r.revisionId);
|
|
1663
1839
|
}
|
|
1664
|
-
if (!t) throw
|
|
1840
|
+
if (!t) throw D("Branch", e.branchId);
|
|
1665
1841
|
}
|
|
1666
|
-
return
|
|
1667
|
-
let t =
|
|
1842
|
+
return C.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
|
|
1843
|
+
let t = C.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
|
|
1668
1844
|
return t === e.pinReleaseId ? [] : [{
|
|
1669
1845
|
edge: { ...e },
|
|
1670
1846
|
supersededByReleaseId: t,
|
|
@@ -1673,138 +1849,226 @@ function M(v = {}) {
|
|
|
1673
1849
|
});
|
|
1674
1850
|
},
|
|
1675
1851
|
async setContentCollections({ contentId: e, collectionIds: t }) {
|
|
1676
|
-
let n =
|
|
1677
|
-
if (r.length > 100) throw new
|
|
1678
|
-
for (let e of r) if (!
|
|
1852
|
+
let n = H(e), r = [...new Set(t)];
|
|
1853
|
+
if (r.length > 100) throw new u("at most 100 Collections");
|
|
1854
|
+
for (let e of r) if (!S.some((t) => t.id === e)) throw D("Collection", e);
|
|
1679
1855
|
return n.collectionIds = r.sort(), [...n.collectionIds];
|
|
1680
1856
|
},
|
|
1681
1857
|
async setContentAssignees({ contentId: e, assigneeIds: t }) {
|
|
1682
|
-
let n =
|
|
1683
|
-
if (new Set(t).size !== t.length) throw new
|
|
1684
|
-
if (t.length > 50) throw new
|
|
1685
|
-
return n.assigneeIds = [...t],
|
|
1858
|
+
let n = H(e);
|
|
1859
|
+
if (new Set(t).size !== t.length) throw new u("each assignee is given once");
|
|
1860
|
+
if (t.length > 50) throw new u("at most 50 assignees");
|
|
1861
|
+
return n.assigneeIds = [...t], U(n);
|
|
1686
1862
|
},
|
|
1687
1863
|
async blockContent({ contentId: e, blockReasonId: t, allowedUserIds: n }) {
|
|
1688
|
-
let r =
|
|
1689
|
-
if (!
|
|
1690
|
-
if (new Set(n).size !== n.length) throw new
|
|
1864
|
+
let r = H(e);
|
|
1865
|
+
if (!b.some((e) => e.id === t)) throw D("Block Reason", t);
|
|
1866
|
+
if (new Set(n).size !== n.length) throw new u("each allowed user is given once");
|
|
1691
1867
|
return r.block = {
|
|
1692
1868
|
blockReasonId: t,
|
|
1693
1869
|
allowedUserIds: [...n],
|
|
1694
|
-
blockedBy:
|
|
1695
|
-
blockTime:
|
|
1696
|
-
},
|
|
1870
|
+
blockedBy: y,
|
|
1871
|
+
blockTime: v()
|
|
1872
|
+
}, U(r);
|
|
1697
1873
|
},
|
|
1698
1874
|
async unblockContent(e) {
|
|
1699
|
-
let t =
|
|
1700
|
-
|
|
1875
|
+
let t = H(e);
|
|
1876
|
+
if (!t.block && t.editingBlock) throw new u(`Content ${e} is being edited by ${t.editingBlock.editorId} in a Direct Edit: its Editing Block can't be lifted`);
|
|
1877
|
+
return t.block = void 0, U(t);
|
|
1701
1878
|
},
|
|
1702
1879
|
async archiveContent(e) {
|
|
1703
|
-
let t =
|
|
1704
|
-
if (t.archiveTime) return
|
|
1705
|
-
if (!t.main) throw new
|
|
1706
|
-
if (
|
|
1707
|
-
return t.archiveTime =
|
|
1880
|
+
let t = H(e);
|
|
1881
|
+
if (t.archiveTime) return U(t);
|
|
1882
|
+
if (!t.main) throw new u(`Content ${e} is not published: discard its Change Set instead of archiving it`);
|
|
1883
|
+
if (h(t.timeline ?? [], Ze())) throw new u(`Content ${e} has a Release In Force today or later: end its force first`);
|
|
1884
|
+
return t.archiveTime = v(), U(t);
|
|
1708
1885
|
},
|
|
1709
1886
|
async unarchiveContent(e) {
|
|
1710
|
-
let t =
|
|
1711
|
-
return t.archiveTime = void 0,
|
|
1712
|
-
},
|
|
1713
|
-
async openDirectEdit({ contentId: e, idempotencyKey:
|
|
1714
|
-
return
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1887
|
+
let t = H(e);
|
|
1888
|
+
return t.archiveTime = void 0, U(t);
|
|
1889
|
+
},
|
|
1890
|
+
async openDirectEdit({ contentId: e, effectiveOn: n, idempotencyKey: r }) {
|
|
1891
|
+
return B(r, [
|
|
1892
|
+
"openDirectEdit",
|
|
1893
|
+
e,
|
|
1894
|
+
n
|
|
1895
|
+
], async () => {
|
|
1896
|
+
let r = H(e), i = x.find((t) => t.kind === "direct_edit" && t.state === "open" && t.editorId === y && t.chains[0]?.contentId === e);
|
|
1897
|
+
if (i) {
|
|
1898
|
+
let [e] = $(r, {
|
|
1718
1899
|
kind: "change_set",
|
|
1719
|
-
changeSetId:
|
|
1900
|
+
changeSetId: i.id
|
|
1720
1901
|
}, "");
|
|
1721
1902
|
return {
|
|
1722
|
-
changeSet:
|
|
1903
|
+
changeSet: O(i),
|
|
1723
1904
|
content: e,
|
|
1724
1905
|
reopened: !0
|
|
1725
1906
|
};
|
|
1726
1907
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1908
|
+
let a = W(r);
|
|
1909
|
+
if (!a && n) throw new u("effective_on is refused for undated Content");
|
|
1910
|
+
let o = Re(r), s = R(L.find((e) => e.blueprintAccessor === o)), c = s.editingMode;
|
|
1911
|
+
if (r.main && c === "change_sets") throw new t(e, o, c);
|
|
1912
|
+
if (r.editingBlock && r.editingBlock.editorId !== y) throw new l("editing_blocked", `Content ${e} is being edited by ${r.editingBlock.editorId} in a Direct Edit`, e, r.editingBlock.editorId);
|
|
1913
|
+
let d = a ? n || Ze() : void 0, f = await Q.startEditing({
|
|
1731
1914
|
contentId: e,
|
|
1732
|
-
changeSetName: `Direct Edit of ${e}
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1915
|
+
changeSetName: `Direct Edit of ${e}`,
|
|
1916
|
+
effectiveOn: d
|
|
1917
|
+
}), p = Y(f.changeSet.id);
|
|
1918
|
+
p.kind = "direct_edit", p.editorId = y;
|
|
1919
|
+
let m = p.chains[0];
|
|
1920
|
+
if (d && m?.branches[0]) {
|
|
1921
|
+
let e = r.timeline ?? [], t = (e) => !!e.validityPeriod && e.validityPeriod.firstDay <= d && (e.validityPeriod.lastDay === "" || d <= e.validityPeriod.lastDay), n = [...e].reverse().find(t);
|
|
1922
|
+
m.branches[0].effectiveOn = d, m.branches[0].carriedReleaseId = n?.releaseId ?? "";
|
|
1923
|
+
for (let t of e) !t.validityPeriod || t.validityPeriod.firstDay <= d || m.branches.push({
|
|
1924
|
+
id: `br_stub_${V++}`,
|
|
1925
|
+
position: m.branches.length,
|
|
1926
|
+
kind: "carry_forward",
|
|
1927
|
+
headRevisionId: t.revisionId,
|
|
1928
|
+
effectiveOn: t.validityPeriod.firstDay,
|
|
1929
|
+
carriedReleaseId: t.releaseId
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
return s.editingBlock && (r.editingBlock = {
|
|
1933
|
+
editorId: y,
|
|
1934
|
+
changeSetId: p.id,
|
|
1935
|
+
blockTime: v()
|
|
1936
|
+
}), {
|
|
1937
|
+
changeSet: O(p),
|
|
1938
|
+
content: f.content,
|
|
1737
1939
|
reopened: !1
|
|
1738
1940
|
};
|
|
1739
1941
|
});
|
|
1740
1942
|
},
|
|
1741
|
-
async
|
|
1742
|
-
|
|
1943
|
+
async previewDirectEditPublish({ id: e, validityLastDay: t }) {
|
|
1944
|
+
let n = Y(e);
|
|
1945
|
+
if (n.kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
|
|
1946
|
+
return structuredClone(xt(n, t));
|
|
1947
|
+
},
|
|
1948
|
+
async publishDirectEdit({ id: e, expectedHeadId: t, releaseSpec: n, validityLastDay: r, carryForward: i, idempotencyKey: a }) {
|
|
1949
|
+
return B(a, [
|
|
1743
1950
|
"publishDirectEdit",
|
|
1744
1951
|
e,
|
|
1745
|
-
t
|
|
1952
|
+
t,
|
|
1953
|
+
n,
|
|
1954
|
+
r,
|
|
1955
|
+
i
|
|
1746
1956
|
], async () => {
|
|
1747
|
-
let
|
|
1748
|
-
if (
|
|
1749
|
-
let
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1957
|
+
let a = Y(e);
|
|
1958
|
+
if (a.kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
|
|
1959
|
+
let o = H(a.chains[0]?.contentId ?? ""), s = {
|
|
1960
|
+
cs: structuredClone(a),
|
|
1961
|
+
c: structuredClone(o)
|
|
1962
|
+
};
|
|
1963
|
+
try {
|
|
1964
|
+
return await St(a, t, n, {
|
|
1965
|
+
validityLastDay: r,
|
|
1966
|
+
carryForward: i
|
|
1967
|
+
});
|
|
1968
|
+
} catch (e) {
|
|
1969
|
+
throw bt(a, s.cs), bt(o, s.c), e;
|
|
1970
|
+
}
|
|
1971
|
+
});
|
|
1972
|
+
},
|
|
1973
|
+
async saveAndPublishDirectEdit({ id: e, expectedHeadId: t, data: n, fieldMask: r, releaseSpec: i, validityLastDay: a, carryForward: o, idempotencyKey: s }) {
|
|
1974
|
+
return B(s, [
|
|
1975
|
+
"saveAndPublishDirectEdit",
|
|
1976
|
+
e,
|
|
1977
|
+
t,
|
|
1978
|
+
n,
|
|
1979
|
+
r,
|
|
1980
|
+
i,
|
|
1981
|
+
a,
|
|
1982
|
+
o
|
|
1983
|
+
], async () => {
|
|
1984
|
+
let s = Y(e);
|
|
1985
|
+
if (s.kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
|
|
1986
|
+
let c = s.chains[0]?.branches[0];
|
|
1987
|
+
if (!c) throw Error(`Direct Edit ${e} has no Branch`);
|
|
1988
|
+
let u = H(s.chains[0]?.contentId ?? ""), d = {
|
|
1989
|
+
cs: structuredClone(s),
|
|
1990
|
+
c: structuredClone(u)
|
|
1991
|
+
};
|
|
1992
|
+
try {
|
|
1993
|
+
let l = await ot({
|
|
1994
|
+
changeSetId: e,
|
|
1995
|
+
branchId: c.id,
|
|
1996
|
+
expectedHeadId: t,
|
|
1997
|
+
data: n,
|
|
1998
|
+
fieldMask: r
|
|
1999
|
+
});
|
|
2000
|
+
return {
|
|
2001
|
+
content: l,
|
|
2002
|
+
outcome: await St(s, l.revisionId, i, {
|
|
2003
|
+
validityLastDay: a,
|
|
2004
|
+
carryForward: o
|
|
2005
|
+
})
|
|
2006
|
+
};
|
|
2007
|
+
} catch (e) {
|
|
2008
|
+
throw bt(s, d.cs), bt(u, d.c), e;
|
|
1773
2009
|
}
|
|
1774
|
-
return a;
|
|
1775
2010
|
});
|
|
1776
2011
|
},
|
|
1777
2012
|
async discardDirectEdit({ id: e, idempotencyKey: t }) {
|
|
1778
|
-
return
|
|
1779
|
-
if (
|
|
1780
|
-
|
|
2013
|
+
return B(t, ["discardDirectEdit", e], async () => {
|
|
2014
|
+
if (Y(e).kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
|
|
2015
|
+
let t = await Q.discardChangeSet(e);
|
|
2016
|
+
for (let t of C) t.editingBlock?.changeSetId === e && (t.editingBlock = void 0);
|
|
2017
|
+
return t;
|
|
2018
|
+
});
|
|
2019
|
+
},
|
|
2020
|
+
async forceDirectEdit({ id: e, idempotencyKey: t }) {
|
|
2021
|
+
return B(t, ["forceDirectEdit", e], async () => {
|
|
2022
|
+
let t = Y(e);
|
|
2023
|
+
if (t.kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
|
|
2024
|
+
let n = t.chains[0]?.contentId ?? "", r = H(n);
|
|
2025
|
+
if (t.state !== "open" || r.editingBlock?.changeSetId !== e) throw new l("no_editing_block", `Change Set ${e} holds no Editing Block`);
|
|
2026
|
+
let i = R(L.find((e) => e.blueprintAccessor === Re(r))).forceGroup;
|
|
2027
|
+
if (!ze(i)) throw new ne(`forcing the Editing Block of Content ${n} needs the Force Group`);
|
|
2028
|
+
let a = x.find((e) => e.kind === "direct_edit" && e.state === "open" && e.editorId === y && e.chains[0]?.contentId === n);
|
|
2029
|
+
if (a) throw new l("own_direct_edit", `you have a Direct Edit of Content ${n}, ${a.id}`, n);
|
|
2030
|
+
let o = t.editorId ?? "";
|
|
2031
|
+
t.editorId = y, r.editingBlock = {
|
|
2032
|
+
editorId: y,
|
|
2033
|
+
changeSetId: e,
|
|
2034
|
+
blockTime: v()
|
|
2035
|
+
};
|
|
2036
|
+
let [s] = $(r, {
|
|
2037
|
+
kind: "change_set",
|
|
2038
|
+
changeSetId: e
|
|
2039
|
+
}, "");
|
|
2040
|
+
return {
|
|
2041
|
+
changeSet: O(t),
|
|
2042
|
+
content: s,
|
|
2043
|
+
previousEditorId: o
|
|
2044
|
+
};
|
|
1781
2045
|
});
|
|
1782
2046
|
},
|
|
1783
2047
|
async startEditing({ contentId: e, changeSetId: t, effectiveOn: n = "", changeSetName: r = "" }) {
|
|
1784
|
-
let i =
|
|
1785
|
-
if (!i.main) throw new
|
|
1786
|
-
if (
|
|
1787
|
-
if (!
|
|
2048
|
+
let i = H(e);
|
|
2049
|
+
if (!i.main) throw new u(`Content ${e} is not published`);
|
|
2050
|
+
if (q(i), W(i) && !_.test(n)) throw new u("effective_on is required for Dated Content, as YYYY-MM-DD");
|
|
2051
|
+
if (!W(i) && n !== "") throw new u("effective_on is refused for undated Content");
|
|
1788
2052
|
let a;
|
|
1789
2053
|
if (t) {
|
|
1790
|
-
if (a =
|
|
1791
|
-
if (a.chains.some((t) => t.contentId === e)) throw new
|
|
2054
|
+
if (a = X(t), a.kind === "direct_edit") throw new l("one_branch", `Change Set ${t} is a Direct Edit`);
|
|
2055
|
+
if (a.chains.some((t) => t.contentId === e)) throw new u(`Content ${e} already has a Chain in this Change Set`);
|
|
1792
2056
|
} else {
|
|
1793
2057
|
let t = Object.values(i.main.data).filter((e) => typeof e == "string").slice(0, 2).join(" ");
|
|
1794
2058
|
a = {
|
|
1795
|
-
id: `cs_stub_${
|
|
1796
|
-
name: r.trim() ?
|
|
2059
|
+
id: `cs_stub_${V++}`,
|
|
2060
|
+
name: r.trim() ? E(r, "change_set_name", 200) : t || e,
|
|
1797
2061
|
state: "open",
|
|
1798
|
-
createdBy:
|
|
1799
|
-
createTime:
|
|
2062
|
+
createdBy: y,
|
|
2063
|
+
createTime: v(),
|
|
1800
2064
|
chains: [],
|
|
1801
2065
|
dependsOnChangeSetIds: [],
|
|
1802
2066
|
status: "",
|
|
1803
2067
|
assigneeIds: [],
|
|
1804
2068
|
plannedReleases: []
|
|
1805
|
-
},
|
|
2069
|
+
}, x.unshift(a);
|
|
1806
2070
|
}
|
|
1807
|
-
let o =
|
|
2071
|
+
let o = V++, s = `br_stub_${o}`, c = {
|
|
1808
2072
|
...structuredClone(i.main),
|
|
1809
2073
|
branchId: s
|
|
1810
2074
|
};
|
|
@@ -1819,21 +2083,21 @@ function M(v = {}) {
|
|
|
1819
2083
|
headRevisionId: c.revisionId
|
|
1820
2084
|
}]
|
|
1821
2085
|
});
|
|
1822
|
-
let [
|
|
2086
|
+
let [d] = $(i, {
|
|
1823
2087
|
kind: "change_set",
|
|
1824
2088
|
changeSetId: a.id
|
|
1825
2089
|
}, "");
|
|
1826
2090
|
return {
|
|
1827
|
-
changeSet:
|
|
1828
|
-
content:
|
|
2091
|
+
changeSet: O(a),
|
|
2092
|
+
content: d
|
|
1829
2093
|
};
|
|
1830
2094
|
},
|
|
1831
2095
|
async previewChain({ changeSetId: e, contentId: t, effectiveOn: n, validityPeriod: r }) {
|
|
1832
|
-
|
|
1833
|
-
let i =
|
|
1834
|
-
if (!i.main) throw new
|
|
1835
|
-
if (!
|
|
1836
|
-
if (!
|
|
2096
|
+
X(e);
|
|
2097
|
+
let i = H(t);
|
|
2098
|
+
if (!i.main) throw new u(`Content ${t} is not published`);
|
|
2099
|
+
if (!W(i)) throw new u("undated Content's Chain takes no date");
|
|
2100
|
+
if (!_.test(n)) throw new u("effective_on is YYYY-MM-DD");
|
|
1837
2101
|
let a = i.timeline ?? [], o = a.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
|
|
1838
2102
|
return {
|
|
1839
2103
|
forkReleaseId: o?.releaseId ?? "",
|
|
@@ -1844,31 +2108,31 @@ function M(v = {}) {
|
|
|
1844
2108
|
};
|
|
1845
2109
|
},
|
|
1846
2110
|
async planRepeal({ changeSetId: e, contentId: t, lastDay: n }) {
|
|
1847
|
-
|
|
1848
|
-
let r =
|
|
1849
|
-
if (
|
|
1850
|
-
if (!
|
|
1851
|
-
return
|
|
2111
|
+
X(e);
|
|
2112
|
+
let r = H(t);
|
|
2113
|
+
if (q(r), !W(r)) throw new u("a Repeal is for Dated Content");
|
|
2114
|
+
if (!_.test(n)) throw new u("last_day is YYYY-MM-DD");
|
|
2115
|
+
return Ct(r, e, {
|
|
1852
2116
|
kind: "repeal",
|
|
1853
2117
|
validityPeriod: {
|
|
1854
|
-
firstDay:
|
|
2118
|
+
firstDay: ee(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
|
|
1855
2119
|
lastDay: n
|
|
1856
2120
|
}
|
|
1857
2121
|
});
|
|
1858
2122
|
},
|
|
1859
2123
|
async planWithdrawal({ changeSetId: e, contentId: t }) {
|
|
1860
|
-
|
|
1861
|
-
let n =
|
|
1862
|
-
if (
|
|
1863
|
-
return
|
|
2124
|
+
X(e);
|
|
2125
|
+
let n = H(t);
|
|
2126
|
+
if (q(n), W(n)) throw new u("a Withdrawal is for undated Content");
|
|
2127
|
+
return Ct(n, e, { kind: "withdrawal" });
|
|
1864
2128
|
},
|
|
1865
2129
|
async planRelease({ idempotencyKey: e, ...t }) {
|
|
1866
|
-
return
|
|
1867
|
-
let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, { cs: o, chain: s, branch: c, c: l } =
|
|
1868
|
-
if (
|
|
1869
|
-
if (o.plannedReleases.some((e) => e.branchId === n)) throw new
|
|
1870
|
-
let
|
|
1871
|
-
id: `rls_stub_${
|
|
2130
|
+
return B(e, ["planRelease", t], async () => {
|
|
2131
|
+
let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, { cs: o, chain: s, branch: c, c: l } = ct(e, n);
|
|
2132
|
+
if (q(l), c.kind !== "editorial") throw new u("only an editorial Branch's head is released");
|
|
2133
|
+
if (o.plannedReleases.some((e) => e.branchId === n)) throw new u(`Branch ${n} is planned already`);
|
|
2134
|
+
let d = {
|
|
2135
|
+
id: `rls_stub_${V++}`,
|
|
1872
2136
|
contentId: s.contentId,
|
|
1873
2137
|
kind: "revision",
|
|
1874
2138
|
branchId: n,
|
|
@@ -1881,35 +2145,35 @@ function M(v = {}) {
|
|
|
1881
2145
|
splitFromReleaseId: "",
|
|
1882
2146
|
withheld: !1
|
|
1883
2147
|
};
|
|
1884
|
-
return
|
|
2148
|
+
return dt(l, d), o.plannedReleases.push(d), ft(o, l), structuredClone(d);
|
|
1885
2149
|
});
|
|
1886
2150
|
},
|
|
1887
2151
|
async updatePlannedRelease({ idempotencyKey: e, ...t }) {
|
|
1888
|
-
return
|
|
1889
|
-
let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, o =
|
|
1890
|
-
if (s < 0) throw
|
|
2152
|
+
return B(e, ["updatePlannedRelease", t], async () => {
|
|
2153
|
+
let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, o = X(e), s = o.plannedReleases.findIndex((e) => e.id === n);
|
|
2154
|
+
if (s < 0) throw D("Planned Release", n);
|
|
1891
2155
|
let c = o.plannedReleases[s];
|
|
1892
|
-
if (c.proposed) throw new
|
|
1893
|
-
let l =
|
|
1894
|
-
|
|
1895
|
-
let
|
|
2156
|
+
if (c.proposed) throw new u("a proposal is derived from the plans and can't be set");
|
|
2157
|
+
let l = H(c.contentId);
|
|
2158
|
+
q(l);
|
|
2159
|
+
let d = {
|
|
1896
2160
|
...structuredClone(c),
|
|
1897
2161
|
...r ? { validityPeriod: { ...r } } : {},
|
|
1898
2162
|
...i ? { releaseSpec: structuredClone(i) } : {},
|
|
1899
2163
|
...a ? { supersedesReleaseIds: [...a] } : {}
|
|
1900
2164
|
};
|
|
1901
|
-
return
|
|
2165
|
+
return dt(l, d), o.plannedReleases[s] = d, ft(o, l), structuredClone(d);
|
|
1902
2166
|
});
|
|
1903
2167
|
},
|
|
1904
2168
|
async appendBranch({ idempotencyKey: e, ...t }) {
|
|
1905
|
-
return
|
|
1906
|
-
let { changeSetId: e, chainId: n, effectiveOn: r } = t, i =
|
|
1907
|
-
if (!a) throw
|
|
1908
|
-
let o =
|
|
1909
|
-
if (a.born || !
|
|
2169
|
+
return B(e, ["appendBranch", t], async () => {
|
|
2170
|
+
let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = X(e), a = i.chains.find((e) => e.id === n);
|
|
2171
|
+
if (!a) throw D("Chain", n);
|
|
2172
|
+
let o = H(a.contentId);
|
|
2173
|
+
if (a.born || !W(o)) throw new u("only a Chain on published Dated Content takes dates");
|
|
1910
2174
|
let s = a.branches.filter((e) => e.kind === "editorial").at(-1);
|
|
1911
|
-
if (!
|
|
1912
|
-
let c = a.branches.at(-1), l = `br_stub_${
|
|
2175
|
+
if (!_.test(r) || s?.effectiveOn && r <= s.effectiveOn) throw new u("effective_on is a day after the Chain's last editorial Branch's");
|
|
2176
|
+
let c = a.branches.at(-1), l = `br_stub_${V++}`;
|
|
1913
2177
|
a.branches.push({
|
|
1914
2178
|
id: l,
|
|
1915
2179
|
position: a.branches.length,
|
|
@@ -1917,66 +2181,66 @@ function M(v = {}) {
|
|
|
1917
2181
|
headRevisionId: c?.headRevisionId ?? "",
|
|
1918
2182
|
effectiveOn: r
|
|
1919
2183
|
});
|
|
1920
|
-
let
|
|
1921
|
-
return
|
|
1922
|
-
...
|
|
2184
|
+
let d = o.branches[e];
|
|
2185
|
+
return d && (o.branches[e] = {
|
|
2186
|
+
...d,
|
|
1923
2187
|
branchId: l
|
|
1924
2188
|
}), {
|
|
1925
|
-
changeSet:
|
|
2189
|
+
changeSet: O(i),
|
|
1926
2190
|
branchId: l
|
|
1927
2191
|
};
|
|
1928
2192
|
});
|
|
1929
2193
|
},
|
|
1930
2194
|
async dropChain({ idempotencyKey: e, ...t }) {
|
|
1931
|
-
return
|
|
1932
|
-
let { changeSetId: e, chainId: n } = t, r =
|
|
1933
|
-
if (!i) throw
|
|
1934
|
-
if (i.born) throw new
|
|
1935
|
-
for (let e of i.branches)
|
|
1936
|
-
return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !== i.contentId), delete
|
|
2195
|
+
return B(e, ["dropChain", t], async () => {
|
|
2196
|
+
let { changeSetId: e, chainId: n } = t, r = X(e), i = r.chains.find((e) => e.id === n);
|
|
2197
|
+
if (!i) throw D("Chain", n);
|
|
2198
|
+
if (i.born) throw new u("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
|
|
2199
|
+
for (let e of i.branches) ut(e.id);
|
|
2200
|
+
return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !== i.contentId), delete H(i.contentId).branches[e], O(r);
|
|
1937
2201
|
});
|
|
1938
2202
|
},
|
|
1939
2203
|
async getPendingMerge(e) {
|
|
1940
|
-
let t =
|
|
2204
|
+
let t = z.get(e);
|
|
1941
2205
|
return t ? structuredClone(t) : null;
|
|
1942
2206
|
},
|
|
1943
2207
|
async resolveMerge({ idempotencyKey: e, ...t }) {
|
|
1944
|
-
return
|
|
1945
|
-
let { changeSetId: e, branchId: n, expectedHeadId: r, resolutions:
|
|
1946
|
-
if (!l) throw new
|
|
1947
|
-
if (s.headRevisionId !== r) throw new
|
|
2208
|
+
return B(e, ["resolveMerge", t], async () => {
|
|
2209
|
+
let { changeSetId: e, branchId: n, expectedHeadId: r, resolutions: i } = t, { chain: a, branch: s, c } = ct(e, n), l = z.get(n);
|
|
2210
|
+
if (!l) throw new u(`Branch ${n} has no Pending Merge`);
|
|
2211
|
+
if (s.headRevisionId !== r) throw new o({
|
|
1948
2212
|
contentId: c.id,
|
|
1949
2213
|
branchId: n,
|
|
1950
2214
|
expectedHeadId: r,
|
|
1951
2215
|
currentHeadId: s.headRevisionId
|
|
1952
2216
|
});
|
|
1953
|
-
let
|
|
1954
|
-
if (new Set(
|
|
1955
|
-
let
|
|
1956
|
-
for (let e of
|
|
2217
|
+
let d = i.map((e) => e.path), f = l.fields.map((e) => e.path);
|
|
2218
|
+
if (new Set(d).size !== d.length || d.some((e) => !f.includes(e)) || f.some((e) => !d.includes(e))) throw new u("decide every field the Pending Merge lists, once");
|
|
2219
|
+
let p = structuredClone(l.merged);
|
|
2220
|
+
for (let e of i) {
|
|
1957
2221
|
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
|
|
2222
|
+
n === void 0 ? delete p[r] : p[r] = structuredClone(n);
|
|
1959
2223
|
}
|
|
1960
|
-
let
|
|
2224
|
+
let m = st({
|
|
1961
2225
|
changeSetId: e,
|
|
1962
|
-
chain:
|
|
2226
|
+
chain: a,
|
|
1963
2227
|
branch: s,
|
|
1964
2228
|
c,
|
|
1965
|
-
data:
|
|
2229
|
+
data: p,
|
|
1966
2230
|
cause: "resolve",
|
|
1967
2231
|
secondParentId: l.theirsRevisionId
|
|
1968
2232
|
});
|
|
1969
|
-
return
|
|
2233
|
+
return ut(n), qe.delete(n), m;
|
|
1970
2234
|
});
|
|
1971
2235
|
},
|
|
1972
2236
|
async abortMerge({ idempotencyKey: e, ...t }) {
|
|
1973
|
-
return
|
|
1974
|
-
if (
|
|
1975
|
-
|
|
2237
|
+
return B(e, ["abortMerge", t], async () => {
|
|
2238
|
+
if (ct(t.changeSetId, t.branchId), !z.has(t.branchId)) throw new u(`Branch ${t.branchId} has no Pending Merge`);
|
|
2239
|
+
ut(t.branchId);
|
|
1976
2240
|
});
|
|
1977
2241
|
},
|
|
1978
2242
|
async previewInForce({ contentId: e, changeSetId: t, validOn: n }) {
|
|
1979
|
-
let r =
|
|
2243
|
+
let r = X(t), i = H(e), a = n || Ze(), 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));
|
|
1980
2244
|
if (c) {
|
|
1981
2245
|
let e = c.branchId ? o?.branches.find((e) => e.id === c.branchId)?.headRevisionId ?? "" : c.revisionId;
|
|
1982
2246
|
return {
|
|
@@ -1985,24 +2249,24 @@ function M(v = {}) {
|
|
|
1985
2249
|
planned: !0,
|
|
1986
2250
|
withheld: !1,
|
|
1987
2251
|
validityPeriod: c.validityPeriod ? { ...c.validityPeriod } : void 0,
|
|
1988
|
-
data: structuredClone(
|
|
2252
|
+
data: structuredClone(K(i, e) ?? {})
|
|
1989
2253
|
};
|
|
1990
2254
|
}
|
|
1991
|
-
let l =
|
|
2255
|
+
let l = ee(i.timeline ?? [], a);
|
|
1992
2256
|
return l ? {
|
|
1993
2257
|
releaseId: l.releaseId,
|
|
1994
2258
|
revisionId: l.revisionId,
|
|
1995
2259
|
planned: !1,
|
|
1996
2260
|
withheld: !1,
|
|
1997
2261
|
validityPeriod: l.validityPeriod ? { ...l.validityPeriod } : void 0,
|
|
1998
|
-
data: structuredClone(
|
|
2262
|
+
data: structuredClone(K(i, l.revisionId) ?? {})
|
|
1999
2263
|
} : null;
|
|
2000
2264
|
}
|
|
2001
2265
|
};
|
|
2002
|
-
return
|
|
2003
|
-
function
|
|
2266
|
+
return Q;
|
|
2267
|
+
function Ct(e, t, n) {
|
|
2004
2268
|
let r = {
|
|
2005
|
-
id: `rls_stub_${
|
|
2269
|
+
id: `rls_stub_${V++}`,
|
|
2006
2270
|
contentId: e.id,
|
|
2007
2271
|
branchId: "",
|
|
2008
2272
|
revisionId: e.inForce?.revisionId ?? e.main?.revisionId ?? "",
|
|
@@ -2018,10 +2282,10 @@ function M(v = {}) {
|
|
|
2018
2282
|
plannedRelease: r
|
|
2019
2283
|
}], structuredClone({
|
|
2020
2284
|
plannedRelease: r,
|
|
2021
|
-
gapReferrers:
|
|
2285
|
+
gapReferrers: $e(e.id)
|
|
2022
2286
|
});
|
|
2023
2287
|
}
|
|
2024
|
-
function
|
|
2288
|
+
function $(e, t, n) {
|
|
2025
2289
|
let r = (t, n) => ({
|
|
2026
2290
|
id: e.id,
|
|
2027
2291
|
blueprintId: e.blueprintId,
|
|
@@ -2036,33 +2300,33 @@ function M(v = {}) {
|
|
|
2036
2300
|
if (t.kind === "in_force") return e.inForce ? [r(e.inForce, { releaseId: e.inForce.releaseId })] : [];
|
|
2037
2301
|
if (t.kind === "change_set") {
|
|
2038
2302
|
let i = e.branches[t.changeSetId];
|
|
2039
|
-
return !i || n && !
|
|
2303
|
+
return !i || n && !Me(i.data, n) ? [] : [r(i, {
|
|
2040
2304
|
changeSetId: t.changeSetId,
|
|
2041
2305
|
branchId: i.branchId
|
|
2042
2306
|
})];
|
|
2043
2307
|
}
|
|
2044
2308
|
if (!n) return e.main ? [r(e.main, {})] : [];
|
|
2045
2309
|
let i = [];
|
|
2046
|
-
e.main &&
|
|
2047
|
-
for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1))
|
|
2310
|
+
e.main && Me(e.main.data, n) && i.push(r(e.main, {}));
|
|
2311
|
+
for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1)) x.find((e) => e.id === t)?.state === "open" && Me(a.data, n) && i.push(r(a, {
|
|
2048
2312
|
changeSetId: t,
|
|
2049
2313
|
branchId: a.branchId
|
|
2050
2314
|
}));
|
|
2051
2315
|
return i;
|
|
2052
2316
|
}
|
|
2053
2317
|
}
|
|
2054
|
-
function
|
|
2318
|
+
function Me(e, t) {
|
|
2055
2319
|
let n = (e) => e.toLocaleLowerCase().replace(/\s+/g, " "), r = n(t);
|
|
2056
2320
|
return Object.values(e).some((e) => typeof e == "string" && n(e).includes(r));
|
|
2057
2321
|
}
|
|
2058
2322
|
//#endregion
|
|
2059
2323
|
//#region src/testing/stub-status-source.ts
|
|
2060
|
-
function
|
|
2324
|
+
function j(e = fe()) {
|
|
2061
2325
|
return { async listChangeSetStatuses() {
|
|
2062
2326
|
return e.map((e) => ({ ...e }));
|
|
2063
2327
|
} };
|
|
2064
2328
|
}
|
|
2065
2329
|
//#endregion
|
|
2066
|
-
export {
|
|
2330
|
+
export { S as STUB_NOW, x as STUB_OTHER_USER_ID, b as STUB_USER_ID, ue as STUB_WORKSPACE_ID, T as createStubBlueprintSource, A as createStubContenthubClient, j as createStubStatusSource, de as stubBlockReasons, k as stubBlocker, ve as stubBlueprintReleases, _e as stubBlueprints, fe as stubChangeSetStatuses, me as stubChangeSets, ge as stubCollections, xe as stubContents, C as stubIdentity, be as stubRepealedContent, he as stubRequiredChecks, ye as stubResolvedReleases, pe as stubStatusTransitions, w as stubUndatedContent };
|
|
2067
2331
|
|
|
2068
2332
|
//# sourceMappingURL=testing.js.map
|