@knkcs/importhub-ui 0.7.0 → 0.9.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/dist/testing.js CHANGED
@@ -1,38 +1,40 @@
1
- import { createHostMembers as _e } from "@knkcs/anker/host";
2
- import { A as ce, S as M, R as Q, C as le, N as ye } from "./importhub-client-BS6F4DW2.js";
3
- const h = "user_stub_ada", q = "user_stub_grace", te = "ws_stub_main", Be = "ws_stub_other";
4
- function Ae(r = te) {
1
+ import { createHostMembers as Se } from "@knkcs/anker/host";
2
+ import { M as O, A as pe, S as B, R as ee, C as ce, N as we } from "./importhub-client-Wrb4s3lw.js";
3
+ import { p as Pe } from "./field-tree-CghMgGKm.js";
4
+ const b = "user_stub_ada", H = "user_stub_grace", ne = "ws_stub_main", De = "ws_stub_other";
5
+ function Ze(n = ne) {
5
6
  return {
6
- userId: h,
7
- workspaceId: r,
8
- members: _e([
9
- { userId: h, displayName: "Ada Importer", email: "ada@example.com" },
10
- { userId: q, displayName: "Grace Hopper", email: "grace@example.com" }
7
+ userId: b,
8
+ workspaceId: n,
9
+ members: Se([
10
+ { userId: b, displayName: "Ada Importer", email: "ada@example.com" },
11
+ { userId: H, displayName: "Grace Hopper", email: "grace@example.com" }
11
12
  ])
12
13
  };
13
14
  }
14
- const _ = (r, c, l, u = []) => ({
15
- accessor: r.split(".").pop() ?? r,
16
- path: r,
17
- fieldType: c,
18
- label: l,
19
- children: u
20
- }), j = (r) => r.flatMap((c) => [c.path, ...j(c.children)]), pe = (r) => [
21
- _("titel", "text", "Titel"),
22
- _("abkuerzung", "text", "Abkürzung"),
23
- ...r ? [_("fussnote", "rich_text", "Fußnote")] : [],
24
- _("stand", "fieldset", "Stand", [
25
- _("stand.datum", "date", "Datum"),
26
- _("stand.art", "select", "Art")
15
+ const S = (n, a, o, m = []) => ({
16
+ accessor: n.split(".").pop() ?? n,
17
+ path: n,
18
+ fieldType: a,
19
+ label: o,
20
+ children: m
21
+ }), q = (n) => n.flatMap((a) => [a.path, ...q(a.children)]), de = (n) => [
22
+ S("titel", "text", "Titel"),
23
+ S("abkuerzung", "text", "Abkürzung"),
24
+ S("anzeigename", "textarea", "Anzeigename"),
25
+ ...n ? [S("fussnote", "rich_text", "Fußnote")] : [],
26
+ S("stand", "fieldset", "Stand", [
27
+ S("stand.datum", "date", "Datum"),
28
+ S("stand.art", "select", "Art")
27
29
  ])
28
- ], de = () => [
29
- _("fundstelle", "text", "Fundstelle"),
30
- _("ausgabedatum", "date", "Ausgabedatum")
30
+ ], me = () => [
31
+ S("fundstelle", "text", "Fundstelle"),
32
+ S("ausgabedatum", "date", "Ausgabedatum")
31
33
  ];
32
34
  function ge() {
33
- const r = pe(!1), c = pe(!0), l = [
34
- _("aktenzeichen", "text", "Aktenzeichen"),
35
- _("datum", "date", "Datum")
35
+ const n = de(!1), a = de(!0), o = [
36
+ S("aktenzeichen", "text", "Aktenzeichen"),
37
+ S("datum", "date", "Datum")
36
38
  ];
37
39
  return [
38
40
  {
@@ -40,30 +42,30 @@ function ge() {
40
42
  blueprintId: "bp_stub_gesetz",
41
43
  blueprintName: "Gesetz",
42
44
  label: "Release 2",
43
- fieldPaths: j(r),
44
- fields: r,
45
- releaseSpecFields: de()
45
+ fieldPaths: q(n),
46
+ fields: n,
47
+ releaseSpecFields: me()
46
48
  },
47
49
  {
48
50
  id: "br_stub_gesetz_1",
49
51
  blueprintId: "bp_stub_gesetz",
50
52
  blueprintName: "Gesetz",
51
53
  label: "Release 1",
52
- fieldPaths: j(c),
53
- fields: c,
54
- releaseSpecFields: de()
54
+ fieldPaths: q(a),
55
+ fields: a,
56
+ releaseSpecFields: me()
55
57
  },
56
58
  {
57
59
  id: "br_stub_entscheidung_1",
58
60
  blueprintId: "bp_stub_entscheidung",
59
61
  blueprintName: "Entscheidung",
60
62
  label: "Release 1",
61
- fieldPaths: j(l),
62
- fields: l
63
+ fieldPaths: q(o),
64
+ fields: o
63
65
  }
64
66
  ];
65
67
  }
66
- function Ie() {
68
+ function Te() {
67
69
  return [
68
70
  {
69
71
  id: "mp_stub_norm",
@@ -95,7 +97,13 @@ function Ie() {
95
97
  }
96
98
  ];
97
99
  }
98
- function Se() {
100
+ const je = `<?xml version="1.0" encoding="UTF-8"?>
101
+ <gesetz>
102
+ <norm id="n1"><titel>§ 1 Geltungsbereich</titel><fn>Gilt ab 2026.</fn></norm>
103
+ <norm id="n2"><titel>§ 2 Begriffsbestimmungen</titel></norm>
104
+ </gesetz>
105
+ `;
106
+ function ve() {
99
107
  return [
100
108
  {
101
109
  id: "es_stub_latin1",
@@ -108,7 +116,7 @@ function Se() {
108
116
  }
109
117
  ];
110
118
  }
111
- function we() {
119
+ function $e() {
112
120
  return [
113
121
  {
114
122
  id: "ip_stub_gesetz",
@@ -139,12 +147,12 @@ function we() {
139
147
  }
140
148
  ];
141
149
  }
142
- const X = (r, c, l, u = "") => ({
150
+ const te = (n, a, o, m = "") => ({
143
151
  field_type: "text",
144
- config: { name: c, api_accessor: r, required: l, instructions: u },
152
+ config: { name: a, api_accessor: n, required: o, instructions: m },
145
153
  system: !1
146
154
  });
147
- function Pe() {
155
+ function Ee() {
148
156
  return [
149
157
  {
150
158
  name: "citation-links",
@@ -166,8 +174,8 @@ function Pe() {
166
174
  target: "source_file",
167
175
  description: "Renames every element of one name to another.",
168
176
  settingsSpec: [
169
- X("from", "Element", !0, "The element's name now."),
170
- X("to", "New name", !0)
177
+ te("from", "Element", !0, "The element's name now."),
178
+ te("to", "New name", !0)
171
179
  ]
172
180
  },
173
181
  {
@@ -175,11 +183,11 @@ function Pe() {
175
183
  kind: "preprocessor",
176
184
  target: "source_file",
177
185
  description: "Wraps each sentence of an element in its own element.",
178
- settingsSpec: [X("element", "Element", !1)]
186
+ settingsSpec: [te("element", "Element", !1)]
179
187
  }
180
188
  ];
181
189
  }
182
- const $ = (r = {}) => ({
190
+ const M = (n = {}) => ({
183
191
  matched: 0,
184
192
  created: 0,
185
193
  problems: 0,
@@ -187,13 +195,13 @@ const $ = (r = {}) => ({
187
195
  corrected: 0,
188
196
  kept: 0,
189
197
  unchanged: 0,
190
- ...r
191
- }), w = (r) => ({
198
+ ...n
199
+ }), v = (n) => ({
192
200
  importProfile: {
193
201
  configurationId: "ip_stub_gesetz",
194
202
  name: "Boorberg gesetz",
195
- releaseId: `ip_stub_gesetz_rel${r}`,
196
- number: r
203
+ releaseId: `ip_stub_gesetz_rel${n}`,
204
+ number: n
197
205
  },
198
206
  mappings: [
199
207
  {
@@ -209,53 +217,53 @@ const $ = (r = {}) => ({
209
217
  releaseId: "es_stub_latin1_rel1",
210
218
  number: 1
211
219
  }
212
- }), T = (r) => ({
220
+ }), E = (n) => ({
213
221
  importProfileId: "ip_stub_gesetz",
214
222
  importProfileName: "Boorberg gesetz",
215
- sourceFileId: `sf_${r.id}`,
216
- startedBy: h,
223
+ sourceFileId: `sf_${n.id}`,
224
+ startedBy: b,
217
225
  phase: "ended",
218
226
  failureReason: "",
219
227
  progress: { done: 0, total: 0 },
220
- counts: $(),
228
+ counts: M(),
221
229
  changeSetId: "",
222
- releases: w(2),
230
+ releases: v(2),
223
231
  createTime: "2026-11-03T09:00:00.000Z",
224
232
  startTime: "",
225
233
  endTime: "",
226
234
  cancelledBy: "",
227
235
  effectiveDate: "",
228
- ...r
229
- }), B = (r, c, l, u, b) => ({
230
- id: `prob_stub_${r}`,
231
- mappingId: c === "norm" ? "mp_stub_norm" : "mp_stub_title",
232
- mappingName: c === "norm" ? "Gesetz norms" : "Gesetz titles",
233
- sourceKey: l,
234
- field: u,
235
- reason: b
236
+ ...n
237
+ }), x = (n, a, o, m, g) => ({
238
+ id: `prob_stub_${n}`,
239
+ mappingId: a === "norm" ? "mp_stub_norm" : "mp_stub_title",
240
+ mappingName: a === "norm" ? "Gesetz norms" : "Gesetz titles",
241
+ sourceKey: o,
242
+ field: m,
243
+ reason: g
236
244
  });
237
- function ve() {
245
+ function Re() {
238
246
  return [
239
- T({
247
+ E({
240
248
  id: "im_stub_running",
241
249
  phase: "writing",
242
250
  progress: { done: 48, total: 120 },
243
- counts: $({ matched: 120, created: 40, planned: 8 }),
251
+ counts: M({ matched: 120, created: 40, planned: 8 }),
244
252
  changeSetId: "cs_stub_running",
245
253
  createTime: "2026-11-04T10:00:00.000Z",
246
254
  startTime: "2026-11-04T10:00:05.000Z"
247
255
  }),
248
- T({
256
+ E({
249
257
  id: "im_stub_queued",
250
258
  phase: "queued",
251
- startedBy: q,
252
- releases: w(2),
259
+ startedBy: H,
260
+ releases: v(2),
253
261
  createTime: "2026-11-04T10:05:00.000Z"
254
262
  }),
255
- T({
263
+ E({
256
264
  id: "im_stub_problems",
257
265
  outcome: "succeeded_with_problems",
258
- counts: $({
266
+ counts: M({
259
267
  matched: 212,
260
268
  created: 180,
261
269
  planned: 20,
@@ -265,9 +273,9 @@ function ve() {
265
273
  }),
266
274
  changeSetId: "cs_stub_problems",
267
275
  releases: {
268
- ...w(2),
276
+ ...v(2),
269
277
  mappings: [
270
- ...w(2).mappings,
278
+ ...v(2).mappings,
271
279
  {
272
280
  configurationId: "mp_stub_title",
273
281
  name: "Gesetz titles",
@@ -282,52 +290,52 @@ function ve() {
282
290
  effectiveDate: "2026-10-01",
283
291
  source: { date: "2026-09-20", reference: "BGBl. 2026 I Nr. 270" },
284
292
  itemProblems: [
285
- B(1, "norm", "BJNR000010001", "stand/datum", "“31.02.2026” is not a date."),
286
- B(2, "norm", "BJNR000010002", "", "The Version Match found two Releases."),
287
- B(3, "title", "BJNR000020001", "", "No Title has the Ausgabe code BY-7."),
288
- B(4, "norm", "BJNR000030001", "titel", "The field is required."),
289
- B(5, "title", "BJNR000030002", "", "No Title has the Ausgabe code BY-9.")
293
+ x(1, "norm", "BJNR000010001", "stand/datum", "“31.02.2026” is not a date."),
294
+ x(2, "norm", "BJNR000010002", "", "The Version Match found two Releases."),
295
+ x(3, "title", "BJNR000020001", "", "No Title has the Ausgabe code BY-7."),
296
+ x(4, "norm", "BJNR000030001", "titel", "The field is required."),
297
+ x(5, "title", "BJNR000030002", "", "No Title has the Ausgabe code BY-9.")
290
298
  ]
291
299
  }),
292
- T({
300
+ E({
293
301
  id: "im_stub_succeeded",
294
302
  outcome: "succeeded",
295
- counts: $({ matched: 64, created: 64 }),
303
+ counts: M({ matched: 64, created: 64 }),
296
304
  changeSetId: "cs_stub_succeeded",
297
- releases: w(1),
305
+ releases: v(1),
298
306
  createTime: "2026-11-02T14:00:00.000Z",
299
307
  startTime: "2026-11-02T14:00:01.000Z",
300
308
  endTime: "2026-11-02T14:03:10.000Z"
301
309
  }),
302
- T({
310
+ E({
303
311
  id: "im_stub_failed",
304
312
  outcome: "failed",
305
313
  failureReason: "The worker crashed three times running this Import.",
306
- counts: $({ matched: 30 }),
307
- releases: w(1),
314
+ counts: M({ matched: 30 }),
315
+ releases: v(1),
308
316
  createTime: "2026-11-02T11:00:00.000Z",
309
317
  startTime: "2026-11-02T11:00:01.000Z",
310
318
  endTime: "2026-11-02T11:20:00.000Z"
311
319
  }),
312
- T({
320
+ E({
313
321
  id: "im_stub_cancelled",
314
322
  outcome: "cancelled",
315
- cancelledBy: q,
316
- counts: $({ matched: 12, created: 3 }),
317
- releases: w(1),
323
+ cancelledBy: H,
324
+ counts: M({ matched: 12, created: 3 }),
325
+ releases: v(1),
318
326
  createTime: "2026-11-01T16:00:00.000Z",
319
327
  startTime: "2026-11-01T16:00:01.000Z",
320
328
  endTime: "2026-11-01T16:01:00.000Z"
321
329
  })
322
330
  ];
323
331
  }
324
- function Te() {
332
+ function Me() {
325
333
  return [
326
334
  {
327
335
  id: "key_stub_nightly",
328
336
  name: "Nightly gesetz feed",
329
337
  keyPrefix: "ihk_7Qx2",
330
- owner: q,
338
+ owner: H,
331
339
  expireTime: "",
332
340
  createTime: "2026-11-20T07:30:00.000Z"
333
341
  },
@@ -335,13 +343,115 @@ function Te() {
335
343
  id: "key_stub_pipeline",
336
344
  name: "VRPML pipeline",
337
345
  keyPrefix: "ihk_b91F",
338
- owner: h,
346
+ owner: b,
339
347
  expireTime: "2027-06-30T21:59:59.000Z",
340
348
  createTime: "2026-11-03T12:00:00.000Z"
341
349
  }
342
350
  ];
343
351
  }
344
- const Re = [
352
+ const ke = /* @__PURE__ */ new Set(["amp", "lt", "gt", "quot", "apos"]);
353
+ function Ne(n, a) {
354
+ return n.replace(
355
+ /&([A-Za-z_][\w.-]*);/g,
356
+ (o, m) => !ke.has(m) && m in a ? a[m] ?? o : o
357
+ );
358
+ }
359
+ function Ae(n, a) {
360
+ if (typeof DOMParser > "u")
361
+ throw new Error("the stub's Mapping Test reads the sample with the DOM: run it in a browser");
362
+ const o = new DOMParser().parseFromString(a, "application/xml"), m = o.getElementsByTagName("parsererror")[0];
363
+ if (m)
364
+ throw new O(
365
+ `the sample is not XML: ${(m.textContent ?? "").split(`
366
+ `)[0]}`
367
+ );
368
+ const g = n.elementSelector?.trim() ?? "";
369
+ if (!g) throw new O("the Mapping has no element selector");
370
+ const y = (() => {
371
+ try {
372
+ const d = o.evaluate(g, o, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
373
+ return Array.from({ length: d.snapshotLength }, (h, _) => d.snapshotItem(_));
374
+ } catch {
375
+ throw new O(`the element selector ${g} cannot be evaluated`);
376
+ }
377
+ })(), r = n.sourceKey?.selector?.trim() ?? "";
378
+ return {
379
+ elements: y.map((d, h) => {
380
+ const _ = [];
381
+ let w = "";
382
+ if (r)
383
+ try {
384
+ w = _e(o, r, d).trim();
385
+ } catch {
386
+ throw new O(`the Source Key ${r} cannot be evaluated`);
387
+ }
388
+ w || _.push({ field: "", reason: "the element has no Source Key" });
389
+ const I = ye(o, n.fields ?? [], d, "", _);
390
+ return {
391
+ position: h + 1,
392
+ sourceKey: w,
393
+ values: I,
394
+ firstDay: "",
395
+ lastDay: "",
396
+ releaseSpec: {},
397
+ displayName: "",
398
+ collections: [...n.collections ?? []],
399
+ problems: _
400
+ };
401
+ })
402
+ };
403
+ }
404
+ function _e(n, a, o) {
405
+ return n.evaluate(`string(${a})`, o, null, XPathResult.STRING_TYPE, null).stringValue;
406
+ }
407
+ function ye(n, a, o, m, g) {
408
+ const y = {};
409
+ for (const r of a) {
410
+ const d = typeof r.name == "string" ? r.name : "";
411
+ if (!d) continue;
412
+ const h = m ? `${m}.${d}` : d, _ = typeof r.selector == "string" ? r.selector.trim() : "";
413
+ if (r.type === "fieldset") {
414
+ let I = o;
415
+ if (_ && _ !== ".")
416
+ try {
417
+ I = n.evaluate(
418
+ _,
419
+ o,
420
+ null,
421
+ XPathResult.FIRST_ORDERED_NODE_TYPE,
422
+ null
423
+ ).singleNodeValue;
424
+ } catch {
425
+ I = null;
426
+ }
427
+ if (!I) {
428
+ r.optional || g.push({ field: h, reason: `nothing at ${_}` });
429
+ continue;
430
+ }
431
+ const k = Array.isArray(r.fields) ? r.fields : [];
432
+ y[d] = ye(n, k, I, h, g);
433
+ continue;
434
+ }
435
+ if (!_) {
436
+ g.push({ field: h, reason: "the field has no XPath" });
437
+ continue;
438
+ }
439
+ let w;
440
+ try {
441
+ w = _e(n, _, o).trim();
442
+ } catch {
443
+ g.push({ field: h, reason: `the XPath ${_} cannot be evaluated` });
444
+ continue;
445
+ }
446
+ if (!w) {
447
+ r.optional || g.push({ field: h, reason: `nothing at ${_}` });
448
+ continue;
449
+ }
450
+ y[d] = w;
451
+ }
452
+ return y;
453
+ }
454
+ const Be = [
345
455
  "listImportProfiles",
346
456
  "getImportProfile",
347
457
  "createImportProfile",
@@ -355,6 +465,7 @@ const Re = [
355
465
  "deleteMapping",
356
466
  "listMappingImportProfiles",
357
467
  "checkMappingBlueprintRelease",
468
+ "runMappingTest",
358
469
  "listEntitySets",
359
470
  "getEntitySet",
360
471
  "createEntitySet",
@@ -374,90 +485,90 @@ const Re = [
374
485
  "createApiKey",
375
486
  "revokeApiKey"
376
487
  ];
377
- let me = Date.parse("2026-11-02T08:00:00Z");
378
- const P = () => (me += 36e5, new Date(me).toISOString()), ee = (r = []) => r.map((c) => {
379
- const l = Math.max(c.releaseNumber ?? 0, 1), u = Array.from({ length: l }, (y, p) => ({
380
- id: `${c.id}_r${p + 1}`,
381
- content: structuredClone(c.content),
382
- savedBy: h,
383
- savedAt: P(),
488
+ let ue = Date.parse("2026-11-02T08:00:00Z");
489
+ const $ = () => (ue += 36e5, new Date(ue).toISOString()), se = (n = []) => n.map((a) => {
490
+ const o = Math.max(a.releaseNumber ?? 0, 1), m = Array.from({ length: o }, (y, r) => ({
491
+ id: `${a.id}_r${r + 1}`,
492
+ content: structuredClone(a.content),
493
+ savedBy: b,
494
+ savedAt: $(),
384
495
  restoredFromRevisionId: ""
385
- })), b = Array.from({ length: c.releaseNumber ?? 0 }, (y, p) => ({
386
- id: `${c.id}_rel${p + 1}`,
387
- number: p + 1,
388
- revisionId: `${c.id}_r${p + 1}`,
389
- releasedBy: h,
390
- releasedAt: P()
496
+ })), g = Array.from({ length: a.releaseNumber ?? 0 }, (y, r) => ({
497
+ id: `${a.id}_rel${r + 1}`,
498
+ number: r + 1,
499
+ revisionId: `${a.id}_r${r + 1}`,
500
+ releasedBy: b,
501
+ releasedAt: $()
391
502
  }));
392
- return { id: c.id, content: structuredClone(c.content), revisions: u, releases: b };
393
- }), A = (r) => r.revisions[r.revisions.length - 1], he = (r) => r.releases[r.releases.length - 1], Z = (r) => {
394
- const c = he(r), l = r.revisions.find((u) => u.id === c?.revisionId);
503
+ return { id: a.id, content: structuredClone(a.content), revisions: m, releases: g };
504
+ }), F = (n) => n.revisions[n.revisions.length - 1], be = (n) => n.releases[n.releases.length - 1], G = (n) => {
505
+ const a = be(n), o = n.revisions.find((m) => m.id === a?.revisionId);
395
506
  return {
396
- draftRevisionId: A(r).id,
507
+ draftRevisionId: F(n).id,
397
508
  // By content, as importhub compares: a draft that restored the
398
509
  // released content does not differ.
399
- draftDiffersFromRelease: !l || JSON.stringify(l.content) !== JSON.stringify(A(r).content),
400
- ...c ? { latestRelease: { id: c.id, number: c.number } } : {}
510
+ draftDiffersFromRelease: !o || JSON.stringify(o.content) !== JSON.stringify(F(n).content),
511
+ ...a ? { latestRelease: { id: a.id, number: a.number } } : {}
401
512
  };
402
- }, $e = (r) => r.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`), ue = (r) => Object.fromEntries(
403
- Object.entries(r).map(([c, l]) => [$e(c), l])
404
- ), R = (r) => ({
405
- valid: r.length === 0,
406
- reasons: r
407
- }), D = (r) => [...r].sort((c, l) => c.content.name.localeCompare(l.content.name));
408
- let fe = 0;
409
- function Ne(r = {}) {
410
- const c = Object.fromEntries(
513
+ }, xe = (n) => n.replace(/[A-Z]/g, (a) => `_${a.toLowerCase()}`), fe = (n) => Object.fromEntries(
514
+ Object.entries(n).map(([a, o]) => [xe(a), o])
515
+ ), R = (n) => ({
516
+ valid: n.length === 0,
517
+ reasons: n
518
+ }), L = (n) => [...n].sort((a, o) => a.content.name.localeCompare(o.content.name));
519
+ let he = 0;
520
+ function Ge(n = {}) {
521
+ const a = Object.fromEntries(
411
522
  Object.entries(
412
- r.workspaces ?? {
413
- [te]: {
414
- importProfiles: we(),
415
- mappings: Ie(),
416
- entitySets: Se(),
417
- imports: ve(),
418
- apiKeys: Te()
523
+ n.workspaces ?? {
524
+ [ne]: {
525
+ importProfiles: $e(),
526
+ mappings: Te(),
527
+ entitySets: ve(),
528
+ imports: Re(),
529
+ apiKeys: Me()
419
530
  }
420
531
  }
421
532
  ).map(([e, t]) => [
422
533
  e,
423
534
  {
424
- importProfiles: ee(t.importProfiles),
425
- mappings: ee(t.mappings),
426
- entitySets: ee(t.entitySets),
535
+ importProfiles: se(t.importProfiles),
536
+ mappings: se(t.mappings),
537
+ entitySets: se(t.entitySets),
427
538
  imports: structuredClone(t.imports ?? []),
428
539
  apiKeys: structuredClone(t.apiKeys ?? [])
429
540
  }
430
541
  ])
431
- ), l = r.processors ?? Pe(), u = r.blueprintReleases ?? ge();
432
- let b = r.activeWorkspaceId ?? te;
433
- const y = Object.fromEntries(Re.map((e) => [e, 0])), p = () => (c[b] ??= {
542
+ ), o = n.processors ?? Ee(), m = n.blueprintReleases ?? ge();
543
+ let g = n.activeWorkspaceId ?? ne;
544
+ const y = Object.fromEntries(Be.map((e) => [e, 0])), r = () => (a[g] ??= {
434
545
  importProfiles: [],
435
546
  mappings: [],
436
547
  entitySets: [],
437
548
  imports: [],
438
549
  apiKeys: []
439
- }, c[b]), f = async (e, t) => {
440
- if (y[e]++, r.fail) throw r.fail;
550
+ }, a[g]), d = async (e, t) => {
551
+ if (y[e]++, n.fail) throw n.fail;
441
552
  return structuredClone(t());
442
- }, g = (e, t, s) => {
443
- const n = e.find((i) => i.id === t);
444
- if (!n) throw new Error(`${s} ${t} not found`);
445
- return n;
446
- }, v = (e, t, s) => {
553
+ }, h = (e, t, s) => {
554
+ const i = e.find((l) => l.id === t);
555
+ if (!i) throw new Error(`${s} ${t} not found`);
556
+ return i;
557
+ }, _ = (e, t, s) => {
447
558
  if (!t.trim()) throw new Error("a name is required");
448
- if (e.some((n) => n.id !== s && n.content.name === t)) throw new ye();
449
- }, ne = (e, t) => t !== "" && t !== A(e).id, N = (e, t, s, n = "") => {
450
- if (ne(e, s))
559
+ if (e.some((i) => i.id !== s && i.content.name === t)) throw new we();
560
+ }, w = (e, t) => t !== "" && t !== F(e).id, I = (e, t, s, i = "") => {
561
+ if (w(e, s))
451
562
  throw new Error("the draft moved: somebody saved in between");
452
563
  e.content = structuredClone(t), e.revisions.push({
453
564
  id: `${e.id}_r${e.revisions.length + 1}`,
454
565
  content: structuredClone(t),
455
- savedBy: h,
456
- savedAt: P(),
457
- restoredFromRevisionId: n
566
+ savedBy: b,
567
+ savedAt: $(),
568
+ restoredFromRevisionId: i
458
569
  });
459
- }, G = (e, t) => {
460
- const s = H(e);
570
+ }, k = (e, t) => {
571
+ const s = X(e);
461
572
  return {
462
573
  id: s,
463
574
  content: structuredClone(t),
@@ -465,8 +576,8 @@ function Ne(r = {}) {
465
576
  {
466
577
  id: `${s}_r1`,
467
578
  content: structuredClone(t),
468
- savedBy: h,
469
- savedAt: P(),
579
+ savedBy: b,
580
+ savedAt: $(),
470
581
  restoredFromRevisionId: ""
471
582
  }
472
583
  ],
@@ -474,7 +585,7 @@ function Ne(r = {}) {
474
585
  };
475
586
  };
476
587
  function J(e) {
477
- const t = [], s = u.find((o) => o.id === e.blueprintReleaseId);
588
+ const t = [], s = m.find((p) => p.id === e.blueprintReleaseId);
478
589
  e.blueprintReleaseId ? s ? s.blueprintId !== e.blueprintId && t.push({
479
590
  path: "/blueprintReleaseId",
480
591
  code: "release_of_other_blueprint",
@@ -492,118 +603,118 @@ function Ne(r = {}) {
492
603
  code: "no_element_selector",
493
604
  message: "It has no element selector."
494
605
  }), !e.sourceKey?.selector && !e.sourceKey?.template && t.push({ path: "/sourceKey", code: "no_source_key", message: "It has no Source Key." });
495
- const n = (o, a) => {
496
- typeof a == "string" && a !== "" && !Ee(a) && t.push({ path: o, code: "invalid_xpath", message: `"${a}" is not an XPath.` });
606
+ const i = (p, c) => {
607
+ typeof c == "string" && c !== "" && !Oe(c) && t.push({ path: p, code: "invalid_xpath", message: `"${c}" is not an XPath.` });
497
608
  };
498
- n("/element_selector", e.elementSelector), n("/source_key/selector", e.sourceKey?.selector);
499
- const i = [];
500
- return (e.fields ?? []).forEach((o, a) => {
501
- const m = `/fields/${a}`;
502
- for (const { path: d, rel: k, mapping: S } of se(o, "", m))
503
- i.push(d), n(`${k}/selector`, S.selector), s && !s.fieldPaths.includes(d) && t.push({
504
- path: m,
609
+ i("/element_selector", e.elementSelector), i("/source_key/selector", e.sourceKey?.selector);
610
+ const l = [];
611
+ return (e.fields ?? []).forEach((p, c) => {
612
+ const f = `/fields/${c}`;
613
+ for (const { path: u, rel: A, mapping: T } of ie(p, "", f))
614
+ l.push(u), i(`${A}/selector`, T.selector), s && !s.fieldPaths.includes(u) && t.push({
615
+ path: f,
505
616
  code: "unknown_field_path",
506
- message: `The pinned Release has no field ${d}.`
507
- }), S.type === "select" && !S.selectOptions && t.push({
508
- path: m,
617
+ message: `The pinned Release has no field ${u}.`
618
+ }), T.type === "select" && !T.selectOptions && t.push({
619
+ path: f,
509
620
  code: "xmlmapper_schema",
510
- message: `The select field ${d} has no select options.`
621
+ message: `The select field ${u} has no select options.`
511
622
  });
512
- }), (e.versionMatch?.contentFields ?? []).forEach((o, a) => {
513
- i.includes(o) || t.push({
514
- path: `/version_match/content_fields/${a}`,
623
+ }), (e.versionMatch?.contentFields ?? []).forEach((p, c) => {
624
+ l.includes(p) || t.push({
625
+ path: `/version_match/content_fields/${c}`,
515
626
  code: "unknown_version_match_field",
516
- message: `The Version Match compares ${o}, which the Mapping does not map.`
627
+ message: `The Version Match compares ${p}, which the Mapping does not map.`
517
628
  });
518
- }), (e.titleContributions ?? []).forEach((o, a) => {
519
- (!o.selector || !o.ausgabeCodeSelector) && t.push({
520
- path: `/title_contributions/${a}`,
629
+ }), (e.titleContributions ?? []).forEach((p, c) => {
630
+ (!p.selector || !p.ausgabeCodeSelector) && t.push({
631
+ path: `/title_contributions/${c}`,
521
632
  code: "incomplete_title_contribution",
522
633
  message: "A Title Contribution needs a selector and an Ausgabe code selector."
523
- }), n(`/title_contributions/${a}/selector`, o.selector);
524
- }), (e.placeholderAssets ?? []).forEach((o, a) => {
525
- (!o.selector || !o.assetType || !o.keyParts?.length || !o.nameSelector) && t.push({
526
- path: `/placeholder_assets/${a}`,
634
+ }), i(`/title_contributions/${c}/selector`, p.selector);
635
+ }), (e.placeholderAssets ?? []).forEach((p, c) => {
636
+ (!p.selector || !p.assetType || !p.keyParts?.length || !p.nameSelector) && t.push({
637
+ path: `/placeholder_assets/${c}`,
527
638
  code: "incomplete_placeholder_assets",
528
639
  message: "Placeholder Assets need a selector, an asset type, the key's parts and a name selector."
529
- }), n(`/placeholder_assets/${a}/selector`, o.selector), (o.keyParts ?? []).forEach((m, d) => {
530
- n(`/placeholder_assets/${a}/key_parts/${d}`, m);
640
+ }), i(`/placeholder_assets/${c}/selector`, p.selector), (p.keyParts ?? []).forEach((f, u) => {
641
+ i(`/placeholder_assets/${c}/key_parts/${u}`, f);
531
642
  });
532
- }), t;
643
+ }), t.push(...Fe(e, s?.fields, l)), t;
533
644
  }
534
645
  function re(e, t, s) {
535
- return e.flatMap((n, i) => {
536
- const o = `/${t}/${i}`, a = l.find((d) => d.name === n.processor);
537
- return a ? a.target !== "source_file" ? [
646
+ return e.flatMap((i, l) => {
647
+ const p = `/${t}/${l}`, c = o.find((u) => u.name === i.processor);
648
+ return c ? c.target !== "source_file" ? [
538
649
  {
539
- path: o,
650
+ path: p,
540
651
  code: "rich_text_processor",
541
- message: `${a.name} is configured on a rich-text field, not on a Profile.`
652
+ message: `${c.name} is configured on a rich-text field, not on a Profile.`
542
653
  }
543
- ] : a.kind !== s ? [{ path: o, code: "wrong_processor_kind", message: `${a.name} does not run here.` }] : a.settingsSpec.filter(
544
- (d) => d.config.required && (n.settings[d.config.api_accessor] ?? "") === ""
545
- ).map((d) => ({
546
- path: `${o}/settings/${d.config.api_accessor}`,
654
+ ] : c.kind !== s ? [{ path: p, code: "wrong_processor_kind", message: `${c.name} does not run here.` }] : c.settingsSpec.filter(
655
+ (u) => u.config.required && (i.settings[u.config.api_accessor] ?? "") === ""
656
+ ).map((u) => ({
657
+ path: `${p}/settings/${u.config.api_accessor}`,
547
658
  code: "invalid_processor_settings",
548
- message: `${a.name}: ${d.config.api_accessor} is required.`
659
+ message: `${c.name}: ${u.config.api_accessor} is required.`
549
660
  })) : [
550
- { path: o, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
661
+ { path: p, code: "unknown_processor", message: `No Processor is called ${i.processor}.` }
551
662
  ];
552
663
  });
553
664
  }
554
- function L(e) {
555
- const t = p(), s = [
665
+ function U(e) {
666
+ const t = r(), s = [
556
667
  ...re(e.preprocessors, "preprocessors", "preprocessor"),
557
668
  ...re(e.postProcessors, "postProcessors", "post_processor")
558
669
  ];
559
- return e.mappingIds.length === 0 && s.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((n, i) => {
560
- const o = t.mappings.find((m) => m.id === n);
561
- if (!o) {
670
+ return e.mappingIds.length === 0 && s.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((i, l) => {
671
+ const p = t.mappings.find((f) => f.id === i);
672
+ if (!p) {
562
673
  s.push({
563
- path: `/mappingIds/${i}`,
674
+ path: `/mappingIds/${l}`,
564
675
  code: "mapping_missing",
565
676
  message: "It includes a Mapping that does not exist."
566
677
  });
567
678
  return;
568
679
  }
569
- const a = J(o.content);
570
- a.length > 0 && s.push({
571
- path: `/mappingIds/${i}`,
680
+ const c = J(p.content);
681
+ c.length > 0 && s.push({
682
+ path: `/mappingIds/${l}`,
572
683
  code: "mapping_invalid",
573
- message: `The Mapping ${o.content.name} is invalid: ${a.map((m) => m.message).join(" ")}`
684
+ message: `The Mapping ${p.content.name} is invalid: ${c.map((f) => f.message).join(" ")}`
574
685
  });
575
- }), e.entitySetId && !t.entitySets.some((n) => n.id === e.entitySetId) && s.push({
686
+ }), e.entitySetId && !t.entitySets.some((i) => i.id === e.entitySetId) && s.push({
576
687
  path: "/entitySetId",
577
688
  code: "entity_set_missing",
578
689
  message: "It names an Entity Set that does not exist."
579
690
  }), s;
580
691
  }
581
- const ie = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], x = (e) => ({
692
+ const oe = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], K = (e) => ({
582
693
  id: e.id,
583
694
  content: e.content,
584
- validity: R(L(e.content)),
585
- state: Z(e)
586
- }), O = (e) => ({
695
+ validity: R(U(e.content)),
696
+ state: G(e)
697
+ }), z = (e) => ({
587
698
  id: e.id,
588
699
  content: e.content,
589
700
  validity: R(J(e.content)),
590
- state: Z(e)
591
- }), F = (e) => ({
701
+ state: G(e)
702
+ }), C = (e) => ({
592
703
  id: e.id,
593
704
  content: e.content,
594
- validity: R(ie(e.content)),
595
- state: Z(e)
596
- }), K = (e) => D(p().importProfiles.filter((t) => e(t.content))).map((t) => ({
705
+ validity: R(oe(e.content)),
706
+ state: G(e)
707
+ }), D = (e) => L(r().importProfiles.filter((t) => e(t.content))).map((t) => ({
597
708
  id: t.id,
598
709
  name: t.content.name
599
- })), H = (e) => `${e}_stub_new_${++fe}`, E = (e) => {
600
- const t = p();
710
+ })), X = (e) => `${e}_stub_new_${++he}`, N = (e) => {
711
+ const t = r();
601
712
  switch (e) {
602
713
  case "importProfile":
603
714
  return {
604
715
  items: t.importProfiles,
605
716
  name: "Import Profile",
606
- reasons: (s) => L(s)
717
+ reasons: (s) => U(s)
607
718
  };
608
719
  case "mapping":
609
720
  return {
@@ -615,31 +726,31 @@ function Ne(r = {}) {
615
726
  return {
616
727
  items: t.entitySets,
617
728
  name: "Entity Set",
618
- reasons: (s) => ie(s)
729
+ reasons: (s) => oe(s)
619
730
  };
620
731
  }
621
- }, I = (e, t) => {
622
- A(t).validity = R(E(e).reasons(t.content));
623
- }, U = (e, t) => {
624
- const s = e.revisions.find((n) => n.id === t);
732
+ }, P = (e, t) => {
733
+ F(t).validity = R(N(e).reasons(t.content));
734
+ }, V = (e, t) => {
735
+ const s = e.revisions.find((i) => i.id === t);
625
736
  if (!s) throw new Error(`Revision ${t} not found`);
626
737
  return s;
627
- }, oe = /* @__PURE__ */ new Set(), ae = r.contenthubRights ?? ["editor", "publisher"], z = (e) => {
628
- const t = p().imports.find((s) => s.id === e);
738
+ }, ae = /* @__PURE__ */ new Set(), le = n.contenthubRights ?? ["editor", "publisher"], Z = (e) => {
739
+ const t = r().imports.find((s) => s.id === e);
629
740
  if (!t) throw new Error(`Import ${e} not found`);
630
741
  return t;
631
- }, W = (e) => {
632
- e.cancelledBy && e.phase !== "ended" && (e.phase = "ended", e.outcome = "cancelled", e.endTime = P());
633
- }, C = ({ itemProblems: e, ...t }) => t, V = (e, t) => {
634
- const s = he(e);
742
+ }, Y = (e) => {
743
+ e.cancelledBy && e.phase !== "ended" && (e.phase = "ended", e.outcome = "cancelled", e.endTime = $());
744
+ }, j = ({ itemProblems: e, ...t }) => t, W = (e, t) => {
745
+ const s = be(e);
635
746
  if (!s)
636
- throw new M(`the ${t} ${e.content.name} has no Release yet`);
637
- const n = e.revisions.find((i) => i.id === s.revisionId)?.content ?? e.content;
747
+ throw new B(`the ${t} ${e.content.name} has no Release yet`);
748
+ const i = e.revisions.find((l) => l.id === s.revisionId)?.content ?? e.content;
638
749
  return {
639
- content: n,
750
+ content: i,
640
751
  ref: {
641
752
  configurationId: e.id,
642
- name: n.name,
753
+ name: i.name,
643
754
  releaseId: s.id,
644
755
  number: s.number
645
756
  }
@@ -648,171 +759,180 @@ function Ne(r = {}) {
648
759
  return {
649
760
  calls: y,
650
761
  switchWorkspace(e) {
651
- b = e;
762
+ g = e;
652
763
  },
653
764
  updateImport(e, t) {
654
- Object.assign(z(e), structuredClone(t));
765
+ Object.assign(Z(e), structuredClone(t));
655
766
  },
656
- listImportProfiles: () => f("listImportProfiles", () => D(p().importProfiles).map(x)),
657
- getImportProfile: (e) => f("getImportProfile", () => x(g(p().importProfiles, e, "Import Profile"))),
658
- createImportProfile: (e) => f("createImportProfile", () => {
659
- v(p().importProfiles, e.name);
660
- const t = G("ip", e);
661
- return I("importProfile", t), p().importProfiles.push(t), x(t);
767
+ listImportProfiles: () => d("listImportProfiles", () => L(r().importProfiles).map(K)),
768
+ getImportProfile: (e) => d("getImportProfile", () => K(h(r().importProfiles, e, "Import Profile"))),
769
+ createImportProfile: (e) => d("createImportProfile", () => {
770
+ _(r().importProfiles, e.name);
771
+ const t = k("ip", e);
772
+ return P("importProfile", t), r().importProfiles.push(t), K(t);
662
773
  }),
663
- updateImportProfile: (e, t, s) => f("updateImportProfile", () => {
664
- const n = g(p().importProfiles, e, "Import Profile");
665
- return v(p().importProfiles, t.name, e), N(n, t, s), I("importProfile", n), x(n);
774
+ updateImportProfile: (e, t, s) => d("updateImportProfile", () => {
775
+ const i = h(r().importProfiles, e, "Import Profile");
776
+ return _(r().importProfiles, t.name, e), I(i, t, s), P("importProfile", i), K(i);
666
777
  }),
667
- deleteImportProfile: (e) => f("deleteImportProfile", () => {
668
- g(p().importProfiles, e, "Import Profile"), p().importProfiles = p().importProfiles.filter((t) => t.id !== e);
778
+ deleteImportProfile: (e) => d("deleteImportProfile", () => {
779
+ h(r().importProfiles, e, "Import Profile"), r().importProfiles = r().importProfiles.filter((t) => t.id !== e);
669
780
  }),
670
- listProcessors: () => f("listProcessors", () => [...l].sort((e, t) => e.name.localeCompare(t.name))),
671
- listMappings: () => f("listMappings", () => D(p().mappings).map(O)),
672
- getMapping: (e) => f("getMapping", () => O(g(p().mappings, e, "Mapping"))),
673
- createMapping: (e) => f("createMapping", () => {
674
- v(p().mappings, e.name);
675
- const t = G("mp", e);
676
- return I("mapping", t), p().mappings.push(t), O(t);
781
+ listProcessors: () => d("listProcessors", () => [...o].sort((e, t) => e.name.localeCompare(t.name))),
782
+ listMappings: () => d("listMappings", () => L(r().mappings).map(z)),
783
+ getMapping: (e) => d("getMapping", () => z(h(r().mappings, e, "Mapping"))),
784
+ createMapping: (e) => d("createMapping", () => {
785
+ _(r().mappings, e.name);
786
+ const t = k("mp", e);
787
+ return P("mapping", t), r().mappings.push(t), z(t);
677
788
  }),
678
- updateMapping: (e, t, s) => f("updateMapping", () => {
679
- const n = g(p().mappings, e, "Mapping");
680
- return v(p().mappings, t.name, e), N(n, t, s), I("mapping", n), O(n);
789
+ updateMapping: (e, t, s) => d("updateMapping", () => {
790
+ const i = h(r().mappings, e, "Mapping");
791
+ return _(r().mappings, t.name, e), I(i, t, s), P("mapping", i), z(i);
681
792
  }),
682
- deleteMapping: (e) => f("deleteMapping", () => {
683
- g(p().mappings, e, "Mapping");
684
- const t = K((s) => s.mappingIds.includes(e));
793
+ deleteMapping: (e) => d("deleteMapping", () => {
794
+ h(r().mappings, e, "Mapping");
795
+ const t = D((s) => s.mappingIds.includes(e));
685
796
  if (t.length > 0)
686
- throw new le(
797
+ throw new ce(
687
798
  t,
688
799
  `the Mapping is included by ${t.map((s) => s.name).join(", ")}`
689
800
  );
690
- p().mappings = p().mappings.filter((s) => s.id !== e);
801
+ r().mappings = r().mappings.filter((s) => s.id !== e);
691
802
  }),
692
- listMappingImportProfiles: (e) => f("listMappingImportProfiles", () => (g(p().mappings, e, "Mapping"), K((t) => t.mappingIds.includes(e)))),
693
- checkMappingBlueprintRelease: (e, t) => f("checkMappingBlueprintRelease", () => {
694
- const s = g(p().mappings, e, "Mapping"), n = u.find((i) => i.id === t);
695
- if (!n) throw new Error(`Blueprint Release ${t} not found`);
696
- if (n.blueprintId !== s.content.blueprintId)
803
+ listMappingImportProfiles: (e) => d("listMappingImportProfiles", () => (h(r().mappings, e, "Mapping"), D((t) => t.mappingIds.includes(e)))),
804
+ checkMappingBlueprintRelease: (e, t) => d("checkMappingBlueprintRelease", () => {
805
+ const s = h(r().mappings, e, "Mapping"), i = m.find((l) => l.id === t);
806
+ if (!i) throw new Error(`Blueprint Release ${t} not found`);
807
+ if (i.blueprintId !== s.content.blueprintId)
697
808
  throw new Error("the Release is of another Blueprint");
698
809
  return {
699
- blueprintId: n.blueprintId,
700
- missingFieldPaths: (s.content.fields ?? []).flatMap((i, o) => se(i, "", `/fields/${o}`).map((a) => a.path)).filter((i) => !n.fieldPaths.includes(i)),
810
+ blueprintId: i.blueprintId,
811
+ missingFieldPaths: (s.content.fields ?? []).flatMap((l, p) => ie(l, "", `/fields/${p}`).map((c) => c.path)).filter((l) => !i.fieldPaths.includes(l)),
701
812
  missingReleaseSpecFields: [
702
- ...(s.content.releaseSpec ?? []).map((i) => i.field ?? ""),
813
+ ...(s.content.releaseSpec ?? []).map((l) => l.field ?? ""),
703
814
  ...s.content.versionMatch?.releaseSpecFields ?? []
704
815
  ].filter(
705
- (i, o, a) => i !== "" && a.indexOf(i) === o && !(n.releaseSpecFields ?? []).some((m) => m.path === i)
816
+ (l, p, c) => l !== "" && c.indexOf(l) === p && !(i.releaseSpecFields ?? []).some((f) => f.path === l)
706
817
  )
707
818
  };
708
819
  }),
709
- listEntitySets: () => f("listEntitySets", () => D(p().entitySets).map(F)),
710
- getEntitySet: (e) => f("getEntitySet", () => F(g(p().entitySets, e, "Entity Set"))),
711
- createEntitySet: (e) => f("createEntitySet", () => {
712
- v(p().entitySets, e.name);
713
- const t = G("es", e);
714
- return I("entitySet", t), p().entitySets.push(t), F(t);
820
+ runMappingTest: ({ content: e, sample: t, entitySetId: s }) => d("runMappingTest", () => {
821
+ let i = new TextDecoder().decode(t);
822
+ if (s) {
823
+ const l = r().entitySets.find((p) => p.id === s);
824
+ if (!l) throw new O(`Entity Set ${s} not found`);
825
+ i = Ne(i, l.content.entities);
826
+ }
827
+ return Ae(e, i);
828
+ }),
829
+ listEntitySets: () => d("listEntitySets", () => L(r().entitySets).map(C)),
830
+ getEntitySet: (e) => d("getEntitySet", () => C(h(r().entitySets, e, "Entity Set"))),
831
+ createEntitySet: (e) => d("createEntitySet", () => {
832
+ _(r().entitySets, e.name);
833
+ const t = k("es", e);
834
+ return P("entitySet", t), r().entitySets.push(t), C(t);
715
835
  }),
716
- updateEntitySet: (e, t, s) => f("updateEntitySet", () => {
717
- const n = g(p().entitySets, e, "Entity Set");
718
- return v(p().entitySets, t.name, e), N(n, t, s), I("entitySet", n), F(n);
836
+ updateEntitySet: (e, t, s) => d("updateEntitySet", () => {
837
+ const i = h(r().entitySets, e, "Entity Set");
838
+ return _(r().entitySets, t.name, e), I(i, t, s), P("entitySet", i), C(i);
719
839
  }),
720
- deleteEntitySet: (e) => f("deleteEntitySet", () => {
721
- g(p().entitySets, e, "Entity Set");
722
- const t = K((s) => s.entitySetId === e);
840
+ deleteEntitySet: (e) => d("deleteEntitySet", () => {
841
+ h(r().entitySets, e, "Entity Set");
842
+ const t = D((s) => s.entitySetId === e);
723
843
  if (t.length > 0)
724
- throw new le(
844
+ throw new ce(
725
845
  t,
726
846
  `the Entity Set is named by ${t.map((s) => s.name).join(", ")}`
727
847
  );
728
- p().entitySets = p().entitySets.filter((s) => s.id !== e);
848
+ r().entitySets = r().entitySets.filter((s) => s.id !== e);
729
849
  }),
730
- cutRelease: (e, t, s) => f("cutRelease", () => {
731
- const n = E(e), i = g(n.items, t, n.name);
732
- if (ne(i, s))
733
- throw new Q("the draft moved: somebody saved in between");
734
- const o = R(n.reasons(i.content));
735
- if (!o.valid) throw new Q("the draft is invalid", o);
736
- if (!Z(i).draftDiffersFromRelease)
737
- throw new Q(
850
+ cutRelease: (e, t, s) => d("cutRelease", () => {
851
+ const i = N(e), l = h(i.items, t, i.name);
852
+ if (w(l, s))
853
+ throw new ee("the draft moved: somebody saved in between");
854
+ const p = R(i.reasons(l.content));
855
+ if (!p.valid) throw new ee("the draft is invalid", p);
856
+ if (!G(l).draftDiffersFromRelease)
857
+ throw new ee(
738
858
  "the draft does not differ from the latest Release: there is nothing to release"
739
859
  );
740
- const a = i.releases.length + 1, m = {
741
- id: `${i.id}_rel${a}`,
742
- number: a,
743
- revisionId: A(i).id,
744
- releasedBy: h,
745
- releasedAt: P()
860
+ const c = l.releases.length + 1, f = {
861
+ id: `${l.id}_rel${c}`,
862
+ number: c,
863
+ revisionId: F(l).id,
864
+ releasedBy: b,
865
+ releasedAt: $()
746
866
  };
747
- return i.releases.push(m), {
748
- release: m,
749
- importProfiles: e === "mapping" ? K((d) => d.mappingIds.includes(t)) : []
867
+ return l.releases.push(f), {
868
+ release: f,
869
+ importProfiles: e === "mapping" ? D((u) => u.mappingIds.includes(t)) : []
750
870
  };
751
871
  }),
752
- listHistory: (e, t, s) => f("listHistory", () => {
753
- const n = E(e), i = g(n.items, t, n.name), o = [...i.revisions].reverse(), a = Number(s || "0");
872
+ listHistory: (e, t, s) => d("listHistory", () => {
873
+ const i = N(e), l = h(i.items, t, i.name), p = [...l.revisions].reverse(), c = Number(s || "0");
754
874
  return {
755
- revisions: o.slice(a, a + 10).map((d) => ({
756
- id: d.id,
757
- savedBy: d.savedBy,
758
- savedAt: d.savedAt,
759
- validity: d.validity ?? R(n.reasons(d.content)),
760
- restoredFromRevisionId: d.restoredFromRevisionId
875
+ revisions: p.slice(c, c + 10).map((u) => ({
876
+ id: u.id,
877
+ savedBy: u.savedBy,
878
+ savedAt: u.savedAt,
879
+ validity: u.validity ?? R(i.reasons(u.content)),
880
+ restoredFromRevisionId: u.restoredFromRevisionId
761
881
  })),
762
- releases: [...i.releases].reverse(),
763
- nextPageToken: a + 10 < o.length ? String(a + 10) : ""
882
+ releases: [...l.releases].reverse(),
883
+ nextPageToken: c + 10 < p.length ? String(c + 10) : ""
764
884
  };
765
885
  }),
766
- compareRevisions: (e, t, s, n) => f("compareRevisions", () => {
767
- const i = E(e), o = g(i.items, t, i.name), a = ue(U(o, s).content), m = ue(U(o, n).content), d = [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(m)])].map((k) => {
768
- const S = a[k], Y = m[k], be = S === void 0 && Y !== void 0 ? "added" : S !== void 0 && Y === void 0 ? "removed" : JSON.stringify(S) === JSON.stringify(Y) ? "unchanged" : "changed";
769
- return { field: k, status: be };
886
+ compareRevisions: (e, t, s, i) => d("compareRevisions", () => {
887
+ const l = N(e), p = h(l.items, t, l.name), c = fe(V(p, s).content), f = fe(V(p, i).content), u = [.../* @__PURE__ */ new Set([...Object.keys(c), ...Object.keys(f)])].map((A) => {
888
+ const T = c[A], Q = f[A], Ie = T === void 0 && Q !== void 0 ? "added" : T !== void 0 && Q === void 0 ? "removed" : JSON.stringify(T) === JSON.stringify(Q) ? "unchanged" : "changed";
889
+ return { field: A, status: Ie };
770
890
  });
771
891
  return {
772
- from: { revisionId: s, content: a },
773
- to: { revisionId: n, content: m },
774
- fields: d
892
+ from: { revisionId: s, content: c },
893
+ to: { revisionId: i, content: f },
894
+ fields: u
775
895
  };
776
896
  }),
777
- restoreRevision: (e, t, s, n) => f("restoreRevision", () => {
778
- const i = E(e), o = g(i.items, t, i.name);
779
- N(o, U(o, s).content, n, s), I(e, o);
897
+ restoreRevision: (e, t, s, i) => d("restoreRevision", () => {
898
+ const l = N(e), p = h(l.items, t, l.name);
899
+ I(p, V(p, s).content, i, s), P(e, p);
780
900
  }),
781
901
  async uploadSourceFile(e, t) {
782
- if (y.uploadSourceFile++, r.fail) throw r.fail;
783
- for (const n of [0.25, 0.5, 0.75])
784
- await new Promise((i) => setTimeout(i, 20)), t(n);
785
- if (r.uploadFails) throw r.uploadFails;
902
+ if (y.uploadSourceFile++, n.fail) throw n.fail;
903
+ for (const i of [0.25, 0.5, 0.75])
904
+ await new Promise((l) => setTimeout(l, 20)), t(i);
905
+ if (n.uploadFails) throw n.uploadFails;
786
906
  t(1);
787
- const s = H("sf");
788
- return oe.add(s), { id: s, fileName: e.name };
907
+ const s = X("sf");
908
+ return ae.add(s), { id: s, fileName: e.name };
789
909
  },
790
- startImport: (e) => f("startImport", () => {
791
- const t = p(), s = g(t.importProfiles, e.importProfileId, "Import Profile");
792
- if (!oe.has(e.sourceFileId))
793
- throw new M("nothing was uploaded to the Source File");
794
- if (!ae.includes("editor"))
795
- throw new M(
910
+ startImport: (e) => d("startImport", () => {
911
+ const t = r(), s = h(t.importProfiles, e.importProfileId, "Import Profile");
912
+ if (!ae.has(e.sourceFileId))
913
+ throw new B("nothing was uploaded to the Source File");
914
+ if (!le.includes("editor"))
915
+ throw new B(
796
916
  "starting an Import needs contenthub editor in the workspace"
797
917
  );
798
- const n = V(s, "Import Profile");
799
- if (n.content.autoPublish && !ae.includes("publisher"))
800
- throw new M(
918
+ const i = W(s, "Import Profile");
919
+ if (i.content.autoPublish && !le.includes("publisher"))
920
+ throw new B(
801
921
  "the Import Profile has Auto-publish, which needs contenthub publisher"
802
922
  );
803
- const i = L(n.content);
804
- if (i.length > 0)
805
- throw new M(
806
- `the Import Profile ${n.ref.name} is invalid: ${i.map((d) => d.message).join(" ")}`
923
+ const l = U(i.content);
924
+ if (l.length > 0)
925
+ throw new B(
926
+ `the Import Profile ${i.ref.name} is invalid: ${l.map((u) => u.message).join(" ")}`
807
927
  );
808
- const o = n.content.mappingIds.map(
809
- (d) => V(g(t.mappings, d, "Mapping"), "Mapping").ref
810
- ), a = n.content.entitySetId ? V(g(t.entitySets, n.content.entitySetId, "Entity Set"), "Entity Set").ref : void 0, m = {
811
- id: H("im"),
928
+ const p = i.content.mappingIds.map(
929
+ (u) => W(h(t.mappings, u, "Mapping"), "Mapping").ref
930
+ ), c = i.content.entitySetId ? W(h(t.entitySets, i.content.entitySetId, "Entity Set"), "Entity Set").ref : void 0, f = {
931
+ id: X("im"),
812
932
  importProfileId: s.id,
813
- importProfileName: n.ref.name,
933
+ importProfileName: i.ref.name,
814
934
  sourceFileId: e.sourceFileId,
815
- startedBy: h,
935
+ startedBy: b,
816
936
  phase: "queued",
817
937
  failureReason: "",
818
938
  progress: { done: 0, total: 0 },
@@ -827,11 +947,11 @@ function Ne(r = {}) {
827
947
  },
828
948
  changeSetId: "",
829
949
  releases: {
830
- importProfile: n.ref,
831
- mappings: o,
832
- ...a ? { entitySet: a } : {}
950
+ importProfile: i.ref,
951
+ mappings: p,
952
+ ...c ? { entitySet: c } : {}
833
953
  },
834
- createTime: P(),
954
+ createTime: $(),
835
955
  startTime: "",
836
956
  endTime: "",
837
957
  cancelledBy: "",
@@ -839,132 +959,166 @@ function Ne(r = {}) {
839
959
  ...e.source ? { source: e.source } : {},
840
960
  itemProblems: []
841
961
  };
842
- return t.imports.unshift(m), C(m);
962
+ return t.imports.unshift(f), j(f);
843
963
  }),
844
- listImports: (e) => f("listImports", () => {
845
- const t = p().imports;
846
- t.forEach(W);
964
+ listImports: (e) => d("listImports", () => {
965
+ const t = r().imports;
966
+ t.forEach(Y);
847
967
  const s = Number(e || "0");
848
968
  return {
849
- imports: t.slice(s, s + 50).map(C),
969
+ imports: t.slice(s, s + 50).map(j),
850
970
  nextPageToken: s + 50 < t.length ? String(s + 50) : ""
851
971
  };
852
972
  }),
853
- getImport: (e) => f("getImport", () => {
854
- const t = z(e);
855
- return W(t), C(t);
973
+ getImport: (e) => d("getImport", () => {
974
+ const t = Z(e);
975
+ return Y(t), j(t);
856
976
  }),
857
- cancelImport: (e) => f("cancelImport", () => {
858
- const t = z(e);
977
+ cancelImport: (e) => d("cancelImport", () => {
978
+ const t = Z(e);
859
979
  if (t.phase === "ended") throw new Error("the Import has ended");
860
- return t.cancelledBy ||= h, t.phase === "queued" && W(t), C(t);
980
+ return t.cancelledBy ||= b, t.phase === "queued" && Y(t), j(t);
861
981
  }),
862
- listItemProblems: (e, t) => f("listItemProblems", () => {
863
- const s = z(e).itemProblems ?? [], n = t.sourceKeyQuery.toLowerCase(), i = s.filter(
864
- (m) => (!t.mappingId || m.mappingId === t.mappingId) && m.sourceKey.toLowerCase().includes(n)
865
- ), o = /* @__PURE__ */ new Map();
866
- for (const m of s) {
867
- const d = o.get(m.mappingId) ?? {
868
- mappingId: m.mappingId,
869
- mappingName: m.mappingName,
982
+ listItemProblems: (e, t) => d("listItemProblems", () => {
983
+ const s = Z(e).itemProblems ?? [], i = t.sourceKeyQuery.toLowerCase(), l = s.filter(
984
+ (f) => (!t.mappingId || f.mappingId === t.mappingId) && f.sourceKey.toLowerCase().includes(i)
985
+ ), p = /* @__PURE__ */ new Map();
986
+ for (const f of s) {
987
+ const u = p.get(f.mappingId) ?? {
988
+ mappingId: f.mappingId,
989
+ mappingName: f.mappingName,
870
990
  count: 0
871
991
  };
872
- d.count++, o.set(m.mappingId, d);
992
+ u.count++, p.set(f.mappingId, u);
873
993
  }
874
- const a = Number(t.pageToken || "0");
994
+ const c = Number(t.pageToken || "0");
875
995
  return {
876
- itemProblems: i.slice(a, a + 50),
996
+ itemProblems: l.slice(c, c + 50),
877
997
  totalCount: s.length,
878
- matchingCount: i.length,
879
- mappings: [...o.values()].sort((m, d) => m.mappingName.localeCompare(d.mappingName)),
880
- nextPageToken: a + 50 < i.length ? String(a + 50) : ""
998
+ matchingCount: l.length,
999
+ mappings: [...p.values()].sort((f, u) => f.mappingName.localeCompare(u.mappingName)),
1000
+ nextPageToken: c + 50 < l.length ? String(c + 50) : ""
881
1001
  };
882
1002
  }),
883
- listApiKeys: () => f("listApiKeys", () => p().apiKeys),
884
- createApiKey: (e) => f("createApiKey", () => {
1003
+ listApiKeys: () => d("listApiKeys", () => r().apiKeys),
1004
+ createApiKey: (e) => d("createApiKey", () => {
885
1005
  const t = e.name.trim();
886
1006
  if (!t) throw new Error("a name is required");
887
- if (t.length > ce)
888
- throw new Error(`the name is longer than ${ce} characters`);
1007
+ if (t.length > pe)
1008
+ throw new Error(`the name is longer than ${pe} characters`);
889
1009
  const s = e.expireTime ? new Date(e.expireTime).toISOString() : "";
890
1010
  if (s && Date.parse(s) <= Date.now())
891
1011
  throw new Error("the expiry must lie in the future");
892
- const n = ++fe, i = {
893
- id: `key_stub_new_${n}`,
1012
+ const i = ++he, l = {
1013
+ id: `key_stub_new_${i}`,
894
1014
  name: t,
895
- keyPrefix: `ihk_n${String(n).padStart(3, "0")}`,
896
- owner: h,
1015
+ keyPrefix: `ihk_n${String(i).padStart(3, "0")}`,
1016
+ owner: b,
897
1017
  expireTime: s,
898
1018
  createTime: (/* @__PURE__ */ new Date()).toISOString()
899
1019
  };
900
- return p().apiKeys.unshift(i), { apiKey: i, secret: `${i.keyPrefix}_stub_secret_${n}` };
1020
+ return r().apiKeys.unshift(l), { apiKey: l, secret: `${l.keyPrefix}_stub_secret_${i}` };
901
1021
  }),
902
- revokeApiKey: (e) => f("revokeApiKey", () => {
903
- const t = p();
1022
+ revokeApiKey: (e) => d("revokeApiKey", () => {
1023
+ const t = r();
904
1024
  if (!t.apiKeys.some((s) => s.id === e)) throw new Error(`API key ${e} not found`);
905
1025
  t.apiKeys = t.apiKeys.filter((s) => s.id !== e);
906
1026
  })
907
1027
  };
908
1028
  }
909
- function Ee(r) {
910
- const c = [], l = { "]": "[", ")": "(" };
911
- for (const u of r)
912
- if (u === "[" || u === "(") c.push(u);
913
- else if (u in l && c.pop() !== l[u]) return !1;
914
- return c.length === 0;
1029
+ function Oe(n) {
1030
+ const a = [], o = { "]": "[", ")": "(" };
1031
+ for (const m of n)
1032
+ if (m === "[" || m === "(") a.push(m);
1033
+ else if (m in o && a.pop() !== o[m]) return !1;
1034
+ return a.length === 0;
915
1035
  }
916
- function se(r, c, l) {
917
- const u = `${c}${String(r.name ?? "")}`;
1036
+ function ie(n, a, o) {
1037
+ const m = `${a}${String(n.name ?? "")}`;
918
1038
  return [
919
- { path: u, rel: l, mapping: r },
1039
+ { path: m, rel: o, mapping: n },
920
1040
  ...["fields", "virtualTableFields"].flatMap(
921
- (b) => (Array.isArray(r[b]) ? r[b] : []).flatMap(
922
- (y, p) => se(y, `${u}.`, `${l}/${b}/${p}`)
1041
+ (g) => (Array.isArray(n[g]) ? n[g] : []).flatMap(
1042
+ (y, r) => ie(y, `${m}.`, `${o}/${g}/${r}`)
923
1043
  )
924
1044
  )
925
1045
  ];
926
1046
  }
927
- function xe(r = ge()) {
1047
+ function Le(n = ge()) {
928
1048
  return {
929
1049
  async listBlueprints() {
930
- return [...new Map(r.map((l) => [l.blueprintId, l.blueprintName]))].map(([l, u]) => ({ id: l, name: u })).sort((l, u) => l.name.localeCompare(u.name));
1050
+ return [...new Map(n.map((o) => [o.blueprintId, o.blueprintName]))].map(([o, m]) => ({ id: o, name: m })).sort((o, m) => o.name.localeCompare(m.name));
931
1051
  },
932
- async listReleases(c) {
933
- return r.filter((l) => l.blueprintId === c).map((l) => ({ id: l.id, label: l.label }));
1052
+ async listReleases(a) {
1053
+ return n.filter((o) => o.blueprintId === a).map((o) => ({ id: o.id, label: o.label }));
934
1054
  },
935
- async getRelease(c) {
936
- const l = r.find((u) => u.id === c);
937
- if (!l) throw new Error(`Blueprint Release ${c} not found`);
1055
+ async getRelease(a) {
1056
+ const o = n.find((m) => m.id === a);
1057
+ if (!o) throw new Error(`Blueprint Release ${a} not found`);
938
1058
  return {
939
- id: l.id,
940
- blueprintId: l.blueprintId,
941
- name: l.label,
942
- fields: l.fields ?? l.fieldPaths.map((u) => ({
943
- accessor: u,
944
- path: u,
1059
+ id: o.id,
1060
+ blueprintId: o.blueprintId,
1061
+ name: o.label,
1062
+ fields: o.fields ?? o.fieldPaths.map((m) => ({
1063
+ accessor: m,
1064
+ path: m,
945
1065
  fieldType: "text",
946
1066
  label: "",
947
1067
  children: []
948
1068
  })),
949
- releaseSpecFields: l.releaseSpecFields ?? []
1069
+ releaseSpecFields: o.releaseSpecFields ?? []
950
1070
  };
951
1071
  }
952
1072
  };
953
1073
  }
1074
+ function Fe(n, a, o) {
1075
+ const m = (n.displayNameTemplate ?? "").trim(), g = (n.displayNameField ?? "").trim(), y = (d, h, _) => [
1076
+ { path: d, code: h, message: _ }
1077
+ ];
1078
+ if (!m && !g) return [];
1079
+ if (!g)
1080
+ return y(
1081
+ "/display_name_field",
1082
+ "incomplete_display_name",
1083
+ "the display-name template names no field to write the display name into"
1084
+ );
1085
+ if (!m)
1086
+ return y(
1087
+ "/display_name_template",
1088
+ "incomplete_display_name",
1089
+ `the display-name field "${g}" has no display-name template to fill it`
1090
+ );
1091
+ if (!a) return [];
1092
+ const r = (d) => d.flatMap((h) => [h.path, ...r(h.children)]);
1093
+ return r(a).includes(g) ? Pe(a).some((d) => d.path === g) ? o.includes(g) ? y(
1094
+ "/display_name_field",
1095
+ "display_name_field_mapped",
1096
+ `the field "${g}" is mapped too: it takes the display name or a mapped value, not both`
1097
+ ) : [] : y(
1098
+ "/display_name_field",
1099
+ "display_name_field_not_plain_text",
1100
+ `the display-name field "${g}" is not a plain-text one (text or textarea)`
1101
+ ) : y(
1102
+ "/display_name_field",
1103
+ "unknown_display_name_field",
1104
+ `the Blueprint Release has no field "${g}" to write the display name into`
1105
+ );
1106
+ }
954
1107
  export {
955
- q as STUB_OTHER_USER_ID,
956
- Be as STUB_OTHER_WORKSPACE_ID,
957
- h as STUB_USER_ID,
958
- te as STUB_WORKSPACE_ID,
959
- xe as createStubBlueprints,
960
- Ne as createStubImporthubClient,
961
- Te as stubApiKeys,
1108
+ H as STUB_OTHER_USER_ID,
1109
+ De as STUB_OTHER_WORKSPACE_ID,
1110
+ b as STUB_USER_ID,
1111
+ ne as STUB_WORKSPACE_ID,
1112
+ Le as createStubBlueprints,
1113
+ Ge as createStubImporthubClient,
1114
+ Me as stubApiKeys,
962
1115
  ge as stubBlueprintReleases,
963
- Se as stubEntitySets,
964
- Ae as stubIdentity,
965
- we as stubImportProfiles,
966
- ve as stubImports,
967
- Ie as stubMappings,
968
- Pe as stubProcessors
1116
+ ve as stubEntitySets,
1117
+ Ze as stubIdentity,
1118
+ $e as stubImportProfiles,
1119
+ Re as stubImports,
1120
+ je as stubMappingTestSample,
1121
+ Te as stubMappings,
1122
+ Ee as stubProcessors
969
1123
  };
970
1124
  //# sourceMappingURL=testing.js.map