@wise/dynamic-flow-types 1.1.1 → 1.2.1

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.
@@ -8,5 +8,4 @@ export * from './spec/Promotion';
8
8
  export * from './spec/Schema';
9
9
  export * from './spec/Step';
10
10
  export * from './spec/ValidationAsync';
11
-
12
11
  export type { FileUploadSchema, CameraDirection } from './spec/FileUploadSchema';
@@ -0,0 +1,23 @@
1
+ import { HttpMethod } from './core';
2
+ type CoreAction = {
3
+ id?: string;
4
+ /**
5
+ * @deprecated Please use id instead
6
+ */
7
+ $id?: string;
8
+ data?: Record<string, unknown>;
9
+ exit?: boolean;
10
+ method?: HttpMethod;
11
+ result?: Record<string, unknown>;
12
+ timeout?: number;
13
+ url?: string;
14
+ };
15
+ export type Action = CoreAction & {
16
+ title?: string;
17
+ type?: 'primary' | 'secondary' | 'link' | 'positive' | 'negative';
18
+ disabled?: boolean;
19
+ };
20
+ export type ActionResponseBody = {
21
+ action: Action;
22
+ };
23
+ export {};
@@ -0,0 +1,19 @@
1
+ import { ImageLayout } from './LayoutComponent';
2
+ import { StringSchema } from './Schema';
3
+ export type FileUploadSchema = Omit<StringSchema, 'type' | 'format' | 'source' | 'image' | 'cameraConfig'> & {
4
+ type: 'string';
5
+ format: 'base64url';
6
+ source?: 'camera' | 'file';
7
+ image?: ImageLayout;
8
+ cameraConfig?: CameraConfig;
9
+ };
10
+ type CameraConfig = {
11
+ assets?: {
12
+ overlay?: string;
13
+ outline?: string;
14
+ };
15
+ direction?: CameraDirection;
16
+ instructions?: string;
17
+ };
18
+ export type CameraDirection = 'back' | 'front';
19
+ export {};
@@ -0,0 +1,164 @@
1
+ import { Action } from './Action';
2
+ import { ExternalStepPollingConfiguration, ExternalStepPollingResponseHandler } from './Polling';
3
+ import { Schema } from './Schema';
4
+ import { Margin, Size, Icon, Image, Align, Orientation, Reference, Alert } from './core';
5
+ export type LayoutComponent = AlertLayout | BoxLayout | ButtonLayout | ColumnsLayout | DecisionLayout | DividerLayout | ExternalLayout | FormLayout | HeadingLayout | ImageLayout | InfoLayout | ListLayout | LoadingIndicatorLayout | MarkdownLayout | ParagraphLayout | ReviewLayout | StatusListLayout;
6
+ export type AlertLayout = {
7
+ type: 'alert';
8
+ } & Alert;
9
+ export type BoxLayout = {
10
+ type: 'box';
11
+ components: LayoutComponent[];
12
+ width?: Size;
13
+ margin?: Margin;
14
+ border?: boolean;
15
+ };
16
+ export type ButtonLayout = {
17
+ type: 'button';
18
+ action: Action | Reference;
19
+ title?: string;
20
+ control?: 'primary' | 'secondary' | 'tertiary';
21
+ context?: 'neutral' | 'positive' | 'negative';
22
+ disabled?: boolean;
23
+ margin?: Margin;
24
+ /**
25
+ * @deprecated Only supported on web client
26
+ */
27
+ size?: Size;
28
+ };
29
+ export type ColumnsLayout = {
30
+ type: 'columns';
31
+ left: LayoutComponent[];
32
+ right: LayoutComponent[];
33
+ bias?: 'none' | 'left' | 'right';
34
+ margin?: Margin;
35
+ };
36
+ export type DecisionLayout = {
37
+ type: 'decision';
38
+ options: DecisionOption[];
39
+ margin?: Margin;
40
+ };
41
+ type DecisionOption = {
42
+ action: Action | Reference;
43
+ title: string;
44
+ description?: string;
45
+ icon?: Icon;
46
+ image?: Image;
47
+ disabled?: boolean;
48
+ };
49
+ /**
50
+ * @deprecated Only supported on web client
51
+ */
52
+ export type DividerLayout = {
53
+ type: 'divider';
54
+ margin?: Margin;
55
+ };
56
+ /**
57
+ * @deprecated Please use the external feature set instead
58
+ */
59
+ export type ExternalLayout = {
60
+ type: 'external';
61
+ requestUrl: string;
62
+ polling?: Omit<ExternalStepPollingConfiguration, 'responseHandlers'>;
63
+ responseHandlers?: ExternalStepPollingResponseHandler[];
64
+ retryTitle?: string;
65
+ };
66
+ export type FormLayout = {
67
+ type: 'form';
68
+ schemaId?: never;
69
+ schema: Schema | Reference;
70
+ margin?: Margin;
71
+ } | {
72
+ type: 'form';
73
+ schemaId: string;
74
+ schema?: never;
75
+ margin?: Margin;
76
+ };
77
+ export type HeadingLayout = {
78
+ type: 'heading';
79
+ size?: Size;
80
+ text: string;
81
+ margin?: Margin;
82
+ align?: Align;
83
+ };
84
+ export type ImageLayout = {
85
+ type: 'image';
86
+ url: string;
87
+ /**
88
+ * @deprecated Only supported on web client
89
+ */
90
+ text?: string;
91
+ size?: Size;
92
+ margin?: Margin;
93
+ };
94
+ export type InfoLayout = {
95
+ type: 'info';
96
+ markdown: string;
97
+ margin?: Margin;
98
+ align?: Align;
99
+ };
100
+ /**
101
+ * @deprecated Please use StatusListLayout instead
102
+ */
103
+ export type ListLayout = {
104
+ type: 'list';
105
+ items: ListItem[];
106
+ title?: string;
107
+ margin?: Margin;
108
+ };
109
+ type ListItem = {
110
+ title: string;
111
+ description?: string;
112
+ icon?: Icon;
113
+ status?: 'positive' | 'neutral' | 'warning';
114
+ };
115
+ export type StatusListLayout = {
116
+ type: 'status-list';
117
+ items: StatusListItem[];
118
+ title?: string;
119
+ margin?: Margin;
120
+ };
121
+ type StatusListItem = {
122
+ title: string;
123
+ description?: string;
124
+ icon?: Icon;
125
+ status?: 'done' | 'not-done' | 'pending';
126
+ };
127
+ export type LoadingIndicatorLayout = {
128
+ type: 'loading-indicator';
129
+ margin?: Margin;
130
+ size?: Size;
131
+ };
132
+ export type MarkdownLayout = {
133
+ type: 'markdown';
134
+ content: string;
135
+ margin?: Margin;
136
+ align?: Align;
137
+ };
138
+ export type ParagraphLayout = {
139
+ type: 'paragraph';
140
+ text: string;
141
+ control?: 'copyable';
142
+ margin?: Margin;
143
+ align?: Align;
144
+ };
145
+ export type ReviewLayout = {
146
+ type: 'review';
147
+ title?: string;
148
+ fields: ReviewField[];
149
+ control?: string;
150
+ /**
151
+ * @deprecated Use `control` instead.
152
+ */
153
+ orientation?: Orientation;
154
+ margin?: Margin;
155
+ /**
156
+ * @deprecated Only supported on web client
157
+ */
158
+ action?: Action;
159
+ };
160
+ type ReviewField = {
161
+ label: string;
162
+ value: string | number | boolean | null | undefined;
163
+ };
164
+ export {};
@@ -1,4 +1,6 @@
1
1
  export type BasicModel = boolean | number | string;
2
- export type ObjectModel = { [key: string]: Model };
2
+ export type ObjectModel = {
3
+ [key: string]: Model;
4
+ };
3
5
  export type ArrayModel = Array<BasicModel | null>;
4
6
  export type Model = BasicModel | ObjectModel | ArrayModel | null;
@@ -0,0 +1,8 @@
1
+ import { Schema } from './Schema';
2
+ export type PersistAsync = {
3
+ idProperty: string;
4
+ method?: 'POST' | 'PUT' | 'PATCH';
5
+ param: string;
6
+ schema: Schema;
7
+ url: string;
8
+ };
@@ -1,30 +1,26 @@
1
1
  import { Action } from './Action';
2
-
3
2
  export type PollingConfiguration = {
4
- url: string;
5
- interval: number;
6
- maxAttempts: number;
7
- onError: {
8
- action: Action;
9
- };
3
+ url: string;
4
+ interval: number;
5
+ maxAttempts: number;
6
+ onError: {
7
+ action: Action;
8
+ };
10
9
  };
11
-
12
10
  export type PollingResponse = {
13
- action: Action;
11
+ action: Action;
14
12
  } | null;
15
-
16
13
  /**
17
14
  * @deprecated Please use external feature instead of external step
18
15
  */
19
16
  export type ExternalStepPollingConfiguration = PollingConfiguration & {
20
- maxConsecutiveFails: number;
21
- responseHandlers: ExternalStepPollingResponseHandler[];
17
+ maxConsecutiveFails: number;
18
+ responseHandlers: ExternalStepPollingResponseHandler[];
22
19
  };
23
-
24
20
  /**
25
21
  * @deprecated Please use external feature instead of external step
26
22
  */
27
23
  export type ExternalStepPollingResponseHandler = {
28
- result: string;
29
- action: Action;
24
+ result: string;
25
+ action: Action;
30
26
  };
@@ -0,0 +1,20 @@
1
+ import { Icon, Image } from './core';
2
+ export type Promotion = {
3
+ displayTwice?: boolean;
4
+ other: {
5
+ description?: string;
6
+ heading?: {
7
+ text: string;
8
+ };
9
+ icon?: Icon;
10
+ image?: Image;
11
+ title: string;
12
+ };
13
+ promoted?: {
14
+ title?: string;
15
+ description?: string;
16
+ };
17
+ control?: string;
18
+ checkedMeans?: 'promoted' | 'other';
19
+ default?: 'promoted' | 'other';
20
+ };
@@ -0,0 +1,179 @@
1
+ import { FileUploadSchema } from './FileUploadSchema';
2
+ import { Model, ObjectModel } from './Model';
3
+ import { PersistAsync } from './PersistAsync';
4
+ import { Promotion } from './Promotion';
5
+ import { ValidationAsync } from './ValidationAsync';
6
+ import { Icon, Image, Alert, Help } from './core';
7
+ export type Schema = AllOfSchema | ArraySchema | BlobSchema | BooleanSchema | IntegerSchema | NumberSchema | ObjectSchema | OneOfSchema | StringSchema | ListArraySchema | TupleArraySchema | FileUploadSchema | MultipleFileUploadSchema | ConstSchema;
8
+ type SchemaBase = {
9
+ $id?: string;
10
+ type?: 'boolean' | 'blob' | 'array' | 'integer' | 'number' | 'string' | 'object';
11
+ alert?: Alert;
12
+ autofillProvider?: string;
13
+ autofillKey?: string;
14
+ allOf?: never;
15
+ analyticsId?: string;
16
+ const?: Model;
17
+ default?: Model;
18
+ description?: string;
19
+ disabled?: boolean;
20
+ format?: string;
21
+ help?: Help;
22
+ hidden?: boolean;
23
+ icon?: Icon;
24
+ image?: Image;
25
+ oneOf?: never;
26
+ persistAsync?: never;
27
+ promoted?: boolean;
28
+ promotion?: never;
29
+ /**
30
+ * @deprecated Please use disabled
31
+ */
32
+ readOnly?: boolean;
33
+ refreshStepOnChange?: boolean;
34
+ /**
35
+ * @deprecated Please use refreshStepOnChange instead
36
+ */
37
+ refreshFormOnChange?: boolean;
38
+ refreshUrl?: string;
39
+ /**
40
+ * @deprecated Please use refreshUrl instead
41
+ */
42
+ refreshFormUrl?: string;
43
+ summary?: SchemaSummary;
44
+ title?: string;
45
+ validationAsync?: ValidationAsync;
46
+ validationMessages?: Record<string, string>;
47
+ /**
48
+ * @deprecated Please use oneOf instead
49
+ */
50
+ values?: {
51
+ label: string;
52
+ value: string | number;
53
+ }[];
54
+ /**
55
+ * @deprecated Please use layouts instead
56
+ */
57
+ width?: string;
58
+ keywords?: string[];
59
+ };
60
+ export type AllOfSchema = Omit<SchemaBase, 'allOf'> & {
61
+ allOf: Schema[];
62
+ maximum?: number;
63
+ minimum?: number;
64
+ minLength?: number;
65
+ maxLength?: number;
66
+ minItems?: number;
67
+ maxItems?: number;
68
+ required?: string[];
69
+ disabled?: never;
70
+ };
71
+ export type ArraySchema = Omit<SchemaBase, 'persistAsync'> & {
72
+ type: 'array';
73
+ addItemTitle?: string;
74
+ editItemTitle?: string;
75
+ removeItemTitle?: string;
76
+ items: Schema | Schema[];
77
+ maxItems?: number;
78
+ minItems?: number;
79
+ persistAsync?: PersistAsync;
80
+ summary?: ArraySchemaSummary;
81
+ };
82
+ export type ListArraySchema = ArraySchema & {
83
+ items: Schema;
84
+ };
85
+ export type TupleArraySchema = ArraySchema & {
86
+ items: Schema[];
87
+ };
88
+ export type MultipleFileUploadSchema = ListArraySchema & {
89
+ items: PersistAsyncSchema;
90
+ };
91
+ export type BlobSchema = SchemaBase & {
92
+ type: 'blob';
93
+ accepts?: string[];
94
+ maxSize?: number;
95
+ };
96
+ export type BooleanSchema = SchemaBase & {
97
+ type: 'boolean';
98
+ default?: boolean;
99
+ const?: boolean;
100
+ oneOf?: BooleanSchema[];
101
+ };
102
+ export type ConstSchema = SchemaBase & {
103
+ type?: never;
104
+ const: Model;
105
+ };
106
+ export type IntegerSchema = Omit<SchemaBase, 'persistAsync'> & {
107
+ type: 'integer';
108
+ default?: number;
109
+ maximum?: number;
110
+ minimum?: number;
111
+ persistAsync?: PersistAsync;
112
+ placeholder?: number;
113
+ const?: number;
114
+ oneOf?: IntegerSchema[];
115
+ };
116
+ export type NumberSchema = SchemaBase & Omit<IntegerSchema, 'type'> & {
117
+ type: 'number';
118
+ oneOf?: NumberSchema[];
119
+ };
120
+ export type ObjectSchema = SchemaBase & {
121
+ type: 'object';
122
+ displayOrder: string[];
123
+ properties: Record<string, Schema>;
124
+ required?: string[];
125
+ oneOf?: ObjectSchema[];
126
+ };
127
+ export type OneOfSchema = Omit<SchemaBase, 'oneOf' | 'promotion'> & {
128
+ oneOf: Schema[];
129
+ promotion?: Promotion;
130
+ maximum?: number;
131
+ minimum?: number;
132
+ minLength?: number;
133
+ maxLength?: number;
134
+ minItems?: number;
135
+ maxItems?: number;
136
+ required?: string[];
137
+ default?: Model;
138
+ placeholder?: Model;
139
+ control?: string;
140
+ };
141
+ export type OneOfObjectSchema = Omit<OneOfSchema, 'oneOf' | 'default'> & {
142
+ oneOf: ObjectSchema[];
143
+ default?: ObjectModel;
144
+ };
145
+ export type PersistAsyncSchema = Schema & {
146
+ persistAsync: PersistAsync;
147
+ };
148
+ export type StringSchema = Omit<SchemaBase, 'persistAsync'> & {
149
+ type: 'string';
150
+ control?: string;
151
+ default?: string;
152
+ displayFormat?: string;
153
+ minimum?: string;
154
+ maximum?: string;
155
+ maxLength?: number;
156
+ minLength?: number;
157
+ pattern?: string;
158
+ persistAsync?: PersistAsync;
159
+ placeholder?: string;
160
+ const?: string;
161
+ oneOf?: StringSchema[];
162
+ };
163
+ export type BasicSchema = BooleanSchema | IntegerSchema | NumberSchema | StringSchema;
164
+ export type ValidationAsyncSchema = BasicSchema & {
165
+ validationAsync: ValidationAsync;
166
+ };
167
+ type SchemaSummary = {
168
+ providesDescription?: boolean;
169
+ providesIcon?: boolean;
170
+ providesImage?: boolean;
171
+ providesTitle?: boolean;
172
+ };
173
+ type ArraySchemaSummary = SchemaSummary & {
174
+ defaultDescription?: string;
175
+ defaultIcon?: Icon;
176
+ defaultImage?: Image;
177
+ defaultTitle?: string;
178
+ };
179
+ export {};
@@ -0,0 +1,116 @@
1
+ import { Action } from './Action';
2
+ import { LayoutComponent } from './LayoutComponent';
3
+ import { ObjectModel } from './Model';
4
+ import { ExternalStepPollingConfiguration, ExternalStepPollingResponseHandler, PollingConfiguration } from './Polling';
5
+ import { Schema } from './Schema';
6
+ import { Image } from './core';
7
+ export type Step = FormStep | DecisionStep | ExternalStep | FinalStep;
8
+ type BaseStep = {
9
+ id?: string;
10
+ /**
11
+ * @deprecated Please use id instead
12
+ */
13
+ key?: string;
14
+ type?: string;
15
+ title?: string;
16
+ description?: string;
17
+ analytics?: Record<string, unknown>;
18
+ layout?: LayoutComponent[];
19
+ schemas?: Schema[];
20
+ actions?: Action[];
21
+ model?: ObjectModel;
22
+ refreshUrl?: string;
23
+ /**
24
+ * @deprecated Please use refreshUrl instead
25
+ */
26
+ refreshFormUrl?: string;
27
+ polling?: PollingConfiguration;
28
+ external?: {
29
+ url: string;
30
+ };
31
+ errors?: {
32
+ error?: GlobalError;
33
+ validation?: FormErrors;
34
+ };
35
+ };
36
+ export type FormStep = BaseStep & {
37
+ type?: 'form';
38
+ title: string;
39
+ layout: LayoutComponent[];
40
+ schemas: Schema[];
41
+ errors?: unknown;
42
+ };
43
+ /**
44
+ * @deprecated Please use a form step with a layout instead
45
+ */
46
+ export type FinalStep = BaseStep & {
47
+ type: 'final';
48
+ actions: Action[];
49
+ details: {
50
+ description: string;
51
+ image?: Image;
52
+ title: string;
53
+ };
54
+ success: boolean;
55
+ };
56
+ /**
57
+ * @deprecated Please use the external feature set instead
58
+ */
59
+ export type ExternalStep = BaseStep & {
60
+ type: 'external';
61
+ description?: string;
62
+ polling?: Omit<ExternalStepPollingConfiguration, 'responseHandlers'>;
63
+ requestUrl: string;
64
+ responseHandlers?: ExternalStepPollingResponseHandler[];
65
+ retryTitle?: string;
66
+ title: string;
67
+ };
68
+ /**
69
+ * @deprecated Please use DecisionLayout instead
70
+ */
71
+ export type DecisionStep = BaseStep & {
72
+ type: 'decision';
73
+ options?: DecisionStepOption[];
74
+ };
75
+ /**
76
+ * @deprecated Please use DecisionLayout instead
77
+ */
78
+ export type DecisionStepOption = {
79
+ title: string;
80
+ description?: string;
81
+ url: string;
82
+ disabled?: boolean;
83
+ };
84
+ export type FormErrors = Record<string, unknown> | string | undefined | null;
85
+ export type GlobalError = string | undefined | null;
86
+ export type ErrorResponseBody = {
87
+ error?: GlobalError;
88
+ validation?: FormErrors;
89
+ refreshUrl?: string;
90
+ /**
91
+ * @deprecated Please use refreshUrl instead
92
+ */
93
+ refreshFormUrl?: string;
94
+ };
95
+ /**
96
+ * @deprecated Please use the review layout component
97
+ */
98
+ export type LegacyReviewStep = Omit<FormStep, 'actions' | 'schemas' | 'layout'> & {
99
+ reviewFields?: LegacyReviewFields;
100
+ actions?: Action[];
101
+ schemas?: Schema[];
102
+ };
103
+ export type LegacyReviewFields = {
104
+ title?: string;
105
+ fields: Array<{
106
+ title: string;
107
+ value: string;
108
+ }>;
109
+ };
110
+ export type LegacyFormStep = Step & {
111
+ type?: 'form';
112
+ reviewFields?: LegacyReviewFields;
113
+ schemas?: Schema[];
114
+ actions?: Action[];
115
+ };
116
+ export {};
@@ -0,0 +1,6 @@
1
+ import { HttpMethod } from './core';
2
+ export type ValidationAsync = {
3
+ param: string;
4
+ url: string;
5
+ method?: HttpMethod;
6
+ };
@@ -0,0 +1,31 @@
1
+ export type Image = {
2
+ url: string;
3
+ text?: string;
4
+ name?: string;
5
+ };
6
+ export type Icon = {
7
+ name?: string;
8
+ text?: never;
9
+ } | {
10
+ name?: never;
11
+ text?: string;
12
+ };
13
+ export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
14
+ export type Margin = Size;
15
+ export type Context = 'neutral' | 'warning' | 'positive' | 'negative';
16
+ export type Orientation = 'horizontal' | 'vertical';
17
+ export type Align = 'left' | 'right' | 'center';
18
+ export type HttpMethod = 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
19
+ export type Reference = {
20
+ $ref: string;
21
+ };
22
+ /** @deprecated Prefer Context */
23
+ export type LegacyContext = 'success' | 'failure' | 'info' | 'primary';
24
+ export type Alert = {
25
+ markdown: string;
26
+ context?: Context | LegacyContext;
27
+ margin?: Margin;
28
+ };
29
+ export type Help = {
30
+ markdown: string;
31
+ };
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-types",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "Dynamic Flow TypeScript Types",
5
5
  "license": "Apache-2.0",
6
- "types": "./build/index.d.ts",
7
6
  "repository": {
8
7
  "type": "git",
9
8
  "fullname": "transferwise/dynamic-flow",
10
9
  "url": "git+https://github.com/transferwise/dynamic-flow.git"
11
10
  },
11
+ "types": "./build/index.d.ts",
12
+ "files": [
13
+ "build"
14
+ ],
12
15
  "devDependencies": {
13
16
  "@formatjs/cli": "^4.8.3",
14
17
  "eslint": "8.36.0",
package/.eslintrc.js DELETED
@@ -1,14 +0,0 @@
1
- module.exports = {
2
- extends: '@transferwise',
3
- parserOptions: {
4
- tsconfigRootDir: __dirname,
5
- project: ['./tsconfig.json'],
6
- },
7
- env: {
8
- browser: true,
9
- },
10
- rules: {
11
- // We don't have next pages
12
- '@next/next/no-html-link-for-pages': 'off',
13
- },
14
- };
@@ -1,4 +0,0 @@
1
-
2
- > @wise/dynamic-flow-types@1.1.1 build /__w/dynamic-flow/dynamic-flow/web/types
3
- > pnpm tsc --emitDeclarationOnly
4
-
package/CHANGELOG.md DELETED
@@ -1,27 +0,0 @@
1
- # @wise/dynamic-flow-types
2
-
3
- ## 1.1.1
4
-
5
- ### Patch Changes
6
-
7
- - 40c300b: Publish .d.ts files instead of .ts
8
-
9
- ## 1.1.0
10
-
11
- ### Minor Changes
12
-
13
- - 57ab87e: Add support for action.id property
14
- - 44409c6: Adding support for status-list
15
-
16
- ## 1.0.0
17
-
18
- ### Major Changes
19
-
20
- - 1120e78: TypeScript types extracted from the web client library.
21
-
22
- ## 0.0.2
23
-
24
- ### Patch Changes
25
-
26
- - 28cd77d: Make @wise/dynamic-flow-types non-private.
27
- Declare @wise/dynamic-flow-types as a non-dev dependency.
@@ -1,25 +0,0 @@
1
- import { HttpMethod } from './core';
2
-
3
- type CoreAction = {
4
- id?: string;
5
- /**
6
- * @deprecated Please use id instead
7
- */
8
- $id?: string;
9
- data?: Record<string, unknown>;
10
- exit?: boolean;
11
- method?: HttpMethod;
12
- result?: Record<string, unknown>;
13
- timeout?: number;
14
- url?: string;
15
- };
16
-
17
- export type Action = CoreAction & {
18
- title?: string;
19
- type?: 'primary' | 'secondary' | 'link' | 'positive' | 'negative';
20
- disabled?: boolean;
21
- };
22
-
23
- export type ActionResponseBody = {
24
- action: Action;
25
- };
@@ -1,23 +0,0 @@
1
- import { ImageLayout } from './LayoutComponent';
2
- import { StringSchema } from './Schema';
3
-
4
- export type FileUploadSchema = Omit<
5
- StringSchema,
6
- 'type' | 'format' | 'source' | 'image' | 'cameraConfig'
7
- > & {
8
- type: 'string';
9
- format: 'base64url';
10
- source?: 'camera' | 'file';
11
- image?: ImageLayout;
12
- cameraConfig?: CameraConfig;
13
- };
14
- type CameraConfig = {
15
- assets?: {
16
- overlay?: string;
17
- outline?: string;
18
- };
19
- direction?: CameraDirection;
20
- instructions?: string;
21
- };
22
-
23
- export type CameraDirection = 'back' | 'front';
@@ -1,194 +0,0 @@
1
- import { Action } from './Action';
2
- import { ExternalStepPollingConfiguration, ExternalStepPollingResponseHandler } from './Polling';
3
- import { Schema } from './Schema';
4
- import { Margin, Size, Icon, Image, Align, Orientation, Reference, Alert } from './core';
5
-
6
- export type LayoutComponent =
7
- | AlertLayout
8
- | BoxLayout
9
- | ButtonLayout
10
- | ColumnsLayout
11
- | DecisionLayout
12
- | DividerLayout
13
- | ExternalLayout
14
- | FormLayout
15
- | HeadingLayout
16
- | ImageLayout
17
- | InfoLayout
18
- | ListLayout
19
- | LoadingIndicatorLayout
20
- | MarkdownLayout
21
- | ParagraphLayout
22
- | ReviewLayout
23
- | StatusListLayout;
24
-
25
- export type AlertLayout = { type: 'alert' } & Alert;
26
-
27
- export type BoxLayout = {
28
- type: 'box';
29
- components: LayoutComponent[];
30
- width?: Size;
31
- margin?: Margin;
32
- border?: boolean;
33
- };
34
-
35
- export type ButtonLayout = {
36
- type: 'button';
37
- action: Action | Reference;
38
- title?: string;
39
- control?: 'primary' | 'secondary' | 'tertiary';
40
- context?: 'neutral' | 'positive' | 'negative';
41
- disabled?: boolean;
42
- margin?: Margin;
43
- /**
44
- * @deprecated Only supported on web client
45
- */
46
- size?: Size;
47
- };
48
-
49
- export type ColumnsLayout = {
50
- type: 'columns';
51
- left: LayoutComponent[];
52
- right: LayoutComponent[];
53
- bias?: 'none' | 'left' | 'right';
54
- margin?: Margin;
55
- };
56
-
57
- export type DecisionLayout = {
58
- type: 'decision';
59
- options: DecisionOption[];
60
- margin?: Margin;
61
- };
62
- type DecisionOption = {
63
- action: Action | Reference;
64
- title: string;
65
- description?: string;
66
- icon?: Icon;
67
- image?: Image;
68
- disabled?: boolean;
69
- };
70
-
71
- /**
72
- * @deprecated Only supported on web client
73
- */
74
- export type DividerLayout = {
75
- type: 'divider';
76
- margin?: Margin;
77
- };
78
-
79
- /**
80
- * @deprecated Please use the external feature set instead
81
- */
82
- export type ExternalLayout = {
83
- type: 'external';
84
- requestUrl: string;
85
- polling?: Omit<ExternalStepPollingConfiguration, 'responseHandlers'>;
86
- responseHandlers?: ExternalStepPollingResponseHandler[];
87
- retryTitle?: string;
88
- };
89
-
90
- export type FormLayout =
91
- | {
92
- type: 'form';
93
- schemaId?: never;
94
- schema: Schema | Reference;
95
- margin?: Margin;
96
- }
97
- | {
98
- type: 'form';
99
- schemaId: string;
100
- schema?: never;
101
- margin?: Margin;
102
- };
103
-
104
- export type HeadingLayout = {
105
- type: 'heading';
106
- size?: Size;
107
- text: string;
108
- margin?: Margin;
109
- align?: Align;
110
- };
111
-
112
- export type ImageLayout = {
113
- type: 'image';
114
- url: string;
115
- /**
116
- * @deprecated Only supported on web client
117
- */
118
- text?: string;
119
- size?: Size;
120
- margin?: Margin;
121
- };
122
-
123
- export type InfoLayout = {
124
- type: 'info';
125
- markdown: string;
126
- margin?: Margin;
127
- align?: Align;
128
- };
129
-
130
- /**
131
- * @deprecated Please use StatusListLayout instead
132
- */
133
- export type ListLayout = {
134
- type: 'list';
135
- items: ListItem[];
136
- title?: string;
137
- margin?: Margin;
138
- };
139
-
140
- type ListItem = {
141
- title: string;
142
- description?: string;
143
- icon?: Icon;
144
- status?: 'positive' | 'neutral' | 'warning';
145
- };
146
-
147
- export type StatusListLayout = {
148
- type: 'status-list';
149
- items: StatusListItem[];
150
- title?: string;
151
- margin?: Margin;
152
- };
153
-
154
- type StatusListItem = {
155
- title: string;
156
- description?: string;
157
- icon?: Icon;
158
- status?: 'done' | 'not-done' | 'pending';
159
- };
160
-
161
- export type LoadingIndicatorLayout = {
162
- type: 'loading-indicator';
163
- margin?: Margin;
164
- size?: Size;
165
- };
166
-
167
- export type MarkdownLayout = {
168
- type: 'markdown';
169
- content: string;
170
- margin?: Margin;
171
- align?: Align;
172
- };
173
-
174
- export type ParagraphLayout = {
175
- type: 'paragraph';
176
- text: string;
177
- control?: 'copyable';
178
- margin?: Margin;
179
- align?: Align;
180
- };
181
-
182
- export type ReviewLayout = {
183
- type: 'review';
184
- title?: string;
185
- fields: ReviewField[];
186
- orientation?: Orientation;
187
- margin?: Margin;
188
- /**
189
- * @deprecated Only supported on web client
190
- */
191
- action?: Action;
192
- };
193
-
194
- type ReviewField = { label: string; value: string | number | boolean | null | undefined };
@@ -1,10 +0,0 @@
1
- import { Schema } from './Schema';
2
-
3
- export type PersistAsync = {
4
- idProperty: string;
5
- method?: 'POST' | 'PUT' | 'PATCH';
6
- param: string;
7
- schema: Schema;
8
- url: string;
9
- };
10
- type PersistAsyncResponseBody = Record<string, unknown> | { validation: Record<string, unknown> };
@@ -1,21 +0,0 @@
1
- import { Icon, Image } from './core';
2
-
3
- export type Promotion = {
4
- displayTwice?: boolean;
5
- other: {
6
- description?: string;
7
- heading?: {
8
- text: string;
9
- };
10
- icon?: Icon;
11
- image?: Image;
12
- title: string;
13
- };
14
- promoted?: {
15
- title?: string;
16
- description?: string; // not in spec (only web)
17
- };
18
- control?: string; // not in spec (only web)
19
- checkedMeans?: 'promoted' | 'other'; // not in spec (only web)
20
- default?: 'promoted' | 'other';
21
- };
@@ -1,200 +0,0 @@
1
- import { FileUploadSchema } from './FileUploadSchema';
2
- import { Model, ObjectModel } from './Model';
3
- import { PersistAsync } from './PersistAsync';
4
- import { Promotion } from './Promotion';
5
- import { ValidationAsync } from './ValidationAsync';
6
- import { Icon, Image, Alert, Help } from './core';
7
-
8
- export type Schema =
9
- | AllOfSchema
10
- | ArraySchema
11
- | BlobSchema
12
- | BooleanSchema
13
- | IntegerSchema
14
- | NumberSchema
15
- | ObjectSchema
16
- | OneOfSchema
17
- | StringSchema
18
- | ListArraySchema
19
- | TupleArraySchema
20
- | FileUploadSchema
21
- | MultipleFileUploadSchema
22
- | ConstSchema;
23
-
24
- type SchemaBase = {
25
- $id?: string;
26
- type?: 'boolean' | 'blob' | 'array' | 'integer' | 'number' | 'string' | 'object';
27
- alert?: Alert;
28
- autofillProvider?: string;
29
- autofillKey?: string;
30
- allOf?: never;
31
- analyticsId?: string;
32
- const?: Model;
33
- default?: Model;
34
- description?: string;
35
- disabled?: boolean;
36
- format?: string;
37
- help?: Help;
38
- hidden?: boolean;
39
- icon?: Icon;
40
- image?: Image;
41
- oneOf?: never;
42
- persistAsync?: never;
43
- promoted?: boolean;
44
- promotion?: never;
45
- /**
46
- * @deprecated Please use disabled
47
- */
48
- readOnly?: boolean;
49
- refreshStepOnChange?: boolean;
50
- /**
51
- * @deprecated Please use refreshStepOnChange instead
52
- */
53
- refreshFormOnChange?: boolean;
54
- refreshUrl?: string;
55
- /**
56
- * @deprecated Please use refreshUrl instead
57
- */
58
- refreshFormUrl?: string;
59
- summary?: SchemaSummary;
60
- title?: string;
61
- validationAsync?: ValidationAsync;
62
- validationMessages?: Record<string, string>;
63
- /**
64
- * @deprecated Please use oneOf instead
65
- */
66
- values?: { label: string; value: string | number }[];
67
- /**
68
- * @deprecated Please use layouts instead
69
- */
70
- width?: string;
71
- keywords?: string[];
72
- };
73
-
74
- export type AllOfSchema = Omit<SchemaBase, 'allOf'> & {
75
- allOf: Schema[];
76
- maximum?: number;
77
- minimum?: number;
78
- minLength?: number;
79
- maxLength?: number;
80
- minItems?: number;
81
- maxItems?: number;
82
- required?: string[];
83
- };
84
-
85
- export type ArraySchema = Omit<SchemaBase, 'persistAsync'> & {
86
- type: 'array';
87
- addItemTitle?: string;
88
- editItemTitle?: string;
89
- removeItemTitle?: string;
90
- items: Schema | Schema[];
91
- maxItems?: number;
92
- minItems?: number;
93
- persistAsync?: PersistAsync;
94
-
95
- summary?: ArraySchemaSummary;
96
- };
97
-
98
- export type ListArraySchema = ArraySchema & { items: Schema };
99
- export type TupleArraySchema = ArraySchema & { items: Schema[] };
100
- export type MultipleFileUploadSchema = ListArraySchema & { items: PersistAsyncSchema };
101
-
102
- export type BlobSchema = SchemaBase & {
103
- type: 'blob';
104
- accepts?: string[];
105
- maxSize?: number;
106
- };
107
-
108
- export type BooleanSchema = SchemaBase & {
109
- type: 'boolean';
110
- default?: boolean;
111
-
112
- const?: boolean;
113
- oneOf?: BooleanSchema[];
114
- };
115
-
116
- export type ConstSchema = SchemaBase & {
117
- type?: never;
118
- const: Model;
119
- };
120
-
121
- export type IntegerSchema = Omit<SchemaBase, 'persistAsync'> & {
122
- type: 'integer';
123
- default?: number;
124
- maximum?: number;
125
- minimum?: number;
126
- persistAsync?: PersistAsync;
127
- placeholder?: number;
128
-
129
- const?: number;
130
- oneOf?: IntegerSchema[];
131
- };
132
-
133
- export type NumberSchema = SchemaBase &
134
- Omit<IntegerSchema, 'type'> & { type: 'number'; oneOf?: NumberSchema[] };
135
-
136
- export type ObjectSchema = SchemaBase & {
137
- type: 'object';
138
- displayOrder: string[];
139
- properties: Record<string, Schema>;
140
- required?: string[];
141
- oneOf?: ObjectSchema[];
142
- };
143
-
144
- export type OneOfSchema = Omit<SchemaBase, 'oneOf' | 'promotion'> & {
145
- oneOf: Schema[];
146
- promotion?: Promotion;
147
- maximum?: number;
148
- minimum?: number;
149
- minLength?: number;
150
- maxLength?: number;
151
- minItems?: number;
152
- maxItems?: number;
153
- required?: string[];
154
- default?: Model;
155
- placeholder?: Model;
156
- control?: string;
157
- };
158
-
159
- export type OneOfObjectSchema = Omit<OneOfSchema, 'oneOf' | 'default'> & {
160
- oneOf: ObjectSchema[];
161
- default?: ObjectModel;
162
- };
163
-
164
- export type PersistAsyncSchema = Schema & { persistAsync: PersistAsync };
165
-
166
- export type StringSchema = Omit<SchemaBase, 'persistAsync'> & {
167
- type: 'string';
168
- control?: string;
169
- default?: string;
170
- displayFormat?: string;
171
- minimum?: string; // FIXME: https://transferwise.atlassian.net/browse/MC-3188
172
- maximum?: string; // FIXME: https://transferwise.atlassian.net/browse/MC-3188
173
- maxLength?: number;
174
- minLength?: number;
175
- pattern?: string;
176
- persistAsync?: PersistAsync;
177
- placeholder?: string;
178
- const?: string;
179
- oneOf?: StringSchema[];
180
- };
181
-
182
- export type BasicSchema = BooleanSchema | IntegerSchema | NumberSchema | StringSchema;
183
-
184
- export type ValidationAsyncSchema = BasicSchema & {
185
- validationAsync: ValidationAsync;
186
- };
187
-
188
- type SchemaSummary = {
189
- providesDescription?: boolean;
190
- providesIcon?: boolean;
191
- providesImage?: boolean;
192
- providesTitle?: boolean;
193
- };
194
-
195
- type ArraySchemaSummary = SchemaSummary & {
196
- defaultDescription?: string;
197
- defaultIcon?: Icon;
198
- defaultImage?: Image;
199
- defaultTitle?: string;
200
- };
package/src/spec/Step.ts DELETED
@@ -1,126 +0,0 @@
1
- import { Action } from './Action';
2
- import { LayoutComponent } from './LayoutComponent';
3
- import { ObjectModel } from './Model';
4
- import {
5
- ExternalStepPollingConfiguration,
6
- ExternalStepPollingResponseHandler,
7
- PollingConfiguration,
8
- } from './Polling';
9
- import { Schema } from './Schema';
10
- import { Image } from './core';
11
-
12
- export type Step = FormStep | DecisionStep | ExternalStep | FinalStep;
13
-
14
- type BaseStep = {
15
- id?: string;
16
- /**
17
- * @deprecated Please use id instead
18
- */
19
- key?: string;
20
- type?: string;
21
- title?: string;
22
- description?: string;
23
- analytics?: Record<string, unknown>;
24
- layout?: LayoutComponent[];
25
- schemas?: Schema[];
26
- actions?: Action[];
27
- model?: ObjectModel;
28
- refreshUrl?: string;
29
- /**
30
- * @deprecated Please use refreshUrl instead
31
- */
32
- refreshFormUrl?: string;
33
- polling?: PollingConfiguration;
34
- external?: { url: string };
35
- errors?: {
36
- error?: GlobalError;
37
- validation?: FormErrors;
38
- };
39
- };
40
-
41
- export type FormStep = BaseStep & {
42
- type?: 'form';
43
- title: string;
44
- layout: LayoutComponent[];
45
- schemas: Schema[];
46
- errors?: unknown;
47
- };
48
-
49
- /**
50
- * @deprecated Please use a form step with a layout instead
51
- */
52
- export type FinalStep = BaseStep & {
53
- type: 'final';
54
- actions: Action[];
55
- details: {
56
- description: string;
57
- image?: Image;
58
- title: string;
59
- };
60
- success: boolean;
61
- };
62
-
63
- /**
64
- * @deprecated Please use the external feature set instead
65
- */
66
- export type ExternalStep = BaseStep & {
67
- type: 'external';
68
- description?: string;
69
- polling?: Omit<ExternalStepPollingConfiguration, 'responseHandlers'>;
70
- requestUrl: string;
71
- responseHandlers?: ExternalStepPollingResponseHandler[];
72
- retryTitle?: string;
73
- title: string;
74
- };
75
-
76
- /**
77
- * @deprecated Please use DecisionLayout instead
78
- */
79
- export type DecisionStep = BaseStep & {
80
- type: 'decision';
81
- options?: DecisionStepOption[];
82
- };
83
-
84
- /**
85
- * @deprecated Please use DecisionLayout instead
86
- */
87
- export type DecisionStepOption = {
88
- title: string;
89
- description?: string;
90
- url: string;
91
- disabled?: boolean;
92
- };
93
-
94
- export type FormErrors = Record<string, unknown> | string | undefined | null;
95
- export type GlobalError = string | undefined | null;
96
-
97
- export type ErrorResponseBody = {
98
- error?: GlobalError;
99
- validation?: FormErrors;
100
- refreshUrl?: string;
101
- /**
102
- * @deprecated Please use refreshUrl instead
103
- */
104
- refreshFormUrl?: string;
105
- };
106
-
107
- /**
108
- * @deprecated Please use the review layout component
109
- */
110
- export type LegacyReviewStep = Omit<FormStep, 'actions' | 'schemas' | 'layout'> & {
111
- reviewFields?: LegacyReviewFields;
112
- actions?: Action[];
113
- schemas?: Schema[];
114
- };
115
-
116
- export type LegacyReviewFields = {
117
- title?: string;
118
- fields: Array<{ title: string; value: string }>;
119
- };
120
-
121
- export type LegacyFormStep = Step & {
122
- type?: 'form';
123
- reviewFields?: LegacyReviewFields;
124
- schemas?: Schema[];
125
- actions?: Action[];
126
- };
@@ -1,8 +0,0 @@
1
- import { HttpMethod } from './core';
2
-
3
- export type ValidationAsync = {
4
- param: string;
5
- url: string;
6
- method?: HttpMethod; // not in spec (only web)
7
- };
8
- type ValidationAsyncResponseBody = { message: string };
package/src/spec/core.ts DELETED
@@ -1,25 +0,0 @@
1
- export type Image = {
2
- url: string;
3
- text?: string; // TODO: not in spec. web only? consider calling it altText -- make proposal
4
- name?: string; // TODO: not in spec. web only? consider calling it altText
5
- };
6
-
7
- export type Icon = { name?: string; text?: never } | { name?: never; text?: string };
8
-
9
- export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
10
- export type Margin = Size;
11
- export type Context = 'neutral' | 'warning' | 'positive' | 'negative';
12
- export type Orientation = 'horizontal' | 'vertical';
13
- export type Align = 'left' | 'right' | 'center';
14
-
15
- export type HttpMethod = 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
16
-
17
- export type Reference = { $ref: string };
18
-
19
- export type Alert = {
20
- markdown: string;
21
- context?: Context;
22
- margin?: Margin;
23
- };
24
-
25
- export type Help = { markdown: string };
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDir": "src",
4
- "outDir": "build",
5
- "lib": ["dom", "dom.iterable", "esnext"],
6
- "declaration": true,
7
- "allowJs": false,
8
- "checkJs": false,
9
- "skipLibCheck": true,
10
- "strict": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "esModuleInterop": true,
13
- "module": "esnext",
14
- "moduleResolution": "node",
15
- "resolveJsonModule": true,
16
- "jsx": "react-jsx",
17
- "isolatedModules": true
18
- },
19
- "include": ["src/**/*.ts"],
20
- "exclude": ["node_modules", "build"]
21
- }