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