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