@knkcs/importhub-ui 0.3.0 → 0.5.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.
@@ -0,0 +1,497 @@
1
+ import { JSX } from 'react';
2
+ import { Schema } from '@knkcs/fieldkit/schema';
3
+
4
+ /** What moving a Mapping's draft to another Blueprint Release would lose. */
5
+ declare interface BlueprintReleaseCheck {
6
+ blueprintId: string;
7
+ /** Every mapped field path the Release does not have. */
8
+ missingFieldPaths: string[];
9
+ /** Every Release Spec field read or matched on that it does not have. */
10
+ missingReleaseSpecFields: string[];
11
+ }
12
+
13
+ /** What happens to a Changed Version (importhub.v1.ChangedVersionHandling). */
14
+ declare type ChangedVersionHandling = "CHANGED_VERSION_HANDLING_UNSPECIFIED" | "CHANGED_VERSION_HANDLING_CORRECT" | "CHANGED_VERSION_HANDLING_KEEP" | "CHANGED_VERSION_HANDLING_FAIL";
15
+
16
+ /** Two Revisions of one configuration, and how each top-level field differs. */
17
+ declare interface ConfigurationComparison {
18
+ from: ConfigurationVersion;
19
+ to: ConfigurationVersion;
20
+ fields: {
21
+ field: string;
22
+ status: FieldComparisonStatus;
23
+ }[];
24
+ }
25
+
26
+ /** One page of a configuration's history. */
27
+ declare interface ConfigurationHistoryPage {
28
+ /** This page's Revisions, newest first. */
29
+ revisions: ConfigurationRevision[];
30
+ /** Every Release, newest first, on every page. */
31
+ releases: ConfigurationReleaseRecord[];
32
+ /** The token of the next page; "" on the last. */
33
+ nextPageToken: string;
34
+ }
35
+
36
+ /** The kinds of versioned configuration (ADR 0016). */
37
+ declare type ConfigurationKind = "importProfile" | "mapping" | "entitySet";
38
+
39
+ /** A Configuration Release, as a list names it: "Release 3". */
40
+ declare interface ConfigurationRelease {
41
+ id: string;
42
+ number: number;
43
+ }
44
+
45
+ /** A Configuration Release as the history lists it: who cut it, when, from what. */
46
+ declare interface ConfigurationReleaseRecord extends ConfigurationRelease {
47
+ /** The Revision it pins. */
48
+ revisionId: string;
49
+ /** The odon user id of the admin who cut it. */
50
+ releasedBy: string;
51
+ /** When it was cut, as an ISO 8601 timestamp. */
52
+ releasedAt: string;
53
+ }
54
+
55
+ /** One saved Revision of a configuration, as its history lists it. */
56
+ declare interface ConfigurationRevision {
57
+ id: string;
58
+ /** The odon user id of who saved it; the host's members name them. */
59
+ savedBy: string;
60
+ /** When it was saved, as an ISO 8601 timestamp. */
61
+ savedAt: string;
62
+ /** Whether it could be released, as decided when it was saved. */
63
+ validity: Validity;
64
+ /** The Revision it restored; "" for an ordinary save. */
65
+ restoredFromRevisionId: string;
66
+ }
67
+
68
+ /** Where a configuration stands: its draft and its latest Release. */
69
+ declare interface ConfigurationState {
70
+ draftRevisionId: string;
71
+ /** Unset while the configuration has none. */
72
+ latestRelease?: ConfigurationRelease;
73
+ /** True when the draft differs from the latest Release, and while there is none. */
74
+ draftDiffersFromRelease: boolean;
75
+ }
76
+
77
+ /**
78
+ * One side of a comparison: a Revision's content, keyed as importhub keys
79
+ * the compared fields (the proto's field names, such as `mapping_ids`).
80
+ */
81
+ declare interface ConfigurationVersion {
82
+ revisionId: string;
83
+ content: Record<string, unknown>;
84
+ }
85
+
86
+ /** One configuration of a kind, at its draft. */
87
+ declare interface Configured<C> {
88
+ id: string;
89
+ /** The draft's content. */
90
+ content: C;
91
+ /**
92
+ * Whether it is valid now: for Profiles and Mappings the service's
93
+ * `current_validity`, which counts what changed since the save (an
94
+ * included Mapping turned invalid, a Blueprint gone); for Entity Sets the
95
+ * validity as saved, the only one they have.
96
+ */
97
+ validity: Validity;
98
+ state: ConfigurationState;
99
+ }
100
+
101
+ /** A Release cut, and for a Mapping the Import Profiles that take it. */
102
+ declare interface CutReleaseResult {
103
+ release: ConfigurationReleaseRecord;
104
+ /** The Profiles that include the Mapping; empty for other kinds. */
105
+ importProfiles: ImportProfileRef[];
106
+ }
107
+
108
+ declare type EntitySet = Configured<EntitySetContent>;
109
+
110
+ /** What an admin edits of an Entity Set. */
111
+ declare interface EntitySetContent {
112
+ name: string;
113
+ description: string;
114
+ /** Entity names without `&` and `;`, to the text each stands for. */
115
+ entities: Record<string, string>;
116
+ }
117
+
118
+ declare type FieldComparisonStatus = "unchanged" | "added" | "removed" | "changed";
119
+
120
+ /** One run of an Import Profile's Release over one Source File. */
121
+ declare interface Import {
122
+ id: string;
123
+ importProfileId: string;
124
+ /** The Profile's name when the Import started. */
125
+ importProfileName: string;
126
+ sourceFileId: string;
127
+ /** The odon user id of who started it; the host's members name them. */
128
+ startedBy: string;
129
+ phase: ImportPhase;
130
+ /** Unset until it has ended. */
131
+ outcome?: ImportOutcome;
132
+ /** Why it Failed, as importhub words it; "" otherwise. */
133
+ failureReason: string;
134
+ /** How far the current phase is: done of total, both 0 while unknown. */
135
+ progress: {
136
+ done: number;
137
+ total: number;
138
+ };
139
+ counts: ImportCounts;
140
+ /** The contenthub Change Set it fills; "" until it opened one. */
141
+ changeSetId: string;
142
+ /** The exact Releases it runs with, pinned at Start (release-a-configuration:AC8). */
143
+ releases: {
144
+ importProfile?: ImportReleaseRef;
145
+ /** In the Profile's order. */
146
+ mappings: ImportReleaseRef[];
147
+ /** Unset when the Profile names no Entity Set. */
148
+ entitySet?: ImportReleaseRef;
149
+ };
150
+ /** ISO 8601 timestamps; start and end "" until they happen. */
151
+ createTime: string;
152
+ startTime: string;
153
+ endTime: string;
154
+ /** The odon user id of who cancelled it, as soon as they asked; "" for nobody. */
155
+ cancelledBy: string;
156
+ /** YYYY-MM-DD, or "" for none. */
157
+ effectiveDate: string;
158
+ source?: ImportSource;
159
+ }
160
+
161
+ /** What an Import has done (importhub.v1.ImportCounts). */
162
+ declare interface ImportCounts {
163
+ /** Source Versions its Mappings matched. */
164
+ matched: number;
165
+ /** Content it created. */
166
+ created: number;
167
+ /** Item Problems: Source Versions it skipped. */
168
+ problems: number;
169
+ /** New Planned Releases of Content that exists. */
170
+ planned: number;
171
+ /** Changed Versions planned as corrections. */
172
+ corrected: number;
173
+ /** Changed Versions kept. */
174
+ kept: number;
175
+ /** Source Versions already in contenthub. */
176
+ unchanged: number;
177
+ }
178
+
179
+ /**
180
+ * What the screens ask of importhub. Every call acts on the caller's
181
+ * workspace, which importhub takes from the token's active workspace and
182
+ * never from an argument: a host switches workspace by switching the token.
183
+ * An update names the draft it was made on, and is refused when somebody
184
+ * saved in between.
185
+ */
186
+ declare interface ImporthubClient {
187
+ /** Every Import Profile of the workspace, by name. */
188
+ listImportProfiles(): Promise<ImportProfile[]>;
189
+ getImportProfile(id: string): Promise<ImportProfile>;
190
+ createImportProfile(content: ImportProfileContent): Promise<ImportProfile>;
191
+ updateImportProfile(id: string, content: ImportProfileContent, draftRevisionId: string): Promise<ImportProfile>;
192
+ deleteImportProfile(id: string): Promise<void>;
193
+ /** The Processor catalogue, by name; the same in every workspace. */
194
+ listProcessors(): Promise<Processor[]>;
195
+ /** Every Mapping of the workspace, by name. */
196
+ listMappings(): Promise<Mapping[]>;
197
+ getMapping(id: string): Promise<Mapping>;
198
+ createMapping(content: MappingContent): Promise<Mapping>;
199
+ updateMapping(id: string, content: MappingContent, draftRevisionId: string): Promise<Mapping>;
200
+ /** Throws ConfigurationInUseError while a Profile includes it. */
201
+ deleteMapping(id: string): Promise<void>;
202
+ /** The Import Profiles whose draft or latest Release includes it. */
203
+ listMappingImportProfiles(id: string): Promise<ImportProfileRef[]>;
204
+ /** Checks moving the draft to another Blueprint Release, saving nothing. */
205
+ checkMappingBlueprintRelease(id: string, blueprintReleaseId: string): Promise<BlueprintReleaseCheck>;
206
+ /** Every Entity Set of the workspace, by name. */
207
+ listEntitySets(): Promise<EntitySet[]>;
208
+ getEntitySet(id: string): Promise<EntitySet>;
209
+ createEntitySet(content: EntitySetContent): Promise<EntitySet>;
210
+ updateEntitySet(id: string, content: EntitySetContent, draftRevisionId: string): Promise<EntitySet>;
211
+ /** Throws ConfigurationInUseError while a Profile names it. */
212
+ deleteEntitySet(id: string): Promise<void>;
213
+ /**
214
+ * Cuts a Configuration Release from the draft named. Throws
215
+ * ReleaseRefusedError, with the reasons when the draft is invalid.
216
+ */
217
+ cutRelease(kind: ConfigurationKind, id: string, draftRevisionId: string): Promise<CutReleaseResult>;
218
+ /** One page of the history; pageToken "" for the first. */
219
+ listHistory(kind: ConfigurationKind, id: string, pageToken: string): Promise<ConfigurationHistoryPage>;
220
+ compareRevisions(kind: ConfigurationKind, id: string, fromRevisionId: string, toRevisionId: string): Promise<ConfigurationComparison>;
221
+ /** Saves an older Revision's content as a new draft, on the draft named. */
222
+ restoreRevision(kind: ConfigurationKind, id: string, revisionId: string, draftRevisionId: string): Promise<void>;
223
+ /**
224
+ * Uploads one file as a Source File: importhub hands out a direct upload
225
+ * URL into its blob store, and the file goes there, not through importhub
226
+ * (start-an-import:AC1). `onProgress` hears the share sent, 0 to 1.
227
+ */
228
+ uploadSourceFile(file: File, onProgress: (fraction: number) => void): Promise<SourceFile>;
229
+ /** Queues an Import. Throws StartRefusedError, with importhub's reason. */
230
+ startImport(input: StartImportInput): Promise<Import>;
231
+ /** One page of the workspace's Imports, newest first; pageToken "" for the first. */
232
+ listImports(pageToken: string): Promise<ImportsPage>;
233
+ getImport(id: string): Promise<Import>;
234
+ /** Asks a queued or running Import to stop; returns it as it is now. */
235
+ cancelImport(id: string): Promise<Import>;
236
+ listItemProblems(importId: string, filter: ItemProblemsFilter): Promise<ItemProblemsPage>;
237
+ }
238
+
239
+ /** How an Import ended (importhub.v1.ImportOutcome, CONTEXT.md "Import Outcome"). */
240
+ declare type ImportOutcome = "succeeded" | "succeeded_with_problems" | "failed" | "cancelled";
241
+
242
+ /** Where an Import is (importhub.v1.ImportPhase). */
243
+ declare type ImportPhase = "queued" | "reading" | "writing" | "ended";
244
+
245
+ declare type ImportProfile = Configured<ImportProfileContent>;
246
+
247
+ /** What an admin edits of an Import Profile. */
248
+ declare interface ImportProfileContent {
249
+ name: string;
250
+ description: string;
251
+ /** The Entity Set the Source File is read with; "" for none. */
252
+ entitySetId: string;
253
+ /** In the order they run. */
254
+ preprocessors: ProcessorStep[];
255
+ /** The Mappings it includes, by id, in the order they run. */
256
+ mappingIds: string[];
257
+ /** In the order they run. */
258
+ postProcessors: ProcessorStep[];
259
+ autoPublish: boolean;
260
+ deleteSourceFileOnSuccess: boolean;
261
+ }
262
+
263
+ /** An Import Profile, named where another configuration is used. */
264
+ declare interface ImportProfileRef {
265
+ id: string;
266
+ name: string;
267
+ }
268
+
269
+ /** One Configuration Release an Import runs with, named as it was then. */
270
+ declare interface ImportReleaseRef {
271
+ configurationId: string;
272
+ /** The configuration's name in that Release. */
273
+ name: string;
274
+ releaseId: string;
275
+ /** "Release 3". */
276
+ number: number;
277
+ }
278
+
279
+ /** The publication that triggered an Import: such as 2026-09-20, "BGBl. 2026 I Nr. 270". */
280
+ declare interface ImportSource {
281
+ /** The day it was published, as YYYY-MM-DD. */
282
+ date: string;
283
+ /** How it is cited. */
284
+ reference: string;
285
+ }
286
+
287
+ /** One page of the workspace's Imports, newest first. */
288
+ declare interface ImportsPage {
289
+ imports: Import[];
290
+ /** "" on the last page. */
291
+ nextPageToken: string;
292
+ }
293
+
294
+ /** One Source Version an Import could not save and skipped (CONTEXT.md "Item Problem"). */
295
+ declare interface ItemProblem {
296
+ id: string;
297
+ mappingId: string;
298
+ /** The Mapping's name in the Release the Import ran. */
299
+ mappingName: string;
300
+ /** "" when the element has none. */
301
+ sourceKey: string;
302
+ /** A /-separated path in the Content's data; "" for the Source Version as a whole. */
303
+ field: string;
304
+ /** Why, as importhub words it. */
305
+ reason: string;
306
+ }
307
+
308
+ /** How an Import's Item Problems are filtered: by Mapping, and by Source Key. */
309
+ declare interface ItemProblemsFilter {
310
+ /** "" for every Mapping. */
311
+ mappingId: string;
312
+ /** Matches Source Keys that contain it, ignoring case; "" for all. */
313
+ sourceKeyQuery: string;
314
+ /** "" for the first page. */
315
+ pageToken: string;
316
+ }
317
+
318
+ /** One page of an Import's Item Problems, with their counts. */
319
+ declare interface ItemProblemsPage {
320
+ itemProblems: ItemProblem[];
321
+ /** Every Item Problem of the Import, whatever the filter. */
322
+ totalCount: number;
323
+ /** The Item Problems the filter matches, on every page. */
324
+ matchingCount: number;
325
+ /** Every Mapping with Item Problems and how many, whatever the filter. */
326
+ mappings: {
327
+ mappingId: string;
328
+ mappingName: string;
329
+ count: number;
330
+ }[];
331
+ /** "" on the last page. */
332
+ nextPageToken: string;
333
+ }
334
+
335
+ declare type Mapping = Configured<MappingContent>;
336
+
337
+ /**
338
+ * What an admin edits of a Mapping, in the JSON shape of importhub.v1's
339
+ * MappingContent: its camelCase keys, enums by their names
340
+ * (`CHANGED_VERSION_HANDLING_KEEP`), unset settings left out. The settings are
341
+ * typed as the structured editor (F4) edits them; every key travels through
342
+ * as given, typed or not, so a save never drops one a screen does not show.
343
+ */
344
+ declare interface MappingContent {
345
+ name: string;
346
+ description?: string;
347
+ blueprintId: string;
348
+ blueprintReleaseId: string;
349
+ elementSelector?: string;
350
+ sourceKey?: {
351
+ selector?: string;
352
+ template?: string;
353
+ extractPattern?: string;
354
+ /** `-` when unset; "" joins the groups with nothing. */
355
+ extractSeparator?: string;
356
+ normalize?: boolean;
357
+ [key: string]: unknown;
358
+ };
359
+ /** Each an xmlmapper FieldMapping; `name` is the field path. */
360
+ fields?: Array<Record<string, unknown>>;
361
+ versionMatch?: {
362
+ validityPeriod?: boolean;
363
+ releaseSpecFields?: string[];
364
+ contentFields?: string[];
365
+ };
366
+ validityPeriod?: {
367
+ validFromSelector?: string;
368
+ validToSelector?: string;
369
+ dateFormats?: string[];
370
+ };
371
+ releaseSpec?: Array<{
372
+ field?: string;
373
+ selector?: string;
374
+ }>;
375
+ /** Unset: Correct. */
376
+ changedVersion?: ChangedVersionHandling;
377
+ stub?: boolean;
378
+ titleContributions?: Array<{
379
+ selector?: string;
380
+ ausgabeCodeSelector?: string;
381
+ referenceSpecValues?: Array<{
382
+ field?: string;
383
+ selector?: string;
384
+ }>;
385
+ referenceFilterSelector?: string;
386
+ intent?: TitleIntent;
387
+ intentTextSelector?: string;
388
+ }>;
389
+ collectionRouting?: {
390
+ selector?: string;
391
+ collectionMap?: Record<string, string>;
392
+ idPattern?: string;
393
+ collectionTemplate?: string;
394
+ suffix?: string;
395
+ fallback?: string;
396
+ };
397
+ collections?: string[];
398
+ displayNameTemplate?: string;
399
+ placeholderAssets?: Array<{
400
+ selector?: string;
401
+ assetType?: string;
402
+ keyParts?: string[];
403
+ nameSelector?: string;
404
+ descriptionSelector?: string;
405
+ metadata?: Record<string, string>;
406
+ folderRoot?: string;
407
+ folderPathSelector?: string;
408
+ }>;
409
+ [key: string]: unknown;
410
+ }
411
+
412
+ /**
413
+ * The structured Mapping editor (edit-a-mapping-in-the-structured-editor):
414
+ * a Mapping's page, as `MappingDetail` shows it, with the editor's tabs
415
+ * between Settings and History. Fields shows the pinned Release's field tree
416
+ * and the selected field's form with its Advanced (JSON); Source Key &
417
+ * Source Versions and Output hold the Mapping-level settings. Every tab edits one
418
+ * form over the whole content and saves with the header's one Save, and the
419
+ * reasons importhub gives for an invalid draft show at the fields they
420
+ * concern. The field tree comes from the host's
421
+ * `ImporthubBlueprints.getRelease`.
422
+ *
423
+ * From `@knkcs/importhub-ui/mapping-editor`, which a host loads lazily, so a
424
+ * host that never opens a Mapping never loads the editor (knkcms/core
425
+ * ADR 0003).
426
+ */
427
+ export declare function MappingEditor({ client, id, onDeleted }: MappingEditorProps): JSX.Element;
428
+
429
+ export declare interface MappingEditorProps {
430
+ client: ImporthubClient;
431
+ /** The Mapping's id. */
432
+ id: string;
433
+ /** It was deleted: the host leaves its page. */
434
+ onDeleted: () => void;
435
+ }
436
+
437
+ /** One entry of the Processor catalogue. */
438
+ declare interface Processor {
439
+ /** How a Profile names it, such as `entity-element`. */
440
+ name: string;
441
+ kind: ProcessorKind;
442
+ /** What it works on: a Profile lists only `source_file` ones. */
443
+ target: ProcessorTarget;
444
+ /** In English, from the service. */
445
+ description: string;
446
+ /** Its settings as fieldkit Fields, in form order; empty for none. */
447
+ settingsSpec: Schema;
448
+ }
449
+
450
+ declare type ProcessorKind = "preprocessor" | "post_processor";
451
+
452
+ /** One Processor in a Profile's pipeline, with its settings. */
453
+ declare interface ProcessorStep {
454
+ /** The Processor, by its name in the catalogue. */
455
+ processor: string;
456
+ /** One value per setting of its settings spec, by `api_accessor`. */
457
+ settings: Record<string, unknown>;
458
+ }
459
+
460
+ declare type ProcessorTarget = "source_file" | "rich_text_field";
461
+
462
+ /** A Source File uploaded and ready to be imported. */
463
+ declare interface SourceFile {
464
+ id: string;
465
+ fileName: string;
466
+ }
467
+
468
+ /** What starting an Import takes. */
469
+ declare interface StartImportInput {
470
+ importProfileId: string;
471
+ sourceFileId: string;
472
+ /** YYYY-MM-DD; "" or unset for none. */
473
+ effectiveDate?: string;
474
+ /** Both or neither. */
475
+ source?: ImportSource;
476
+ }
477
+
478
+ /** The intent a Title Contribution writes (importhub.v1.TitleIntent). */
479
+ declare type TitleIntent = "TITLE_INTENT_UNSPECIFIED" | "TITLE_INTENT_EXCLUDE" | "TITLE_INTENT_REPLACE" | "TITLE_INTENT_ANNOTATE";
480
+
481
+ /** Whether a configuration may be released, and if not, why. */
482
+ declare interface Validity {
483
+ valid: boolean;
484
+ reasons: ValidityReason[];
485
+ }
486
+
487
+ /** One thing that makes a configuration invalid (importhub.v1.ValidityReason). */
488
+ declare interface ValidityReason {
489
+ /** Where, as a JSON Pointer into the content; empty for the whole. */
490
+ path: string;
491
+ /** A stable code, such as `no_mappings`; the type's service lists them. */
492
+ code: string;
493
+ /** What is wrong, in English, for a person. */
494
+ message: string;
495
+ }
496
+
497
+ export { }