@wise/dynamic-flow-types 2.26.0 → 2.27.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.
@@ -7,7 +7,6 @@ import type { JsonElement } from '../JsonElement';
7
7
  * the flow must end.
8
8
  * An endpoint can respond to a submitting action with an error status code and the standard error response format in order to display errors to the user.
9
9
  * ### Behavior
10
- * #### Non-Exiting Actions
11
10
  * If an action does not specify the `exit` property as true, it is expected that the action will submit the step payload.
12
11
  * For example, the following action is a non-exiting action.
13
12
  * ```kt
@@ -19,7 +18,6 @@ import type { JsonElement } from '../JsonElement';
19
18
  * #### Exiting Actions
20
19
  * If an action specifies `exit` as `true`, it is expected that this action should terminate the flow. For exiting actions,
21
20
  * the `url` property is optional.
22
- * #### Non-Submitting Exiting Actions
23
21
  * If the `url` property is not specified, when the action is taken the flow will be terminated and the value of the result
24
22
  * property will be used as the result of the flow.
25
23
  * ##### Example
@@ -12,7 +12,10 @@ export type ReviewLayoutField = {
12
12
  */
13
13
  value: string;
14
14
  /**
15
- * The value without any formatting.
15
+ * The value of the field without any formatting applied. This can be used
16
+ * when you display a formatted value to the user, but want to provide an
17
+ * unformatted value to the client for other uses, for example when copying
18
+ * the value to the clipboard.
16
19
  */
17
20
  rawValue?: string;
18
21
  /**
@@ -8,6 +8,7 @@ import type { AlertLayout } from '../layout/AlertLayout';
8
8
  /**
9
9
  * A variable length array where each item matches the items JSON schema. This can be used, for example, to create a
10
10
  * repeating form section, or multi-file upload.
11
+ * If no items are entered, the value for submission is an empty array.
11
12
  */
12
13
  export type ArraySchemaList = {
13
14
  /**
@@ -7,6 +7,7 @@ import type { ValidateAsync } from '../feature/ValidateAsync';
7
7
  import type { AlertLayout } from '../layout/AlertLayout';
8
8
  /**
9
9
  * A fixed-length array where each schema represents the data at the corresponding element in the array.
10
+ * As ordering needs to remain consistent, the submission value will include null values where applicable.
10
11
  * The minItems and maxItems validation has no purpose for a tuple, and should be ignored if provided.
11
12
  */
12
13
  export type ArraySchemaTuple = {
@@ -7,6 +7,7 @@ import type { AlertLayout } from '../layout/AlertLayout';
7
7
  import type { Help } from '../feature/Help';
8
8
  /**
9
9
  * Represents a boolean value in the submission.
10
+ * The submission value is either `true` or `false`, defaulting to `false`.
10
11
  */
11
12
  export type BooleanSchema = {
12
13
  /**
@@ -8,6 +8,7 @@ import type { AutocompleteToken } from '../misc/AutocompleteToken';
8
8
  import type { Help } from '../feature/Help';
9
9
  /**
10
10
  * Represents a numeric value which must be a whole number. For floating point numbers, use a [NumberSchema] instead.
11
+ * When not provided, the submission value is `null`.
11
12
  */
12
13
  export type IntegerSchema = {
13
14
  /**
@@ -9,6 +9,7 @@ import type { Help } from '../feature/Help';
9
9
  /**
10
10
  * Represents any numeric value - either an integer or a floating point number.
11
11
  * If the value should always be an integer, consider using an [IntegerSchema] instead.
12
+ * When not provided, the submission value is `null`.
12
13
  */
13
14
  export type NumberSchema = {
14
15
  /**
@@ -6,6 +6,7 @@ import type { SummaryProvider } from '../feature/SummaryProvider';
6
6
  import type { AlertLayout } from '../layout/AlertLayout';
7
7
  /**
8
8
  * Represents an object value in the submission.
9
+ * The value for submission includes only non-null property values. If all property values are null, the value is an empty object.
9
10
  * Objects can optionally be given a title to have them appear as form sections.
10
11
  * If you'd like to group your fields into separate sections while keeping them in the same object in your submission,
11
12
  * consider using [AllOfSchema].
@@ -9,7 +9,72 @@ import type { AutocompleteToken } from '../misc/AutocompleteToken';
9
9
  /**
10
10
  * Offers a choice between a number of child schemas.
11
11
  * Use a oneOf schema to represent either the selection of one of many constant values (e.g. a select box or dropdown)
12
- * or alternative sections of a form (e.g. when the user can complete either section A or section B).
12
+ * or alternative sections of a form (e.g. when the user can complete either a form in tab A or tab B).
13
+ * ### Preselection
14
+ * Sometimes you may want to load a step with an option selected - for example in order to retain the selected option
15
+ * after a refresh.
16
+ * To figure out which item to select, we look at the step model. Clients will first populate the form with the model, and
17
+ * then inspect each oneOf option and compare them with the model to see which ones match. **If no options match, or if
18
+ * multiple match, we will not select anything.**
19
+ * This is the full matching algorithm:
20
+ * ```ts
21
+ * function isPartialMatch(optionValue, stepModel) {
22
+ * if (isArray(optionValue) && isArray(stepModel)) {
23
+ * return (
24
+ * optionValue.length === stepModel.length &&
25
+ * optionValue.every((value, index) => isPartialModelMatch(value, stepModel[index]))
26
+ * );
27
+ * }
28
+ * if (isObject(optionValue) && isObject(stepModel)) {
29
+ * // Don't look at properties with null values
30
+ * const nonNullishKeysInBoth = intersection(nonNullishKeys(optionValue), nonNullishKeys(stepModel));
31
+ * return (
32
+ * nonNullishKeysInBoth.length > 0 &&
33
+ * nonNullishKeysInBoth.every((key) => isPartialModelMatch(optionValue[key], stepModel[key]))
34
+ * );
35
+ * }
36
+ * return optionValue === stepModel;
37
+ * };
38
+ * ```
39
+ * #### Caveats
40
+ * Persisted fields are ignored, as are keys with nullish values.
41
+ * #### Discriminators
42
+ * If your oneOf options share schema property names, you will need to add a discriminator to ensure successful
43
+ * preselection. For example - if the following example did **not** contain a const type discriminator and the step
44
+ * model was `{ "name": "Jane" }`, we would not know which option to select, as both match. Conversely, if you remove
45
+ * the name property from the schemas, the const discriminator would be unnecessary, as there would be no ambiguity. *
46
+ * ```kt
47
+ * schemas {
48
+ * obj {
49
+ * title = "Iban option"
50
+ * properties {
51
+ * const("type") {
52
+ * value = JsonPrimitive("IBAN")
53
+ * }
54
+ * string("iban") {
55
+ * title = "IBAN"
56
+ * }
57
+ * string("name") {
58
+ * title = "Name"
59
+ * }
60
+ * }
61
+ * }
62
+ * obj {
63
+ * title = "Bic option"
64
+ * properties {
65
+ * const("type") {
66
+ * value = JsonPrimitive("BIC")
67
+ * }
68
+ * string("bic") {
69
+ * title = "BIC"
70
+ * }
71
+ * string("name") {
72
+ * title = "Name"
73
+ * }
74
+ * }
75
+ * }
76
+ * }
77
+ * ```
13
78
  */
14
79
  export type OneOfSchema = {
15
80
  /**
@@ -18,5 +18,11 @@ import type { StringSchema } from './StringSchema';
18
18
  * At submission time, the values entered for each root schema are merged and submitted to the endpoint
19
19
  * defined by the [com.wise.dynamicflow.feature.Action] the user has taken. In the case of any conflicting definitions,
20
20
  * schemas which appear later in the schemas array will overwrite any values from schemas earlier in the array.
21
+ * When building submission values from schemas a few rules apply depending on the schema type.
22
+ * - Primitive schemas ([com.wise.dynamicflow.schema.IntegerSchema], [com.wise.dynamicflow.schema.NumberSchema], [com.wise.dynamicflow.schema.StringSchema]) will submit `null` if they contain no value.
23
+ * - A [com.wise.dynamicflow.schema.BooleanSchema] will always submit `true` or `false`, never `null`.
24
+ * - Clients consider an empty string equivalent to having no value for a [com.wise.dynamicflow.schema.StringSchema].
25
+ * - An [com.wise.dynamicflow.schema.ObjectSchema] will always submit a JSON Object. Properties that have a value of `null` are ignored.
26
+ * - An [com.wise.dynamicflow.schema.ArraySchema] will always submit a JSON Array.
21
27
  */
22
28
  export type Schema = AllOfSchema | ArraySchema | BlobSchema | BooleanSchema | ConstSchema | IntegerSchema | NumberSchema | ObjectSchema | OneOfSchema | StringSchema;
@@ -13,6 +13,7 @@ import type { Help } from '../feature/Help';
13
13
  * Represents a string value in the submission.
14
14
  * This could be used for standard text input, or a format can be provided
15
15
  * to specify a particular type of string (e.g. a date).
16
+ * When not provided, the submission value is `null`.
16
17
  */
17
18
  export type StringSchema = {
18
19
  type: 'string';
@@ -11,8 +11,11 @@ export type ReviewField = {
11
11
  help?: string;
12
12
  label: string;
13
13
  value: string;
14
+ rawValue?: string;
14
15
  };
15
16
  export type ReviewCallToAction = {
17
+ accessibilityDescription?: string;
18
+ href?: string;
16
19
  title: string;
17
20
  onClick: () => void;
18
21
  };
@@ -200,6 +200,7 @@ export type ReviewLayout = {
200
200
  callToAction?: {
201
201
  title: string;
202
202
  action: Action;
203
+ behavior?: Behavior;
203
204
  };
204
205
  };
205
206
  export type SearchLayout = SearchConfig & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-types",
3
- "version": "2.26.0",
3
+ "version": "2.27.0",
4
4
  "description": "Dynamic Flow TypeScript Types",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {