@wise/dynamic-flow-types 2.7.0 → 2.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/build/next/feature/Action.d.ts +95 -7
- package/build/next/feature/External.d.ts +35 -0
- package/build/next/feature/Help.d.ts +6 -0
- package/build/next/feature/LinkHandler.d.ts +54 -0
- package/build/next/feature/Navigation.d.ts +11 -1
- package/build/next/feature/NavigationBackBehaviour.d.ts +8 -0
- package/build/next/feature/NavigationStackBehavior.d.ts +5 -0
- package/build/next/feature/PersistAsync.d.ts +73 -0
- package/build/next/feature/Polling.d.ts +43 -0
- package/build/next/feature/PollingOnError.d.ts +3 -0
- package/build/next/feature/StepError.d.ts +37 -0
- package/build/next/feature/Summary.d.ts +4 -0
- package/build/next/feature/SummaryProvider.d.ts +15 -0
- package/build/next/feature/SummarySummariser.d.ts +28 -0
- package/build/next/feature/UploadSource.d.ts +4 -0
- package/build/next/feature/ValidateAsync.d.ts +56 -0
- package/build/next/layout/AlertLayout.d.ts +20 -0
- package/build/next/layout/BoxLayout.d.ts +21 -0
- package/build/next/layout/ButtonLayout.d.ts +36 -3
- package/build/next/layout/ColumnsLayout.d.ts +22 -0
- package/build/next/layout/ColumnsLayoutBias.d.ts +3 -0
- package/build/next/layout/DecisionLayout.d.ts +15 -0
- package/build/next/layout/DecisionLayoutOption.d.ts +21 -0
- package/build/next/layout/DividerLayout.d.ts +10 -0
- package/build/next/layout/FormLayout.d.ts +21 -3
- package/build/next/layout/FormLayoutSchemaReference.d.ts +4 -0
- package/build/next/layout/HeadingLayout.d.ts +21 -0
- package/build/next/layout/ImageLayout.d.ts +26 -4
- package/build/next/layout/InfoLayout.d.ts +17 -0
- package/build/next/layout/InstructionsLayout.d.ts +18 -0
- package/build/next/layout/InstructionsLayoutItem.d.ts +9 -0
- package/build/next/layout/Layout.d.ts +3 -0
- package/build/next/layout/ListLayout.d.ts +16 -0
- package/build/next/layout/ListLayoutItem.d.ts +13 -0
- package/build/next/layout/ListLayoutStatus.d.ts +1 -0
- package/build/next/layout/LoadingIndicatorLayout.d.ts +16 -0
- package/build/next/layout/MarkdownLayout.d.ts +25 -0
- package/build/next/layout/ModalLayout.d.ts +17 -0
- package/build/next/layout/ModalLayoutContent.d.ts +3 -0
- package/build/next/layout/ModalLayoutTrigger.d.ts +3 -0
- package/build/next/layout/ParagraphLayout.d.ts +18 -0
- package/build/next/layout/ReviewLayout.d.ts +26 -5
- package/build/next/layout/ReviewLayoutCallToAction.d.ts +9 -0
- package/build/next/layout/ReviewLayoutField.d.ts +12 -0
- package/build/next/layout/SearchLayout.d.ts +29 -0
- package/build/next/layout/StatusListLayout.d.ts +18 -0
- package/build/next/layout/StatusListLayoutItem.d.ts +15 -0
- package/build/next/layout/StatusListLayoutStatus.d.ts +3 -0
- package/build/next/misc/Align.d.ts +3 -0
- package/build/next/misc/AutocompleteToken.d.ts +7 -0
- package/build/next/misc/Context.d.ts +5 -0
- package/build/next/misc/HttpMethod.d.ts +3 -0
- package/build/next/misc/Icon.d.ts +3 -0
- package/build/next/misc/IconNamed.d.ts +7 -0
- package/build/next/misc/IconText.d.ts +6 -0
- package/build/next/misc/Image.d.ts +8 -1
- package/build/next/misc/Size.d.ts +6 -0
- package/build/next/responses/action/ActionResponseBody.d.ts +11 -0
- package/build/next/responses/error/ErrorResponseBody.d.ts +47 -3
- package/build/next/responses/search/SearchResponseBody.d.ts +6 -0
- package/build/next/responses/search/SearchResult.d.ts +3 -0
- package/build/next/responses/search/SearchResultAction.d.ts +21 -0
- package/build/next/responses/search/SearchResultSearch.d.ts +22 -0
- package/build/next/responses/search/SearchSearchRequest.d.ts +17 -0
- package/build/next/schema/AllOfSchema.d.ts +55 -3
- package/build/next/schema/ArraySchema.d.ts +6 -0
- package/build/next/schema/ArraySchemaList.d.ts +74 -3
- package/build/next/schema/ArraySchemaTuple.d.ts +58 -3
- package/build/next/schema/BlobSchema.d.ts +80 -6
- package/build/next/schema/BooleanSchema.d.ts +98 -15
- package/build/next/schema/ConstSchema.d.ts +52 -3
- package/build/next/schema/IntegerSchema.d.ts +118 -15
- package/build/next/schema/NumberSchema.d.ts +119 -15
- package/build/next/schema/ObjectSchema.d.ts +69 -6
- package/build/next/schema/OneOfSchema.d.ts +111 -18
- package/build/next/schema/Schema.d.ts +11 -0
- package/build/next/schema/StringSchema.d.ts +150 -24
- package/build/next/schema/StringSchemaFormat.d.ts +3 -0
- package/build/next/step/Step.d.ts +62 -12
- package/package.json +3 -3
- package/build/next/schema/BlobSchemaSource.d.ts +0 -1
- package/build/next/schema/StringSchemaSource.d.ts +0 -4
|
@@ -1,14 +1,70 @@
|
|
|
1
1
|
import type { ActionType } from './ActionType';
|
|
2
2
|
import type { HttpMethod } from '../misc/HttpMethod';
|
|
3
3
|
import type { JsonElement } from '../JsonElement';
|
|
4
|
+
/**
|
|
5
|
+
* An action may be performed by the user when submitting a step. Actions can submit to an endpoint, progress the flow, or exit the flow.
|
|
6
|
+
* An action typically defines its URL and HTTP method to submit step data, and can optionally indicate that on success
|
|
7
|
+
* this action will end the flow.
|
|
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
|
+
* ### Behaviour
|
|
10
|
+
* #### Non-Exiting Actions
|
|
11
|
+
* If an action does not specify the `exit` property as true, it is expected that the action will submit the step payload.
|
|
12
|
+
* For example, the following action is a non-exiting action.
|
|
13
|
+
* ```kt
|
|
14
|
+
* action {
|
|
15
|
+
* url = "/submitForm"
|
|
16
|
+
* method = HttpMethod.POST
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
* #### Exiting Actions
|
|
20
|
+
* If an action specifies `exit` as `true`, it is expected that this action should terminate the flow. For exiting actions,
|
|
21
|
+
* the `url` property is optional.
|
|
22
|
+
* #### Submitting Exiting Actions
|
|
23
|
+
* If the `url` property is specified, the step payload will be submitted. On a successful response, the `result` property of the action (if provided)
|
|
24
|
+
* will be merged with the response to the submission, and that combined result will be used as the result of the flow, which will terminate. In case
|
|
25
|
+
* of any conflicts in the merge, the value of the result property of the action takes precedence.
|
|
26
|
+
* #### Non-Submitting Exiting Actions
|
|
27
|
+
* If the `url` property is not specified, when the action is taken the flow will be terminated and the value of the result
|
|
28
|
+
* property will be used as the result of the flow.
|
|
29
|
+
* ##### Example
|
|
30
|
+
* Given the following action:
|
|
31
|
+
* ```kt
|
|
32
|
+
* action {
|
|
33
|
+
* exit = true
|
|
34
|
+
* result = encodeToJsonElement(mapOf(
|
|
35
|
+
* "someKey" to "someValue"
|
|
36
|
+
* ))
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
* When this action is taken, the flow will be completed and the result of the flow will be:
|
|
40
|
+
* ```json
|
|
41
|
+
* {
|
|
42
|
+
* "someKey": "someValue"
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
* #### Actions Which Sometimes Exit
|
|
46
|
+
* In some cases, the provider of the step will not know if a submitting action will exit. For example, depending on the data entered by the user,
|
|
47
|
+
* the flow may be complete, or we may need to ask them some follow-up questions. In these cases the `exit` property shouldn’t be specified. Instead,
|
|
48
|
+
* the response to the submission should include an `X-DF-Response-Type: exit` header. When the client receives this header
|
|
49
|
+
* in the response, it will continue in the same way as it would for a submitting exiting action. See [com.wise.dynamicflow.responses.FlowResponse].
|
|
50
|
+
* #### Summary
|
|
51
|
+
* This tree summarises the possible paths an action can lead to:
|
|
52
|
+
* - If `exit` is `true`:
|
|
53
|
+
* - If `url` is `null`:
|
|
54
|
+
* - Exit flow with value of `result`
|
|
55
|
+
* - If `url` is non-null:
|
|
56
|
+
* - Submit to `url`
|
|
57
|
+
* - Merge value of `result` into response body
|
|
58
|
+
* - Exit flow with the merged result
|
|
59
|
+
* - If `exit` is `false`:
|
|
60
|
+
* - Submit to `url`
|
|
61
|
+
* - If response has header `X-DF-Response-Type: "exit"`:
|
|
62
|
+
* - Merge value of `result` into response body
|
|
63
|
+
* - Exit flow with the merged result
|
|
64
|
+
* - If response does not have header `X-DF-Response-Type: "exit"`:
|
|
65
|
+
* - The response is handles as normal
|
|
66
|
+
*/
|
|
4
67
|
export type Action = {
|
|
5
|
-
id?: string;
|
|
6
|
-
url?: string;
|
|
7
|
-
method?: HttpMethod;
|
|
8
|
-
exit?: boolean;
|
|
9
|
-
result?: JsonElement;
|
|
10
|
-
data?: JsonElement;
|
|
11
|
-
timeout?: number;
|
|
12
68
|
/**
|
|
13
69
|
* @deprecated Please use Button.title instead
|
|
14
70
|
*/
|
|
@@ -22,14 +78,46 @@ export type Action = {
|
|
|
22
78
|
*/
|
|
23
79
|
disabled?: boolean;
|
|
24
80
|
/**
|
|
81
|
+
* A unique id which can be used to refer to the action.
|
|
25
82
|
* @deprecated Please use 'id' instead
|
|
26
83
|
*/
|
|
27
84
|
$id?: string;
|
|
28
85
|
/**
|
|
86
|
+
* A reference to an action in the actions array.
|
|
29
87
|
* @deprecated Action references are deprecated.
|
|
30
88
|
*/
|
|
31
89
|
$ref?: string;
|
|
32
90
|
/**
|
|
91
|
+
* A unique id which can be used for analytics purposes.
|
|
92
|
+
*/
|
|
93
|
+
id?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The URL to use for the submission.
|
|
96
|
+
*/
|
|
97
|
+
url?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The HTTP method to use for the async submission. Defaults to POST.
|
|
100
|
+
*/
|
|
101
|
+
method?: HttpMethod;
|
|
102
|
+
/**
|
|
103
|
+
* See 'Exiting Actions'.
|
|
104
|
+
*/
|
|
105
|
+
exit?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* See 'Exiting Actions'.
|
|
108
|
+
*/
|
|
109
|
+
result?: JsonElement;
|
|
110
|
+
/**
|
|
111
|
+
* An object to be merged with the step data before submission.
|
|
112
|
+
*/
|
|
113
|
+
data?: JsonElement;
|
|
114
|
+
/**
|
|
115
|
+
* Suggested 'timeout' duration, in seconds, for the network request resulting from this action. Typically used when the endpoint is expected
|
|
116
|
+
* to take a long time to respond.
|
|
117
|
+
*/
|
|
118
|
+
timeout?: number;
|
|
119
|
+
/**
|
|
120
|
+
* Indicates that the action should not trigger client-side validation.
|
|
33
121
|
* @experimental This feature may be changed in the future without notice.
|
|
34
122
|
*/
|
|
35
123
|
skipValidation?: boolean;
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External specifies a URL to be opened automatically when a step loads. Url-opening behaviour depends on the platform.
|
|
3
|
+
* General guidance is as follows:
|
|
4
|
+
* Web:
|
|
5
|
+
* - Open a URL in a new browser tab.
|
|
6
|
+
* Mobile:
|
|
7
|
+
* - Open a URL in the default browser.
|
|
8
|
+
* - Or open another app via a universal link.
|
|
9
|
+
* External is typically used alongside [Polling].
|
|
10
|
+
* ### Example
|
|
11
|
+
* ```kt
|
|
12
|
+
* Step.build {
|
|
13
|
+
* id = "external example"
|
|
14
|
+
* title = ""
|
|
15
|
+
* external {
|
|
16
|
+
* url = "https://foo.bar/external-request?id=12345"
|
|
17
|
+
* }
|
|
18
|
+
* layout {
|
|
19
|
+
* heading {
|
|
20
|
+
* text = "Your bank is opening in another window"
|
|
21
|
+
* }
|
|
22
|
+
* paragraph {
|
|
23
|
+
* text = "Please follow their instructions."
|
|
24
|
+
* }
|
|
25
|
+
* markdown {
|
|
26
|
+
* // Note that the "Reopen window" button/link is just a normal Markdown link that happens to specify the same URL as External.
|
|
27
|
+
* content = "[Reopen window](https://foo.bar/external-request?id=12345)"
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
1
33
|
export type External = {
|
|
34
|
+
/**
|
|
35
|
+
* The URL to open.
|
|
36
|
+
*/
|
|
2
37
|
url: string;
|
|
3
38
|
};
|
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
import type { Action } from './Action';
|
|
2
|
+
/**
|
|
3
|
+
* A pattern which is matched against any incoming universal links, with an action to trigger when the pattern is matched.
|
|
4
|
+
* Link handling is typically used alongside [External].
|
|
5
|
+
* ### Action Data
|
|
6
|
+
* When the action is performed, the payload will contain all the data usually submitted with an action. Additionally,
|
|
7
|
+
* the data will be merged with an object containing the following structure:
|
|
8
|
+
* ```json
|
|
9
|
+
* {
|
|
10
|
+
* "url": "https://wise.com/some-url"
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
* Where "https://wise.com/some-url" is the full URL that was matched against the pattern.
|
|
14
|
+
* ### Example
|
|
15
|
+
* Given the step below, the client will listen for any deep or universal links that are used to open the app.
|
|
16
|
+
* ```kt
|
|
17
|
+
* Step.build {
|
|
18
|
+
* layout { }
|
|
19
|
+
* linkHandlers = listOf(
|
|
20
|
+
* LinkHandler(
|
|
21
|
+
* regexPattern = """https:\/\/wise.com\/success-callback.""",
|
|
22
|
+
* action = Action.build {
|
|
23
|
+
* url = "/handle-success-callback"
|
|
24
|
+
* data = encodeToJsonElement(mapOf("some-additional-data" to true))
|
|
25
|
+
* }
|
|
26
|
+
* ),
|
|
27
|
+
* LinkHandler(
|
|
28
|
+
* regexPattern = """https:\/\/wise\.com\/failure-callback.*""",
|
|
29
|
+
* action = Action.build {
|
|
30
|
+
* url = "/handle-failure-callback"
|
|
31
|
+
* }
|
|
32
|
+
* )
|
|
33
|
+
* )
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
* If the user is on this step and then opens a universal or deep link, it'll be matched against the patterns
|
|
37
|
+
* in the array, and any matching action will be executed.
|
|
38
|
+
* For example, if the user opens the app with the universal link "https://wise.com/success-callback?token=1234",
|
|
39
|
+
* this will be matched against the first pattern in the array. The corresponding action will be executed, and
|
|
40
|
+
* the payload will also contain the url that was matched - for example in this case the following data
|
|
41
|
+
* would be submitted to "/handle-success-callback":
|
|
42
|
+
* ```json
|
|
43
|
+
* {
|
|
44
|
+
* "some-additional-data": true,
|
|
45
|
+
* "url": "https://wise.com/success-callback?token=1234"
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
* If a link is opened which doesn't match any of the patterns then no action is taken.
|
|
49
|
+
*/
|
|
2
50
|
export type LinkHandler = {
|
|
51
|
+
/**
|
|
52
|
+
* A regex pattern to be matched against any incoming universal links.
|
|
53
|
+
*/
|
|
3
54
|
regexPattern: string;
|
|
55
|
+
/**
|
|
56
|
+
* An action to be triggered when the regex pattern is matched.
|
|
57
|
+
*/
|
|
4
58
|
action: Action;
|
|
5
59
|
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import type { NavigationBackBehaviour } from './NavigationBackBehaviour';
|
|
2
|
+
import type { NavigationStackBehavior } from './NavigationStackBehavior';
|
|
2
3
|
/**
|
|
4
|
+
* Allows configuration of how navigating between steps should happen.
|
|
5
|
+
* For example, it can be used to control what happens when the user navigates back from a step.
|
|
3
6
|
* @experimental This feature may be changed in the future without notice.
|
|
4
7
|
*/
|
|
5
8
|
export type Navigation = {
|
|
6
|
-
back?: NavigationBackBehaviour;
|
|
7
9
|
/**
|
|
8
10
|
* @deprecated Please use 'back' instead
|
|
9
11
|
*/
|
|
10
12
|
backButton?: NavigationBackBehaviour;
|
|
13
|
+
/**
|
|
14
|
+
* Configure custom back behaviour which overrides any native back behaviour of the client.
|
|
15
|
+
*/
|
|
16
|
+
back?: NavigationBackBehaviour;
|
|
17
|
+
/**
|
|
18
|
+
* Configure the behaviour of the navigation stack when this step is presented.
|
|
19
|
+
*/
|
|
20
|
+
stackBehavior?: NavigationStackBehavior;
|
|
11
21
|
};
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { Action } from './Action';
|
|
2
2
|
/**
|
|
3
|
+
* Describes how back navigation should be handled.
|
|
3
4
|
* @experimental This feature may be changed in the future without notice.
|
|
4
5
|
*/
|
|
5
6
|
export type NavigationBackBehaviour = {
|
|
7
|
+
/**
|
|
8
|
+
* A title describing the back action.
|
|
9
|
+
*/
|
|
6
10
|
title?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The [com.wise.dynamicflow.feature.Action] triggered when the user navigates back.
|
|
13
|
+
* Note that this action will not validate the model against the schema before submitting.
|
|
14
|
+
*/
|
|
7
15
|
action: Action;
|
|
8
16
|
};
|
|
@@ -1,9 +1,82 @@
|
|
|
1
1
|
import type { Schema } from '../schema/Schema';
|
|
2
2
|
import type { HttpMethod } from '../misc/HttpMethod';
|
|
3
|
+
/**
|
|
4
|
+
* Persist Async allows you to submit part of a step asynchronously to an endpoint, then submit an identifier from that asynchronous submission
|
|
5
|
+
* as part of the main step submission. This can be useful in cases where the content of a field is very large (for example file upload),
|
|
6
|
+
* or for if you need to tokenize part of the form for security reasons (e.g. submitting card numbers to a PCI-compliant server).
|
|
7
|
+
* This functionality is specified using the `persistAsync` property of a [com.wise.dynamicflow.schema.Schema].
|
|
8
|
+
* Note that the schema on which the `persistAsync` property is set should reflect the value that is
|
|
9
|
+
* submitted (i.e. the token/identifier), while the [schema] property defines
|
|
10
|
+
* the schema that is shown to the user and submitted to the persist async endpoint.
|
|
11
|
+
* ### Example
|
|
12
|
+
* When the value of the field changes, a request is sent to the URL defined in the `persistAsync` object, where the request body is
|
|
13
|
+
* a JSON object containing the value of the field under a property matching the value of `persistAsync.param`.
|
|
14
|
+
* For example, if the schema was defined as:
|
|
15
|
+
* ```kt
|
|
16
|
+
* Step.build {
|
|
17
|
+
* layout { }
|
|
18
|
+
* schemas {
|
|
19
|
+
* string {
|
|
20
|
+
* persistAsync {
|
|
21
|
+
* url = "/persistCard"
|
|
22
|
+
* param = "number"
|
|
23
|
+
* idProperty = "token"
|
|
24
|
+
* schema = StringSchema.build {
|
|
25
|
+
* title = "Card Number"
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
* Then a text input titled "Card Number" would be rendered in the form to represent this schema. When the user enters a card number
|
|
33
|
+
* of "1234567890", a `POST` request would be made to the `/persistCard` endpoint with the following body:
|
|
34
|
+
* ```json
|
|
35
|
+
* {
|
|
36
|
+
* "number": "1234567890"
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
* On success, the response body should be a JSON object which contains an identifier that should be used in the main submission
|
|
40
|
+
* under the property specified in `persistAsync.idProperty` - for example:
|
|
41
|
+
* ```json
|
|
42
|
+
* {
|
|
43
|
+
* "token": "ce0a93b2-f11d-49a4-ab02-705bb66f5b39"
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
* When the user submits the form, the submission will contain this identifier as the value of the schema.
|
|
47
|
+
* ### Error Handling
|
|
48
|
+
* In the case of an error, the standard [StepError] response can be used.
|
|
49
|
+
* In the card example above, the server could respond as follows with a non-2xx status code to show an error
|
|
50
|
+
* on the card number field:
|
|
51
|
+
* ```json
|
|
52
|
+
* {
|
|
53
|
+
* "validation": {
|
|
54
|
+
* "number": "This card number is invalid"
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
* If a persist async call fails, the client should re-attempt it on the next form submission. A failure should prevent
|
|
59
|
+
* submission and display an error to the user.
|
|
60
|
+
*/
|
|
3
61
|
export type PersistAsync = {
|
|
62
|
+
/**
|
|
63
|
+
* The name of the property under which the value of the schema will be sent in the request body.
|
|
64
|
+
*/
|
|
4
65
|
param: string;
|
|
66
|
+
/**
|
|
67
|
+
* The name of the property under which the value used in the main submission can be found in the response body.
|
|
68
|
+
*/
|
|
5
69
|
idProperty: string;
|
|
70
|
+
/**
|
|
71
|
+
* The schema which will be shown to the user, and whose value will be sent in the Persist Async submission.
|
|
72
|
+
*/
|
|
6
73
|
schema: Schema;
|
|
74
|
+
/**
|
|
75
|
+
* The URL used for the async submission.
|
|
76
|
+
*/
|
|
7
77
|
url: string;
|
|
78
|
+
/**
|
|
79
|
+
* The HTTP method used for the async submission. Defaults to POST.
|
|
80
|
+
*/
|
|
8
81
|
method: HttpMethod;
|
|
9
82
|
};
|
|
@@ -1,7 +1,50 @@
|
|
|
1
1
|
import type { PollingOnError } from './PollingOnError';
|
|
2
|
+
/**
|
|
3
|
+
* Polling instructs the client to periodically make an HTTP GET request to the specified URL and eventually trigger an action.
|
|
4
|
+
* Polling is typically used alongside [External]. For example, a step may first open an external URL and then poll for a server state change.
|
|
5
|
+
* The client may continue to another step or end the flow.
|
|
6
|
+
* ### Example
|
|
7
|
+
* Given the step below, the client will start making requests to the specified URL every 5 seconds.
|
|
8
|
+
* If the response is a json object with an `action` property, for instance `{ action: { url: "/next-step", "data": "all-ok" } }`, then the action is "executed". This usually loads the next step, or exits the flow.
|
|
9
|
+
* If the response body is not a json object with an `action` property, but the status code is 2xx, then the client continues to make requests until an `action` is found or `maxAttempts` is reached.
|
|
10
|
+
* ```kt
|
|
11
|
+
* Step.build {
|
|
12
|
+
* layout { }
|
|
13
|
+
* polling {
|
|
14
|
+
* url = "https://bar.foo/status?id=12345"
|
|
15
|
+
* interval = 5
|
|
16
|
+
* maxAttempts = 100
|
|
17
|
+
* onError {
|
|
18
|
+
* action {
|
|
19
|
+
* exit = true
|
|
20
|
+
* result = encodeToJsonElement(mapOf("exit-action-data" to "EXIT!!!"))
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
* #### Error handling
|
|
27
|
+
* Given the above step, the action in the `onError` object is triggered if:
|
|
28
|
+
* - the response status code is a failure (>=400).
|
|
29
|
+
* - the number of attempts exceeds the specified `maxAttempts`
|
|
30
|
+
*/
|
|
2
31
|
export type Polling = {
|
|
32
|
+
/**
|
|
33
|
+
* The URL to open.
|
|
34
|
+
*/
|
|
3
35
|
url: string;
|
|
36
|
+
/**
|
|
37
|
+
* The time interval between requests, in seconds.
|
|
38
|
+
*/
|
|
4
39
|
interval: number;
|
|
40
|
+
/**
|
|
41
|
+
* The maximum number of requests that may be attempted, before triggering the [onError] action.
|
|
42
|
+
* @see onError
|
|
43
|
+
*/
|
|
5
44
|
maxAttempts: number;
|
|
45
|
+
/**
|
|
46
|
+
* An object with one action property to be triggered when polling fails.
|
|
47
|
+
* @see maxAttempts
|
|
48
|
+
*/
|
|
6
49
|
onError: PollingOnError;
|
|
7
50
|
};
|
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
import type { JsonElement } from '../JsonElement';
|
|
2
|
+
/**
|
|
3
|
+
* Errors which should be displayed to the user when the step loads.
|
|
4
|
+
*/
|
|
2
5
|
export type StepError = {
|
|
6
|
+
/**
|
|
7
|
+
* A general error message, not related to any particular schema.
|
|
8
|
+
*/
|
|
3
9
|
error?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Error messages related to specific fields. The structure of this value must match the structure of the data
|
|
12
|
+
* to be validated.
|
|
13
|
+
* For example, given the following model:
|
|
14
|
+
* ```
|
|
15
|
+
* {
|
|
16
|
+
* "name": "A Person",
|
|
17
|
+
* "bankDetails": {
|
|
18
|
+
* "accountNumber": "31510604",
|
|
19
|
+
* "sortCode": "100000"
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
* A validation message for the "sortCode" field should be provided as follows:
|
|
24
|
+
* ```
|
|
25
|
+
* {
|
|
26
|
+
* "bankDetails": {
|
|
27
|
+
* "sortCode": "Please enter a valid sort code"
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
* Multiple validation messages can be returned at once, for example:
|
|
32
|
+
* ```
|
|
33
|
+
* {
|
|
34
|
+
* "name": "Please enter a full name",
|
|
35
|
+
* "bankDetails": {
|
|
36
|
+
* "sortCode": "Please enter a valid sort code"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
4
41
|
validation?: JsonElement;
|
|
5
42
|
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { SummaryProvider } from './SummaryProvider';
|
|
2
2
|
import type { SummarySummariser } from './SummarySummariser';
|
|
3
|
+
/**
|
|
4
|
+
* Summary specifies a configuration to produce user-facing copy for child schemas of [com.wise.dynamicflow.schema.ArraySchema.List].
|
|
5
|
+
* Default values may be specified to be used if values are not provided on child schemas.
|
|
6
|
+
*/
|
|
3
7
|
export type Summary = SummaryProvider | SummarySummariser;
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A schema which provides values for the summary.
|
|
3
|
+
*/
|
|
1
4
|
export type SummaryProvider = {
|
|
5
|
+
/**
|
|
6
|
+
* If true, the value of this schema can be used as a summary title.
|
|
7
|
+
*/
|
|
2
8
|
providesTitle?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true, the value of this schema can be used as a summary description.
|
|
11
|
+
*/
|
|
3
12
|
providesDescription?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If true, the icon of this schema can be used as a summary icon.
|
|
15
|
+
*/
|
|
4
16
|
providesIcon?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* If true, the image of this schema can be used as a summary image.
|
|
19
|
+
*/
|
|
5
20
|
providesImage?: boolean;
|
|
6
21
|
};
|
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
import type { Icon } from '../misc/Icon';
|
|
2
2
|
import type { ImageLayout } from '../layout/ImageLayout';
|
|
3
|
+
/**
|
|
4
|
+
* A schema which summarises its child schemas.
|
|
5
|
+
* Default values can be specified for the summary if values are not provided by its child schemas.
|
|
6
|
+
*/
|
|
3
7
|
export type SummarySummariser = {
|
|
8
|
+
/**
|
|
9
|
+
* A title to be used for the summary if a title is not provided by a child schema.
|
|
10
|
+
*/
|
|
4
11
|
defaultTitle?: string;
|
|
12
|
+
/**
|
|
13
|
+
* A description to be used for the summary if a description is not provided by a child schema.
|
|
14
|
+
*/
|
|
5
15
|
defaultDescription?: string;
|
|
16
|
+
/**
|
|
17
|
+
* An icon to be used for the summary if an icon is not provided by a child schema.
|
|
18
|
+
*/
|
|
6
19
|
defaultIcon?: Icon;
|
|
20
|
+
/**
|
|
21
|
+
* An image to be used for the summary if an image is not provided by a child schema.
|
|
22
|
+
*/
|
|
7
23
|
defaultImage?: ImageLayout;
|
|
24
|
+
/**
|
|
25
|
+
* If true, the value of this schema can be used as a summary title.
|
|
26
|
+
*/
|
|
8
27
|
providesTitle?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* If true, the value of this schema can be used as a summary description.
|
|
30
|
+
*/
|
|
9
31
|
providesDescription?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* If true, the icon of this schema can be used as a summary icon.
|
|
34
|
+
*/
|
|
10
35
|
providesIcon?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* If true, the image of this schema can be used as a summary image.
|
|
38
|
+
*/
|
|
11
39
|
providesImage?: boolean;
|
|
12
40
|
};
|
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
import type { HttpMethod } from '../misc/HttpMethod';
|
|
2
|
+
/**
|
|
3
|
+
* Validation Async allows you to validate the value of a field on change by calling an endpoint.
|
|
4
|
+
* This allows for more complex validation than is possible using local validation rules.
|
|
5
|
+
* When the value of a schema with a [ValidateAsync] configuration changes, first any local validation
|
|
6
|
+
* is run. If this local validation passes, a request is sent to the URL defined at [url],
|
|
7
|
+
* where the request body is a JSON object containing the value of the field under a property matching
|
|
8
|
+
* the value of [param].
|
|
9
|
+
* On success, the server should respond with a `2xx` status code and either an empty body, in which
|
|
10
|
+
* case no feedback is given to the user, or a JSON body with a `message` property, which will be shown
|
|
11
|
+
* to the user. On failure, the server should respond with a `422` status code and a JSON body with
|
|
12
|
+
* a `message` property which will be shown to the user.
|
|
13
|
+
* **Note that "failed" validation does not prevent the client from submitting the step in the case of async validation.**
|
|
14
|
+
* Also, in the case where the validation-async network call fails or returns an unexpected response,
|
|
15
|
+
* the client ignores the problem and allows the user to submit.
|
|
16
|
+
* For these reasons, any validation which is critical should also be performed by the server on submission.
|
|
17
|
+
* ### Example
|
|
18
|
+
* Given a schema defined as:
|
|
19
|
+
* ```kt
|
|
20
|
+
* string {
|
|
21
|
+
* title = "IBAN"
|
|
22
|
+
* validationAsync = ValidateAsync(
|
|
23
|
+
* param = "iban",
|
|
24
|
+
* method = HttpMethod.POST,
|
|
25
|
+
* url = "/validate-iban"
|
|
26
|
+
* )
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
* When the user enters a value, e.g. "NL30ABNA7619995846", a `POST` request would be made to the `/validate-iban` endpoint with the following body:
|
|
30
|
+
* ```json
|
|
31
|
+
* {
|
|
32
|
+
* "iban": "NL30ABNA7619995846"
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
* On success, the server responds with a `200` status code and the response body should either be empty, in which case no feedback will be given to the user, or a JSON body with the following structure:
|
|
36
|
+
* ```json
|
|
37
|
+
* {
|
|
38
|
+
* "message": "Valid IBAN"
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
* In which case the message will be displayed to the user to let them know the value they have entered is valid.
|
|
42
|
+
* On failure, the server should respond with a `422` status code and a json body giving a message to display to the user:
|
|
43
|
+
* ```json
|
|
44
|
+
* {
|
|
45
|
+
* "message": "This IBAN is invalid. Please check it again."
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
2
49
|
export type ValidateAsync = {
|
|
50
|
+
/**
|
|
51
|
+
* The name of the property under which the value of the schema will be sent in the request body.
|
|
52
|
+
*/
|
|
3
53
|
param: string;
|
|
54
|
+
/**
|
|
55
|
+
* The HTTP method to use for the request. Only methods which allow a request body are supported.
|
|
56
|
+
*/
|
|
4
57
|
method: HttpMethod;
|
|
58
|
+
/**
|
|
59
|
+
* The URL to use for the request.
|
|
60
|
+
*/
|
|
5
61
|
url: string;
|
|
6
62
|
};
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import type { Context } from '../misc/Context';
|
|
2
2
|
import type { Size } from '../misc/Size';
|
|
3
|
+
/**
|
|
4
|
+
* Show an attention-grabbing message.
|
|
5
|
+
* Alerts can be used to communicate important messages to the user, drawing more attention than a standard paragraph or info layout.
|
|
6
|
+
*/
|
|
3
7
|
export type AlertLayout = {
|
|
8
|
+
/**
|
|
9
|
+
* It must be `alert`.
|
|
10
|
+
*/
|
|
4
11
|
type: 'alert';
|
|
12
|
+
/**
|
|
13
|
+
* The content of the alert as string. The following subset of markdown features are supported:
|
|
14
|
+
* Emphasis, strong emphasis.
|
|
15
|
+
*/
|
|
5
16
|
markdown: string;
|
|
17
|
+
/**
|
|
18
|
+
* The semantics of the alert. Defaults to `neutral`.
|
|
19
|
+
*/
|
|
6
20
|
context?: Context;
|
|
21
|
+
/**
|
|
22
|
+
* Specify a particular control to use to represent the layout. If the control is unknown, it will be ignored.
|
|
23
|
+
*/
|
|
7
24
|
control?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The vertical margin to apply above this component. Defaults to `md`.
|
|
27
|
+
*/
|
|
8
28
|
margin?: Size;
|
|
9
29
|
};
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import type { Layout } from './Layout';
|
|
2
2
|
import type { Size } from '../misc/Size';
|
|
3
|
+
/**
|
|
4
|
+
* A container for a group of components with an optional border.
|
|
5
|
+
*/
|
|
3
6
|
export type BoxLayout = {
|
|
7
|
+
/**
|
|
8
|
+
* It must be `box`.
|
|
9
|
+
*/
|
|
4
10
|
type: 'box';
|
|
11
|
+
/**
|
|
12
|
+
* The contained components.
|
|
13
|
+
*/
|
|
5
14
|
components: Layout[];
|
|
15
|
+
/**
|
|
16
|
+
* The width of the box. Defaults to `xl`.
|
|
17
|
+
*/
|
|
6
18
|
width?: Size;
|
|
19
|
+
/**
|
|
20
|
+
* If true, a border is displayed around the box. Defaults to false.
|
|
21
|
+
*/
|
|
7
22
|
border?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Specify a particular control to use to represent the layout. If the control is unknown, it will be ignored.
|
|
25
|
+
*/
|
|
8
26
|
control?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The vertical margin to apply above this component. Defaults to `md`.
|
|
29
|
+
*/
|
|
9
30
|
margin?: Size;
|
|
10
31
|
};
|