@republicroad/seal-editor 1.15.0 → 1.17.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/index.d.ts CHANGED
@@ -43,6 +43,8 @@ export declare const anyNodeSchema: z.ZodObject<{
43
43
  }, z.core.$strip>>;
44
44
  }, z.core.$strip>;
45
45
 
46
+ export declare const applySchemaTextToInputContract: (contract: InputContract, schemaText: string) => InputContract;
47
+
46
48
  declare type Arrayable<T> = T | T[];
47
49
 
48
50
  export declare const AUTO_SYNC_DEBOUNCE_MS = 700;
@@ -221,8 +223,35 @@ export declare const compareAndUnifyLists: <T extends BaseItem>(newList: T[], ol
221
223
 
222
224
  export declare const compareStringFields: (field1?: string | null, field2?: string | null) => boolean;
223
225
 
226
+ export declare const computeExampleDrift: (data: Record<string, unknown>, definitions: Array<Pick<RequestDefinition, "name" | "path" | "type">>) => RequestExampleDrift;
227
+
224
228
  export declare const computeGraphDiff: (a: DecisionGraphType, b: DecisionGraphType) => GraphDiff;
225
229
 
230
+ export declare type ContractDriftEvent = {
231
+ at: string;
232
+ nodeId: string;
233
+ nodeName?: string;
234
+ kind: ContractDriftEventKind;
235
+ exampleNames: string[];
236
+ counts?: {
237
+ missing: number;
238
+ extra: number;
239
+ conflicts: number;
240
+ constraints: number;
241
+ };
242
+ };
243
+
244
+ export declare type ContractDriftEventKind = 'drift-detected' | 'drift-migrated' | 'drift-confirmed';
245
+
246
+ export declare const contractExamplesToSources: (contract: InputContract, options?: {
247
+ dataLabel?: string;
248
+ }) => RequestExampleSource[];
249
+
250
+ export declare type ContractFixture = {
251
+ name: string;
252
+ input: unknown;
253
+ };
254
+
226
255
  declare type ControlToType<T> = T extends keyof InputTypeMap ? InputTypeMap[T] : never;
227
256
 
228
257
  declare type CreateDynamicType<T extends ReadonlyArray<unknown>, Result = {}> = T extends readonly [infer First, ...infer Rest] ? First extends {
@@ -342,6 +371,8 @@ declare type DecisionGraphEmptyType = {
342
371
  mode?: JdmUiMode;
343
372
  onChange?: DecisionGraphStoreType['listeners']['onChange'];
344
373
  onReactFlowInit?: DecisionGraphStoreType['listeners']['onReactFlowInit'];
374
+ fixturesRunner?: DecisionGraphStoreType['state']['fixturesRunner'];
375
+ onContractEvent?: DecisionGraphStoreType['listeners']['onContractEvent'];
345
376
  onCodeExtension?: DecisionGraphStoreType['listeners']['onCodeExtension'];
346
377
  onFunctionReady?: DecisionGraphStoreType['listeners']['onFunctionReady'];
347
378
  };
@@ -378,6 +409,13 @@ declare type DecisionGraphStoreType = {
378
409
  user: string;
379
410
  simulatorRequest?: string;
380
411
  simulatorExampleBinding?: SimulatorExampleBinding;
412
+ fixturesRunner?: FixturesRunner | null;
413
+ fixturesRun?: {
414
+ nodeId: string;
415
+ status: 'running' | 'done' | 'error';
416
+ report?: ExampleRunReport;
417
+ error?: string;
418
+ } | null;
381
419
  compactMode?: boolean;
382
420
  dictionaries?: DictionaryMap;
383
421
  mode?: JdmUiMode;
@@ -424,11 +462,15 @@ declare type DecisionGraphStoreType = {
424
462
  removeNodeType: (id: string, kind?: NodeTypeKind) => void;
425
463
  setSimulatorRequest: (req: string) => void;
426
464
  setSimulatorExampleBinding: (binding?: SimulatorExampleBinding) => void;
465
+ setFixturesRunner: (runner: FixturesRunner | null) => void;
466
+ runFixtures: () => Promise<void>;
467
+ emitContractEvent: (event: ContractDriftEvent) => void;
427
468
  triggerNodeSelect: (id: string, mode: 'toggle' | 'only') => void;
428
469
  };
429
470
  listeners: {
430
471
  onChange?: (val: DecisionGraphType) => void;
431
472
  onPanelsChange?: (val?: string) => void;
473
+ onContractEvent?: (event: ContractDriftEvent) => void;
432
474
  onReactFlowInit?: (instance: ReactFlowInstance) => void;
433
475
  onCodeExtension?: CodeEditorProps['extension'];
434
476
  onFunctionReady?: (monaco: Monaco) => void;
@@ -639,6 +681,17 @@ export declare const decisionModelSchema: z.ZodObject<{
639
681
  }, z.core.$strip>>>;
640
682
  inputField: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>, z.ZodTransform<string | null, string | null>>;
641
683
  outputPath: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>, z.ZodTransform<string | null, string | null>>;
684
+ inputContract: z.ZodOptional<z.ZodNullable<z.ZodObject<{
685
+ contractVersion: z.ZodDefault<z.ZodNumber>;
686
+ schema: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>>>, z.ZodTransform<Record<string, any>, string | Record<string, any> | null | undefined>>;
687
+ examples: z.ZodDefault<z.ZodArray<z.ZodObject<{
688
+ id: z.ZodString;
689
+ name: z.ZodDefault<z.ZodString>;
690
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
691
+ data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
692
+ schemaFingerprint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
693
+ }, z.core.$strip>>>;
694
+ }, z.core.$strip>>>;
642
695
  }, z.core.$strip>>;
643
696
  id: z.ZodDefault<z.ZodString>;
644
697
  name: z.ZodString;
@@ -1204,6 +1257,53 @@ declare const en: {
1204
1257
  readonly 'request.fieldNamePlaceholder': "Field name";
1205
1258
  readonly 'request.formatSchema': "Format schema";
1206
1259
  readonly 'request.noDataSources': "No data";
1260
+ readonly 'request.driftSchemaChanged': "Schema changed since last validation";
1261
+ readonly 'request.driftMissing': "missing";
1262
+ readonly 'request.driftExtra': "extra";
1263
+ readonly 'request.driftConflicts': "type conflicts";
1264
+ readonly 'request.driftMigrate': "Migrate";
1265
+ readonly 'request.driftMigrateTooltip': "Fill missing values from defaults and remove fields that no longer exist";
1266
+ readonly 'request.driftMigrateAll': "Migrate all";
1267
+ readonly 'request.driftMigrateAllTooltip': "Apply the safe migration to every example";
1268
+ readonly 'request.driftConfirmValid': "Mark valid";
1269
+ readonly 'request.driftConfirmTooltip': "The example already matches the current schema - record its fingerprint";
1270
+ readonly 'request.driftConstraints': "constraint violations";
1271
+ readonly 'request.importContract': "Import contract";
1272
+ readonly 'request.importContractTooltip': "Adopt a shared contract envelope (contractVersion + schema + examples)";
1273
+ readonly 'request.importContractSuccess': "Contract envelope imported";
1274
+ readonly 'request.importContractInvalidJson': "The file is not valid JSON";
1275
+ readonly 'request.importContractInvalidShape': "Not a contract envelope (contractVersion + schema + examples are required)";
1276
+ readonly 'request.importContractUnsupportedVersion': "The envelope contractVersion is newer than this version supports";
1277
+ readonly 'request.exportContract': "Export contract";
1278
+ readonly 'request.exportContractTooltip': "Download the contract envelope for sharing (OpenAPI / mock / fixtures)";
1279
+ readonly 'request.showRemainingSources': "Show remaining examples";
1280
+ readonly 'request.runAll': "Run all";
1281
+ readonly 'request.runAllTooltip': "Execute every example against the current graph (runs on the host engine)";
1282
+ readonly 'request.runAllFailed': "Run failed";
1283
+ readonly 'request.runAllMatrixTitle': "Run report";
1284
+ readonly 'request.runAllMatrixLabel': "Run all result matrix";
1285
+ readonly 'request.runAllPassed': "passed";
1286
+ readonly 'request.runAllFailedCount': "failed";
1287
+ readonly 'request.outcomePassed': "passed";
1288
+ readonly 'request.outcomeAssertionFailed': "assertion failed";
1289
+ readonly 'request.outcomeExecutionError': "error";
1290
+ readonly 'request.modeDesign': "Design";
1291
+ readonly 'request.modeCode': "Code";
1292
+ readonly 'request.designModeTooltip': "Structured field editor";
1293
+ readonly 'request.examplesSwitcherLabel': "Examples";
1294
+ readonly 'request.selectFieldHint': "Select a field in the tree to edit it";
1295
+ readonly 'request.objectChildrenHint': "Child fields";
1296
+ readonly 'request.arrayCodeHint': "Array item editing lives in Code mode.";
1297
+ readonly 'request.examplePreviewTitle': "Example";
1298
+ readonly 'request.debugInSimulator': "Debug";
1299
+ readonly 'request.fixturesNoInputNode': "No input node in this graph";
1300
+ readonly 'request.fixturesNoExamples': "The input node has no examples yet";
1301
+ readonly 'request.fixturesRunning': "Running…";
1302
+ readonly 'cf.argsDriftTitle': "Function argument drift";
1303
+ readonly 'cf.argsDriftRows': "row(s)";
1304
+ readonly 'cf.argsDriftMissing': "missing";
1305
+ readonly 'cf.argsDriftUnrecognized': "unrecognized";
1306
+ readonly 'cf.argsFillMissing': "Fill missing defaults";
1207
1307
  readonly 'request.noDefinitions': "No field definitions";
1208
1308
  readonly 'request.schemaPriorityTooltip': "Schema has the highest priority. Definitions and example data sync into schema, but schema remains the source of truth.";
1209
1309
  readonly 'request.simulateTooltip': "Open simulator";
@@ -1241,6 +1341,24 @@ declare const en: {
1241
1341
 
1242
1342
  export declare const ensureWasmLoaded: () => Promise<void>;
1243
1343
 
1344
+ export declare type ExampleRunOutcome = 'passed' | 'assertion-failed' | 'execution-error';
1345
+
1346
+ export declare type ExampleRunReport = {
1347
+ passed: number;
1348
+ failed: number;
1349
+ results: ExampleRunResult[];
1350
+ };
1351
+
1352
+ export declare type ExampleRunResult = {
1353
+ name: string;
1354
+ passed: boolean;
1355
+ outcome: ExampleRunOutcome;
1356
+ actual?: unknown;
1357
+ error?: string;
1358
+ durationMs?: number;
1359
+ traceHits?: string[];
1360
+ };
1361
+
1244
1362
  declare type ExposedStore<T> = UseBoundStore<StoreApi<T>> & {
1245
1363
  setState: (partial: Partial<T>) => void;
1246
1364
  };
@@ -1334,6 +1452,10 @@ declare type ExtensionParams = {
1334
1452
  type?: 'standard' | 'unary' | 'template';
1335
1453
  };
1336
1454
 
1455
+ export declare const FixturesPanel: default_2.FC;
1456
+
1457
+ export declare type FixturesRunner = (graph: DecisionGraphType, fixtures: ContractFixture[]) => Promise<ExampleRunReport>;
1458
+
1337
1459
  declare const Function_2: default_2.FC<FunctionProps>;
1338
1460
  export { Function_2 as Function }
1339
1461
 
@@ -1497,6 +1619,8 @@ declare type GraphTabsProps = {
1497
1619
  tabBarExtraContent?: TabsProps['tabBarExtraContent'];
1498
1620
  };
1499
1621
 
1622
+ export declare const hasExampleDrift: (drift: RequestExampleDrift) => boolean;
1623
+
1500
1624
  declare type HitPolicy = 'first' | 'collect';
1501
1625
 
1502
1626
  export declare type I18nMessages = Record<string, string>;
@@ -1522,6 +1646,22 @@ declare type InferTypeData<T> = {
1522
1646
 
1523
1647
  declare type Input = unknown;
1524
1648
 
1649
+ export declare const INPUT_CONTRACT_VERSION = 1;
1650
+
1651
+ export declare type InputContract = {
1652
+ contractVersion: number;
1653
+ schema: RequestJsonSchema;
1654
+ examples: InputContractExample[];
1655
+ };
1656
+
1657
+ export declare type InputContractExample = {
1658
+ id: string;
1659
+ name: string;
1660
+ description?: string;
1661
+ data: Record<string, unknown>;
1662
+ schemaFingerprint?: string;
1663
+ };
1664
+
1525
1665
  export declare const inputNodeSchema: z.ZodObject<{
1526
1666
  type: z.ZodLiteral<NodeKind.Input>;
1527
1667
  content: z.ZodDefault<z.ZodObject<{
@@ -1534,6 +1674,17 @@ export declare const inputNodeSchema: z.ZodObject<{
1534
1674
  }, z.core.$strip>>>;
1535
1675
  inputField: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>, z.ZodTransform<string | null, string | null>>;
1536
1676
  outputPath: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>, z.ZodTransform<string | null, string | null>>;
1677
+ inputContract: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1678
+ contractVersion: z.ZodDefault<z.ZodNumber>;
1679
+ schema: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>>>, z.ZodTransform<Record<string, any>, string | Record<string, any> | null | undefined>>;
1680
+ examples: z.ZodDefault<z.ZodArray<z.ZodObject<{
1681
+ id: z.ZodString;
1682
+ name: z.ZodDefault<z.ZodString>;
1683
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1684
+ data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
1685
+ schemaFingerprint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1686
+ }, z.core.$strip>>>;
1687
+ }, z.core.$strip>>>;
1537
1688
  }, z.core.$strip>>;
1538
1689
  id: z.ZodDefault<z.ZodString>;
1539
1690
  name: z.ZodString;
@@ -1617,6 +1768,11 @@ declare interface MenuProps {
1617
1768
  onClick?: MenuItemType['onClick'];
1618
1769
  }
1619
1770
 
1771
+ export declare const migrateRequestExampleDataByDefinitions: (data: Record<string, unknown>, definitions: Array<Pick<RequestDefinition, "name" | "path" | "type" | "defaultValue">>) => {
1772
+ data: Record<string, unknown>;
1773
+ conflicts: RequestDefinitionSyncConflict[];
1774
+ };
1775
+
1620
1776
  export declare type MinimalNodeProps = Pick<NodeProps, 'id' | 'selected'> & {
1621
1777
  data: any;
1622
1778
  };
@@ -1855,6 +2011,17 @@ export declare const nodeSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<[z.ZodObjec
1855
2011
  }, z.core.$strip>>>;
1856
2012
  inputField: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>, z.ZodTransform<string | null, string | null>>;
1857
2013
  outputPath: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>, z.ZodTransform<string | null, string | null>>;
2014
+ inputContract: z.ZodOptional<z.ZodNullable<z.ZodObject<{
2015
+ contractVersion: z.ZodDefault<z.ZodNumber>;
2016
+ schema: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>>>, z.ZodTransform<Record<string, any>, string | Record<string, any> | null | undefined>>;
2017
+ examples: z.ZodDefault<z.ZodArray<z.ZodObject<{
2018
+ id: z.ZodString;
2019
+ name: z.ZodDefault<z.ZodString>;
2020
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2021
+ data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
2022
+ schemaFingerprint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2023
+ }, z.core.$strip>>>;
2024
+ }, z.core.$strip>>>;
1858
2025
  }, z.core.$strip>>;
1859
2026
  id: z.ZodDefault<z.ZodString>;
1860
2027
  name: z.ZodString;
@@ -2054,10 +2221,16 @@ declare interface RadioGroupProps {
2054
2221
  style?: React_2.CSSProperties;
2055
2222
  }
2056
2223
 
2224
+ export declare const readRequestInputContract: (content?: RequestContentLike | null) => {
2225
+ contract: InputContract;
2226
+ origin: RequestInputContractOrigin;
2227
+ };
2228
+
2057
2229
  declare type RequestContentLike = {
2058
2230
  schema?: unknown;
2059
2231
  schemaUI?: unknown;
2060
2232
  inputs?: LegacyRequestInput[];
2233
+ inputContract?: InputContract;
2061
2234
  };
2062
2235
 
2063
2236
  export declare type RequestDefinition = {
@@ -2074,8 +2247,20 @@ export declare type RequestDefinition = {
2074
2247
  defaultValue?: string;
2075
2248
  };
2076
2249
 
2250
+ declare type RequestDefinitionSyncConflict = {
2251
+ path: string;
2252
+ nextType: RequestDefinitionType;
2253
+ value: unknown;
2254
+ };
2255
+
2077
2256
  export declare type RequestDefinitionType = 'number' | 'string' | 'array' | 'object' | 'datetime' | 'boolean';
2078
2257
 
2258
+ export declare type RequestExampleDrift = {
2259
+ missing: Array<Pick<RequestDefinition, 'name' | 'path' | 'type'>>;
2260
+ extra: string[];
2261
+ conflicts: RequestDefinitionSyncConflict[];
2262
+ };
2263
+
2079
2264
  declare type RequestExampleMeta = {
2080
2265
  name?: string;
2081
2266
  description?: string;
@@ -2089,6 +2274,8 @@ export declare type RequestExampleSource = {
2089
2274
  source: 'schema.examples' | 'content.inputs';
2090
2275
  };
2091
2276
 
2277
+ declare type RequestInputContractOrigin = 'contract' | 'legacy';
2278
+
2092
2279
  declare type RequestJsonSchema = {
2093
2280
  'type'?: string | string[];
2094
2281
  'description'?: string;
@@ -2101,6 +2288,8 @@ declare type RequestJsonSchema = {
2101
2288
  [key: string]: unknown;
2102
2289
  };
2103
2290
 
2291
+ export declare const requestSchemaFingerprint: (schema: unknown) => string;
2292
+
2104
2293
  export declare const resolveRequestSchemaValue: (content?: RequestContentLike | null, options?: {
2105
2294
  includeExamples?: boolean;
2106
2295
  }) => RequestJsonSchema | null;
@@ -2508,19 +2697,21 @@ declare type ViewConfig = {
2508
2697
 
2509
2698
  declare type ViewConfigPermission = 'edit:values' | 'edit:rules' | 'edit:full';
2510
2699
 
2700
+ export declare const writeRequestInputContract: (content: RequestContentLike & Record<string, any>, contract: InputContract) => InputContract;
2701
+
2511
2702
  export { }
2512
2703
 
2513
2704
 
2514
- declare global {
2515
- interface Window {
2516
- monaco?: Monaco;
2705
+ declare module '@gorules/zen-engine-wasm' {
2706
+ interface VariableType {
2707
+ __hash: string;
2517
2708
  }
2518
2709
  }
2519
2710
 
2520
2711
 
2521
- declare module '@gorules/zen-engine-wasm' {
2522
- interface VariableType {
2523
- __hash: string;
2712
+ declare global {
2713
+ interface Window {
2714
+ monaco?: Monaco;
2524
2715
  }
2525
2716
  }
2526
2717