@wise/dynamic-flow-types 4.3.0 → 4.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.
@@ -32,6 +32,7 @@ import {
32
32
  type ReviewLayoutCallToAction,
33
33
  type ReviewLayoutField,
34
34
  type AlertLayoutCallToAction,
35
+ type SubflowResponseBody,
35
36
  type ModalResponseBody,
36
37
  type AllOfSchema,
37
38
  type NumberSchema,
@@ -47,6 +48,7 @@ import {
47
48
  type ArraySchemaList,
48
49
  type ArraySchemaTuple,
49
50
  type PollingOnError,
51
+ type SubflowBehavior,
50
52
  type ModalBehavior,
51
53
  type ToolbarButton,
52
54
  type ToolbarItem,
@@ -442,6 +444,10 @@ export const summarySummariserSchema = z.object({
442
444
  providesMedia: z.boolean().optional(),
443
445
  });
444
446
 
447
+ export const pushPresentationSchema = z.object({
448
+ type: z.literal('push'),
449
+ });
450
+
445
451
  export const dismissBehaviorSchema = z.object({
446
452
  type: z.literal('dismiss'),
447
453
  });
@@ -478,6 +484,10 @@ export const linkSchema = z.object({
478
484
  url: z.string(),
479
485
  });
480
486
 
487
+ export const modalPresentationSchema = z.object({
488
+ type: z.literal('modal'),
489
+ });
490
+
481
491
  export const actionSchema = z.object({
482
492
  title: z.string().optional(),
483
493
  type: actionTypeSchema.optional(),
@@ -505,6 +515,15 @@ export const copyBehaviorSchema = z.object({
505
515
  content: z.string(),
506
516
  });
507
517
 
518
+ export const requestSchema = z.object({
519
+ url: z.string(),
520
+ method: httpMethodSchema,
521
+ body: jsonElementSchema.optional(),
522
+ prefetch: z.boolean().optional(),
523
+ });
524
+
525
+ export const presentationSchema = z.union([modalPresentationSchema, pushPresentationSchema]);
526
+
508
527
  export const linkBehaviorSchema = z.object({
509
528
  type: z.literal('link'),
510
529
  url: z.string(),
@@ -560,6 +579,14 @@ export const suggestionsSchema = z.object({
560
579
  values: z.array(suggestionsValueSchema),
561
580
  });
562
581
 
582
+ export const dynamicLaunchConfigSchema = z.object({
583
+ type: z.literal('dynamic'),
584
+ request: requestSchema,
585
+ presentation: presentationSchema,
586
+ });
587
+
588
+ export const launchConfigSchema = dynamicLaunchConfigSchema;
589
+
563
590
  export const searchResponseBodySchema = z.object({
564
591
  results: z.array(searchResultSchema),
565
592
  });
@@ -675,6 +702,7 @@ export const behaviorSchema: z.ZodSchema<Behavior> = z.lazy(() =>
675
702
  linkBehaviorSchema,
676
703
  modalBehaviorSchema,
677
704
  refreshBehaviorSchema,
705
+ subflowBehaviorSchema,
678
706
  ]),
679
707
  );
680
708
 
@@ -952,6 +980,16 @@ export const alertLayoutCallToActionSchema: z.ZodSchema<AlertLayoutCallToAction>
952
980
  }),
953
981
  );
954
982
 
983
+ export const subflowResponseBodySchema: z.ZodSchema<SubflowResponseBody> = z.lazy(() =>
984
+ z.object({
985
+ referrerId: z.string(),
986
+ launchConfig: launchConfigSchema,
987
+ resultKey: z.string().optional(),
988
+ onCompletion: behaviorSchema.optional(),
989
+ onError: behaviorSchema.optional(),
990
+ }),
991
+ );
992
+
955
993
  export const modalResponseBodySchema: z.ZodSchema<ModalResponseBody> = z.lazy(() =>
956
994
  z.object({
957
995
  title: z.string().optional(),
@@ -1278,6 +1316,7 @@ export const objectSchemaSchema: z.ZodSchema<ObjectSchema> = z.lazy(() =>
1278
1316
  additionalText: z.string().optional(),
1279
1317
  supportingValues: supportingValuesSchema.optional(),
1280
1318
  inlineAlert: inlineAlertSchema.optional(),
1319
+ onChange: behaviorSchema.optional(),
1281
1320
  }),
1282
1321
  );
1283
1322
 
@@ -1351,6 +1390,17 @@ export const pollingOnErrorSchema: z.ZodSchema<PollingOnError> = z.lazy(() =>
1351
1390
  }),
1352
1391
  );
1353
1392
 
1393
+ export const subflowBehaviorSchema: z.ZodSchema<SubflowBehavior> = z.lazy(() =>
1394
+ z.object({
1395
+ type: z.literal('subflow'),
1396
+ referrerId: z.string(),
1397
+ launchConfig: launchConfigSchema,
1398
+ resultKey: z.string().optional(),
1399
+ onCompletion: behaviorSchema.optional(),
1400
+ onError: behaviorSchema.optional(),
1401
+ }),
1402
+ );
1403
+
1354
1404
  export const modalBehaviorSchema: z.ZodSchema<ModalBehavior> = z.lazy(() =>
1355
1405
  z.object({
1356
1406
  type: z.literal('modal'),
@@ -7,3 +7,4 @@ export type ValidationResult = {
7
7
  export declare const validateStep: (step: unknown) => ValidationResult;
8
8
  export declare const validateActionResponse: (response: unknown) => ValidationResult;
9
9
  export declare const validateErrorResponse: (response: unknown) => ValidationResult;
10
+ export declare const validateSubflowResponse: (response: unknown) => ValidationResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-types",
3
- "version": "4.3.0",
3
+ "version": "4.5.0",
4
4
  "description": "Dynamic Flow TypeScript Types",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "build"
26
26
  ],
27
27
  "devDependencies": {
28
- "@formatjs/cli": "^6.9.0",
28
+ "@formatjs/cli": "^6.12.0",
29
29
  "@types/react": "18.3.27",
30
30
  "esbuild": "0.27.0",
31
31
  "npm-run-all2": "8.0.4",