@knkcs/contenthub-ui 0.0.0-stage → 0.1.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 +30 -0
- package/LICENSE +30 -0
- package/README.md +25 -2
- package/dist/branch-content-fields-WBpviLQg.js +86 -0
- package/dist/branch-content-fields-WBpviLQg.js.map +1 -0
- package/dist/branch-form-kit-BIZbBl1B.js +11 -0
- package/dist/branch-form-kit-BIZbBl1B.js.map +1 -0
- package/dist/content-data-fields-CGJTea3s.js +19 -0
- package/dist/content-data-fields-CGJTea3s.js.map +1 -0
- package/dist/content-library-B2eauvHt.js +2494 -0
- package/dist/content-library-B2eauvHt.js.map +1 -0
- package/dist/heads-Brd2Gtjm.js +124 -0
- package/dist/heads-Brd2Gtjm.js.map +1 -0
- package/dist/index.d.ts +5729 -0
- package/dist/index.js +7180 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.d.ts +1555 -0
- package/dist/testing.js +1801 -0
- package/dist/testing.js.map +1 -0
- package/package.json +100 -4
package/dist/testing.js
ADDED
|
@@ -0,0 +1,1801 @@
|
|
|
1
|
+
import { A as e, C as t, E as n, M as r, S as i, _ as a, b as o, f as s, g as c, h as l, i as u, j as d, k as f, n as p, o as m, r as h, s as ee, t as te, u as ne, v as re, w as ie, x as ae, y as oe } from "./heads-Brd2Gtjm.js";
|
|
2
|
+
import { Code as g, ConnectError as _ } from "@connectrpc/connect";
|
|
3
|
+
import { createHostMembers as v } from "@knkcs/anker/host";
|
|
4
|
+
//#region src/testing/fixtures.ts
|
|
5
|
+
var y = "ws_stub", b = "user_stub", x = "user_ben", S = "2026-10-01T09:00:00.000Z";
|
|
6
|
+
function C() {
|
|
7
|
+
return {
|
|
8
|
+
userId: b,
|
|
9
|
+
workspaceId: y,
|
|
10
|
+
members: v([{
|
|
11
|
+
userId: b,
|
|
12
|
+
displayName: "Ada Editor",
|
|
13
|
+
email: "ada@example.com"
|
|
14
|
+
}, {
|
|
15
|
+
userId: x,
|
|
16
|
+
displayName: "Ben Reviewer",
|
|
17
|
+
email: "ben@example.com"
|
|
18
|
+
}])
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function se() {
|
|
22
|
+
return [{
|
|
23
|
+
id: "br_author",
|
|
24
|
+
name: "Being revised by the author",
|
|
25
|
+
createTime: S,
|
|
26
|
+
updateTime: S
|
|
27
|
+
}, {
|
|
28
|
+
id: "br_embargo",
|
|
29
|
+
name: "Embargoed until publication",
|
|
30
|
+
createTime: S,
|
|
31
|
+
updateTime: S
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
function ce() {
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
slug: "in_progress",
|
|
38
|
+
name: "In Bearbeitung",
|
|
39
|
+
color: "steelblue"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
slug: "in_review",
|
|
43
|
+
name: "In Prüfung",
|
|
44
|
+
color: "orange"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
slug: "ready",
|
|
48
|
+
name: "Bereit",
|
|
49
|
+
color: "seagreen"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
slug: "on_hold",
|
|
53
|
+
name: "Zurückgestellt",
|
|
54
|
+
color: "gray"
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
function le() {
|
|
59
|
+
return {
|
|
60
|
+
in_progress: ["in_review", "on_hold"],
|
|
61
|
+
in_review: [
|
|
62
|
+
"in_progress",
|
|
63
|
+
"ready",
|
|
64
|
+
"on_hold"
|
|
65
|
+
],
|
|
66
|
+
ready: ["in_review", "on_hold"],
|
|
67
|
+
on_hold: ["in_progress"]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function ue() {
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
id: "cs_bgbl_270",
|
|
74
|
+
name: "BGBl. 2026 I Nr. 270",
|
|
75
|
+
source: {
|
|
76
|
+
date: "2026-09-20",
|
|
77
|
+
reference: "BGBl. 2026 I Nr. 270"
|
|
78
|
+
},
|
|
79
|
+
state: "open",
|
|
80
|
+
createdBy: b,
|
|
81
|
+
createTime: "2026-09-30T08:00:00.000Z",
|
|
82
|
+
chains: [{
|
|
83
|
+
id: "chain_para_1",
|
|
84
|
+
contentId: "content_para_1",
|
|
85
|
+
born: !1,
|
|
86
|
+
branches: [{
|
|
87
|
+
id: "br_para_1_a",
|
|
88
|
+
position: 0,
|
|
89
|
+
kind: "editorial",
|
|
90
|
+
headRevisionId: "rev_p1_a2",
|
|
91
|
+
effectiveOn: "2026-07-01",
|
|
92
|
+
carriedReleaseId: "rls_p1_1"
|
|
93
|
+
}, {
|
|
94
|
+
id: "br_para_1_b",
|
|
95
|
+
position: 1,
|
|
96
|
+
kind: "editorial",
|
|
97
|
+
headRevisionId: "rev_p1_b1",
|
|
98
|
+
effectiveOn: "2026-10-01"
|
|
99
|
+
}]
|
|
100
|
+
}, {
|
|
101
|
+
id: "chain_para_4a",
|
|
102
|
+
contentId: "content_para_4a",
|
|
103
|
+
born: !0,
|
|
104
|
+
branches: [{
|
|
105
|
+
id: "br_para_4a",
|
|
106
|
+
position: 0,
|
|
107
|
+
kind: "editorial",
|
|
108
|
+
headRevisionId: "rev_p4a_1"
|
|
109
|
+
}]
|
|
110
|
+
}],
|
|
111
|
+
dependsOnChangeSetIds: [],
|
|
112
|
+
status: "in_progress",
|
|
113
|
+
assigneeIds: [b],
|
|
114
|
+
plannedReleases: [
|
|
115
|
+
{
|
|
116
|
+
id: "rls_p1_2",
|
|
117
|
+
contentId: "content_para_1",
|
|
118
|
+
kind: "revision",
|
|
119
|
+
branchId: "br_para_1_b",
|
|
120
|
+
revisionId: "",
|
|
121
|
+
validityPeriod: {
|
|
122
|
+
firstDay: "2026-10-01",
|
|
123
|
+
lastDay: ""
|
|
124
|
+
},
|
|
125
|
+
supersedesReleaseIds: [],
|
|
126
|
+
proposed: !1,
|
|
127
|
+
proposedForReleaseId: "",
|
|
128
|
+
splitFromReleaseId: "",
|
|
129
|
+
withheld: !1
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "rls_p1_1_cut",
|
|
133
|
+
contentId: "content_para_1",
|
|
134
|
+
kind: "date_only",
|
|
135
|
+
branchId: "",
|
|
136
|
+
revisionId: "rev_p1_main",
|
|
137
|
+
validityPeriod: {
|
|
138
|
+
firstDay: "2020-01-01",
|
|
139
|
+
lastDay: "2026-09-30"
|
|
140
|
+
},
|
|
141
|
+
supersedesReleaseIds: ["rls_p1_1"],
|
|
142
|
+
proposed: !0,
|
|
143
|
+
proposedForReleaseId: "rls_p1_1",
|
|
144
|
+
splitFromReleaseId: "",
|
|
145
|
+
withheld: !1
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: "rls_p4a_1",
|
|
149
|
+
contentId: "content_para_4a",
|
|
150
|
+
kind: "revision",
|
|
151
|
+
branchId: "br_para_4a",
|
|
152
|
+
revisionId: "",
|
|
153
|
+
validityPeriod: {
|
|
154
|
+
firstDay: "2026-10-01",
|
|
155
|
+
lastDay: ""
|
|
156
|
+
},
|
|
157
|
+
supersedesReleaseIds: [],
|
|
158
|
+
proposed: !1,
|
|
159
|
+
proposedForReleaseId: "",
|
|
160
|
+
splitFromReleaseId: "",
|
|
161
|
+
withheld: !1
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: "cs_bgbl_255",
|
|
167
|
+
name: "BGBl. 2026 I Nr. 255",
|
|
168
|
+
source: {
|
|
169
|
+
date: "2026-09-10",
|
|
170
|
+
reference: "BGBl. 2026 I Nr. 255"
|
|
171
|
+
},
|
|
172
|
+
state: "open",
|
|
173
|
+
createdBy: x,
|
|
174
|
+
createTime: "2026-09-25T08:00:00.000Z",
|
|
175
|
+
chains: [],
|
|
176
|
+
dependsOnChangeSetIds: [],
|
|
177
|
+
status: "",
|
|
178
|
+
assigneeIds: [x],
|
|
179
|
+
plannedReleases: []
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: "cs_correction_3",
|
|
183
|
+
name: "Correction of § 3",
|
|
184
|
+
state: "published",
|
|
185
|
+
createdBy: b,
|
|
186
|
+
createTime: "2026-09-01T08:00:00.000Z",
|
|
187
|
+
closeTime: "2026-09-02T08:00:00.000Z",
|
|
188
|
+
chains: [],
|
|
189
|
+
dependsOnChangeSetIds: [],
|
|
190
|
+
status: "ready",
|
|
191
|
+
assigneeIds: [],
|
|
192
|
+
plannedReleases: []
|
|
193
|
+
}
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
function de() {
|
|
197
|
+
return [{
|
|
198
|
+
id: "rc_print",
|
|
199
|
+
name: "Druckprobe",
|
|
200
|
+
scope: "change_set",
|
|
201
|
+
blueprintAccessors: [],
|
|
202
|
+
independent: !1
|
|
203
|
+
}, {
|
|
204
|
+
id: "rc_lawyer",
|
|
205
|
+
name: "Juristische Prüfung",
|
|
206
|
+
scope: "branch",
|
|
207
|
+
blueprintAccessors: [],
|
|
208
|
+
independent: !0
|
|
209
|
+
}];
|
|
210
|
+
}
|
|
211
|
+
function fe() {
|
|
212
|
+
return [
|
|
213
|
+
{
|
|
214
|
+
id: "col_bgb",
|
|
215
|
+
name: "BGB",
|
|
216
|
+
parentId: "col_laws",
|
|
217
|
+
restricted: !1
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: "col_commentary",
|
|
221
|
+
name: "Commentary",
|
|
222
|
+
parentId: "",
|
|
223
|
+
restricted: !1
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
id: "col_laws",
|
|
227
|
+
name: "Laws",
|
|
228
|
+
parentId: "",
|
|
229
|
+
restricted: !1
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: "col_stgb",
|
|
233
|
+
name: "StGB",
|
|
234
|
+
parentId: "col_laws",
|
|
235
|
+
restricted: !1
|
|
236
|
+
}
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
function w() {
|
|
240
|
+
return [
|
|
241
|
+
{
|
|
242
|
+
id: "bp_commentary",
|
|
243
|
+
name: "Commentary"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
id: "bp_footnote",
|
|
247
|
+
name: "Footnote"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: "bp_paragraph",
|
|
251
|
+
name: "Paragraph"
|
|
252
|
+
}
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
function T() {
|
|
256
|
+
return [
|
|
257
|
+
{
|
|
258
|
+
id: "bpr_paragraph_2",
|
|
259
|
+
blueprintId: "bp_paragraph",
|
|
260
|
+
name: "2026-10",
|
|
261
|
+
releaseTime: "2026-10-01T07:00:00.000Z"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
id: "bpr_paragraph_1",
|
|
265
|
+
blueprintId: "bp_paragraph",
|
|
266
|
+
name: "2026-09",
|
|
267
|
+
releaseTime: "2026-09-01T07:00:00.000Z"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
id: "bpr_footnote_1",
|
|
271
|
+
blueprintId: "bp_footnote",
|
|
272
|
+
name: "2026-08",
|
|
273
|
+
releaseTime: "2026-08-01T07:00:00.000Z"
|
|
274
|
+
}
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
function pe() {
|
|
278
|
+
let e = (e, t) => ({
|
|
279
|
+
field_type: "text",
|
|
280
|
+
config: {
|
|
281
|
+
name: t,
|
|
282
|
+
api_accessor: e,
|
|
283
|
+
required: !1,
|
|
284
|
+
instructions: ""
|
|
285
|
+
},
|
|
286
|
+
system: !1
|
|
287
|
+
}), t = {
|
|
288
|
+
displayName: "Paragraph",
|
|
289
|
+
dated: !0,
|
|
290
|
+
fields: [e("number", "Number"), e("heading", "Heading")],
|
|
291
|
+
parts: {}
|
|
292
|
+
};
|
|
293
|
+
return {
|
|
294
|
+
bpr_paragraph_1: t,
|
|
295
|
+
bpr_paragraph_2: t,
|
|
296
|
+
bpr_footnote_1: {
|
|
297
|
+
displayName: "Footnote",
|
|
298
|
+
dated: !0,
|
|
299
|
+
fields: [e("text", "Text")],
|
|
300
|
+
parts: {}
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function me() {
|
|
305
|
+
let e = "2001-11-01T08:00:00.000Z";
|
|
306
|
+
return {
|
|
307
|
+
id: "content_para_3",
|
|
308
|
+
blueprintId: "bp_paragraph",
|
|
309
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
310
|
+
collectionIds: ["col_bgb"],
|
|
311
|
+
main: {
|
|
312
|
+
revisionId: "rev_p3_main",
|
|
313
|
+
data: {
|
|
314
|
+
number: "§ 3",
|
|
315
|
+
heading: "(weggefallen)"
|
|
316
|
+
},
|
|
317
|
+
revisionCreateTime: e
|
|
318
|
+
},
|
|
319
|
+
branches: {},
|
|
320
|
+
timeline: [{
|
|
321
|
+
ordinal: 1,
|
|
322
|
+
releaseId: "rls_p3_repeal",
|
|
323
|
+
kind: "repeal",
|
|
324
|
+
revisionId: "rev_p3_main",
|
|
325
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
326
|
+
validityPeriod: {
|
|
327
|
+
firstDay: "1900-01-01",
|
|
328
|
+
lastDay: "2001-12-31"
|
|
329
|
+
},
|
|
330
|
+
publishTime: e,
|
|
331
|
+
first: !0
|
|
332
|
+
}]
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function he() {
|
|
336
|
+
let e = "2026-09-01T08:00:00.000Z";
|
|
337
|
+
return [
|
|
338
|
+
{
|
|
339
|
+
id: "content_fn_1",
|
|
340
|
+
blueprintId: "bp_footnote",
|
|
341
|
+
blueprintReleaseId: "bpr_footnote_1",
|
|
342
|
+
collectionIds: [],
|
|
343
|
+
main: {
|
|
344
|
+
revisionId: "rev_fn1_main",
|
|
345
|
+
data: { text: "Fassung ab 1. Januar 2027" },
|
|
346
|
+
revisionCreateTime: e
|
|
347
|
+
},
|
|
348
|
+
branches: {},
|
|
349
|
+
timeline: [{
|
|
350
|
+
ordinal: 1,
|
|
351
|
+
releaseId: "rls_fn1_1",
|
|
352
|
+
kind: "revision",
|
|
353
|
+
revisionId: "rev_fn1_main",
|
|
354
|
+
blueprintReleaseId: "bpr_footnote_1",
|
|
355
|
+
validityPeriod: {
|
|
356
|
+
firstDay: "2027-01-01",
|
|
357
|
+
lastDay: ""
|
|
358
|
+
},
|
|
359
|
+
publishTime: e,
|
|
360
|
+
first: !0
|
|
361
|
+
}]
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
id: "content_para_1",
|
|
365
|
+
blueprintId: "bp_paragraph",
|
|
366
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
367
|
+
collectionIds: ["col_bgb"],
|
|
368
|
+
assigneeIds: [b, x],
|
|
369
|
+
main: {
|
|
370
|
+
revisionId: "rev_p1_main",
|
|
371
|
+
data: {
|
|
372
|
+
number: "§ 1",
|
|
373
|
+
heading: "Beginn der Rechtsfähigkeit"
|
|
374
|
+
},
|
|
375
|
+
revisionCreateTime: e
|
|
376
|
+
},
|
|
377
|
+
inForce: {
|
|
378
|
+
releaseId: "rls_p1_1",
|
|
379
|
+
revisionId: "rev_p1_main",
|
|
380
|
+
data: {
|
|
381
|
+
number: "§ 1",
|
|
382
|
+
heading: "Beginn der Rechtsfähigkeit"
|
|
383
|
+
},
|
|
384
|
+
revisionCreateTime: e
|
|
385
|
+
},
|
|
386
|
+
branches: { cs_bgbl_270: {
|
|
387
|
+
branchId: "br_para_1_b",
|
|
388
|
+
revisionId: "rev_p1_b1",
|
|
389
|
+
data: {
|
|
390
|
+
number: "§ 1",
|
|
391
|
+
heading: "Beginn der Rechtsfähigkeit, Erbfähigkeit"
|
|
392
|
+
},
|
|
393
|
+
revisionCreateTime: "2026-09-30T09:00:00.000Z"
|
|
394
|
+
} },
|
|
395
|
+
timeline: [{
|
|
396
|
+
ordinal: 1,
|
|
397
|
+
releaseId: "rls_p1_1",
|
|
398
|
+
kind: "revision",
|
|
399
|
+
revisionId: "rev_p1_main",
|
|
400
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
401
|
+
validityPeriod: {
|
|
402
|
+
firstDay: "1900-01-01",
|
|
403
|
+
lastDay: ""
|
|
404
|
+
},
|
|
405
|
+
publishTime: e,
|
|
406
|
+
first: !0
|
|
407
|
+
}],
|
|
408
|
+
plannedReleases: [{
|
|
409
|
+
changeSetId: "cs_bgbl_270",
|
|
410
|
+
plannedRelease: {
|
|
411
|
+
id: "rls_p1_270",
|
|
412
|
+
contentId: "content_para_1",
|
|
413
|
+
kind: "revision",
|
|
414
|
+
branchId: "br_para_1_b",
|
|
415
|
+
validityPeriod: {
|
|
416
|
+
firstDay: "2026-11-01",
|
|
417
|
+
lastDay: ""
|
|
418
|
+
},
|
|
419
|
+
revisionId: "",
|
|
420
|
+
supersedesReleaseIds: [],
|
|
421
|
+
proposed: !1,
|
|
422
|
+
proposedForReleaseId: "",
|
|
423
|
+
splitFromReleaseId: "",
|
|
424
|
+
withheld: !1
|
|
425
|
+
}
|
|
426
|
+
}],
|
|
427
|
+
revisions: [
|
|
428
|
+
{
|
|
429
|
+
id: "rev_p1_b1",
|
|
430
|
+
contentId: "content_para_1",
|
|
431
|
+
parentId: "rev_p1_a2",
|
|
432
|
+
secondParentId: "",
|
|
433
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
434
|
+
createTime: "2026-09-30T09:00:00.000Z",
|
|
435
|
+
author: b,
|
|
436
|
+
cause: "save",
|
|
437
|
+
branchId: "br_para_1_b",
|
|
438
|
+
changeSetId: "cs_bgbl_270",
|
|
439
|
+
data: {
|
|
440
|
+
number: "§ 1",
|
|
441
|
+
heading: "Beginn der Rechtsfähigkeit, Erbfähigkeit"
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
id: "rev_p1_a2",
|
|
446
|
+
contentId: "content_para_1",
|
|
447
|
+
parentId: "rev_p1_main",
|
|
448
|
+
secondParentId: "",
|
|
449
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
450
|
+
createTime: "2026-09-30T08:30:00.000Z",
|
|
451
|
+
author: x,
|
|
452
|
+
cause: "save",
|
|
453
|
+
branchId: "br_para_1_a",
|
|
454
|
+
changeSetId: "cs_bgbl_270",
|
|
455
|
+
data: {
|
|
456
|
+
number: "§ 1",
|
|
457
|
+
heading: "Beginn der Rechtsfähigkeit des Menschen"
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
id: "rev_p1_main",
|
|
462
|
+
contentId: "content_para_1",
|
|
463
|
+
parentId: "",
|
|
464
|
+
secondParentId: "",
|
|
465
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
466
|
+
createTime: e,
|
|
467
|
+
author: b,
|
|
468
|
+
cause: "create",
|
|
469
|
+
branchId: "br_para_1_main",
|
|
470
|
+
changeSetId: "cs_correction_3"
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
edges: [{
|
|
474
|
+
sourceContentId: "content_para_1",
|
|
475
|
+
sourceRevisionId: "rev_p1_main",
|
|
476
|
+
path: "/see_also",
|
|
477
|
+
kind: "reference",
|
|
478
|
+
targetContentId: "content_para_2",
|
|
479
|
+
targetAssetId: "",
|
|
480
|
+
targetBlueprintReleaseId: "",
|
|
481
|
+
pinReleaseId: "rls_p2_0"
|
|
482
|
+
}]
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
id: "content_para_2",
|
|
486
|
+
blueprintId: "bp_paragraph",
|
|
487
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
488
|
+
collectionIds: ["col_bgb"],
|
|
489
|
+
main: {
|
|
490
|
+
revisionId: "rev_p2_main",
|
|
491
|
+
data: {
|
|
492
|
+
number: "§ 2",
|
|
493
|
+
heading: "Eintritt der Volljährigkeit"
|
|
494
|
+
},
|
|
495
|
+
revisionCreateTime: e
|
|
496
|
+
},
|
|
497
|
+
inForce: {
|
|
498
|
+
releaseId: "rls_p2_1",
|
|
499
|
+
revisionId: "rev_p2_main",
|
|
500
|
+
data: {
|
|
501
|
+
number: "§ 2",
|
|
502
|
+
heading: "Eintritt der Volljährigkeit"
|
|
503
|
+
},
|
|
504
|
+
revisionCreateTime: e
|
|
505
|
+
},
|
|
506
|
+
branches: {},
|
|
507
|
+
timeline: [{
|
|
508
|
+
ordinal: 1,
|
|
509
|
+
releaseId: "rls_p2_1",
|
|
510
|
+
kind: "revision",
|
|
511
|
+
revisionId: "rev_p2_main",
|
|
512
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
513
|
+
validityPeriod: {
|
|
514
|
+
firstDay: "1975-01-01",
|
|
515
|
+
lastDay: ""
|
|
516
|
+
},
|
|
517
|
+
publishTime: e,
|
|
518
|
+
first: !1
|
|
519
|
+
}],
|
|
520
|
+
edges: [{
|
|
521
|
+
sourceContentId: "content_para_2",
|
|
522
|
+
sourceRevisionId: "rev_p2_main",
|
|
523
|
+
path: "/see_also",
|
|
524
|
+
kind: "reference",
|
|
525
|
+
targetContentId: "content_para_1",
|
|
526
|
+
targetAssetId: "",
|
|
527
|
+
targetBlueprintReleaseId: "",
|
|
528
|
+
pinReleaseId: ""
|
|
529
|
+
}]
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
id: "content_para_4a",
|
|
533
|
+
blueprintId: "bp_paragraph",
|
|
534
|
+
blueprintReleaseId: "bpr_paragraph_2",
|
|
535
|
+
collectionIds: ["col_bgb"],
|
|
536
|
+
branches: { cs_bgbl_270: {
|
|
537
|
+
branchId: "br_para_4a",
|
|
538
|
+
revisionId: "rev_p4a_1",
|
|
539
|
+
data: {
|
|
540
|
+
number: "§ 4a",
|
|
541
|
+
heading: "Elektronische Form"
|
|
542
|
+
},
|
|
543
|
+
revisionCreateTime: "2026-09-30T10:00:00.000Z"
|
|
544
|
+
} }
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
id: "content_stgb_211",
|
|
548
|
+
blueprintId: "bp_paragraph",
|
|
549
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
550
|
+
collectionIds: ["col_stgb"],
|
|
551
|
+
assigneeIds: [x],
|
|
552
|
+
main: {
|
|
553
|
+
revisionId: "rev_s211_main",
|
|
554
|
+
data: {
|
|
555
|
+
number: "§ 211",
|
|
556
|
+
heading: "Mord"
|
|
557
|
+
},
|
|
558
|
+
revisionCreateTime: e
|
|
559
|
+
},
|
|
560
|
+
inForce: {
|
|
561
|
+
releaseId: "rls_s211_1",
|
|
562
|
+
revisionId: "rev_s211_main",
|
|
563
|
+
data: {
|
|
564
|
+
number: "§ 211",
|
|
565
|
+
heading: "Mord"
|
|
566
|
+
},
|
|
567
|
+
revisionCreateTime: e
|
|
568
|
+
},
|
|
569
|
+
branches: {},
|
|
570
|
+
timeline: [{
|
|
571
|
+
ordinal: 1,
|
|
572
|
+
releaseId: "rls_s211_1",
|
|
573
|
+
kind: "revision",
|
|
574
|
+
revisionId: "rev_s211_main",
|
|
575
|
+
blueprintReleaseId: "bpr_paragraph_1",
|
|
576
|
+
validityPeriod: {
|
|
577
|
+
firstDay: "1941-09-15",
|
|
578
|
+
lastDay: ""
|
|
579
|
+
},
|
|
580
|
+
publishTime: e,
|
|
581
|
+
first: !0
|
|
582
|
+
}]
|
|
583
|
+
}
|
|
584
|
+
];
|
|
585
|
+
}
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/testing/stub-blueprint-source.ts
|
|
588
|
+
function E(e = w(), t = T()) {
|
|
589
|
+
return {
|
|
590
|
+
async searchBlueprints({ query: t }) {
|
|
591
|
+
let n = t.trim().toLocaleLowerCase();
|
|
592
|
+
return {
|
|
593
|
+
blueprints: e.filter((e) => e.name.toLocaleLowerCase().includes(n)).map((e) => ({ ...e })),
|
|
594
|
+
nextPageToken: ""
|
|
595
|
+
};
|
|
596
|
+
},
|
|
597
|
+
async getBlueprints(t) {
|
|
598
|
+
return e.filter((e) => t.includes(e.id)).map((e) => ({ ...e }));
|
|
599
|
+
},
|
|
600
|
+
async listReleases(e) {
|
|
601
|
+
return t.filter((t) => t.blueprintId === e).map((e) => ({ ...e }));
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
//#endregion
|
|
606
|
+
//#region src/testing/stub-client.ts
|
|
607
|
+
function ge(e, t) {
|
|
608
|
+
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
609
|
+
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
610
|
+
}
|
|
611
|
+
function D(e, t, n) {
|
|
612
|
+
let r = e.trim();
|
|
613
|
+
if (r === "") throw new i(`${t} is required`);
|
|
614
|
+
if ([...r].length > n) throw new i(`${t} is at most ${n} characters`);
|
|
615
|
+
if (/[\u0000-\u001f\u007f]/.test(r)) throw new i(`${t} is one line of text`);
|
|
616
|
+
return r;
|
|
617
|
+
}
|
|
618
|
+
function _e(e) {
|
|
619
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new i(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
|
|
620
|
+
return {
|
|
621
|
+
date: e.date.trim(),
|
|
622
|
+
reference: D(e.reference, "source.reference", 500)
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function ve(e) {
|
|
626
|
+
let t = e.trim();
|
|
627
|
+
if (t === "") throw new i("a Block Reason needs a name");
|
|
628
|
+
if ([...t].length > 200) throw new i("a Block Reason's name is at most 200 characters");
|
|
629
|
+
if (/[\u0000-\u001f\u007f]/.test(t)) throw new i("a Block Reason's name is one line of text");
|
|
630
|
+
return t;
|
|
631
|
+
}
|
|
632
|
+
function ye(e) {
|
|
633
|
+
let t = D(e.name, "a Required Check's name", 200);
|
|
634
|
+
if (e.scope !== "branch" && e.scope !== "change_set") throw new i("a Required Check's scope is Branch or Change Set");
|
|
635
|
+
let n = e.blueprintAccessors.map((e) => {
|
|
636
|
+
let t = e.trim();
|
|
637
|
+
if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new i(`"${t}" is not a Blueprint accessor`);
|
|
638
|
+
return t;
|
|
639
|
+
});
|
|
640
|
+
return {
|
|
641
|
+
name: t,
|
|
642
|
+
scope: e.scope,
|
|
643
|
+
blueprintAccessors: [...new Set(n)].sort(),
|
|
644
|
+
independent: e.independent
|
|
645
|
+
};
|
|
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", O = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
|
|
648
|
+
function k(e, t) {
|
|
649
|
+
return new _(`${e} ${t}: not found`, g.NotFound);
|
|
650
|
+
}
|
|
651
|
+
var A = (e) => structuredClone(e);
|
|
652
|
+
function j(e, t = {}) {
|
|
653
|
+
return {
|
|
654
|
+
code: e,
|
|
655
|
+
contentId: "",
|
|
656
|
+
branchId: "",
|
|
657
|
+
expectedHeadId: "",
|
|
658
|
+
currentHeadId: "",
|
|
659
|
+
releaseId: "",
|
|
660
|
+
overlapsReleaseId: "",
|
|
661
|
+
dependencyChangeSetId: "",
|
|
662
|
+
path: "",
|
|
663
|
+
targetContentId: "",
|
|
664
|
+
assetId: "",
|
|
665
|
+
parentContentIds: [],
|
|
666
|
+
requiredCheckId: "",
|
|
667
|
+
coveredReleaseId: "",
|
|
668
|
+
revisionId: "",
|
|
669
|
+
...t
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
function M(g = {}) {
|
|
673
|
+
let _ = g.now ?? (() => "2026-10-01T09:00:00.000Z"), v = g.userId ?? "user_stub", y = g.statuses ?? ce(), b = g.statusTransitions ?? le(), x = (g.blockReasons ?? se()).map((e) => ({ ...e })), S = (g.changeSets ?? ue()).map(A), C = (g.collections ?? fe()).map((e) => ({ ...e })), w = structuredClone(g.contents ?? he()), me = g.blueprintReleases ?? T(), E = g.resolvedReleases ?? pe(), M = structuredClone(g.requiredChecks ?? de()), P = g.authzMode ?? "guardian", Se = new Set(g.withheld ?? []), F = (e) => {
|
|
674
|
+
if (Se.has(e)) throw new r(xe);
|
|
675
|
+
}, I = new Map(Object.entries(structuredClone(g.collectionGrants ?? {}))), L = new Map(Object.entries(structuredClone(g.recorders ?? {}))), Ce = (e) => L.get(e) ?? {
|
|
676
|
+
everyMember: !0,
|
|
677
|
+
userIds: []
|
|
678
|
+
}, we = g.memberIds ?? ["user_stub", "user_ben"], Te = g.admin ?? !0, Ee = structuredClone(g.checkResults ?? []), De = g.publishBlockers ?? {}, Oe = g.pendingMerges ?? {}, ke = structuredClone(g.conflicts ?? {}), R = /* @__PURE__ */ new Map(), Ae = /* @__PURE__ */ new Map(), z = async (e, t, n) => {
|
|
679
|
+
if (!e) return n();
|
|
680
|
+
let r = JSON.stringify(t), a = Ae.get(e);
|
|
681
|
+
if (a) {
|
|
682
|
+
if (a.asked !== r) throw new i(`idempotency key ${e} names another request`);
|
|
683
|
+
return structuredClone(a.answer);
|
|
684
|
+
}
|
|
685
|
+
let o = await n();
|
|
686
|
+
return Ae.set(e, {
|
|
687
|
+
asked: r,
|
|
688
|
+
answer: structuredClone(o)
|
|
689
|
+
}), o;
|
|
690
|
+
}, B = /* @__PURE__ */ new Map(), je = /* @__PURE__ */ new Map(), V = 1, H = (e) => {
|
|
691
|
+
let t = w.find((t) => t.id === e);
|
|
692
|
+
if (!t) throw k("Content", e);
|
|
693
|
+
return t;
|
|
694
|
+
}, U = (e) => structuredClone({
|
|
695
|
+
collectionIds: [...e.collectionIds].sort(),
|
|
696
|
+
assigneeIds: e.assigneeIds ?? [],
|
|
697
|
+
block: e.block,
|
|
698
|
+
archiveTime: e.archiveTime
|
|
699
|
+
}), Me = () => _().slice(0, 10), W = (e) => E[e.blueprintReleaseId]?.dated ?? !1, G = (e) => {
|
|
700
|
+
let t = [...e.revisions ?? []], n = [...Object.entries(e.branches).map(([e, t]) => ({
|
|
701
|
+
...t,
|
|
702
|
+
changeSetId: e
|
|
703
|
+
})), ...e.main ? [{
|
|
704
|
+
...e.main,
|
|
705
|
+
branchId: "",
|
|
706
|
+
changeSetId: ""
|
|
707
|
+
}] : []];
|
|
708
|
+
for (let r of n) t.some((e) => e.id === r.revisionId) || t.push({
|
|
709
|
+
id: r.revisionId,
|
|
710
|
+
contentId: e.id,
|
|
711
|
+
parentId: "",
|
|
712
|
+
secondParentId: "",
|
|
713
|
+
blueprintReleaseId: e.blueprintReleaseId,
|
|
714
|
+
createTime: r.revisionCreateTime,
|
|
715
|
+
author: v,
|
|
716
|
+
cause: "create",
|
|
717
|
+
branchId: r.branchId,
|
|
718
|
+
changeSetId: r.changeSetId,
|
|
719
|
+
data: r.data
|
|
720
|
+
});
|
|
721
|
+
return t.sort((e, t) => e.createTime < t.createTime ? 1 : e.createTime > t.createTime ? -1 : 0);
|
|
722
|
+
}, K = (e, t) => [
|
|
723
|
+
e.main,
|
|
724
|
+
e.inForce,
|
|
725
|
+
...Object.values(e.branches)
|
|
726
|
+
].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Ne = (e, t) => {
|
|
727
|
+
let n = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
728
|
+
return (e ?? []).filter((e) => e.config.required === !0 && n(t[e.config.api_accessor])).map((e) => e.config.api_accessor);
|
|
729
|
+
}, q = (e) => {
|
|
730
|
+
if (e.archiveTime) throw new a(e.id);
|
|
731
|
+
if (e.block && !e.block.allowedUserIds.includes(v)) throw new re(e.id, e.block.blockReasonId);
|
|
732
|
+
}, Pe = (e) => w.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
|
|
733
|
+
edge: { ...e },
|
|
734
|
+
releaseId: t.inForce?.releaseId ?? ""
|
|
735
|
+
}))), Fe = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Ie = (e, t) => x.some((n) => n.name === e && n.id !== t), Le = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), J = (e) => {
|
|
736
|
+
let t = C.find((t) => t.id === e);
|
|
737
|
+
if (!t) throw k("Collection", e);
|
|
738
|
+
return t;
|
|
739
|
+
}, Y = (e, t, n) => C.some((r) => r.parentId === e && r.name === t && r.id !== n), X = (e) => {
|
|
740
|
+
if (P === "workspace") throw new n(O);
|
|
741
|
+
if (!J(e).restricted) throw new i(`Collection ${e} is open: only a Restricted Collection takes grants`);
|
|
742
|
+
let t = (I.get(e) ?? []).some((e) => e.userId === v && e.level === "owner");
|
|
743
|
+
if (!Te && !t) throw new ee("only its owner or a workspace admin manages its grants");
|
|
744
|
+
}, Re = (e) => {
|
|
745
|
+
if (P === "workspace") throw new ae("required_check_recorders", be);
|
|
746
|
+
if (!Te) throw new ee("permission denied");
|
|
747
|
+
if (e === "") throw new i("required_check_id is required");
|
|
748
|
+
if (!M.some((t) => t.id === e)) throw k("Required Check", e);
|
|
749
|
+
return Ce(e);
|
|
750
|
+
}, ze = async ({ changeSetId: e, branchId: t, expectedHeadId: n, data: r, fieldMask: a }) => {
|
|
751
|
+
let o = Q(e).chains.find((e) => e.branches.some((e) => e.id === t)), s = o?.branches.find((e) => e.id === t);
|
|
752
|
+
if (!o || !s) throw k("Branch", t);
|
|
753
|
+
let c = H(o.contentId);
|
|
754
|
+
if (q(c), R.has(t)) throw new i("a Pending Merge waits on this Branch: resolve or abort it first");
|
|
755
|
+
if (n === "") throw new i("expected_head_id is required");
|
|
756
|
+
if (s.headRevisionId !== n) throw new f({
|
|
757
|
+
contentId: c.id,
|
|
758
|
+
branchId: t,
|
|
759
|
+
expectedHeadId: n,
|
|
760
|
+
currentHeadId: s.headRevisionId
|
|
761
|
+
});
|
|
762
|
+
let l = K(c, s.headRevisionId) ?? {}, u = JSON.parse(JSON.stringify(r)), d;
|
|
763
|
+
if (a) {
|
|
764
|
+
let e = Object.keys(u).filter((e) => !a.includes(e));
|
|
765
|
+
if (e.length > 0) throw new i(`data holds ${e.join(", ")}, which the mask doesn't name`);
|
|
766
|
+
d = structuredClone(l);
|
|
767
|
+
for (let e of a) e in u ? d[e] = u[e] : delete d[e];
|
|
768
|
+
} else d = u;
|
|
769
|
+
return Be({
|
|
770
|
+
changeSetId: e,
|
|
771
|
+
chain: o,
|
|
772
|
+
branch: s,
|
|
773
|
+
c,
|
|
774
|
+
data: d,
|
|
775
|
+
cause: "save"
|
|
776
|
+
});
|
|
777
|
+
}, Be = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
|
|
778
|
+
let s = n.id, c = `rev_stub_${V++}`, l = _();
|
|
779
|
+
return r.revisions = [{
|
|
780
|
+
id: c,
|
|
781
|
+
contentId: r.id,
|
|
782
|
+
parentId: n.headRevisionId,
|
|
783
|
+
secondParentId: o,
|
|
784
|
+
blueprintReleaseId: r.blueprintReleaseId,
|
|
785
|
+
createTime: l,
|
|
786
|
+
author: v,
|
|
787
|
+
cause: a,
|
|
788
|
+
branchId: s,
|
|
789
|
+
changeSetId: e,
|
|
790
|
+
data: structuredClone(i)
|
|
791
|
+
}, ...r.revisions ?? []], n.headRevisionId = c, t.branches.at(-1)?.id === s && (r.branches[e] = {
|
|
792
|
+
branchId: s,
|
|
793
|
+
revisionId: c,
|
|
794
|
+
data: structuredClone(i),
|
|
795
|
+
revisionCreateTime: l
|
|
796
|
+
}), {
|
|
797
|
+
id: r.id,
|
|
798
|
+
blueprintId: r.blueprintId,
|
|
799
|
+
blueprintReleaseId: r.blueprintReleaseId,
|
|
800
|
+
revisionId: c,
|
|
801
|
+
data: structuredClone(i),
|
|
802
|
+
changeSetId: e,
|
|
803
|
+
branchId: s,
|
|
804
|
+
revisionCreateTime: l,
|
|
805
|
+
releaseId: ""
|
|
806
|
+
};
|
|
807
|
+
}, Ve = (e, t) => {
|
|
808
|
+
let n = Q(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 k("Branch", t);
|
|
810
|
+
return {
|
|
811
|
+
cs: n,
|
|
812
|
+
chain: r,
|
|
813
|
+
branch: i,
|
|
814
|
+
c: H(r.contentId)
|
|
815
|
+
};
|
|
816
|
+
}, He = (e, t) => {
|
|
817
|
+
for (let n of S) for (let r of n.chains) {
|
|
818
|
+
let n = r.branches.find((t) => t.id === e);
|
|
819
|
+
if (!n) continue;
|
|
820
|
+
let i = {
|
|
821
|
+
branchId: e,
|
|
822
|
+
contentId: r.contentId,
|
|
823
|
+
reason: t.reason ?? "conflict",
|
|
824
|
+
oursRevisionId: n.headRevisionId,
|
|
825
|
+
theirsRevisionId: t.theirsRevisionId,
|
|
826
|
+
carried: !1,
|
|
827
|
+
fields: structuredClone(t.fields),
|
|
828
|
+
merged: structuredClone(t.merged)
|
|
829
|
+
};
|
|
830
|
+
R.set(e, i), n.hasPendingMerge = !0, delete ke[e];
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
throw k("Branch", e);
|
|
834
|
+
}, Ue = (e) => {
|
|
835
|
+
R.delete(e);
|
|
836
|
+
for (let t of S) for (let n of t.chains) {
|
|
837
|
+
let t = n.branches.find((t) => t.id === e);
|
|
838
|
+
t && (t.hasPendingMerge = !1);
|
|
839
|
+
}
|
|
840
|
+
}, We = (e, t) => {
|
|
841
|
+
let n = t.validityPeriod;
|
|
842
|
+
if (W(e)) {
|
|
843
|
+
if (!n || !h.test(n.firstDay)) throw new i("validity_period.first_day is required for Dated Content");
|
|
844
|
+
if (n.lastDay !== "" && (!h.test(n.lastDay) || n.lastDay < n.firstDay)) throw new i("validity_period.last_day is a day on or after first_day");
|
|
845
|
+
} else if (n) throw new i("validity_period is refused for undated Content");
|
|
846
|
+
let r = Ne(E[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
|
|
847
|
+
source: "fieldkit",
|
|
848
|
+
code: "required",
|
|
849
|
+
path: `/${e}`
|
|
850
|
+
}));
|
|
851
|
+
if (r.length > 0) throw new oe("the Release Spec values break the Blueprint Release", r);
|
|
852
|
+
if (n && n.lastDay !== "") {
|
|
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 o(e.id, r);
|
|
855
|
+
}
|
|
856
|
+
}, Ge = (e, t) => {
|
|
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
|
+
let o = n.find((t) => t.proposedForReleaseId === e.releaseId && t.splitFromReleaseId === a);
|
|
859
|
+
i.push({
|
|
860
|
+
id: o?.id ?? `rls_stub_${V++}`,
|
|
861
|
+
contentId: t.id,
|
|
862
|
+
kind: "date_only",
|
|
863
|
+
branchId: "",
|
|
864
|
+
revisionId: e.revisionId,
|
|
865
|
+
validityPeriod: r,
|
|
866
|
+
supersedesReleaseIds: a ? [] : [e.releaseId],
|
|
867
|
+
proposed: !0,
|
|
868
|
+
proposedForReleaseId: e.releaseId,
|
|
869
|
+
splitFromReleaseId: a,
|
|
870
|
+
withheld: !1
|
|
871
|
+
});
|
|
872
|
+
};
|
|
873
|
+
for (let e of r) {
|
|
874
|
+
let n = e.validityPeriod;
|
|
875
|
+
if (e.contentId === t.id && e.kind === "revision" && n) for (let r of t.timeline ?? []) {
|
|
876
|
+
let t = r.validityPeriod;
|
|
877
|
+
t && !e.supersedesReleaseIds.includes(r.releaseId) && t.firstDay < n.firstDay && (t.lastDay === "" || t.lastDay >= n.firstDay) && (a(r, {
|
|
878
|
+
firstDay: t.firstDay,
|
|
879
|
+
lastDay: ge(n.firstDay, -1)
|
|
880
|
+
}, ""), n.lastDay !== "" && (t.lastDay === "" || t.lastDay > n.lastDay) && a(r, {
|
|
881
|
+
firstDay: ge(n.lastDay, 1),
|
|
882
|
+
lastDay: t.lastDay
|
|
883
|
+
}, r.releaseId));
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
e.plannedReleases = [...r, ...i];
|
|
887
|
+
}, Z = (e) => {
|
|
888
|
+
let t = S.find((t) => t.id === e);
|
|
889
|
+
if (!t) throw k("Change Set", e);
|
|
890
|
+
return t;
|
|
891
|
+
}, Q = (e) => {
|
|
892
|
+
let t = Z(e);
|
|
893
|
+
if (t.state !== "open") throw new l(t.state);
|
|
894
|
+
return t;
|
|
895
|
+
}, Ke = (e) => y.find((t) => t.slug === e)?.name ?? e, qe = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (S.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => qe(e, t, n))), Je = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
|
|
896
|
+
key: t.id,
|
|
897
|
+
branchless: !1,
|
|
898
|
+
contentId: e.contentId,
|
|
899
|
+
revision: t.headRevisionId
|
|
900
|
+
}))), ...e.plannedReleases.filter((e) => e.kind !== "revision" && e.revisionId !== "").map((e) => ({
|
|
901
|
+
key: e.id,
|
|
902
|
+
branchless: !0,
|
|
903
|
+
contentId: e.contentId,
|
|
904
|
+
revision: e.revisionId
|
|
905
|
+
}))], Ye = (e) => w.find((t) => t.id === e)?.blueprintId, Xe = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes(Ye(t) ?? ""), Ze = (e) => {
|
|
906
|
+
let t = Je(e), n = (t, n) => Ee.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 ? !p(r.heads, t.heads) : !1;
|
|
908
|
+
return {
|
|
909
|
+
check: structuredClone(e),
|
|
910
|
+
...t,
|
|
911
|
+
results: n,
|
|
912
|
+
stale: i,
|
|
913
|
+
cleared: !!r && !i && r.outcome !== "failed"
|
|
914
|
+
};
|
|
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 [...M].sort(a)) {
|
|
917
|
+
let a = t.filter((t) => Xe(e, t.contentId));
|
|
918
|
+
if (e.scope === "change_set") {
|
|
919
|
+
if (a.length === 0) continue;
|
|
920
|
+
let o = Object.fromEntries(t.map((e) => [e.key, e.revision]));
|
|
921
|
+
i.push(r(e, {
|
|
922
|
+
contentId: "",
|
|
923
|
+
branchId: "",
|
|
924
|
+
releaseId: "",
|
|
925
|
+
heads: o
|
|
926
|
+
}, n(e, "")));
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
for (let t of a) i.push(r(e, {
|
|
930
|
+
contentId: t.contentId,
|
|
931
|
+
branchId: t.branchless ? "" : t.key,
|
|
932
|
+
releaseId: t.branchless ? t.key : "",
|
|
933
|
+
heads: { [t.key]: t.revision }
|
|
934
|
+
}, n(e, t.key)));
|
|
935
|
+
}
|
|
936
|
+
return i;
|
|
937
|
+
}, Qe = (e, t) => {
|
|
938
|
+
let n = [], r = te(e);
|
|
939
|
+
for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(j("moved_head", {
|
|
940
|
+
contentId: r.contentId,
|
|
941
|
+
branchId: e.id,
|
|
942
|
+
expectedHeadId: t[e.id] ?? "",
|
|
943
|
+
currentHeadId: e.headRevisionId
|
|
944
|
+
}));
|
|
945
|
+
for (let [e, i] of Object.entries(t)) e in r || n.push(j("moved_head", {
|
|
946
|
+
branchId: e,
|
|
947
|
+
expectedHeadId: i
|
|
948
|
+
}));
|
|
949
|
+
for (let t of e.dependsOnChangeSetIds) {
|
|
950
|
+
let e = S.find((e) => e.id === t)?.state;
|
|
951
|
+
e === "open" ? n.push(j("unpublished_dependency", { dependencyChangeSetId: t })) : e === "discarded" && n.push(j("discarded_dependency", { dependencyChangeSetId: t }));
|
|
952
|
+
}
|
|
953
|
+
for (let t of Ze(e)) t.cleared || n.push(j("outstanding_check", {
|
|
954
|
+
requiredCheckId: t.check.id,
|
|
955
|
+
contentId: t.contentId,
|
|
956
|
+
branchId: t.branchId,
|
|
957
|
+
releaseId: t.releaseId
|
|
958
|
+
}));
|
|
959
|
+
for (let t of e.chains) {
|
|
960
|
+
let e = w.find((e) => e.id === t.contentId);
|
|
961
|
+
for (let r of t.branches) {
|
|
962
|
+
let t = e && K(e, r.headRevisionId);
|
|
963
|
+
if (e && t) for (let i of Ne(E[e.blueprintReleaseId]?.fields, t)) n.push(j("missing_required_field", {
|
|
964
|
+
contentId: e.id,
|
|
965
|
+
revisionId: r.headRevisionId,
|
|
966
|
+
path: `/${i}`
|
|
967
|
+
}));
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
return [...n, ...structuredClone(De[e.id] ?? [])];
|
|
971
|
+
}, $ = (e) => {
|
|
972
|
+
let t = te(e);
|
|
973
|
+
return e.plannedReleases.filter((e) => !e.withheld).map((n) => ({
|
|
974
|
+
id: n.id,
|
|
975
|
+
contentId: n.contentId,
|
|
976
|
+
kind: n.kind,
|
|
977
|
+
branchId: n.branchId,
|
|
978
|
+
revisionId: n.branchId ? t[n.branchId] ?? "" : n.revisionId,
|
|
979
|
+
first: !!e.chains.find((e) => e.contentId === n.contentId)?.born,
|
|
980
|
+
supersedesReleaseIds: [...n.supersedesReleaseIds],
|
|
981
|
+
validityPeriod: n.validityPeriod ? { ...n.validityPeriod } : void 0
|
|
982
|
+
}));
|
|
983
|
+
};
|
|
984
|
+
for (let [e, t] of Object.entries(ke)) t.pending && He(e, t);
|
|
985
|
+
return {
|
|
986
|
+
async listBlockReasons() {
|
|
987
|
+
return [...x].sort(Fe).map((e) => ({ ...e }));
|
|
988
|
+
},
|
|
989
|
+
async createBlockReason({ name: e }) {
|
|
990
|
+
let t = ve(e);
|
|
991
|
+
if (Ie(t)) throw new ne(t);
|
|
992
|
+
let n = {
|
|
993
|
+
id: `br_stub_${V++}`,
|
|
994
|
+
name: t,
|
|
995
|
+
createTime: _(),
|
|
996
|
+
updateTime: _()
|
|
997
|
+
};
|
|
998
|
+
return x.push(n), { ...n };
|
|
999
|
+
},
|
|
1000
|
+
async renameBlockReason({ id: e, name: t }) {
|
|
1001
|
+
let n = ve(t), r = x.find((t) => t.id === e);
|
|
1002
|
+
if (!r) throw k("Block Reason", e);
|
|
1003
|
+
if (Ie(n, e)) throw new ne(n);
|
|
1004
|
+
return r.name = n, r.updateTime = _(), { ...r };
|
|
1005
|
+
},
|
|
1006
|
+
async deleteBlockReason({ id: e }) {
|
|
1007
|
+
if (!x.some((t) => t.id === e)) throw k("Block Reason", e);
|
|
1008
|
+
x = x.filter((t) => t.id !== e);
|
|
1009
|
+
},
|
|
1010
|
+
async listChangeSets(e = {}) {
|
|
1011
|
+
let t = S.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
|
+
return {
|
|
1013
|
+
changeSets: t.slice(r, r + n).map((e) => ({
|
|
1014
|
+
...A(e),
|
|
1015
|
+
chains: [],
|
|
1016
|
+
dependsOnChangeSetIds: [],
|
|
1017
|
+
plannedReleases: []
|
|
1018
|
+
})),
|
|
1019
|
+
nextPageToken: r + n < t.length ? String(r + n) : ""
|
|
1020
|
+
};
|
|
1021
|
+
},
|
|
1022
|
+
async createChangeSet({ name: e, source: t }) {
|
|
1023
|
+
let n = D(e, "name", 200), r = t ? _e(t) : void 0, i = {
|
|
1024
|
+
id: `cs_stub_${V++}`,
|
|
1025
|
+
name: n,
|
|
1026
|
+
source: r,
|
|
1027
|
+
state: "open",
|
|
1028
|
+
createdBy: v,
|
|
1029
|
+
createTime: _(),
|
|
1030
|
+
chains: [],
|
|
1031
|
+
dependsOnChangeSetIds: [],
|
|
1032
|
+
status: "",
|
|
1033
|
+
assigneeIds: [],
|
|
1034
|
+
plannedReleases: []
|
|
1035
|
+
};
|
|
1036
|
+
return S.unshift(i), A(i);
|
|
1037
|
+
},
|
|
1038
|
+
async getChangeSet(e) {
|
|
1039
|
+
return A(Z(e));
|
|
1040
|
+
},
|
|
1041
|
+
async updateChangeSet({ id: e, updateMask: t, name: n, source: r }) {
|
|
1042
|
+
let a = Q(e);
|
|
1043
|
+
if (t.length === 0) throw new i("update_mask is required");
|
|
1044
|
+
let o = t.includes("name") ? D(n ?? "", "name", 200) : a.name, s = a.source;
|
|
1045
|
+
return t.includes("source") && (s = r ? _e(r) : void 0), a.name = o, a.source = s, A(a);
|
|
1046
|
+
},
|
|
1047
|
+
async setChangeSetStatus({ id: t, expectedStatus: n, status: r }) {
|
|
1048
|
+
let a = Q(t);
|
|
1049
|
+
if (a.status !== n) throw new e(a.status);
|
|
1050
|
+
if (a.status === r) return A(a);
|
|
1051
|
+
if (!y.some((e) => e.slug === r)) throw new i(`status "${r}" is not in the workspace's catalogue`);
|
|
1052
|
+
if (y.some((e) => e.slug === a.status) && !(b[a.status] ?? []).includes(r)) throw new d({
|
|
1053
|
+
fromStatus: a.status,
|
|
1054
|
+
toStatus: r,
|
|
1055
|
+
reason: `There is no transition from ${Ke(a.status)} to ${Ke(r)}.`,
|
|
1056
|
+
requiresPermission: !1
|
|
1057
|
+
});
|
|
1058
|
+
return a.status = r, A(a);
|
|
1059
|
+
},
|
|
1060
|
+
async setChangeSetAssignees({ id: e, assigneeIds: t }) {
|
|
1061
|
+
let n = Z(e);
|
|
1062
|
+
if (new Set(t).size !== t.length) throw new i("each assignee is given once");
|
|
1063
|
+
if (t.length > 50) throw new i("at most 50 assignees");
|
|
1064
|
+
return n.assigneeIds = [...t], A(n);
|
|
1065
|
+
},
|
|
1066
|
+
async addDependency({ id: e, dependsOnId: t }) {
|
|
1067
|
+
let n = Q(e), r = Z(t);
|
|
1068
|
+
if (r.state !== "open") throw new i(`Change Set ${t} is ${r.state}`);
|
|
1069
|
+
if (qe(t, e)) throw new i("the dependency would close a cycle");
|
|
1070
|
+
return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t), A(n);
|
|
1071
|
+
},
|
|
1072
|
+
async removeDependency({ id: e, dependsOnId: t }) {
|
|
1073
|
+
let n = Q(e);
|
|
1074
|
+
if (!n.dependsOnChangeSetIds.includes(t)) throw k(`dependency of Change Set ${e} on`, t);
|
|
1075
|
+
return n.dependsOnChangeSetIds = n.dependsOnChangeSetIds.filter((e) => e !== t), A(n);
|
|
1076
|
+
},
|
|
1077
|
+
async validatePublish({ id: e, reviewedHeads: t }) {
|
|
1078
|
+
let n = Z(e);
|
|
1079
|
+
F(e);
|
|
1080
|
+
let r = B.get(e);
|
|
1081
|
+
if (r && p(r, t)) return {
|
|
1082
|
+
blockers: [],
|
|
1083
|
+
releases: $(n),
|
|
1084
|
+
published: !0
|
|
1085
|
+
};
|
|
1086
|
+
if (n.state !== "open") throw new l(n.state);
|
|
1087
|
+
return {
|
|
1088
|
+
blockers: Qe(n, t),
|
|
1089
|
+
releases: $(n),
|
|
1090
|
+
published: !1
|
|
1091
|
+
};
|
|
1092
|
+
},
|
|
1093
|
+
async publish({ id: e, reviewedHeads: t }) {
|
|
1094
|
+
let n = Z(e);
|
|
1095
|
+
F(e);
|
|
1096
|
+
let r = B.get(e);
|
|
1097
|
+
if (r && p(r, t)) return {
|
|
1098
|
+
changeSet: A(n),
|
|
1099
|
+
publishTime: n.closeTime ?? _(),
|
|
1100
|
+
releases: $(n)
|
|
1101
|
+
};
|
|
1102
|
+
if (n.state !== "open") throw new l(n.state);
|
|
1103
|
+
let i = Qe(n, t);
|
|
1104
|
+
if (i.length > 0) throw new ie(i);
|
|
1105
|
+
let a = $(n);
|
|
1106
|
+
return n.state = "published", n.closeTime = _(), B.set(e, { ...t }), {
|
|
1107
|
+
changeSet: A(n),
|
|
1108
|
+
publishTime: n.closeTime,
|
|
1109
|
+
releases: a
|
|
1110
|
+
};
|
|
1111
|
+
},
|
|
1112
|
+
async updateFromMain({ id: e, chainId: t, idempotencyKey: n }) {
|
|
1113
|
+
return z(n, [
|
|
1114
|
+
"updateFromMain",
|
|
1115
|
+
e,
|
|
1116
|
+
t
|
|
1117
|
+
], async () => {
|
|
1118
|
+
let n = Q(e);
|
|
1119
|
+
t || F(e);
|
|
1120
|
+
let r = t ? n.chains.filter((e) => e.id === t) : n.chains;
|
|
1121
|
+
if (t && r.length === 0) throw k("Chain", t);
|
|
1122
|
+
let i = structuredClone(Oe[e] ?? []), a = [];
|
|
1123
|
+
for (let e of r) for (let t of e.branches) {
|
|
1124
|
+
let n = {
|
|
1125
|
+
branchId: t.id,
|
|
1126
|
+
contentId: e.contentId
|
|
1127
|
+
}, r = ke[t.id];
|
|
1128
|
+
R.has(t.id) ? a.push(n) : r && (He(t.id, r), i.push(n));
|
|
1129
|
+
}
|
|
1130
|
+
return {
|
|
1131
|
+
changeSet: A(n),
|
|
1132
|
+
mergedBranchIds: [],
|
|
1133
|
+
conflicted: i,
|
|
1134
|
+
pending: a,
|
|
1135
|
+
endedBranchIds: []
|
|
1136
|
+
};
|
|
1137
|
+
});
|
|
1138
|
+
},
|
|
1139
|
+
async discardChangeSet(e) {
|
|
1140
|
+
let t = Q(e);
|
|
1141
|
+
return F(e), t.state = "discarded", t.closeTime = _(), t.chains = [], A(t);
|
|
1142
|
+
},
|
|
1143
|
+
async listCheckResults(e) {
|
|
1144
|
+
return Ze(Z(e));
|
|
1145
|
+
},
|
|
1146
|
+
async recordCheckResult({ changeSetId: e, requiredCheckId: t, heads: n, outcome: r, note: a }) {
|
|
1147
|
+
let o = Q(e);
|
|
1148
|
+
if (r === "waived" && a.trim() === "") throw new i("a waived result needs a note saying why");
|
|
1149
|
+
if ([...a].length > 2e3) throw new i(`a note is at most ${s} characters`);
|
|
1150
|
+
let l = M.find((e) => e.id === t);
|
|
1151
|
+
if (!l) throw k("Required Check", t);
|
|
1152
|
+
let u = Ce(t);
|
|
1153
|
+
if (P === "guardian" && !u.everyMember && !u.userIds.includes(v)) throw new c(`recording results of Required Check ${t} needs its recorder relation`);
|
|
1154
|
+
let d = Je(o), p = Object.keys(n);
|
|
1155
|
+
if (l.scope === "branch" && p.length !== 1) throw new i("a Branch-scope result names one head");
|
|
1156
|
+
if (l.scope === "change_set" && p.length !== d.length) throw new i("a Change Set-scope result names every head of the Change Set");
|
|
1157
|
+
for (let e of p) {
|
|
1158
|
+
let t = d.find((t) => t.key === e);
|
|
1159
|
+
if (!t) throw new i(`heads name ${e}, which this Change Set doesn't hold`);
|
|
1160
|
+
if (t.revision !== n[e]) throw new f({
|
|
1161
|
+
contentId: t.contentId,
|
|
1162
|
+
branchId: t.branchless ? "" : t.key,
|
|
1163
|
+
expectedHeadId: n[e],
|
|
1164
|
+
currentHeadId: t.revision
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
let m = {
|
|
1168
|
+
id: `cr_stub_${V++}`,
|
|
1169
|
+
requiredCheckId: t,
|
|
1170
|
+
heads: { ...n },
|
|
1171
|
+
outcome: r,
|
|
1172
|
+
note: a,
|
|
1173
|
+
recordedBy: v,
|
|
1174
|
+
recordTime: _()
|
|
1175
|
+
};
|
|
1176
|
+
return Ee.push({
|
|
1177
|
+
...m,
|
|
1178
|
+
changeSetId: e
|
|
1179
|
+
}), structuredClone(m);
|
|
1180
|
+
},
|
|
1181
|
+
async listRequiredChecks() {
|
|
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([...M].sort(e));
|
|
1184
|
+
},
|
|
1185
|
+
async createRequiredCheck(e) {
|
|
1186
|
+
let n = ye(e);
|
|
1187
|
+
if (M.some((e) => e.name === n.name)) throw new t(n.name);
|
|
1188
|
+
let r = {
|
|
1189
|
+
id: `rc_stub_${V++}`,
|
|
1190
|
+
...n
|
|
1191
|
+
};
|
|
1192
|
+
return M.push(r), structuredClone(r);
|
|
1193
|
+
},
|
|
1194
|
+
async updateRequiredCheck({ id: e, ...n }) {
|
|
1195
|
+
let r = ye(n), i = M.find((t) => t.id === e);
|
|
1196
|
+
if (!i) throw k("Required Check", e);
|
|
1197
|
+
if (M.some((t) => t.name === r.name && t.id !== e)) throw new t(r.name);
|
|
1198
|
+
return Object.assign(i, r), structuredClone(i);
|
|
1199
|
+
},
|
|
1200
|
+
async deleteRequiredCheck({ id: e }) {
|
|
1201
|
+
if (!M.some((t) => t.id === e)) throw k("Required Check", e);
|
|
1202
|
+
M = M.filter((t) => t.id !== e), L.delete(e);
|
|
1203
|
+
},
|
|
1204
|
+
async listRequiredCheckRecorders(e) {
|
|
1205
|
+
return structuredClone(Re(e));
|
|
1206
|
+
},
|
|
1207
|
+
async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1208
|
+
let n = Re(e);
|
|
1209
|
+
if ("everyMember" in t) {
|
|
1210
|
+
L.set(e, {
|
|
1211
|
+
...n,
|
|
1212
|
+
everyMember: !0
|
|
1213
|
+
});
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
if (!we.includes(t.userId)) throw new i(`user ${t.userId} is not a member of the workspace`);
|
|
1217
|
+
L.set(e, {
|
|
1218
|
+
...n,
|
|
1219
|
+
userIds: [.../* @__PURE__ */ new Set([...n.userIds, t.userId])].sort()
|
|
1220
|
+
});
|
|
1221
|
+
},
|
|
1222
|
+
async revokeRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
|
|
1223
|
+
let n = Re(e);
|
|
1224
|
+
L.set(e, "everyMember" in t ? {
|
|
1225
|
+
...n,
|
|
1226
|
+
everyMember: !1
|
|
1227
|
+
} : {
|
|
1228
|
+
...n,
|
|
1229
|
+
userIds: n.userIds.filter((e) => e !== t.userId)
|
|
1230
|
+
});
|
|
1231
|
+
},
|
|
1232
|
+
async listCollections() {
|
|
1233
|
+
return [...C].sort(Le).map((e) => ({ ...e }));
|
|
1234
|
+
},
|
|
1235
|
+
async createCollection({ name: e, parentId: r = "", restricted: i = !1 }) {
|
|
1236
|
+
let a = D(e, "a Collection's name", 200);
|
|
1237
|
+
if (r !== "" && J(r), i && P === "workspace") throw new n(O);
|
|
1238
|
+
if (Y(r, a)) throw new t(a);
|
|
1239
|
+
let o = {
|
|
1240
|
+
id: `col_stub_${V++}`,
|
|
1241
|
+
name: a,
|
|
1242
|
+
parentId: r,
|
|
1243
|
+
restricted: i
|
|
1244
|
+
};
|
|
1245
|
+
return C.push(o), i && I.set(o.id, [{
|
|
1246
|
+
userId: v,
|
|
1247
|
+
level: "owner"
|
|
1248
|
+
}]), { ...o };
|
|
1249
|
+
},
|
|
1250
|
+
async renameCollection({ id: e, name: n }) {
|
|
1251
|
+
let r = D(n, "a Collection's name", 200), i = J(e);
|
|
1252
|
+
if (Y(i.parentId, r, e)) throw new t(r);
|
|
1253
|
+
return i.name = r, { ...i };
|
|
1254
|
+
},
|
|
1255
|
+
async moveCollection({ id: e, parentId: n }) {
|
|
1256
|
+
let r = J(e);
|
|
1257
|
+
for (let t = n; t !== ""; t = J(t).parentId) if (t === e) throw new i(`Collection ${e} can't move under itself or a Collection under it`);
|
|
1258
|
+
if (Y(n, r.name, e)) throw new t("");
|
|
1259
|
+
return r.parentId = n, { ...r };
|
|
1260
|
+
},
|
|
1261
|
+
async removeCollection({ id: e }) {
|
|
1262
|
+
if (J(e), C.some((t) => t.parentId === e)) throw new i(`Collection ${e} has Collections under it: remove or move those first`);
|
|
1263
|
+
C.splice(C.findIndex((t) => t.id === e), 1), I.delete(e);
|
|
1264
|
+
let t = [];
|
|
1265
|
+
for (let n of w) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
|
|
1266
|
+
return t;
|
|
1267
|
+
},
|
|
1268
|
+
async setCollectionRestricted({ id: e, restricted: t, acknowledgeDisclosure: r = !1 }) {
|
|
1269
|
+
if (t && P === "workspace") throw new n(O);
|
|
1270
|
+
let a = J(e);
|
|
1271
|
+
if (a.restricted === t) return { ...a };
|
|
1272
|
+
if (!t && !r) throw new i(`unrestricting Collection ${e} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
|
|
1273
|
+
return a.restricted = t, t ? I.set(e, [{
|
|
1274
|
+
userId: v,
|
|
1275
|
+
level: "owner"
|
|
1276
|
+
}]) : I.delete(e), { ...a };
|
|
1277
|
+
},
|
|
1278
|
+
async listCollectionGrants(e) {
|
|
1279
|
+
return X(e), structuredClone(I.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
|
|
1280
|
+
},
|
|
1281
|
+
async grantCollectionAccess({ collectionId: e, userId: t, level: n }) {
|
|
1282
|
+
if (X(e), n !== "viewer" && n !== "editor") throw new i("a grant is viewer or editor");
|
|
1283
|
+
if (!we.includes(t)) throw new i(`${t} is not a member of the workspace`);
|
|
1284
|
+
let r = I.get(e) ?? [];
|
|
1285
|
+
r.some((e) => e.level === "owner" && e.userId === t) || I.set(e, [...r.filter((e) => e.userId !== t), {
|
|
1286
|
+
userId: t,
|
|
1287
|
+
level: n
|
|
1288
|
+
}]);
|
|
1289
|
+
},
|
|
1290
|
+
async revokeCollectionAccess({ collectionId: e, userId: t }) {
|
|
1291
|
+
X(e), I.set(e, (I.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
|
|
1292
|
+
},
|
|
1293
|
+
async listContents(e = {}) {
|
|
1294
|
+
let t = e.view ?? { kind: "main" }, n = (e.search ?? "").trim();
|
|
1295
|
+
if (n !== "" && t.kind === "in_force") throw new i("filter.search: Editor Search covers Main and open Branch heads, never Releases");
|
|
1296
|
+
if ([...n].length > 200) throw new i("filter.search is at most 200 characters");
|
|
1297
|
+
if (e.collectionId && !C.some((t) => t.id === e.collectionId)) throw k("Collection", e.collectionId);
|
|
1298
|
+
t.kind === "change_set" && Z(t.changeSetId);
|
|
1299
|
+
let r = w.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) => et(e, t, n)), a = Math.min(e.pageSize || 50, 200), o = e.pageToken ? Number(e.pageToken) : 0;
|
|
1300
|
+
return {
|
|
1301
|
+
contents: r.slice(o, o + a),
|
|
1302
|
+
nextPageToken: o + a < r.length ? String(o + a) : ""
|
|
1303
|
+
};
|
|
1304
|
+
},
|
|
1305
|
+
async createContent({ changeSetId: e, blueprintReleaseId: t, copyFrom: n }) {
|
|
1306
|
+
let r = Q(e), i = {}, a = t;
|
|
1307
|
+
if (n) {
|
|
1308
|
+
let e = "revisionId" in n ? n.revisionId : w.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = w.find((t) => e && K(t, e));
|
|
1309
|
+
if (!r || !e) throw k("copy source", JSON.stringify(n));
|
|
1310
|
+
i = structuredClone(K(r, e) ?? {}), a = t || r.blueprintReleaseId;
|
|
1311
|
+
}
|
|
1312
|
+
let o = me.find((e) => e.id === a);
|
|
1313
|
+
if (!o) throw new oe(`Blueprint Release ${a} can't be loaded`, [{
|
|
1314
|
+
source: "contenthub",
|
|
1315
|
+
code: "release_not_found",
|
|
1316
|
+
path: ""
|
|
1317
|
+
}]);
|
|
1318
|
+
let s = V++, c = `content_stub_${s}`, l = `br_stub_${s}`, u = `rev_stub_${s}`;
|
|
1319
|
+
return w.push({
|
|
1320
|
+
id: c,
|
|
1321
|
+
blueprintId: o.blueprintId,
|
|
1322
|
+
blueprintReleaseId: a,
|
|
1323
|
+
collectionIds: [],
|
|
1324
|
+
branches: { [e]: {
|
|
1325
|
+
branchId: l,
|
|
1326
|
+
revisionId: u,
|
|
1327
|
+
data: i,
|
|
1328
|
+
revisionCreateTime: _()
|
|
1329
|
+
} }
|
|
1330
|
+
}), r.chains.push({
|
|
1331
|
+
id: `chain_stub_${s}`,
|
|
1332
|
+
contentId: c,
|
|
1333
|
+
born: !0,
|
|
1334
|
+
branches: [{
|
|
1335
|
+
id: l,
|
|
1336
|
+
position: 0,
|
|
1337
|
+
kind: "editorial",
|
|
1338
|
+
headRevisionId: u
|
|
1339
|
+
}]
|
|
1340
|
+
}), {
|
|
1341
|
+
id: c,
|
|
1342
|
+
blueprintId: o.blueprintId,
|
|
1343
|
+
blueprintReleaseId: a,
|
|
1344
|
+
revisionId: u,
|
|
1345
|
+
data: structuredClone(i),
|
|
1346
|
+
changeSetId: e,
|
|
1347
|
+
branchId: l,
|
|
1348
|
+
revisionCreateTime: _(),
|
|
1349
|
+
releaseId: ""
|
|
1350
|
+
};
|
|
1351
|
+
},
|
|
1352
|
+
async saveRevision({ idempotencyKey: e, ...t }) {
|
|
1353
|
+
if (!e) return ze(t);
|
|
1354
|
+
let n = JSON.stringify(t), r = je.get(e);
|
|
1355
|
+
if (r) {
|
|
1356
|
+
if (r.asked !== n) throw new i(`idempotency key ${e} names another save`);
|
|
1357
|
+
return structuredClone(r.content);
|
|
1358
|
+
}
|
|
1359
|
+
let a = await ze(t);
|
|
1360
|
+
return je.set(e, {
|
|
1361
|
+
asked: n,
|
|
1362
|
+
content: structuredClone(a)
|
|
1363
|
+
}), a;
|
|
1364
|
+
},
|
|
1365
|
+
async getContent({ id: e, changeSetId: t }) {
|
|
1366
|
+
let n = H(e), [r] = et(n, t ? {
|
|
1367
|
+
kind: "change_set",
|
|
1368
|
+
changeSetId: t
|
|
1369
|
+
} : { kind: "main" }, "");
|
|
1370
|
+
if (!r) throw k("Content", e);
|
|
1371
|
+
let i = E[n.blueprintReleaseId];
|
|
1372
|
+
return {
|
|
1373
|
+
content: r,
|
|
1374
|
+
blueprintRelease: i ? structuredClone(i) : void 0,
|
|
1375
|
+
attributes: U(n)
|
|
1376
|
+
};
|
|
1377
|
+
},
|
|
1378
|
+
async getTimeline(e) {
|
|
1379
|
+
let t = H(e), n = (e) => S.find((t) => t.id === e)?.state === "open";
|
|
1380
|
+
return structuredClone({
|
|
1381
|
+
entries: t.timeline ?? [],
|
|
1382
|
+
plannedReleases: (t.plannedReleases ?? []).filter((e) => n(e.changeSetId))
|
|
1383
|
+
});
|
|
1384
|
+
},
|
|
1385
|
+
async listRevisions({ target: e, pageSize: t, pageToken: n }) {
|
|
1386
|
+
let r;
|
|
1387
|
+
if ("contentId" in e) {
|
|
1388
|
+
let t = H(e.contentId);
|
|
1389
|
+
if (!t.main) throw k("Content", e.contentId);
|
|
1390
|
+
r = G(t);
|
|
1391
|
+
} else {
|
|
1392
|
+
let t = w.find((t) => G(t).some((t) => t.branchId === e.branchId));
|
|
1393
|
+
if (!t) throw k("Branch", e.branchId);
|
|
1394
|
+
r = G(t).filter((t) => t.branchId === e.branchId);
|
|
1395
|
+
}
|
|
1396
|
+
let i = Math.min(t || 50, 200), a = n ? Number(n) : 0;
|
|
1397
|
+
return {
|
|
1398
|
+
revisions: r.slice(a, a + i).map(({ data: e, ...t }) => t),
|
|
1399
|
+
nextPageToken: a + i < r.length ? String(a + i) : ""
|
|
1400
|
+
};
|
|
1401
|
+
},
|
|
1402
|
+
async compare({ revisionId: e, base: t }) {
|
|
1403
|
+
let n = w.find((t) => G(t).some((t) => t.id === e));
|
|
1404
|
+
if (!n) throw k("Revision", e);
|
|
1405
|
+
let r = G(n), a = r.find((t) => t.id === e), o;
|
|
1406
|
+
if (t.kind === "revision") o = t.revisionId;
|
|
1407
|
+
else if (t.kind === "main_head") {
|
|
1408
|
+
if (!n.main) throw new i("the Content is not published: it has no Main Branch");
|
|
1409
|
+
o = n.main.revisionId;
|
|
1410
|
+
} else o = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
|
|
1411
|
+
let s = r.find((e) => e.id === o);
|
|
1412
|
+
if (!s) throw k("Revision", o);
|
|
1413
|
+
let c = K(n, a.id) ?? {}, l = K(n, s.id) ?? {}, u = [];
|
|
1414
|
+
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
|
+
path: `/${e}`,
|
|
1416
|
+
kind: "changed",
|
|
1417
|
+
before: l[e],
|
|
1418
|
+
after: c[e]
|
|
1419
|
+
}) : u.push({
|
|
1420
|
+
path: `/${e}`,
|
|
1421
|
+
kind: "removed",
|
|
1422
|
+
before: l[e]
|
|
1423
|
+
}) : u.push({
|
|
1424
|
+
path: `/${e}`,
|
|
1425
|
+
kind: "added",
|
|
1426
|
+
after: c[e]
|
|
1427
|
+
});
|
|
1428
|
+
let d = ({ data: e, ...t }) => t;
|
|
1429
|
+
return {
|
|
1430
|
+
base: d(s),
|
|
1431
|
+
revision: d(a),
|
|
1432
|
+
changes: u
|
|
1433
|
+
};
|
|
1434
|
+
},
|
|
1435
|
+
async listReferences({ contentId: e, revisionId: t }) {
|
|
1436
|
+
return (H(e).edges ?? []).filter((e) => e.sourceRevisionId === t).map((e) => ({ ...e }));
|
|
1437
|
+
},
|
|
1438
|
+
async listReferrers({ contentId: e, includeOpenChangeSets: t, pageSize: n, pageToken: r }) {
|
|
1439
|
+
H(e);
|
|
1440
|
+
let i = (e) => {
|
|
1441
|
+
let t = Math.min(n || 100, 1e3), i = r ? Number(r) : 0;
|
|
1442
|
+
return {
|
|
1443
|
+
referrers: e.slice(i, i + t),
|
|
1444
|
+
nextPageToken: i + t < e.length ? String(i + t) : ""
|
|
1445
|
+
};
|
|
1446
|
+
}, a = w.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
|
|
1447
|
+
edge: { ...e },
|
|
1448
|
+
releaseId: t.inForce?.releaseId ?? "",
|
|
1449
|
+
changeSetId: "",
|
|
1450
|
+
branchId: ""
|
|
1451
|
+
})));
|
|
1452
|
+
if (!t) return i(a);
|
|
1453
|
+
let o = w.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => S.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
|
|
1454
|
+
edge: { ...e },
|
|
1455
|
+
releaseId: "",
|
|
1456
|
+
changeSetId: n,
|
|
1457
|
+
branchId: r.branchId
|
|
1458
|
+
})) : []));
|
|
1459
|
+
return i([...a, ...o]);
|
|
1460
|
+
},
|
|
1461
|
+
async listOutdatedPins(e) {
|
|
1462
|
+
let t;
|
|
1463
|
+
if ("revisionId" in e) t = e.revisionId;
|
|
1464
|
+
else {
|
|
1465
|
+
for (let n of w) {
|
|
1466
|
+
let r = Object.values(n.branches).find((t) => t.branchId === e.branchId);
|
|
1467
|
+
r && (t = r.revisionId);
|
|
1468
|
+
}
|
|
1469
|
+
if (!t) throw k("Branch", e.branchId);
|
|
1470
|
+
}
|
|
1471
|
+
return w.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
|
|
1472
|
+
let t = w.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
|
|
1473
|
+
return t === e.pinReleaseId ? [] : [{
|
|
1474
|
+
edge: { ...e },
|
|
1475
|
+
supersededByReleaseId: t,
|
|
1476
|
+
inForceReleaseId: t
|
|
1477
|
+
}];
|
|
1478
|
+
});
|
|
1479
|
+
},
|
|
1480
|
+
async setContentCollections({ contentId: e, collectionIds: t }) {
|
|
1481
|
+
let n = H(e), r = [...new Set(t)];
|
|
1482
|
+
if (r.length > 100) throw new i("at most 100 Collections");
|
|
1483
|
+
for (let e of r) if (!C.some((t) => t.id === e)) throw k("Collection", e);
|
|
1484
|
+
return n.collectionIds = r.sort(), [...n.collectionIds];
|
|
1485
|
+
},
|
|
1486
|
+
async setContentAssignees({ contentId: e, assigneeIds: t }) {
|
|
1487
|
+
let n = H(e);
|
|
1488
|
+
if (new Set(t).size !== t.length) throw new i("each assignee is given once");
|
|
1489
|
+
if (t.length > 50) throw new i("at most 50 assignees");
|
|
1490
|
+
return n.assigneeIds = [...t], U(n);
|
|
1491
|
+
},
|
|
1492
|
+
async blockContent({ contentId: e, blockReasonId: t, allowedUserIds: n }) {
|
|
1493
|
+
let r = H(e);
|
|
1494
|
+
if (!x.some((e) => e.id === t)) throw k("Block Reason", t);
|
|
1495
|
+
if (new Set(n).size !== n.length) throw new i("each allowed user is given once");
|
|
1496
|
+
return r.block = {
|
|
1497
|
+
blockReasonId: t,
|
|
1498
|
+
allowedUserIds: [...n],
|
|
1499
|
+
blockedBy: v,
|
|
1500
|
+
blockTime: _()
|
|
1501
|
+
}, U(r);
|
|
1502
|
+
},
|
|
1503
|
+
async unblockContent(e) {
|
|
1504
|
+
let t = H(e);
|
|
1505
|
+
return t.block = void 0, U(t);
|
|
1506
|
+
},
|
|
1507
|
+
async archiveContent(e) {
|
|
1508
|
+
let t = H(e);
|
|
1509
|
+
if (t.archiveTime) return U(t);
|
|
1510
|
+
if (!t.main) throw new i(`Content ${e} is not published: discard its Change Set instead of archiving it`);
|
|
1511
|
+
if (u(t.timeline ?? [], Me())) throw new i(`Content ${e} has a Release In Force today or later: end its force first`);
|
|
1512
|
+
return t.archiveTime = _(), U(t);
|
|
1513
|
+
},
|
|
1514
|
+
async unarchiveContent(e) {
|
|
1515
|
+
let t = H(e);
|
|
1516
|
+
return t.archiveTime = void 0, U(t);
|
|
1517
|
+
},
|
|
1518
|
+
async startEditing({ contentId: e, changeSetId: t, effectiveOn: n = "", changeSetName: r = "" }) {
|
|
1519
|
+
let a = H(e);
|
|
1520
|
+
if (!a.main) throw new i(`Content ${e} is not published`);
|
|
1521
|
+
if (q(a), W(a) && !h.test(n)) throw new i("effective_on is required for Dated Content, as YYYY-MM-DD");
|
|
1522
|
+
if (!W(a) && n !== "") throw new i("effective_on is refused for undated Content");
|
|
1523
|
+
let o;
|
|
1524
|
+
if (t) {
|
|
1525
|
+
if (o = Q(t), o.chains.some((t) => t.contentId === e)) throw new i(`Content ${e} already has a Chain in this Change Set`);
|
|
1526
|
+
} else {
|
|
1527
|
+
let t = Object.values(a.main.data).filter((e) => typeof e == "string").slice(0, 2).join(" ");
|
|
1528
|
+
o = {
|
|
1529
|
+
id: `cs_stub_${V++}`,
|
|
1530
|
+
name: r.trim() ? D(r, "change_set_name", 200) : t || e,
|
|
1531
|
+
state: "open",
|
|
1532
|
+
createdBy: v,
|
|
1533
|
+
createTime: _(),
|
|
1534
|
+
chains: [],
|
|
1535
|
+
dependsOnChangeSetIds: [],
|
|
1536
|
+
status: "",
|
|
1537
|
+
assigneeIds: [],
|
|
1538
|
+
plannedReleases: []
|
|
1539
|
+
}, S.unshift(o);
|
|
1540
|
+
}
|
|
1541
|
+
let s = V++, c = `br_stub_${s}`, l = {
|
|
1542
|
+
...structuredClone(a.main),
|
|
1543
|
+
branchId: c
|
|
1544
|
+
};
|
|
1545
|
+
a.branches[o.id] = l, o.chains.push({
|
|
1546
|
+
id: `chain_stub_${s}`,
|
|
1547
|
+
contentId: e,
|
|
1548
|
+
born: !1,
|
|
1549
|
+
branches: [{
|
|
1550
|
+
id: c,
|
|
1551
|
+
position: 0,
|
|
1552
|
+
kind: "editorial",
|
|
1553
|
+
headRevisionId: l.revisionId
|
|
1554
|
+
}]
|
|
1555
|
+
});
|
|
1556
|
+
let [u] = et(a, {
|
|
1557
|
+
kind: "change_set",
|
|
1558
|
+
changeSetId: o.id
|
|
1559
|
+
}, "");
|
|
1560
|
+
return {
|
|
1561
|
+
changeSet: A(o),
|
|
1562
|
+
content: u
|
|
1563
|
+
};
|
|
1564
|
+
},
|
|
1565
|
+
async previewChain({ changeSetId: e, contentId: t, effectiveOn: n, validityPeriod: r }) {
|
|
1566
|
+
Q(e);
|
|
1567
|
+
let a = H(t);
|
|
1568
|
+
if (!a.main) throw new i(`Content ${t} is not published`);
|
|
1569
|
+
if (!W(a)) throw new i("undated Content's Chain takes no date");
|
|
1570
|
+
if (!h.test(n)) throw new i("effective_on is YYYY-MM-DD");
|
|
1571
|
+
let o = a.timeline ?? [], s = o.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
|
|
1572
|
+
return {
|
|
1573
|
+
forkReleaseId: s?.releaseId ?? "",
|
|
1574
|
+
carryForwardReleaseIds: o.filter((e) => e.validityPeriod && e.validityPeriod.firstDay > n).map((e) => e.releaseId),
|
|
1575
|
+
mergesMain: !1,
|
|
1576
|
+
cutIntoReleaseIds: s ? [s.releaseId] : [],
|
|
1577
|
+
coveredReleaseIds: r && r.lastDay !== "" ? o.filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && r.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= r.lastDay).map((e) => e.releaseId) : []
|
|
1578
|
+
};
|
|
1579
|
+
},
|
|
1580
|
+
async planRepeal({ changeSetId: e, contentId: t, lastDay: n }) {
|
|
1581
|
+
Q(e);
|
|
1582
|
+
let r = H(t);
|
|
1583
|
+
if (q(r), !W(r)) throw new i("a Repeal is for Dated Content");
|
|
1584
|
+
if (!h.test(n)) throw new i("last_day is YYYY-MM-DD");
|
|
1585
|
+
return $e(r, e, {
|
|
1586
|
+
kind: "repeal",
|
|
1587
|
+
validityPeriod: {
|
|
1588
|
+
firstDay: m(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
|
|
1589
|
+
lastDay: n
|
|
1590
|
+
}
|
|
1591
|
+
});
|
|
1592
|
+
},
|
|
1593
|
+
async planWithdrawal({ changeSetId: e, contentId: t }) {
|
|
1594
|
+
Q(e);
|
|
1595
|
+
let n = H(t);
|
|
1596
|
+
if (q(n), W(n)) throw new i("a Withdrawal is for undated Content");
|
|
1597
|
+
return $e(n, e, { kind: "withdrawal" });
|
|
1598
|
+
},
|
|
1599
|
+
async planRelease({ idempotencyKey: e, ...t }) {
|
|
1600
|
+
return z(e, ["planRelease", t], async () => {
|
|
1601
|
+
let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: a, supersedesReleaseIds: o } = t, { cs: s, chain: c, branch: l, c: u } = Ve(e, n);
|
|
1602
|
+
if (q(u), l.kind !== "editorial") throw new i("only an editorial Branch's head is released");
|
|
1603
|
+
if (s.plannedReleases.some((e) => e.branchId === n)) throw new i(`Branch ${n} is planned already`);
|
|
1604
|
+
let d = {
|
|
1605
|
+
id: `rls_stub_${V++}`,
|
|
1606
|
+
contentId: c.contentId,
|
|
1607
|
+
kind: "revision",
|
|
1608
|
+
branchId: n,
|
|
1609
|
+
revisionId: "",
|
|
1610
|
+
validityPeriod: r ? { ...r } : void 0,
|
|
1611
|
+
releaseSpec: structuredClone(a ?? {}),
|
|
1612
|
+
supersedesReleaseIds: [...o ?? []],
|
|
1613
|
+
proposed: !1,
|
|
1614
|
+
proposedForReleaseId: "",
|
|
1615
|
+
splitFromReleaseId: "",
|
|
1616
|
+
withheld: !1
|
|
1617
|
+
};
|
|
1618
|
+
return We(u, d), s.plannedReleases.push(d), Ge(s, u), structuredClone(d);
|
|
1619
|
+
});
|
|
1620
|
+
},
|
|
1621
|
+
async updatePlannedRelease({ idempotencyKey: e, ...t }) {
|
|
1622
|
+
return z(e, ["updatePlannedRelease", t], async () => {
|
|
1623
|
+
let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: a, supersedesReleaseIds: o } = t, s = Q(e), c = s.plannedReleases.findIndex((e) => e.id === n);
|
|
1624
|
+
if (c < 0) throw k("Planned Release", n);
|
|
1625
|
+
let l = s.plannedReleases[c];
|
|
1626
|
+
if (l.proposed) throw new i("a proposal is derived from the plans and can't be set");
|
|
1627
|
+
let u = H(l.contentId);
|
|
1628
|
+
q(u);
|
|
1629
|
+
let d = {
|
|
1630
|
+
...structuredClone(l),
|
|
1631
|
+
...r ? { validityPeriod: { ...r } } : {},
|
|
1632
|
+
...a ? { releaseSpec: structuredClone(a) } : {},
|
|
1633
|
+
...o ? { supersedesReleaseIds: [...o] } : {}
|
|
1634
|
+
};
|
|
1635
|
+
return We(u, d), s.plannedReleases[c] = d, Ge(s, u), structuredClone(d);
|
|
1636
|
+
});
|
|
1637
|
+
},
|
|
1638
|
+
async appendBranch({ idempotencyKey: e, ...t }) {
|
|
1639
|
+
return z(e, ["appendBranch", t], async () => {
|
|
1640
|
+
let { changeSetId: e, chainId: n, effectiveOn: r } = t, a = Q(e), o = a.chains.find((e) => e.id === n);
|
|
1641
|
+
if (!o) throw k("Chain", n);
|
|
1642
|
+
let s = H(o.contentId);
|
|
1643
|
+
if (o.born || !W(s)) throw new i("only a Chain on published Dated Content takes dates");
|
|
1644
|
+
let c = o.branches.filter((e) => e.kind === "editorial").at(-1);
|
|
1645
|
+
if (!h.test(r) || c?.effectiveOn && r <= c.effectiveOn) throw new i("effective_on is a day after the Chain's last editorial Branch's");
|
|
1646
|
+
let l = o.branches.at(-1), u = `br_stub_${V++}`;
|
|
1647
|
+
o.branches.push({
|
|
1648
|
+
id: u,
|
|
1649
|
+
position: o.branches.length,
|
|
1650
|
+
kind: "editorial",
|
|
1651
|
+
headRevisionId: l?.headRevisionId ?? "",
|
|
1652
|
+
effectiveOn: r
|
|
1653
|
+
});
|
|
1654
|
+
let d = s.branches[e];
|
|
1655
|
+
return d && (s.branches[e] = {
|
|
1656
|
+
...d,
|
|
1657
|
+
branchId: u
|
|
1658
|
+
}), {
|
|
1659
|
+
changeSet: A(a),
|
|
1660
|
+
branchId: u
|
|
1661
|
+
};
|
|
1662
|
+
});
|
|
1663
|
+
},
|
|
1664
|
+
async dropChain({ idempotencyKey: e, ...t }) {
|
|
1665
|
+
return z(e, ["dropChain", t], async () => {
|
|
1666
|
+
let { changeSetId: e, chainId: n } = t, r = Q(e), a = r.chains.find((e) => e.id === n);
|
|
1667
|
+
if (!a) throw k("Chain", n);
|
|
1668
|
+
if (a.born) throw new i("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
|
|
1669
|
+
for (let e of a.branches) Ue(e.id);
|
|
1670
|
+
return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !== a.contentId), delete H(a.contentId).branches[e], A(r);
|
|
1671
|
+
});
|
|
1672
|
+
},
|
|
1673
|
+
async getPendingMerge(e) {
|
|
1674
|
+
let t = R.get(e);
|
|
1675
|
+
return t ? structuredClone(t) : null;
|
|
1676
|
+
},
|
|
1677
|
+
async resolveMerge({ idempotencyKey: e, ...t }) {
|
|
1678
|
+
return z(e, ["resolveMerge", t], async () => {
|
|
1679
|
+
let { changeSetId: e, branchId: n, expectedHeadId: r, resolutions: a } = t, { chain: o, branch: s, c } = Ve(e, n), l = R.get(n);
|
|
1680
|
+
if (!l) throw new i(`Branch ${n} has no Pending Merge`);
|
|
1681
|
+
if (s.headRevisionId !== r) throw new f({
|
|
1682
|
+
contentId: c.id,
|
|
1683
|
+
branchId: n,
|
|
1684
|
+
expectedHeadId: r,
|
|
1685
|
+
currentHeadId: s.headRevisionId
|
|
1686
|
+
});
|
|
1687
|
+
let u = a.map((e) => e.path), d = l.fields.map((e) => e.path);
|
|
1688
|
+
if (new Set(u).size !== u.length || u.some((e) => !d.includes(e)) || d.some((e) => !u.includes(e))) throw new i("decide every field the Pending Merge lists, once");
|
|
1689
|
+
let p = structuredClone(l.merged);
|
|
1690
|
+
for (let e of a) {
|
|
1691
|
+
let t = l.fields.find((t) => t.path === e.path), n = "side" in e ? e.side === "ours" ? t.ours : t.theirs : e.value, r = e.path.replace(/^\//, "");
|
|
1692
|
+
n === void 0 ? delete p[r] : p[r] = structuredClone(n);
|
|
1693
|
+
}
|
|
1694
|
+
let m = Be({
|
|
1695
|
+
changeSetId: e,
|
|
1696
|
+
chain: o,
|
|
1697
|
+
branch: s,
|
|
1698
|
+
c,
|
|
1699
|
+
data: p,
|
|
1700
|
+
cause: "resolve",
|
|
1701
|
+
secondParentId: l.theirsRevisionId
|
|
1702
|
+
});
|
|
1703
|
+
return Ue(n), m;
|
|
1704
|
+
});
|
|
1705
|
+
},
|
|
1706
|
+
async abortMerge({ idempotencyKey: e, ...t }) {
|
|
1707
|
+
return z(e, ["abortMerge", t], async () => {
|
|
1708
|
+
if (Ve(t.changeSetId, t.branchId), !R.has(t.branchId)) throw new i(`Branch ${t.branchId} has no Pending Merge`);
|
|
1709
|
+
Ue(t.branchId);
|
|
1710
|
+
});
|
|
1711
|
+
},
|
|
1712
|
+
async previewInForce({ contentId: e, changeSetId: t, validOn: n }) {
|
|
1713
|
+
let r = Q(t), i = H(e), a = n || Me(), 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
|
+
if (c) {
|
|
1715
|
+
let e = c.branchId ? o?.branches.find((e) => e.id === c.branchId)?.headRevisionId ?? "" : c.revisionId;
|
|
1716
|
+
return {
|
|
1717
|
+
releaseId: c.id,
|
|
1718
|
+
revisionId: e,
|
|
1719
|
+
planned: !0,
|
|
1720
|
+
withheld: !1,
|
|
1721
|
+
validityPeriod: c.validityPeriod ? { ...c.validityPeriod } : void 0,
|
|
1722
|
+
data: structuredClone(K(i, e) ?? {})
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
let l = m(i.timeline ?? [], a);
|
|
1726
|
+
return l ? {
|
|
1727
|
+
releaseId: l.releaseId,
|
|
1728
|
+
revisionId: l.revisionId,
|
|
1729
|
+
planned: !1,
|
|
1730
|
+
withheld: !1,
|
|
1731
|
+
validityPeriod: l.validityPeriod ? { ...l.validityPeriod } : void 0,
|
|
1732
|
+
data: structuredClone(K(i, l.revisionId) ?? {})
|
|
1733
|
+
} : null;
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
function $e(e, t, n) {
|
|
1737
|
+
let r = {
|
|
1738
|
+
id: `rls_stub_${V++}`,
|
|
1739
|
+
contentId: e.id,
|
|
1740
|
+
branchId: "",
|
|
1741
|
+
revisionId: e.inForce?.revisionId ?? e.main?.revisionId ?? "",
|
|
1742
|
+
supersedesReleaseIds: [],
|
|
1743
|
+
proposed: !1,
|
|
1744
|
+
proposedForReleaseId: "",
|
|
1745
|
+
splitFromReleaseId: "",
|
|
1746
|
+
withheld: !1,
|
|
1747
|
+
...n
|
|
1748
|
+
};
|
|
1749
|
+
return e.plannedReleases = [...e.plannedReleases ?? [], {
|
|
1750
|
+
changeSetId: t,
|
|
1751
|
+
plannedRelease: r
|
|
1752
|
+
}], structuredClone({
|
|
1753
|
+
plannedRelease: r,
|
|
1754
|
+
gapReferrers: Pe(e.id)
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
function et(e, t, n) {
|
|
1758
|
+
let r = (t, n) => ({
|
|
1759
|
+
id: e.id,
|
|
1760
|
+
blueprintId: e.blueprintId,
|
|
1761
|
+
blueprintReleaseId: e.blueprintReleaseId,
|
|
1762
|
+
revisionId: t.revisionId,
|
|
1763
|
+
data: structuredClone(t.data),
|
|
1764
|
+
changeSetId: n.changeSetId ?? "",
|
|
1765
|
+
branchId: n.branchId ?? "",
|
|
1766
|
+
revisionCreateTime: t.revisionCreateTime,
|
|
1767
|
+
releaseId: n.releaseId ?? ""
|
|
1768
|
+
});
|
|
1769
|
+
if (t.kind === "in_force") return e.inForce ? [r(e.inForce, { releaseId: e.inForce.releaseId })] : [];
|
|
1770
|
+
if (t.kind === "change_set") {
|
|
1771
|
+
let i = e.branches[t.changeSetId];
|
|
1772
|
+
return !i || n && !N(i.data, n) ? [] : [r(i, {
|
|
1773
|
+
changeSetId: t.changeSetId,
|
|
1774
|
+
branchId: i.branchId
|
|
1775
|
+
})];
|
|
1776
|
+
}
|
|
1777
|
+
if (!n) return e.main ? [r(e.main, {})] : [];
|
|
1778
|
+
let i = [];
|
|
1779
|
+
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)) S.find((e) => e.id === t)?.state === "open" && N(a.data, n) && i.push(r(a, {
|
|
1781
|
+
changeSetId: t,
|
|
1782
|
+
branchId: a.branchId
|
|
1783
|
+
}));
|
|
1784
|
+
return i;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
function N(e, t) {
|
|
1788
|
+
let n = (e) => e.toLocaleLowerCase().replace(/\s+/g, " "), r = n(t);
|
|
1789
|
+
return Object.values(e).some((e) => typeof e == "string" && n(e).includes(r));
|
|
1790
|
+
}
|
|
1791
|
+
//#endregion
|
|
1792
|
+
//#region src/testing/stub-status-source.ts
|
|
1793
|
+
function P(e = ce()) {
|
|
1794
|
+
return { async listChangeSetStatuses() {
|
|
1795
|
+
return e.map((e) => ({ ...e }));
|
|
1796
|
+
} };
|
|
1797
|
+
}
|
|
1798
|
+
//#endregion
|
|
1799
|
+
export { S as STUB_NOW, x as STUB_OTHER_USER_ID, b as STUB_USER_ID, y as STUB_WORKSPACE_ID, E as createStubBlueprintSource, M as createStubContenthubClient, P as createStubStatusSource, se as stubBlockReasons, j as stubBlocker, T as stubBlueprintReleases, w as stubBlueprints, ce as stubChangeSetStatuses, ue as stubChangeSets, fe as stubCollections, he as stubContents, C as stubIdentity, me as stubRepealedContent, de as stubRequiredChecks, pe as stubResolvedReleases, le as stubStatusTransitions };
|
|
1800
|
+
|
|
1801
|
+
//# sourceMappingURL=testing.js.map
|