@uides/stepwise 1.1.0-d0adc9fb → 2.0.0-07ee8440
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/.rush/temp/chunked-rush-logs/stepwise.build.chunks.jsonl +1 -1
- package/.rush/temp/package-deps_build.json +67 -67
- package/.rush/temp/shrinkwrap-deps.json +2 -2
- package/package.json +6 -6
- package/rush-logs/stepwise.build.log +1 -1
- package/src/schemas/__tests__/step.spec.ts +2 -4
- package/src/schemas/action.ts +132 -131
- package/src/schemas/application.ts +7 -8
- package/src/schemas/attributes.ts +1 -1
- package/src/schemas/common.ts +15 -82
- package/src/schemas/document.ts +53 -49
- package/src/schemas/edupass-healthstate.ts +47 -44
- package/src/schemas/field/afm/index.ts +11 -12
- package/src/schemas/field/amka/index.ts +10 -9
- package/src/schemas/field/attachment/index.ts +21 -20
- package/src/schemas/field/captcha/index.ts +8 -7
- package/src/schemas/field/choice/index.ts +20 -19
- package/src/schemas/field/common.spec.ts +7 -13
- package/src/schemas/field/common.ts +103 -85
- package/src/schemas/field/date/index.ts +24 -23
- package/src/schemas/field/doc_subtitle/index.ts +10 -9
- package/src/schemas/field/doc_title/index.ts +18 -17
- package/src/schemas/field/dynamically-filled-text/index.ts +26 -24
- package/src/schemas/field/email/index.ts +12 -11
- package/src/schemas/field/fillable-string/index.ts +18 -17
- package/src/schemas/field/five-block-date/index.ts +8 -7
- package/src/schemas/field/green-pass-qrcode/index.ts +14 -15
- package/src/schemas/field/hidden/index.ts +58 -64
- package/src/schemas/field/hierarchical-selector/index.ts +27 -25
- package/src/schemas/field/iban/index.ts +11 -10
- package/src/schemas/field/image/index.ts +19 -18
- package/src/schemas/field/index.spec.ts +17 -19
- package/src/schemas/field/index.ts +176 -85
- package/src/schemas/field/int/index.ts +11 -10
- package/src/schemas/field/lab-results/index.ts +9 -8
- package/src/schemas/field/landline_phone/index.ts +8 -7
- package/src/schemas/field/mobile_phone/index.ts +12 -11
- package/src/schemas/field/multiple-choice/index.ts +15 -14
- package/src/schemas/field/pdf-image/index.ts +14 -13
- package/src/schemas/field/postal_code/index.ts +9 -8
- package/src/schemas/field/qrcode/index.ts +18 -17
- package/src/schemas/field/quote/index.ts +18 -17
- package/src/schemas/field/radio-choice/index.ts +21 -15
- package/src/schemas/field/rate/index.ts +10 -9
- package/src/schemas/field/recipient/index.ts +11 -10
- package/src/schemas/field/redirect/index.ts +12 -11
- package/src/schemas/field/refcode/index.ts +25 -24
- package/src/schemas/field/string/index.ts +42 -41
- package/src/schemas/field/text/index.ts +23 -22
- package/src/schemas/field/three-block-date/index.ts +15 -14
- package/src/schemas/fieldset/component-params.ts +40 -37
- package/src/schemas/fieldset/display-components.ts +42 -49
- package/src/schemas/fieldset/enums.ts +12 -6
- package/src/schemas/fieldset/index.ts +9 -10
- package/src/schemas/layout.ts +43 -32
- package/src/schemas/outputs.ts +7 -6
- package/src/schemas/resource/enums.ts +6 -6
- package/src/schemas/resource/field.ts +10 -8
- package/src/schemas/resource/object-action.ts +21 -16
- package/src/schemas/resource/resource-action.ts +19 -17
- package/src/schemas/resource/resource.ts +19 -20
- package/src/schemas/step.ts +116 -115
- package/src/schemas/template/enums.ts +2 -2
- package/src/schemas/template/template-base.ts +15 -13
- package/src/schemas/template/template-source.ts +12 -13
- package/src/schemas/template/template.ts +12 -13
- package/src/schemas/validation-context/enums.ts +5 -5
- package/src/schemas/validation-context/validation-context.ts +45 -44
- package/src/utils/index.spec.ts +2 -0
- package/src/utils/index.ts +5 -3
package/src/schemas/step.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { ActionsSchema } from '@uides/stepwise/schemas/action';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
ComponentLayoutSchema,
|
|
5
|
+
DisplayModeSchema,
|
|
6
|
+
DisplayLangSchema,
|
|
7
|
+
validateField,
|
|
5
8
|
DisplayMode,
|
|
6
9
|
DisplayLang,
|
|
7
|
-
nullish,
|
|
8
|
-
object,
|
|
9
|
-
validateField,
|
|
10
10
|
} from '@uides/stepwise/schemas/common';
|
|
11
11
|
import { FieldsSchema } from '@uides/stepwise/schemas/field';
|
|
12
12
|
import { FieldsetsSchema } from '@uides/stepwise/schemas/fieldset';
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const ManifestAttachmentSchema = v.strictObject({
|
|
15
15
|
field_name: v.string(),
|
|
16
|
-
retrieval_scope: nullish(v.string()),
|
|
16
|
+
retrieval_scope: v.nullish(v.string()),
|
|
17
17
|
'manifest-position': v.picklist(['no', 'begin', 'end']),
|
|
18
|
-
'attachment-handler': nullish(v.string()),
|
|
18
|
+
'attachment-handler': v.nullish(v.string()),
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Describes what to display in a step.
|
|
23
23
|
*/
|
|
24
|
-
export const StepDisplayContentSchema =
|
|
25
|
-
title: nullish(v.string()),
|
|
26
|
-
captionLeft: nullish(v.string()),
|
|
24
|
+
export const StepDisplayContentSchema = v.strictObject({
|
|
25
|
+
title: v.nullish(v.string()),
|
|
26
|
+
captionLeft: v.nullish(v.string()),
|
|
27
27
|
/**
|
|
28
28
|
* The name of the service that the step belongs to
|
|
29
29
|
*
|
|
30
30
|
* It is used to display the name of the service that owns the template this step belongs to,
|
|
31
31
|
* in the header of the UI.
|
|
32
32
|
*/
|
|
33
|
-
serviceName: nullish(v.string()),
|
|
33
|
+
serviceName: v.nullish(v.string()),
|
|
34
34
|
/**
|
|
35
35
|
* The URL of the service to redirect to when the user clicks on the service name
|
|
36
36
|
*/
|
|
37
|
-
serviceURL: nullish(v.string()),
|
|
37
|
+
serviceURL: v.nullish(v.string()),
|
|
38
38
|
/**
|
|
39
39
|
* Service logo to display in the header
|
|
40
40
|
*
|
|
@@ -42,44 +42,44 @@ export const StepDisplayContentSchema = object({
|
|
|
42
42
|
* for the template that the step belongs to. It is used to display the logo in the
|
|
43
43
|
* header of the UI.
|
|
44
44
|
*/
|
|
45
|
-
serviceLogo: nullish(v.string()),
|
|
45
|
+
serviceLogo: v.nullish(v.string()),
|
|
46
46
|
/**
|
|
47
47
|
* The URL of the service to redirect to when the user clicks on the service logo
|
|
48
48
|
*/
|
|
49
|
-
serviceLogoURL: nullish(v.string()),
|
|
50
|
-
footerContent: nullish(v.string()),
|
|
51
|
-
footerLogo: nullish(v.string()),
|
|
52
|
-
footerTop: nullish(v.boolean()),
|
|
53
|
-
termsTitle: nullish(v.string()),
|
|
54
|
-
termsURL: nullish(v.string()),
|
|
55
|
-
fontName: nullish(v.string()),
|
|
56
|
-
'page-numbering': nullish(v.boolean()),
|
|
57
|
-
'signature-position': nullish(v.array(v.number())),
|
|
58
|
-
'signature-page': nullish(v.picklist(['first', 'last'])),
|
|
59
|
-
'state-label': nullish(
|
|
49
|
+
serviceLogoURL: v.nullish(v.string()),
|
|
50
|
+
footerContent: v.nullish(v.string()),
|
|
51
|
+
footerLogo: v.nullish(v.string()),
|
|
52
|
+
footerTop: v.nullish(v.boolean()),
|
|
53
|
+
termsTitle: v.nullish(v.string()),
|
|
54
|
+
termsURL: v.nullish(v.string()),
|
|
55
|
+
fontName: v.nullish(v.string()),
|
|
56
|
+
'page-numbering': v.nullish(v.boolean()),
|
|
57
|
+
'signature-position': v.nullish(v.array(v.number())),
|
|
58
|
+
'signature-page': v.nullish(v.picklist(['first', 'last'])),
|
|
59
|
+
'state-label': v.nullish(
|
|
60
60
|
v.record(v.picklist(['editing', 'issued']), v.string())
|
|
61
61
|
),
|
|
62
|
-
'sidebar-state-label': nullish(v.string()),
|
|
63
|
-
'sidebar-refcode-label': nullish(v.string()),
|
|
64
|
-
'sidebar-template-label': nullish(v.string()),
|
|
65
|
-
'sidebar-issuedate-label': nullish(v.string()),
|
|
66
|
-
'success-message': nullish(v.string()),
|
|
67
|
-
'success-code-message': nullish(v.string()),
|
|
68
|
-
'as-manifest-for-attachment': nullish(
|
|
69
|
-
layout: nullish(
|
|
62
|
+
'sidebar-state-label': v.nullish(v.string()),
|
|
63
|
+
'sidebar-refcode-label': v.nullish(v.string()),
|
|
64
|
+
'sidebar-template-label': v.nullish(v.string()),
|
|
65
|
+
'sidebar-issuedate-label': v.nullish(v.string()),
|
|
66
|
+
'success-message': v.nullish(v.string()),
|
|
67
|
+
'success-code-message': v.nullish(v.string()),
|
|
68
|
+
'as-manifest-for-attachment': v.nullish(ManifestAttachmentSchema),
|
|
69
|
+
layout: v.nullish(ComponentLayoutSchema),
|
|
70
70
|
});
|
|
71
|
-
type StepDisplay = v.
|
|
71
|
+
type StepDisplay = v.InferOutput<typeof StepDisplayContentSchema>;
|
|
72
72
|
type StepDisplayType = Partial<
|
|
73
73
|
Record<DisplayMode, Partial<Record<DisplayLang, StepDisplay>>>
|
|
74
74
|
>;
|
|
75
75
|
|
|
76
76
|
const StepDisplaySchema = v.record(
|
|
77
|
-
|
|
78
|
-
v.record(
|
|
79
|
-
) as unknown as v.
|
|
77
|
+
DisplayModeSchema,
|
|
78
|
+
v.record(DisplayLangSchema, StepDisplayContentSchema)
|
|
79
|
+
) as unknown as v.GenericSchema<StepDisplayType, StepDisplayType>;
|
|
80
80
|
|
|
81
|
-
const PossibleNextStepsSchema =
|
|
82
|
-
documentation:
|
|
81
|
+
const PossibleNextStepsSchema = v.strictObject({
|
|
82
|
+
documentation: v.strictObject({
|
|
83
83
|
label: v.string(),
|
|
84
84
|
}),
|
|
85
85
|
});
|
|
@@ -87,90 +87,91 @@ const PossibleNextStepsSchema = object({
|
|
|
87
87
|
/**
|
|
88
88
|
* Describes a step.
|
|
89
89
|
*/
|
|
90
|
-
export const StepSchema =
|
|
91
|
-
{
|
|
90
|
+
export const StepSchema = v.pipe(
|
|
91
|
+
v.strictObject({
|
|
92
92
|
/**
|
|
93
93
|
* Actions that can be performed on the step
|
|
94
94
|
*
|
|
95
95
|
* An action is usually translated as a button in the UI, which the user can click
|
|
96
96
|
* to perform an action, like downloading a PDF or going to the next step.
|
|
97
97
|
*/
|
|
98
|
-
actions: nullish(ActionsSchema), // TODO: Not optional in backend schema but optional in some templates
|
|
98
|
+
actions: v.nullish(ActionsSchema), // TODO: Not optional in backend schema but optional in some templates
|
|
99
99
|
'action-order': v.string(),
|
|
100
|
-
fields: nullish(FieldsSchema), // TODO: Not optional in backend schema but optional in some templates
|
|
101
|
-
fieldsets: nullish(FieldsetsSchema), // TODO: Not optional in backend schema but optional in some templates
|
|
100
|
+
fields: v.nullish(FieldsSchema), // TODO: Not optional in backend schema but optional in some templates
|
|
101
|
+
fieldsets: v.nullish(FieldsetsSchema), // TODO: Not optional in backend schema but optional in some templates
|
|
102
102
|
'fieldset-order': v.string(),
|
|
103
|
-
possible_next_steps:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
possible_next_steps: v.nullish(
|
|
104
|
+
v.record(v.string(), PossibleNextStepsSchema)
|
|
105
|
+
),
|
|
106
|
+
'field-compute-order': v.nullish(v.string()),
|
|
107
|
+
next_step: v.nullish(v.string()),
|
|
108
|
+
pre_access_hook: v.nullish(v.string()),
|
|
109
|
+
decide_next_step: v.nullish(v.string()),
|
|
108
110
|
display: StepDisplaySchema,
|
|
109
|
-
validator: nullish(v.string()),
|
|
111
|
+
validator: v.nullish(v.string()),
|
|
110
112
|
/** @default false */
|
|
111
|
-
'is-final-view': nullish(v.boolean()),
|
|
112
|
-
validation_dynamic_info: nullish(v.string()),
|
|
113
|
-
'has-display-fields': nullish(v.boolean()),
|
|
114
|
-
targets: nullish(v.array(v.record(v.any()))),
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
for (const field of Object.values(fields || {})) {
|
|
153
|
-
if (
|
|
154
|
-
field['user-input-mode'] !== 'noinput' &&
|
|
155
|
-
field['user-input-mode'] !== 'display'
|
|
156
|
-
)
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return true;
|
|
161
|
-
}),
|
|
162
|
-
validateField('fields', (fields) => {
|
|
113
|
+
'is-final-view': v.nullish(v.boolean()),
|
|
114
|
+
validation_dynamic_info: v.nullish(v.string()),
|
|
115
|
+
'has-display-fields': v.nullish(v.boolean()),
|
|
116
|
+
targets: v.nullish(v.array(v.record(v.string(), v.any()))),
|
|
117
|
+
}),
|
|
118
|
+
|
|
119
|
+
validateField('fieldsets', (fieldsets, step) => {
|
|
120
|
+
if (!fieldsets || !step.fields) return true;
|
|
121
|
+
const fieldsSpec = step.fields;
|
|
122
|
+
for (const fieldset of Object.values(fieldsets)) {
|
|
123
|
+
if (!validateOrderOnSet(fieldset['field-order'], fieldsSpec))
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}),
|
|
128
|
+
validateField('fieldset-order', (fieldsetOrder, step) => {
|
|
129
|
+
if (!fieldsetOrder || !step.fieldsets) return true;
|
|
130
|
+
return validateOrderOnSet(fieldsetOrder, step.fieldsets);
|
|
131
|
+
}),
|
|
132
|
+
validateField('action-order', (actionOrder, step) => {
|
|
133
|
+
if (!actionOrder || !step.actions) return true;
|
|
134
|
+
return validateOrderOnSet(actionOrder, step.actions);
|
|
135
|
+
}),
|
|
136
|
+
validateField('decide_next_step', (decideNextStep, step) => {
|
|
137
|
+
if (!decideNextStep) return true;
|
|
138
|
+
const possibleNextSteps = Object.keys(step.possible_next_steps || {});
|
|
139
|
+
if (!possibleNextSteps.length) return false;
|
|
140
|
+
return true;
|
|
141
|
+
}),
|
|
142
|
+
validateField('fields', (fields, step) => {
|
|
143
|
+
const actions = step.actions;
|
|
144
|
+
const actionOrder = step['action-order'];
|
|
145
|
+
if (!actionOrder.split(' ').includes('update')) return true;
|
|
146
|
+
if (
|
|
147
|
+
actions &&
|
|
148
|
+
actions['update'] &&
|
|
149
|
+
'component-params' in actions['update'] &&
|
|
150
|
+
actions['update']['component-params'] &&
|
|
151
|
+
'ensure-no-input' in actions['update']['component-params'] &&
|
|
152
|
+
actions['update']['component-params']['ensure-no-input']
|
|
153
|
+
) {
|
|
163
154
|
for (const field of Object.values(fields || {})) {
|
|
164
155
|
if (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
!field.display
|
|
156
|
+
field['user-input-mode'] !== 'noinput' &&
|
|
157
|
+
field['user-input-mode'] !== 'display'
|
|
168
158
|
)
|
|
169
159
|
return false;
|
|
170
160
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
161
|
+
}
|
|
162
|
+
return true;
|
|
163
|
+
}),
|
|
164
|
+
validateField('fields', (fields) => {
|
|
165
|
+
for (const field of Object.values(fields || {})) {
|
|
166
|
+
if (
|
|
167
|
+
(field['user-input-mode'] === 'required' ||
|
|
168
|
+
field['user-input-mode'] === 'optional') &&
|
|
169
|
+
!field.display
|
|
170
|
+
)
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
})
|
|
174
175
|
);
|
|
175
176
|
|
|
176
177
|
function validateOrderOnSet(
|
|
@@ -185,20 +186,20 @@ function validateOrderOnSet(
|
|
|
185
186
|
return true;
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
export type Step = v.
|
|
189
|
-
type
|
|
189
|
+
export type Step = v.InferOutput<typeof StepSchema>;
|
|
190
|
+
type StepSchemaType = v.GenericSchema<Step, Step>;
|
|
190
191
|
|
|
191
192
|
export type StepsType = Record<string, Step>;
|
|
192
|
-
const StepsSchema = v.record(v.string(), StepSchema) as v.
|
|
193
|
+
const StepsSchema = v.record(v.string(), StepSchema) as v.GenericSchema<
|
|
193
194
|
StepsType,
|
|
194
195
|
StepsType
|
|
195
196
|
>;
|
|
196
197
|
export const StepsSpecSchema = v.object({
|
|
197
198
|
'steps-order': v.string(),
|
|
198
|
-
collectable: nullish(v.boolean()),
|
|
199
|
-
sign: nullish(v.boolean()),
|
|
199
|
+
collectable: v.nullish(v.boolean()),
|
|
200
|
+
sign: v.nullish(v.boolean()),
|
|
200
201
|
steps: StepsSchema,
|
|
201
|
-
'intro-step': nullish(StepSchema as unknown as
|
|
202
|
+
'intro-step': v.nullish(StepSchema as unknown as StepSchemaType),
|
|
202
203
|
});
|
|
203
|
-
export type StepsSpec = v.
|
|
204
|
-
export type
|
|
204
|
+
export type StepsSpec = v.InferOutput<typeof StepsSpecSchema>;
|
|
205
|
+
export type StepsSpecSchemaType = v.GenericSchema<StepsSpec, StepsSpec>;
|
|
@@ -10,7 +10,7 @@ import * as v from 'valibot';
|
|
|
10
10
|
* @value 'global' Global recipient.
|
|
11
11
|
* @value 'dataset' Dataset recipient.
|
|
12
12
|
*/
|
|
13
|
-
export const
|
|
13
|
+
export const RecipientPolicySchema = v.picklist([
|
|
14
14
|
'none',
|
|
15
15
|
'owner_box',
|
|
16
16
|
'owner',
|
|
@@ -19,4 +19,4 @@ export const RecipientPolicy = v.picklist([
|
|
|
19
19
|
'dataset',
|
|
20
20
|
'targets', // TODO: Add documentation for this value
|
|
21
21
|
]);
|
|
22
|
-
export type RecipientPolicy = v.
|
|
22
|
+
export type RecipientPolicy = v.InferOutput<typeof RecipientPolicySchema>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
StepsSpecSchema,
|
|
4
|
+
StepsSpecSchemaType,
|
|
5
|
+
} from '@uides/stepwise/schemas/step';
|
|
6
|
+
import { RecipientPolicySchema } from '@uides/stepwise/schemas/template/enums';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Describes a template
|
|
@@ -9,21 +11,21 @@ import { RecipientPolicy } from '@uides/stepwise/schemas/template/enums';
|
|
|
9
11
|
* A template is a set of steps that the user must complete in order to complete a process
|
|
10
12
|
* in the system, whether that is the issuance of a document or the entry of a request.
|
|
11
13
|
*/
|
|
12
|
-
export const
|
|
14
|
+
export const TemplateBaseSchema = v.strictObject({
|
|
13
15
|
/**
|
|
14
16
|
* Template's creation date
|
|
15
17
|
*/
|
|
16
|
-
created_at: nullish(v.string()),
|
|
18
|
+
created_at: v.nullish(v.string()),
|
|
17
19
|
/** Brief summary of template */
|
|
18
20
|
description: v.string(),
|
|
19
|
-
id: nullish(v.number()),
|
|
21
|
+
id: v.nullish(v.number()),
|
|
20
22
|
/**
|
|
21
23
|
* Defines the fields that are used to index documents
|
|
22
24
|
*
|
|
23
25
|
* A list of fields of the document, that are used to index multiple documents upon their
|
|
24
26
|
* presentation to the user's gate interface.
|
|
25
27
|
*/
|
|
26
|
-
index_by_fields: nullish(v.string()),
|
|
28
|
+
index_by_fields: v.nullish(v.string()),
|
|
27
29
|
/**
|
|
28
30
|
* Whether the template is officially published or not.
|
|
29
31
|
*
|
|
@@ -31,7 +33,7 @@ export const TemplateBase = object({
|
|
|
31
33
|
* Otherwise it is considered a draft and the documents it produces are not valid.
|
|
32
34
|
* @default true
|
|
33
35
|
*/
|
|
34
|
-
is_official: nullish(v.boolean()),
|
|
36
|
+
is_official: v.nullish(v.boolean()),
|
|
35
37
|
/**
|
|
36
38
|
* Codename of the gate that owns the template
|
|
37
39
|
*
|
|
@@ -43,15 +45,15 @@ export const TemplateBase = object({
|
|
|
43
45
|
* Recipient's business title
|
|
44
46
|
* @deprecated
|
|
45
47
|
*/
|
|
46
|
-
recipient_hint: nullish(v.string()),
|
|
48
|
+
recipient_hint: v.nullish(v.string()),
|
|
47
49
|
/** How the document's recipient is determined */
|
|
48
|
-
recipient_policy:
|
|
50
|
+
recipient_policy: RecipientPolicySchema,
|
|
49
51
|
/** The template's unique identifier */
|
|
50
52
|
refname: v.string(),
|
|
51
53
|
/**
|
|
52
54
|
* List of templates with which replies to the document can be issued.
|
|
53
55
|
*/
|
|
54
|
-
reply_templates: nullish(v.array(v.string())),
|
|
56
|
+
reply_templates: v.nullish(v.array(v.string())),
|
|
55
57
|
/** Brief title of template */
|
|
56
58
|
shortname: v.string(),
|
|
57
59
|
/** Description of template */
|
|
@@ -59,9 +61,9 @@ export const TemplateBase = object({
|
|
|
59
61
|
/**
|
|
60
62
|
* Specification of the steps of the template.
|
|
61
63
|
*/
|
|
62
|
-
steps_spec: nullish(StepsSpecSchema as unknown as
|
|
64
|
+
steps_spec: v.nullish(StepsSpecSchema as unknown as StepsSpecSchemaType),
|
|
63
65
|
});
|
|
64
66
|
|
|
65
|
-
export type TemplateBase = v.
|
|
67
|
+
export type TemplateBase = v.InferOutput<typeof TemplateBaseSchema>;
|
|
66
68
|
|
|
67
69
|
export default TemplateBase;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import {
|
|
3
|
-
import { TemplateBase } from '@uides/stepwise/schemas/template/template-base';
|
|
2
|
+
import { TemplateBaseSchema } from '@uides/stepwise/schemas/template/template-base';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Template model used in the backend.
|
|
@@ -10,36 +9,36 @@ import { TemplateBase } from '@uides/stepwise/schemas/template/template-base';
|
|
|
10
9
|
*
|
|
11
10
|
* @see {@link TemplateBase} for the definition of a template.
|
|
12
11
|
*/
|
|
13
|
-
export const
|
|
12
|
+
export const TemplateSourceSchema = v.strictObject(
|
|
14
13
|
{
|
|
15
|
-
...
|
|
14
|
+
...TemplateBaseSchema.entries,
|
|
16
15
|
/**
|
|
17
16
|
* Action to execute when the document is issued.
|
|
18
17
|
*/
|
|
19
|
-
action_on_issue: nullish(v.string()),
|
|
20
|
-
case_prefixes: nullish(v.array(v.string())),
|
|
18
|
+
action_on_issue: v.nullish(v.string()),
|
|
19
|
+
case_prefixes: v.nullish(v.array(v.string())),
|
|
21
20
|
/**
|
|
22
21
|
* Claims that are not checked for in the user's session
|
|
23
22
|
*/
|
|
24
|
-
exempted_claims: nullish(v.array(v.string())),
|
|
23
|
+
exempted_claims: v.nullish(v.array(v.string())),
|
|
25
24
|
/**
|
|
26
25
|
* Extra claims to check for in the user's session.
|
|
27
26
|
*
|
|
28
27
|
* When creating a new declaration that includes the template, the application checks
|
|
29
28
|
* that the session contains all the claims specified in this field.
|
|
30
29
|
*/
|
|
31
|
-
extra_required_claims: nullish(v.array(v.string())),
|
|
32
|
-
posting_whitelist: nullish(v.array(v.string())),
|
|
30
|
+
extra_required_claims: v.nullish(v.array(v.string())),
|
|
31
|
+
posting_whitelist: v.nullish(v.array(v.string())),
|
|
33
32
|
/**
|
|
34
33
|
* Whether a case number is assigned on instantiation of the template.
|
|
35
34
|
* @default false
|
|
36
35
|
*/
|
|
37
|
-
requires_case: nullish(v.boolean()),
|
|
38
|
-
validation_context: nullish(v.string()),
|
|
36
|
+
requires_case: v.nullish(v.boolean()),
|
|
37
|
+
validation_context: v.nullish(v.string()),
|
|
39
38
|
/**
|
|
40
39
|
* Defines the access policy of th document in the validation phase
|
|
41
40
|
*/
|
|
42
|
-
validation_policy: nullish(v.string()),
|
|
41
|
+
validation_policy: v.nullish(v.string()),
|
|
43
42
|
}
|
|
44
43
|
// TODO: Is this validation pipeline necessary?
|
|
45
44
|
// [
|
|
@@ -84,6 +83,6 @@ export const TemplateSource = object(
|
|
|
84
83
|
// return true;
|
|
85
84
|
// }
|
|
86
85
|
|
|
87
|
-
export type TemplateSource = v.
|
|
86
|
+
export type TemplateSource = v.InferOutput<typeof TemplateSourceSchema>;
|
|
88
87
|
|
|
89
88
|
export default TemplateSource;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import {
|
|
3
|
-
import { TemplateBase } from '@uides/stepwise/schemas/template/template-base';
|
|
2
|
+
import { TemplateBaseSchema } from '@uides/stepwise/schemas/template/template-base';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Template type used in the frontend.
|
|
@@ -10,13 +9,13 @@ import { TemplateBase } from '@uides/stepwise/schemas/template/template-base';
|
|
|
10
9
|
*
|
|
11
10
|
* @see {@link TemplateBase} for the definition of a template.
|
|
12
11
|
*/
|
|
13
|
-
export const
|
|
14
|
-
...
|
|
12
|
+
export const TemplateSchema = v.strictObject({
|
|
13
|
+
...TemplateBaseSchema.entries,
|
|
15
14
|
/**
|
|
16
15
|
* Whether the template is enabled or not.
|
|
17
16
|
*/
|
|
18
|
-
enabled: nullish(v.boolean()),
|
|
19
|
-
template_type:
|
|
17
|
+
enabled: v.nullish(v.boolean()),
|
|
18
|
+
template_type: v.strictObject({
|
|
20
19
|
/** @default 'application' */
|
|
21
20
|
refname: v.string(),
|
|
22
21
|
/** @default [] */
|
|
@@ -27,7 +26,7 @@ export const Template = object({
|
|
|
27
26
|
* Recipient's business title
|
|
28
27
|
* @deprecated
|
|
29
28
|
*/
|
|
30
|
-
recipient_hint: nullish(v.string()),
|
|
29
|
+
recipient_hint: v.nullish(v.string()),
|
|
31
30
|
/**
|
|
32
31
|
* Claims that the application checks for in the user's session.
|
|
33
32
|
*
|
|
@@ -40,12 +39,12 @@ export const Template = object({
|
|
|
40
39
|
* An entity's gate can be the owner of a template. If not specified, the template is considered
|
|
41
40
|
* to be owned by the "System".
|
|
42
41
|
*/
|
|
43
|
-
owner: nullish(v.string()),
|
|
44
|
-
login_endpoint: nullish(v.string()),
|
|
45
|
-
fields: nullish(v.array(v.any())),
|
|
46
|
-
allow_custom_recipient: nullish(v.boolean()),
|
|
47
|
-
listable: nullish(v.boolean()),
|
|
42
|
+
owner: v.nullish(v.string()),
|
|
43
|
+
login_endpoint: v.nullish(v.string()),
|
|
44
|
+
fields: v.nullish(v.array(v.any())),
|
|
45
|
+
allow_custom_recipient: v.nullish(v.boolean()),
|
|
46
|
+
listable: v.nullish(v.boolean()),
|
|
48
47
|
});
|
|
49
|
-
export type Template = v.
|
|
48
|
+
export type Template = v.InferOutput<typeof TemplateSchema>;
|
|
50
49
|
|
|
51
50
|
export default Template;
|
|
@@ -7,13 +7,13 @@ import * as v from 'valibot';
|
|
|
7
7
|
* @value 'validate-document-qrcode' Validate document QR code.
|
|
8
8
|
* @value 'paragraph' Paragraph.
|
|
9
9
|
*/
|
|
10
|
-
export const
|
|
10
|
+
export const ValidationFieldComponentSchema = v.picklist([
|
|
11
11
|
'validate-document-string',
|
|
12
12
|
'validate-document-qrcode',
|
|
13
13
|
'paragraph',
|
|
14
14
|
]);
|
|
15
|
-
export type ValidationFieldComponent = v.
|
|
16
|
-
typeof
|
|
15
|
+
export type ValidationFieldComponent = v.InferOutput<
|
|
16
|
+
typeof ValidationFieldComponentSchema
|
|
17
17
|
>;
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -24,10 +24,10 @@ export type ValidationFieldComponent = v.Output<
|
|
|
24
24
|
* @value 'noinput' No user input allowed, like 'display'.
|
|
25
25
|
* @value 'display' Display only the value of the field, like 'noinput'.
|
|
26
26
|
*/
|
|
27
|
-
export const
|
|
27
|
+
export const UserInputModeSchema = v.picklist([
|
|
28
28
|
'required',
|
|
29
29
|
'optional',
|
|
30
30
|
'noinput',
|
|
31
31
|
'display',
|
|
32
32
|
]);
|
|
33
|
-
export type UserInputMode = v.
|
|
33
|
+
export type UserInputMode = v.InferOutput<typeof UserInputModeSchema>;
|