@knkcs/importhub-ui 0.8.0 → 0.9.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
@@ -308,6 +308,14 @@ declare interface ImporthubClient {
308
308
  listMappingImportProfiles(id: string): Promise<ImportProfileRef[]>;
309
309
  /** Checks moving the draft to another Blueprint Release, saving nothing. */
310
310
  checkMappingBlueprintRelease(id: string, blueprintReleaseId: string): Promise<BlueprintReleaseCheck>;
311
+ /**
312
+ * Runs a Mapping Test: the content given over the sample, read as an
313
+ * Import reads a Source File. Stores nothing and touches nothing outside
314
+ * importhub (test-a-mapping-on-a-sample-file:AC4). Throws with importhub's
315
+ * reason when the test cannot run at all: a sample that is not XML, an
316
+ * element selector or Source Key xmlmapper cannot evaluate.
317
+ */
318
+ runMappingTest(input: MappingTestInput): Promise<MappingTestResult>;
311
319
  /** Every Entity Set of the workspace, by name. */
312
320
  listEntitySets(): Promise<EntitySet[]>;
313
321
  getEntitySet(id: string): Promise<EntitySet>;
@@ -534,6 +542,59 @@ declare interface MappingContent {
534
542
  [key: string]: unknown;
535
543
  }
536
544
 
545
+ /** One element a Mapping Test matched, as an Import would read it. */
546
+ declare interface MappingTestElement {
547
+ /** Its position among the elements matched, from 1. */
548
+ position: number;
549
+ /** Its Source Key, verbatim; "" when it has none. */
550
+ sourceKey: string;
551
+ /** Its mapped values by field accessor; a field that cannot be mapped is left out. */
552
+ values: Record<string, unknown>;
553
+ /** The Validity Period the sample gives, as YYYY-MM-DD; "" for none. */
554
+ firstDay: string;
555
+ lastDay: string;
556
+ /** The Release Spec values the sample gives, by field. */
557
+ releaseSpec: Record<string, unknown>;
558
+ /** What the display-name template makes; "" without one. */
559
+ displayName: string;
560
+ /** The Collections it would be filed into, by name. */
561
+ collections: string[];
562
+ /** Each field that cannot be mapped, and what an Import would report; none when clean. */
563
+ problems: MappingTestProblem[];
564
+ }
565
+
566
+ /**
567
+ * What a Mapping Test runs (test-a-mapping-on-a-sample-file:AC1): a
568
+ * Mapping's content as the editor holds it, saved or not, over a sample file.
569
+ */
570
+ declare interface MappingTestInput {
571
+ content: MappingContent;
572
+ /** The sample file, an XML file, sent whole. */
573
+ sample: Uint8Array;
574
+ /**
575
+ * An Entity Set of the workspace whose draft's entities the sample uses;
576
+ * "" or unset for none.
577
+ */
578
+ entitySetId?: string;
579
+ }
580
+
581
+ /** One problem of an element in a Mapping Test (importhub.v1.MappingTestProblem). */
582
+ declare interface MappingTestProblem {
583
+ /**
584
+ * A field path, `.`-joined into fieldsets and virtual tables, or the
585
+ * Mapping's setting that reads it (`display_name_template`, say); "" for
586
+ * the element as a whole, such as an element without a Source Key.
587
+ */
588
+ field: string;
589
+ /** Why, for a person: xmlmapper's message for a field that cannot be mapped. */
590
+ reason: string;
591
+ }
592
+
593
+ /** What a Mapping Test answers: every element the element selector matched. */
594
+ declare interface MappingTestResult {
595
+ elements: MappingTestElement[];
596
+ }
597
+
537
598
  /** One entry of the Processor catalogue. */
538
599
  declare interface Processor {
539
600
  /** How a Profile names it, such as `entity-element`. */
@@ -689,6 +750,12 @@ export declare function stubImports(): StubImport[];
689
750
  /** The stub workspace's Mappings: one valid and released, one invalid. */
690
751
  export declare function stubMappings(): StubConfiguration<MappingContent>[];
691
752
 
753
+ /**
754
+ * A sample file for the "Gesetz norms" Mapping's Mapping Test: two norms,
755
+ * the second without a footnote.
756
+ */
757
+ export declare const stubMappingTestSample = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gesetz>\n\t<norm id=\"n1\"><titel>\u00A7 1 Geltungsbereich</titel><fn>Gilt ab 2026.</fn></norm>\n\t<norm id=\"n2\"><titel>\u00A7 2 Begriffsbestimmungen</titel></norm>\n</gesetz>\n";
758
+
692
759
  /** The catalogue, a few Processors of each kind and target. */
693
760
  export declare function stubProcessors(): Processor[];
694
761