@knkcs/importhub-ui 0.2.0 → 0.3.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,16 +1,16 @@
1
- import { createHostMembers as j } from "@knkcs/anker/host";
2
- import { C as O, N as F } from "./importhub-client-CYqd7Eeq.js";
3
- const z = "user_stub_ada", k = "ws_stub_main", V = "ws_stub_other";
4
- function J(r = k) {
1
+ import { createHostMembers as X } from "@knkcs/anker/host";
2
+ import { R as j, C as J, N as Y } from "./importhub-client-CrS-3Zuu.js";
3
+ const b = "user_stub_ada", D = "ws_stub_main", ce = "ws_stub_other";
4
+ function me(r = D) {
5
5
  return {
6
- userId: z,
6
+ userId: b,
7
7
  workspaceId: r,
8
- members: j([
9
- { userId: z, displayName: "Ada Importer", email: "ada@example.com" }
8
+ members: X([
9
+ { userId: b, displayName: "Ada Importer", email: "ada@example.com" }
10
10
  ])
11
11
  };
12
12
  }
13
- function x() {
13
+ function Z() {
14
14
  return [
15
15
  {
16
16
  id: "br_stub_gesetz_2",
@@ -35,7 +35,7 @@ function x() {
35
35
  }
36
36
  ];
37
37
  }
38
- function U() {
38
+ function ee() {
39
39
  return [
40
40
  {
41
41
  id: "mp_stub_norm",
@@ -67,7 +67,7 @@ function U() {
67
67
  }
68
68
  ];
69
69
  }
70
- function D() {
70
+ function te() {
71
71
  return [
72
72
  {
73
73
  id: "es_stub_latin1",
@@ -80,7 +80,7 @@ function D() {
80
80
  }
81
81
  ];
82
82
  }
83
- function W() {
83
+ function se() {
84
84
  return [
85
85
  {
86
86
  id: "ip_stub_gesetz",
@@ -111,12 +111,12 @@ function W() {
111
111
  }
112
112
  ];
113
113
  }
114
- const w = (r, p, o, d = "") => ({
114
+ const F = (r, a, p, f = "") => ({
115
115
  field_type: "text",
116
- config: { name: p, api_accessor: r, required: o, instructions: d },
116
+ config: { name: a, api_accessor: r, required: p, instructions: f },
117
117
  system: !1
118
118
  });
119
- function L() {
119
+ function ne() {
120
120
  return [
121
121
  {
122
122
  name: "citation-links",
@@ -138,8 +138,8 @@ function L() {
138
138
  target: "source_file",
139
139
  description: "Renames every element of one name to another.",
140
140
  settingsSpec: [
141
- w("from", "Element", !0, "The element's name now."),
142
- w("to", "New name", !0)
141
+ F("from", "Element", !0, "The element's name now."),
142
+ F("to", "New name", !0)
143
143
  ]
144
144
  },
145
145
  {
@@ -147,11 +147,11 @@ function L() {
147
147
  kind: "preprocessor",
148
148
  target: "source_file",
149
149
  description: "Wraps each sentence of an element in its own element.",
150
- settingsSpec: [w("element", "Element", !1)]
150
+ settingsSpec: [F("element", "Element", !1)]
151
151
  }
152
152
  ];
153
153
  }
154
- const q = [
154
+ const ie = [
155
155
  "listImportProfiles",
156
156
  "getImportProfile",
157
157
  "createImportProfile",
@@ -169,60 +169,104 @@ const q = [
169
169
  "getEntitySet",
170
170
  "createEntitySet",
171
171
  "updateEntitySet",
172
- "deleteEntitySet"
173
- ], v = (r = []) => r.map((p) => ({
174
- id: p.id,
175
- content: structuredClone(p.content),
176
- revision: 1,
177
- releaseNumber: p.releaseNumber,
178
- releasedRevision: p.releaseNumber ? 1 : void 0
179
- })), y = (r) => ({
180
- draftRevisionId: `${r.id}_r${r.revision}`,
181
- draftDiffersFromRelease: r.releasedRevision !== r.revision,
182
- ...r.releaseNumber ? { latestRelease: { id: `${r.id}_rel${r.releaseNumber}`, number: r.releaseNumber } } : {}
183
- }), $ = (r) => ({
172
+ "deleteEntitySet",
173
+ "cutRelease",
174
+ "listHistory",
175
+ "compareRevisions",
176
+ "restoreRevision"
177
+ ];
178
+ let q = Date.parse("2026-11-02T08:00:00Z");
179
+ const P = () => (q += 36e5, new Date(q).toISOString()), K = (r = []) => r.map((a) => {
180
+ const p = Math.max(a.releaseNumber ?? 0, 1), f = Array.from({ length: p }, (w, i) => ({
181
+ id: `${a.id}_r${i + 1}`,
182
+ content: structuredClone(a.content),
183
+ savedBy: b,
184
+ savedAt: P(),
185
+ restoredFromRevisionId: ""
186
+ })), I = Array.from({ length: a.releaseNumber ?? 0 }, (w, i) => ({
187
+ id: `${a.id}_rel${i + 1}`,
188
+ number: i + 1,
189
+ revisionId: `${a.id}_r${i + 1}`,
190
+ releasedBy: b,
191
+ releasedAt: P()
192
+ }));
193
+ return { id: a.id, content: structuredClone(a.content), revisions: f, releases: I };
194
+ }), v = (r) => r.revisions[r.revisions.length - 1], re = (r) => r.releases[r.releases.length - 1], O = (r) => {
195
+ const a = re(r), p = r.revisions.find((f) => f.id === a?.revisionId);
196
+ return {
197
+ draftRevisionId: v(r).id,
198
+ // By content, as importhub compares: a draft that restored the
199
+ // released content does not differ.
200
+ draftDiffersFromRelease: !p || JSON.stringify(p.content) !== JSON.stringify(v(r).content),
201
+ ...a ? { latestRelease: { id: a.id, number: a.number } } : {}
202
+ };
203
+ }, oe = (r) => r.replace(/[A-Z]/g, (a) => `_${a.toLowerCase()}`), G = (r) => Object.fromEntries(
204
+ Object.entries(r).map(([a, p]) => [oe(a), p])
205
+ ), y = (r) => ({
184
206
  valid: r.length === 0,
185
207
  reasons: r
186
- }), S = (r) => [...r].sort((p, o) => p.content.name.localeCompare(o.content.name));
187
- let A = 0;
188
- function Q(r = {}) {
189
- const p = Object.fromEntries(
208
+ }), B = (r) => [...r].sort((a, p) => a.content.name.localeCompare(p.content.name));
209
+ let ae = 0;
210
+ function de(r = {}) {
211
+ const a = Object.fromEntries(
190
212
  Object.entries(
191
213
  r.workspaces ?? {
192
- [k]: {
193
- importProfiles: W(),
194
- mappings: U(),
195
- entitySets: D()
214
+ [D]: {
215
+ importProfiles: se(),
216
+ mappings: ee(),
217
+ entitySets: te()
196
218
  }
197
219
  }
198
220
  ).map(([e, t]) => [
199
221
  e,
200
222
  {
201
- importProfiles: v(t.importProfiles),
202
- mappings: v(t.mappings),
203
- entitySets: v(t.entitySets)
223
+ importProfiles: K(t.importProfiles),
224
+ mappings: K(t.mappings),
225
+ entitySets: K(t.entitySets)
204
226
  }
205
227
  ])
206
- ), o = r.processors ?? L(), d = r.blueprintReleases ?? x();
207
- let P = r.activeWorkspaceId ?? k;
208
- const N = Object.fromEntries(q.map((e) => [e, 0])), s = () => (p[P] ??= { importProfiles: [], mappings: [], entitySets: [] }, p[P]), a = async (e, t) => {
209
- if (N[e]++, r.fail) throw r.fail;
228
+ ), p = r.processors ?? ne(), f = r.blueprintReleases ?? Z();
229
+ let I = r.activeWorkspaceId ?? D;
230
+ const w = Object.fromEntries(ie.map((e) => [e, 0])), i = () => (a[I] ??= { importProfiles: [], mappings: [], entitySets: [] }, a[I]), c = async (e, t) => {
231
+ if (w[e]++, r.fail) throw r.fail;
210
232
  return structuredClone(t());
211
- }, c = (e, t, n) => {
212
- const i = e.find((l) => l.id === t);
213
- if (!i) throw new Error(`${n} ${t} not found`);
214
- return i;
215
- }, g = (e, t, n) => {
233
+ }, u = (e, t, s) => {
234
+ const n = e.find((o) => o.id === t);
235
+ if (!n) throw new Error(`${s} ${t} not found`);
236
+ return n;
237
+ }, _ = (e, t, s) => {
216
238
  if (!t.trim()) throw new Error("a name is required");
217
- if (e.some((i) => i.id !== n && i.content.name === t)) throw new F();
218
- }, E = (e, t, n) => {
219
- if (n && n !== y(e).draftRevisionId)
239
+ if (e.some((n) => n.id !== s && n.content.name === t)) throw new Y();
240
+ }, H = (e, t) => t !== "" && t !== v(e).id, R = (e, t, s, n = "") => {
241
+ if (H(e, s))
220
242
  throw new Error("the draft moved: somebody saved in between");
221
- e.content = structuredClone(t), e.revision++;
243
+ e.content = structuredClone(t), e.revisions.push({
244
+ id: `${e.id}_r${e.revisions.length + 1}`,
245
+ content: structuredClone(t),
246
+ savedBy: b,
247
+ savedAt: P(),
248
+ restoredFromRevisionId: n
249
+ });
250
+ }, N = (e, t) => {
251
+ const s = V(e);
252
+ return {
253
+ id: s,
254
+ content: structuredClone(t),
255
+ revisions: [
256
+ {
257
+ id: `${s}_r1`,
258
+ content: structuredClone(t),
259
+ savedBy: b,
260
+ savedAt: P(),
261
+ restoredFromRevisionId: ""
262
+ }
263
+ ],
264
+ releases: []
265
+ };
222
266
  };
223
- function B(e) {
224
- const t = [], n = d.find((i) => i.id === e.blueprintReleaseId);
225
- return e.blueprintReleaseId ? n ? n.blueprintId !== e.blueprintId && t.push({
267
+ function C(e) {
268
+ const t = [], s = f.find((n) => n.id === e.blueprintReleaseId);
269
+ return e.blueprintReleaseId ? s ? s.blueprintId !== e.blueprintId && t.push({
226
270
  path: "/blueprintReleaseId",
227
271
  code: "release_of_other_blueprint",
228
272
  message: "The pinned Release is of another Blueprint."
@@ -238,190 +282,257 @@ function Q(r = {}) {
238
282
  path: "/elementSelector",
239
283
  code: "no_element_selector",
240
284
  message: "It has no element selector."
241
- }), !e.sourceKey?.selector && !e.sourceKey?.template && t.push({ path: "/sourceKey", code: "no_source_key", message: "It has no Source Key." }), (e.fields ?? []).forEach((i, l) => {
242
- const m = String(i.name ?? "");
243
- n && !n.fieldPaths.includes(m) && t.push({
244
- path: `/fields/${l}`,
285
+ }), !e.sourceKey?.selector && !e.sourceKey?.template && t.push({ path: "/sourceKey", code: "no_source_key", message: "It has no Source Key." }), (e.fields ?? []).forEach((n, o) => {
286
+ const l = String(n.name ?? "");
287
+ s && !s.fieldPaths.includes(l) && t.push({
288
+ path: `/fields/${o}`,
245
289
  code: "unknown_field_path",
246
- message: `The pinned Release has no field ${m}.`
290
+ message: `The pinned Release has no field ${l}.`
247
291
  });
248
292
  }), t;
249
293
  }
250
- function C(e, t, n) {
251
- return e.flatMap((i, l) => {
252
- const m = `/${t}/${l}`, u = o.find((f) => f.name === i.processor);
253
- return u ? u.target !== "source_file" ? [
294
+ function U(e, t, s) {
295
+ return e.flatMap((n, o) => {
296
+ const l = `/${t}/${o}`, m = p.find((d) => d.name === n.processor);
297
+ return m ? m.target !== "source_file" ? [
254
298
  {
255
- path: m,
299
+ path: l,
256
300
  code: "rich_text_processor",
257
- message: `${u.name} is configured on a rich-text field, not on a Profile.`
301
+ message: `${m.name} is configured on a rich-text field, not on a Profile.`
258
302
  }
259
- ] : u.kind !== n ? [{ path: m, code: "wrong_processor_kind", message: `${u.name} does not run here.` }] : u.settingsSpec.filter(
260
- (f) => f.config.required && (i.settings[f.config.api_accessor] ?? "") === ""
261
- ).map((f) => ({
262
- path: `${m}/settings/${f.config.api_accessor}`,
303
+ ] : m.kind !== s ? [{ path: l, code: "wrong_processor_kind", message: `${m.name} does not run here.` }] : m.settingsSpec.filter(
304
+ (d) => d.config.required && (n.settings[d.config.api_accessor] ?? "") === ""
305
+ ).map((d) => ({
306
+ path: `${l}/settings/${d.config.api_accessor}`,
263
307
  code: "invalid_processor_settings",
264
- message: `${u.name}: ${f.config.api_accessor} is required.`
308
+ message: `${m.name}: ${d.config.api_accessor} is required.`
265
309
  })) : [
266
- { path: m, code: "unknown_processor", message: `No Processor is called ${i.processor}.` }
310
+ { path: l, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
267
311
  ];
268
312
  });
269
313
  }
270
- function T(e) {
271
- const t = s(), n = [
272
- ...C(e.preprocessors, "preprocessors", "preprocessor"),
273
- ...C(e.postProcessors, "postProcessors", "post_processor")
314
+ function L(e) {
315
+ const t = i(), s = [
316
+ ...U(e.preprocessors, "preprocessors", "preprocessor"),
317
+ ...U(e.postProcessors, "postProcessors", "post_processor")
274
318
  ];
275
- return e.mappingIds.length === 0 && n.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((i, l) => {
276
- const m = t.mappings.find((I) => I.id === i);
277
- if (!m) {
278
- n.push({
279
- path: `/mappingIds/${l}`,
319
+ return e.mappingIds.length === 0 && s.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((n, o) => {
320
+ const l = t.mappings.find((g) => g.id === n);
321
+ if (!l) {
322
+ s.push({
323
+ path: `/mappingIds/${o}`,
280
324
  code: "mapping_missing",
281
325
  message: "It includes a Mapping that does not exist."
282
326
  });
283
327
  return;
284
328
  }
285
- const u = B(m.content);
286
- u.length > 0 && n.push({
287
- path: `/mappingIds/${l}`,
329
+ const m = C(l.content);
330
+ m.length > 0 && s.push({
331
+ path: `/mappingIds/${o}`,
288
332
  code: "mapping_invalid",
289
- message: `The Mapping ${m.content.name} is invalid: ${u.map((I) => I.message).join(" ")}`
333
+ message: `The Mapping ${l.content.name} is invalid: ${m.map((g) => g.message).join(" ")}`
290
334
  });
291
- }), e.entitySetId && !t.entitySets.some((i) => i.id === e.entitySetId) && n.push({
335
+ }), e.entitySetId && !t.entitySets.some((n) => n.id === e.entitySetId) && s.push({
292
336
  path: "/entitySetId",
293
337
  code: "entity_set_missing",
294
338
  message: "It names an Entity Set that does not exist."
295
- }), n;
339
+ }), s;
296
340
  }
297
- const K = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], b = (e) => ({
341
+ const W = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], E = (e) => ({
298
342
  id: e.id,
299
343
  content: e.content,
300
- validity: $(T(e.content)),
301
- state: y(e)
302
- }), h = (e) => ({
344
+ validity: y(L(e.content)),
345
+ state: O(e)
346
+ }), M = (e) => ({
303
347
  id: e.id,
304
348
  content: e.content,
305
- validity: $(B(e.content)),
306
- state: y(e)
307
- }), _ = (e) => ({
349
+ validity: y(C(e.content)),
350
+ state: O(e)
351
+ }), $ = (e) => ({
308
352
  id: e.id,
309
353
  content: e.content,
310
- validity: $(K(e.content)),
311
- state: y(e)
312
- }), M = (e) => S(s().importProfiles.filter((t) => e(t.content))).map((t) => ({
354
+ validity: y(W(e.content)),
355
+ state: O(e)
356
+ }), k = (e) => B(i().importProfiles.filter((t) => e(t.content))).map((t) => ({
313
357
  id: t.id,
314
358
  name: t.content.name
315
- })), R = (e) => `${e}_stub_new_${++A}`;
359
+ })), V = (e) => `${e}_stub_new_${++ae}`, S = (e) => {
360
+ const t = i();
361
+ switch (e) {
362
+ case "importProfile":
363
+ return {
364
+ items: t.importProfiles,
365
+ name: "Import Profile",
366
+ reasons: (s) => L(s)
367
+ };
368
+ case "mapping":
369
+ return {
370
+ items: t.mappings,
371
+ name: "Mapping",
372
+ reasons: (s) => C(s)
373
+ };
374
+ case "entitySet":
375
+ return {
376
+ items: t.entitySets,
377
+ name: "Entity Set",
378
+ reasons: (s) => W(s)
379
+ };
380
+ }
381
+ }, h = (e, t) => {
382
+ v(t).validity = y(S(e).reasons(t.content));
383
+ }, x = (e, t) => {
384
+ const s = e.revisions.find((n) => n.id === t);
385
+ if (!s) throw new Error(`Revision ${t} not found`);
386
+ return s;
387
+ };
316
388
  return {
317
- calls: N,
389
+ calls: w,
318
390
  switchWorkspace(e) {
319
- P = e;
391
+ I = e;
320
392
  },
321
- listImportProfiles: () => a("listImportProfiles", () => S(s().importProfiles).map(b)),
322
- getImportProfile: (e) => a("getImportProfile", () => b(c(s().importProfiles, e, "Import Profile"))),
323
- createImportProfile: (e) => a("createImportProfile", () => {
324
- g(s().importProfiles, e.name);
325
- const t = {
326
- id: R("ip"),
327
- content: structuredClone(e),
328
- revision: 1
329
- };
330
- return s().importProfiles.push(t), b(t);
393
+ listImportProfiles: () => c("listImportProfiles", () => B(i().importProfiles).map(E)),
394
+ getImportProfile: (e) => c("getImportProfile", () => E(u(i().importProfiles, e, "Import Profile"))),
395
+ createImportProfile: (e) => c("createImportProfile", () => {
396
+ _(i().importProfiles, e.name);
397
+ const t = N("ip", e);
398
+ return h("importProfile", t), i().importProfiles.push(t), E(t);
331
399
  }),
332
- updateImportProfile: (e, t, n) => a("updateImportProfile", () => {
333
- const i = c(s().importProfiles, e, "Import Profile");
334
- return g(s().importProfiles, t.name, e), E(i, t, n), b(i);
400
+ updateImportProfile: (e, t, s) => c("updateImportProfile", () => {
401
+ const n = u(i().importProfiles, e, "Import Profile");
402
+ return _(i().importProfiles, t.name, e), R(n, t, s), h("importProfile", n), E(n);
335
403
  }),
336
- deleteImportProfile: (e) => a("deleteImportProfile", () => {
337
- c(s().importProfiles, e, "Import Profile"), s().importProfiles = s().importProfiles.filter((t) => t.id !== e);
404
+ deleteImportProfile: (e) => c("deleteImportProfile", () => {
405
+ u(i().importProfiles, e, "Import Profile"), i().importProfiles = i().importProfiles.filter((t) => t.id !== e);
338
406
  }),
339
- listProcessors: () => a("listProcessors", () => [...o].sort((e, t) => e.name.localeCompare(t.name))),
340
- listMappings: () => a("listMappings", () => S(s().mappings).map(h)),
341
- getMapping: (e) => a("getMapping", () => h(c(s().mappings, e, "Mapping"))),
342
- createMapping: (e) => a("createMapping", () => {
343
- g(s().mappings, e.name);
344
- const t = {
345
- id: R("mp"),
346
- content: structuredClone(e),
347
- revision: 1
348
- };
349
- return s().mappings.push(t), h(t);
407
+ listProcessors: () => c("listProcessors", () => [...p].sort((e, t) => e.name.localeCompare(t.name))),
408
+ listMappings: () => c("listMappings", () => B(i().mappings).map(M)),
409
+ getMapping: (e) => c("getMapping", () => M(u(i().mappings, e, "Mapping"))),
410
+ createMapping: (e) => c("createMapping", () => {
411
+ _(i().mappings, e.name);
412
+ const t = N("mp", e);
413
+ return h("mapping", t), i().mappings.push(t), M(t);
350
414
  }),
351
- updateMapping: (e, t, n) => a("updateMapping", () => {
352
- const i = c(s().mappings, e, "Mapping");
353
- return g(s().mappings, t.name, e), E(i, t, n), h(i);
415
+ updateMapping: (e, t, s) => c("updateMapping", () => {
416
+ const n = u(i().mappings, e, "Mapping");
417
+ return _(i().mappings, t.name, e), R(n, t, s), h("mapping", n), M(n);
354
418
  }),
355
- deleteMapping: (e) => a("deleteMapping", () => {
356
- c(s().mappings, e, "Mapping");
357
- const t = M((n) => n.mappingIds.includes(e));
419
+ deleteMapping: (e) => c("deleteMapping", () => {
420
+ u(i().mappings, e, "Mapping");
421
+ const t = k((s) => s.mappingIds.includes(e));
358
422
  if (t.length > 0)
359
- throw new O(
423
+ throw new J(
360
424
  t,
361
- `the Mapping is included by ${t.map((n) => n.name).join(", ")}`
425
+ `the Mapping is included by ${t.map((s) => s.name).join(", ")}`
362
426
  );
363
- s().mappings = s().mappings.filter((n) => n.id !== e);
427
+ i().mappings = i().mappings.filter((s) => s.id !== e);
364
428
  }),
365
- listMappingImportProfiles: (e) => a("listMappingImportProfiles", () => (c(s().mappings, e, "Mapping"), M((t) => t.mappingIds.includes(e)))),
366
- checkMappingBlueprintRelease: (e, t) => a("checkMappingBlueprintRelease", () => {
367
- const n = c(s().mappings, e, "Mapping"), i = d.find((l) => l.id === t);
368
- if (!i) throw new Error(`Blueprint Release ${t} not found`);
369
- if (i.blueprintId !== n.content.blueprintId)
429
+ listMappingImportProfiles: (e) => c("listMappingImportProfiles", () => (u(i().mappings, e, "Mapping"), k((t) => t.mappingIds.includes(e)))),
430
+ checkMappingBlueprintRelease: (e, t) => c("checkMappingBlueprintRelease", () => {
431
+ const s = u(i().mappings, e, "Mapping"), n = f.find((o) => o.id === t);
432
+ if (!n) throw new Error(`Blueprint Release ${t} not found`);
433
+ if (n.blueprintId !== s.content.blueprintId)
370
434
  throw new Error("the Release is of another Blueprint");
371
435
  return {
372
- blueprintId: i.blueprintId,
373
- missingFieldPaths: (n.content.fields ?? []).map((l) => String(l.name ?? "")).filter((l) => !i.fieldPaths.includes(l)),
436
+ blueprintId: n.blueprintId,
437
+ missingFieldPaths: (s.content.fields ?? []).map((o) => String(o.name ?? "")).filter((o) => !n.fieldPaths.includes(o)),
374
438
  missingReleaseSpecFields: []
375
439
  };
376
440
  }),
377
- listEntitySets: () => a("listEntitySets", () => S(s().entitySets).map(_)),
378
- getEntitySet: (e) => a("getEntitySet", () => _(c(s().entitySets, e, "Entity Set"))),
379
- createEntitySet: (e) => a("createEntitySet", () => {
380
- g(s().entitySets, e.name);
381
- const t = {
382
- id: R("es"),
383
- content: structuredClone(e),
384
- revision: 1
385
- };
386
- return s().entitySets.push(t), _(t);
441
+ listEntitySets: () => c("listEntitySets", () => B(i().entitySets).map($)),
442
+ getEntitySet: (e) => c("getEntitySet", () => $(u(i().entitySets, e, "Entity Set"))),
443
+ createEntitySet: (e) => c("createEntitySet", () => {
444
+ _(i().entitySets, e.name);
445
+ const t = N("es", e);
446
+ return h("entitySet", t), i().entitySets.push(t), $(t);
387
447
  }),
388
- updateEntitySet: (e, t, n) => a("updateEntitySet", () => {
389
- const i = c(s().entitySets, e, "Entity Set");
390
- return g(s().entitySets, t.name, e), E(i, t, n), _(i);
448
+ updateEntitySet: (e, t, s) => c("updateEntitySet", () => {
449
+ const n = u(i().entitySets, e, "Entity Set");
450
+ return _(i().entitySets, t.name, e), R(n, t, s), h("entitySet", n), $(n);
391
451
  }),
392
- deleteEntitySet: (e) => a("deleteEntitySet", () => {
393
- c(s().entitySets, e, "Entity Set");
394
- const t = M((n) => n.entitySetId === e);
452
+ deleteEntitySet: (e) => c("deleteEntitySet", () => {
453
+ u(i().entitySets, e, "Entity Set");
454
+ const t = k((s) => s.entitySetId === e);
395
455
  if (t.length > 0)
396
- throw new O(
456
+ throw new J(
397
457
  t,
398
- `the Entity Set is named by ${t.map((n) => n.name).join(", ")}`
458
+ `the Entity Set is named by ${t.map((s) => s.name).join(", ")}`
459
+ );
460
+ i().entitySets = i().entitySets.filter((s) => s.id !== e);
461
+ }),
462
+ cutRelease: (e, t, s) => c("cutRelease", () => {
463
+ const n = S(e), o = u(n.items, t, n.name);
464
+ if (H(o, s))
465
+ throw new j("the draft moved: somebody saved in between");
466
+ const l = y(n.reasons(o.content));
467
+ if (!l.valid) throw new j("the draft is invalid", l);
468
+ if (!O(o).draftDiffersFromRelease)
469
+ throw new j(
470
+ "the draft does not differ from the latest Release: there is nothing to release"
399
471
  );
400
- s().entitySets = s().entitySets.filter((n) => n.id !== e);
472
+ const m = o.releases.length + 1, g = {
473
+ id: `${o.id}_rel${m}`,
474
+ number: m,
475
+ revisionId: v(o).id,
476
+ releasedBy: b,
477
+ releasedAt: P()
478
+ };
479
+ return o.releases.push(g), {
480
+ release: g,
481
+ importProfiles: e === "mapping" ? k((d) => d.mappingIds.includes(t)) : []
482
+ };
483
+ }),
484
+ listHistory: (e, t, s) => c("listHistory", () => {
485
+ const n = S(e), o = u(n.items, t, n.name), l = [...o.revisions].reverse(), m = Number(s || "0");
486
+ return {
487
+ revisions: l.slice(m, m + 10).map((d) => ({
488
+ id: d.id,
489
+ savedBy: d.savedBy,
490
+ savedAt: d.savedAt,
491
+ validity: d.validity ?? y(n.reasons(d.content)),
492
+ restoredFromRevisionId: d.restoredFromRevisionId
493
+ })),
494
+ releases: [...o.releases].reverse(),
495
+ nextPageToken: m + 10 < l.length ? String(m + 10) : ""
496
+ };
497
+ }),
498
+ compareRevisions: (e, t, s, n) => c("compareRevisions", () => {
499
+ const o = S(e), l = u(o.items, t, o.name), m = G(x(l, s).content), g = G(x(l, n).content), d = [.../* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(g)])].map((z) => {
500
+ const A = m[z], T = g[z], Q = A === void 0 && T !== void 0 ? "added" : A !== void 0 && T === void 0 ? "removed" : JSON.stringify(A) === JSON.stringify(T) ? "unchanged" : "changed";
501
+ return { field: z, status: Q };
502
+ });
503
+ return {
504
+ from: { revisionId: s, content: m },
505
+ to: { revisionId: n, content: g },
506
+ fields: d
507
+ };
508
+ }),
509
+ restoreRevision: (e, t, s, n) => c("restoreRevision", () => {
510
+ const o = S(e), l = u(o.items, t, o.name);
511
+ R(l, x(l, s).content, n, s), h(e, l);
401
512
  })
402
513
  };
403
514
  }
404
- function X(r = x()) {
515
+ function ue(r = Z()) {
405
516
  return {
406
517
  async listBlueprints() {
407
- return [...new Map(r.map((o) => [o.blueprintId, o.blueprintName]))].map(([o, d]) => ({ id: o, name: d })).sort((o, d) => o.name.localeCompare(d.name));
518
+ return [...new Map(r.map((p) => [p.blueprintId, p.blueprintName]))].map(([p, f]) => ({ id: p, name: f })).sort((p, f) => p.name.localeCompare(f.name));
408
519
  },
409
- async listReleases(p) {
410
- return r.filter((o) => o.blueprintId === p).map((o) => ({ id: o.id, label: o.label }));
520
+ async listReleases(a) {
521
+ return r.filter((p) => p.blueprintId === a).map((p) => ({ id: p.id, label: p.label }));
411
522
  }
412
523
  };
413
524
  }
414
525
  export {
415
- V as STUB_OTHER_WORKSPACE_ID,
416
- z as STUB_USER_ID,
417
- k as STUB_WORKSPACE_ID,
418
- X as createStubBlueprints,
419
- Q as createStubImporthubClient,
420
- x as stubBlueprintReleases,
421
- D as stubEntitySets,
422
- J as stubIdentity,
423
- W as stubImportProfiles,
424
- U as stubMappings,
425
- L as stubProcessors
526
+ ce as STUB_OTHER_WORKSPACE_ID,
527
+ b as STUB_USER_ID,
528
+ D as STUB_WORKSPACE_ID,
529
+ ue as createStubBlueprints,
530
+ de as createStubImporthubClient,
531
+ Z as stubBlueprintReleases,
532
+ te as stubEntitySets,
533
+ me as stubIdentity,
534
+ se as stubImportProfiles,
535
+ ee as stubMappings,
536
+ ne as stubProcessors
426
537
  };
427
538
  //# sourceMappingURL=testing.js.map