@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.
package/dist/testing.d.ts CHANGED
@@ -10,6 +10,9 @@ declare interface BlueprintReleaseCheck {
10
10
  missingReleaseSpecFields: string[];
11
11
  }
12
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
+
13
16
  /** Two Revisions of one configuration, and how each top-level field differs. */
14
17
  declare interface ConfigurationComparison {
15
18
  from: ConfigurationVersion;
@@ -122,18 +125,106 @@ declare interface EntitySetContent {
122
125
 
123
126
  declare type FieldComparisonStatus = "unchanged" | "added" | "removed" | "changed";
124
127
 
128
+ /** One run of an Import Profile's Release over one Source File. */
129
+ declare interface Import {
130
+ id: string;
131
+ importProfileId: string;
132
+ /** The Profile's name when the Import started. */
133
+ importProfileName: string;
134
+ sourceFileId: string;
135
+ /** The odon user id of who started it; the host's members name them. */
136
+ startedBy: string;
137
+ phase: ImportPhase;
138
+ /** Unset until it has ended. */
139
+ outcome?: ImportOutcome;
140
+ /** Why it Failed, as importhub words it; "" otherwise. */
141
+ failureReason: string;
142
+ /** How far the current phase is: done of total, both 0 while unknown. */
143
+ progress: {
144
+ done: number;
145
+ total: number;
146
+ };
147
+ counts: ImportCounts;
148
+ /** The contenthub Change Set it fills; "" until it opened one. */
149
+ changeSetId: string;
150
+ /** The exact Releases it runs with, pinned at Start (release-a-configuration:AC8). */
151
+ releases: {
152
+ importProfile?: ImportReleaseRef;
153
+ /** In the Profile's order. */
154
+ mappings: ImportReleaseRef[];
155
+ /** Unset when the Profile names no Entity Set. */
156
+ entitySet?: ImportReleaseRef;
157
+ };
158
+ /** ISO 8601 timestamps; start and end "" until they happen. */
159
+ createTime: string;
160
+ startTime: string;
161
+ endTime: string;
162
+ /** The odon user id of who cancelled it, as soon as they asked; "" for nobody. */
163
+ cancelledBy: string;
164
+ /** YYYY-MM-DD, or "" for none. */
165
+ effectiveDate: string;
166
+ source?: ImportSource;
167
+ }
168
+
169
+ /** What an Import has done (importhub.v1.ImportCounts). */
170
+ declare interface ImportCounts {
171
+ /** Source Versions its Mappings matched. */
172
+ matched: number;
173
+ /** Content it created. */
174
+ created: number;
175
+ /** Item Problems: Source Versions it skipped. */
176
+ problems: number;
177
+ /** New Planned Releases of Content that exists. */
178
+ planned: number;
179
+ /** Changed Versions planned as corrections. */
180
+ corrected: number;
181
+ /** Changed Versions kept. */
182
+ kept: number;
183
+ /** Source Versions already in contenthub. */
184
+ unchanged: number;
185
+ }
186
+
125
187
  /** A Blueprint, as a Mapping's target is picked and named. */
126
188
  declare interface ImporthubBlueprint {
127
189
  id: string;
128
190
  name: string;
129
191
  }
130
192
 
193
+ /**
194
+ * One field of a Blueprint Release's field tree, as the Mapping editor shows
195
+ * it (importhub.v1.BlueprintField).
196
+ */
197
+ declare interface ImporthubBlueprintField {
198
+ /** Its accessor among its siblings. */
199
+ accessor: string;
200
+ /** Its accessors from the top joined by `.`: how a Mapping names it. */
201
+ path: string;
202
+ /** Its fieldkit field type, such as `text`, `date` or `fieldset`. */
203
+ fieldType: string;
204
+ /** Its label for a person; "" when the Release gives none. */
205
+ label: string;
206
+ /** A fieldset's or a virtual table's fields, nested. */
207
+ children: ImporthubBlueprintField[];
208
+ }
209
+
131
210
  /** A Blueprint Release, as a Mapping pins it: `label` names it, such as "Release 3". */
132
211
  declare interface ImporthubBlueprintRelease {
133
212
  id: string;
134
213
  label: string;
135
214
  }
136
215
 
216
+ /** A Blueprint Release with its field tree, as the Mapping editor reads it. */
217
+ declare interface ImporthubBlueprintReleaseTree {
218
+ id: string;
219
+ blueprintId: string;
220
+ /** The name it was cut with, such as `2026-10`. */
221
+ name: string;
222
+ /** Its field tree, in the Release's order. */
223
+ fields: ImporthubBlueprintField[];
224
+ /** Its Release Spec fields, which Release Spec sources and Version Match read. */
225
+ releaseSpecFields: ImporthubBlueprintField[];
226
+ }
227
+
137
228
  /**
138
229
  * Where the screens find Blueprints and their Releases, which live in
139
230
  * blueprinthub, not importhub: importhub stores only their ids. A host that
@@ -146,6 +237,13 @@ declare interface ImporthubBlueprints {
146
237
  listBlueprints(): Promise<ImporthubBlueprint[]>;
147
238
  /** A Blueprint's Releases, newest first. */
148
239
  listReleases(blueprintId: string): Promise<ImporthubBlueprintRelease[]>;
240
+ /**
241
+ * A Release with its field tree, for the Mapping editor
242
+ * (edit-a-mapping-in-the-structured-editor:AC1). Optional, so a host
243
+ * written before the editor still type-checks; without it the editor
244
+ * lists only the fields the Mapping maps, and says why.
245
+ */
246
+ getRelease?(releaseId: string): Promise<ImporthubBlueprintReleaseTree>;
149
247
  }
150
248
 
151
249
  /**
@@ -192,8 +290,28 @@ declare interface ImporthubClient {
192
290
  compareRevisions(kind: ConfigurationKind, id: string, fromRevisionId: string, toRevisionId: string): Promise<ConfigurationComparison>;
193
291
  /** Saves an older Revision's content as a new draft, on the draft named. */
194
292
  restoreRevision(kind: ConfigurationKind, id: string, revisionId: string, draftRevisionId: string): Promise<void>;
293
+ /**
294
+ * Uploads one file as a Source File: importhub hands out a direct upload
295
+ * URL into its blob store, and the file goes there, not through importhub
296
+ * (start-an-import:AC1). `onProgress` hears the share sent, 0 to 1.
297
+ */
298
+ uploadSourceFile(file: File, onProgress: (fraction: number) => void): Promise<SourceFile>;
299
+ /** Queues an Import. Throws StartRefusedError, with importhub's reason. */
300
+ startImport(input: StartImportInput): Promise<Import>;
301
+ /** One page of the workspace's Imports, newest first; pageToken "" for the first. */
302
+ listImports(pageToken: string): Promise<ImportsPage>;
303
+ getImport(id: string): Promise<Import>;
304
+ /** Asks a queued or running Import to stop; returns it as it is now. */
305
+ cancelImport(id: string): Promise<Import>;
306
+ listItemProblems(importId: string, filter: ItemProblemsFilter): Promise<ItemProblemsPage>;
195
307
  }
196
308
 
309
+ /** How an Import ended (importhub.v1.ImportOutcome, CONTEXT.md "Import Outcome"). */
310
+ declare type ImportOutcome = "succeeded" | "succeeded_with_problems" | "failed" | "cancelled";
311
+
312
+ /** Where an Import is (importhub.v1.ImportPhase). */
313
+ declare type ImportPhase = "queued" | "reading" | "writing" | "ended";
314
+
197
315
  declare type ImportProfile = Configured<ImportProfileContent>;
198
316
 
199
317
  /** What an admin edits of an Import Profile. */
@@ -218,14 +336,80 @@ declare interface ImportProfileRef {
218
336
  name: string;
219
337
  }
220
338
 
339
+ /** One Configuration Release an Import runs with, named as it was then. */
340
+ declare interface ImportReleaseRef {
341
+ configurationId: string;
342
+ /** The configuration's name in that Release. */
343
+ name: string;
344
+ releaseId: string;
345
+ /** "Release 3". */
346
+ number: number;
347
+ }
348
+
349
+ /** The publication that triggered an Import: such as 2026-09-20, "BGBl. 2026 I Nr. 270". */
350
+ declare interface ImportSource {
351
+ /** The day it was published, as YYYY-MM-DD. */
352
+ date: string;
353
+ /** How it is cited. */
354
+ reference: string;
355
+ }
356
+
357
+ /** One page of the workspace's Imports, newest first. */
358
+ declare interface ImportsPage {
359
+ imports: Import[];
360
+ /** "" on the last page. */
361
+ nextPageToken: string;
362
+ }
363
+
364
+ /** One Source Version an Import could not save and skipped (CONTEXT.md "Item Problem"). */
365
+ declare interface ItemProblem {
366
+ id: string;
367
+ mappingId: string;
368
+ /** The Mapping's name in the Release the Import ran. */
369
+ mappingName: string;
370
+ /** "" when the element has none. */
371
+ sourceKey: string;
372
+ /** A /-separated path in the Content's data; "" for the Source Version as a whole. */
373
+ field: string;
374
+ /** Why, as importhub words it. */
375
+ reason: string;
376
+ }
377
+
378
+ /** How an Import's Item Problems are filtered: by Mapping, and by Source Key. */
379
+ declare interface ItemProblemsFilter {
380
+ /** "" for every Mapping. */
381
+ mappingId: string;
382
+ /** Matches Source Keys that contain it, ignoring case; "" for all. */
383
+ sourceKeyQuery: string;
384
+ /** "" for the first page. */
385
+ pageToken: string;
386
+ }
387
+
388
+ /** One page of an Import's Item Problems, with their counts. */
389
+ declare interface ItemProblemsPage {
390
+ itemProblems: ItemProblem[];
391
+ /** Every Item Problem of the Import, whatever the filter. */
392
+ totalCount: number;
393
+ /** The Item Problems the filter matches, on every page. */
394
+ matchingCount: number;
395
+ /** Every Mapping with Item Problems and how many, whatever the filter. */
396
+ mappings: {
397
+ mappingId: string;
398
+ mappingName: string;
399
+ count: number;
400
+ }[];
401
+ /** "" on the last page. */
402
+ nextPageToken: string;
403
+ }
404
+
221
405
  declare type Mapping = Configured<MappingContent>;
222
406
 
223
407
  /**
224
408
  * What an admin edits of a Mapping, in the JSON shape of importhub.v1's
225
- * MappingContent (its camelCase keys). The screens here edit only the
226
- * fields they name; every other setting (field mappings, Version Match,
227
- * Title Contributions, …) is the structured editor's (F4), and travels
228
- * through as given, so a save here never drops it.
409
+ * MappingContent: its camelCase keys, enums by their names
410
+ * (`CHANGED_VERSION_HANDLING_KEEP`), unset settings left out. The settings are
411
+ * typed as the structured editor (F4) edits them; every key travels through
412
+ * as given, typed or not, so a save never drops one a screen does not show.
229
413
  */
230
414
  declare interface MappingContent {
231
415
  name: string;
@@ -236,10 +420,62 @@ declare interface MappingContent {
236
420
  sourceKey?: {
237
421
  selector?: string;
238
422
  template?: string;
423
+ extractPattern?: string;
424
+ /** `-` when unset; "" joins the groups with nothing. */
425
+ extractSeparator?: string;
426
+ normalize?: boolean;
239
427
  [key: string]: unknown;
240
428
  };
241
429
  /** Each an xmlmapper FieldMapping; `name` is the field path. */
242
430
  fields?: Array<Record<string, unknown>>;
431
+ versionMatch?: {
432
+ validityPeriod?: boolean;
433
+ releaseSpecFields?: string[];
434
+ contentFields?: string[];
435
+ };
436
+ validityPeriod?: {
437
+ validFromSelector?: string;
438
+ validToSelector?: string;
439
+ dateFormats?: string[];
440
+ };
441
+ releaseSpec?: Array<{
442
+ field?: string;
443
+ selector?: string;
444
+ }>;
445
+ /** Unset: Correct. */
446
+ changedVersion?: ChangedVersionHandling;
447
+ stub?: boolean;
448
+ titleContributions?: Array<{
449
+ selector?: string;
450
+ ausgabeCodeSelector?: string;
451
+ referenceSpecValues?: Array<{
452
+ field?: string;
453
+ selector?: string;
454
+ }>;
455
+ referenceFilterSelector?: string;
456
+ intent?: TitleIntent;
457
+ intentTextSelector?: string;
458
+ }>;
459
+ collectionRouting?: {
460
+ selector?: string;
461
+ collectionMap?: Record<string, string>;
462
+ idPattern?: string;
463
+ collectionTemplate?: string;
464
+ suffix?: string;
465
+ fallback?: string;
466
+ };
467
+ collections?: string[];
468
+ displayNameTemplate?: string;
469
+ placeholderAssets?: Array<{
470
+ selector?: string;
471
+ assetType?: string;
472
+ keyParts?: string[];
473
+ nameSelector?: string;
474
+ descriptionSelector?: string;
475
+ metadata?: Record<string, string>;
476
+ folderRoot?: string;
477
+ folderPathSelector?: string;
478
+ }>;
243
479
  [key: string]: unknown;
244
480
  }
245
481
 
@@ -268,6 +504,25 @@ declare interface ProcessorStep {
268
504
 
269
505
  declare type ProcessorTarget = "source_file" | "rich_text_field";
270
506
 
507
+ /** A Source File uploaded and ready to be imported. */
508
+ declare interface SourceFile {
509
+ id: string;
510
+ fileName: string;
511
+ }
512
+
513
+ /** What starting an Import takes. */
514
+ declare interface StartImportInput {
515
+ importProfileId: string;
516
+ sourceFileId: string;
517
+ /** YYYY-MM-DD; "" or unset for none. */
518
+ effectiveDate?: string;
519
+ /** Both or neither. */
520
+ source?: ImportSource;
521
+ }
522
+
523
+ /** A second member of the stub workspace, who starts and cancels Imports too. */
524
+ export declare const STUB_OTHER_USER_ID = "user_stub_grace";
525
+
271
526
  /** A second workspace, for tests that switch to it. */
272
527
  export declare const STUB_OTHER_WORKSPACE_ID = "ws_stub_other";
273
528
 
@@ -283,12 +538,18 @@ export declare interface StubBlueprintRelease {
283
538
  blueprintId: string;
284
539
  blueprintName: string;
285
540
  label: string;
541
+ /** Every field path, nested ones included (`stand.datum`). */
286
542
  fieldPaths: string[];
543
+ /** Its field tree, for the Mapping editor; the paths as text fields when unset. */
544
+ fields?: ImporthubBlueprintField[];
545
+ /** Its Release Spec fields; none when unset. */
546
+ releaseSpecFields?: ImporthubBlueprintField[];
287
547
  }
288
548
 
289
549
  /**
290
- * Two Releases of the "Gesetz" Blueprint, the newer of which dropped
291
- * `fussnote`, and one of "Entscheidung".
550
+ * Two Releases of the "Gesetz" Blueprint, with a fieldset `stand` and two
551
+ * Release Spec fields, the newer of which dropped `fussnote`, and one of
552
+ * "Entscheidung".
292
553
  */
293
554
  export declare function stubBlueprintReleases(): StubBlueprintRelease[];
294
555
 
@@ -300,6 +561,9 @@ export declare interface StubConfiguration<C> {
300
561
  releaseNumber?: number;
301
562
  }
302
563
 
564
+ /** A contenthub right the stub viewer holds, which Start checks. */
565
+ export declare type StubContenthubRight = "editor" | "publisher";
566
+
303
567
  /** The stub workspace's Entity Sets: one. */
304
568
  export declare function stubEntitySets(): StubConfiguration<EntitySetContent>[];
305
569
 
@@ -309,9 +573,19 @@ export declare function stubEntitySets(): StubConfiguration<EntitySetContent>[];
309
573
  */
310
574
  export declare function stubIdentity(workspaceId?: string): HostIdentity;
311
575
 
576
+ /** A stub Import as the stub client is seeded with it, with its Item Problems. */
577
+ export declare interface StubImport extends Import {
578
+ itemProblems?: ItemProblem[];
579
+ }
580
+
312
581
  export declare interface StubImporthubClient extends ImporthubClient {
313
582
  /** Answer for another workspace from now on, as a host's new token would. */
314
583
  switchWorkspace(workspaceId: string): void;
584
+ /**
585
+ * Moves an Import on as importhub's worker would: a phase, progress,
586
+ * counts, an Outcome. For tests that follow an Import while it runs.
587
+ */
588
+ updateImport(id: string, patch: Partial<StubImport>): void;
315
589
  /** How many calls each method has answered, for tests that count reloads. */
316
590
  readonly calls: Readonly<Record<keyof ImporthubClient, number>>;
317
591
  }
@@ -328,6 +602,13 @@ export declare interface StubImporthubClientOptions {
328
602
  processors?: Processor[];
329
603
  /** The Blueprint Releases blueprinthub knows; the fixtures' by default. */
330
604
  blueprintReleases?: StubBlueprintRelease[];
605
+ /**
606
+ * The contenthub rights the viewer holds, which Start checks
607
+ * (start-an-import:AC4); both by default.
608
+ */
609
+ contenthubRights?: StubContenthubRight[];
610
+ /** Fail every upload with this error, as an unreachable blob store would. */
611
+ uploadFails?: Error;
331
612
  /** Fail every call with this error, as an unreachable importhub would. */
332
613
  fail?: Error;
333
614
  }
@@ -338,6 +619,12 @@ export declare interface StubImporthubClientOptions {
338
619
  */
339
620
  export declare function stubImportProfiles(): StubConfiguration<ImportProfileContent>[];
340
621
 
622
+ /**
623
+ * The stub workspace's Imports, newest first: one running, one queued
624
+ * behind it, and one of each Import Outcome.
625
+ */
626
+ export declare function stubImports(): StubImport[];
627
+
341
628
  /** The stub workspace's Mappings: one valid and released, one invalid. */
342
629
  export declare function stubMappings(): StubConfiguration<MappingContent>[];
343
630
 
@@ -349,8 +636,13 @@ export declare interface StubWorkspace {
349
636
  importProfiles?: StubConfiguration<ImportProfileContent>[];
350
637
  mappings?: StubConfiguration<MappingContent>[];
351
638
  entitySets?: StubConfiguration<EntitySetContent>[];
639
+ /** Its Imports, newest first, each with its Item Problems. */
640
+ imports?: StubImport[];
352
641
  }
353
642
 
643
+ /** The intent a Title Contribution writes (importhub.v1.TitleIntent). */
644
+ declare type TitleIntent = "TITLE_INTENT_UNSPECIFIED" | "TITLE_INTENT_EXCLUDE" | "TITLE_INTENT_REPLACE" | "TITLE_INTENT_ANNOTATE";
645
+
354
646
  /** Whether a configuration may be released, and if not, why. */
355
647
  declare interface Validity {
356
648
  valid: boolean;