@knkcs/importhub-ui 0.7.0 → 0.8.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 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) {
5
6
  return {
6
- userId: h,
7
- workspaceId: r,
8
- members: _e([
9
- { userId: h, displayName: "Ada Importer", email: "ada@example.com" },
7
+ userId: b,
8
+ workspaceId: i,
9
+ members: be([
10
+ { userId: b, displayName: "Ada Importer", email: "ada@example.com" },
10
11
  { userId: q, 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,
15
+ const y = (i, o, c, u = []) => ({
16
+ accessor: i.split(".").pop() ?? i,
17
+ path: i,
18
+ fieldType: o,
19
+ label: c,
19
20
  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")
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")
27
29
  ])
28
30
  ], de = () => [
29
- _("fundstelle", "text", "Fundstelle"),
30
- _("ausgabedatum", "date", "Ausgabedatum")
31
+ y("fundstelle", "text", "Fundstelle"),
32
+ y("ausgabedatum", "date", "Ausgabedatum")
31
33
  ];
32
- function ge() {
33
- const r = pe(!1), c = pe(!0), l = [
34
- _("aktenzeichen", "text", "Aktenzeichen"),
35
- _("datum", "date", "Datum")
34
+ function he() {
35
+ const i = ce(!1), o = ce(!0), c = [
36
+ y("aktenzeichen", "text", "Aktenzeichen"),
37
+ y("datum", "date", "Datum")
36
38
  ];
37
39
  return [
38
40
  {
@@ -40,8 +42,8 @@ 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
+ fieldPaths: j(i),
46
+ fields: i,
45
47
  releaseSpecFields: de()
46
48
  },
47
49
  {
@@ -49,8 +51,8 @@ function ge() {
49
51
  blueprintId: "bp_stub_gesetz",
50
52
  blueprintName: "Gesetz",
51
53
  label: "Release 1",
52
- fieldPaths: j(c),
53
- fields: c,
54
+ fieldPaths: j(o),
55
+ fields: o,
54
56
  releaseSpecFields: de()
55
57
  },
56
58
  {
@@ -58,12 +60,12 @@ function ge() {
58
60
  blueprintId: "bp_stub_entscheidung",
59
61
  blueprintName: "Entscheidung",
60
62
  label: "Release 1",
61
- fieldPaths: j(l),
62
- fields: l
63
+ fieldPaths: j(c),
64
+ fields: c
63
65
  }
64
66
  ];
65
67
  }
66
- function Ie() {
68
+ function Se() {
67
69
  return [
68
70
  {
69
71
  id: "mp_stub_norm",
@@ -95,7 +97,7 @@ function Ie() {
95
97
  }
96
98
  ];
97
99
  }
98
- function Se() {
100
+ function we() {
99
101
  return [
100
102
  {
101
103
  id: "es_stub_latin1",
@@ -108,7 +110,7 @@ function Se() {
108
110
  }
109
111
  ];
110
112
  }
111
- function we() {
113
+ function Pe() {
112
114
  return [
113
115
  {
114
116
  id: "ip_stub_gesetz",
@@ -139,12 +141,12 @@ function we() {
139
141
  }
140
142
  ];
141
143
  }
142
- const X = (r, c, l, u = "") => ({
144
+ const X = (i, o, c, u = "") => ({
143
145
  field_type: "text",
144
- config: { name: c, api_accessor: r, required: l, instructions: u },
146
+ config: { name: o, api_accessor: i, required: c, instructions: u },
145
147
  system: !1
146
148
  });
147
- function Pe() {
149
+ function ve() {
148
150
  return [
149
151
  {
150
152
  name: "citation-links",
@@ -179,7 +181,7 @@ function Pe() {
179
181
  }
180
182
  ];
181
183
  }
182
- const $ = (r = {}) => ({
184
+ const R = (i = {}) => ({
183
185
  matched: 0,
184
186
  created: 0,
185
187
  problems: 0,
@@ -187,13 +189,13 @@ const $ = (r = {}) => ({
187
189
  corrected: 0,
188
190
  kept: 0,
189
191
  unchanged: 0,
190
- ...r
191
- }), w = (r) => ({
192
+ ...i
193
+ }), P = (i) => ({
192
194
  importProfile: {
193
195
  configurationId: "ip_stub_gesetz",
194
196
  name: "Boorberg gesetz",
195
- releaseId: `ip_stub_gesetz_rel${r}`,
196
- number: r
197
+ releaseId: `ip_stub_gesetz_rel${i}`,
198
+ number: i
197
199
  },
198
200
  mappings: [
199
201
  {
@@ -209,38 +211,38 @@ const $ = (r = {}) => ({
209
211
  releaseId: "es_stub_latin1_rel1",
210
212
  number: 1
211
213
  }
212
- }), T = (r) => ({
214
+ }), T = (i) => ({
213
215
  importProfileId: "ip_stub_gesetz",
214
216
  importProfileName: "Boorberg gesetz",
215
- sourceFileId: `sf_${r.id}`,
216
- startedBy: h,
217
+ sourceFileId: `sf_${i.id}`,
218
+ startedBy: b,
217
219
  phase: "ended",
218
220
  failureReason: "",
219
221
  progress: { done: 0, total: 0 },
220
- counts: $(),
222
+ counts: R(),
221
223
  changeSetId: "",
222
- releases: w(2),
224
+ releases: P(2),
223
225
  createTime: "2026-11-03T09:00:00.000Z",
224
226
  startTime: "",
225
227
  endTime: "",
226
228
  cancelledBy: "",
227
229
  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,
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,
234
236
  field: u,
235
- reason: b
237
+ reason: g
236
238
  });
237
- function ve() {
239
+ function Te() {
238
240
  return [
239
241
  T({
240
242
  id: "im_stub_running",
241
243
  phase: "writing",
242
244
  progress: { done: 48, total: 120 },
243
- counts: $({ matched: 120, created: 40, planned: 8 }),
245
+ counts: R({ matched: 120, created: 40, planned: 8 }),
244
246
  changeSetId: "cs_stub_running",
245
247
  createTime: "2026-11-04T10:00:00.000Z",
246
248
  startTime: "2026-11-04T10:00:05.000Z"
@@ -249,13 +251,13 @@ function ve() {
249
251
  id: "im_stub_queued",
250
252
  phase: "queued",
251
253
  startedBy: q,
252
- releases: w(2),
254
+ releases: P(2),
253
255
  createTime: "2026-11-04T10:05:00.000Z"
254
256
  }),
255
257
  T({
256
258
  id: "im_stub_problems",
257
259
  outcome: "succeeded_with_problems",
258
- counts: $({
260
+ counts: R({
259
261
  matched: 212,
260
262
  created: 180,
261
263
  planned: 20,
@@ -265,9 +267,9 @@ function ve() {
265
267
  }),
266
268
  changeSetId: "cs_stub_problems",
267
269
  releases: {
268
- ...w(2),
270
+ ...P(2),
269
271
  mappings: [
270
- ...w(2).mappings,
272
+ ...P(2).mappings,
271
273
  {
272
274
  configurationId: "mp_stub_title",
273
275
  name: "Gesetz titles",
@@ -292,9 +294,9 @@ function ve() {
292
294
  T({
293
295
  id: "im_stub_succeeded",
294
296
  outcome: "succeeded",
295
- counts: $({ matched: 64, created: 64 }),
297
+ counts: R({ matched: 64, created: 64 }),
296
298
  changeSetId: "cs_stub_succeeded",
297
- releases: w(1),
299
+ releases: P(1),
298
300
  createTime: "2026-11-02T14:00:00.000Z",
299
301
  startTime: "2026-11-02T14:00:01.000Z",
300
302
  endTime: "2026-11-02T14:03:10.000Z"
@@ -303,8 +305,8 @@ function ve() {
303
305
  id: "im_stub_failed",
304
306
  outcome: "failed",
305
307
  failureReason: "The worker crashed three times running this Import.",
306
- counts: $({ matched: 30 }),
307
- releases: w(1),
308
+ counts: R({ matched: 30 }),
309
+ releases: P(1),
308
310
  createTime: "2026-11-02T11:00:00.000Z",
309
311
  startTime: "2026-11-02T11:00:01.000Z",
310
312
  endTime: "2026-11-02T11:20:00.000Z"
@@ -313,15 +315,15 @@ function ve() {
313
315
  id: "im_stub_cancelled",
314
316
  outcome: "cancelled",
315
317
  cancelledBy: q,
316
- counts: $({ matched: 12, created: 3 }),
317
- releases: w(1),
318
+ counts: R({ matched: 12, created: 3 }),
319
+ releases: P(1),
318
320
  createTime: "2026-11-01T16:00:00.000Z",
319
321
  startTime: "2026-11-01T16:00:01.000Z",
320
322
  endTime: "2026-11-01T16:01:00.000Z"
321
323
  })
322
324
  ];
323
325
  }
324
- function Te() {
326
+ function $e() {
325
327
  return [
326
328
  {
327
329
  id: "key_stub_nightly",
@@ -335,7 +337,7 @@ function Te() {
335
337
  id: "key_stub_pipeline",
336
338
  name: "VRPML pipeline",
337
339
  keyPrefix: "ihk_b91F",
338
- owner: h,
340
+ owner: b,
339
341
  expireTime: "2027-06-30T21:59:59.000Z",
340
342
  createTime: "2026-11-03T12:00:00.000Z"
341
343
  }
@@ -375,47 +377,47 @@ const Re = [
375
377
  "revokeApiKey"
376
378
  ];
377
379
  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(),
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),
384
+ savedBy: b,
385
+ savedAt: v(),
384
386
  restoredFromRevisionId: ""
385
- })), b = Array.from({ length: c.releaseNumber ?? 0 }, (y, p) => ({
386
- id: `${c.id}_rel${p + 1}`,
387
+ })), g = Array.from({ length: o.releaseNumber ?? 0 }, (_, p) => ({
388
+ id: `${o.id}_rel${p + 1}`,
387
389
  number: p + 1,
388
- revisionId: `${c.id}_r${p + 1}`,
389
- releasedBy: h,
390
- releasedAt: P()
390
+ revisionId: `${o.id}_r${p + 1}`,
391
+ releasedBy: b,
392
+ releasedAt: v()
391
393
  }));
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);
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);
395
397
  return {
396
- draftRevisionId: A(r).id,
398
+ draftRevisionId: N(i).id,
397
399
  // By content, as importhub compares: a draft that restored the
398
400
  // 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 } } : {}
401
+ draftDiffersFromRelease: !c || JSON.stringify(c.content) !== JSON.stringify(N(i).content),
402
+ ...o ? { latestRelease: { id: o.id, number: o.number } } : {}
401
403
  };
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));
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));
408
410
  let fe = 0;
409
- function Ne(r = {}) {
410
- const c = Object.fromEntries(
411
+ function Oe(i = {}) {
412
+ const o = Object.fromEntries(
411
413
  Object.entries(
412
- r.workspaces ?? {
414
+ i.workspaces ?? {
413
415
  [te]: {
414
- importProfiles: we(),
415
- mappings: Ie(),
416
- entitySets: Se(),
417
- imports: ve(),
418
- apiKeys: Te()
416
+ importProfiles: Pe(),
417
+ mappings: Se(),
418
+ entitySets: we(),
419
+ imports: Te(),
420
+ apiKeys: $e()
419
421
  }
420
422
  }
421
423
  ).map(([e, t]) => [
@@ -428,32 +430,32 @@ function Ne(r = {}) {
428
430
  apiKeys: structuredClone(t.apiKeys ?? [])
429
431
  }
430
432
  ])
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] ??= {
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] ??= {
434
436
  importProfiles: [],
435
437
  mappings: [],
436
438
  entitySets: [],
437
439
  imports: [],
438
440
  apiKeys: []
439
- }, c[b]), f = async (e, t) => {
440
- if (y[e]++, r.fail) throw r.fail;
441
+ }, o[g]), d = async (e, t) => {
442
+ if (_[e]++, i.fail) throw i.fail;
441
443
  return structuredClone(t());
442
- }, g = (e, t, s) => {
443
- const n = e.find((i) => i.id === t);
444
+ }, h = (e, t, s) => {
445
+ const n = e.find((r) => r.id === t);
444
446
  if (!n) throw new Error(`${s} ${t} not found`);
445
447
  return n;
446
- }, v = (e, t, s) => {
448
+ }, I = (e, t, s) => {
447
449
  if (!t.trim()) throw new Error("a name is required");
448
450
  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 = "") => {
451
+ }, ne = (e, t) => t !== "" && t !== N(e).id, x = (e, t, s, n = "") => {
450
452
  if (ne(e, s))
451
453
  throw new Error("the draft moved: somebody saved in between");
452
454
  e.content = structuredClone(t), e.revisions.push({
453
455
  id: `${e.id}_r${e.revisions.length + 1}`,
454
456
  content: structuredClone(t),
455
- savedBy: h,
456
- savedAt: P(),
457
+ savedBy: b,
458
+ savedAt: v(),
457
459
  restoredFromRevisionId: n
458
460
  });
459
461
  }, G = (e, t) => {
@@ -465,8 +467,8 @@ function Ne(r = {}) {
465
467
  {
466
468
  id: `${s}_r1`,
467
469
  content: structuredClone(t),
468
- savedBy: h,
469
- savedAt: P(),
470
+ savedBy: b,
471
+ savedAt: v(),
470
472
  restoredFromRevisionId: ""
471
473
  }
472
474
  ],
@@ -474,7 +476,7 @@ function Ne(r = {}) {
474
476
  };
475
477
  };
476
478
  function J(e) {
477
- const t = [], s = u.find((o) => o.id === e.blueprintReleaseId);
479
+ const t = [], s = u.find((a) => a.id === e.blueprintReleaseId);
478
480
  e.blueprintReleaseId ? s ? s.blueprintId !== e.blueprintId && t.push({
479
481
  path: "/blueprintReleaseId",
480
482
  code: "release_of_other_blueprint",
@@ -492,85 +494,85 @@ function Ne(r = {}) {
492
494
  code: "no_element_selector",
493
495
  message: "It has no element selector."
494
496
  }), !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.` });
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.` });
497
499
  };
498
500
  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,
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({
506
+ path: f,
505
507
  code: "unknown_field_path",
506
- message: `The pinned Release has no field ${d}.`
507
- }), S.type === "select" && !S.selectOptions && t.push({
508
- path: m,
508
+ message: `The pinned Release has no field ${m}.`
509
+ }), w.type === "select" && !w.selectOptions && t.push({
510
+ path: f,
509
511
  code: "xmlmapper_schema",
510
- message: `The select field ${d} has no select options.`
512
+ message: `The select field ${m} has no select options.`
511
513
  });
512
- }), (e.versionMatch?.contentFields ?? []).forEach((o, a) => {
513
- i.includes(o) || t.push({
514
- path: `/version_match/content_fields/${a}`,
514
+ }), (e.versionMatch?.contentFields ?? []).forEach((a, l) => {
515
+ r.includes(a) || t.push({
516
+ path: `/version_match/content_fields/${l}`,
515
517
  code: "unknown_version_match_field",
516
- message: `The Version Match compares ${o}, which the Mapping does not map.`
518
+ message: `The Version Match compares ${a}, which the Mapping does not map.`
517
519
  });
518
- }), (e.titleContributions ?? []).forEach((o, a) => {
519
- (!o.selector || !o.ausgabeCodeSelector) && t.push({
520
- path: `/title_contributions/${a}`,
520
+ }), (e.titleContributions ?? []).forEach((a, l) => {
521
+ (!a.selector || !a.ausgabeCodeSelector) && t.push({
522
+ path: `/title_contributions/${l}`,
521
523
  code: "incomplete_title_contribution",
522
524
  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}`,
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}`,
527
529
  code: "incomplete_placeholder_assets",
528
530
  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);
531
+ }), n(`/placeholder_assets/${l}/selector`, a.selector), (a.keyParts ?? []).forEach((f, m) => {
532
+ n(`/placeholder_assets/${l}/key_parts/${m}`, f);
531
533
  });
532
- }), t;
534
+ }), t.push(...Me(e, s?.fields, r)), t;
533
535
  }
534
- 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" ? [
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" ? [
538
540
  {
539
- path: o,
541
+ path: a,
540
542
  code: "rich_text_processor",
541
- message: `${a.name} is configured on a rich-text field, not on a Profile.`
543
+ message: `${l.name} is configured on a rich-text field, not on a Profile.`
542
544
  }
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}`,
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}`,
547
549
  code: "invalid_processor_settings",
548
- message: `${a.name}: ${d.config.api_accessor} is required.`
550
+ message: `${l.name}: ${m.config.api_accessor} is required.`
549
551
  })) : [
550
- { path: o, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
552
+ { path: a, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
551
553
  ];
552
554
  });
553
555
  }
554
556
  function L(e) {
555
557
  const t = p(), s = [
556
- ...re(e.preprocessors, "preprocessors", "preprocessor"),
557
- ...re(e.postProcessors, "postProcessors", "post_processor")
558
+ ...ie(e.preprocessors, "preprocessors", "preprocessor"),
559
+ ...ie(e.postProcessors, "postProcessors", "post_processor")
558
560
  ];
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) {
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) {
562
564
  s.push({
563
- path: `/mappingIds/${i}`,
565
+ path: `/mappingIds/${r}`,
564
566
  code: "mapping_missing",
565
567
  message: "It includes a Mapping that does not exist."
566
568
  });
567
569
  return;
568
570
  }
569
- const a = J(o.content);
570
- a.length > 0 && s.push({
571
- path: `/mappingIds/${i}`,
571
+ const l = J(a.content);
572
+ l.length > 0 && s.push({
573
+ path: `/mappingIds/${r}`,
572
574
  code: "mapping_invalid",
573
- message: `The Mapping ${o.content.name} is invalid: ${a.map((m) => m.message).join(" ")}`
575
+ message: `The Mapping ${a.content.name} is invalid: ${l.map((f) => f.message).join(" ")}`
574
576
  });
575
577
  }), e.entitySetId && !t.entitySets.some((n) => n.id === e.entitySetId) && s.push({
576
578
  path: "/entitySetId",
@@ -578,25 +580,25 @@ function Ne(r = {}) {
578
580
  message: "It names an Entity Set that does not exist."
579
581
  }), s;
580
582
  }
581
- const ie = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], x = (e) => ({
583
+ const re = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], A = (e) => ({
582
584
  id: e.id,
583
585
  content: e.content,
584
- validity: R(L(e.content)),
586
+ validity: $(L(e.content)),
585
587
  state: Z(e)
586
- }), O = (e) => ({
588
+ }), F = (e) => ({
587
589
  id: e.id,
588
590
  content: e.content,
589
- validity: R(J(e.content)),
591
+ validity: $(J(e.content)),
590
592
  state: Z(e)
591
- }), F = (e) => ({
593
+ }), O = (e) => ({
592
594
  id: e.id,
593
595
  content: e.content,
594
- validity: R(ie(e.content)),
596
+ validity: $(re(e.content)),
595
597
  state: Z(e)
596
598
  }), K = (e) => D(p().importProfiles.filter((t) => e(t.content))).map((t) => ({
597
599
  id: t.id,
598
600
  name: t.content.name
599
- })), H = (e) => `${e}_stub_new_${++fe}`, E = (e) => {
601
+ })), H = (e) => `${e}_stub_new_${++fe}`, k = (e) => {
600
602
  const t = p();
601
603
  switch (e) {
602
604
  case "importProfile":
@@ -615,26 +617,26 @@ function Ne(r = {}) {
615
617
  return {
616
618
  items: t.entitySets,
617
619
  name: "Entity Set",
618
- reasons: (s) => ie(s)
620
+ reasons: (s) => re(s)
619
621
  };
620
622
  }
621
- }, I = (e, t) => {
622
- A(t).validity = R(E(e).reasons(t.content));
623
+ }, S = (e, t) => {
624
+ N(t).validity = $(k(e).reasons(t.content));
623
625
  }, U = (e, t) => {
624
626
  const s = e.revisions.find((n) => n.id === t);
625
627
  if (!s) throw new Error(`Revision ${t} not found`);
626
628
  return s;
627
- }, oe = /* @__PURE__ */ new Set(), ae = r.contenthubRights ?? ["editor", "publisher"], z = (e) => {
629
+ }, oe = /* @__PURE__ */ new Set(), ae = i.contenthubRights ?? ["editor", "publisher"], z = (e) => {
628
630
  const t = p().imports.find((s) => s.id === e);
629
631
  if (!t) throw new Error(`Import ${e} not found`);
630
632
  return t;
631
633
  }, W = (e) => {
632
- e.cancelledBy && e.phase !== "ended" && (e.phase = "ended", e.outcome = "cancelled", e.endTime = P());
634
+ e.cancelledBy && e.phase !== "ended" && (e.phase = "ended", e.outcome = "cancelled", e.endTime = v());
633
635
  }, C = ({ itemProblems: e, ...t }) => t, V = (e, t) => {
634
- const s = he(e);
636
+ const s = ge(e);
635
637
  if (!s)
636
638
  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;
639
+ const n = e.revisions.find((r) => r.id === s.revisionId)?.content ?? e.content;
638
640
  return {
639
641
  content: n,
640
642
  ref: {
@@ -646,149 +648,149 @@ function Ne(r = {}) {
646
648
  };
647
649
  };
648
650
  return {
649
- calls: y,
651
+ calls: _,
650
652
  switchWorkspace(e) {
651
- b = e;
653
+ g = e;
652
654
  },
653
655
  updateImport(e, t) {
654
656
  Object.assign(z(e), structuredClone(t));
655
657
  },
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);
658
+ listImportProfiles: () => d("listImportProfiles", () => D(p().importProfiles).map(A)),
659
+ getImportProfile: (e) => d("getImportProfile", () => A(h(p().importProfiles, e, "Import Profile"))),
660
+ createImportProfile: (e) => d("createImportProfile", () => {
661
+ I(p().importProfiles, e.name);
660
662
  const t = G("ip", e);
661
- return I("importProfile", t), p().importProfiles.push(t), x(t);
663
+ return S("importProfile", t), p().importProfiles.push(t), A(t);
662
664
  }),
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);
665
+ 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);
666
668
  }),
667
- deleteImportProfile: (e) => f("deleteImportProfile", () => {
668
- g(p().importProfiles, e, "Import Profile"), p().importProfiles = p().importProfiles.filter((t) => t.id !== e);
669
+ deleteImportProfile: (e) => d("deleteImportProfile", () => {
670
+ h(p().importProfiles, e, "Import Profile"), p().importProfiles = p().importProfiles.filter((t) => t.id !== e);
669
671
  }),
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);
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"))),
675
+ createMapping: (e) => d("createMapping", () => {
676
+ I(p().mappings, e.name);
675
677
  const t = G("mp", e);
676
- return I("mapping", t), p().mappings.push(t), O(t);
678
+ return S("mapping", t), p().mappings.push(t), F(t);
677
679
  }),
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);
680
+ 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);
681
683
  }),
682
- deleteMapping: (e) => f("deleteMapping", () => {
683
- g(p().mappings, e, "Mapping");
684
+ deleteMapping: (e) => d("deleteMapping", () => {
685
+ h(p().mappings, e, "Mapping");
684
686
  const t = K((s) => s.mappingIds.includes(e));
685
687
  if (t.length > 0)
686
- throw new le(
688
+ throw new pe(
687
689
  t,
688
690
  `the Mapping is included by ${t.map((s) => s.name).join(", ")}`
689
691
  );
690
692
  p().mappings = p().mappings.filter((s) => s.id !== e);
691
693
  }),
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);
694
+ listMappingImportProfiles: (e) => d("listMappingImportProfiles", () => (h(p().mappings, e, "Mapping"), K((t) => t.mappingIds.includes(e)))),
695
+ checkMappingBlueprintRelease: (e, t) => d("checkMappingBlueprintRelease", () => {
696
+ const s = h(p().mappings, e, "Mapping"), n = u.find((r) => r.id === t);
695
697
  if (!n) throw new Error(`Blueprint Release ${t} not found`);
696
698
  if (n.blueprintId !== s.content.blueprintId)
697
699
  throw new Error("the Release is of another Blueprint");
698
700
  return {
699
701
  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)),
702
+ missingFieldPaths: (s.content.fields ?? []).flatMap((r, a) => se(r, "", `/fields/${a}`).map((l) => l.path)).filter((r) => !n.fieldPaths.includes(r)),
701
703
  missingReleaseSpecFields: [
702
- ...(s.content.releaseSpec ?? []).map((i) => i.field ?? ""),
704
+ ...(s.content.releaseSpec ?? []).map((r) => r.field ?? ""),
703
705
  ...s.content.versionMatch?.releaseSpecFields ?? []
704
706
  ].filter(
705
- (i, o, a) => i !== "" && a.indexOf(i) === o && !(n.releaseSpecFields ?? []).some((m) => m.path === i)
707
+ (r, a, l) => r !== "" && l.indexOf(r) === a && !(n.releaseSpecFields ?? []).some((f) => f.path === r)
706
708
  )
707
709
  };
708
710
  }),
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);
711
+ listEntitySets: () => d("listEntitySets", () => D(p().entitySets).map(O)),
712
+ getEntitySet: (e) => d("getEntitySet", () => O(h(p().entitySets, e, "Entity Set"))),
713
+ createEntitySet: (e) => d("createEntitySet", () => {
714
+ I(p().entitySets, e.name);
713
715
  const t = G("es", e);
714
- return I("entitySet", t), p().entitySets.push(t), F(t);
716
+ return S("entitySet", t), p().entitySets.push(t), O(t);
715
717
  }),
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);
718
+ 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);
719
721
  }),
720
- deleteEntitySet: (e) => f("deleteEntitySet", () => {
721
- g(p().entitySets, e, "Entity Set");
722
+ deleteEntitySet: (e) => d("deleteEntitySet", () => {
723
+ h(p().entitySets, e, "Entity Set");
722
724
  const t = K((s) => s.entitySetId === e);
723
725
  if (t.length > 0)
724
- throw new le(
726
+ throw new pe(
725
727
  t,
726
728
  `the Entity Set is named by ${t.map((s) => s.name).join(", ")}`
727
729
  );
728
730
  p().entitySets = p().entitySets.filter((s) => s.id !== e);
729
731
  }),
730
- cutRelease: (e, t, s) => f("cutRelease", () => {
731
- const n = E(e), i = g(n.items, t, n.name);
732
- if (ne(i, s))
732
+ cutRelease: (e, t, s) => d("cutRelease", () => {
733
+ const n = k(e), r = h(n.items, t, n.name);
734
+ if (ne(r, s))
733
735
  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)
736
+ const a = $(n.reasons(r.content));
737
+ if (!a.valid) throw new Q("the draft is invalid", a);
738
+ if (!Z(r).draftDiffersFromRelease)
737
739
  throw new Q(
738
740
  "the draft does not differ from the latest Release: there is nothing to release"
739
741
  );
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()
742
+ const l = r.releases.length + 1, f = {
743
+ id: `${r.id}_rel${l}`,
744
+ number: l,
745
+ revisionId: N(r).id,
746
+ releasedBy: b,
747
+ releasedAt: v()
746
748
  };
747
- return i.releases.push(m), {
748
- release: m,
749
- importProfiles: e === "mapping" ? K((d) => d.mappingIds.includes(t)) : []
749
+ return r.releases.push(f), {
750
+ release: f,
751
+ importProfiles: e === "mapping" ? K((m) => m.mappingIds.includes(t)) : []
750
752
  };
751
753
  }),
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");
754
+ 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");
754
756
  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
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
761
763
  })),
762
- releases: [...i.releases].reverse(),
763
- nextPageToken: a + 10 < o.length ? String(a + 10) : ""
764
+ releases: [...r.releases].reverse(),
765
+ nextPageToken: l + 10 < a.length ? String(l + 10) : ""
764
766
  };
765
767
  }),
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 };
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 };
770
772
  });
771
773
  return {
772
- from: { revisionId: s, content: a },
773
- to: { revisionId: n, content: m },
774
- fields: d
774
+ from: { revisionId: s, content: l },
775
+ to: { revisionId: n, content: f },
776
+ fields: m
775
777
  };
776
778
  }),
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);
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);
780
782
  }),
781
783
  async uploadSourceFile(e, t) {
782
- if (y.uploadSourceFile++, r.fail) throw r.fail;
784
+ if (_.uploadSourceFile++, i.fail) throw i.fail;
783
785
  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;
786
+ await new Promise((r) => setTimeout(r, 20)), t(n);
787
+ if (i.uploadFails) throw i.uploadFails;
786
788
  t(1);
787
789
  const s = H("sf");
788
790
  return oe.add(s), { id: s, fileName: e.name };
789
791
  },
790
- startImport: (e) => f("startImport", () => {
791
- const t = p(), s = g(t.importProfiles, e.importProfileId, "Import Profile");
792
+ startImport: (e) => d("startImport", () => {
793
+ const t = p(), s = h(t.importProfiles, e.importProfileId, "Import Profile");
792
794
  if (!oe.has(e.sourceFileId))
793
795
  throw new M("nothing was uploaded to the Source File");
794
796
  if (!ae.includes("editor"))
@@ -800,19 +802,19 @@ function Ne(r = {}) {
800
802
  throw new M(
801
803
  "the Import Profile has Auto-publish, which needs contenthub publisher"
802
804
  );
803
- const i = L(n.content);
804
- if (i.length > 0)
805
+ const r = L(n.content);
806
+ if (r.length > 0)
805
807
  throw new M(
806
- `the Import Profile ${n.ref.name} is invalid: ${i.map((d) => d.message).join(" ")}`
808
+ `the Import Profile ${n.ref.name} is invalid: ${r.map((m) => m.message).join(" ")}`
807
809
  );
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 = {
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 = {
811
813
  id: H("im"),
812
814
  importProfileId: s.id,
813
815
  importProfileName: n.ref.name,
814
816
  sourceFileId: e.sourceFileId,
815
- startedBy: h,
817
+ startedBy: b,
816
818
  phase: "queued",
817
819
  failureReason: "",
818
820
  progress: { done: 0, total: 0 },
@@ -828,10 +830,10 @@ function Ne(r = {}) {
828
830
  changeSetId: "",
829
831
  releases: {
830
832
  importProfile: n.ref,
831
- mappings: o,
832
- ...a ? { entitySet: a } : {}
833
+ mappings: a,
834
+ ...l ? { entitySet: l } : {}
833
835
  },
834
- createTime: P(),
836
+ createTime: v(),
835
837
  startTime: "",
836
838
  endTime: "",
837
839
  cancelledBy: "",
@@ -839,9 +841,9 @@ function Ne(r = {}) {
839
841
  ...e.source ? { source: e.source } : {},
840
842
  itemProblems: []
841
843
  };
842
- return t.imports.unshift(m), C(m);
844
+ return t.imports.unshift(f), C(f);
843
845
  }),
844
- listImports: (e) => f("listImports", () => {
846
+ listImports: (e) => d("listImports", () => {
845
847
  const t = p().imports;
846
848
  t.forEach(W);
847
849
  const s = Number(e || "0");
@@ -850,121 +852,154 @@ function Ne(r = {}) {
850
852
  nextPageToken: s + 50 < t.length ? String(s + 50) : ""
851
853
  };
852
854
  }),
853
- getImport: (e) => f("getImport", () => {
855
+ getImport: (e) => d("getImport", () => {
854
856
  const t = z(e);
855
857
  return W(t), C(t);
856
858
  }),
857
- cancelImport: (e) => f("cancelImport", () => {
859
+ cancelImport: (e) => d("cancelImport", () => {
858
860
  const t = z(e);
859
861
  if (t.phase === "ended") throw new Error("the Import has ended");
860
- return t.cancelledBy ||= h, t.phase === "queued" && W(t), C(t);
862
+ return t.cancelledBy ||= b, t.phase === "queued" && W(t), C(t);
861
863
  }),
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,
864
+ 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();
868
+ for (const f of s) {
869
+ const m = a.get(f.mappingId) ?? {
870
+ mappingId: f.mappingId,
871
+ mappingName: f.mappingName,
870
872
  count: 0
871
873
  };
872
- d.count++, o.set(m.mappingId, d);
874
+ m.count++, a.set(f.mappingId, m);
873
875
  }
874
- const a = Number(t.pageToken || "0");
876
+ const l = Number(t.pageToken || "0");
875
877
  return {
876
- itemProblems: i.slice(a, a + 50),
878
+ itemProblems: r.slice(l, l + 50),
877
879
  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) : ""
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) : ""
881
883
  };
882
884
  }),
883
- listApiKeys: () => f("listApiKeys", () => p().apiKeys),
884
- createApiKey: (e) => f("createApiKey", () => {
885
+ listApiKeys: () => d("listApiKeys", () => p().apiKeys),
886
+ createApiKey: (e) => d("createApiKey", () => {
885
887
  const t = e.name.trim();
886
888
  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`);
889
+ if (t.length > le)
890
+ throw new Error(`the name is longer than ${le} characters`);
889
891
  const s = e.expireTime ? new Date(e.expireTime).toISOString() : "";
890
892
  if (s && Date.parse(s) <= Date.now())
891
893
  throw new Error("the expiry must lie in the future");
892
- const n = ++fe, i = {
894
+ const n = ++fe, r = {
893
895
  id: `key_stub_new_${n}`,
894
896
  name: t,
895
897
  keyPrefix: `ihk_n${String(n).padStart(3, "0")}`,
896
- owner: h,
898
+ owner: b,
897
899
  expireTime: s,
898
900
  createTime: (/* @__PURE__ */ new Date()).toISOString()
899
901
  };
900
- return p().apiKeys.unshift(i), { apiKey: i, secret: `${i.keyPrefix}_stub_secret_${n}` };
902
+ return p().apiKeys.unshift(r), { apiKey: r, secret: `${r.keyPrefix}_stub_secret_${n}` };
901
903
  }),
902
- revokeApiKey: (e) => f("revokeApiKey", () => {
904
+ revokeApiKey: (e) => d("revokeApiKey", () => {
903
905
  const t = p();
904
906
  if (!t.apiKeys.some((s) => s.id === e)) throw new Error(`API key ${e} not found`);
905
907
  t.apiKeys = t.apiKeys.filter((s) => s.id !== e);
906
908
  })
907
909
  };
908
910
  }
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;
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;
915
917
  }
916
- function se(r, c, l) {
917
- const u = `${c}${String(r.name ?? "")}`;
918
+ function se(i, o, c) {
919
+ const u = `${o}${String(i.name ?? "")}`;
918
920
  return [
919
- { path: u, rel: l, mapping: r },
921
+ { path: u, rel: c, mapping: i },
920
922
  ...["fields", "virtualTableFields"].flatMap(
921
- (b) => (Array.isArray(r[b]) ? r[b] : []).flatMap(
922
- (y, p) => se(y, `${u}.`, `${l}/${b}/${p}`)
923
+ (g) => (Array.isArray(i[g]) ? i[g] : []).flatMap(
924
+ (_, p) => se(_, `${u}.`, `${c}/${g}/${p}`)
923
925
  )
924
926
  )
925
927
  ];
926
928
  }
927
- function xe(r = ge()) {
929
+ function Ke(i = he()) {
928
930
  return {
929
931
  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));
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));
931
933
  },
932
- async listReleases(c) {
933
- return r.filter((l) => l.blueprintId === c).map((l) => ({ id: l.id, label: l.label }));
934
+ async listReleases(o) {
935
+ return i.filter((c) => c.blueprintId === o).map((c) => ({ id: c.id, label: c.label }));
934
936
  },
935
- async getRelease(c) {
936
- const l = r.find((u) => u.id === c);
937
- if (!l) throw new Error(`Blueprint Release ${c} not found`);
937
+ async getRelease(o) {
938
+ const c = i.find((u) => u.id === o);
939
+ if (!c) throw new Error(`Blueprint Release ${o} not found`);
938
940
  return {
939
- id: l.id,
940
- blueprintId: l.blueprintId,
941
- name: l.label,
942
- fields: l.fields ?? l.fieldPaths.map((u) => ({
941
+ id: c.id,
942
+ blueprintId: c.blueprintId,
943
+ name: c.label,
944
+ fields: c.fields ?? c.fieldPaths.map((u) => ({
943
945
  accessor: u,
944
946
  path: u,
945
947
  fieldType: "text",
946
948
  label: "",
947
949
  children: []
948
950
  })),
949
- releaseSpecFields: l.releaseSpecFields ?? []
951
+ releaseSpecFields: c.releaseSpecFields ?? []
950
952
  };
951
953
  }
952
954
  };
953
955
  }
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 }
959
+ ];
960
+ if (!u && !g) return [];
961
+ if (!g)
962
+ return _(
963
+ "/display_name_field",
964
+ "incomplete_display_name",
965
+ "the display-name template names no field to write the display name into"
966
+ );
967
+ if (!u)
968
+ return _(
969
+ "/display_name_template",
970
+ "incomplete_display_name",
971
+ `the display-name field "${g}" has no display-name template to fill it`
972
+ );
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) ? _(
976
+ "/display_name_field",
977
+ "display_name_field_mapped",
978
+ `the field "${g}" is mapped too: it takes the display name or a mapped value, not both`
979
+ ) : [] : _(
980
+ "/display_name_field",
981
+ "display_name_field_not_plain_text",
982
+ `the display-name field "${g}" is not a plain-text one (text or textarea)`
983
+ ) : _(
984
+ "/display_name_field",
985
+ "unknown_display_name_field",
986
+ `the Blueprint Release has no field "${g}" to write the display name into`
987
+ );
988
+ }
954
989
  export {
955
990
  q as STUB_OTHER_USER_ID,
956
- Be as STUB_OTHER_WORKSPACE_ID,
957
- h as STUB_USER_ID,
991
+ Ae as STUB_OTHER_WORKSPACE_ID,
992
+ b as STUB_USER_ID,
958
993
  te as STUB_WORKSPACE_ID,
959
- xe as createStubBlueprints,
960
- Ne as createStubImporthubClient,
961
- Te as stubApiKeys,
962
- 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
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
969
1004
  };
970
1005
  //# sourceMappingURL=testing.js.map