@knkcs/importhub-ui 0.1.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/CHANGELOG.md +14 -0
- package/README.md +17 -4
- package/dist/importhub-client-CrS-3Zuu.js +23 -0
- package/dist/importhub-client-CrS-3Zuu.js.map +1 -0
- package/dist/index.d.ts +883 -13
- package/dist/index.js +2408 -95
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +309 -14
- package/dist/testing.js +522 -41
- package/dist/testing.js.map +1 -1
- package/package.json +10 -2
package/dist/testing.js
CHANGED
|
@@ -1,57 +1,538 @@
|
|
|
1
|
-
import { createHostMembers as
|
|
2
|
-
|
|
3
|
-
|
|
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) {
|
|
4
5
|
return {
|
|
5
|
-
userId:
|
|
6
|
-
workspaceId:
|
|
7
|
-
members:
|
|
8
|
-
{ userId:
|
|
6
|
+
userId: b,
|
|
7
|
+
workspaceId: r,
|
|
8
|
+
members: X([
|
|
9
|
+
{ userId: b, displayName: "Ada Importer", email: "ada@example.com" }
|
|
9
10
|
])
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function Z() {
|
|
13
14
|
return [
|
|
14
|
-
{
|
|
15
|
-
|
|
15
|
+
{
|
|
16
|
+
id: "br_stub_gesetz_2",
|
|
17
|
+
blueprintId: "bp_stub_gesetz",
|
|
18
|
+
blueprintName: "Gesetz",
|
|
19
|
+
label: "Release 2",
|
|
20
|
+
fieldPaths: ["titel", "abkuerzung"]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "br_stub_gesetz_1",
|
|
24
|
+
blueprintId: "bp_stub_gesetz",
|
|
25
|
+
blueprintName: "Gesetz",
|
|
26
|
+
label: "Release 1",
|
|
27
|
+
fieldPaths: ["titel", "abkuerzung", "fussnote"]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "br_stub_entscheidung_1",
|
|
31
|
+
blueprintId: "bp_stub_entscheidung",
|
|
32
|
+
blueprintName: "Entscheidung",
|
|
33
|
+
label: "Release 1",
|
|
34
|
+
fieldPaths: ["aktenzeichen", "datum"]
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function ee() {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
id: "mp_stub_norm",
|
|
42
|
+
releaseNumber: 1,
|
|
43
|
+
content: {
|
|
44
|
+
name: "Gesetz norms",
|
|
45
|
+
description: "One Content per norm",
|
|
46
|
+
blueprintId: "bp_stub_gesetz",
|
|
47
|
+
blueprintReleaseId: "br_stub_gesetz_1",
|
|
48
|
+
elementSelector: "//norm",
|
|
49
|
+
sourceKey: { selector: "@id" },
|
|
50
|
+
fields: [
|
|
51
|
+
{ name: "titel", selector: "titel", type: "text" },
|
|
52
|
+
{ name: "fussnote", selector: "fn", type: "text" }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "mp_stub_decision",
|
|
58
|
+
content: {
|
|
59
|
+
name: "Court decisions",
|
|
60
|
+
description: "",
|
|
61
|
+
blueprintId: "bp_stub_entscheidung",
|
|
62
|
+
blueprintReleaseId: "br_stub_entscheidung_1",
|
|
63
|
+
elementSelector: "",
|
|
64
|
+
sourceKey: {},
|
|
65
|
+
fields: []
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
function te() {
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
id: "es_stub_latin1",
|
|
74
|
+
releaseNumber: 1,
|
|
75
|
+
content: {
|
|
76
|
+
name: "ISO Latin 1",
|
|
77
|
+
description: "The Latin-1 entities Boorberg's files use",
|
|
78
|
+
entities: { auml: "ä", nbsp: " " }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
function se() {
|
|
84
|
+
return [
|
|
85
|
+
{
|
|
86
|
+
id: "ip_stub_gesetz",
|
|
87
|
+
releaseNumber: 2,
|
|
88
|
+
content: {
|
|
89
|
+
name: "Boorberg gesetz",
|
|
90
|
+
description: "Boorberg's law files",
|
|
91
|
+
entitySetId: "es_stub_latin1",
|
|
92
|
+
preprocessors: [{ processor: "rename-element", settings: { from: "para", to: "absatz" } }],
|
|
93
|
+
mappingIds: ["mp_stub_norm"],
|
|
94
|
+
postProcessors: [],
|
|
95
|
+
autoPublish: !1,
|
|
96
|
+
deleteSourceFileOnSuccess: !0
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "ip_stub_vrpml",
|
|
101
|
+
content: {
|
|
102
|
+
name: "VRPML court decisions",
|
|
103
|
+
description: "",
|
|
104
|
+
entitySetId: "",
|
|
105
|
+
preprocessors: [],
|
|
106
|
+
mappingIds: ["mp_stub_decision"],
|
|
107
|
+
postProcessors: [],
|
|
108
|
+
autoPublish: !1,
|
|
109
|
+
deleteSourceFileOnSuccess: !1
|
|
110
|
+
}
|
|
111
|
+
}
|
|
16
112
|
];
|
|
17
113
|
}
|
|
18
|
-
|
|
19
|
-
|
|
114
|
+
const F = (r, a, p, f = "") => ({
|
|
115
|
+
field_type: "text",
|
|
116
|
+
config: { name: a, api_accessor: r, required: p, instructions: f },
|
|
117
|
+
system: !1
|
|
118
|
+
});
|
|
119
|
+
function ne() {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
name: "citation-links",
|
|
123
|
+
kind: "post_processor",
|
|
124
|
+
target: "source_file",
|
|
125
|
+
description: "Links citations in rich text to the Content they name, through legalcitationhub.",
|
|
126
|
+
settingsSpec: []
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "norm-cite",
|
|
130
|
+
kind: "preprocessor",
|
|
131
|
+
target: "rich_text_field",
|
|
132
|
+
description: "Marks legal norm citations in one rich-text field.",
|
|
133
|
+
settingsSpec: []
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "rename-element",
|
|
137
|
+
kind: "preprocessor",
|
|
138
|
+
target: "source_file",
|
|
139
|
+
description: "Renames every element of one name to another.",
|
|
140
|
+
settingsSpec: [
|
|
141
|
+
F("from", "Element", !0, "The element's name now."),
|
|
142
|
+
F("to", "New name", !0)
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "sentence-detect",
|
|
147
|
+
kind: "preprocessor",
|
|
148
|
+
target: "source_file",
|
|
149
|
+
description: "Wraps each sentence of an element in its own element.",
|
|
150
|
+
settingsSpec: [F("element", "Element", !1)]
|
|
151
|
+
}
|
|
152
|
+
];
|
|
20
153
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
154
|
+
const ie = [
|
|
155
|
+
"listImportProfiles",
|
|
156
|
+
"getImportProfile",
|
|
157
|
+
"createImportProfile",
|
|
158
|
+
"updateImportProfile",
|
|
159
|
+
"deleteImportProfile",
|
|
160
|
+
"listProcessors",
|
|
161
|
+
"listMappings",
|
|
162
|
+
"getMapping",
|
|
163
|
+
"createMapping",
|
|
164
|
+
"updateMapping",
|
|
165
|
+
"deleteMapping",
|
|
166
|
+
"listMappingImportProfiles",
|
|
167
|
+
"checkMappingBlueprintRelease",
|
|
168
|
+
"listEntitySets",
|
|
169
|
+
"getEntitySet",
|
|
170
|
+
"createEntitySet",
|
|
171
|
+
"updateEntitySet",
|
|
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 } } : {}
|
|
24
202
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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) => ({
|
|
206
|
+
valid: r.length === 0,
|
|
207
|
+
reasons: r
|
|
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(
|
|
212
|
+
Object.entries(
|
|
213
|
+
r.workspaces ?? {
|
|
214
|
+
[D]: {
|
|
215
|
+
importProfiles: se(),
|
|
216
|
+
mappings: ee(),
|
|
217
|
+
entitySets: te()
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
).map(([e, t]) => [
|
|
221
|
+
e,
|
|
222
|
+
{
|
|
223
|
+
importProfiles: K(t.importProfiles),
|
|
224
|
+
mappings: K(t.mappings),
|
|
225
|
+
entitySets: K(t.entitySets)
|
|
226
|
+
}
|
|
227
|
+
])
|
|
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;
|
|
232
|
+
return structuredClone(t());
|
|
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) => {
|
|
238
|
+
if (!t.trim()) throw new Error("a name is required");
|
|
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))
|
|
242
|
+
throw new Error("the draft moved: somebody saved in between");
|
|
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
|
+
};
|
|
32
266
|
};
|
|
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({
|
|
270
|
+
path: "/blueprintReleaseId",
|
|
271
|
+
code: "release_of_other_blueprint",
|
|
272
|
+
message: "The pinned Release is of another Blueprint."
|
|
273
|
+
}) : t.push({
|
|
274
|
+
path: "/blueprintReleaseId",
|
|
275
|
+
code: "blueprint_gone",
|
|
276
|
+
message: "blueprinthub does not know the Blueprint Release it pins."
|
|
277
|
+
}) : t.push({
|
|
278
|
+
path: "/blueprintReleaseId",
|
|
279
|
+
code: "no_blueprint_release",
|
|
280
|
+
message: "It pins no Blueprint Release."
|
|
281
|
+
}), e.elementSelector || t.push({
|
|
282
|
+
path: "/elementSelector",
|
|
283
|
+
code: "no_element_selector",
|
|
284
|
+
message: "It has no element selector."
|
|
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}`,
|
|
289
|
+
code: "unknown_field_path",
|
|
290
|
+
message: `The pinned Release has no field ${l}.`
|
|
291
|
+
});
|
|
292
|
+
}), t;
|
|
293
|
+
}
|
|
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" ? [
|
|
298
|
+
{
|
|
299
|
+
path: l,
|
|
300
|
+
code: "rich_text_processor",
|
|
301
|
+
message: `${m.name} is configured on a rich-text field, not on a Profile.`
|
|
302
|
+
}
|
|
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}`,
|
|
307
|
+
code: "invalid_processor_settings",
|
|
308
|
+
message: `${m.name}: ${d.config.api_accessor} is required.`
|
|
309
|
+
})) : [
|
|
310
|
+
{ path: l, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
|
|
311
|
+
];
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function L(e) {
|
|
315
|
+
const t = i(), s = [
|
|
316
|
+
...U(e.preprocessors, "preprocessors", "preprocessor"),
|
|
317
|
+
...U(e.postProcessors, "postProcessors", "post_processor")
|
|
318
|
+
];
|
|
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}`,
|
|
324
|
+
code: "mapping_missing",
|
|
325
|
+
message: "It includes a Mapping that does not exist."
|
|
326
|
+
});
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const m = C(l.content);
|
|
330
|
+
m.length > 0 && s.push({
|
|
331
|
+
path: `/mappingIds/${o}`,
|
|
332
|
+
code: "mapping_invalid",
|
|
333
|
+
message: `The Mapping ${l.content.name} is invalid: ${m.map((g) => g.message).join(" ")}`
|
|
334
|
+
});
|
|
335
|
+
}), e.entitySetId && !t.entitySets.some((n) => n.id === e.entitySetId) && s.push({
|
|
336
|
+
path: "/entitySetId",
|
|
337
|
+
code: "entity_set_missing",
|
|
338
|
+
message: "It names an Entity Set that does not exist."
|
|
339
|
+
}), s;
|
|
340
|
+
}
|
|
341
|
+
const W = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], E = (e) => ({
|
|
342
|
+
id: e.id,
|
|
343
|
+
content: e.content,
|
|
344
|
+
validity: y(L(e.content)),
|
|
345
|
+
state: O(e)
|
|
346
|
+
}), M = (e) => ({
|
|
347
|
+
id: e.id,
|
|
348
|
+
content: e.content,
|
|
349
|
+
validity: y(C(e.content)),
|
|
350
|
+
state: O(e)
|
|
351
|
+
}), $ = (e) => ({
|
|
352
|
+
id: e.id,
|
|
353
|
+
content: e.content,
|
|
354
|
+
validity: y(W(e.content)),
|
|
355
|
+
state: O(e)
|
|
356
|
+
}), k = (e) => B(i().importProfiles.filter((t) => e(t.content))).map((t) => ({
|
|
357
|
+
id: t.id,
|
|
358
|
+
name: t.content.name
|
|
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
|
+
};
|
|
388
|
+
return {
|
|
389
|
+
calls: w,
|
|
390
|
+
switchWorkspace(e) {
|
|
391
|
+
I = e;
|
|
392
|
+
},
|
|
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);
|
|
399
|
+
}),
|
|
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);
|
|
403
|
+
}),
|
|
404
|
+
deleteImportProfile: (e) => c("deleteImportProfile", () => {
|
|
405
|
+
u(i().importProfiles, e, "Import Profile"), i().importProfiles = i().importProfiles.filter((t) => t.id !== e);
|
|
406
|
+
}),
|
|
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);
|
|
414
|
+
}),
|
|
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);
|
|
418
|
+
}),
|
|
419
|
+
deleteMapping: (e) => c("deleteMapping", () => {
|
|
420
|
+
u(i().mappings, e, "Mapping");
|
|
421
|
+
const t = k((s) => s.mappingIds.includes(e));
|
|
422
|
+
if (t.length > 0)
|
|
423
|
+
throw new J(
|
|
424
|
+
t,
|
|
425
|
+
`the Mapping is included by ${t.map((s) => s.name).join(", ")}`
|
|
426
|
+
);
|
|
427
|
+
i().mappings = i().mappings.filter((s) => s.id !== e);
|
|
428
|
+
}),
|
|
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)
|
|
434
|
+
throw new Error("the Release is of another Blueprint");
|
|
435
|
+
return {
|
|
436
|
+
blueprintId: n.blueprintId,
|
|
437
|
+
missingFieldPaths: (s.content.fields ?? []).map((o) => String(o.name ?? "")).filter((o) => !n.fieldPaths.includes(o)),
|
|
438
|
+
missingReleaseSpecFields: []
|
|
439
|
+
};
|
|
440
|
+
}),
|
|
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);
|
|
447
|
+
}),
|
|
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);
|
|
451
|
+
}),
|
|
452
|
+
deleteEntitySet: (e) => c("deleteEntitySet", () => {
|
|
453
|
+
u(i().entitySets, e, "Entity Set");
|
|
454
|
+
const t = k((s) => s.entitySetId === e);
|
|
455
|
+
if (t.length > 0)
|
|
456
|
+
throw new J(
|
|
457
|
+
t,
|
|
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"
|
|
471
|
+
);
|
|
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);
|
|
512
|
+
})
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function ue(r = Z()) {
|
|
33
516
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
() => [...n().importProfiles ?? []].sort((t, s) => t.name.localeCompare(s.name))
|
|
41
|
-
),
|
|
42
|
-
listEntitySets: () => a(
|
|
43
|
-
"listEntitySets",
|
|
44
|
-
() => [...n().entitySets ?? []].sort((t, s) => t.name.localeCompare(s.name))
|
|
45
|
-
)
|
|
517
|
+
async listBlueprints() {
|
|
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));
|
|
519
|
+
},
|
|
520
|
+
async listReleases(a) {
|
|
521
|
+
return r.filter((p) => p.blueprintId === a).map((p) => ({ id: p.id, label: p.label }));
|
|
522
|
+
}
|
|
46
523
|
};
|
|
47
524
|
}
|
|
48
525
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
56
537
|
};
|
|
57
538
|
//# sourceMappingURL=testing.js.map
|