@inploi/flows 0.0.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/dist/chunk-3QWHH45C.mjs +2 -0
- package/dist/chunk-3QWHH45C.mjs.map +1 -0
- package/dist/interpreter.d.mts +234 -0
- package/dist/interpreter.mjs +2 -0
- package/dist/interpreter.mjs.map +1 -0
- package/dist/linked-list.d.mts +28 -0
- package/dist/linked-list.mjs +2 -0
- package/dist/linked-list.mjs.map +1 -0
- package/dist/result-6033e9fc.d.ts +749 -0
- package/dist/utils.d.mts +60 -0
- package/dist/utils.mjs +2 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Issue reason type.
|
|
3
|
+
*/
|
|
4
|
+
type IssueReason = 'any' | 'array' | 'bigint' | 'blob' | 'boolean' | 'date' | 'function' | 'instance' | 'map' | 'number' | 'object' | 'record' | 'set' | 'special' | 'string' | 'symbol' | 'tuple' | 'undefined' | 'unknown' | 'type';
|
|
5
|
+
/**
|
|
6
|
+
* Issue origin type.
|
|
7
|
+
*/
|
|
8
|
+
type IssueOrigin = 'key' | 'value';
|
|
9
|
+
/**
|
|
10
|
+
* Path item type.
|
|
11
|
+
*/
|
|
12
|
+
type PathItem = ObjectPathItem | RecordPathItem | TuplePathItem | MapPathItem | SetPathItem | ArrayPathItem;
|
|
13
|
+
/**
|
|
14
|
+
* Issue type.
|
|
15
|
+
*/
|
|
16
|
+
type Issue = {
|
|
17
|
+
/**
|
|
18
|
+
* The issue reason.
|
|
19
|
+
*/
|
|
20
|
+
reason: IssueReason;
|
|
21
|
+
/**
|
|
22
|
+
* The validation name.
|
|
23
|
+
*/
|
|
24
|
+
validation: string;
|
|
25
|
+
/**
|
|
26
|
+
* The issue origin.
|
|
27
|
+
*/
|
|
28
|
+
origin: IssueOrigin;
|
|
29
|
+
/**
|
|
30
|
+
* The error message.
|
|
31
|
+
*/
|
|
32
|
+
message: string;
|
|
33
|
+
/**
|
|
34
|
+
* The input data.
|
|
35
|
+
*/
|
|
36
|
+
input: unknown;
|
|
37
|
+
/**
|
|
38
|
+
* The validation requirement
|
|
39
|
+
*/
|
|
40
|
+
requirement?: unknown;
|
|
41
|
+
/**
|
|
42
|
+
* The issue path.
|
|
43
|
+
*/
|
|
44
|
+
path?: PathItem[];
|
|
45
|
+
/**
|
|
46
|
+
* The sub issues.
|
|
47
|
+
*/
|
|
48
|
+
issues?: Issues;
|
|
49
|
+
/**
|
|
50
|
+
* Whether it was abort early.
|
|
51
|
+
*/
|
|
52
|
+
abortEarly?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the pipe was abort early.
|
|
55
|
+
*/
|
|
56
|
+
abortPipeEarly?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the pipe was skipped.
|
|
59
|
+
*/
|
|
60
|
+
skipPipe?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Issues type.
|
|
64
|
+
*/
|
|
65
|
+
type Issues = [Issue, ...Issue[]];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Error message type.
|
|
69
|
+
*/
|
|
70
|
+
type ErrorMessage = string | (() => string);
|
|
71
|
+
/**
|
|
72
|
+
* Resolve type.
|
|
73
|
+
*
|
|
74
|
+
* Hint: This type has no effect and is only used so that TypeScript displays
|
|
75
|
+
* the final type in the preview instead of the utility types used.
|
|
76
|
+
*/
|
|
77
|
+
type Resolve<T> = T;
|
|
78
|
+
/**
|
|
79
|
+
* Resolve object type.
|
|
80
|
+
*
|
|
81
|
+
* Hint: This type has no effect and is only used so that TypeScript displays
|
|
82
|
+
* the final type in the preview instead of the utility types used.
|
|
83
|
+
*/
|
|
84
|
+
type ResolveObject<T> = Resolve<{
|
|
85
|
+
[k in keyof T]: T[k];
|
|
86
|
+
}>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Parse info type.
|
|
90
|
+
*/
|
|
91
|
+
type ParseInfo = Partial<Pick<Issue, 'origin' | 'abortEarly' | 'abortPipeEarly' | 'skipPipe'>>;
|
|
92
|
+
/**
|
|
93
|
+
* Parse result type.
|
|
94
|
+
*/
|
|
95
|
+
type _ParseResult<TOutput> = {
|
|
96
|
+
/**
|
|
97
|
+
* The parse output.
|
|
98
|
+
*/
|
|
99
|
+
output: TOutput;
|
|
100
|
+
/**
|
|
101
|
+
* The parse issues.
|
|
102
|
+
*/
|
|
103
|
+
issues?: undefined;
|
|
104
|
+
} | {
|
|
105
|
+
/**
|
|
106
|
+
* The parse output.
|
|
107
|
+
*/
|
|
108
|
+
output?: undefined;
|
|
109
|
+
/**
|
|
110
|
+
* The parse issues.
|
|
111
|
+
*/
|
|
112
|
+
issues: Issues;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Base schema type.
|
|
116
|
+
*/
|
|
117
|
+
type BaseSchema<TInput = any, TOutput = TInput> = {
|
|
118
|
+
/**
|
|
119
|
+
* Whether it's async.
|
|
120
|
+
*/
|
|
121
|
+
async: false;
|
|
122
|
+
/**
|
|
123
|
+
* Parses unknown input based on its schema.
|
|
124
|
+
*
|
|
125
|
+
* @param input The input to be parsed.
|
|
126
|
+
* @param info The parse info.
|
|
127
|
+
*
|
|
128
|
+
* @returns The parse result.
|
|
129
|
+
*
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
_parse(input: unknown, info?: ParseInfo): _ParseResult<TOutput>;
|
|
133
|
+
/**
|
|
134
|
+
* Input and output type.
|
|
135
|
+
*
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
_types?: {
|
|
139
|
+
input: TInput;
|
|
140
|
+
output: TOutput;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Base schema async type.
|
|
145
|
+
*/
|
|
146
|
+
type BaseSchemaAsync<TInput = any, TOutput = TInput> = {
|
|
147
|
+
/**
|
|
148
|
+
* Whether it's async.
|
|
149
|
+
*/
|
|
150
|
+
async: true;
|
|
151
|
+
/**
|
|
152
|
+
* Parses unknown input based on its schema.
|
|
153
|
+
*
|
|
154
|
+
* @param input The input to be parsed.
|
|
155
|
+
* @param info The parse info.
|
|
156
|
+
*
|
|
157
|
+
* @returns The parse result.
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
_parse(input: unknown, info?: ParseInfo): Promise<_ParseResult<TOutput>>;
|
|
162
|
+
/**
|
|
163
|
+
* Input and output type.
|
|
164
|
+
*
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
_types?: {
|
|
168
|
+
input: TInput;
|
|
169
|
+
output: TOutput;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Input inference type.
|
|
174
|
+
*/
|
|
175
|
+
type Input<TSchema extends BaseSchema | BaseSchemaAsync> = NonNullable<TSchema['_types']>['input'];
|
|
176
|
+
/**
|
|
177
|
+
* Output inference type.
|
|
178
|
+
*/
|
|
179
|
+
type Output<TSchema extends BaseSchema | BaseSchemaAsync> = NonNullable<TSchema['_types']>['output'];
|
|
180
|
+
/**
|
|
181
|
+
* Pipe result type.
|
|
182
|
+
*/
|
|
183
|
+
type PipeResult<TOutput> = {
|
|
184
|
+
/**
|
|
185
|
+
* The pipe output.
|
|
186
|
+
*/
|
|
187
|
+
output: TOutput;
|
|
188
|
+
/**
|
|
189
|
+
* The pipe issues.
|
|
190
|
+
*/
|
|
191
|
+
issues?: undefined;
|
|
192
|
+
} | {
|
|
193
|
+
/**
|
|
194
|
+
* The pipe output.
|
|
195
|
+
*/
|
|
196
|
+
output?: undefined;
|
|
197
|
+
/**
|
|
198
|
+
* The pipe issues.
|
|
199
|
+
*/
|
|
200
|
+
issues: Pick<Issue, 'validation' | 'message' | 'input' | 'requirement'>[];
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Base validation type.
|
|
204
|
+
*/
|
|
205
|
+
type BaseValidation<TInput = any> = {
|
|
206
|
+
/**
|
|
207
|
+
* Whether it's async.
|
|
208
|
+
*/
|
|
209
|
+
async: false;
|
|
210
|
+
/**
|
|
211
|
+
* The error message.
|
|
212
|
+
*/
|
|
213
|
+
message: ErrorMessage;
|
|
214
|
+
/**
|
|
215
|
+
* Parses unknown input based on its requirement.
|
|
216
|
+
*
|
|
217
|
+
* @param input The input to be parsed.
|
|
218
|
+
*
|
|
219
|
+
* @returns The parse result.
|
|
220
|
+
*
|
|
221
|
+
* @internal
|
|
222
|
+
*/
|
|
223
|
+
_parse(input: TInput): PipeResult<TInput>;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Base transformation type.
|
|
227
|
+
*/
|
|
228
|
+
type BaseTransformation<TInput = any> = {
|
|
229
|
+
/**
|
|
230
|
+
* Whether it's async.
|
|
231
|
+
*/
|
|
232
|
+
async: false;
|
|
233
|
+
/**
|
|
234
|
+
* Parses unknown input based on its requirement.
|
|
235
|
+
*
|
|
236
|
+
* @param input The input to be parsed.
|
|
237
|
+
*
|
|
238
|
+
* @returns The parse result.
|
|
239
|
+
*
|
|
240
|
+
* @internal
|
|
241
|
+
*/
|
|
242
|
+
_parse(input: TInput): PipeResult<TInput>;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Pipe type.
|
|
246
|
+
*/
|
|
247
|
+
type Pipe<TInput> = (BaseValidation<TInput> | BaseTransformation<TInput>)[];
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Array path item type.
|
|
251
|
+
*/
|
|
252
|
+
type ArrayPathItem = {
|
|
253
|
+
type: 'array';
|
|
254
|
+
input: unknown[];
|
|
255
|
+
key: number;
|
|
256
|
+
value: unknown;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Boolean schema type.
|
|
261
|
+
*/
|
|
262
|
+
type BooleanSchema<TOutput = boolean> = BaseSchema<boolean, TOutput> & {
|
|
263
|
+
/**
|
|
264
|
+
* The schema type.
|
|
265
|
+
*/
|
|
266
|
+
type: 'boolean';
|
|
267
|
+
/**
|
|
268
|
+
* The error message.
|
|
269
|
+
*/
|
|
270
|
+
message: ErrorMessage;
|
|
271
|
+
/**
|
|
272
|
+
* The validation and transformation pipeline.
|
|
273
|
+
*/
|
|
274
|
+
pipe: Pipe<boolean> | undefined;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Literal type.
|
|
279
|
+
*/
|
|
280
|
+
type Literal = number | string | boolean | symbol | bigint;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Literal schema type.
|
|
284
|
+
*/
|
|
285
|
+
type LiteralSchema<TLiteral extends Literal, TOutput = TLiteral> = BaseSchema<TLiteral, TOutput> & {
|
|
286
|
+
/**
|
|
287
|
+
* The schema type.
|
|
288
|
+
*/
|
|
289
|
+
type: 'literal';
|
|
290
|
+
/**
|
|
291
|
+
* The literal value.
|
|
292
|
+
*/
|
|
293
|
+
literal: TLiteral;
|
|
294
|
+
/**
|
|
295
|
+
* The error message.
|
|
296
|
+
*/
|
|
297
|
+
message: ErrorMessage;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Map path item type.
|
|
302
|
+
*/
|
|
303
|
+
type MapPathItem = {
|
|
304
|
+
type: 'map';
|
|
305
|
+
input: Map<unknown, unknown>;
|
|
306
|
+
key: unknown;
|
|
307
|
+
value: unknown;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Never schema type.
|
|
312
|
+
*/
|
|
313
|
+
type NeverSchema = BaseSchema<never> & {
|
|
314
|
+
/**
|
|
315
|
+
* The schema type.
|
|
316
|
+
*/
|
|
317
|
+
type: 'never';
|
|
318
|
+
/**
|
|
319
|
+
* The error message.
|
|
320
|
+
*/
|
|
321
|
+
message: ErrorMessage;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Never schema async type.
|
|
326
|
+
*/
|
|
327
|
+
type NeverSchemaAsync = BaseSchemaAsync<never> & {
|
|
328
|
+
/**
|
|
329
|
+
* The schema type.
|
|
330
|
+
*/
|
|
331
|
+
type: 'never';
|
|
332
|
+
/**
|
|
333
|
+
* The error message.
|
|
334
|
+
*/
|
|
335
|
+
message: ErrorMessage;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Nullable schema type.
|
|
340
|
+
*/
|
|
341
|
+
type NullableSchema<TWrapped extends BaseSchema, TDefault extends Input<TWrapped> | (() => Input<TWrapped> | undefined) | undefined = undefined, TOutput = TDefault extends Input<TWrapped> ? Output<TWrapped> : Output<TWrapped> | null> = BaseSchema<Input<TWrapped> | null, TOutput> & {
|
|
342
|
+
/**
|
|
343
|
+
* The schema type.
|
|
344
|
+
*/
|
|
345
|
+
type: 'nullable';
|
|
346
|
+
/**
|
|
347
|
+
* The wrapped schema.
|
|
348
|
+
*/
|
|
349
|
+
wrapped: TWrapped;
|
|
350
|
+
/**
|
|
351
|
+
* The default value.
|
|
352
|
+
*/
|
|
353
|
+
default: TDefault;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Number schema type.
|
|
358
|
+
*/
|
|
359
|
+
type NumberSchema<TOutput = number> = BaseSchema<number, TOutput> & {
|
|
360
|
+
/**
|
|
361
|
+
* The schema type.
|
|
362
|
+
*/
|
|
363
|
+
type: 'number';
|
|
364
|
+
/**
|
|
365
|
+
* The error message.
|
|
366
|
+
*/
|
|
367
|
+
message: ErrorMessage;
|
|
368
|
+
/**
|
|
369
|
+
* The validation and transformation pipeline.
|
|
370
|
+
*/
|
|
371
|
+
pipe: Pipe<number> | undefined;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Object entries async type.
|
|
376
|
+
*/
|
|
377
|
+
type ObjectEntriesAsync = Record<string, BaseSchema | BaseSchemaAsync>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Object path item type.
|
|
381
|
+
*/
|
|
382
|
+
type ObjectPathItem = {
|
|
383
|
+
type: 'object';
|
|
384
|
+
input: Record<string, unknown>;
|
|
385
|
+
key: string;
|
|
386
|
+
value: unknown;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Required object keys type.
|
|
390
|
+
*/
|
|
391
|
+
type RequiredKeys<TObject extends object> = {
|
|
392
|
+
[TKey in keyof TObject]: undefined extends TObject[TKey] ? never : TKey;
|
|
393
|
+
}[keyof TObject];
|
|
394
|
+
/**
|
|
395
|
+
* Optional object keys type.
|
|
396
|
+
*/
|
|
397
|
+
type OptionalKeys<TObject extends object> = {
|
|
398
|
+
[TKey in keyof TObject]: undefined extends TObject[TKey] ? TKey : never;
|
|
399
|
+
}[keyof TObject];
|
|
400
|
+
/**
|
|
401
|
+
* Object with question marks type.
|
|
402
|
+
*/
|
|
403
|
+
type WithQuestionMarks<TObject extends object> = Pick<TObject, RequiredKeys<TObject>> & Partial<Pick<TObject, OptionalKeys<TObject>>>;
|
|
404
|
+
/**
|
|
405
|
+
* Object input inference type.
|
|
406
|
+
*/
|
|
407
|
+
type ObjectInput<TEntries extends ObjectEntries | ObjectEntriesAsync, TRest extends BaseSchema | BaseSchemaAsync | undefined> = TRest extends undefined | NeverSchema | NeverSchemaAsync ? ResolveObject<WithQuestionMarks<{
|
|
408
|
+
[TKey in keyof TEntries]: Input<TEntries[TKey]>;
|
|
409
|
+
}>> : TRest extends BaseSchema | BaseSchemaAsync ? ResolveObject<WithQuestionMarks<{
|
|
410
|
+
[TKey in keyof TEntries]: Input<TEntries[TKey]>;
|
|
411
|
+
}>> & Record<string, Input<TRest>> : never;
|
|
412
|
+
/**
|
|
413
|
+
* Object output inference type.
|
|
414
|
+
*/
|
|
415
|
+
type ObjectOutput<TEntries extends ObjectEntries | ObjectEntriesAsync, TRest extends BaseSchema | BaseSchemaAsync | undefined> = TRest extends undefined | NeverSchema | NeverSchemaAsync ? ResolveObject<WithQuestionMarks<{
|
|
416
|
+
[TKey in keyof TEntries]: Output<TEntries[TKey]>;
|
|
417
|
+
}>> : TRest extends BaseSchema | BaseSchemaAsync ? ResolveObject<WithQuestionMarks<{
|
|
418
|
+
[TKey in keyof TEntries]: Output<TEntries[TKey]>;
|
|
419
|
+
}>> & Record<string, Output<TRest>> : never;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Object entries type.
|
|
423
|
+
*/
|
|
424
|
+
type ObjectEntries = Record<string, BaseSchema>;
|
|
425
|
+
/**
|
|
426
|
+
* Object schema type.
|
|
427
|
+
*/
|
|
428
|
+
type ObjectSchema<TEntries extends ObjectEntries, TRest extends BaseSchema | undefined = undefined, TOutput = ObjectOutput<TEntries, TRest>> = BaseSchema<ObjectInput<TEntries, TRest>, TOutput> & {
|
|
429
|
+
/**
|
|
430
|
+
* The schema type.
|
|
431
|
+
*/
|
|
432
|
+
type: 'object';
|
|
433
|
+
/**
|
|
434
|
+
* The object entries schema.
|
|
435
|
+
*/
|
|
436
|
+
entries: TEntries;
|
|
437
|
+
/**
|
|
438
|
+
* The object rest schema.
|
|
439
|
+
*/
|
|
440
|
+
rest: TRest;
|
|
441
|
+
/**
|
|
442
|
+
* The error message.
|
|
443
|
+
*/
|
|
444
|
+
message: ErrorMessage;
|
|
445
|
+
/**
|
|
446
|
+
* The validation and transformation pipeline.
|
|
447
|
+
*/
|
|
448
|
+
pipe: Pipe<ObjectOutput<TEntries, TRest>> | undefined;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Optional schema type.
|
|
453
|
+
*/
|
|
454
|
+
type OptionalSchema<TWrapped extends BaseSchema, TDefault extends Input<TWrapped> | (() => Input<TWrapped> | undefined) | undefined = undefined, TOutput = TDefault extends Input<TWrapped> ? Output<TWrapped> : Output<TWrapped> | undefined> = BaseSchema<Input<TWrapped> | undefined, TOutput> & {
|
|
455
|
+
/**
|
|
456
|
+
* The schema type.
|
|
457
|
+
*/
|
|
458
|
+
type: 'optional';
|
|
459
|
+
/**
|
|
460
|
+
* The wrapped schema.
|
|
461
|
+
*/
|
|
462
|
+
wrapped: TWrapped;
|
|
463
|
+
/**
|
|
464
|
+
* Returns the default value.
|
|
465
|
+
*/
|
|
466
|
+
default: TDefault;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* String schema type.
|
|
471
|
+
*/
|
|
472
|
+
type StringSchema<TOutput = string> = BaseSchema<string, TOutput> & {
|
|
473
|
+
/**
|
|
474
|
+
* The schema type.
|
|
475
|
+
*/
|
|
476
|
+
type: 'string';
|
|
477
|
+
/**
|
|
478
|
+
* The error message.
|
|
479
|
+
*/
|
|
480
|
+
message: ErrorMessage;
|
|
481
|
+
/**
|
|
482
|
+
* The validation and transformation pipeline.
|
|
483
|
+
*/
|
|
484
|
+
pipe: Pipe<string> | undefined;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Record path item type.
|
|
489
|
+
*/
|
|
490
|
+
type RecordPathItem = {
|
|
491
|
+
type: 'record';
|
|
492
|
+
input: Record<string | number | symbol, unknown>;
|
|
493
|
+
key: string | number | symbol;
|
|
494
|
+
value: unknown;
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Set path item type.
|
|
499
|
+
*/
|
|
500
|
+
type SetPathItem = {
|
|
501
|
+
type: 'set';
|
|
502
|
+
input: Set<unknown>;
|
|
503
|
+
key: number;
|
|
504
|
+
value: unknown;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Tuple path item type.
|
|
509
|
+
*/
|
|
510
|
+
type TuplePathItem = {
|
|
511
|
+
type: 'tuple';
|
|
512
|
+
input: [unknown, ...unknown[]];
|
|
513
|
+
key: number;
|
|
514
|
+
value: unknown;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Unknown schema type.
|
|
519
|
+
*/
|
|
520
|
+
type UnknownSchema<TOutput = unknown> = BaseSchema<unknown, TOutput> & {
|
|
521
|
+
/**
|
|
522
|
+
* The schema type.
|
|
523
|
+
*/
|
|
524
|
+
type: 'unknown';
|
|
525
|
+
/**
|
|
526
|
+
* The validation and transformation pipeline.
|
|
527
|
+
*/
|
|
528
|
+
pipe: Pipe<unknown> | undefined;
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
declare const responseSchema: ObjectSchema<{
|
|
532
|
+
/** Not necessarily true when we receive a positive response because the API considers only 200 as success */
|
|
533
|
+
success: BooleanSchema<boolean>;
|
|
534
|
+
integration_response: ObjectSchema<{
|
|
535
|
+
service: OptionalSchema<StringSchema<string>, undefined, string | undefined>;
|
|
536
|
+
status: NumberSchema<number>;
|
|
537
|
+
data: UnknownSchema<unknown>;
|
|
538
|
+
error: NullableSchema<ObjectSchema<{
|
|
539
|
+
message: StringSchema<string>;
|
|
540
|
+
data: UnknownSchema<unknown>;
|
|
541
|
+
}, undefined, {
|
|
542
|
+
message: string;
|
|
543
|
+
data?: unknown;
|
|
544
|
+
}>, undefined, {
|
|
545
|
+
message: string;
|
|
546
|
+
data?: unknown;
|
|
547
|
+
} | null>;
|
|
548
|
+
}, undefined, {
|
|
549
|
+
error: {
|
|
550
|
+
message: string;
|
|
551
|
+
data?: unknown;
|
|
552
|
+
} | null;
|
|
553
|
+
status: number;
|
|
554
|
+
service?: string | undefined;
|
|
555
|
+
data?: unknown;
|
|
556
|
+
}>;
|
|
557
|
+
}, undefined, {
|
|
558
|
+
success: boolean;
|
|
559
|
+
integration_response: {
|
|
560
|
+
error: {
|
|
561
|
+
message: string;
|
|
562
|
+
data?: unknown;
|
|
563
|
+
} | null;
|
|
564
|
+
status: number;
|
|
565
|
+
service?: string | undefined;
|
|
566
|
+
data?: unknown;
|
|
567
|
+
};
|
|
568
|
+
}>;
|
|
569
|
+
type IntegrationResponse = Output<typeof responseSchema>;
|
|
570
|
+
|
|
571
|
+
type TextInput = {
|
|
572
|
+
type: 'text';
|
|
573
|
+
config: {
|
|
574
|
+
key: string;
|
|
575
|
+
optional: boolean;
|
|
576
|
+
placeholder?: string;
|
|
577
|
+
format: 'text' | 'email' | 'url' | 'phone';
|
|
578
|
+
defaultValue?: string;
|
|
579
|
+
maxChars: number | undefined;
|
|
580
|
+
minChars: number | undefined;
|
|
581
|
+
};
|
|
582
|
+
submission: TextInputSubmission;
|
|
583
|
+
};
|
|
584
|
+
type TextInputSubmission = {
|
|
585
|
+
type: 'string';
|
|
586
|
+
value: string;
|
|
587
|
+
};
|
|
588
|
+
type NumberInput = {
|
|
589
|
+
type: 'number';
|
|
590
|
+
config: {
|
|
591
|
+
key: string;
|
|
592
|
+
optional: boolean;
|
|
593
|
+
placeholder?: string;
|
|
594
|
+
defaultValue?: string;
|
|
595
|
+
decimalCases?: number;
|
|
596
|
+
min?: number;
|
|
597
|
+
max?: number;
|
|
598
|
+
};
|
|
599
|
+
submission: NumberInputSubmission;
|
|
600
|
+
};
|
|
601
|
+
type NumberInputSubmission = {
|
|
602
|
+
type: 'number';
|
|
603
|
+
value: number;
|
|
604
|
+
};
|
|
605
|
+
type MultipleChoiceInput = {
|
|
606
|
+
type: 'multiple-choice';
|
|
607
|
+
config: {
|
|
608
|
+
key: string;
|
|
609
|
+
options: {
|
|
610
|
+
value: string;
|
|
611
|
+
label: string;
|
|
612
|
+
}[];
|
|
613
|
+
minSelected?: number;
|
|
614
|
+
maxSelected?: number;
|
|
615
|
+
};
|
|
616
|
+
submission: MultipleChoiceInputSubmission;
|
|
617
|
+
};
|
|
618
|
+
type MultipleChoiceInputSubmission = {
|
|
619
|
+
type: 'enum';
|
|
620
|
+
value: string[];
|
|
621
|
+
};
|
|
622
|
+
type BooleanChoiceInput = {
|
|
623
|
+
type: 'boolean';
|
|
624
|
+
config: {
|
|
625
|
+
key: string;
|
|
626
|
+
labels: {
|
|
627
|
+
true: string;
|
|
628
|
+
false: string;
|
|
629
|
+
};
|
|
630
|
+
optional: boolean;
|
|
631
|
+
};
|
|
632
|
+
submission: BooleanChoiceInputSubmission;
|
|
633
|
+
};
|
|
634
|
+
type BooleanChoiceInputSubmission = {
|
|
635
|
+
type: 'boolean';
|
|
636
|
+
value: boolean;
|
|
637
|
+
};
|
|
638
|
+
type FileToUpload = {
|
|
639
|
+
name: string;
|
|
640
|
+
data: string;
|
|
641
|
+
sizeKb: number;
|
|
642
|
+
};
|
|
643
|
+
type FileInput = {
|
|
644
|
+
type: 'file';
|
|
645
|
+
config: {
|
|
646
|
+
key: string;
|
|
647
|
+
optional: boolean;
|
|
648
|
+
extensions: string[];
|
|
649
|
+
fileSizeLimitKib?: number;
|
|
650
|
+
allowMultiple: boolean;
|
|
651
|
+
};
|
|
652
|
+
key: string;
|
|
653
|
+
submission: FileInputSubmission;
|
|
654
|
+
};
|
|
655
|
+
type FileInputSubmission = {
|
|
656
|
+
type: 'file';
|
|
657
|
+
value: FileToUpload[];
|
|
658
|
+
};
|
|
659
|
+
type SubmitInput = {
|
|
660
|
+
type: 'submit';
|
|
661
|
+
config: {
|
|
662
|
+
key: string;
|
|
663
|
+
label: string;
|
|
664
|
+
};
|
|
665
|
+
submission: SubmitInputSubmission;
|
|
666
|
+
};
|
|
667
|
+
type SubmitInputSubmission = {
|
|
668
|
+
type: 'integration';
|
|
669
|
+
value: IntegrationResponse;
|
|
670
|
+
};
|
|
671
|
+
type AddressInput = {
|
|
672
|
+
type: 'address';
|
|
673
|
+
config: {
|
|
674
|
+
key: string;
|
|
675
|
+
optional: boolean;
|
|
676
|
+
/** Keys for remapping
|
|
677
|
+
* @example {line1: "lineOne"} will send submissions with the key being "lineOne" instead of "line1"
|
|
678
|
+
*/
|
|
679
|
+
keys: {
|
|
680
|
+
line1: string | null;
|
|
681
|
+
line2: string | null;
|
|
682
|
+
line3: string | null;
|
|
683
|
+
city: string | null;
|
|
684
|
+
state: string | null;
|
|
685
|
+
postcode: string | null;
|
|
686
|
+
country: string | null;
|
|
687
|
+
};
|
|
688
|
+
placeholder?: string;
|
|
689
|
+
};
|
|
690
|
+
submission: AddressInputSubmission;
|
|
691
|
+
};
|
|
692
|
+
type AddressInputSubmission = {
|
|
693
|
+
type: 'address';
|
|
694
|
+
value: {
|
|
695
|
+
[remappedKey: string]: string | undefined;
|
|
696
|
+
};
|
|
697
|
+
};
|
|
698
|
+
type PhoneInput = {
|
|
699
|
+
type: 'phone';
|
|
700
|
+
config: {
|
|
701
|
+
key: string;
|
|
702
|
+
optional: boolean;
|
|
703
|
+
submissionFormat: 'phone' | 'text';
|
|
704
|
+
placeholder?: string;
|
|
705
|
+
defaultValue: {
|
|
706
|
+
countryCode?: string;
|
|
707
|
+
phoneNumber?: string;
|
|
708
|
+
};
|
|
709
|
+
minChars?: number;
|
|
710
|
+
maxChars?: number;
|
|
711
|
+
};
|
|
712
|
+
submission: PhoneInputSubmission;
|
|
713
|
+
};
|
|
714
|
+
type PhoneInputSubmission = {
|
|
715
|
+
type: 'phone';
|
|
716
|
+
value: {
|
|
717
|
+
countryCode: string;
|
|
718
|
+
phoneNumber: string;
|
|
719
|
+
};
|
|
720
|
+
} | {
|
|
721
|
+
type: 'string';
|
|
722
|
+
value: string;
|
|
723
|
+
};
|
|
724
|
+
type FlowInput = TextInput | NumberInput | MultipleChoiceInput | BooleanChoiceInput | FileInput | SubmitInput | AddressInput | PhoneInput;
|
|
725
|
+
|
|
726
|
+
type FlowSubmissions = {
|
|
727
|
+
[key: string]: FlowInput['submission'] | {
|
|
728
|
+
type: 'integration';
|
|
729
|
+
value: unknown;
|
|
730
|
+
};
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
type Result<R, E> = Ok<R> | Err<E>;
|
|
734
|
+
interface Ok<R> {
|
|
735
|
+
ok: true;
|
|
736
|
+
err: false;
|
|
737
|
+
val: R;
|
|
738
|
+
'~brand': 'ok';
|
|
739
|
+
}
|
|
740
|
+
declare const Ok: <const R>(val: R) => Ok<R>;
|
|
741
|
+
interface Err<E> {
|
|
742
|
+
ok: false;
|
|
743
|
+
err: true;
|
|
744
|
+
val: E;
|
|
745
|
+
'~brand': 'err';
|
|
746
|
+
}
|
|
747
|
+
declare const Err: <const E>(val: E) => Err<E>;
|
|
748
|
+
|
|
749
|
+
export { Err as E, FlowSubmissions as F, Issues as I, LiteralSchema as L, NullableSchema as N, Ok as O, PhoneInput as P, Result as R, StringSchema as S, FlowInput as a, Output as b, ObjectSchema as c, OptionalSchema as d };
|