@knkcs/contenthub-ui 0.1.0 → 0.3.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 +14 -0
- package/README.md +2 -2
- package/dist/{branch-content-fields-WBpviLQg.js → branch-content-fields-LyF6sD2e.js} +2 -2
- package/dist/{branch-content-fields-WBpviLQg.js.map → branch-content-fields-LyF6sD2e.js.map} +1 -1
- package/dist/{content-library-B2eauvHt.js → content-library-v0mjVD4J.js} +452 -405
- package/dist/content-library-v0mjVD4J.js.map +1 -0
- package/dist/{heads-Brd2Gtjm.js → heads-dBmqNcOB.js} +12 -12
- package/dist/heads-dBmqNcOB.js.map +1 -0
- package/dist/index.d.ts +68 -13
- package/dist/index.js +2349 -2306
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +65 -13
- package/dist/testing.js +494 -467
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/content-library-B2eauvHt.js.map +0 -1
- package/dist/heads-Brd2Gtjm.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { A as e, C as t,
|
|
2
|
-
import { Code as
|
|
3
|
-
import { createHostMembers as
|
|
1
|
+
import { A as e, C as t, D as n, M as r, N as i, S as a, T as o, _ as s, b as c, f as l, g as u, h as d, i as f, j as p, n as m, o as ee, r as h, s as te, t as ne, u as re, v as ie, w as g, x as ae, y as _ } from "./heads-dBmqNcOB.js";
|
|
2
|
+
import { Code as v, ConnectError as y } from "@connectrpc/connect";
|
|
3
|
+
import { createHostMembers as b } from "@knkcs/anker/host";
|
|
4
4
|
//#region src/testing/fixtures.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
5
|
+
var x = "ws_stub", S = "user_stub", C = "user_ben", w = "2026-10-01T09:00:00.000Z";
|
|
6
|
+
function T() {
|
|
7
7
|
return {
|
|
8
|
-
userId:
|
|
9
|
-
workspaceId:
|
|
10
|
-
members:
|
|
11
|
-
userId:
|
|
8
|
+
userId: S,
|
|
9
|
+
workspaceId: x,
|
|
10
|
+
members: b([{
|
|
11
|
+
userId: S,
|
|
12
12
|
displayName: "Ada Editor",
|
|
13
13
|
email: "ada@example.com"
|
|
14
14
|
}, {
|
|
15
|
-
userId:
|
|
15
|
+
userId: C,
|
|
16
16
|
displayName: "Ben Reviewer",
|
|
17
17
|
email: "ben@example.com"
|
|
18
18
|
}])
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function oe() {
|
|
22
22
|
return [{
|
|
23
23
|
id: "br_author",
|
|
24
24
|
name: "Being revised by the author",
|
|
25
|
-
createTime:
|
|
26
|
-
updateTime:
|
|
25
|
+
createTime: w,
|
|
26
|
+
updateTime: w
|
|
27
27
|
}, {
|
|
28
28
|
id: "br_embargo",
|
|
29
29
|
name: "Embargoed until publication",
|
|
30
|
-
createTime:
|
|
31
|
-
updateTime:
|
|
30
|
+
createTime: w,
|
|
31
|
+
updateTime: w
|
|
32
32
|
}];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function E() {
|
|
35
35
|
return [
|
|
36
36
|
{
|
|
37
37
|
slug: "in_progress",
|
|
@@ -55,7 +55,7 @@ function ce() {
|
|
|
55
55
|
}
|
|
56
56
|
];
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function se() {
|
|
59
59
|
return {
|
|
60
60
|
in_progress: ["in_review", "on_hold"],
|
|
61
61
|
in_review: [
|
|
@@ -67,7 +67,7 @@ function le() {
|
|
|
67
67
|
on_hold: ["in_progress"]
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function ce() {
|
|
71
71
|
return [
|
|
72
72
|
{
|
|
73
73
|
id: "cs_bgbl_270",
|
|
@@ -77,7 +77,7 @@ function ue() {
|
|
|
77
77
|
reference: "BGBl. 2026 I Nr. 270"
|
|
78
78
|
},
|
|
79
79
|
state: "open",
|
|
80
|
-
createdBy:
|
|
80
|
+
createdBy: S,
|
|
81
81
|
createTime: "2026-09-30T08:00:00.000Z",
|
|
82
82
|
chains: [{
|
|
83
83
|
id: "chain_para_1",
|
|
@@ -110,7 +110,7 @@ function ue() {
|
|
|
110
110
|
}],
|
|
111
111
|
dependsOnChangeSetIds: [],
|
|
112
112
|
status: "in_progress",
|
|
113
|
-
assigneeIds: [
|
|
113
|
+
assigneeIds: [S],
|
|
114
114
|
plannedReleases: [
|
|
115
115
|
{
|
|
116
116
|
id: "rls_p1_2",
|
|
@@ -170,19 +170,19 @@ function ue() {
|
|
|
170
170
|
reference: "BGBl. 2026 I Nr. 255"
|
|
171
171
|
},
|
|
172
172
|
state: "open",
|
|
173
|
-
createdBy:
|
|
173
|
+
createdBy: C,
|
|
174
174
|
createTime: "2026-09-25T08:00:00.000Z",
|
|
175
175
|
chains: [],
|
|
176
176
|
dependsOnChangeSetIds: [],
|
|
177
177
|
status: "",
|
|
178
|
-
assigneeIds: [
|
|
178
|
+
assigneeIds: [C],
|
|
179
179
|
plannedReleases: []
|
|
180
180
|
},
|
|
181
181
|
{
|
|
182
182
|
id: "cs_correction_3",
|
|
183
183
|
name: "Correction of § 3",
|
|
184
184
|
state: "published",
|
|
185
|
-
createdBy:
|
|
185
|
+
createdBy: S,
|
|
186
186
|
createTime: "2026-09-01T08:00:00.000Z",
|
|
187
187
|
closeTime: "2026-09-02T08:00:00.000Z",
|
|
188
188
|
chains: [],
|
|
@@ -193,7 +193,7 @@ function ue() {
|
|
|
193
193
|
}
|
|
194
194
|
];
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function le() {
|
|
197
197
|
return [{
|
|
198
198
|
id: "rc_print",
|
|
199
199
|
name: "Druckprobe",
|
|
@@ -208,7 +208,7 @@ function de() {
|
|
|
208
208
|
independent: !0
|
|
209
209
|
}];
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function ue() {
|
|
212
212
|
return [
|
|
213
213
|
{
|
|
214
214
|
id: "col_bgb",
|
|
@@ -236,7 +236,7 @@ function fe() {
|
|
|
236
236
|
}
|
|
237
237
|
];
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function de() {
|
|
240
240
|
return [
|
|
241
241
|
{
|
|
242
242
|
id: "bp_commentary",
|
|
@@ -252,7 +252,7 @@ function w() {
|
|
|
252
252
|
}
|
|
253
253
|
];
|
|
254
254
|
}
|
|
255
|
-
function
|
|
255
|
+
function fe() {
|
|
256
256
|
return [
|
|
257
257
|
{
|
|
258
258
|
id: "bpr_paragraph_2",
|
|
@@ -301,7 +301,7 @@ function pe() {
|
|
|
301
301
|
}
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function D() {
|
|
305
305
|
let e = "2001-11-01T08:00:00.000Z";
|
|
306
306
|
return {
|
|
307
307
|
id: "content_para_3",
|
|
@@ -332,7 +332,7 @@ function me() {
|
|
|
332
332
|
}]
|
|
333
333
|
};
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function me() {
|
|
336
336
|
let e = "2026-09-01T08:00:00.000Z";
|
|
337
337
|
return [
|
|
338
338
|
{
|
|
@@ -365,7 +365,7 @@ function he() {
|
|
|
365
365
|
blueprintId: "bp_paragraph",
|
|
366
366
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
367
367
|
collectionIds: ["col_bgb"],
|
|
368
|
-
assigneeIds: [
|
|
368
|
+
assigneeIds: [S, C],
|
|
369
369
|
main: {
|
|
370
370
|
revisionId: "rev_p1_main",
|
|
371
371
|
data: {
|
|
@@ -432,7 +432,7 @@ function he() {
|
|
|
432
432
|
secondParentId: "",
|
|
433
433
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
434
434
|
createTime: "2026-09-30T09:00:00.000Z",
|
|
435
|
-
author:
|
|
435
|
+
author: S,
|
|
436
436
|
cause: "save",
|
|
437
437
|
branchId: "br_para_1_b",
|
|
438
438
|
changeSetId: "cs_bgbl_270",
|
|
@@ -448,7 +448,7 @@ function he() {
|
|
|
448
448
|
secondParentId: "",
|
|
449
449
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
450
450
|
createTime: "2026-09-30T08:30:00.000Z",
|
|
451
|
-
author:
|
|
451
|
+
author: C,
|
|
452
452
|
cause: "save",
|
|
453
453
|
branchId: "br_para_1_a",
|
|
454
454
|
changeSetId: "cs_bgbl_270",
|
|
@@ -464,7 +464,7 @@ function he() {
|
|
|
464
464
|
secondParentId: "",
|
|
465
465
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
466
466
|
createTime: e,
|
|
467
|
-
author:
|
|
467
|
+
author: S,
|
|
468
468
|
cause: "create",
|
|
469
469
|
branchId: "br_para_1_main",
|
|
470
470
|
changeSetId: "cs_correction_3"
|
|
@@ -548,7 +548,7 @@ function he() {
|
|
|
548
548
|
blueprintId: "bp_paragraph",
|
|
549
549
|
blueprintReleaseId: "bpr_paragraph_1",
|
|
550
550
|
collectionIds: ["col_stgb"],
|
|
551
|
-
assigneeIds: [
|
|
551
|
+
assigneeIds: [C],
|
|
552
552
|
main: {
|
|
553
553
|
revisionId: "rev_s211_main",
|
|
554
554
|
data: {
|
|
@@ -585,7 +585,7 @@ function he() {
|
|
|
585
585
|
}
|
|
586
586
|
//#endregion
|
|
587
587
|
//#region src/testing/stub-blueprint-source.ts
|
|
588
|
-
function
|
|
588
|
+
function he(e = de(), t = fe()) {
|
|
589
589
|
return {
|
|
590
590
|
async searchBlueprints({ query: t }) {
|
|
591
591
|
let n = t.trim().toLocaleLowerCase();
|
|
@@ -608,33 +608,33 @@ function ge(e, t) {
|
|
|
608
608
|
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
609
609
|
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function O(e, t, n) {
|
|
612
612
|
let r = e.trim();
|
|
613
|
-
if (r === "") throw new
|
|
614
|
-
if ([...r].length > n) throw new
|
|
615
|
-
if (/[\u0000-\u001f\u007f]/.test(r)) throw new
|
|
613
|
+
if (r === "") throw new a(`${t} is required`);
|
|
614
|
+
if ([...r].length > n) throw new a(`${t} is at most ${n} characters`);
|
|
615
|
+
if (/[\u0000-\u001f\u007f]/.test(r)) throw new a(`${t} is one line of text`);
|
|
616
616
|
return r;
|
|
617
617
|
}
|
|
618
618
|
function _e(e) {
|
|
619
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new
|
|
619
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new a(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
|
|
620
620
|
return {
|
|
621
621
|
date: e.date.trim(),
|
|
622
|
-
reference:
|
|
622
|
+
reference: O(e.reference, "source.reference", 500)
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
625
|
function ve(e) {
|
|
626
626
|
let t = e.trim();
|
|
627
|
-
if (t === "") throw new
|
|
628
|
-
if ([...t].length > 200) throw new
|
|
629
|
-
if (/[\u0000-\u001f\u007f]/.test(t)) throw new
|
|
627
|
+
if (t === "") throw new a("a Block Reason needs a name");
|
|
628
|
+
if ([...t].length > 200) throw new a("a Block Reason's name is at most 200 characters");
|
|
629
|
+
if (/[\u0000-\u001f\u007f]/.test(t)) throw new a("a Block Reason's name is one line of text");
|
|
630
630
|
return t;
|
|
631
631
|
}
|
|
632
632
|
function ye(e) {
|
|
633
|
-
let t =
|
|
634
|
-
if (e.scope !== "branch" && e.scope !== "change_set") throw new
|
|
633
|
+
let t = O(e.name, "a Required Check's name", 200);
|
|
634
|
+
if (e.scope !== "branch" && e.scope !== "change_set") throw new a("a Required Check's scope is Branch or Change Set");
|
|
635
635
|
let n = e.blueprintAccessors.map((e) => {
|
|
636
636
|
let t = e.trim();
|
|
637
|
-
if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new
|
|
637
|
+
if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new a(`"${t}" is not a Blueprint accessor`);
|
|
638
638
|
return t;
|
|
639
639
|
});
|
|
640
640
|
return {
|
|
@@ -644,9 +644,9 @@ function ye(e) {
|
|
|
644
644
|
independent: e.independent
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
|
-
var be = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", xe = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it",
|
|
647
|
+
var be = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", xe = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it", Se = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
|
|
648
648
|
function k(e, t) {
|
|
649
|
-
return new
|
|
649
|
+
return new y(`${e} ${t}: not found`, v.NotFound);
|
|
650
650
|
}
|
|
651
651
|
var A = (e) => structuredClone(e);
|
|
652
652
|
function j(e, t = {}) {
|
|
@@ -669,34 +669,34 @@ function j(e, t = {}) {
|
|
|
669
669
|
...t
|
|
670
670
|
};
|
|
671
671
|
}
|
|
672
|
-
function M(
|
|
673
|
-
let
|
|
674
|
-
if (
|
|
675
|
-
},
|
|
672
|
+
function M(v = {}) {
|
|
673
|
+
let y = v.now ?? (() => "2026-10-01T09:00:00.000Z"), b = v.userId ?? "user_stub", x = v.statuses ?? E(), S = v.statusTransitions ?? se(), C = (v.blockReasons ?? oe()).map((e) => ({ ...e })), w = (v.changeSets ?? ce()).map(A), T = (v.collections ?? ue()).map((e) => ({ ...e })), D = structuredClone(v.contents ?? me()), he = v.blueprints ?? de(), M = v.blueprintReleases ?? fe(), P = v.resolvedReleases ?? pe(), F = structuredClone(v.requiredChecks ?? le()), I = v.authzMode ?? "guardian", Ce = new Set(v.withheld ?? []), L = (e) => {
|
|
674
|
+
if (Ce.has(e)) throw new i(xe);
|
|
675
|
+
}, R = new Map(Object.entries(structuredClone(v.collectionGrants ?? {}))), z = new Map(Object.entries(structuredClone(v.recorders ?? {}))), we = (e) => z.get(e) ?? {
|
|
676
676
|
everyMember: !0,
|
|
677
677
|
userIds: []
|
|
678
|
-
},
|
|
678
|
+
}, Te = v.memberIds ?? ["user_stub", "user_ben"], Ee = v.admin ?? !0, De = structuredClone(v.checkResults ?? []), Oe = v.publishBlockers ?? {}, ke = v.pendingMerges ?? {}, Ae = structuredClone(v.conflicts ?? {}), B = /* @__PURE__ */ new Map(), je = /* @__PURE__ */ new Map(), V = async (e, t, n) => {
|
|
679
679
|
if (!e) return n();
|
|
680
|
-
let r = JSON.stringify(t),
|
|
681
|
-
if (
|
|
682
|
-
if (
|
|
683
|
-
return structuredClone(
|
|
680
|
+
let r = JSON.stringify(t), i = je.get(e);
|
|
681
|
+
if (i) {
|
|
682
|
+
if (i.asked !== r) throw new a(`idempotency key ${e} names another request`);
|
|
683
|
+
return structuredClone(i.answer);
|
|
684
684
|
}
|
|
685
685
|
let o = await n();
|
|
686
|
-
return
|
|
686
|
+
return je.set(e, {
|
|
687
687
|
asked: r,
|
|
688
688
|
answer: structuredClone(o)
|
|
689
689
|
}), o;
|
|
690
|
-
},
|
|
691
|
-
let t =
|
|
690
|
+
}, Me = /* @__PURE__ */ new Map(), Ne = /* @__PURE__ */ new Map(), H = 1, U = (e) => {
|
|
691
|
+
let t = D.find((t) => t.id === e);
|
|
692
692
|
if (!t) throw k("Content", e);
|
|
693
693
|
return t;
|
|
694
|
-
},
|
|
694
|
+
}, W = (e) => structuredClone({
|
|
695
695
|
collectionIds: [...e.collectionIds].sort(),
|
|
696
696
|
assigneeIds: e.assigneeIds ?? [],
|
|
697
697
|
block: e.block,
|
|
698
698
|
archiveTime: e.archiveTime
|
|
699
|
-
}),
|
|
699
|
+
}), Pe = () => y().slice(0, 10), G = (e) => P[e.blueprintReleaseId]?.dated ?? !1, K = (e) => {
|
|
700
700
|
let t = [...e.revisions ?? []], n = [...Object.entries(e.branches).map(([e, t]) => ({
|
|
701
701
|
...t,
|
|
702
702
|
changeSetId: e
|
|
@@ -712,70 +712,70 @@ function M(g = {}) {
|
|
|
712
712
|
secondParentId: "",
|
|
713
713
|
blueprintReleaseId: e.blueprintReleaseId,
|
|
714
714
|
createTime: r.revisionCreateTime,
|
|
715
|
-
author:
|
|
715
|
+
author: b,
|
|
716
716
|
cause: "create",
|
|
717
717
|
branchId: r.branchId,
|
|
718
718
|
changeSetId: r.changeSetId,
|
|
719
719
|
data: r.data
|
|
720
720
|
});
|
|
721
721
|
return t.sort((e, t) => e.createTime < t.createTime ? 1 : e.createTime > t.createTime ? -1 : 0);
|
|
722
|
-
},
|
|
722
|
+
}, q = (e, t) => [
|
|
723
723
|
e.main,
|
|
724
724
|
e.inForce,
|
|
725
725
|
...Object.values(e.branches)
|
|
726
|
-
].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data,
|
|
726
|
+
].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Fe = (e, t) => {
|
|
727
727
|
let n = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
728
728
|
return (e ?? []).filter((e) => e.config.required === !0 && n(t[e.config.api_accessor])).map((e) => e.config.api_accessor);
|
|
729
|
-
},
|
|
730
|
-
if (e.archiveTime) throw new
|
|
731
|
-
if (e.block && !e.block.allowedUserIds.includes(
|
|
732
|
-
},
|
|
729
|
+
}, J = (e) => {
|
|
730
|
+
if (e.archiveTime) throw new s(e.id);
|
|
731
|
+
if (e.block && !e.block.allowedUserIds.includes(b)) throw new ie(e.id, e.block.blockReasonId);
|
|
732
|
+
}, Ie = (e) => D.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
|
|
733
733
|
edge: { ...e },
|
|
734
734
|
releaseId: t.inForce?.releaseId ?? ""
|
|
735
|
-
}))),
|
|
736
|
-
let t =
|
|
735
|
+
}))), Le = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Re = (e, t) => C.some((n) => n.name === e && n.id !== t), ze = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Y = (e) => {
|
|
736
|
+
let t = T.find((t) => t.id === e);
|
|
737
737
|
if (!t) throw k("Collection", e);
|
|
738
738
|
return t;
|
|
739
|
-
},
|
|
740
|
-
if (
|
|
741
|
-
if (!
|
|
742
|
-
let t = (
|
|
743
|
-
if (!
|
|
744
|
-
},
|
|
745
|
-
if (
|
|
746
|
-
if (!
|
|
747
|
-
if (e === "") throw new
|
|
748
|
-
if (!
|
|
749
|
-
return
|
|
750
|
-
},
|
|
751
|
-
let
|
|
752
|
-
if (!
|
|
753
|
-
let
|
|
754
|
-
if (
|
|
755
|
-
if (
|
|
756
|
-
if (
|
|
757
|
-
contentId:
|
|
758
|
-
branchId:
|
|
759
|
-
expectedHeadId:
|
|
760
|
-
currentHeadId:
|
|
739
|
+
}, Be = (e, t, n) => T.some((r) => r.parentId === e && r.name === t && r.id !== n), Ve = (e) => {
|
|
740
|
+
if (I === "workspace") throw new n(Se);
|
|
741
|
+
if (!Y(e).restricted) throw new a(`Collection ${e} is open: only a Restricted Collection takes grants`);
|
|
742
|
+
let t = (R.get(e) ?? []).some((e) => e.userId === b && e.level === "owner");
|
|
743
|
+
if (!Ee && !t) throw new te("only its owner or a workspace admin manages its grants");
|
|
744
|
+
}, He = (e) => {
|
|
745
|
+
if (I === "workspace") throw new ae("required_check_recorders", be);
|
|
746
|
+
if (!Ee) throw new te("permission denied");
|
|
747
|
+
if (e === "") throw new a("required_check_id is required");
|
|
748
|
+
if (!F.some((t) => t.id === e)) throw k("Required Check", e);
|
|
749
|
+
return we(e);
|
|
750
|
+
}, Ue = async ({ changeSetId: t, branchId: n, expectedHeadId: r, data: i, fieldMask: o }) => {
|
|
751
|
+
let s = Z(t).chains.find((e) => e.branches.some((e) => e.id === n)), c = s?.branches.find((e) => e.id === n);
|
|
752
|
+
if (!s || !c) throw k("Branch", n);
|
|
753
|
+
let l = U(s.contentId);
|
|
754
|
+
if (J(l), B.has(n)) throw new a("a Pending Merge waits on this Branch: resolve or abort it first");
|
|
755
|
+
if (r === "") throw new a("expected_head_id is required");
|
|
756
|
+
if (c.headRevisionId !== r) throw new e({
|
|
757
|
+
contentId: l.id,
|
|
758
|
+
branchId: n,
|
|
759
|
+
expectedHeadId: r,
|
|
760
|
+
currentHeadId: c.headRevisionId
|
|
761
761
|
});
|
|
762
|
-
let
|
|
763
|
-
if (
|
|
764
|
-
let e = Object.keys(
|
|
765
|
-
if (e.length > 0) throw new
|
|
766
|
-
|
|
767
|
-
for (let e of
|
|
768
|
-
} else
|
|
769
|
-
return
|
|
770
|
-
changeSetId:
|
|
771
|
-
chain:
|
|
772
|
-
branch:
|
|
773
|
-
c,
|
|
774
|
-
data:
|
|
762
|
+
let u = q(l, c.headRevisionId) ?? {}, d = JSON.parse(JSON.stringify(i)), f;
|
|
763
|
+
if (o) {
|
|
764
|
+
let e = Object.keys(d).filter((e) => !o.includes(e));
|
|
765
|
+
if (e.length > 0) throw new a(`data holds ${e.join(", ")}, which the mask doesn't name`);
|
|
766
|
+
f = structuredClone(u);
|
|
767
|
+
for (let e of o) e in d ? f[e] = d[e] : delete f[e];
|
|
768
|
+
} else f = d;
|
|
769
|
+
return We({
|
|
770
|
+
changeSetId: t,
|
|
771
|
+
chain: s,
|
|
772
|
+
branch: c,
|
|
773
|
+
c: l,
|
|
774
|
+
data: f,
|
|
775
775
|
cause: "save"
|
|
776
776
|
});
|
|
777
|
-
},
|
|
778
|
-
let s = n.id, c = `rev_stub_${
|
|
777
|
+
}, We = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
|
|
778
|
+
let s = n.id, c = `rev_stub_${H++}`, l = y();
|
|
779
779
|
return r.revisions = [{
|
|
780
780
|
id: c,
|
|
781
781
|
contentId: r.id,
|
|
@@ -783,7 +783,7 @@ function M(g = {}) {
|
|
|
783
783
|
secondParentId: o,
|
|
784
784
|
blueprintReleaseId: r.blueprintReleaseId,
|
|
785
785
|
createTime: l,
|
|
786
|
-
author:
|
|
786
|
+
author: b,
|
|
787
787
|
cause: a,
|
|
788
788
|
branchId: s,
|
|
789
789
|
changeSetId: e,
|
|
@@ -804,17 +804,17 @@ function M(g = {}) {
|
|
|
804
804
|
revisionCreateTime: l,
|
|
805
805
|
releaseId: ""
|
|
806
806
|
};
|
|
807
|
-
},
|
|
808
|
-
let n =
|
|
807
|
+
}, Ge = (e, t) => {
|
|
808
|
+
let n = Z(e), r = n.chains.find((e) => e.branches.some((e) => e.id === t)), i = r?.branches.find((e) => e.id === t);
|
|
809
809
|
if (!r || !i) throw k("Branch", t);
|
|
810
810
|
return {
|
|
811
811
|
cs: n,
|
|
812
812
|
chain: r,
|
|
813
813
|
branch: i,
|
|
814
|
-
c:
|
|
814
|
+
c: U(r.contentId)
|
|
815
815
|
};
|
|
816
|
-
},
|
|
817
|
-
for (let n of
|
|
816
|
+
}, Ke = (e, t) => {
|
|
817
|
+
for (let n of w) for (let r of n.chains) {
|
|
818
818
|
let n = r.branches.find((t) => t.id === e);
|
|
819
819
|
if (!n) continue;
|
|
820
820
|
let i = {
|
|
@@ -827,37 +827,37 @@ function M(g = {}) {
|
|
|
827
827
|
fields: structuredClone(t.fields),
|
|
828
828
|
merged: structuredClone(t.merged)
|
|
829
829
|
};
|
|
830
|
-
|
|
830
|
+
B.set(e, i), n.hasPendingMerge = !0, delete Ae[e];
|
|
831
831
|
return;
|
|
832
832
|
}
|
|
833
833
|
throw k("Branch", e);
|
|
834
|
-
},
|
|
835
|
-
|
|
836
|
-
for (let t of
|
|
834
|
+
}, qe = (e) => {
|
|
835
|
+
B.delete(e);
|
|
836
|
+
for (let t of w) for (let n of t.chains) {
|
|
837
837
|
let t = n.branches.find((t) => t.id === e);
|
|
838
838
|
t && (t.hasPendingMerge = !1);
|
|
839
839
|
}
|
|
840
|
-
},
|
|
840
|
+
}, Je = (e, t) => {
|
|
841
841
|
let n = t.validityPeriod;
|
|
842
|
-
if (
|
|
843
|
-
if (!n || !h.test(n.firstDay)) throw new
|
|
844
|
-
if (n.lastDay !== "" && (!h.test(n.lastDay) || n.lastDay < n.firstDay)) throw new
|
|
845
|
-
} else if (n) throw new
|
|
846
|
-
let r =
|
|
842
|
+
if (G(e)) {
|
|
843
|
+
if (!n || !h.test(n.firstDay)) throw new a("validity_period.first_day is required for Dated Content");
|
|
844
|
+
if (n.lastDay !== "" && (!h.test(n.lastDay) || n.lastDay < n.firstDay)) throw new a("validity_period.last_day is a day on or after first_day");
|
|
845
|
+
} else if (n) throw new a("validity_period is refused for undated Content");
|
|
846
|
+
let r = Fe(P[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
|
|
847
847
|
source: "fieldkit",
|
|
848
848
|
code: "required",
|
|
849
849
|
path: `/${e}`
|
|
850
850
|
}));
|
|
851
|
-
if (r.length > 0) throw new
|
|
851
|
+
if (r.length > 0) throw new _("the Release Spec values break the Blueprint Release", r);
|
|
852
852
|
if (n && n.lastDay !== "") {
|
|
853
853
|
let r = (e.timeline ?? []).filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && n.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= n.lastDay && !t.supersedesReleaseIds.includes(e.releaseId)).map((e) => e.releaseId);
|
|
854
|
-
if (r.length > 0) throw new
|
|
854
|
+
if (r.length > 0) throw new c(e.id, r);
|
|
855
855
|
}
|
|
856
|
-
},
|
|
856
|
+
}, Ye = (e, t) => {
|
|
857
857
|
let n = e.plannedReleases.filter((e) => e.contentId === t.id && e.proposed), r = e.plannedReleases.filter((e) => !(e.contentId === t.id && e.proposed)), i = [], a = (e, r, a) => {
|
|
858
858
|
let o = n.find((t) => t.proposedForReleaseId === e.releaseId && t.splitFromReleaseId === a);
|
|
859
859
|
i.push({
|
|
860
|
-
id: o?.id ?? `rls_stub_${
|
|
860
|
+
id: o?.id ?? `rls_stub_${H++}`,
|
|
861
861
|
contentId: t.id,
|
|
862
862
|
kind: "date_only",
|
|
863
863
|
branchId: "",
|
|
@@ -884,15 +884,15 @@ function M(g = {}) {
|
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
886
|
e.plannedReleases = [...r, ...i];
|
|
887
|
-
},
|
|
888
|
-
let t =
|
|
887
|
+
}, X = (e) => {
|
|
888
|
+
let t = w.find((t) => t.id === e);
|
|
889
889
|
if (!t) throw k("Change Set", e);
|
|
890
890
|
return t;
|
|
891
|
-
},
|
|
892
|
-
let t =
|
|
893
|
-
if (t.state !== "open") throw new
|
|
891
|
+
}, Z = (e) => {
|
|
892
|
+
let t = X(e);
|
|
893
|
+
if (t.state !== "open") throw new d(t.state);
|
|
894
894
|
return t;
|
|
895
|
-
},
|
|
895
|
+
}, Xe = (e) => x.find((t) => t.slug === e)?.name ?? e, Ze = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (w.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => Ze(e, t, n))), Qe = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
|
|
896
896
|
key: t.id,
|
|
897
897
|
branchless: !1,
|
|
898
898
|
contentId: e.contentId,
|
|
@@ -902,9 +902,9 @@ function M(g = {}) {
|
|
|
902
902
|
branchless: !0,
|
|
903
903
|
contentId: e.contentId,
|
|
904
904
|
revision: e.revisionId
|
|
905
|
-
}))],
|
|
906
|
-
let t =
|
|
907
|
-
let r = n[0], i = r ? !
|
|
905
|
+
}))], $e = (e) => D.find((t) => t.id === e)?.blueprintId, et = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes($e(t) ?? ""), tt = (e) => {
|
|
906
|
+
let t = Qe(e), n = (t, n) => De.filter((n) => n.changeSetId === e.id && n.requiredCheckId === t.id).filter((e) => (t.scope === "change_set" ? "" : Object.keys(e.heads)[0]) === n).reverse().map(({ changeSetId: e, ...t }) => structuredClone(t)), r = (e, t, n) => {
|
|
907
|
+
let r = n[0], i = r ? !m(r.heads, t.heads) : !1;
|
|
908
908
|
return {
|
|
909
909
|
check: structuredClone(e),
|
|
910
910
|
...t,
|
|
@@ -913,8 +913,8 @@ function M(g = {}) {
|
|
|
913
913
|
cleared: !!r && !i && r.outcome !== "failed"
|
|
914
914
|
};
|
|
915
915
|
}, i = [], a = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
|
|
916
|
-
for (let e of [...
|
|
917
|
-
let a = t.filter((t) =>
|
|
916
|
+
for (let e of [...F].sort(a)) {
|
|
917
|
+
let a = t.filter((t) => et(e, t.contentId));
|
|
918
918
|
if (e.scope === "change_set") {
|
|
919
919
|
if (a.length === 0) continue;
|
|
920
920
|
let o = Object.fromEntries(t.map((e) => [e.key, e.revision]));
|
|
@@ -934,8 +934,8 @@ function M(g = {}) {
|
|
|
934
934
|
}, n(e, t.key)));
|
|
935
935
|
}
|
|
936
936
|
return i;
|
|
937
|
-
},
|
|
938
|
-
let n = [], r =
|
|
937
|
+
}, nt = (e, t) => {
|
|
938
|
+
let n = [], r = ne(e);
|
|
939
939
|
for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(j("moved_head", {
|
|
940
940
|
contentId: r.contentId,
|
|
941
941
|
branchId: e.id,
|
|
@@ -947,29 +947,29 @@ function M(g = {}) {
|
|
|
947
947
|
expectedHeadId: i
|
|
948
948
|
}));
|
|
949
949
|
for (let t of e.dependsOnChangeSetIds) {
|
|
950
|
-
let e =
|
|
950
|
+
let e = w.find((e) => e.id === t)?.state;
|
|
951
951
|
e === "open" ? n.push(j("unpublished_dependency", { dependencyChangeSetId: t })) : e === "discarded" && n.push(j("discarded_dependency", { dependencyChangeSetId: t }));
|
|
952
952
|
}
|
|
953
|
-
for (let t of
|
|
953
|
+
for (let t of tt(e)) t.cleared || n.push(j("outstanding_check", {
|
|
954
954
|
requiredCheckId: t.check.id,
|
|
955
955
|
contentId: t.contentId,
|
|
956
956
|
branchId: t.branchId,
|
|
957
957
|
releaseId: t.releaseId
|
|
958
958
|
}));
|
|
959
959
|
for (let t of e.chains) {
|
|
960
|
-
let e =
|
|
960
|
+
let e = D.find((e) => e.id === t.contentId);
|
|
961
961
|
for (let r of t.branches) {
|
|
962
|
-
let t = e &&
|
|
963
|
-
if (e && t) for (let i of
|
|
962
|
+
let t = e && q(e, r.headRevisionId);
|
|
963
|
+
if (e && t) for (let i of Fe(P[e.blueprintReleaseId]?.fields, t)) n.push(j("missing_required_field", {
|
|
964
964
|
contentId: e.id,
|
|
965
965
|
revisionId: r.headRevisionId,
|
|
966
966
|
path: `/${i}`
|
|
967
967
|
}));
|
|
968
968
|
}
|
|
969
969
|
}
|
|
970
|
-
return [...n, ...structuredClone(
|
|
971
|
-
},
|
|
972
|
-
let t =
|
|
970
|
+
return [...n, ...structuredClone(Oe[e.id] ?? [])];
|
|
971
|
+
}, Q = (e) => {
|
|
972
|
+
let t = ne(e);
|
|
973
973
|
return e.plannedReleases.filter((e) => !e.withheld).map((n) => ({
|
|
974
974
|
id: n.id,
|
|
975
975
|
contentId: n.contentId,
|
|
@@ -981,34 +981,34 @@ function M(g = {}) {
|
|
|
981
981
|
validityPeriod: n.validityPeriod ? { ...n.validityPeriod } : void 0
|
|
982
982
|
}));
|
|
983
983
|
};
|
|
984
|
-
for (let [e, t] of Object.entries(
|
|
984
|
+
for (let [e, t] of Object.entries(Ae)) t.pending && Ke(e, t);
|
|
985
985
|
return {
|
|
986
986
|
async listBlockReasons() {
|
|
987
|
-
return [...
|
|
987
|
+
return [...C].sort(Le).map((e) => ({ ...e }));
|
|
988
988
|
},
|
|
989
989
|
async createBlockReason({ name: e }) {
|
|
990
990
|
let t = ve(e);
|
|
991
|
-
if (
|
|
991
|
+
if (Re(t)) throw new re(t);
|
|
992
992
|
let n = {
|
|
993
|
-
id: `br_stub_${
|
|
993
|
+
id: `br_stub_${H++}`,
|
|
994
994
|
name: t,
|
|
995
|
-
createTime:
|
|
996
|
-
updateTime:
|
|
995
|
+
createTime: y(),
|
|
996
|
+
updateTime: y()
|
|
997
997
|
};
|
|
998
|
-
return
|
|
998
|
+
return C.push(n), { ...n };
|
|
999
999
|
},
|
|
1000
1000
|
async renameBlockReason({ id: e, name: t }) {
|
|
1001
|
-
let n = ve(t), r =
|
|
1001
|
+
let n = ve(t), r = C.find((t) => t.id === e);
|
|
1002
1002
|
if (!r) throw k("Block Reason", e);
|
|
1003
|
-
if (
|
|
1004
|
-
return r.name = n, r.updateTime =
|
|
1003
|
+
if (Re(n, e)) throw new re(n);
|
|
1004
|
+
return r.name = n, r.updateTime = y(), { ...r };
|
|
1005
1005
|
},
|
|
1006
1006
|
async deleteBlockReason({ id: e }) {
|
|
1007
|
-
if (!
|
|
1008
|
-
|
|
1007
|
+
if (!C.some((t) => t.id === e)) throw k("Block Reason", e);
|
|
1008
|
+
C = C.filter((t) => t.id !== e);
|
|
1009
1009
|
},
|
|
1010
1010
|
async listChangeSets(e = {}) {
|
|
1011
|
-
let t =
|
|
1011
|
+
let t = w.filter((t) => (!e.state || t.state === e.state) && (!e.assigneeId || t.assigneeIds.includes(e.assigneeId)) && (!e.contentId || t.chains.some((t) => t.contentId === e.contentId))), n = Math.min(e.pageSize || 50, 200), r = e.pageToken ? Number(e.pageToken) : 0;
|
|
1012
1012
|
return {
|
|
1013
1013
|
changeSets: t.slice(r, r + n).map((e) => ({
|
|
1014
1014
|
...A(e),
|
|
@@ -1020,112 +1020,112 @@ function M(g = {}) {
|
|
|
1020
1020
|
};
|
|
1021
1021
|
},
|
|
1022
1022
|
async createChangeSet({ name: e, source: t }) {
|
|
1023
|
-
let n =
|
|
1024
|
-
id: `cs_stub_${
|
|
1023
|
+
let n = O(e, "name", 200), r = t ? _e(t) : void 0, i = {
|
|
1024
|
+
id: `cs_stub_${H++}`,
|
|
1025
1025
|
name: n,
|
|
1026
1026
|
source: r,
|
|
1027
1027
|
state: "open",
|
|
1028
|
-
createdBy:
|
|
1029
|
-
createTime:
|
|
1028
|
+
createdBy: b,
|
|
1029
|
+
createTime: y(),
|
|
1030
1030
|
chains: [],
|
|
1031
1031
|
dependsOnChangeSetIds: [],
|
|
1032
1032
|
status: "",
|
|
1033
1033
|
assigneeIds: [],
|
|
1034
1034
|
plannedReleases: []
|
|
1035
1035
|
};
|
|
1036
|
-
return
|
|
1036
|
+
return w.unshift(i), A(i);
|
|
1037
1037
|
},
|
|
1038
1038
|
async getChangeSet(e) {
|
|
1039
|
-
return A(
|
|
1039
|
+
return A(X(e));
|
|
1040
1040
|
},
|
|
1041
1041
|
async updateChangeSet({ id: e, updateMask: t, name: n, source: r }) {
|
|
1042
|
-
let
|
|
1043
|
-
if (t.length === 0) throw new
|
|
1044
|
-
let o = t.includes("name") ?
|
|
1045
|
-
return t.includes("source") && (s = r ? _e(r) : void 0),
|
|
1046
|
-
},
|
|
1047
|
-
async setChangeSetStatus({ id:
|
|
1048
|
-
let
|
|
1049
|
-
if (
|
|
1050
|
-
if (
|
|
1051
|
-
if (!
|
|
1052
|
-
if (
|
|
1053
|
-
fromStatus:
|
|
1054
|
-
toStatus:
|
|
1055
|
-
reason: `There is no transition from ${
|
|
1042
|
+
let i = Z(e);
|
|
1043
|
+
if (t.length === 0) throw new a("update_mask is required");
|
|
1044
|
+
let o = t.includes("name") ? O(n ?? "", "name", 200) : i.name, s = i.source;
|
|
1045
|
+
return t.includes("source") && (s = r ? _e(r) : void 0), i.name = o, i.source = s, A(i);
|
|
1046
|
+
},
|
|
1047
|
+
async setChangeSetStatus({ id: e, expectedStatus: t, status: n }) {
|
|
1048
|
+
let i = Z(e);
|
|
1049
|
+
if (i.status !== t) throw new p(i.status);
|
|
1050
|
+
if (i.status === n) return A(i);
|
|
1051
|
+
if (!x.some((e) => e.slug === n)) throw new a(`status "${n}" is not in the workspace's catalogue`);
|
|
1052
|
+
if (x.some((e) => e.slug === i.status) && !(S[i.status] ?? []).includes(n)) throw new r({
|
|
1053
|
+
fromStatus: i.status,
|
|
1054
|
+
toStatus: n,
|
|
1055
|
+
reason: `There is no transition from ${Xe(i.status)} to ${Xe(n)}.`,
|
|
1056
1056
|
requiresPermission: !1
|
|
1057
1057
|
});
|
|
1058
|
-
return
|
|
1058
|
+
return i.status = n, A(i);
|
|
1059
1059
|
},
|
|
1060
1060
|
async setChangeSetAssignees({ id: e, assigneeIds: t }) {
|
|
1061
|
-
let n =
|
|
1062
|
-
if (new Set(t).size !== t.length) throw new
|
|
1063
|
-
if (t.length > 50) throw new
|
|
1061
|
+
let n = X(e);
|
|
1062
|
+
if (new Set(t).size !== t.length) throw new a("each assignee is given once");
|
|
1063
|
+
if (t.length > 50) throw new a("at most 50 assignees");
|
|
1064
1064
|
return n.assigneeIds = [...t], A(n);
|
|
1065
1065
|
},
|
|
1066
1066
|
async addDependency({ id: e, dependsOnId: t }) {
|
|
1067
|
-
let n =
|
|
1068
|
-
if (r.state !== "open") throw new
|
|
1069
|
-
if (
|
|
1067
|
+
let n = Z(e), r = X(t);
|
|
1068
|
+
if (r.state !== "open") throw new a(`Change Set ${t} is ${r.state}`);
|
|
1069
|
+
if (Ze(t, e)) throw new a("the dependency would close a cycle");
|
|
1070
1070
|
return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t), A(n);
|
|
1071
1071
|
},
|
|
1072
1072
|
async removeDependency({ id: e, dependsOnId: t }) {
|
|
1073
|
-
let n =
|
|
1073
|
+
let n = Z(e);
|
|
1074
1074
|
if (!n.dependsOnChangeSetIds.includes(t)) throw k(`dependency of Change Set ${e} on`, t);
|
|
1075
1075
|
return n.dependsOnChangeSetIds = n.dependsOnChangeSetIds.filter((e) => e !== t), A(n);
|
|
1076
1076
|
},
|
|
1077
1077
|
async validatePublish({ id: e, reviewedHeads: t }) {
|
|
1078
|
-
let n =
|
|
1079
|
-
|
|
1080
|
-
let r =
|
|
1081
|
-
if (r &&
|
|
1078
|
+
let n = X(e);
|
|
1079
|
+
L(e);
|
|
1080
|
+
let r = Me.get(e);
|
|
1081
|
+
if (r && m(r, t)) return {
|
|
1082
1082
|
blockers: [],
|
|
1083
|
-
releases:
|
|
1083
|
+
releases: Q(n),
|
|
1084
1084
|
published: !0
|
|
1085
1085
|
};
|
|
1086
|
-
if (n.state !== "open") throw new
|
|
1086
|
+
if (n.state !== "open") throw new d(n.state);
|
|
1087
1087
|
return {
|
|
1088
|
-
blockers:
|
|
1089
|
-
releases:
|
|
1088
|
+
blockers: nt(n, t),
|
|
1089
|
+
releases: Q(n),
|
|
1090
1090
|
published: !1
|
|
1091
1091
|
};
|
|
1092
1092
|
},
|
|
1093
1093
|
async publish({ id: e, reviewedHeads: t }) {
|
|
1094
|
-
let n =
|
|
1095
|
-
|
|
1096
|
-
let r =
|
|
1097
|
-
if (r &&
|
|
1094
|
+
let n = X(e);
|
|
1095
|
+
L(e);
|
|
1096
|
+
let r = Me.get(e);
|
|
1097
|
+
if (r && m(r, t)) return {
|
|
1098
1098
|
changeSet: A(n),
|
|
1099
|
-
publishTime: n.closeTime ??
|
|
1100
|
-
releases:
|
|
1099
|
+
publishTime: n.closeTime ?? y(),
|
|
1100
|
+
releases: Q(n)
|
|
1101
1101
|
};
|
|
1102
|
-
if (n.state !== "open") throw new
|
|
1103
|
-
let i =
|
|
1104
|
-
if (i.length > 0) throw new
|
|
1105
|
-
let a =
|
|
1106
|
-
return n.state = "published", n.closeTime =
|
|
1102
|
+
if (n.state !== "open") throw new d(n.state);
|
|
1103
|
+
let i = nt(n, t);
|
|
1104
|
+
if (i.length > 0) throw new o(i);
|
|
1105
|
+
let a = Q(n);
|
|
1106
|
+
return n.state = "published", n.closeTime = y(), Me.set(e, { ...t }), {
|
|
1107
1107
|
changeSet: A(n),
|
|
1108
1108
|
publishTime: n.closeTime,
|
|
1109
1109
|
releases: a
|
|
1110
1110
|
};
|
|
1111
1111
|
},
|
|
1112
1112
|
async updateFromMain({ id: e, chainId: t, idempotencyKey: n }) {
|
|
1113
|
-
return
|
|
1113
|
+
return V(n, [
|
|
1114
1114
|
"updateFromMain",
|
|
1115
1115
|
e,
|
|
1116
1116
|
t
|
|
1117
1117
|
], async () => {
|
|
1118
|
-
let n =
|
|
1119
|
-
t ||
|
|
1118
|
+
let n = Z(e);
|
|
1119
|
+
t || L(e);
|
|
1120
1120
|
let r = t ? n.chains.filter((e) => e.id === t) : n.chains;
|
|
1121
1121
|
if (t && r.length === 0) throw k("Chain", t);
|
|
1122
|
-
let i = structuredClone(
|
|
1122
|
+
let i = structuredClone(ke[e] ?? []), a = [];
|
|
1123
1123
|
for (let e of r) for (let t of e.branches) {
|
|
1124
1124
|
let n = {
|
|
1125
1125
|
branchId: t.id,
|
|
1126
1126
|
contentId: e.contentId
|
|
1127
|
-
}, r =
|
|
1128
|
-
|
|
1127
|
+
}, r = Ae[t.id];
|
|
1128
|
+
B.has(t.id) ? a.push(n) : r && (Ke(t.id, r), i.push(n));
|
|
1129
1129
|
}
|
|
1130
1130
|
return {
|
|
1131
1131
|
changeSet: A(n),
|
|
@@ -1137,91 +1137,91 @@ function M(g = {}) {
|
|
|
1137
1137
|
});
|
|
1138
1138
|
},
|
|
1139
1139
|
async discardChangeSet(e) {
|
|
1140
|
-
let t =
|
|
1141
|
-
return
|
|
1140
|
+
let t = Z(e);
|
|
1141
|
+
return L(e), t.state = "discarded", t.closeTime = y(), t.chains = [], A(t);
|
|
1142
1142
|
},
|
|
1143
1143
|
async listCheckResults(e) {
|
|
1144
|
-
return
|
|
1145
|
-
},
|
|
1146
|
-
async recordCheckResult({ changeSetId:
|
|
1147
|
-
let
|
|
1148
|
-
if (
|
|
1149
|
-
if ([...
|
|
1150
|
-
let
|
|
1151
|
-
if (!
|
|
1152
|
-
let
|
|
1153
|
-
if (
|
|
1154
|
-
let
|
|
1155
|
-
if (
|
|
1156
|
-
if (
|
|
1157
|
-
for (let
|
|
1158
|
-
let
|
|
1159
|
-
if (!
|
|
1160
|
-
if (
|
|
1161
|
-
contentId:
|
|
1162
|
-
branchId:
|
|
1163
|
-
expectedHeadId:
|
|
1164
|
-
currentHeadId:
|
|
1144
|
+
return tt(X(e));
|
|
1145
|
+
},
|
|
1146
|
+
async recordCheckResult({ changeSetId: t, requiredCheckId: n, heads: r, outcome: i, note: o }) {
|
|
1147
|
+
let s = Z(t);
|
|
1148
|
+
if (i === "waived" && o.trim() === "") throw new a("a waived result needs a note saying why");
|
|
1149
|
+
if ([...o].length > 2e3) throw new a(`a note is at most ${l} characters`);
|
|
1150
|
+
let c = F.find((e) => e.id === n);
|
|
1151
|
+
if (!c) throw k("Required Check", n);
|
|
1152
|
+
let d = we(n);
|
|
1153
|
+
if (I === "guardian" && !d.everyMember && !d.userIds.includes(b)) throw new u(`recording results of Required Check ${n} needs its recorder relation`);
|
|
1154
|
+
let f = Qe(s), p = Object.keys(r);
|
|
1155
|
+
if (c.scope === "branch" && p.length !== 1) throw new a("a Branch-scope result names one head");
|
|
1156
|
+
if (c.scope === "change_set" && p.length !== f.length) throw new a("a Change Set-scope result names every head of the Change Set");
|
|
1157
|
+
for (let t of p) {
|
|
1158
|
+
let n = f.find((e) => e.key === t);
|
|
1159
|
+
if (!n) throw new a(`heads name ${t}, which this Change Set doesn't hold`);
|
|
1160
|
+
if (n.revision !== r[t]) throw new e({
|
|
1161
|
+
contentId: n.contentId,
|
|
1162
|
+
branchId: n.branchless ? "" : n.key,
|
|
1163
|
+
expectedHeadId: r[t],
|
|
1164
|
+
currentHeadId: n.revision
|
|
1165
1165
|
});
|
|
1166
1166
|
}
|
|
1167
1167
|
let m = {
|
|
1168
|
-
id: `cr_stub_${
|
|
1169
|
-
requiredCheckId:
|
|
1170
|
-
heads: { ...
|
|
1171
|
-
outcome:
|
|
1172
|
-
note:
|
|
1173
|
-
recordedBy:
|
|
1174
|
-
recordTime:
|
|
1168
|
+
id: `cr_stub_${H++}`,
|
|
1169
|
+
requiredCheckId: n,
|
|
1170
|
+
heads: { ...r },
|
|
1171
|
+
outcome: i,
|
|
1172
|
+
note: o,
|
|
1173
|
+
recordedBy: b,
|
|
1174
|
+
recordTime: y()
|
|
1175
1175
|
};
|
|
1176
|
-
return
|
|
1176
|
+
return De.push({
|
|
1177
1177
|
...m,
|
|
1178
|
-
changeSetId:
|
|
1178
|
+
changeSetId: t
|
|
1179
1179
|
}), structuredClone(m);
|
|
1180
1180
|
},
|
|
1181
1181
|
async listRequiredChecks() {
|
|
1182
1182
|
let e = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
|
|
1183
|
-
return structuredClone([...
|
|
1183
|
+
return structuredClone([...F].sort(e));
|
|
1184
1184
|
},
|
|
1185
1185
|
async createRequiredCheck(e) {
|
|
1186
|
-
let
|
|
1187
|
-
if (
|
|
1188
|
-
let
|
|
1189
|
-
id: `rc_stub_${
|
|
1190
|
-
...
|
|
1186
|
+
let t = ye(e);
|
|
1187
|
+
if (F.some((e) => e.name === t.name)) throw new g(t.name);
|
|
1188
|
+
let n = {
|
|
1189
|
+
id: `rc_stub_${H++}`,
|
|
1190
|
+
...t
|
|
1191
1191
|
};
|
|
1192
|
-
return
|
|
1192
|
+
return F.push(n), structuredClone(n);
|
|
1193
1193
|
},
|
|
1194
|
-
async updateRequiredCheck({ id: e, ...
|
|
1195
|
-
let
|
|
1196
|
-
if (!
|
|
1197
|
-
if (
|
|
1198
|
-
return Object.assign(
|
|
1194
|
+
async updateRequiredCheck({ id: e, ...t }) {
|
|
1195
|
+
let n = ye(t), r = F.find((t) => t.id === e);
|
|
1196
|
+
if (!r) throw k("Required Check", e);
|
|
1197
|
+
if (F.some((t) => t.name === n.name && t.id !== e)) throw new g(n.name);
|
|
1198
|
+
return Object.assign(r, n), structuredClone(r);
|
|
1199
1199
|
},
|
|
1200
1200
|
async deleteRequiredCheck({ id: e }) {
|
|
1201
|
-
if (!
|
|
1202
|
-
|
|
1201
|
+
if (!F.some((t) => t.id === e)) throw k("Required Check", e);
|
|
1202
|
+
F = F.filter((t) => t.id !== e), z.delete(e);
|
|
1203
1203
|
},
|
|
1204
1204
|
async listRequiredCheckRecorders(e) {
|
|
1205
|
-
return structuredClone(
|
|
1205
|
+
return structuredClone(He(e));
|
|
1206
1206
|
},
|
|
1207
1207
|
async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1208
|
-
let n =
|
|
1208
|
+
let n = He(e);
|
|
1209
1209
|
if ("everyMember" in t) {
|
|
1210
|
-
|
|
1210
|
+
z.set(e, {
|
|
1211
1211
|
...n,
|
|
1212
1212
|
everyMember: !0
|
|
1213
1213
|
});
|
|
1214
1214
|
return;
|
|
1215
1215
|
}
|
|
1216
|
-
if (!
|
|
1217
|
-
|
|
1216
|
+
if (!Te.includes(t.userId)) throw new a(`user ${t.userId} is not a member of the workspace`);
|
|
1217
|
+
z.set(e, {
|
|
1218
1218
|
...n,
|
|
1219
1219
|
userIds: [.../* @__PURE__ */ new Set([...n.userIds, t.userId])].sort()
|
|
1220
1220
|
});
|
|
1221
1221
|
},
|
|
1222
1222
|
async revokeRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1223
|
-
let n =
|
|
1224
|
-
|
|
1223
|
+
let n = He(e);
|
|
1224
|
+
z.set(e, "everyMember" in t ? {
|
|
1225
1225
|
...n,
|
|
1226
1226
|
everyMember: !1
|
|
1227
1227
|
} : {
|
|
@@ -1229,94 +1229,121 @@ function M(g = {}) {
|
|
|
1229
1229
|
userIds: n.userIds.filter((e) => e !== t.userId)
|
|
1230
1230
|
});
|
|
1231
1231
|
},
|
|
1232
|
-
async
|
|
1233
|
-
|
|
1232
|
+
async searchBlueprints({ query: e }) {
|
|
1233
|
+
let t = e.trim().toLocaleLowerCase();
|
|
1234
|
+
return {
|
|
1235
|
+
blueprints: he.filter((e) => !e.archived).filter((e) => e.name.toLocaleLowerCase().includes(t)).filter((e) => M.some((t) => t.blueprintId === e.id)).map((e) => ({
|
|
1236
|
+
id: e.id,
|
|
1237
|
+
name: e.name
|
|
1238
|
+
})),
|
|
1239
|
+
nextPageToken: ""
|
|
1240
|
+
};
|
|
1241
|
+
},
|
|
1242
|
+
async getBlueprints(e) {
|
|
1243
|
+
if (e.length > 1e3) throw new a(`at most ${t} Blueprint ids`);
|
|
1244
|
+
return he.filter((t) => e.includes(t.id)).map((e) => ({
|
|
1245
|
+
id: e.id,
|
|
1246
|
+
name: e.name
|
|
1247
|
+
}));
|
|
1248
|
+
},
|
|
1249
|
+
async listBlueprintReleases(e) {
|
|
1250
|
+
return M.filter((t) => t.blueprintId === e).map((e) => ({
|
|
1251
|
+
id: e.id,
|
|
1252
|
+
blueprintId: e.blueprintId,
|
|
1253
|
+
name: e.name ?? e.id,
|
|
1254
|
+
releaseTime: e.releaseTime ?? "2026-10-01T09:00:00.000Z",
|
|
1255
|
+
refusals: (e.refusals ?? []).map((e) => ({ ...e }))
|
|
1256
|
+
}));
|
|
1234
1257
|
},
|
|
1235
|
-
async
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
let
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1258
|
+
async listCollections() {
|
|
1259
|
+
return [...T].sort(ze).map((e) => ({ ...e }));
|
|
1260
|
+
},
|
|
1261
|
+
async createCollection({ name: e, parentId: t = "", restricted: r = !1 }) {
|
|
1262
|
+
let i = O(e, "a Collection's name", 200);
|
|
1263
|
+
if (t !== "" && Y(t), r && I === "workspace") throw new n(Se);
|
|
1264
|
+
if (Be(t, i)) throw new g(i);
|
|
1265
|
+
let a = {
|
|
1266
|
+
id: `col_stub_${H++}`,
|
|
1267
|
+
name: i,
|
|
1268
|
+
parentId: t,
|
|
1269
|
+
restricted: r
|
|
1244
1270
|
};
|
|
1245
|
-
return
|
|
1246
|
-
userId:
|
|
1271
|
+
return T.push(a), r && R.set(a.id, [{
|
|
1272
|
+
userId: b,
|
|
1247
1273
|
level: "owner"
|
|
1248
|
-
}]), { ...
|
|
1274
|
+
}]), { ...a };
|
|
1249
1275
|
},
|
|
1250
|
-
async renameCollection({ id: e, name:
|
|
1251
|
-
let
|
|
1252
|
-
if (
|
|
1253
|
-
return
|
|
1276
|
+
async renameCollection({ id: e, name: t }) {
|
|
1277
|
+
let n = O(t, "a Collection's name", 200), r = Y(e);
|
|
1278
|
+
if (Be(r.parentId, n, e)) throw new g(n);
|
|
1279
|
+
return r.name = n, { ...r };
|
|
1254
1280
|
},
|
|
1255
|
-
async moveCollection({ id: e, parentId:
|
|
1256
|
-
let
|
|
1257
|
-
for (let
|
|
1258
|
-
if (
|
|
1259
|
-
return
|
|
1281
|
+
async moveCollection({ id: e, parentId: t }) {
|
|
1282
|
+
let n = Y(e);
|
|
1283
|
+
for (let n = t; n !== ""; n = Y(n).parentId) if (n === e) throw new a(`Collection ${e} can't move under itself or a Collection under it`);
|
|
1284
|
+
if (Be(t, n.name, e)) throw new g("");
|
|
1285
|
+
return n.parentId = t, { ...n };
|
|
1260
1286
|
},
|
|
1261
1287
|
async removeCollection({ id: e }) {
|
|
1262
|
-
if (
|
|
1263
|
-
|
|
1288
|
+
if (Y(e), T.some((t) => t.parentId === e)) throw new a(`Collection ${e} has Collections under it: remove or move those first`);
|
|
1289
|
+
T.splice(T.findIndex((t) => t.id === e), 1), R.delete(e);
|
|
1264
1290
|
let t = [];
|
|
1265
|
-
for (let n of
|
|
1291
|
+
for (let n of D) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
|
|
1266
1292
|
return t;
|
|
1267
1293
|
},
|
|
1268
1294
|
async setCollectionRestricted({ id: e, restricted: t, acknowledgeDisclosure: r = !1 }) {
|
|
1269
|
-
if (t &&
|
|
1270
|
-
let
|
|
1271
|
-
if (
|
|
1272
|
-
if (!t && !r) throw new
|
|
1273
|
-
return
|
|
1274
|
-
userId:
|
|
1295
|
+
if (t && I === "workspace") throw new n(Se);
|
|
1296
|
+
let i = Y(e);
|
|
1297
|
+
if (i.restricted === t) return { ...i };
|
|
1298
|
+
if (!t && !r) throw new a(`unrestricting Collection ${e} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
|
|
1299
|
+
return i.restricted = t, t ? R.set(e, [{
|
|
1300
|
+
userId: b,
|
|
1275
1301
|
level: "owner"
|
|
1276
|
-
}]) :
|
|
1302
|
+
}]) : R.delete(e), { ...i };
|
|
1277
1303
|
},
|
|
1278
1304
|
async listCollectionGrants(e) {
|
|
1279
|
-
return
|
|
1305
|
+
return Ve(e), structuredClone(R.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
|
|
1280
1306
|
},
|
|
1281
1307
|
async grantCollectionAccess({ collectionId: e, userId: t, level: n }) {
|
|
1282
|
-
if (
|
|
1283
|
-
if (!
|
|
1284
|
-
let r =
|
|
1285
|
-
r.some((e) => e.level === "owner" && e.userId === t) ||
|
|
1308
|
+
if (Ve(e), n !== "viewer" && n !== "editor") throw new a("a grant is viewer or editor");
|
|
1309
|
+
if (!Te.includes(t)) throw new a(`${t} is not a member of the workspace`);
|
|
1310
|
+
let r = R.get(e) ?? [];
|
|
1311
|
+
r.some((e) => e.level === "owner" && e.userId === t) || R.set(e, [...r.filter((e) => e.userId !== t), {
|
|
1286
1312
|
userId: t,
|
|
1287
1313
|
level: n
|
|
1288
1314
|
}]);
|
|
1289
1315
|
},
|
|
1290
1316
|
async revokeCollectionAccess({ collectionId: e, userId: t }) {
|
|
1291
|
-
|
|
1317
|
+
Ve(e), R.set(e, (R.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
|
|
1292
1318
|
},
|
|
1293
1319
|
async listContents(e = {}) {
|
|
1294
1320
|
let t = e.view ?? { kind: "main" }, n = (e.search ?? "").trim();
|
|
1295
|
-
if (n !== "" && t.kind === "in_force") throw new
|
|
1296
|
-
if ([...n].length > 200) throw new
|
|
1297
|
-
if (e.collectionId && !
|
|
1298
|
-
t.kind === "change_set" &&
|
|
1299
|
-
let r =
|
|
1321
|
+
if (n !== "" && t.kind === "in_force") throw new a("filter.search: Editor Search covers Main and open Branch heads, never Releases");
|
|
1322
|
+
if ([...n].length > 200) throw new a("filter.search is at most 200 characters");
|
|
1323
|
+
if (e.collectionId && !T.some((t) => t.id === e.collectionId)) throw k("Collection", e.collectionId);
|
|
1324
|
+
t.kind === "change_set" && X(t.changeSetId);
|
|
1325
|
+
let r = D.filter((e) => !e.archiveTime).filter((t) => !e.collectionId || t.collectionIds.includes(e.collectionId)).filter((t) => !e.blueprintIds?.length || e.blueprintIds.includes(t.blueprintId)).filter((t) => !e.assigneeId || (t.assigneeIds ?? []).includes(e.assigneeId)).sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)).flatMap((e) => $(e, t, n)), i = Math.min(e.pageSize || 50, 200), o = e.pageToken ? Number(e.pageToken) : 0;
|
|
1300
1326
|
return {
|
|
1301
|
-
contents: r.slice(o, o +
|
|
1302
|
-
nextPageToken: o +
|
|
1327
|
+
contents: r.slice(o, o + i),
|
|
1328
|
+
nextPageToken: o + i < r.length ? String(o + i) : ""
|
|
1303
1329
|
};
|
|
1304
1330
|
},
|
|
1305
1331
|
async createContent({ changeSetId: e, blueprintReleaseId: t, copyFrom: n }) {
|
|
1306
|
-
let r =
|
|
1332
|
+
let r = Z(e), i = {}, a = t;
|
|
1307
1333
|
if (n) {
|
|
1308
|
-
let e = "revisionId" in n ? n.revisionId :
|
|
1334
|
+
let e = "revisionId" in n ? n.revisionId : D.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = D.find((t) => e && q(t, e));
|
|
1309
1335
|
if (!r || !e) throw k("copy source", JSON.stringify(n));
|
|
1310
|
-
i = structuredClone(
|
|
1336
|
+
i = structuredClone(q(r, e) ?? {}), a = t || r.blueprintReleaseId;
|
|
1311
1337
|
}
|
|
1312
|
-
let o =
|
|
1313
|
-
if (!o) throw new
|
|
1338
|
+
let o = M.find((e) => e.id === a);
|
|
1339
|
+
if (!o) throw new _(`Blueprint Release ${a} can't be loaded`, [{
|
|
1314
1340
|
source: "contenthub",
|
|
1315
1341
|
code: "release_not_found",
|
|
1316
1342
|
path: ""
|
|
1317
1343
|
}]);
|
|
1318
|
-
|
|
1319
|
-
|
|
1344
|
+
if (o.refusals?.length) throw new _(`Blueprint Release ${a} can't be loaded`, o.refusals.map((e) => ({ ...e })));
|
|
1345
|
+
let s = H++, c = `content_stub_${s}`, l = `br_stub_${s}`, u = `rev_stub_${s}`;
|
|
1346
|
+
return D.push({
|
|
1320
1347
|
id: c,
|
|
1321
1348
|
blueprintId: o.blueprintId,
|
|
1322
1349
|
blueprintReleaseId: a,
|
|
@@ -1325,7 +1352,7 @@ function M(g = {}) {
|
|
|
1325
1352
|
branchId: l,
|
|
1326
1353
|
revisionId: u,
|
|
1327
1354
|
data: i,
|
|
1328
|
-
revisionCreateTime:
|
|
1355
|
+
revisionCreateTime: y()
|
|
1329
1356
|
} }
|
|
1330
1357
|
}), r.chains.push({
|
|
1331
1358
|
id: `chain_stub_${s}`,
|
|
@@ -1345,38 +1372,38 @@ function M(g = {}) {
|
|
|
1345
1372
|
data: structuredClone(i),
|
|
1346
1373
|
changeSetId: e,
|
|
1347
1374
|
branchId: l,
|
|
1348
|
-
revisionCreateTime:
|
|
1375
|
+
revisionCreateTime: y(),
|
|
1349
1376
|
releaseId: ""
|
|
1350
1377
|
};
|
|
1351
1378
|
},
|
|
1352
1379
|
async saveRevision({ idempotencyKey: e, ...t }) {
|
|
1353
|
-
if (!e) return
|
|
1354
|
-
let n = JSON.stringify(t), r =
|
|
1380
|
+
if (!e) return Ue(t);
|
|
1381
|
+
let n = JSON.stringify(t), r = Ne.get(e);
|
|
1355
1382
|
if (r) {
|
|
1356
|
-
if (r.asked !== n) throw new
|
|
1383
|
+
if (r.asked !== n) throw new a(`idempotency key ${e} names another save`);
|
|
1357
1384
|
return structuredClone(r.content);
|
|
1358
1385
|
}
|
|
1359
|
-
let
|
|
1360
|
-
return
|
|
1386
|
+
let i = await Ue(t);
|
|
1387
|
+
return Ne.set(e, {
|
|
1361
1388
|
asked: n,
|
|
1362
|
-
content: structuredClone(
|
|
1363
|
-
}),
|
|
1389
|
+
content: structuredClone(i)
|
|
1390
|
+
}), i;
|
|
1364
1391
|
},
|
|
1365
1392
|
async getContent({ id: e, changeSetId: t }) {
|
|
1366
|
-
let n =
|
|
1393
|
+
let n = U(e), [r] = $(n, t ? {
|
|
1367
1394
|
kind: "change_set",
|
|
1368
1395
|
changeSetId: t
|
|
1369
1396
|
} : { kind: "main" }, "");
|
|
1370
1397
|
if (!r) throw k("Content", e);
|
|
1371
|
-
let i =
|
|
1398
|
+
let i = P[n.blueprintReleaseId];
|
|
1372
1399
|
return {
|
|
1373
1400
|
content: r,
|
|
1374
1401
|
blueprintRelease: i ? structuredClone(i) : void 0,
|
|
1375
|
-
attributes:
|
|
1402
|
+
attributes: W(n)
|
|
1376
1403
|
};
|
|
1377
1404
|
},
|
|
1378
1405
|
async getTimeline(e) {
|
|
1379
|
-
let t =
|
|
1406
|
+
let t = U(e), n = (e) => w.find((t) => t.id === e)?.state === "open";
|
|
1380
1407
|
return structuredClone({
|
|
1381
1408
|
entries: t.timeline ?? [],
|
|
1382
1409
|
plannedReleases: (t.plannedReleases ?? []).filter((e) => n(e.changeSetId))
|
|
@@ -1385,13 +1412,13 @@ function M(g = {}) {
|
|
|
1385
1412
|
async listRevisions({ target: e, pageSize: t, pageToken: n }) {
|
|
1386
1413
|
let r;
|
|
1387
1414
|
if ("contentId" in e) {
|
|
1388
|
-
let t =
|
|
1415
|
+
let t = U(e.contentId);
|
|
1389
1416
|
if (!t.main) throw k("Content", e.contentId);
|
|
1390
|
-
r =
|
|
1417
|
+
r = K(t);
|
|
1391
1418
|
} else {
|
|
1392
|
-
let t =
|
|
1419
|
+
let t = D.find((t) => K(t).some((t) => t.branchId === e.branchId));
|
|
1393
1420
|
if (!t) throw k("Branch", e.branchId);
|
|
1394
|
-
r =
|
|
1421
|
+
r = K(t).filter((t) => t.branchId === e.branchId);
|
|
1395
1422
|
}
|
|
1396
1423
|
let i = Math.min(t || 50, 200), a = n ? Number(n) : 0;
|
|
1397
1424
|
return {
|
|
@@ -1400,17 +1427,17 @@ function M(g = {}) {
|
|
|
1400
1427
|
};
|
|
1401
1428
|
},
|
|
1402
1429
|
async compare({ revisionId: e, base: t }) {
|
|
1403
|
-
let n =
|
|
1430
|
+
let n = D.find((t) => K(t).some((t) => t.id === e));
|
|
1404
1431
|
if (!n) throw k("Revision", e);
|
|
1405
|
-
let r =
|
|
1432
|
+
let r = K(n), i = r.find((t) => t.id === e), o;
|
|
1406
1433
|
if (t.kind === "revision") o = t.revisionId;
|
|
1407
1434
|
else if (t.kind === "main_head") {
|
|
1408
|
-
if (!n.main) throw new
|
|
1435
|
+
if (!n.main) throw new a("the Content is not published: it has no Main Branch");
|
|
1409
1436
|
o = n.main.revisionId;
|
|
1410
1437
|
} else o = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
|
|
1411
1438
|
let s = r.find((e) => e.id === o);
|
|
1412
1439
|
if (!s) throw k("Revision", o);
|
|
1413
|
-
let c =
|
|
1440
|
+
let c = q(n, i.id) ?? {}, l = q(n, s.id) ?? {}, u = [];
|
|
1414
1441
|
for (let e of [.../* @__PURE__ */ new Set([...Object.keys(c), ...Object.keys(l)])]) e in l ? e in c ? JSON.stringify(c[e]) !== JSON.stringify(l[e]) && u.push({
|
|
1415
1442
|
path: `/${e}`,
|
|
1416
1443
|
kind: "changed",
|
|
@@ -1428,29 +1455,29 @@ function M(g = {}) {
|
|
|
1428
1455
|
let d = ({ data: e, ...t }) => t;
|
|
1429
1456
|
return {
|
|
1430
1457
|
base: d(s),
|
|
1431
|
-
revision: d(
|
|
1458
|
+
revision: d(i),
|
|
1432
1459
|
changes: u
|
|
1433
1460
|
};
|
|
1434
1461
|
},
|
|
1435
1462
|
async listReferences({ contentId: e, revisionId: t }) {
|
|
1436
|
-
return (
|
|
1463
|
+
return (U(e).edges ?? []).filter((e) => e.sourceRevisionId === t).map((e) => ({ ...e }));
|
|
1437
1464
|
},
|
|
1438
1465
|
async listReferrers({ contentId: e, includeOpenChangeSets: t, pageSize: n, pageToken: r }) {
|
|
1439
|
-
|
|
1466
|
+
U(e);
|
|
1440
1467
|
let i = (e) => {
|
|
1441
1468
|
let t = Math.min(n || 100, 1e3), i = r ? Number(r) : 0;
|
|
1442
1469
|
return {
|
|
1443
1470
|
referrers: e.slice(i, i + t),
|
|
1444
1471
|
nextPageToken: i + t < e.length ? String(i + t) : ""
|
|
1445
1472
|
};
|
|
1446
|
-
}, a =
|
|
1473
|
+
}, a = D.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
|
|
1447
1474
|
edge: { ...e },
|
|
1448
1475
|
releaseId: t.inForce?.releaseId ?? "",
|
|
1449
1476
|
changeSetId: "",
|
|
1450
1477
|
branchId: ""
|
|
1451
1478
|
})));
|
|
1452
1479
|
if (!t) return i(a);
|
|
1453
|
-
let o =
|
|
1480
|
+
let o = D.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => w.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
|
|
1454
1481
|
edge: { ...e },
|
|
1455
1482
|
releaseId: "",
|
|
1456
1483
|
changeSetId: n,
|
|
@@ -1462,14 +1489,14 @@ function M(g = {}) {
|
|
|
1462
1489
|
let t;
|
|
1463
1490
|
if ("revisionId" in e) t = e.revisionId;
|
|
1464
1491
|
else {
|
|
1465
|
-
for (let n of
|
|
1492
|
+
for (let n of D) {
|
|
1466
1493
|
let r = Object.values(n.branches).find((t) => t.branchId === e.branchId);
|
|
1467
1494
|
r && (t = r.revisionId);
|
|
1468
1495
|
}
|
|
1469
1496
|
if (!t) throw k("Branch", e.branchId);
|
|
1470
1497
|
}
|
|
1471
|
-
return
|
|
1472
|
-
let t =
|
|
1498
|
+
return D.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
|
|
1499
|
+
let t = D.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
|
|
1473
1500
|
return t === e.pinReleaseId ? [] : [{
|
|
1474
1501
|
edge: { ...e },
|
|
1475
1502
|
supersededByReleaseId: t,
|
|
@@ -1478,71 +1505,71 @@ function M(g = {}) {
|
|
|
1478
1505
|
});
|
|
1479
1506
|
},
|
|
1480
1507
|
async setContentCollections({ contentId: e, collectionIds: t }) {
|
|
1481
|
-
let n =
|
|
1482
|
-
if (r.length > 100) throw new
|
|
1483
|
-
for (let e of r) if (!
|
|
1508
|
+
let n = U(e), r = [...new Set(t)];
|
|
1509
|
+
if (r.length > 100) throw new a("at most 100 Collections");
|
|
1510
|
+
for (let e of r) if (!T.some((t) => t.id === e)) throw k("Collection", e);
|
|
1484
1511
|
return n.collectionIds = r.sort(), [...n.collectionIds];
|
|
1485
1512
|
},
|
|
1486
1513
|
async setContentAssignees({ contentId: e, assigneeIds: t }) {
|
|
1487
|
-
let n =
|
|
1488
|
-
if (new Set(t).size !== t.length) throw new
|
|
1489
|
-
if (t.length > 50) throw new
|
|
1490
|
-
return n.assigneeIds = [...t],
|
|
1514
|
+
let n = U(e);
|
|
1515
|
+
if (new Set(t).size !== t.length) throw new a("each assignee is given once");
|
|
1516
|
+
if (t.length > 50) throw new a("at most 50 assignees");
|
|
1517
|
+
return n.assigneeIds = [...t], W(n);
|
|
1491
1518
|
},
|
|
1492
1519
|
async blockContent({ contentId: e, blockReasonId: t, allowedUserIds: n }) {
|
|
1493
|
-
let r =
|
|
1494
|
-
if (!
|
|
1495
|
-
if (new Set(n).size !== n.length) throw new
|
|
1520
|
+
let r = U(e);
|
|
1521
|
+
if (!C.some((e) => e.id === t)) throw k("Block Reason", t);
|
|
1522
|
+
if (new Set(n).size !== n.length) throw new a("each allowed user is given once");
|
|
1496
1523
|
return r.block = {
|
|
1497
1524
|
blockReasonId: t,
|
|
1498
1525
|
allowedUserIds: [...n],
|
|
1499
|
-
blockedBy:
|
|
1500
|
-
blockTime:
|
|
1501
|
-
},
|
|
1526
|
+
blockedBy: b,
|
|
1527
|
+
blockTime: y()
|
|
1528
|
+
}, W(r);
|
|
1502
1529
|
},
|
|
1503
1530
|
async unblockContent(e) {
|
|
1504
|
-
let t =
|
|
1505
|
-
return t.block = void 0,
|
|
1531
|
+
let t = U(e);
|
|
1532
|
+
return t.block = void 0, W(t);
|
|
1506
1533
|
},
|
|
1507
1534
|
async archiveContent(e) {
|
|
1508
|
-
let t =
|
|
1509
|
-
if (t.archiveTime) return
|
|
1510
|
-
if (!t.main) throw new
|
|
1511
|
-
if (
|
|
1512
|
-
return t.archiveTime =
|
|
1535
|
+
let t = U(e);
|
|
1536
|
+
if (t.archiveTime) return W(t);
|
|
1537
|
+
if (!t.main) throw new a(`Content ${e} is not published: discard its Change Set instead of archiving it`);
|
|
1538
|
+
if (f(t.timeline ?? [], Pe())) throw new a(`Content ${e} has a Release In Force today or later: end its force first`);
|
|
1539
|
+
return t.archiveTime = y(), W(t);
|
|
1513
1540
|
},
|
|
1514
1541
|
async unarchiveContent(e) {
|
|
1515
|
-
let t =
|
|
1516
|
-
return t.archiveTime = void 0,
|
|
1542
|
+
let t = U(e);
|
|
1543
|
+
return t.archiveTime = void 0, W(t);
|
|
1517
1544
|
},
|
|
1518
1545
|
async startEditing({ contentId: e, changeSetId: t, effectiveOn: n = "", changeSetName: r = "" }) {
|
|
1519
|
-
let
|
|
1520
|
-
if (!
|
|
1521
|
-
if (
|
|
1522
|
-
if (!
|
|
1546
|
+
let i = U(e);
|
|
1547
|
+
if (!i.main) throw new a(`Content ${e} is not published`);
|
|
1548
|
+
if (J(i), G(i) && !h.test(n)) throw new a("effective_on is required for Dated Content, as YYYY-MM-DD");
|
|
1549
|
+
if (!G(i) && n !== "") throw new a("effective_on is refused for undated Content");
|
|
1523
1550
|
let o;
|
|
1524
1551
|
if (t) {
|
|
1525
|
-
if (o =
|
|
1552
|
+
if (o = Z(t), o.chains.some((t) => t.contentId === e)) throw new a(`Content ${e} already has a Chain in this Change Set`);
|
|
1526
1553
|
} else {
|
|
1527
|
-
let t = Object.values(
|
|
1554
|
+
let t = Object.values(i.main.data).filter((e) => typeof e == "string").slice(0, 2).join(" ");
|
|
1528
1555
|
o = {
|
|
1529
|
-
id: `cs_stub_${
|
|
1530
|
-
name: r.trim() ?
|
|
1556
|
+
id: `cs_stub_${H++}`,
|
|
1557
|
+
name: r.trim() ? O(r, "change_set_name", 200) : t || e,
|
|
1531
1558
|
state: "open",
|
|
1532
|
-
createdBy:
|
|
1533
|
-
createTime:
|
|
1559
|
+
createdBy: b,
|
|
1560
|
+
createTime: y(),
|
|
1534
1561
|
chains: [],
|
|
1535
1562
|
dependsOnChangeSetIds: [],
|
|
1536
1563
|
status: "",
|
|
1537
1564
|
assigneeIds: [],
|
|
1538
1565
|
plannedReleases: []
|
|
1539
|
-
},
|
|
1566
|
+
}, w.unshift(o);
|
|
1540
1567
|
}
|
|
1541
|
-
let s =
|
|
1542
|
-
...structuredClone(
|
|
1568
|
+
let s = H++, c = `br_stub_${s}`, l = {
|
|
1569
|
+
...structuredClone(i.main),
|
|
1543
1570
|
branchId: c
|
|
1544
1571
|
};
|
|
1545
|
-
|
|
1572
|
+
i.branches[o.id] = l, o.chains.push({
|
|
1546
1573
|
id: `chain_stub_${s}`,
|
|
1547
1574
|
contentId: e,
|
|
1548
1575
|
born: !1,
|
|
@@ -1553,7 +1580,7 @@ function M(g = {}) {
|
|
|
1553
1580
|
headRevisionId: l.revisionId
|
|
1554
1581
|
}]
|
|
1555
1582
|
});
|
|
1556
|
-
let [u] =
|
|
1583
|
+
let [u] = $(i, {
|
|
1557
1584
|
kind: "change_set",
|
|
1558
1585
|
changeSetId: o.id
|
|
1559
1586
|
}, "");
|
|
@@ -1563,12 +1590,12 @@ function M(g = {}) {
|
|
|
1563
1590
|
};
|
|
1564
1591
|
},
|
|
1565
1592
|
async previewChain({ changeSetId: e, contentId: t, effectiveOn: n, validityPeriod: r }) {
|
|
1566
|
-
|
|
1567
|
-
let
|
|
1568
|
-
if (!
|
|
1569
|
-
if (!
|
|
1570
|
-
if (!h.test(n)) throw new
|
|
1571
|
-
let o =
|
|
1593
|
+
Z(e);
|
|
1594
|
+
let i = U(t);
|
|
1595
|
+
if (!i.main) throw new a(`Content ${t} is not published`);
|
|
1596
|
+
if (!G(i)) throw new a("undated Content's Chain takes no date");
|
|
1597
|
+
if (!h.test(n)) throw new a("effective_on is YYYY-MM-DD");
|
|
1598
|
+
let o = i.timeline ?? [], s = o.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
|
|
1572
1599
|
return {
|
|
1573
1600
|
forkReleaseId: s?.releaseId ?? "",
|
|
1574
1601
|
carryForwardReleaseIds: o.filter((e) => e.validityPeriod && e.validityPeriod.firstDay > n).map((e) => e.releaseId),
|
|
@@ -1578,72 +1605,72 @@ function M(g = {}) {
|
|
|
1578
1605
|
};
|
|
1579
1606
|
},
|
|
1580
1607
|
async planRepeal({ changeSetId: e, contentId: t, lastDay: n }) {
|
|
1581
|
-
|
|
1582
|
-
let r =
|
|
1583
|
-
if (
|
|
1584
|
-
if (!h.test(n)) throw new
|
|
1585
|
-
return
|
|
1608
|
+
Z(e);
|
|
1609
|
+
let r = U(t);
|
|
1610
|
+
if (J(r), !G(r)) throw new a("a Repeal is for Dated Content");
|
|
1611
|
+
if (!h.test(n)) throw new a("last_day is YYYY-MM-DD");
|
|
1612
|
+
return rt(r, e, {
|
|
1586
1613
|
kind: "repeal",
|
|
1587
1614
|
validityPeriod: {
|
|
1588
|
-
firstDay:
|
|
1615
|
+
firstDay: ee(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
|
|
1589
1616
|
lastDay: n
|
|
1590
1617
|
}
|
|
1591
1618
|
});
|
|
1592
1619
|
},
|
|
1593
1620
|
async planWithdrawal({ changeSetId: e, contentId: t }) {
|
|
1594
|
-
|
|
1595
|
-
let n =
|
|
1596
|
-
if (
|
|
1597
|
-
return
|
|
1621
|
+
Z(e);
|
|
1622
|
+
let n = U(t);
|
|
1623
|
+
if (J(n), G(n)) throw new a("a Withdrawal is for undated Content");
|
|
1624
|
+
return rt(n, e, { kind: "withdrawal" });
|
|
1598
1625
|
},
|
|
1599
1626
|
async planRelease({ idempotencyKey: e, ...t }) {
|
|
1600
|
-
return
|
|
1601
|
-
let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec:
|
|
1602
|
-
if (
|
|
1603
|
-
if (s.plannedReleases.some((e) => e.branchId === n)) throw new
|
|
1627
|
+
return V(e, ["planRelease", t], async () => {
|
|
1628
|
+
let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: o } = t, { cs: s, chain: c, branch: l, c: u } = Ge(e, n);
|
|
1629
|
+
if (J(u), l.kind !== "editorial") throw new a("only an editorial Branch's head is released");
|
|
1630
|
+
if (s.plannedReleases.some((e) => e.branchId === n)) throw new a(`Branch ${n} is planned already`);
|
|
1604
1631
|
let d = {
|
|
1605
|
-
id: `rls_stub_${
|
|
1632
|
+
id: `rls_stub_${H++}`,
|
|
1606
1633
|
contentId: c.contentId,
|
|
1607
1634
|
kind: "revision",
|
|
1608
1635
|
branchId: n,
|
|
1609
1636
|
revisionId: "",
|
|
1610
1637
|
validityPeriod: r ? { ...r } : void 0,
|
|
1611
|
-
releaseSpec: structuredClone(
|
|
1638
|
+
releaseSpec: structuredClone(i ?? {}),
|
|
1612
1639
|
supersedesReleaseIds: [...o ?? []],
|
|
1613
1640
|
proposed: !1,
|
|
1614
1641
|
proposedForReleaseId: "",
|
|
1615
1642
|
splitFromReleaseId: "",
|
|
1616
1643
|
withheld: !1
|
|
1617
1644
|
};
|
|
1618
|
-
return
|
|
1645
|
+
return Je(u, d), s.plannedReleases.push(d), Ye(s, u), structuredClone(d);
|
|
1619
1646
|
});
|
|
1620
1647
|
},
|
|
1621
1648
|
async updatePlannedRelease({ idempotencyKey: e, ...t }) {
|
|
1622
|
-
return
|
|
1623
|
-
let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec:
|
|
1649
|
+
return V(e, ["updatePlannedRelease", t], async () => {
|
|
1650
|
+
let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: o } = t, s = Z(e), c = s.plannedReleases.findIndex((e) => e.id === n);
|
|
1624
1651
|
if (c < 0) throw k("Planned Release", n);
|
|
1625
1652
|
let l = s.plannedReleases[c];
|
|
1626
|
-
if (l.proposed) throw new
|
|
1627
|
-
let u =
|
|
1628
|
-
|
|
1653
|
+
if (l.proposed) throw new a("a proposal is derived from the plans and can't be set");
|
|
1654
|
+
let u = U(l.contentId);
|
|
1655
|
+
J(u);
|
|
1629
1656
|
let d = {
|
|
1630
1657
|
...structuredClone(l),
|
|
1631
1658
|
...r ? { validityPeriod: { ...r } } : {},
|
|
1632
|
-
...
|
|
1659
|
+
...i ? { releaseSpec: structuredClone(i) } : {},
|
|
1633
1660
|
...o ? { supersedesReleaseIds: [...o] } : {}
|
|
1634
1661
|
};
|
|
1635
|
-
return
|
|
1662
|
+
return Je(u, d), s.plannedReleases[c] = d, Ye(s, u), structuredClone(d);
|
|
1636
1663
|
});
|
|
1637
1664
|
},
|
|
1638
1665
|
async appendBranch({ idempotencyKey: e, ...t }) {
|
|
1639
|
-
return
|
|
1640
|
-
let { changeSetId: e, chainId: n, effectiveOn: r } = t,
|
|
1666
|
+
return V(e, ["appendBranch", t], async () => {
|
|
1667
|
+
let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = Z(e), o = i.chains.find((e) => e.id === n);
|
|
1641
1668
|
if (!o) throw k("Chain", n);
|
|
1642
|
-
let s =
|
|
1643
|
-
if (o.born || !
|
|
1669
|
+
let s = U(o.contentId);
|
|
1670
|
+
if (o.born || !G(s)) throw new a("only a Chain on published Dated Content takes dates");
|
|
1644
1671
|
let c = o.branches.filter((e) => e.kind === "editorial").at(-1);
|
|
1645
|
-
if (!h.test(r) || c?.effectiveOn && r <= c.effectiveOn) throw new
|
|
1646
|
-
let l = o.branches.at(-1), u = `br_stub_${
|
|
1672
|
+
if (!h.test(r) || c?.effectiveOn && r <= c.effectiveOn) throw new a("effective_on is a day after the Chain's last editorial Branch's");
|
|
1673
|
+
let l = o.branches.at(-1), u = `br_stub_${H++}`;
|
|
1647
1674
|
o.branches.push({
|
|
1648
1675
|
id: u,
|
|
1649
1676
|
position: o.branches.length,
|
|
@@ -1656,61 +1683,61 @@ function M(g = {}) {
|
|
|
1656
1683
|
...d,
|
|
1657
1684
|
branchId: u
|
|
1658
1685
|
}), {
|
|
1659
|
-
changeSet: A(
|
|
1686
|
+
changeSet: A(i),
|
|
1660
1687
|
branchId: u
|
|
1661
1688
|
};
|
|
1662
1689
|
});
|
|
1663
1690
|
},
|
|
1664
1691
|
async dropChain({ idempotencyKey: e, ...t }) {
|
|
1665
|
-
return
|
|
1666
|
-
let { changeSetId: e, chainId: n } = t, r =
|
|
1667
|
-
if (!
|
|
1668
|
-
if (
|
|
1669
|
-
for (let e of
|
|
1670
|
-
return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !==
|
|
1692
|
+
return V(e, ["dropChain", t], async () => {
|
|
1693
|
+
let { changeSetId: e, chainId: n } = t, r = Z(e), i = r.chains.find((e) => e.id === n);
|
|
1694
|
+
if (!i) throw k("Chain", n);
|
|
1695
|
+
if (i.born) throw new a("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
|
|
1696
|
+
for (let e of i.branches) qe(e.id);
|
|
1697
|
+
return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !== i.contentId), delete U(i.contentId).branches[e], A(r);
|
|
1671
1698
|
});
|
|
1672
1699
|
},
|
|
1673
1700
|
async getPendingMerge(e) {
|
|
1674
|
-
let t =
|
|
1701
|
+
let t = B.get(e);
|
|
1675
1702
|
return t ? structuredClone(t) : null;
|
|
1676
1703
|
},
|
|
1677
|
-
async resolveMerge({ idempotencyKey:
|
|
1678
|
-
return
|
|
1679
|
-
let { changeSetId:
|
|
1680
|
-
if (!
|
|
1681
|
-
if (
|
|
1682
|
-
contentId:
|
|
1683
|
-
branchId:
|
|
1684
|
-
expectedHeadId:
|
|
1685
|
-
currentHeadId:
|
|
1704
|
+
async resolveMerge({ idempotencyKey: t, ...n }) {
|
|
1705
|
+
return V(t, ["resolveMerge", n], async () => {
|
|
1706
|
+
let { changeSetId: t, branchId: r, expectedHeadId: i, resolutions: o } = n, { chain: s, branch: c, c: l } = Ge(t, r), u = B.get(r);
|
|
1707
|
+
if (!u) throw new a(`Branch ${r} has no Pending Merge`);
|
|
1708
|
+
if (c.headRevisionId !== i) throw new e({
|
|
1709
|
+
contentId: l.id,
|
|
1710
|
+
branchId: r,
|
|
1711
|
+
expectedHeadId: i,
|
|
1712
|
+
currentHeadId: c.headRevisionId
|
|
1686
1713
|
});
|
|
1687
|
-
let
|
|
1688
|
-
if (new Set(
|
|
1689
|
-
let p = structuredClone(
|
|
1690
|
-
for (let e of
|
|
1691
|
-
let t =
|
|
1714
|
+
let d = o.map((e) => e.path), f = u.fields.map((e) => e.path);
|
|
1715
|
+
if (new Set(d).size !== d.length || d.some((e) => !f.includes(e)) || f.some((e) => !d.includes(e))) throw new a("decide every field the Pending Merge lists, once");
|
|
1716
|
+
let p = structuredClone(u.merged);
|
|
1717
|
+
for (let e of o) {
|
|
1718
|
+
let t = u.fields.find((t) => t.path === e.path), n = "side" in e ? e.side === "ours" ? t.ours : t.theirs : e.value, r = e.path.replace(/^\//, "");
|
|
1692
1719
|
n === void 0 ? delete p[r] : p[r] = structuredClone(n);
|
|
1693
1720
|
}
|
|
1694
|
-
let m =
|
|
1695
|
-
changeSetId:
|
|
1696
|
-
chain:
|
|
1697
|
-
branch:
|
|
1698
|
-
c,
|
|
1721
|
+
let m = We({
|
|
1722
|
+
changeSetId: t,
|
|
1723
|
+
chain: s,
|
|
1724
|
+
branch: c,
|
|
1725
|
+
c: l,
|
|
1699
1726
|
data: p,
|
|
1700
1727
|
cause: "resolve",
|
|
1701
|
-
secondParentId:
|
|
1728
|
+
secondParentId: u.theirsRevisionId
|
|
1702
1729
|
});
|
|
1703
|
-
return
|
|
1730
|
+
return qe(r), m;
|
|
1704
1731
|
});
|
|
1705
1732
|
},
|
|
1706
1733
|
async abortMerge({ idempotencyKey: e, ...t }) {
|
|
1707
|
-
return
|
|
1708
|
-
if (
|
|
1709
|
-
|
|
1734
|
+
return V(e, ["abortMerge", t], async () => {
|
|
1735
|
+
if (Ge(t.changeSetId, t.branchId), !B.has(t.branchId)) throw new a(`Branch ${t.branchId} has no Pending Merge`);
|
|
1736
|
+
qe(t.branchId);
|
|
1710
1737
|
});
|
|
1711
1738
|
},
|
|
1712
1739
|
async previewInForce({ contentId: e, changeSetId: t, validOn: n }) {
|
|
1713
|
-
let r =
|
|
1740
|
+
let r = Z(t), i = U(e), a = n || Pe(), o = r.chains.find((t) => t.contentId === e), s = (e) => !e.validityPeriod || e.validityPeriod.firstDay <= a && (e.validityPeriod.lastDay === "" || a <= e.validityPeriod.lastDay), c = r.plannedReleases.find((t) => t.contentId === e && t.kind !== "repeal" && s(t));
|
|
1714
1741
|
if (c) {
|
|
1715
1742
|
let e = c.branchId ? o?.branches.find((e) => e.id === c.branchId)?.headRevisionId ?? "" : c.revisionId;
|
|
1716
1743
|
return {
|
|
@@ -1719,23 +1746,23 @@ function M(g = {}) {
|
|
|
1719
1746
|
planned: !0,
|
|
1720
1747
|
withheld: !1,
|
|
1721
1748
|
validityPeriod: c.validityPeriod ? { ...c.validityPeriod } : void 0,
|
|
1722
|
-
data: structuredClone(
|
|
1749
|
+
data: structuredClone(q(i, e) ?? {})
|
|
1723
1750
|
};
|
|
1724
1751
|
}
|
|
1725
|
-
let l =
|
|
1752
|
+
let l = ee(i.timeline ?? [], a);
|
|
1726
1753
|
return l ? {
|
|
1727
1754
|
releaseId: l.releaseId,
|
|
1728
1755
|
revisionId: l.revisionId,
|
|
1729
1756
|
planned: !1,
|
|
1730
1757
|
withheld: !1,
|
|
1731
1758
|
validityPeriod: l.validityPeriod ? { ...l.validityPeriod } : void 0,
|
|
1732
|
-
data: structuredClone(
|
|
1759
|
+
data: structuredClone(q(i, l.revisionId) ?? {})
|
|
1733
1760
|
} : null;
|
|
1734
1761
|
}
|
|
1735
1762
|
};
|
|
1736
|
-
function
|
|
1763
|
+
function rt(e, t, n) {
|
|
1737
1764
|
let r = {
|
|
1738
|
-
id: `rls_stub_${
|
|
1765
|
+
id: `rls_stub_${H++}`,
|
|
1739
1766
|
contentId: e.id,
|
|
1740
1767
|
branchId: "",
|
|
1741
1768
|
revisionId: e.inForce?.revisionId ?? e.main?.revisionId ?? "",
|
|
@@ -1751,10 +1778,10 @@ function M(g = {}) {
|
|
|
1751
1778
|
plannedRelease: r
|
|
1752
1779
|
}], structuredClone({
|
|
1753
1780
|
plannedRelease: r,
|
|
1754
|
-
gapReferrers:
|
|
1781
|
+
gapReferrers: Ie(e.id)
|
|
1755
1782
|
});
|
|
1756
1783
|
}
|
|
1757
|
-
function
|
|
1784
|
+
function $(e, t, n) {
|
|
1758
1785
|
let r = (t, n) => ({
|
|
1759
1786
|
id: e.id,
|
|
1760
1787
|
blueprintId: e.blueprintId,
|
|
@@ -1777,7 +1804,7 @@ function M(g = {}) {
|
|
|
1777
1804
|
if (!n) return e.main ? [r(e.main, {})] : [];
|
|
1778
1805
|
let i = [];
|
|
1779
1806
|
e.main && N(e.main.data, n) && i.push(r(e.main, {}));
|
|
1780
|
-
for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1))
|
|
1807
|
+
for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1)) w.find((e) => e.id === t)?.state === "open" && N(a.data, n) && i.push(r(a, {
|
|
1781
1808
|
changeSetId: t,
|
|
1782
1809
|
branchId: a.branchId
|
|
1783
1810
|
}));
|
|
@@ -1790,12 +1817,12 @@ function N(e, t) {
|
|
|
1790
1817
|
}
|
|
1791
1818
|
//#endregion
|
|
1792
1819
|
//#region src/testing/stub-status-source.ts
|
|
1793
|
-
function P(e =
|
|
1820
|
+
function P(e = E()) {
|
|
1794
1821
|
return { async listChangeSetStatuses() {
|
|
1795
1822
|
return e.map((e) => ({ ...e }));
|
|
1796
1823
|
} };
|
|
1797
1824
|
}
|
|
1798
1825
|
//#endregion
|
|
1799
|
-
export {
|
|
1826
|
+
export { w as STUB_NOW, C as STUB_OTHER_USER_ID, S as STUB_USER_ID, x as STUB_WORKSPACE_ID, he as createStubBlueprintSource, M as createStubContenthubClient, P as createStubStatusSource, oe as stubBlockReasons, j as stubBlocker, fe as stubBlueprintReleases, de as stubBlueprints, E as stubChangeSetStatuses, ce as stubChangeSets, ue as stubCollections, me as stubContents, T as stubIdentity, D as stubRepealedContent, le as stubRequiredChecks, pe as stubResolvedReleases, se as stubStatusTransitions };
|
|
1800
1827
|
|
|
1801
1828
|
//# sourceMappingURL=testing.js.map
|