@knkcs/importhub-ui 0.4.0 → 0.6.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
@@ -1,6 +1,26 @@
1
1
  import { HostIdentity } from '@knkcs/anker/host';
2
2
  import { Schema } from '@knkcs/fieldkit/schema';
3
3
 
4
+ /**
5
+ * An importhub API key of the workspace (importhub.v1.APIKey): an odon API
6
+ * key with scope `importhub:workspace:<W>`, which importhub created with a
7
+ * standing Delegation Grant that ends with it (ADR 0006, amended). Never its
8
+ * secret.
9
+ */
10
+ declare interface ApiKey {
11
+ id: string;
12
+ /** What it is for, as people read it: "Nightly gesetz feed". */
13
+ name: string;
14
+ /** The secret's first characters, for telling keys apart. */
15
+ keyPrefix: string;
16
+ /** The odon user id of who created it, as whom it acts; the host's members name them. */
17
+ owner: string;
18
+ /** When it stops working, as an ISO 8601 timestamp; "" for never. */
19
+ expireTime: string;
20
+ /** When it was created, as an ISO 8601 timestamp. */
21
+ createTime: string;
22
+ }
23
+
4
24
  /** What moving a Mapping's draft to another Blueprint Release would lose. */
5
25
  declare interface BlueprintReleaseCheck {
6
26
  blueprintId: string;
@@ -98,6 +118,21 @@ declare interface Configured<C> {
98
118
  state: ConfigurationState;
99
119
  }
100
120
 
121
+ /** What creating an API key takes. */
122
+ declare interface CreateApiKeyInput {
123
+ /** Not blank, at most API_KEY_NAME_MAX characters. */
124
+ name: string;
125
+ /** When it stops working, as an ISO 8601 timestamp in the future; "" or unset for never. */
126
+ expireTime?: string;
127
+ }
128
+
129
+ /** A key just created, with its secret: the one time importhub returns it. */
130
+ declare interface CreatedApiKey {
131
+ apiKey: ApiKey;
132
+ /** To send as `Authorization: Bearer <secret>`; no later call returns it. */
133
+ secret: string;
134
+ }
135
+
101
136
  /**
102
137
  * An `ImporthubBlueprints` over the stub's Blueprint Releases, for a host's
103
138
  * `ImporthubHost.blueprints` in tests.
@@ -125,6 +160,65 @@ declare interface EntitySetContent {
125
160
 
126
161
  declare type FieldComparisonStatus = "unchanged" | "added" | "removed" | "changed";
127
162
 
163
+ /** One run of an Import Profile's Release over one Source File. */
164
+ declare interface Import {
165
+ id: string;
166
+ importProfileId: string;
167
+ /** The Profile's name when the Import started. */
168
+ importProfileName: string;
169
+ sourceFileId: string;
170
+ /** The odon user id of who started it; the host's members name them. */
171
+ startedBy: string;
172
+ phase: ImportPhase;
173
+ /** Unset until it has ended. */
174
+ outcome?: ImportOutcome;
175
+ /** Why it Failed, as importhub words it; "" otherwise. */
176
+ failureReason: string;
177
+ /** How far the current phase is: done of total, both 0 while unknown. */
178
+ progress: {
179
+ done: number;
180
+ total: number;
181
+ };
182
+ counts: ImportCounts;
183
+ /** The contenthub Change Set it fills; "" until it opened one. */
184
+ changeSetId: string;
185
+ /** The exact Releases it runs with, pinned at Start (release-a-configuration:AC8). */
186
+ releases: {
187
+ importProfile?: ImportReleaseRef;
188
+ /** In the Profile's order. */
189
+ mappings: ImportReleaseRef[];
190
+ /** Unset when the Profile names no Entity Set. */
191
+ entitySet?: ImportReleaseRef;
192
+ };
193
+ /** ISO 8601 timestamps; start and end "" until they happen. */
194
+ createTime: string;
195
+ startTime: string;
196
+ endTime: string;
197
+ /** The odon user id of who cancelled it, as soon as they asked; "" for nobody. */
198
+ cancelledBy: string;
199
+ /** YYYY-MM-DD, or "" for none. */
200
+ effectiveDate: string;
201
+ source?: ImportSource;
202
+ }
203
+
204
+ /** What an Import has done (importhub.v1.ImportCounts). */
205
+ declare interface ImportCounts {
206
+ /** Source Versions its Mappings matched. */
207
+ matched: number;
208
+ /** Content it created. */
209
+ created: number;
210
+ /** Item Problems: Source Versions it skipped. */
211
+ problems: number;
212
+ /** New Planned Releases of Content that exists. */
213
+ planned: number;
214
+ /** Changed Versions planned as corrections. */
215
+ corrected: number;
216
+ /** Changed Versions kept. */
217
+ kept: number;
218
+ /** Source Versions already in contenthub. */
219
+ unchanged: number;
220
+ }
221
+
128
222
  /** A Blueprint, as a Mapping's target is picked and named. */
129
223
  declare interface ImporthubBlueprint {
130
224
  id: string;
@@ -231,8 +325,43 @@ declare interface ImporthubClient {
231
325
  compareRevisions(kind: ConfigurationKind, id: string, fromRevisionId: string, toRevisionId: string): Promise<ConfigurationComparison>;
232
326
  /** Saves an older Revision's content as a new draft, on the draft named. */
233
327
  restoreRevision(kind: ConfigurationKind, id: string, revisionId: string, draftRevisionId: string): Promise<void>;
328
+ /**
329
+ * Uploads one file as a Source File: importhub hands out a direct upload
330
+ * URL into its blob store, and the file goes there, not through importhub
331
+ * (start-an-import:AC1). `onProgress` hears the share sent, 0 to 1.
332
+ */
333
+ uploadSourceFile(file: File, onProgress: (fraction: number) => void): Promise<SourceFile>;
334
+ /** Queues an Import. Throws StartRefusedError, with importhub's reason. */
335
+ startImport(input: StartImportInput): Promise<Import>;
336
+ /** One page of the workspace's Imports, newest first; pageToken "" for the first. */
337
+ listImports(pageToken: string): Promise<ImportsPage>;
338
+ getImport(id: string): Promise<Import>;
339
+ /** Asks a queued or running Import to stop; returns it as it is now. */
340
+ cancelImport(id: string): Promise<Import>;
341
+ listItemProblems(importId: string, filter: ItemProblemsFilter): Promise<ItemProblemsPage>;
342
+ /**
343
+ * Every API key of the workspace, every importer's, newest first, without
344
+ * their secrets. Needs importhub's `importer`, as all three key calls do.
345
+ */
346
+ listApiKeys(): Promise<ApiKey[]>;
347
+ /**
348
+ * Creates an API key acting as the caller, with its Delegation Grant, and
349
+ * returns its secret this once (import-with-an-api-key:AC5).
350
+ */
351
+ createApiKey(input: CreateApiKeyInput): Promise<CreatedApiKey>;
352
+ /**
353
+ * Revokes an API key in odon and releases its Grant: it stops working at
354
+ * once (import-with-an-api-key:AC7).
355
+ */
356
+ revokeApiKey(id: string): Promise<void>;
234
357
  }
235
358
 
359
+ /** How an Import ended (importhub.v1.ImportOutcome, CONTEXT.md "Import Outcome"). */
360
+ declare type ImportOutcome = "succeeded" | "succeeded_with_problems" | "failed" | "cancelled";
361
+
362
+ /** Where an Import is (importhub.v1.ImportPhase). */
363
+ declare type ImportPhase = "queued" | "reading" | "writing" | "ended";
364
+
236
365
  declare type ImportProfile = Configured<ImportProfileContent>;
237
366
 
238
367
  /** What an admin edits of an Import Profile. */
@@ -257,6 +386,72 @@ declare interface ImportProfileRef {
257
386
  name: string;
258
387
  }
259
388
 
389
+ /** One Configuration Release an Import runs with, named as it was then. */
390
+ declare interface ImportReleaseRef {
391
+ configurationId: string;
392
+ /** The configuration's name in that Release. */
393
+ name: string;
394
+ releaseId: string;
395
+ /** "Release 3". */
396
+ number: number;
397
+ }
398
+
399
+ /** The publication that triggered an Import: such as 2026-09-20, "BGBl. 2026 I Nr. 270". */
400
+ declare interface ImportSource {
401
+ /** The day it was published, as YYYY-MM-DD. */
402
+ date: string;
403
+ /** How it is cited. */
404
+ reference: string;
405
+ }
406
+
407
+ /** One page of the workspace's Imports, newest first. */
408
+ declare interface ImportsPage {
409
+ imports: Import[];
410
+ /** "" on the last page. */
411
+ nextPageToken: string;
412
+ }
413
+
414
+ /** One Source Version an Import could not save and skipped (CONTEXT.md "Item Problem"). */
415
+ declare interface ItemProblem {
416
+ id: string;
417
+ mappingId: string;
418
+ /** The Mapping's name in the Release the Import ran. */
419
+ mappingName: string;
420
+ /** "" when the element has none. */
421
+ sourceKey: string;
422
+ /** A /-separated path in the Content's data; "" for the Source Version as a whole. */
423
+ field: string;
424
+ /** Why, as importhub words it. */
425
+ reason: string;
426
+ }
427
+
428
+ /** How an Import's Item Problems are filtered: by Mapping, and by Source Key. */
429
+ declare interface ItemProblemsFilter {
430
+ /** "" for every Mapping. */
431
+ mappingId: string;
432
+ /** Matches Source Keys that contain it, ignoring case; "" for all. */
433
+ sourceKeyQuery: string;
434
+ /** "" for the first page. */
435
+ pageToken: string;
436
+ }
437
+
438
+ /** One page of an Import's Item Problems, with their counts. */
439
+ declare interface ItemProblemsPage {
440
+ itemProblems: ItemProblem[];
441
+ /** Every Item Problem of the Import, whatever the filter. */
442
+ totalCount: number;
443
+ /** The Item Problems the filter matches, on every page. */
444
+ matchingCount: number;
445
+ /** Every Mapping with Item Problems and how many, whatever the filter. */
446
+ mappings: {
447
+ mappingId: string;
448
+ mappingName: string;
449
+ count: number;
450
+ }[];
451
+ /** "" on the last page. */
452
+ nextPageToken: string;
453
+ }
454
+
260
455
  declare type Mapping = Configured<MappingContent>;
261
456
 
262
457
  /**
@@ -359,6 +554,25 @@ declare interface ProcessorStep {
359
554
 
360
555
  declare type ProcessorTarget = "source_file" | "rich_text_field";
361
556
 
557
+ /** A Source File uploaded and ready to be imported. */
558
+ declare interface SourceFile {
559
+ id: string;
560
+ fileName: string;
561
+ }
562
+
563
+ /** What starting an Import takes. */
564
+ declare interface StartImportInput {
565
+ importProfileId: string;
566
+ sourceFileId: string;
567
+ /** YYYY-MM-DD; "" or unset for none. */
568
+ effectiveDate?: string;
569
+ /** Both or neither. */
570
+ source?: ImportSource;
571
+ }
572
+
573
+ /** A second member of the stub workspace, who starts and cancels Imports too. */
574
+ export declare const STUB_OTHER_USER_ID = "user_stub_grace";
575
+
362
576
  /** A second workspace, for tests that switch to it. */
363
577
  export declare const STUB_OTHER_WORKSPACE_ID = "ws_stub_other";
364
578
 
@@ -368,6 +582,12 @@ export declare const STUB_USER_ID = "user_stub_ada";
368
582
  /** The stub workspace's id. */
369
583
  export declare const STUB_WORKSPACE_ID = "ws_stub_main";
370
584
 
585
+ /**
586
+ * The stub workspace's API keys, newest first: Grace's nightly feed, which
587
+ * never expires, and Ada's pipeline key, which does.
588
+ */
589
+ export declare function stubApiKeys(): ApiKey[];
590
+
371
591
  /** A Blueprint Release the stub knows, with the field paths it has. */
372
592
  export declare interface StubBlueprintRelease {
373
593
  id: string;
@@ -397,6 +617,9 @@ export declare interface StubConfiguration<C> {
397
617
  releaseNumber?: number;
398
618
  }
399
619
 
620
+ /** A contenthub right the stub viewer holds, which Start checks. */
621
+ export declare type StubContenthubRight = "editor" | "publisher";
622
+
400
623
  /** The stub workspace's Entity Sets: one. */
401
624
  export declare function stubEntitySets(): StubConfiguration<EntitySetContent>[];
402
625
 
@@ -406,9 +629,19 @@ export declare function stubEntitySets(): StubConfiguration<EntitySetContent>[];
406
629
  */
407
630
  export declare function stubIdentity(workspaceId?: string): HostIdentity;
408
631
 
632
+ /** A stub Import as the stub client is seeded with it, with its Item Problems. */
633
+ export declare interface StubImport extends Import {
634
+ itemProblems?: ItemProblem[];
635
+ }
636
+
409
637
  export declare interface StubImporthubClient extends ImporthubClient {
410
638
  /** Answer for another workspace from now on, as a host's new token would. */
411
639
  switchWorkspace(workspaceId: string): void;
640
+ /**
641
+ * Moves an Import on as importhub's worker would: a phase, progress,
642
+ * counts, an Outcome. For tests that follow an Import while it runs.
643
+ */
644
+ updateImport(id: string, patch: Partial<StubImport>): void;
412
645
  /** How many calls each method has answered, for tests that count reloads. */
413
646
  readonly calls: Readonly<Record<keyof ImporthubClient, number>>;
414
647
  }
@@ -425,6 +658,13 @@ export declare interface StubImporthubClientOptions {
425
658
  processors?: Processor[];
426
659
  /** The Blueprint Releases blueprinthub knows; the fixtures' by default. */
427
660
  blueprintReleases?: StubBlueprintRelease[];
661
+ /**
662
+ * The contenthub rights the viewer holds, which Start checks
663
+ * (start-an-import:AC4); both by default.
664
+ */
665
+ contenthubRights?: StubContenthubRight[];
666
+ /** Fail every upload with this error, as an unreachable blob store would. */
667
+ uploadFails?: Error;
428
668
  /** Fail every call with this error, as an unreachable importhub would. */
429
669
  fail?: Error;
430
670
  }
@@ -435,6 +675,12 @@ export declare interface StubImporthubClientOptions {
435
675
  */
436
676
  export declare function stubImportProfiles(): StubConfiguration<ImportProfileContent>[];
437
677
 
678
+ /**
679
+ * The stub workspace's Imports, newest first: one running, one queued
680
+ * behind it, and one of each Import Outcome.
681
+ */
682
+ export declare function stubImports(): StubImport[];
683
+
438
684
  /** The stub workspace's Mappings: one valid and released, one invalid. */
439
685
  export declare function stubMappings(): StubConfiguration<MappingContent>[];
440
686
 
@@ -446,6 +692,10 @@ export declare interface StubWorkspace {
446
692
  importProfiles?: StubConfiguration<ImportProfileContent>[];
447
693
  mappings?: StubConfiguration<MappingContent>[];
448
694
  entitySets?: StubConfiguration<EntitySetContent>[];
695
+ /** Its Imports, newest first, each with its Item Problems. */
696
+ imports?: StubImport[];
697
+ /** Its importhub API keys, newest first. */
698
+ apiKeys?: ApiKey[];
449
699
  }
450
700
 
451
701
  /** The intent a Title Contribution writes (importhub.v1.TitleIntent). */