@wise/dynamic-flow-client 0.1.4 → 0.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.
- package/README.md +2 -0
- package/build/flow/DynamicFlow.js +15 -5
- package/build/flow/fixtures/components/alert.d.ts +2 -2
- package/build/flow/fixtures/components/box.d.ts +2 -2
- package/build/flow/fixtures/components/button.d.ts +2 -2
- package/build/flow/fixtures/components/columns.d.ts +2 -2
- package/build/flow/fixtures/components/copyable.d.ts +2 -2
- package/build/flow/fixtures/components/decision.d.ts +2 -2
- package/build/flow/fixtures/components/heading.d.ts +2 -2
- package/build/flow/fixtures/components/image.d.ts +3 -2
- package/build/flow/fixtures/components/image.js +22 -3
- package/build/flow/fixtures/components/info.d.ts +2 -2
- package/build/flow/fixtures/components/list.d.ts +2 -2
- package/build/flow/fixtures/components/loading-indicator.d.ts +2 -2
- package/build/flow/fixtures/components/paragraph.d.ts +2 -2
- package/build/flow/fixtures/components/review.d.ts +2 -2
- package/build/flow/fixtures/examples/camera-capture.d.ts +2 -2
- package/build/flow/fixtures/examples/recipient-update.d.ts +2 -2
- package/build/flow/fixtures/examples/recipient-update.js +2 -2
- package/build/flow/fixtures/examples/recipient.d.ts +2 -2
- package/build/flow/fixtures/examples/single-file-upload.d.ts +2 -2
- package/build/flow/fixtures/examples/single-file-upload.js +32 -30
- package/build/flow/fixtures/examples/step-validation-errors.d.ts +2 -2
- package/build/flow/fixtures/features/action-response.d.ts +2 -2
- package/build/flow/fixtures/features/external.d.ts +2 -2
- package/build/flow/fixtures/features/persist-async.d.ts +2 -2
- package/build/flow/fixtures/features/polling.d.ts +2 -2
- package/build/flow/fixtures/features/validation-async.d.ts +3 -0
- package/build/flow/fixtures/features/validation-async.js +38 -0
- package/build/flow/fixtures/index.d.ts +34 -28
- package/build/flow/fixtures/index.js +8 -1
- package/build/flow/fixtures/responses/action-response-final.d.ts +2 -2
- package/build/flow/fixtures/responses/recipient-update-final.d.ts +2 -2
- package/build/flow/fixtures/schemas/basic-form.d.ts +2 -2
- package/build/flow/fixtures/schemas/number-and-integer.d.ts +2 -2
- package/build/flow/fixtures/schemas/one-of.d.ts +2 -2
- package/build/flow/fixtures/schemas/string-formats.d.ts +2 -2
- package/build/flow/fixtures/schemas/string-formats.js +6 -2
- package/build/flow/stories/DynamicFlow.story.d.ts +1 -0
- package/build/flow/stories/DynamicFlow.story.js +30 -0
- package/build/flow/stories/EditableDynamicFlow.js +2 -1
- package/build/flow/stories/fixtureFetcher.d.ts +2 -0
- package/build/flow/stories/fixtureFetcher.js +114 -0
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.d.ts +1 -1
- package/build/jsonSchemaForm/schemaFormControl/optionMapper.d.ts +6 -11
- package/build/jsonSchemaForm/schemaFormControl/optionMapper.js +12 -6
- package/build/layout/image/index.d.ts +3 -2
- package/build/layout/image/index.js +17 -38
- package/build/main.css +45 -0
- package/package.json +34 -29
- package/build/common/hooks/useDebouncedFunction.test.d.ts +0 -1
- package/build/common/hooks/useDebouncedFunction.test.js +0 -59
- package/build/common/logging/spec.d.ts +0 -1
- package/build/common/logging/spec.js +0 -45
- package/build/common/tracking/spec.d.ts +0 -1
- package/build/common/tracking/spec.js +0 -49
- package/build/common/utils/generate-random-id.test.d.ts +0 -1
- package/build/common/utils/generate-random-id.test.js +0 -12
- package/build/common/validation/rule-validators/spec.d.ts +0 -1
- package/build/common/validation/rule-validators/spec.js +0 -145
- package/build/common/validation/schema-validators/spec.d.ts +0 -1
- package/build/common/validation/schema-validators/spec.js +0 -137
- package/build/common/validation/valid-model/spec.d.ts +0 -1
- package/build/common/validation/valid-model/spec.js +0 -605
- package/build/common/validation/validation-failures/spec.d.ts +0 -1
- package/build/common/validation/validation-failures/spec.js +0 -185
- package/build/flow/response-parsers/spec.d.ts +0 -1
- package/build/flow/response-parsers/spec.js +0 -263
- package/build/layout/loading-indicator/spec.d.ts +0 -1
- package/build/layout/loading-indicator/spec.js +0 -11
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { isValidRequired, isValidMinLength, isValidMaxLength, isValidMinimum, isValidMaximum, isValidPattern, isValidMinItems, isValidMaxItems, isValidRequiredArray, } from '.';
|
|
2
|
-
describe('Given a library for validating json schema rules', function () {
|
|
3
|
-
describe('when establishing if a value passes required validation', function () {
|
|
4
|
-
it('should return true if required and value defined', function () {
|
|
5
|
-
expect(isValidRequired('something', true)).toBe(true);
|
|
6
|
-
});
|
|
7
|
-
it('should return false if required and value undefined', function () {
|
|
8
|
-
expect(isValidRequired(undefined, true)).toBe(false);
|
|
9
|
-
});
|
|
10
|
-
it('should return true if not required', function () {
|
|
11
|
-
expect(isValidRequired(undefined, false)).toBe(true);
|
|
12
|
-
expect(isValidRequired('something', false)).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe('when establishing if a value passes minLength validation', function () {
|
|
16
|
-
it('should return true if minLength exists and value matches or exceeds it', function () {
|
|
17
|
-
expect(isValidMinLength('a', 1)).toBe(true);
|
|
18
|
-
expect(isValidMinLength('ab', 1)).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
it('should return false if minLength exists and value undefined', function () {
|
|
21
|
-
expect(isValidMinLength(undefined, 1)).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
it('should return false if minLength exists and value too short', function () {
|
|
24
|
-
expect(isValidMinLength('', 1)).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
it('should return true if minLength not defined', function () {
|
|
27
|
-
expect(isValidMinLength('a', undefined)).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe('when establishing if a value passes maxLength validation', function () {
|
|
31
|
-
it('should return true if maxLength exists and value matches or shorter than it', function () {
|
|
32
|
-
expect(isValidMaxLength('', 2)).toBe(true);
|
|
33
|
-
expect(isValidMaxLength('a', 2)).toBe(true);
|
|
34
|
-
expect(isValidMaxLength('ab', 2)).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
it('should return false if maxLength exists and value undefined', function () {
|
|
37
|
-
expect(isValidMaxLength(undefined, 2)).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
it('should return false if maxLength exists and value too long', function () {
|
|
40
|
-
expect(isValidMaxLength('abc', 2)).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
it('should return true if maxLength not defined', function () {
|
|
43
|
-
expect(isValidMaxLength('a', undefined)).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe('when establishing if a value passes pattern validation', function () {
|
|
47
|
-
it('should return true if pattern exists and value matches it', function () {
|
|
48
|
-
expect(isValidPattern('a', '[a-z]+')).toBe(true);
|
|
49
|
-
});
|
|
50
|
-
it('should return false if pattern exists and value undefined', function () {
|
|
51
|
-
expect(isValidPattern(undefined, '[a-z]+')).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
it('should return false if pattern exists and value invalid', function () {
|
|
54
|
-
expect(isValidPattern('012', '[a-z]+')).toBe(false);
|
|
55
|
-
});
|
|
56
|
-
it('should return true if pattern not defined', function () {
|
|
57
|
-
expect(isValidPattern('a', undefined)).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('when establishing if a value passes minimum validation', function () {
|
|
61
|
-
it('should return true if min exists and value matches or exceeds it', function () {
|
|
62
|
-
expect(isValidMinimum(1, 1)).toBe(true);
|
|
63
|
-
expect(isValidMinimum(0, 0)).toBe(true);
|
|
64
|
-
// FIXME - these are not valid
|
|
65
|
-
// expect(isValidMinimum('2', '1')).toBe(true);
|
|
66
|
-
// expect(isValidMinimum('1', '1')).toBe(true);
|
|
67
|
-
// expect(isValidMinimum('0', '0')).toBe(true);
|
|
68
|
-
});
|
|
69
|
-
it('should return false if min exists and value undefined', function () {
|
|
70
|
-
expect(isValidMinimum(undefined, 1)).toBe(false);
|
|
71
|
-
});
|
|
72
|
-
it('should return false if min exists and value too low', function () {
|
|
73
|
-
expect(isValidMinimum(1, 2)).toBe(false);
|
|
74
|
-
expect(isValidMinimum(-1, 0)).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
it('should return true if min not defined', function () {
|
|
77
|
-
expect(isValidMinimum(1, undefined)).toBe(true);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
describe('when establishing if a value passes maximum validation', function () {
|
|
81
|
-
it('should return true if max exists and value matches or is lower than it', function () {
|
|
82
|
-
expect(isValidMaximum(2, 2)).toBe(true);
|
|
83
|
-
expect(isValidMaximum(-1, 0)).toBe(true);
|
|
84
|
-
// FIXME - these are not valid
|
|
85
|
-
// expect(isValidMaximum('2', '2')).toBe(true);
|
|
86
|
-
// expect(isValidMaximum('0', '2')).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
it('should return false if max exists and value undefined', function () {
|
|
89
|
-
expect(isValidMaximum(undefined, 2)).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
it('should return false if max exists and value too high', function () {
|
|
92
|
-
expect(isValidMaximum(3, 2)).toBe(false);
|
|
93
|
-
});
|
|
94
|
-
it('should return true if max not defined', function () {
|
|
95
|
-
expect(isValidMaximum(2, undefined)).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe('when establishing if an array passes minItems validation', function () {
|
|
99
|
-
it('should return true if minItems exists and value length matches or exceeds it', function () {
|
|
100
|
-
expect(isValidMinItems([1], 1)).toBe(true);
|
|
101
|
-
expect(isValidMinItems([], 0)).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
it('should return false if minItems exists and value undefined', function () {
|
|
104
|
-
expect(isValidMinItems(undefined, 1)).toBe(false);
|
|
105
|
-
});
|
|
106
|
-
it('should return false if minItems exists and value too short', function () {
|
|
107
|
-
expect(isValidMinItems([1], 2)).toBe(false);
|
|
108
|
-
expect(isValidMinItems([], 1)).toBe(false);
|
|
109
|
-
});
|
|
110
|
-
it('should return true if minItems not defined', function () {
|
|
111
|
-
expect(isValidMinItems([], undefined)).toBe(true);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
describe('when establishing if an array passes maxItems validation', function () {
|
|
115
|
-
it('should return true if maxItems exists and value length matches or is less than it', function () {
|
|
116
|
-
expect(isValidMaxItems([1], 1)).toBe(true);
|
|
117
|
-
expect(isValidMaxItems([], 0)).toBe(true);
|
|
118
|
-
});
|
|
119
|
-
it('should return false if maxItems exists and value undefined', function () {
|
|
120
|
-
expect(isValidMaxItems(undefined, 1)).toBe(false);
|
|
121
|
-
});
|
|
122
|
-
it('should return false if maxItems exists and value too long', function () {
|
|
123
|
-
expect(isValidMaxItems([1, 2], 1)).toBe(false);
|
|
124
|
-
});
|
|
125
|
-
it('should return true if maxItems not defined', function () {
|
|
126
|
-
expect(isValidMaxItems([], undefined)).toBe(true);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
describe('when establishing validations an array', function () {
|
|
130
|
-
it('should return true all values for a non-required input', function () {
|
|
131
|
-
expect(isValidRequiredArray([1], false)).toBe(true);
|
|
132
|
-
expect(isValidRequiredArray([], false)).toBe(true);
|
|
133
|
-
expect(isValidRequiredArray(undefined, false)).toBe(true);
|
|
134
|
-
expect(isValidRequiredArray(null, false)).toBe(true);
|
|
135
|
-
});
|
|
136
|
-
it('should return true for only array values for a required input', function () {
|
|
137
|
-
expect(isValidRequiredArray([1], true)).toBe(true);
|
|
138
|
-
expect(isValidRequiredArray([], true)).toBe(true);
|
|
139
|
-
});
|
|
140
|
-
it('should return false for values for a required input', function () {
|
|
141
|
-
expect(isValidRequiredArray(null, true)).toBe(false);
|
|
142
|
-
expect(isValidRequiredArray(undefined, true)).toBe(false);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { isValidSchema } from '.';
|
|
2
|
-
describe('Given a library for validating json schema models', function () {
|
|
3
|
-
var schema;
|
|
4
|
-
describe('when validating an object schema', function () {
|
|
5
|
-
beforeEach(function () {
|
|
6
|
-
schema = {
|
|
7
|
-
type: 'object',
|
|
8
|
-
properties: {
|
|
9
|
-
a: {
|
|
10
|
-
type: 'number',
|
|
11
|
-
minimum: 2
|
|
12
|
-
},
|
|
13
|
-
b: {
|
|
14
|
-
type: 'string',
|
|
15
|
-
minLength: 3
|
|
16
|
-
},
|
|
17
|
-
c: {
|
|
18
|
-
"const": true
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
required: ['a', 'c'],
|
|
22
|
-
displayOrder: ['a', 'b', 'c']
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
it('should return false if the value is of an incorrect type', function () {
|
|
26
|
-
expect(isValidSchema([1], schema)).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
it('should return false if a required property is missing', function () {
|
|
29
|
-
expect(isValidSchema({}, schema)).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
it('should return false is a required property does not validate', function () {
|
|
32
|
-
expect(isValidSchema({ a: 1, c: true }, schema)).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
it('should return false if an optional property is invalid', function () {
|
|
35
|
-
expect(isValidSchema({ a: 2, b: 'c', c: true }, schema)).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
it('should return true if required properties validate and non-required fields are missing', function () {
|
|
38
|
-
expect(isValidSchema({ a: 2, c: true }, schema)).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
it('should return true if all properties validate', function () {
|
|
41
|
-
expect(isValidSchema({ a: 2, b: 'cde', c: true }, schema)).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe('when validating an array schema', function () {
|
|
45
|
-
beforeEach(function () {
|
|
46
|
-
schema = {
|
|
47
|
-
type: 'array',
|
|
48
|
-
items: {
|
|
49
|
-
type: 'string',
|
|
50
|
-
minLength: 2
|
|
51
|
-
},
|
|
52
|
-
minItems: 2,
|
|
53
|
-
maxItems: 2
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
it('should return false if not an array', function () {
|
|
57
|
-
expect(isValidSchema({ a: 1 }, schema)).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
it('should return false if the array is too small', function () {
|
|
60
|
-
expect(isValidSchema(['ab'], schema)).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
it('should return false if the array is too long', function () {
|
|
63
|
-
expect(isValidSchema(['ab', 'cd', 'ef'], schema)).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
it('should return false if any of the items do not validate', function () {
|
|
66
|
-
expect(isValidSchema(['ab', 'c'], schema)).toBe(false);
|
|
67
|
-
});
|
|
68
|
-
it('should return true is the array is correct size and items are valid', function () {
|
|
69
|
-
expect(isValidSchema(['ab', 'cd'], schema)).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
describe('when validating a oneOf schema', function () {
|
|
73
|
-
beforeEach(function () {
|
|
74
|
-
schema = {
|
|
75
|
-
oneOf: [
|
|
76
|
-
{
|
|
77
|
-
type: 'string',
|
|
78
|
-
minLength: 2
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
type: 'number',
|
|
82
|
-
minimum: 2
|
|
83
|
-
},
|
|
84
|
-
]
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
it('should return false if neither schema validates', function () {
|
|
88
|
-
expect(isValidSchema(true, schema)).toBe(false);
|
|
89
|
-
expect(isValidSchema('a', schema)).toBe(false);
|
|
90
|
-
expect(isValidSchema(1, schema)).toBe(false);
|
|
91
|
-
});
|
|
92
|
-
it('should return true if either schema validates', function () {
|
|
93
|
-
expect(isValidSchema('ab', schema)).toBe(true);
|
|
94
|
-
expect(isValidSchema(2, schema)).toBe(true);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
describe('when validating an allOf schema', function () {
|
|
98
|
-
beforeEach(function () {
|
|
99
|
-
schema = {
|
|
100
|
-
allOf: [
|
|
101
|
-
{
|
|
102
|
-
type: 'object',
|
|
103
|
-
properties: {
|
|
104
|
-
a: {
|
|
105
|
-
type: 'string',
|
|
106
|
-
minLength: 2
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
displayOrder: ['a'],
|
|
110
|
-
required: ['a']
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
type: 'object',
|
|
114
|
-
properties: {
|
|
115
|
-
b: {
|
|
116
|
-
type: 'number',
|
|
117
|
-
minimum: 2
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
displayOrder: ['b'],
|
|
121
|
-
required: ['b']
|
|
122
|
-
},
|
|
123
|
-
]
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
it('should return false if only one schema is present', function () {
|
|
127
|
-
expect(isValidSchema({ a: 'bc' }, schema)).toBe(false);
|
|
128
|
-
expect(isValidSchema({ b: 2 }, schema)).toBe(false);
|
|
129
|
-
});
|
|
130
|
-
it('should return false if any schemas are invalid', function () {
|
|
131
|
-
expect(isValidSchema({ a: 'bc', b: 1 }, schema)).toBe(false);
|
|
132
|
-
});
|
|
133
|
-
it('should return true if both schemas validate', function () {
|
|
134
|
-
expect(isValidSchema({ a: 'bc', b: 2 }, schema)).toBe(true);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|