@knkcs/contenthub-ui 0.5.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 +13 -0
- package/README.md +2 -2
- package/dist/{branch-content-fields-DI9aQfh0.js → branch-content-fields-CMa-BJa2.js} +2 -2
- package/dist/{branch-content-fields-DI9aQfh0.js.map → branch-content-fields-CMa-BJa2.js.map} +1 -1
- package/dist/{content-library-BdHuzmXL.js → content-library-C5MCRNY0.js} +449 -375
- package/dist/content-library-C5MCRNY0.js.map +1 -0
- package/dist/{heads-BrvZ_GYT.js → heads-BT8RZ-Gs.js} +16 -11
- package/dist/heads-BT8RZ-Gs.js.map +1 -0
- package/dist/index.d.ts +166 -37
- package/dist/index.js +2774 -2718
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +71 -21
- package/dist/testing.js +685 -655
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/content-library-BdHuzmXL.js.map +0 -1
- package/dist/heads-BrvZ_GYT.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Code as
|
|
3
|
-
import { createHostMembers as
|
|
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
|
+
import { Code as v, ConnectError as y } from "@connectrpc/connect";
|
|
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 ce() {
|
|
|
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 le() {
|
|
|
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 ue() {
|
|
|
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 ue() {
|
|
|
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 ue() {
|
|
|
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 ue() {
|
|
|
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 de() {
|
|
|
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 fe() {
|
|
|
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 me() {
|
|
|
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 he() {
|
|
|
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 D() {
|
|
|
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 ge() {
|
|
|
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 _e() {
|
|
|
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 _e() {
|
|
|
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 _e() {
|
|
|
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 _e() {
|
|
|
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 _e() {
|
|
|
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 _e() {
|
|
|
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 ve(e = pe(), t = me()) {
|
|
|
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,56 +650,78 @@ function ve(e = pe(), t = me()) {
|
|
|
644
650
|
}
|
|
645
651
|
//#endregion
|
|
646
652
|
//#region src/testing/stub-client.ts
|
|
647
|
-
function
|
|
653
|
+
function Se(e) {
|
|
648
654
|
let t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
649
655
|
return t.setUTCDate(t.getUTCDate() - 1), t.toISOString().slice(0, 10);
|
|
650
656
|
}
|
|
651
|
-
function
|
|
657
|
+
function Ce(e, t) {
|
|
652
658
|
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
653
659
|
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
654
660
|
}
|
|
655
|
-
function
|
|
661
|
+
function E(e, t, n) {
|
|
656
662
|
let r = e.trim();
|
|
657
|
-
if (r === "") throw new
|
|
658
|
-
if ([...r].length > n) throw new
|
|
659
|
-
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`);
|
|
660
666
|
return r;
|
|
661
667
|
}
|
|
662
|
-
function
|
|
663
|
-
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`);
|
|
664
670
|
return {
|
|
665
671
|
date: e.date.trim(),
|
|
666
|
-
reference:
|
|
672
|
+
reference: E(e.reference, "source.reference", 500)
|
|
667
673
|
};
|
|
668
674
|
}
|
|
669
|
-
function
|
|
675
|
+
function Te(e) {
|
|
670
676
|
let t = e.trim();
|
|
671
|
-
if (t === "") throw new
|
|
672
|
-
if ([...t].length > 200) throw new
|
|
673
|
-
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");
|
|
674
680
|
return t;
|
|
675
681
|
}
|
|
676
|
-
function
|
|
677
|
-
let t =
|
|
678
|
-
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");
|
|
679
685
|
let n = e.blueprintAccessors.map((e) => {
|
|
680
686
|
let t = e.trim();
|
|
681
|
-
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`);
|
|
682
688
|
return t;
|
|
683
|
-
});
|
|
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");
|
|
684
692
|
return {
|
|
685
693
|
name: t,
|
|
686
694
|
scope: e.scope,
|
|
687
|
-
blueprintAccessors:
|
|
695
|
+
blueprintAccessors: r,
|
|
696
|
+
everyBlueprint: e.everyBlueprint,
|
|
688
697
|
independent: e.independent
|
|
689
698
|
};
|
|
690
699
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
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);
|
|
694
713
|
}
|
|
695
|
-
var
|
|
696
|
-
|
|
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) {
|
|
721
|
+
return new y(`${e} ${t}: not found`, v.NotFound);
|
|
722
|
+
}
|
|
723
|
+
var O = (e) => structuredClone(e);
|
|
724
|
+
function k(e, t = {}) {
|
|
697
725
|
return {
|
|
698
726
|
code: e,
|
|
699
727
|
contentId: "",
|
|
@@ -713,55 +741,55 @@ function j(e, t = {}) {
|
|
|
713
741
|
...t
|
|
714
742
|
};
|
|
715
743
|
}
|
|
716
|
-
function
|
|
717
|
-
let
|
|
718
|
-
if (
|
|
719
|
-
},
|
|
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) ?? {
|
|
720
748
|
everyMember: !0,
|
|
721
749
|
userIds: []
|
|
722
|
-
},
|
|
750
|
+
}, Fe = p.memberIds ?? ["user_stub", "user_ben"], F = p.admin ?? !0, Ie = p.editingSettings ?? {
|
|
723
751
|
editingMode: "change_sets",
|
|
724
752
|
editingBlock: !1
|
|
725
|
-
},
|
|
726
|
-
...
|
|
727
|
-
forceGroup:
|
|
728
|
-
}),
|
|
729
|
-
editingMode: e?.editingMode ??
|
|
730
|
-
editingBlock: e?.editingBlock ??
|
|
731
|
-
forceGroup: [...e?.forceGroup ??
|
|
732
|
-
}),
|
|
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) => ({
|
|
733
761
|
...structuredClone(e),
|
|
734
762
|
forceGroup: e.forceGroup ?? null,
|
|
735
|
-
effective:
|
|
736
|
-
}),
|
|
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 = [
|
|
737
765
|
"direct_edits",
|
|
738
766
|
"change_sets",
|
|
739
767
|
"both"
|
|
740
|
-
],
|
|
741
|
-
if (!
|
|
742
|
-
},
|
|
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) => {
|
|
743
771
|
if (!e) return n();
|
|
744
|
-
let r = JSON.stringify(t), i =
|
|
772
|
+
let r = JSON.stringify(t), i = Je.get(e);
|
|
745
773
|
if (i) {
|
|
746
|
-
if (i.asked !== r) throw new
|
|
774
|
+
if (i.asked !== r) throw new u(`idempotency key ${e} names another request`);
|
|
747
775
|
return structuredClone(i.answer);
|
|
748
776
|
}
|
|
749
777
|
let a = await n();
|
|
750
|
-
return
|
|
778
|
+
return Je.set(e, {
|
|
751
779
|
asked: r,
|
|
752
780
|
answer: structuredClone(a)
|
|
753
781
|
}), a;
|
|
754
|
-
},
|
|
755
|
-
let t =
|
|
756
|
-
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);
|
|
757
785
|
return t;
|
|
758
|
-
},
|
|
786
|
+
}, U = (e) => structuredClone({
|
|
759
787
|
collectionIds: [...e.collectionIds].sort(),
|
|
760
788
|
assigneeIds: e.assigneeIds ?? [],
|
|
761
789
|
block: e.block,
|
|
762
790
|
archiveTime: e.archiveTime,
|
|
763
791
|
editingBlock: e.editingBlock
|
|
764
|
-
}),
|
|
792
|
+
}), Ze = () => v().slice(0, 10), W = (e) => T[e.blueprintReleaseId]?.dated ?? !1, G = (e) => {
|
|
765
793
|
let t = [...e.revisions ?? []], n = [...Object.entries(e.branches).map(([e, t]) => ({
|
|
766
794
|
...t,
|
|
767
795
|
changeSetId: e
|
|
@@ -777,70 +805,70 @@ function M(y = {}) {
|
|
|
777
805
|
secondParentId: "",
|
|
778
806
|
blueprintReleaseId: e.blueprintReleaseId,
|
|
779
807
|
createTime: r.revisionCreateTime,
|
|
780
|
-
author:
|
|
808
|
+
author: y,
|
|
781
809
|
cause: "create",
|
|
782
810
|
branchId: r.branchId,
|
|
783
811
|
changeSetId: r.changeSetId,
|
|
784
812
|
data: r.data
|
|
785
813
|
});
|
|
786
814
|
return t.sort((e, t) => e.createTime < t.createTime ? 1 : e.createTime > t.createTime ? -1 : 0);
|
|
787
|
-
},
|
|
815
|
+
}, K = (e, t) => [
|
|
788
816
|
e.main,
|
|
789
817
|
e.inForce,
|
|
790
818
|
...Object.values(e.branches)
|
|
791
|
-
].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) => {
|
|
792
820
|
let n = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
793
821
|
return (e ?? []).filter((e) => e.config.required === !0 && n(t[e.config.api_accessor])).map((e) => e.config.api_accessor);
|
|
794
|
-
},
|
|
795
|
-
if (e.archiveTime) throw new
|
|
796
|
-
if (e.block && !e.block.allowedUserIds.includes(
|
|
797
|
-
},
|
|
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) => ({
|
|
798
826
|
edge: { ...e },
|
|
799
827
|
releaseId: t.inForce?.releaseId ?? ""
|
|
800
|
-
}))),
|
|
801
|
-
let t =
|
|
802
|
-
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);
|
|
803
831
|
return t;
|
|
804
|
-
},
|
|
805
|
-
if (
|
|
806
|
-
if (!
|
|
807
|
-
let
|
|
808
|
-
if (!
|
|
809
|
-
},
|
|
810
|
-
if (
|
|
811
|
-
if (!
|
|
812
|
-
if (
|
|
813
|
-
if (!
|
|
814
|
-
return
|
|
815
|
-
},
|
|
816
|
-
let
|
|
817
|
-
if (!
|
|
818
|
-
let c =
|
|
819
|
-
if (
|
|
820
|
-
if (n === "") throw new
|
|
821
|
-
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({
|
|
822
850
|
contentId: c.id,
|
|
823
851
|
branchId: t,
|
|
824
852
|
expectedHeadId: n,
|
|
825
853
|
currentHeadId: s.headRevisionId
|
|
826
854
|
});
|
|
827
|
-
let l =
|
|
828
|
-
if (
|
|
829
|
-
let e = Object.keys(
|
|
830
|
-
if (e.length > 0) throw new
|
|
831
|
-
|
|
832
|
-
for (let e of
|
|
833
|
-
} else
|
|
834
|
-
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({
|
|
835
863
|
changeSetId: e,
|
|
836
|
-
chain:
|
|
864
|
+
chain: a,
|
|
837
865
|
branch: s,
|
|
838
866
|
c,
|
|
839
|
-
data:
|
|
867
|
+
data: f,
|
|
840
868
|
cause: "save"
|
|
841
869
|
});
|
|
842
|
-
},
|
|
843
|
-
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();
|
|
844
872
|
return r.revisions = [{
|
|
845
873
|
id: c,
|
|
846
874
|
contentId: r.id,
|
|
@@ -848,7 +876,7 @@ function M(y = {}) {
|
|
|
848
876
|
secondParentId: o,
|
|
849
877
|
blueprintReleaseId: r.blueprintReleaseId,
|
|
850
878
|
createTime: l,
|
|
851
|
-
author:
|
|
879
|
+
author: y,
|
|
852
880
|
cause: a,
|
|
853
881
|
branchId: s,
|
|
854
882
|
changeSetId: e,
|
|
@@ -869,17 +897,17 @@ function M(y = {}) {
|
|
|
869
897
|
revisionCreateTime: l,
|
|
870
898
|
releaseId: ""
|
|
871
899
|
};
|
|
872
|
-
},
|
|
873
|
-
let n =
|
|
874
|
-
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);
|
|
875
903
|
return {
|
|
876
904
|
cs: n,
|
|
877
905
|
chain: r,
|
|
878
906
|
branch: i,
|
|
879
|
-
c:
|
|
907
|
+
c: H(r.contentId)
|
|
880
908
|
};
|
|
881
|
-
},
|
|
882
|
-
for (let n of
|
|
909
|
+
}, lt = (e, t) => {
|
|
910
|
+
for (let n of x) for (let r of n.chains) {
|
|
883
911
|
let n = r.branches.find((t) => t.id === e);
|
|
884
912
|
if (!n) continue;
|
|
885
913
|
let i = {
|
|
@@ -892,37 +920,37 @@ function M(y = {}) {
|
|
|
892
920
|
fields: structuredClone(t.fields),
|
|
893
921
|
merged: structuredClone(t.merged)
|
|
894
922
|
};
|
|
895
|
-
|
|
923
|
+
z.set(e, i), n.hasPendingMerge = !0, delete Ke[e];
|
|
896
924
|
return;
|
|
897
925
|
}
|
|
898
|
-
throw
|
|
899
|
-
},
|
|
900
|
-
|
|
901
|
-
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) {
|
|
902
930
|
let t = n.branches.find((t) => t.id === e);
|
|
903
931
|
t && (t.hasPendingMerge = !1);
|
|
904
932
|
}
|
|
905
|
-
},
|
|
933
|
+
}, dt = (e, t) => {
|
|
906
934
|
let n = t.validityPeriod;
|
|
907
|
-
if (
|
|
908
|
-
if (!n || !
|
|
909
|
-
if (n.lastDay !== "" && (!
|
|
910
|
-
} else if (n) throw new
|
|
911
|
-
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) => ({
|
|
912
940
|
source: "fieldkit",
|
|
913
941
|
code: "required",
|
|
914
942
|
path: `/${e}`
|
|
915
943
|
}));
|
|
916
|
-
if (r.length > 0) throw new
|
|
944
|
+
if (r.length > 0) throw new f("the Release Spec values break the Blueprint Release", r);
|
|
917
945
|
if (n && n.lastDay !== "") {
|
|
918
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);
|
|
919
|
-
if (r.length > 0) throw new
|
|
947
|
+
if (r.length > 0) throw new se(e.id, r);
|
|
920
948
|
}
|
|
921
|
-
},
|
|
949
|
+
}, ft = (e, t) => {
|
|
922
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) => {
|
|
923
951
|
let o = n.find((t) => t.proposedForReleaseId === e.releaseId && t.splitFromReleaseId === a);
|
|
924
952
|
i.push({
|
|
925
|
-
id: o?.id ?? `rls_stub_${
|
|
953
|
+
id: o?.id ?? `rls_stub_${V++}`,
|
|
926
954
|
contentId: t.id,
|
|
927
955
|
kind: "date_only",
|
|
928
956
|
branchId: "",
|
|
@@ -941,23 +969,23 @@ function M(y = {}) {
|
|
|
941
969
|
let t = r.validityPeriod;
|
|
942
970
|
t && !e.supersedesReleaseIds.includes(r.releaseId) && t.firstDay < n.firstDay && (t.lastDay === "" || t.lastDay >= n.firstDay) && (a(r, {
|
|
943
971
|
firstDay: t.firstDay,
|
|
944
|
-
lastDay:
|
|
972
|
+
lastDay: Ce(n.firstDay, -1)
|
|
945
973
|
}, ""), n.lastDay !== "" && (t.lastDay === "" || t.lastDay > n.lastDay) && a(r, {
|
|
946
|
-
firstDay:
|
|
974
|
+
firstDay: Ce(n.lastDay, 1),
|
|
947
975
|
lastDay: t.lastDay
|
|
948
976
|
}, r.releaseId));
|
|
949
977
|
}
|
|
950
978
|
}
|
|
951
979
|
e.plannedReleases = [...r, ...i];
|
|
952
|
-
},
|
|
953
|
-
let t =
|
|
954
|
-
if (!t) throw
|
|
980
|
+
}, Y = (e) => {
|
|
981
|
+
let t = x.find((t) => t.id === e);
|
|
982
|
+
if (!t) throw D("Change Set", e);
|
|
955
983
|
return t;
|
|
956
|
-
},
|
|
957
|
-
let t =
|
|
958
|
-
if (t.state !== "open") throw new
|
|
984
|
+
}, X = (e) => {
|
|
985
|
+
let t = Y(e);
|
|
986
|
+
if (t.state !== "open") throw new m(t.state);
|
|
959
987
|
return t;
|
|
960
|
-
},
|
|
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) => ({
|
|
961
989
|
key: t.id,
|
|
962
990
|
branchless: !1,
|
|
963
991
|
contentId: e.contentId,
|
|
@@ -967,9 +995,12 @@ function M(y = {}) {
|
|
|
967
995
|
branchless: !0,
|
|
968
996
|
contentId: e.contentId,
|
|
969
997
|
revision: e.revisionId
|
|
970
|
-
}))],
|
|
971
|
-
let t =
|
|
972
|
-
|
|
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;
|
|
973
1004
|
return {
|
|
974
1005
|
check: structuredClone(e),
|
|
975
1006
|
...t,
|
|
@@ -978,8 +1009,8 @@ function M(y = {}) {
|
|
|
978
1009
|
cleared: !!r && !i && r.outcome !== "failed"
|
|
979
1010
|
};
|
|
980
1011
|
}, i = [], a = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
|
|
981
|
-
for (let e of [...
|
|
982
|
-
let a = t.filter((t) =>
|
|
1012
|
+
for (let e of [...A].sort(a)) {
|
|
1013
|
+
let a = t.filter((t) => _t(e, t.contentId));
|
|
983
1014
|
if (e.scope === "change_set") {
|
|
984
1015
|
if (a.length === 0) continue;
|
|
985
1016
|
let o = Object.fromEntries(t.map((e) => [e.key, e.revision]));
|
|
@@ -999,48 +1030,48 @@ function M(y = {}) {
|
|
|
999
1030
|
}, n(e, t.key)));
|
|
1000
1031
|
}
|
|
1001
1032
|
return i;
|
|
1002
|
-
},
|
|
1033
|
+
}, yt = (e, t) => {
|
|
1003
1034
|
let n = [], r = re(e);
|
|
1004
|
-
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", {
|
|
1005
1036
|
contentId: r.contentId,
|
|
1006
1037
|
branchId: e.id,
|
|
1007
1038
|
expectedHeadId: t[e.id] ?? "",
|
|
1008
1039
|
currentHeadId: e.headRevisionId
|
|
1009
1040
|
}));
|
|
1010
|
-
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", {
|
|
1011
1042
|
branchId: e,
|
|
1012
1043
|
expectedHeadId: i
|
|
1013
1044
|
}));
|
|
1014
|
-
for (let t of e.chains) for (let e of t.branches)
|
|
1045
|
+
for (let t of e.chains) for (let e of t.branches) qe.has(e.id) && n.push(k("behind_base", {
|
|
1015
1046
|
contentId: t.contentId,
|
|
1016
1047
|
branchId: e.id
|
|
1017
|
-
})),
|
|
1048
|
+
})), z.has(e.id) && n.push(k("pending_merge", {
|
|
1018
1049
|
contentId: t.contentId,
|
|
1019
1050
|
branchId: e.id
|
|
1020
1051
|
}));
|
|
1021
1052
|
for (let t of e.dependsOnChangeSetIds) {
|
|
1022
|
-
let e =
|
|
1023
|
-
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 }));
|
|
1024
1055
|
}
|
|
1025
|
-
for (let t of
|
|
1056
|
+
for (let t of vt(e)) t.cleared || n.push(k("outstanding_check", {
|
|
1026
1057
|
requiredCheckId: t.check.id,
|
|
1027
1058
|
contentId: t.contentId,
|
|
1028
1059
|
branchId: t.branchId,
|
|
1029
1060
|
releaseId: t.releaseId
|
|
1030
1061
|
}));
|
|
1031
1062
|
for (let t of e.chains) {
|
|
1032
|
-
let e =
|
|
1063
|
+
let e = C.find((e) => e.id === t.contentId);
|
|
1033
1064
|
for (let r of t.branches) {
|
|
1034
|
-
let t = e &&
|
|
1035
|
-
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", {
|
|
1036
1067
|
contentId: e.id,
|
|
1037
1068
|
revisionId: r.headRevisionId,
|
|
1038
1069
|
path: `/${i}`
|
|
1039
1070
|
}));
|
|
1040
1071
|
}
|
|
1041
1072
|
}
|
|
1042
|
-
return [...n, ...structuredClone(
|
|
1043
|
-
},
|
|
1073
|
+
return [...n, ...structuredClone(We[e.id] ?? [])];
|
|
1074
|
+
}, Z = (e) => {
|
|
1044
1075
|
let t = re(e);
|
|
1045
1076
|
return e.plannedReleases.filter((e) => !e.withheld).map((n) => ({
|
|
1046
1077
|
id: n.id,
|
|
@@ -1053,33 +1084,33 @@ function M(y = {}) {
|
|
|
1053
1084
|
validityPeriod: n.validityPeriod ? { ...n.validityPeriod } : void 0
|
|
1054
1085
|
}));
|
|
1055
1086
|
};
|
|
1056
|
-
for (let [e, t] of Object.entries(
|
|
1057
|
-
let
|
|
1087
|
+
for (let [e, t] of Object.entries(Ke)) t.pending && lt(e, t);
|
|
1088
|
+
let bt = (e, t) => {
|
|
1058
1089
|
for (let n of Object.keys(e)) n in t || delete e[n];
|
|
1059
1090
|
Object.assign(e, t);
|
|
1060
|
-
},
|
|
1091
|
+
}, xt = (e, t) => {
|
|
1061
1092
|
let n = e.chains[0], r = n?.branches[0], i = r?.effectiveOn ?? "";
|
|
1062
|
-
if (!n || !r || !i) throw new
|
|
1063
|
-
let a =
|
|
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 } : {
|
|
1064
1095
|
firstDay: i,
|
|
1065
1096
|
lastDay: ""
|
|
1066
1097
|
};
|
|
1067
1098
|
if (t !== void 0) {
|
|
1068
|
-
if (t !== "" && (!
|
|
1099
|
+
if (t !== "" && (!_.test(t) || t < l.firstDay)) throw new u("validity_last_day is YYYY-MM-DD, not before the first day");
|
|
1069
1100
|
l.lastDay = t;
|
|
1070
1101
|
}
|
|
1071
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);
|
|
1072
|
-
if (d.length > 0) throw new
|
|
1103
|
+
if (d.length > 0) throw new se(a.id, d, !0);
|
|
1073
1104
|
let f = [];
|
|
1074
1105
|
!c && s?.validityPeriod && s.validityPeriod.firstDay < i && f.push({
|
|
1075
|
-
id: `rls_stub_${
|
|
1106
|
+
id: `rls_stub_${V++}`,
|
|
1076
1107
|
contentId: a.id,
|
|
1077
1108
|
kind: "date_only",
|
|
1078
1109
|
branchId: "",
|
|
1079
1110
|
revisionId: s.revisionId,
|
|
1080
1111
|
validityPeriod: {
|
|
1081
1112
|
firstDay: s.validityPeriod.firstDay,
|
|
1082
|
-
lastDay:
|
|
1113
|
+
lastDay: Se(i)
|
|
1083
1114
|
},
|
|
1084
1115
|
supersedesReleaseIds: [s.releaseId],
|
|
1085
1116
|
proposed: !0,
|
|
@@ -1100,19 +1131,19 @@ function M(y = {}) {
|
|
|
1100
1131
|
dateOnlyReleases: f,
|
|
1101
1132
|
laterWordings: p
|
|
1102
1133
|
};
|
|
1103
|
-
},
|
|
1134
|
+
}, St = async (e, t, n, r = {}) => {
|
|
1104
1135
|
let i = e.id, a = e.chains[0], o = a?.branches[0];
|
|
1105
1136
|
if (!a || !o) throw Error(`Direct Edit ${i} has no Branch`);
|
|
1106
1137
|
let s = !!o.effectiveOn;
|
|
1107
|
-
if (!s && (r.validityLastDay !== void 0 || (r.carryForward ?? []).length > 0)) throw new
|
|
1138
|
+
if (!s && (r.validityLastDay !== void 0 || (r.carryForward ?? []).length > 0)) throw new u("validity_last_day and carry_forward are for Dated Content");
|
|
1108
1139
|
if (e.state === "open") {
|
|
1109
|
-
let t = s ?
|
|
1110
|
-
if (c ? (n || t) && await
|
|
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({
|
|
1111
1142
|
changeSetId: i,
|
|
1112
1143
|
plannedReleaseId: c.id,
|
|
1113
1144
|
releaseSpec: n,
|
|
1114
1145
|
validityPeriod: t?.validityPeriod
|
|
1115
|
-
}) : await
|
|
1146
|
+
}) : await Q.planRelease({
|
|
1116
1147
|
changeSetId: i,
|
|
1117
1148
|
branchId: o.id,
|
|
1118
1149
|
releaseSpec: n,
|
|
@@ -1120,12 +1151,12 @@ function M(y = {}) {
|
|
|
1120
1151
|
supersedesReleaseIds: t?.correctsReleaseId ? [t.correctsReleaseId] : void 0
|
|
1121
1152
|
}), t) {
|
|
1122
1153
|
let n = new Map((r.carryForward ?? []).map((e) => [e.releaseId, e.carry])), i = t.laterWordings.filter((e) => !n.has(e.releaseId));
|
|
1123
|
-
if (i.length > 0) throw new
|
|
1154
|
+
if (i.length > 0) throw new u(`carry_forward has no answer for the later wordings ${i.map((e) => e.releaseId).join(", ")}`);
|
|
1124
1155
|
e.plannedReleases.push(...t.dateOnlyReleases);
|
|
1125
1156
|
for (let r of a.branches.slice(1)) {
|
|
1126
1157
|
let i = t.laterWordings.find((e) => e.releaseId === r.carriedReleaseId);
|
|
1127
1158
|
i && n.get(i.releaseId) && e.plannedReleases.push({
|
|
1128
|
-
id: `rls_stub_${
|
|
1159
|
+
id: `rls_stub_${V++}`,
|
|
1129
1160
|
contentId: a.contentId,
|
|
1130
1161
|
kind: "revision",
|
|
1131
1162
|
branchId: r.id,
|
|
@@ -1140,61 +1171,61 @@ function M(y = {}) {
|
|
|
1140
1171
|
}
|
|
1141
1172
|
}
|
|
1142
1173
|
}
|
|
1143
|
-
let c = await
|
|
1174
|
+
let c = await Q.publish({
|
|
1144
1175
|
id: i,
|
|
1145
1176
|
reviewedHeads: {
|
|
1146
1177
|
...re(e),
|
|
1147
1178
|
[o.id]: t
|
|
1148
1179
|
}
|
|
1149
|
-
}), l =
|
|
1180
|
+
}), l = H(a.contentId);
|
|
1150
1181
|
l.editingBlock?.changeSetId === i && (l.editingBlock = void 0);
|
|
1151
|
-
let
|
|
1152
|
-
if (
|
|
1153
|
-
let { branchId: e, ...t } = structuredClone(
|
|
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);
|
|
1154
1185
|
l.main = t, l.inForce = {
|
|
1155
1186
|
...structuredClone(t),
|
|
1156
|
-
releaseId:
|
|
1187
|
+
releaseId: f.id
|
|
1157
1188
|
}, l.timeline = [...l.timeline ?? [], {
|
|
1158
1189
|
ordinal: (l.timeline?.length ?? 0) + 1,
|
|
1159
|
-
releaseId:
|
|
1190
|
+
releaseId: f.id,
|
|
1160
1191
|
kind: "revision",
|
|
1161
|
-
revisionId:
|
|
1192
|
+
revisionId: d.revisionId,
|
|
1162
1193
|
blueprintReleaseId: l.blueprintReleaseId,
|
|
1163
1194
|
publishTime: c.publishTime,
|
|
1164
1195
|
first: !1
|
|
1165
1196
|
}];
|
|
1166
1197
|
}
|
|
1167
1198
|
return c;
|
|
1168
|
-
},
|
|
1199
|
+
}, Q = {
|
|
1169
1200
|
async listBlockReasons() {
|
|
1170
|
-
return [...
|
|
1201
|
+
return [...b].sort(et).map((e) => ({ ...e }));
|
|
1171
1202
|
},
|
|
1172
1203
|
async createBlockReason({ name: e }) {
|
|
1173
|
-
let t =
|
|
1174
|
-
if (
|
|
1204
|
+
let t = Te(e);
|
|
1205
|
+
if (tt(t)) throw new ie(t);
|
|
1175
1206
|
let n = {
|
|
1176
|
-
id: `br_stub_${
|
|
1207
|
+
id: `br_stub_${V++}`,
|
|
1177
1208
|
name: t,
|
|
1178
|
-
createTime:
|
|
1179
|
-
updateTime:
|
|
1209
|
+
createTime: v(),
|
|
1210
|
+
updateTime: v()
|
|
1180
1211
|
};
|
|
1181
|
-
return
|
|
1212
|
+
return b.push(n), { ...n };
|
|
1182
1213
|
},
|
|
1183
1214
|
async renameBlockReason({ id: e, name: t }) {
|
|
1184
|
-
let n =
|
|
1185
|
-
if (!r) throw
|
|
1186
|
-
if (
|
|
1187
|
-
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 };
|
|
1188
1219
|
},
|
|
1189
1220
|
async deleteBlockReason({ id: e }) {
|
|
1190
|
-
if (!
|
|
1191
|
-
|
|
1221
|
+
if (!b.some((t) => t.id === e)) throw D("Block Reason", e);
|
|
1222
|
+
b = b.filter((t) => t.id !== e);
|
|
1192
1223
|
},
|
|
1193
1224
|
async listChangeSets(e = {}) {
|
|
1194
|
-
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;
|
|
1195
1226
|
return {
|
|
1196
1227
|
changeSets: t.slice(r, r + n).map((e) => ({
|
|
1197
|
-
...
|
|
1228
|
+
...O(e),
|
|
1198
1229
|
chains: [],
|
|
1199
1230
|
dependsOnChangeSetIds: [],
|
|
1200
1231
|
plannedReleases: []
|
|
@@ -1203,115 +1234,115 @@ function M(y = {}) {
|
|
|
1203
1234
|
};
|
|
1204
1235
|
},
|
|
1205
1236
|
async createChangeSet({ name: e, source: t }) {
|
|
1206
|
-
let n =
|
|
1207
|
-
id: `cs_stub_${
|
|
1237
|
+
let n = E(e, "name", 200), r = t ? we(t) : void 0, i = {
|
|
1238
|
+
id: `cs_stub_${V++}`,
|
|
1208
1239
|
name: n,
|
|
1209
1240
|
source: r,
|
|
1210
1241
|
state: "open",
|
|
1211
|
-
createdBy:
|
|
1212
|
-
createTime:
|
|
1242
|
+
createdBy: y,
|
|
1243
|
+
createTime: v(),
|
|
1213
1244
|
chains: [],
|
|
1214
1245
|
dependsOnChangeSetIds: [],
|
|
1215
1246
|
status: "",
|
|
1216
1247
|
assigneeIds: [],
|
|
1217
1248
|
plannedReleases: []
|
|
1218
1249
|
};
|
|
1219
|
-
return
|
|
1250
|
+
return x.unshift(i), O(i);
|
|
1220
1251
|
},
|
|
1221
1252
|
async getChangeSet(e) {
|
|
1222
|
-
return
|
|
1253
|
+
return O(Y(e));
|
|
1223
1254
|
},
|
|
1224
1255
|
async updateChangeSet({ id: e, updateMask: t, name: n, source: r }) {
|
|
1225
|
-
let i =
|
|
1226
|
-
if (t.length === 0) throw new
|
|
1227
|
-
let a = t.includes("name") ?
|
|
1228
|
-
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);
|
|
1229
1260
|
},
|
|
1230
1261
|
async setChangeSetStatus({ id: e, expectedStatus: t, status: n }) {
|
|
1231
|
-
let r =
|
|
1232
|
-
if (r.status !== t) throw new
|
|
1233
|
-
if (r.status === n) return
|
|
1234
|
-
if (!
|
|
1235
|
-
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({
|
|
1236
1267
|
fromStatus: r.status,
|
|
1237
1268
|
toStatus: n,
|
|
1238
|
-
reason: `There is no transition from ${
|
|
1269
|
+
reason: `There is no transition from ${pt(r.status)} to ${pt(n)}.`,
|
|
1239
1270
|
requiresPermission: !1
|
|
1240
1271
|
});
|
|
1241
|
-
return r.status = n,
|
|
1272
|
+
return r.status = n, O(r);
|
|
1242
1273
|
},
|
|
1243
1274
|
async setChangeSetAssignees({ id: e, assigneeIds: t }) {
|
|
1244
|
-
let n =
|
|
1245
|
-
if (new Set(t).size !== t.length) throw new
|
|
1246
|
-
if (t.length > 50) throw new
|
|
1247
|
-
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);
|
|
1248
1279
|
},
|
|
1249
1280
|
async addDependency({ id: e, dependsOnId: t }) {
|
|
1250
|
-
let n =
|
|
1251
|
-
if (r.state !== "open") throw new
|
|
1252
|
-
if (
|
|
1253
|
-
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);
|
|
1254
1285
|
},
|
|
1255
1286
|
async removeDependency({ id: e, dependsOnId: t }) {
|
|
1256
|
-
let n =
|
|
1257
|
-
if (!n.dependsOnChangeSetIds.includes(t)) throw
|
|
1258
|
-
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);
|
|
1259
1290
|
},
|
|
1260
1291
|
async validatePublish({ id: e, reviewedHeads: t }) {
|
|
1261
|
-
let n =
|
|
1262
|
-
|
|
1263
|
-
let r =
|
|
1264
|
-
if (r &&
|
|
1292
|
+
let n = Y(e);
|
|
1293
|
+
M(e);
|
|
1294
|
+
let r = Ye.get(e);
|
|
1295
|
+
if (r && g(r, t)) return {
|
|
1265
1296
|
blockers: [],
|
|
1266
|
-
releases:
|
|
1297
|
+
releases: Z(n),
|
|
1267
1298
|
published: !0
|
|
1268
1299
|
};
|
|
1269
|
-
if (n.state !== "open") throw new
|
|
1300
|
+
if (n.state !== "open") throw new m(n.state);
|
|
1270
1301
|
return {
|
|
1271
|
-
blockers:
|
|
1272
|
-
releases:
|
|
1302
|
+
blockers: yt(n, t),
|
|
1303
|
+
releases: Z(n),
|
|
1273
1304
|
published: !1
|
|
1274
1305
|
};
|
|
1275
1306
|
},
|
|
1276
|
-
async publish({ id: e, reviewedHeads:
|
|
1277
|
-
let
|
|
1278
|
-
|
|
1279
|
-
let
|
|
1280
|
-
if (
|
|
1281
|
-
changeSet:
|
|
1282
|
-
publishTime:
|
|
1283
|
-
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)
|
|
1284
1315
|
};
|
|
1285
|
-
if (
|
|
1286
|
-
let
|
|
1287
|
-
if (
|
|
1288
|
-
let
|
|
1289
|
-
return
|
|
1290
|
-
changeSet:
|
|
1291
|
-
publishTime:
|
|
1292
|
-
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
|
|
1293
1324
|
};
|
|
1294
1325
|
},
|
|
1295
1326
|
async changeValidity({ releaseId: e, validityPeriod: n, changeSetName: r, idempotencyKey: i }) {
|
|
1296
|
-
return
|
|
1327
|
+
return B(i, [
|
|
1297
1328
|
"changeValidity",
|
|
1298
1329
|
e,
|
|
1299
1330
|
n,
|
|
1300
1331
|
r
|
|
1301
1332
|
], async () => {
|
|
1302
|
-
let i =
|
|
1303
|
-
if (!i) throw
|
|
1304
|
-
|
|
1333
|
+
let i = C.find((t) => (t.timeline ?? []).some((t) => t.releaseId === e));
|
|
1334
|
+
if (!i) throw D("Release", e);
|
|
1335
|
+
q(i);
|
|
1305
1336
|
let a = i.timeline ?? [], o = a.find((t) => t.releaseId === e);
|
|
1306
|
-
if (!o?.validityPeriod || !
|
|
1337
|
+
if (!o?.validityPeriod || !W(i)) throw new u("undated Releases carry no Validity Period");
|
|
1307
1338
|
let { firstDay: c, lastDay: l = "" } = n;
|
|
1308
|
-
if (!
|
|
1309
|
-
let d =
|
|
1310
|
-
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);
|
|
1311
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);
|
|
1312
|
-
if (p.length > 0) throw new
|
|
1313
|
-
let
|
|
1314
|
-
id: `rls_stub_${
|
|
1343
|
+
if (p.length > 0) throw new se(i.id, p, !0);
|
|
1344
|
+
let m = {
|
|
1345
|
+
id: `rls_stub_${V++}`,
|
|
1315
1346
|
contentId: i.id,
|
|
1316
1347
|
kind: "date_only",
|
|
1317
1348
|
branchId: "",
|
|
@@ -1325,68 +1356,68 @@ function M(y = {}) {
|
|
|
1325
1356
|
proposedForReleaseId: "",
|
|
1326
1357
|
splitFromReleaseId: "",
|
|
1327
1358
|
withheld: !1
|
|
1328
|
-
},
|
|
1329
|
-
id: `cs_stub_${
|
|
1359
|
+
}, h = {
|
|
1360
|
+
id: `cs_stub_${V++}`,
|
|
1330
1361
|
name: r?.trim() || `Change of validity of ${i.id}`,
|
|
1331
1362
|
state: "open",
|
|
1332
|
-
createdBy:
|
|
1333
|
-
createTime:
|
|
1363
|
+
createdBy: y,
|
|
1364
|
+
createTime: v(),
|
|
1334
1365
|
chains: [],
|
|
1335
1366
|
dependsOnChangeSetIds: [],
|
|
1336
1367
|
status: "",
|
|
1337
1368
|
assigneeIds: [],
|
|
1338
|
-
plannedReleases: [
|
|
1339
|
-
},
|
|
1340
|
-
if (
|
|
1341
|
-
let
|
|
1342
|
-
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 ? {
|
|
1343
1374
|
...t,
|
|
1344
|
-
releaseId:
|
|
1375
|
+
releaseId: m.id,
|
|
1345
1376
|
kind: "date_only",
|
|
1346
1377
|
validityPeriod: {
|
|
1347
1378
|
firstDay: c,
|
|
1348
1379
|
lastDay: l
|
|
1349
1380
|
},
|
|
1350
|
-
publishTime:
|
|
1381
|
+
publishTime: h.closeTime ?? v()
|
|
1351
1382
|
} : t), {
|
|
1352
|
-
changeSet:
|
|
1353
|
-
publishTime:
|
|
1354
|
-
releases:
|
|
1383
|
+
changeSet: O(h),
|
|
1384
|
+
publishTime: h.closeTime,
|
|
1385
|
+
releases: ee
|
|
1355
1386
|
};
|
|
1356
1387
|
});
|
|
1357
1388
|
},
|
|
1358
1389
|
async updateFromMain({ id: e, chainId: t, idempotencyKey: n }) {
|
|
1359
|
-
return
|
|
1390
|
+
return B(n, [
|
|
1360
1391
|
"updateFromMain",
|
|
1361
1392
|
e,
|
|
1362
1393
|
t
|
|
1363
1394
|
], async () => {
|
|
1364
|
-
let n =
|
|
1365
|
-
t ||
|
|
1395
|
+
let n = X(e);
|
|
1396
|
+
t || M(e);
|
|
1366
1397
|
let r = t ? n.chains.filter((e) => e.id === t) : n.chains;
|
|
1367
|
-
if (t && r.length === 0) throw
|
|
1368
|
-
let i = structuredClone(
|
|
1398
|
+
if (t && r.length === 0) throw D("Chain", t);
|
|
1399
|
+
let i = structuredClone(Ge[e] ?? []), a = [], o = [];
|
|
1369
1400
|
for (let t of r) for (let n of t.branches) {
|
|
1370
1401
|
let r = {
|
|
1371
1402
|
branchId: n.id,
|
|
1372
1403
|
contentId: t.contentId
|
|
1373
|
-
}, s =
|
|
1374
|
-
if (
|
|
1375
|
-
else if (s)
|
|
1376
|
-
else if (
|
|
1377
|
-
let r =
|
|
1378
|
-
|
|
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({
|
|
1379
1410
|
changeSetId: e,
|
|
1380
1411
|
chain: t,
|
|
1381
1412
|
branch: n,
|
|
1382
1413
|
c: r,
|
|
1383
|
-
data: structuredClone(
|
|
1414
|
+
data: structuredClone(K(r, n.headRevisionId) ?? {}),
|
|
1384
1415
|
cause: "merge"
|
|
1385
|
-
}),
|
|
1416
|
+
}), qe.delete(n.id), o.push(n.id);
|
|
1386
1417
|
}
|
|
1387
1418
|
}
|
|
1388
1419
|
return {
|
|
1389
|
-
changeSet:
|
|
1420
|
+
changeSet: O(n),
|
|
1390
1421
|
mergedBranchIds: o,
|
|
1391
1422
|
conflicted: i,
|
|
1392
1423
|
pending: a,
|
|
@@ -1395,27 +1426,27 @@ function M(y = {}) {
|
|
|
1395
1426
|
});
|
|
1396
1427
|
},
|
|
1397
1428
|
async discardChangeSet(e) {
|
|
1398
|
-
let t =
|
|
1399
|
-
return
|
|
1429
|
+
let t = X(e);
|
|
1430
|
+
return M(e), t.state = "discarded", t.closeTime = v(), t.chains = [], O(t);
|
|
1400
1431
|
},
|
|
1401
1432
|
async listCheckResults(e) {
|
|
1402
|
-
return
|
|
1403
|
-
},
|
|
1404
|
-
async recordCheckResult({ changeSetId: e, requiredCheckId: t, heads: n, outcome: r, note:
|
|
1405
|
-
let
|
|
1406
|
-
if (r === "waived" &&
|
|
1407
|
-
if ([...
|
|
1408
|
-
let s =
|
|
1409
|
-
if (!s) throw
|
|
1410
|
-
let c =
|
|
1411
|
-
if (
|
|
1412
|
-
let l =
|
|
1413
|
-
if (s.scope === "branch" &&
|
|
1414
|
-
if (s.scope === "change_set" &&
|
|
1415
|
-
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) {
|
|
1416
1447
|
let t = l.find((t) => t.key === e);
|
|
1417
|
-
if (!t) throw new
|
|
1418
|
-
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({
|
|
1419
1450
|
contentId: t.contentId,
|
|
1420
1451
|
branchId: t.branchless ? "" : t.key,
|
|
1421
1452
|
expectedHeadId: n[e],
|
|
@@ -1423,105 +1454,106 @@ function M(y = {}) {
|
|
|
1423
1454
|
});
|
|
1424
1455
|
}
|
|
1425
1456
|
let p = {
|
|
1426
|
-
id: `cr_stub_${
|
|
1457
|
+
id: `cr_stub_${V++}`,
|
|
1427
1458
|
requiredCheckId: t,
|
|
1428
1459
|
heads: { ...n },
|
|
1429
1460
|
outcome: r,
|
|
1430
|
-
note:
|
|
1431
|
-
recordedBy:
|
|
1432
|
-
recordTime:
|
|
1461
|
+
note: i,
|
|
1462
|
+
recordedBy: y,
|
|
1463
|
+
recordTime: v()
|
|
1433
1464
|
};
|
|
1434
|
-
return
|
|
1465
|
+
return Ue.push({
|
|
1435
1466
|
...p,
|
|
1436
1467
|
changeSetId: e
|
|
1437
1468
|
}), structuredClone(p);
|
|
1438
1469
|
},
|
|
1439
1470
|
async getEditingSettings() {
|
|
1440
|
-
let e = [...
|
|
1471
|
+
let e = [...L].sort((e, t) => e.blueprintAccessor < t.blueprintAccessor ? -1 : 1);
|
|
1441
1472
|
return {
|
|
1442
|
-
workspace: structuredClone(
|
|
1443
|
-
overrides: e.map(
|
|
1473
|
+
workspace: structuredClone(I),
|
|
1474
|
+
overrides: e.map(Le)
|
|
1444
1475
|
};
|
|
1445
1476
|
},
|
|
1446
1477
|
async getEffectiveEditingSettings(e) {
|
|
1447
|
-
let t =
|
|
1478
|
+
let t = L.find((t) => t.blueprintAccessor === e.trim());
|
|
1448
1479
|
return {
|
|
1449
|
-
effective:
|
|
1480
|
+
effective: R(t),
|
|
1450
1481
|
editingModeOverridden: (t?.editingMode ?? null) !== null,
|
|
1451
1482
|
editingBlockOverridden: (t?.editingBlock ?? null) !== null,
|
|
1452
1483
|
forceGroupOverridden: (t?.forceGroup ?? null) !== null,
|
|
1453
|
-
callerInForceGroup:
|
|
1484
|
+
callerInForceGroup: ze(R(t).forceGroup)
|
|
1454
1485
|
};
|
|
1455
1486
|
},
|
|
1456
1487
|
async setEditingSettings(e) {
|
|
1457
|
-
if (
|
|
1458
|
-
return
|
|
1488
|
+
if (He(), !Ve.includes(e.editingMode)) throw new u("the workspace's editing settings need an Editing Mode");
|
|
1489
|
+
return I = {
|
|
1459
1490
|
...e,
|
|
1460
|
-
forceGroup:
|
|
1461
|
-
}, structuredClone(
|
|
1491
|
+
forceGroup: Be(e.forceGroup)
|
|
1492
|
+
}, structuredClone(I);
|
|
1462
1493
|
},
|
|
1463
1494
|
async setBlueprintEditingOverride({ blueprintAccessor: e, editingMode: t, editingBlock: n, forceGroup: r }) {
|
|
1464
|
-
|
|
1465
|
-
let i =
|
|
1466
|
-
if (t === null && n === null && r === null) throw new
|
|
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]);
|
|
1467
1499
|
let a = {
|
|
1468
1500
|
blueprintAccessor: i,
|
|
1469
1501
|
editingMode: t,
|
|
1470
1502
|
editingBlock: n,
|
|
1471
|
-
forceGroup: r === null ? null :
|
|
1503
|
+
forceGroup: r === null ? null : Be(r)
|
|
1472
1504
|
};
|
|
1473
|
-
return
|
|
1505
|
+
return L = [...L.filter((e) => e.blueprintAccessor !== i), a], Le(a);
|
|
1474
1506
|
},
|
|
1475
1507
|
async deleteBlueprintEditingOverride({ blueprintAccessor: e }) {
|
|
1476
|
-
|
|
1508
|
+
He();
|
|
1477
1509
|
let t = e.trim();
|
|
1478
|
-
if (!
|
|
1479
|
-
|
|
1510
|
+
if (!L.some((e) => e.blueprintAccessor === t)) throw D("an editing override of", t);
|
|
1511
|
+
L = L.filter((e) => e.blueprintAccessor !== t);
|
|
1480
1512
|
},
|
|
1481
1513
|
async listRequiredChecks() {
|
|
1482
1514
|
let e = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
|
|
1483
|
-
return structuredClone([...
|
|
1515
|
+
return structuredClone([...A].sort(e));
|
|
1484
1516
|
},
|
|
1485
1517
|
async createRequiredCheck(e) {
|
|
1486
|
-
let t =
|
|
1487
|
-
if (
|
|
1488
|
-
let
|
|
1489
|
-
id: `rc_stub_${
|
|
1490
|
-
...
|
|
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
|
|
1491
1523
|
};
|
|
1492
|
-
return
|
|
1524
|
+
return A.push(i), structuredClone(i);
|
|
1493
1525
|
},
|
|
1494
1526
|
async updateRequiredCheck({ id: e, ...t }) {
|
|
1495
|
-
let r =
|
|
1496
|
-
if (!
|
|
1497
|
-
if (
|
|
1498
|
-
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);
|
|
1499
1531
|
},
|
|
1500
1532
|
async deleteRequiredCheck({ id: e }) {
|
|
1501
|
-
if (!
|
|
1502
|
-
|
|
1533
|
+
if (!A.some((t) => t.id === e)) throw D("Required Check", e);
|
|
1534
|
+
A = A.filter((t) => t.id !== e), P.delete(e);
|
|
1503
1535
|
},
|
|
1504
1536
|
async listRequiredCheckRecorders(e) {
|
|
1505
|
-
return structuredClone(
|
|
1537
|
+
return structuredClone(at(e));
|
|
1506
1538
|
},
|
|
1507
1539
|
async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1508
|
-
let n =
|
|
1540
|
+
let n = at(e);
|
|
1509
1541
|
if ("everyMember" in t) {
|
|
1510
|
-
|
|
1542
|
+
P.set(e, {
|
|
1511
1543
|
...n,
|
|
1512
1544
|
everyMember: !0
|
|
1513
1545
|
});
|
|
1514
1546
|
return;
|
|
1515
1547
|
}
|
|
1516
|
-
if (!
|
|
1517
|
-
|
|
1548
|
+
if (!Fe.includes(t.userId)) throw new u(`user ${t.userId} is not a member of the workspace`);
|
|
1549
|
+
P.set(e, {
|
|
1518
1550
|
...n,
|
|
1519
1551
|
userIds: [.../* @__PURE__ */ new Set([...n.userIds, t.userId])].sort()
|
|
1520
1552
|
});
|
|
1521
1553
|
},
|
|
1522
1554
|
async revokeRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1523
|
-
let n =
|
|
1524
|
-
|
|
1555
|
+
let n = at(e);
|
|
1556
|
+
P.set(e, "everyMember" in t ? {
|
|
1525
1557
|
...n,
|
|
1526
1558
|
everyMember: !1
|
|
1527
1559
|
} : {
|
|
@@ -1529,25 +1561,23 @@ function M(y = {}) {
|
|
|
1529
1561
|
userIds: n.userIds.filter((e) => e !== t.userId)
|
|
1530
1562
|
});
|
|
1531
1563
|
},
|
|
1532
|
-
async searchBlueprints({ query: e }) {
|
|
1533
|
-
let
|
|
1564
|
+
async searchBlueprints({ query: e, includeWithoutRelease: t = !1 }) {
|
|
1565
|
+
let n = e.trim().toLocaleLowerCase();
|
|
1534
1566
|
return {
|
|
1535
|
-
blueprints:
|
|
1536
|
-
id: e.id,
|
|
1537
|
-
name: e.name
|
|
1538
|
-
})),
|
|
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),
|
|
1539
1568
|
nextPageToken: ""
|
|
1540
1569
|
};
|
|
1541
1570
|
},
|
|
1542
1571
|
async getBlueprints(e) {
|
|
1543
|
-
if (e.length > 1e3) throw new
|
|
1544
|
-
return
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
})
|
|
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);
|
|
1548
1578
|
},
|
|
1549
1579
|
async listBlueprintReleases(e) {
|
|
1550
|
-
return
|
|
1580
|
+
return be.filter((t) => t.blueprintId === e).map((e) => ({
|
|
1551
1581
|
id: e.id,
|
|
1552
1582
|
blueprintId: e.blueprintId,
|
|
1553
1583
|
name: e.name ?? e.id,
|
|
@@ -1556,94 +1586,94 @@ function M(y = {}) {
|
|
|
1556
1586
|
}));
|
|
1557
1587
|
},
|
|
1558
1588
|
async listCollections() {
|
|
1559
|
-
return [...
|
|
1560
|
-
},
|
|
1561
|
-
async createCollection({ name:
|
|
1562
|
-
let
|
|
1563
|
-
if (
|
|
1564
|
-
if (
|
|
1565
|
-
let
|
|
1566
|
-
id: `col_stub_${
|
|
1567
|
-
name:
|
|
1568
|
-
parentId:
|
|
1569
|
-
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
|
|
1570
1600
|
};
|
|
1571
|
-
return
|
|
1572
|
-
userId:
|
|
1601
|
+
return S.push(o), i && N.set(o.id, [{
|
|
1602
|
+
userId: y,
|
|
1573
1603
|
level: "owner"
|
|
1574
|
-
}]), { ...
|
|
1604
|
+
}]), { ...o };
|
|
1575
1605
|
},
|
|
1576
1606
|
async renameCollection({ id: e, name: t }) {
|
|
1577
|
-
let r =
|
|
1578
|
-
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);
|
|
1579
1609
|
return i.name = r, { ...i };
|
|
1580
1610
|
},
|
|
1581
1611
|
async moveCollection({ id: e, parentId: t }) {
|
|
1582
|
-
let r =
|
|
1583
|
-
for (let n = t; n !== ""; n =
|
|
1584
|
-
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("");
|
|
1585
1615
|
return r.parentId = t, { ...r };
|
|
1586
1616
|
},
|
|
1587
1617
|
async removeCollection({ id: e }) {
|
|
1588
|
-
if (
|
|
1589
|
-
|
|
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);
|
|
1590
1620
|
let t = [];
|
|
1591
|
-
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));
|
|
1592
1622
|
return t;
|
|
1593
1623
|
},
|
|
1594
|
-
async setCollectionRestricted({ id:
|
|
1595
|
-
if (
|
|
1596
|
-
let
|
|
1597
|
-
if (
|
|
1598
|
-
if (!
|
|
1599
|
-
return
|
|
1600
|
-
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,
|
|
1601
1631
|
level: "owner"
|
|
1602
|
-
}]) :
|
|
1632
|
+
}]) : N.delete(t), { ...i };
|
|
1603
1633
|
},
|
|
1604
1634
|
async listCollectionGrants(e) {
|
|
1605
|
-
return
|
|
1635
|
+
return it(e), structuredClone(N.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
|
|
1606
1636
|
},
|
|
1607
1637
|
async grantCollectionAccess({ collectionId: e, userId: t, level: n }) {
|
|
1608
|
-
if (
|
|
1609
|
-
if (!
|
|
1610
|
-
let r =
|
|
1611
|
-
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), {
|
|
1612
1642
|
userId: t,
|
|
1613
1643
|
level: n
|
|
1614
1644
|
}]);
|
|
1615
1645
|
},
|
|
1616
1646
|
async revokeCollectionAccess({ collectionId: e, userId: t }) {
|
|
1617
|
-
|
|
1647
|
+
it(e), N.set(e, (N.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
|
|
1618
1648
|
},
|
|
1619
1649
|
async listContents(e = {}) {
|
|
1620
1650
|
let t = e.view ?? { kind: "main" }, n = (e.search ?? "").trim();
|
|
1621
|
-
if (n !== "" && t.kind === "in_force") throw new
|
|
1622
|
-
if ([...n].length > 200) throw new
|
|
1623
|
-
if (e.collectionId && !
|
|
1624
|
-
t.kind === "change_set" &&
|
|
1625
|
-
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;
|
|
1626
1656
|
return {
|
|
1627
1657
|
contents: r.slice(a, a + i),
|
|
1628
1658
|
nextPageToken: a + i < r.length ? String(a + i) : ""
|
|
1629
1659
|
};
|
|
1630
1660
|
},
|
|
1631
1661
|
async createContent({ changeSetId: e, blueprintReleaseId: t, copyFrom: n }) {
|
|
1632
|
-
let r =
|
|
1662
|
+
let r = X(e), i = {}, a = t;
|
|
1633
1663
|
if (n) {
|
|
1634
|
-
let e = "revisionId" in n ? n.revisionId :
|
|
1635
|
-
if (!r || !e) throw
|
|
1636
|
-
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;
|
|
1637
1667
|
}
|
|
1638
|
-
let o =
|
|
1639
|
-
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`, [{
|
|
1640
1670
|
source: "contenthub",
|
|
1641
1671
|
code: "release_not_found",
|
|
1642
1672
|
path: ""
|
|
1643
1673
|
}]);
|
|
1644
|
-
if (o.refusals?.length) throw new
|
|
1645
|
-
let s =
|
|
1646
|
-
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({
|
|
1647
1677
|
id: c,
|
|
1648
1678
|
blueprintId: o.blueprintId,
|
|
1649
1679
|
blueprintReleaseId: a,
|
|
@@ -1652,7 +1682,7 @@ function M(y = {}) {
|
|
|
1652
1682
|
branchId: l,
|
|
1653
1683
|
revisionId: u,
|
|
1654
1684
|
data: i,
|
|
1655
|
-
revisionCreateTime:
|
|
1685
|
+
revisionCreateTime: v()
|
|
1656
1686
|
} }
|
|
1657
1687
|
}), r.chains.push({
|
|
1658
1688
|
id: `chain_stub_${s}`,
|
|
@@ -1672,35 +1702,35 @@ function M(y = {}) {
|
|
|
1672
1702
|
data: structuredClone(i),
|
|
1673
1703
|
changeSetId: e,
|
|
1674
1704
|
branchId: l,
|
|
1675
|
-
revisionCreateTime:
|
|
1705
|
+
revisionCreateTime: v(),
|
|
1676
1706
|
releaseId: ""
|
|
1677
1707
|
};
|
|
1678
1708
|
},
|
|
1679
1709
|
async saveRevision({ idempotencyKey: e, ...t }) {
|
|
1680
|
-
if (!e) return
|
|
1681
|
-
let n = JSON.stringify(t), r =
|
|
1710
|
+
if (!e) return ot(t);
|
|
1711
|
+
let n = JSON.stringify(t), r = Xe.get(e);
|
|
1682
1712
|
if (r) {
|
|
1683
|
-
if (r.asked !== n) throw new
|
|
1713
|
+
if (r.asked !== n) throw new u(`idempotency key ${e} names another save`);
|
|
1684
1714
|
return structuredClone(r.content);
|
|
1685
1715
|
}
|
|
1686
|
-
let i = await
|
|
1687
|
-
return
|
|
1716
|
+
let i = await ot(t);
|
|
1717
|
+
return Xe.set(e, {
|
|
1688
1718
|
asked: n,
|
|
1689
1719
|
content: structuredClone(i)
|
|
1690
1720
|
}), i;
|
|
1691
1721
|
},
|
|
1692
1722
|
async getContent({ id: e, changeSetId: t, branchId: n }) {
|
|
1693
|
-
let r =
|
|
1723
|
+
let r = H(e), i = t ? {
|
|
1694
1724
|
kind: "change_set",
|
|
1695
1725
|
changeSetId: t
|
|
1696
1726
|
} : { kind: "main" };
|
|
1697
|
-
if (n && !t) throw new
|
|
1698
|
-
let [a] =
|
|
1699
|
-
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);
|
|
1700
1730
|
if (n && n !== a.branchId) {
|
|
1701
|
-
let i =
|
|
1702
|
-
if (!i) throw
|
|
1703
|
-
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 : {});
|
|
1704
1734
|
a = {
|
|
1705
1735
|
...a,
|
|
1706
1736
|
revisionId: i.headRevisionId,
|
|
@@ -1709,15 +1739,15 @@ function M(y = {}) {
|
|
|
1709
1739
|
revisionCreateTime: o?.createTime ?? a.revisionCreateTime
|
|
1710
1740
|
};
|
|
1711
1741
|
}
|
|
1712
|
-
let o =
|
|
1742
|
+
let o = T[r.blueprintReleaseId];
|
|
1713
1743
|
return {
|
|
1714
1744
|
content: a,
|
|
1715
1745
|
blueprintRelease: o ? structuredClone(o) : void 0,
|
|
1716
|
-
attributes:
|
|
1746
|
+
attributes: U(r)
|
|
1717
1747
|
};
|
|
1718
1748
|
},
|
|
1719
1749
|
async getTimeline(e) {
|
|
1720
|
-
let t =
|
|
1750
|
+
let t = H(e), n = (e) => x.find((t) => t.id === e)?.state === "open";
|
|
1721
1751
|
return structuredClone({
|
|
1722
1752
|
entries: t.timeline ?? [],
|
|
1723
1753
|
plannedReleases: (t.plannedReleases ?? []).filter((e) => n(e.changeSetId))
|
|
@@ -1726,13 +1756,13 @@ function M(y = {}) {
|
|
|
1726
1756
|
async listRevisions({ target: e, pageSize: t, pageToken: n }) {
|
|
1727
1757
|
let r;
|
|
1728
1758
|
if ("contentId" in e) {
|
|
1729
|
-
let t =
|
|
1730
|
-
if (!t.main) throw
|
|
1731
|
-
r =
|
|
1759
|
+
let t = H(e.contentId);
|
|
1760
|
+
if (!t.main) throw D("Content", e.contentId);
|
|
1761
|
+
r = G(t);
|
|
1732
1762
|
} else {
|
|
1733
|
-
let t =
|
|
1734
|
-
if (!t) throw
|
|
1735
|
-
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);
|
|
1736
1766
|
}
|
|
1737
1767
|
let i = Math.min(t || 50, 200), a = n ? Number(n) : 0;
|
|
1738
1768
|
return {
|
|
@@ -1741,17 +1771,17 @@ function M(y = {}) {
|
|
|
1741
1771
|
};
|
|
1742
1772
|
},
|
|
1743
1773
|
async compare({ revisionId: e, base: t }) {
|
|
1744
|
-
let n =
|
|
1745
|
-
if (!n) throw
|
|
1746
|
-
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;
|
|
1747
1777
|
if (t.kind === "revision") a = t.revisionId;
|
|
1748
1778
|
else if (t.kind === "main_head") {
|
|
1749
|
-
if (!n.main) throw new
|
|
1779
|
+
if (!n.main) throw new u("the Content is not published: it has no Main Branch");
|
|
1750
1780
|
a = n.main.revisionId;
|
|
1751
1781
|
} else a = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
|
|
1752
1782
|
let o = r.find((e) => e.id === a);
|
|
1753
|
-
if (!o) throw
|
|
1754
|
-
let s =
|
|
1783
|
+
if (!o) throw D("Revision", a);
|
|
1784
|
+
let s = K(n, i.id) ?? {}, c = K(n, o.id) ?? {}, l = [];
|
|
1755
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({
|
|
1756
1786
|
path: `/${e}`,
|
|
1757
1787
|
kind: "changed",
|
|
@@ -1766,32 +1796,32 @@ function M(y = {}) {
|
|
|
1766
1796
|
kind: "added",
|
|
1767
1797
|
after: s[e]
|
|
1768
1798
|
});
|
|
1769
|
-
let
|
|
1799
|
+
let d = ({ data: e, ...t }) => t;
|
|
1770
1800
|
return {
|
|
1771
|
-
base:
|
|
1772
|
-
revision:
|
|
1801
|
+
base: d(o),
|
|
1802
|
+
revision: d(i),
|
|
1773
1803
|
changes: l
|
|
1774
1804
|
};
|
|
1775
1805
|
},
|
|
1776
1806
|
async listReferences({ contentId: e, revisionId: t }) {
|
|
1777
|
-
return (
|
|
1807
|
+
return (H(e).edges ?? []).filter((e) => e.sourceRevisionId === t).map((e) => ({ ...e }));
|
|
1778
1808
|
},
|
|
1779
1809
|
async listReferrers({ contentId: e, includeOpenChangeSets: t, pageSize: n, pageToken: r }) {
|
|
1780
|
-
|
|
1810
|
+
H(e);
|
|
1781
1811
|
let i = (e) => {
|
|
1782
1812
|
let t = Math.min(n || 100, 1e3), i = r ? Number(r) : 0;
|
|
1783
1813
|
return {
|
|
1784
1814
|
referrers: e.slice(i, i + t),
|
|
1785
1815
|
nextPageToken: i + t < e.length ? String(i + t) : ""
|
|
1786
1816
|
};
|
|
1787
|
-
}, a =
|
|
1817
|
+
}, a = C.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
|
|
1788
1818
|
edge: { ...e },
|
|
1789
1819
|
releaseId: t.inForce?.releaseId ?? "",
|
|
1790
1820
|
changeSetId: "",
|
|
1791
1821
|
branchId: ""
|
|
1792
1822
|
})));
|
|
1793
1823
|
if (!t) return i(a);
|
|
1794
|
-
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) => ({
|
|
1795
1825
|
edge: { ...e },
|
|
1796
1826
|
releaseId: "",
|
|
1797
1827
|
changeSetId: n,
|
|
@@ -1803,14 +1833,14 @@ function M(y = {}) {
|
|
|
1803
1833
|
let t;
|
|
1804
1834
|
if ("revisionId" in e) t = e.revisionId;
|
|
1805
1835
|
else {
|
|
1806
|
-
for (let n of
|
|
1836
|
+
for (let n of C) {
|
|
1807
1837
|
let r = Object.values(n.branches).find((t) => t.branchId === e.branchId);
|
|
1808
1838
|
r && (t = r.revisionId);
|
|
1809
1839
|
}
|
|
1810
|
-
if (!t) throw
|
|
1840
|
+
if (!t) throw D("Branch", e.branchId);
|
|
1811
1841
|
}
|
|
1812
|
-
return
|
|
1813
|
-
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 ?? "";
|
|
1814
1844
|
return t === e.pinReleaseId ? [] : [{
|
|
1815
1845
|
edge: { ...e },
|
|
1816
1846
|
supersededByReleaseId: t,
|
|
@@ -1819,104 +1849,104 @@ function M(y = {}) {
|
|
|
1819
1849
|
});
|
|
1820
1850
|
},
|
|
1821
1851
|
async setContentCollections({ contentId: e, collectionIds: t }) {
|
|
1822
|
-
let n =
|
|
1823
|
-
if (r.length > 100) throw new
|
|
1824
|
-
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);
|
|
1825
1855
|
return n.collectionIds = r.sort(), [...n.collectionIds];
|
|
1826
1856
|
},
|
|
1827
1857
|
async setContentAssignees({ contentId: e, assigneeIds: t }) {
|
|
1828
|
-
let n =
|
|
1829
|
-
if (new Set(t).size !== t.length) throw new
|
|
1830
|
-
if (t.length > 50) throw new
|
|
1831
|
-
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);
|
|
1832
1862
|
},
|
|
1833
1863
|
async blockContent({ contentId: e, blockReasonId: t, allowedUserIds: n }) {
|
|
1834
|
-
let r =
|
|
1835
|
-
if (!
|
|
1836
|
-
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");
|
|
1837
1867
|
return r.block = {
|
|
1838
1868
|
blockReasonId: t,
|
|
1839
1869
|
allowedUserIds: [...n],
|
|
1840
|
-
blockedBy:
|
|
1841
|
-
blockTime:
|
|
1842
|
-
},
|
|
1870
|
+
blockedBy: y,
|
|
1871
|
+
blockTime: v()
|
|
1872
|
+
}, U(r);
|
|
1843
1873
|
},
|
|
1844
1874
|
async unblockContent(e) {
|
|
1845
|
-
let t =
|
|
1846
|
-
if (!t.block && t.editingBlock) throw new
|
|
1847
|
-
return t.block = void 0,
|
|
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);
|
|
1848
1878
|
},
|
|
1849
1879
|
async archiveContent(e) {
|
|
1850
|
-
let t =
|
|
1851
|
-
if (t.archiveTime) return
|
|
1852
|
-
if (!t.main) throw new
|
|
1853
|
-
if (
|
|
1854
|
-
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);
|
|
1855
1885
|
},
|
|
1856
1886
|
async unarchiveContent(e) {
|
|
1857
|
-
let t =
|
|
1858
|
-
return t.archiveTime = void 0,
|
|
1887
|
+
let t = H(e);
|
|
1888
|
+
return t.archiveTime = void 0, U(t);
|
|
1859
1889
|
},
|
|
1860
|
-
async openDirectEdit({ contentId: e, effectiveOn:
|
|
1861
|
-
return
|
|
1890
|
+
async openDirectEdit({ contentId: e, effectiveOn: n, idempotencyKey: r }) {
|
|
1891
|
+
return B(r, [
|
|
1862
1892
|
"openDirectEdit",
|
|
1863
1893
|
e,
|
|
1864
|
-
|
|
1894
|
+
n
|
|
1865
1895
|
], async () => {
|
|
1866
|
-
let
|
|
1867
|
-
if (
|
|
1868
|
-
let [e] =
|
|
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, {
|
|
1869
1899
|
kind: "change_set",
|
|
1870
|
-
changeSetId:
|
|
1900
|
+
changeSetId: i.id
|
|
1871
1901
|
}, "");
|
|
1872
1902
|
return {
|
|
1873
|
-
changeSet:
|
|
1903
|
+
changeSet: O(i),
|
|
1874
1904
|
content: e,
|
|
1875
1905
|
reopened: !0
|
|
1876
1906
|
};
|
|
1877
1907
|
}
|
|
1878
|
-
let
|
|
1879
|
-
if (!
|
|
1880
|
-
let
|
|
1881
|
-
if (
|
|
1882
|
-
if (
|
|
1883
|
-
let
|
|
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({
|
|
1884
1914
|
contentId: e,
|
|
1885
1915
|
changeSetName: `Direct Edit of ${e}`,
|
|
1886
|
-
effectiveOn:
|
|
1887
|
-
}),
|
|
1888
|
-
|
|
1889
|
-
let
|
|
1890
|
-
if (
|
|
1891
|
-
let e =
|
|
1892
|
-
|
|
1893
|
-
for (let t of e) !t.validityPeriod || t.validityPeriod.firstDay <=
|
|
1894
|
-
id: `br_stub_${
|
|
1895
|
-
position:
|
|
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,
|
|
1896
1926
|
kind: "carry_forward",
|
|
1897
1927
|
headRevisionId: t.revisionId,
|
|
1898
1928
|
effectiveOn: t.validityPeriod.firstDay,
|
|
1899
1929
|
carriedReleaseId: t.releaseId
|
|
1900
1930
|
});
|
|
1901
1931
|
}
|
|
1902
|
-
return
|
|
1903
|
-
editorId:
|
|
1904
|
-
changeSetId:
|
|
1905
|
-
blockTime:
|
|
1932
|
+
return s.editingBlock && (r.editingBlock = {
|
|
1933
|
+
editorId: y,
|
|
1934
|
+
changeSetId: p.id,
|
|
1935
|
+
blockTime: v()
|
|
1906
1936
|
}), {
|
|
1907
|
-
changeSet:
|
|
1908
|
-
content:
|
|
1937
|
+
changeSet: O(p),
|
|
1938
|
+
content: f.content,
|
|
1909
1939
|
reopened: !1
|
|
1910
1940
|
};
|
|
1911
1941
|
});
|
|
1912
1942
|
},
|
|
1913
1943
|
async previewDirectEditPublish({ id: e, validityLastDay: t }) {
|
|
1914
|
-
let n =
|
|
1915
|
-
if (n.kind !== "direct_edit") throw new
|
|
1916
|
-
return structuredClone(
|
|
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));
|
|
1917
1947
|
},
|
|
1918
1948
|
async publishDirectEdit({ id: e, expectedHeadId: t, releaseSpec: n, validityLastDay: r, carryForward: i, idempotencyKey: a }) {
|
|
1919
|
-
return
|
|
1949
|
+
return B(a, [
|
|
1920
1950
|
"publishDirectEdit",
|
|
1921
1951
|
e,
|
|
1922
1952
|
t,
|
|
@@ -1924,24 +1954,24 @@ function M(y = {}) {
|
|
|
1924
1954
|
r,
|
|
1925
1955
|
i
|
|
1926
1956
|
], async () => {
|
|
1927
|
-
let a =
|
|
1928
|
-
if (a.kind !== "direct_edit") throw new
|
|
1929
|
-
let o =
|
|
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 = {
|
|
1930
1960
|
cs: structuredClone(a),
|
|
1931
1961
|
c: structuredClone(o)
|
|
1932
1962
|
};
|
|
1933
1963
|
try {
|
|
1934
|
-
return await
|
|
1964
|
+
return await St(a, t, n, {
|
|
1935
1965
|
validityLastDay: r,
|
|
1936
1966
|
carryForward: i
|
|
1937
1967
|
});
|
|
1938
1968
|
} catch (e) {
|
|
1939
|
-
throw
|
|
1969
|
+
throw bt(a, s.cs), bt(o, s.c), e;
|
|
1940
1970
|
}
|
|
1941
1971
|
});
|
|
1942
1972
|
},
|
|
1943
1973
|
async saveAndPublishDirectEdit({ id: e, expectedHeadId: t, data: n, fieldMask: r, releaseSpec: i, validityLastDay: a, carryForward: o, idempotencyKey: s }) {
|
|
1944
|
-
return
|
|
1974
|
+
return B(s, [
|
|
1945
1975
|
"saveAndPublishDirectEdit",
|
|
1946
1976
|
e,
|
|
1947
1977
|
t,
|
|
@@ -1951,16 +1981,16 @@ function M(y = {}) {
|
|
|
1951
1981
|
a,
|
|
1952
1982
|
o
|
|
1953
1983
|
], async () => {
|
|
1954
|
-
let s =
|
|
1955
|
-
if (s.kind !== "direct_edit") throw new
|
|
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`);
|
|
1956
1986
|
let c = s.chains[0]?.branches[0];
|
|
1957
1987
|
if (!c) throw Error(`Direct Edit ${e} has no Branch`);
|
|
1958
|
-
let
|
|
1988
|
+
let u = H(s.chains[0]?.contentId ?? ""), d = {
|
|
1959
1989
|
cs: structuredClone(s),
|
|
1960
|
-
c: structuredClone(
|
|
1990
|
+
c: structuredClone(u)
|
|
1961
1991
|
};
|
|
1962
1992
|
try {
|
|
1963
|
-
let l = await
|
|
1993
|
+
let l = await ot({
|
|
1964
1994
|
changeSetId: e,
|
|
1965
1995
|
branchId: c.id,
|
|
1966
1996
|
expectedHeadId: t,
|
|
@@ -1969,76 +1999,76 @@ function M(y = {}) {
|
|
|
1969
1999
|
});
|
|
1970
2000
|
return {
|
|
1971
2001
|
content: l,
|
|
1972
|
-
outcome: await
|
|
2002
|
+
outcome: await St(s, l.revisionId, i, {
|
|
1973
2003
|
validityLastDay: a,
|
|
1974
2004
|
carryForward: o
|
|
1975
2005
|
})
|
|
1976
2006
|
};
|
|
1977
2007
|
} catch (e) {
|
|
1978
|
-
throw
|
|
2008
|
+
throw bt(s, d.cs), bt(u, d.c), e;
|
|
1979
2009
|
}
|
|
1980
2010
|
});
|
|
1981
2011
|
},
|
|
1982
2012
|
async discardDirectEdit({ id: e, idempotencyKey: t }) {
|
|
1983
|
-
return
|
|
1984
|
-
if (
|
|
1985
|
-
let t = await
|
|
1986
|
-
for (let t of
|
|
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);
|
|
1987
2017
|
return t;
|
|
1988
2018
|
});
|
|
1989
2019
|
},
|
|
1990
2020
|
async forceDirectEdit({ id: e, idempotencyKey: t }) {
|
|
1991
|
-
return
|
|
1992
|
-
let t =
|
|
1993
|
-
if (t.kind !== "direct_edit") throw new
|
|
1994
|
-
let n = t.chains[0]?.contentId ?? "", r =
|
|
1995
|
-
if (t.state !== "open" || r.editingBlock?.changeSetId !== e) throw new
|
|
1996
|
-
let i =
|
|
1997
|
-
if (!
|
|
1998
|
-
let a =
|
|
1999
|
-
if (a) throw new
|
|
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);
|
|
2000
2030
|
let o = t.editorId ?? "";
|
|
2001
|
-
t.editorId =
|
|
2002
|
-
editorId:
|
|
2031
|
+
t.editorId = y, r.editingBlock = {
|
|
2032
|
+
editorId: y,
|
|
2003
2033
|
changeSetId: e,
|
|
2004
|
-
blockTime:
|
|
2034
|
+
blockTime: v()
|
|
2005
2035
|
};
|
|
2006
|
-
let [s] =
|
|
2036
|
+
let [s] = $(r, {
|
|
2007
2037
|
kind: "change_set",
|
|
2008
2038
|
changeSetId: e
|
|
2009
2039
|
}, "");
|
|
2010
2040
|
return {
|
|
2011
|
-
changeSet:
|
|
2041
|
+
changeSet: O(t),
|
|
2012
2042
|
content: s,
|
|
2013
2043
|
previousEditorId: o
|
|
2014
2044
|
};
|
|
2015
2045
|
});
|
|
2016
2046
|
},
|
|
2017
2047
|
async startEditing({ contentId: e, changeSetId: t, effectiveOn: n = "", changeSetName: r = "" }) {
|
|
2018
|
-
let i =
|
|
2019
|
-
if (!i.main) throw new
|
|
2020
|
-
if (
|
|
2021
|
-
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");
|
|
2022
2052
|
let a;
|
|
2023
2053
|
if (t) {
|
|
2024
|
-
if (a =
|
|
2025
|
-
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`);
|
|
2026
2056
|
} else {
|
|
2027
2057
|
let t = Object.values(i.main.data).filter((e) => typeof e == "string").slice(0, 2).join(" ");
|
|
2028
2058
|
a = {
|
|
2029
|
-
id: `cs_stub_${
|
|
2030
|
-
name: r.trim() ?
|
|
2059
|
+
id: `cs_stub_${V++}`,
|
|
2060
|
+
name: r.trim() ? E(r, "change_set_name", 200) : t || e,
|
|
2031
2061
|
state: "open",
|
|
2032
|
-
createdBy:
|
|
2033
|
-
createTime:
|
|
2062
|
+
createdBy: y,
|
|
2063
|
+
createTime: v(),
|
|
2034
2064
|
chains: [],
|
|
2035
2065
|
dependsOnChangeSetIds: [],
|
|
2036
2066
|
status: "",
|
|
2037
2067
|
assigneeIds: [],
|
|
2038
2068
|
plannedReleases: []
|
|
2039
|
-
},
|
|
2069
|
+
}, x.unshift(a);
|
|
2040
2070
|
}
|
|
2041
|
-
let o =
|
|
2071
|
+
let o = V++, s = `br_stub_${o}`, c = {
|
|
2042
2072
|
...structuredClone(i.main),
|
|
2043
2073
|
branchId: s
|
|
2044
2074
|
};
|
|
@@ -2053,21 +2083,21 @@ function M(y = {}) {
|
|
|
2053
2083
|
headRevisionId: c.revisionId
|
|
2054
2084
|
}]
|
|
2055
2085
|
});
|
|
2056
|
-
let [
|
|
2086
|
+
let [d] = $(i, {
|
|
2057
2087
|
kind: "change_set",
|
|
2058
2088
|
changeSetId: a.id
|
|
2059
2089
|
}, "");
|
|
2060
2090
|
return {
|
|
2061
|
-
changeSet:
|
|
2062
|
-
content:
|
|
2091
|
+
changeSet: O(a),
|
|
2092
|
+
content: d
|
|
2063
2093
|
};
|
|
2064
2094
|
},
|
|
2065
2095
|
async previewChain({ changeSetId: e, contentId: t, effectiveOn: n, validityPeriod: r }) {
|
|
2066
|
-
|
|
2067
|
-
let i =
|
|
2068
|
-
if (!i.main) throw new
|
|
2069
|
-
if (!
|
|
2070
|
-
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");
|
|
2071
2101
|
let a = i.timeline ?? [], o = a.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
|
|
2072
2102
|
return {
|
|
2073
2103
|
forkReleaseId: o?.releaseId ?? "",
|
|
@@ -2078,31 +2108,31 @@ function M(y = {}) {
|
|
|
2078
2108
|
};
|
|
2079
2109
|
},
|
|
2080
2110
|
async planRepeal({ changeSetId: e, contentId: t, lastDay: n }) {
|
|
2081
|
-
|
|
2082
|
-
let r =
|
|
2083
|
-
if (
|
|
2084
|
-
if (!
|
|
2085
|
-
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, {
|
|
2086
2116
|
kind: "repeal",
|
|
2087
2117
|
validityPeriod: {
|
|
2088
|
-
firstDay:
|
|
2118
|
+
firstDay: ee(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
|
|
2089
2119
|
lastDay: n
|
|
2090
2120
|
}
|
|
2091
2121
|
});
|
|
2092
2122
|
},
|
|
2093
2123
|
async planWithdrawal({ changeSetId: e, contentId: t }) {
|
|
2094
|
-
|
|
2095
|
-
let n =
|
|
2096
|
-
if (
|
|
2097
|
-
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" });
|
|
2098
2128
|
},
|
|
2099
2129
|
async planRelease({ idempotencyKey: e, ...t }) {
|
|
2100
|
-
return
|
|
2101
|
-
let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, { cs: o, chain: s, branch: c, c: l } =
|
|
2102
|
-
if (
|
|
2103
|
-
if (o.plannedReleases.some((e) => e.branchId === n)) throw new
|
|
2104
|
-
let
|
|
2105
|
-
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++}`,
|
|
2106
2136
|
contentId: s.contentId,
|
|
2107
2137
|
kind: "revision",
|
|
2108
2138
|
branchId: n,
|
|
@@ -2115,35 +2145,35 @@ function M(y = {}) {
|
|
|
2115
2145
|
splitFromReleaseId: "",
|
|
2116
2146
|
withheld: !1
|
|
2117
2147
|
};
|
|
2118
|
-
return
|
|
2148
|
+
return dt(l, d), o.plannedReleases.push(d), ft(o, l), structuredClone(d);
|
|
2119
2149
|
});
|
|
2120
2150
|
},
|
|
2121
2151
|
async updatePlannedRelease({ idempotencyKey: e, ...t }) {
|
|
2122
|
-
return
|
|
2123
|
-
let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, o =
|
|
2124
|
-
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);
|
|
2125
2155
|
let c = o.plannedReleases[s];
|
|
2126
|
-
if (c.proposed) throw new
|
|
2127
|
-
let l =
|
|
2128
|
-
|
|
2129
|
-
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 = {
|
|
2130
2160
|
...structuredClone(c),
|
|
2131
2161
|
...r ? { validityPeriod: { ...r } } : {},
|
|
2132
2162
|
...i ? { releaseSpec: structuredClone(i) } : {},
|
|
2133
2163
|
...a ? { supersedesReleaseIds: [...a] } : {}
|
|
2134
2164
|
};
|
|
2135
|
-
return
|
|
2165
|
+
return dt(l, d), o.plannedReleases[s] = d, ft(o, l), structuredClone(d);
|
|
2136
2166
|
});
|
|
2137
2167
|
},
|
|
2138
2168
|
async appendBranch({ idempotencyKey: e, ...t }) {
|
|
2139
|
-
return
|
|
2140
|
-
let { changeSetId: e, chainId: n, effectiveOn: r } = t, i =
|
|
2141
|
-
if (!a) throw
|
|
2142
|
-
let o =
|
|
2143
|
-
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");
|
|
2144
2174
|
let s = a.branches.filter((e) => e.kind === "editorial").at(-1);
|
|
2145
|
-
if (!
|
|
2146
|
-
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++}`;
|
|
2147
2177
|
a.branches.push({
|
|
2148
2178
|
id: l,
|
|
2149
2179
|
position: a.branches.length,
|
|
@@ -2151,66 +2181,66 @@ function M(y = {}) {
|
|
|
2151
2181
|
headRevisionId: c?.headRevisionId ?? "",
|
|
2152
2182
|
effectiveOn: r
|
|
2153
2183
|
});
|
|
2154
|
-
let
|
|
2155
|
-
return
|
|
2156
|
-
...
|
|
2184
|
+
let d = o.branches[e];
|
|
2185
|
+
return d && (o.branches[e] = {
|
|
2186
|
+
...d,
|
|
2157
2187
|
branchId: l
|
|
2158
2188
|
}), {
|
|
2159
|
-
changeSet:
|
|
2189
|
+
changeSet: O(i),
|
|
2160
2190
|
branchId: l
|
|
2161
2191
|
};
|
|
2162
2192
|
});
|
|
2163
2193
|
},
|
|
2164
2194
|
async dropChain({ idempotencyKey: e, ...t }) {
|
|
2165
|
-
return
|
|
2166
|
-
let { changeSetId: e, chainId: n } = t, r =
|
|
2167
|
-
if (!i) throw
|
|
2168
|
-
if (i.born) throw new
|
|
2169
|
-
for (let e of i.branches)
|
|
2170
|
-
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);
|
|
2171
2201
|
});
|
|
2172
2202
|
},
|
|
2173
2203
|
async getPendingMerge(e) {
|
|
2174
|
-
let t =
|
|
2204
|
+
let t = z.get(e);
|
|
2175
2205
|
return t ? structuredClone(t) : null;
|
|
2176
2206
|
},
|
|
2177
2207
|
async resolveMerge({ idempotencyKey: e, ...t }) {
|
|
2178
|
-
return
|
|
2179
|
-
let { changeSetId: e, branchId: n, expectedHeadId: r, resolutions:
|
|
2180
|
-
if (!l) throw new
|
|
2181
|
-
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({
|
|
2182
2212
|
contentId: c.id,
|
|
2183
2213
|
branchId: n,
|
|
2184
2214
|
expectedHeadId: r,
|
|
2185
2215
|
currentHeadId: s.headRevisionId
|
|
2186
2216
|
});
|
|
2187
|
-
let
|
|
2188
|
-
if (new Set(
|
|
2189
|
-
let
|
|
2190
|
-
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) {
|
|
2191
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(/^\//, "");
|
|
2192
|
-
n === void 0 ? delete
|
|
2222
|
+
n === void 0 ? delete p[r] : p[r] = structuredClone(n);
|
|
2193
2223
|
}
|
|
2194
|
-
let
|
|
2224
|
+
let m = st({
|
|
2195
2225
|
changeSetId: e,
|
|
2196
|
-
chain:
|
|
2226
|
+
chain: a,
|
|
2197
2227
|
branch: s,
|
|
2198
2228
|
c,
|
|
2199
|
-
data:
|
|
2229
|
+
data: p,
|
|
2200
2230
|
cause: "resolve",
|
|
2201
2231
|
secondParentId: l.theirsRevisionId
|
|
2202
2232
|
});
|
|
2203
|
-
return
|
|
2233
|
+
return ut(n), qe.delete(n), m;
|
|
2204
2234
|
});
|
|
2205
2235
|
},
|
|
2206
2236
|
async abortMerge({ idempotencyKey: e, ...t }) {
|
|
2207
|
-
return
|
|
2208
|
-
if (
|
|
2209
|
-
|
|
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);
|
|
2210
2240
|
});
|
|
2211
2241
|
},
|
|
2212
2242
|
async previewInForce({ contentId: e, changeSetId: t, validOn: n }) {
|
|
2213
|
-
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));
|
|
2214
2244
|
if (c) {
|
|
2215
2245
|
let e = c.branchId ? o?.branches.find((e) => e.id === c.branchId)?.headRevisionId ?? "" : c.revisionId;
|
|
2216
2246
|
return {
|
|
@@ -2219,24 +2249,24 @@ function M(y = {}) {
|
|
|
2219
2249
|
planned: !0,
|
|
2220
2250
|
withheld: !1,
|
|
2221
2251
|
validityPeriod: c.validityPeriod ? { ...c.validityPeriod } : void 0,
|
|
2222
|
-
data: structuredClone(
|
|
2252
|
+
data: structuredClone(K(i, e) ?? {})
|
|
2223
2253
|
};
|
|
2224
2254
|
}
|
|
2225
|
-
let l =
|
|
2255
|
+
let l = ee(i.timeline ?? [], a);
|
|
2226
2256
|
return l ? {
|
|
2227
2257
|
releaseId: l.releaseId,
|
|
2228
2258
|
revisionId: l.revisionId,
|
|
2229
2259
|
planned: !1,
|
|
2230
2260
|
withheld: !1,
|
|
2231
2261
|
validityPeriod: l.validityPeriod ? { ...l.validityPeriod } : void 0,
|
|
2232
|
-
data: structuredClone(
|
|
2262
|
+
data: structuredClone(K(i, l.revisionId) ?? {})
|
|
2233
2263
|
} : null;
|
|
2234
2264
|
}
|
|
2235
2265
|
};
|
|
2236
|
-
return
|
|
2237
|
-
function
|
|
2266
|
+
return Q;
|
|
2267
|
+
function Ct(e, t, n) {
|
|
2238
2268
|
let r = {
|
|
2239
|
-
id: `rls_stub_${
|
|
2269
|
+
id: `rls_stub_${V++}`,
|
|
2240
2270
|
contentId: e.id,
|
|
2241
2271
|
branchId: "",
|
|
2242
2272
|
revisionId: e.inForce?.revisionId ?? e.main?.revisionId ?? "",
|
|
@@ -2252,10 +2282,10 @@ function M(y = {}) {
|
|
|
2252
2282
|
plannedRelease: r
|
|
2253
2283
|
}], structuredClone({
|
|
2254
2284
|
plannedRelease: r,
|
|
2255
|
-
gapReferrers:
|
|
2285
|
+
gapReferrers: $e(e.id)
|
|
2256
2286
|
});
|
|
2257
2287
|
}
|
|
2258
|
-
function
|
|
2288
|
+
function $(e, t, n) {
|
|
2259
2289
|
let r = (t, n) => ({
|
|
2260
2290
|
id: e.id,
|
|
2261
2291
|
blueprintId: e.blueprintId,
|
|
@@ -2270,33 +2300,33 @@ function M(y = {}) {
|
|
|
2270
2300
|
if (t.kind === "in_force") return e.inForce ? [r(e.inForce, { releaseId: e.inForce.releaseId })] : [];
|
|
2271
2301
|
if (t.kind === "change_set") {
|
|
2272
2302
|
let i = e.branches[t.changeSetId];
|
|
2273
|
-
return !i || n && !
|
|
2303
|
+
return !i || n && !Me(i.data, n) ? [] : [r(i, {
|
|
2274
2304
|
changeSetId: t.changeSetId,
|
|
2275
2305
|
branchId: i.branchId
|
|
2276
2306
|
})];
|
|
2277
2307
|
}
|
|
2278
2308
|
if (!n) return e.main ? [r(e.main, {})] : [];
|
|
2279
2309
|
let i = [];
|
|
2280
|
-
e.main &&
|
|
2281
|
-
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, {
|
|
2282
2312
|
changeSetId: t,
|
|
2283
2313
|
branchId: a.branchId
|
|
2284
2314
|
}));
|
|
2285
2315
|
return i;
|
|
2286
2316
|
}
|
|
2287
2317
|
}
|
|
2288
|
-
function
|
|
2318
|
+
function Me(e, t) {
|
|
2289
2319
|
let n = (e) => e.toLocaleLowerCase().replace(/\s+/g, " "), r = n(t);
|
|
2290
2320
|
return Object.values(e).some((e) => typeof e == "string" && n(e).includes(r));
|
|
2291
2321
|
}
|
|
2292
2322
|
//#endregion
|
|
2293
2323
|
//#region src/testing/stub-status-source.ts
|
|
2294
|
-
function
|
|
2324
|
+
function j(e = fe()) {
|
|
2295
2325
|
return { async listChangeSetStatuses() {
|
|
2296
2326
|
return e.map((e) => ({ ...e }));
|
|
2297
2327
|
} };
|
|
2298
2328
|
}
|
|
2299
2329
|
//#endregion
|
|
2300
|
-
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 };
|
|
2301
2331
|
|
|
2302
2332
|
//# sourceMappingURL=testing.js.map
|