@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.
Files changed (70) hide show
  1. package/.rush/temp/chunked-rush-logs/stepwise.build.chunks.jsonl +1 -1
  2. package/.rush/temp/package-deps_build.json +67 -67
  3. package/.rush/temp/shrinkwrap-deps.json +2 -2
  4. package/package.json +6 -6
  5. package/rush-logs/stepwise.build.log +1 -1
  6. package/src/schemas/__tests__/step.spec.ts +2 -4
  7. package/src/schemas/action.ts +132 -131
  8. package/src/schemas/application.ts +7 -8
  9. package/src/schemas/attributes.ts +1 -1
  10. package/src/schemas/common.ts +15 -82
  11. package/src/schemas/document.ts +53 -49
  12. package/src/schemas/edupass-healthstate.ts +47 -44
  13. package/src/schemas/field/afm/index.ts +11 -12
  14. package/src/schemas/field/amka/index.ts +10 -9
  15. package/src/schemas/field/attachment/index.ts +21 -20
  16. package/src/schemas/field/captcha/index.ts +8 -7
  17. package/src/schemas/field/choice/index.ts +20 -19
  18. package/src/schemas/field/common.spec.ts +7 -13
  19. package/src/schemas/field/common.ts +103 -85
  20. package/src/schemas/field/date/index.ts +24 -23
  21. package/src/schemas/field/doc_subtitle/index.ts +10 -9
  22. package/src/schemas/field/doc_title/index.ts +18 -17
  23. package/src/schemas/field/dynamically-filled-text/index.ts +26 -24
  24. package/src/schemas/field/email/index.ts +12 -11
  25. package/src/schemas/field/fillable-string/index.ts +18 -17
  26. package/src/schemas/field/five-block-date/index.ts +8 -7
  27. package/src/schemas/field/green-pass-qrcode/index.ts +14 -15
  28. package/src/schemas/field/hidden/index.ts +58 -64
  29. package/src/schemas/field/hierarchical-selector/index.ts +27 -25
  30. package/src/schemas/field/iban/index.ts +11 -10
  31. package/src/schemas/field/image/index.ts +19 -18
  32. package/src/schemas/field/index.spec.ts +17 -19
  33. package/src/schemas/field/index.ts +176 -85
  34. package/src/schemas/field/int/index.ts +11 -10
  35. package/src/schemas/field/lab-results/index.ts +9 -8
  36. package/src/schemas/field/landline_phone/index.ts +8 -7
  37. package/src/schemas/field/mobile_phone/index.ts +12 -11
  38. package/src/schemas/field/multiple-choice/index.ts +15 -14
  39. package/src/schemas/field/pdf-image/index.ts +14 -13
  40. package/src/schemas/field/postal_code/index.ts +9 -8
  41. package/src/schemas/field/qrcode/index.ts +18 -17
  42. package/src/schemas/field/quote/index.ts +18 -17
  43. package/src/schemas/field/radio-choice/index.ts +21 -15
  44. package/src/schemas/field/rate/index.ts +10 -9
  45. package/src/schemas/field/recipient/index.ts +11 -10
  46. package/src/schemas/field/redirect/index.ts +12 -11
  47. package/src/schemas/field/refcode/index.ts +25 -24
  48. package/src/schemas/field/string/index.ts +42 -41
  49. package/src/schemas/field/text/index.ts +23 -22
  50. package/src/schemas/field/three-block-date/index.ts +15 -14
  51. package/src/schemas/fieldset/component-params.ts +40 -37
  52. package/src/schemas/fieldset/display-components.ts +42 -49
  53. package/src/schemas/fieldset/enums.ts +12 -6
  54. package/src/schemas/fieldset/index.ts +9 -10
  55. package/src/schemas/layout.ts +43 -32
  56. package/src/schemas/outputs.ts +7 -6
  57. package/src/schemas/resource/enums.ts +6 -6
  58. package/src/schemas/resource/field.ts +10 -8
  59. package/src/schemas/resource/object-action.ts +21 -16
  60. package/src/schemas/resource/resource-action.ts +19 -17
  61. package/src/schemas/resource/resource.ts +19 -20
  62. package/src/schemas/step.ts +116 -115
  63. package/src/schemas/template/enums.ts +2 -2
  64. package/src/schemas/template/template-base.ts +15 -13
  65. package/src/schemas/template/template-source.ts +12 -13
  66. package/src/schemas/template/template.ts +12 -13
  67. package/src/schemas/validation-context/enums.ts +5 -5
  68. package/src/schemas/validation-context/validation-context.ts +45 -44
  69. package/src/utils/index.spec.ts +2 -0
  70. package/src/utils/index.ts +5 -3
@@ -1,70 +1,63 @@
1
1
  import * as v from 'valibot';
2
2
  import {
3
- ComponentLayout,
4
- DisplayLang,
5
- nullish,
6
- object,
3
+ ComponentLayoutSchema,
4
+ DisplayLangSchema,
7
5
  } from '@uides/stepwise/schemas/common';
8
6
  import {
9
- OtherComponentParams,
10
- TableComponentParams,
7
+ OtherComponentParamsSchema,
8
+ TableComponentParamsSchema,
11
9
  } from '@uides/stepwise/schemas/fieldset/component-params';
12
10
  import {
13
- PdfOtherComponent,
14
- PdfTableBasedComponent,
15
- WebComponent,
11
+ PdfOtherComponentSchema,
12
+ PdfTableBasedComponentSchema,
13
+ WebComponentSchema,
16
14
  } from '@uides/stepwise/schemas/fieldset/enums';
17
15
 
18
- export const FieldsetWebDisplay = object({
16
+ export const FieldsetWebDisplaySchema = v.strictObject({
19
17
  /** The explanatory title of the fieldset */
20
- title: nullish(v.string()),
21
- component: WebComponent,
22
- 'component-params': nullish(TableComponentParams),
23
- layout: nullish(ComponentLayout),
18
+ title: v.nullish(v.string()),
19
+ component: WebComponentSchema,
20
+ 'component-params': v.nullish(TableComponentParamsSchema),
21
+ layout: v.nullish(ComponentLayoutSchema),
24
22
  });
25
- export type FieldsetWebDisplay = v.Output<typeof FieldsetWebDisplay>;
23
+ export type FieldsetWebDisplay = v.InferOutput<typeof FieldsetWebDisplaySchema>;
26
24
 
27
- export const FieldsetPdfDisplayTable = object({
25
+ export const FieldsetPdfDisplayTableSchema = v.strictObject({
28
26
  /** The explanatory title of the fieldset */
29
- title: nullish(v.string()),
30
- component: PdfTableBasedComponent,
31
- 'component-params': nullish(TableComponentParams),
27
+ title: v.nullish(v.string()),
28
+ component: PdfTableBasedComponentSchema,
29
+ 'component-params': v.nullish(TableComponentParamsSchema),
32
30
  });
33
- export type FieldsetPdfDisplayTable = v.Output<typeof FieldsetPdfDisplayTable>;
31
+ export type FieldsetPdfDisplayTable = v.InferOutput<
32
+ typeof FieldsetPdfDisplayTableSchema
33
+ >;
34
34
 
35
- export const FieldsetPdfDisplayOther = object({
35
+ export const FieldsetPdfDisplayOtherSchema = v.strictObject({
36
36
  /** The explanatory title of the fieldset */
37
- title: nullish(v.string()),
38
- component: PdfOtherComponent,
39
- 'component-params': nullish(OtherComponentParams),
37
+ title: v.nullish(v.string()),
38
+ component: PdfOtherComponentSchema,
39
+ 'component-params': v.nullish(OtherComponentParamsSchema),
40
40
  });
41
- export type FieldsetPdfDisplayOther = v.Output<typeof FieldsetPdfDisplayOther>;
41
+ export type FieldsetPdfDisplayOther = v.InferOutput<
42
+ typeof FieldsetPdfDisplayOtherSchema
43
+ >;
42
44
 
43
- export const FieldsetPdfDisplay = v.variant('component', [
44
- FieldsetPdfDisplayTable,
45
- FieldsetPdfDisplayOther,
45
+ export const FieldsetPdfDisplaySchema = v.variant('component', [
46
+ FieldsetPdfDisplayTableSchema,
47
+ FieldsetPdfDisplayOtherSchema,
46
48
  ]);
47
- export type FieldsetPdfDisplay = v.Output<typeof FieldsetPdfDisplay>;
49
+ export type FieldsetPdfDisplay = v.InferOutput<typeof FieldsetPdfDisplaySchema>;
48
50
 
49
- export const FieldsetDisplay = v.union([
50
- v.object(
51
- {
52
- default: v.record(DisplayLang, FieldsetWebDisplay),
53
- },
54
- v.unknown()
55
- ),
56
- v.object(
57
- {
58
- web: v.record(DisplayLang, FieldsetWebDisplay),
59
- },
60
- v.unknown()
61
- ),
62
- v.object(
63
- {
64
- pdf: v.record(DisplayLang, FieldsetPdfDisplay),
65
- },
66
- v.unknown()
67
- ),
51
+ export const FieldsetDisplaySchema = v.union([
52
+ v.looseObject({
53
+ default: v.record(DisplayLangSchema, FieldsetWebDisplaySchema),
54
+ }),
55
+ v.looseObject({
56
+ web: v.record(DisplayLangSchema, FieldsetWebDisplaySchema),
57
+ }),
58
+ v.looseObject({
59
+ pdf: v.record(DisplayLangSchema, FieldsetPdfDisplaySchema),
60
+ }),
68
61
  ]);
69
62
 
70
- export type FieldsetDisplay = v.Output<typeof FieldsetDisplay>;
63
+ export type FieldsetDisplay = v.InferOutput<typeof FieldsetDisplaySchema>;
@@ -7,8 +7,8 @@ import * as v from 'valibot';
7
7
  * @value 'hidden' Hidden.
8
8
  * @value 'form' Form.
9
9
  */
10
- export const WebComponent = v.picklist(['values-list', 'hidden', 'form']);
11
- export type WebComponent = v.Output<typeof WebComponent>;
10
+ export const WebComponentSchema = v.picklist(['values-list', 'hidden', 'form']);
11
+ export type WebComponent = v.InferOutput<typeof WebComponentSchema>;
12
12
 
13
13
  /**
14
14
  * Pdf table-based component type.
@@ -21,7 +21,7 @@ export type WebComponent = v.Output<typeof WebComponent>;
21
21
  * @value 'hidden' Hidden.
22
22
  * @value 'custom' Custom.
23
23
  */
24
- export const PdfTableBasedComponent = v.picklist([
24
+ export const PdfTableBasedComponentSchema = v.picklist([
25
25
  'values-list',
26
26
  'table',
27
27
  'one-liner-table',
@@ -30,7 +30,9 @@ export const PdfTableBasedComponent = v.picklist([
30
30
  'hidden',
31
31
  'custom',
32
32
  ]);
33
- export type PdfTableBasedComponent = v.Output<typeof PdfTableBasedComponent>;
33
+ export type PdfTableBasedComponent = v.InferOutput<
34
+ typeof PdfTableBasedComponentSchema
35
+ >;
34
36
 
35
37
  /**
36
38
  * Pdf component type.
@@ -39,5 +41,9 @@ export type PdfTableBasedComponent = v.Output<typeof PdfTableBasedComponent>;
39
41
  * @value 'common' Common.
40
42
  * @value 'plain-text' Plain text. Ideal for displaying fields with values that are large texts. It helps in displaying the text across multiple pages.
41
43
  */
42
- export const PdfOtherComponent = v.picklist(['header', 'common', 'plain-text']);
43
- export type PdfOtherComponent = v.Output<typeof PdfOtherComponent>;
44
+ export const PdfOtherComponentSchema = v.picklist([
45
+ 'header',
46
+ 'common',
47
+ 'plain-text',
48
+ ]);
49
+ export type PdfOtherComponent = v.InferOutput<typeof PdfOtherComponentSchema>;
@@ -3,8 +3,7 @@ export * from '@uides/stepwise/schemas/fieldset/component-params';
3
3
  export * from '@uides/stepwise/schemas/fieldset/display-components';
4
4
 
5
5
  import * as v from 'valibot';
6
- import { nullish, object } from '@uides/stepwise/schemas/common';
7
- import { FieldsetDisplay } from '@uides/stepwise/schemas/fieldset/display-components';
6
+ import { FieldsetDisplaySchema } from '@uides/stepwise/schemas/fieldset/display-components';
8
7
 
9
8
  /**
10
9
  * A set of fields
@@ -12,15 +11,15 @@ import { FieldsetDisplay } from '@uides/stepwise/schemas/fieldset/display-compon
12
11
  * In order to show fields in the UI, they must be grouped in a fieldset. This may be done,
13
12
  * by adding the field names in the `field-order` property of the fieldset.
14
13
  */
15
- export const Fieldset = object({
16
- 'field-order': nullish(v.string()), // TODO: Not optional in backend schema but optional in some templates
17
- display: nullish(FieldsetDisplay),
14
+ export const FieldsetSchema = v.strictObject({
15
+ 'field-order': v.nullish(v.string()), // TODO: Not optional in backend schema but optional in some templates
16
+ display: v.nullish(FieldsetDisplaySchema),
18
17
  });
19
- export type Fieldset = v.Output<typeof Fieldset>;
18
+ export type Fieldset = v.InferOutput<typeof FieldsetSchema>;
20
19
  export default Fieldset;
21
20
 
22
21
  export type Fieldsets = Record<string, Fieldset>;
23
- export const FieldsetsSchema = v.record(Fieldset) as v.BaseSchema<
24
- Fieldsets,
25
- Fieldsets
26
- >;
22
+ export const FieldsetsSchema = v.record(
23
+ v.string(),
24
+ FieldsetSchema
25
+ ) as v.GenericSchema<Fieldsets, Fieldsets>;
@@ -1,9 +1,7 @@
1
1
  import * as v from 'valibot';
2
2
  import {
3
- DisplayLang,
4
- DisplayMode,
5
- nullish,
6
- object,
3
+ DisplayLangSchema,
4
+ DisplayModeSchema,
7
5
  } from '@uides/stepwise/schemas/common';
8
6
 
9
7
  /**
@@ -18,7 +16,7 @@ import {
18
16
  * @value 'nav-link' Navigation link.
19
17
  * @value 'nav-info' Navigation info.
20
18
  */
21
- export const NavActionComponent = v.picklist([
19
+ export const NavActionComponentSchema = v.picklist([
22
20
  'back-button',
23
21
  'entity-name',
24
22
  'button-link',
@@ -28,45 +26,58 @@ export const NavActionComponent = v.picklist([
28
26
  'nav-link',
29
27
  'nav-info',
30
28
  ]);
31
- export type NavActionComponent = v.Output<typeof NavActionComponent>;
29
+ export type NavActionComponent = v.InferOutput<typeof NavActionComponentSchema>;
32
30
 
33
- export const NavActionDisplay = object({
34
- label: nullish(v.string()),
35
- component: NavActionComponent,
36
- 'component-params': nullish(v.record(v.any())),
31
+ export const NavActionDisplaySchema = v.strictObject({
32
+ label: v.nullish(v.string()),
33
+ component: NavActionComponentSchema,
34
+ 'component-params': v.nullish(v.record(v.string(), v.any())),
37
35
  });
38
- export type NavActionDisplay = v.Output<typeof NavActionDisplay>;
36
+ export type NavActionDisplay = v.InferOutput<typeof NavActionDisplaySchema>;
39
37
 
40
- export const NavAction = object({
41
- display: nullish(
42
- v.record(DisplayMode, v.record(DisplayLang, NavActionDisplay))
38
+ export const NavActionSchema = v.strictObject({
39
+ display: v.nullish(
40
+ v.record(
41
+ DisplayModeSchema,
42
+ v.record(DisplayLangSchema, NavActionDisplaySchema)
43
+ )
43
44
  ),
44
45
  });
45
- export type NavAction = v.Output<typeof NavAction>;
46
+ export type NavAction = v.InferOutput<typeof NavActionSchema>;
46
47
 
47
- export const NavActionGroupParams = object({
48
- expanded: nullish(v.boolean()),
49
- 'match-paths': nullish(v.array(v.string())),
48
+ export const NavActionGroupParamsSchema = v.strictObject({
49
+ expanded: v.nullish(v.boolean()),
50
+ 'match-paths': v.nullish(v.array(v.string())),
50
51
  });
51
- export type NavActionGroupParams = v.Output<typeof NavActionGroupParams>;
52
+ export type NavActionGroupParams = v.InferOutput<
53
+ typeof NavActionGroupParamsSchema
54
+ >;
52
55
 
53
- export const NavActionGroupDisplay = object({
54
- label: nullish(v.string()),
55
- component: NavActionComponent,
56
- 'component-params': nullish(NavActionGroupParams),
56
+ export const NavActionGroupDisplaySchema = v.strictObject({
57
+ label: v.nullish(v.string()),
58
+ component: NavActionComponentSchema,
59
+ 'component-params': v.nullish(NavActionGroupParamsSchema),
57
60
  });
58
- export type NavActionGroupDisplay = v.Output<typeof NavActionGroupDisplay>;
61
+ export type NavActionGroupDisplay = v.InferOutput<
62
+ typeof NavActionGroupDisplaySchema
63
+ >;
59
64
 
60
- export const NavActionGroup = object({
61
- items: v.record(NavAction),
65
+ export const NavActionGroupSchema = v.strictObject({
66
+ items: v.record(v.string(), NavActionSchema),
62
67
  'item-order': v.string(),
63
- display: v.record(DisplayMode, v.record(DisplayLang, NavActionGroupDisplay)),
68
+ display: v.record(
69
+ DisplayModeSchema,
70
+ v.record(DisplayLangSchema, NavActionGroupDisplaySchema)
71
+ ),
64
72
  });
65
- export type NavActionGroup = v.Output<typeof NavActionGroup>;
73
+ export type NavActionGroup = v.InferOutput<typeof NavActionGroupSchema>;
66
74
 
67
- export const Layout = object({
75
+ export const LayoutSchema = v.strictObject({
68
76
  'nav-action-order': v.string(),
69
- 'nav-actions': v.record(v.union([NavAction, NavActionGroup])),
70
- 'landing-url': nullish(v.string()),
77
+ 'nav-actions': v.record(
78
+ v.string(),
79
+ v.union([NavActionSchema, NavActionGroupSchema])
80
+ ),
81
+ 'landing-url': v.nullish(v.string()),
71
82
  });
72
- export type Layout = v.Output<typeof Layout>;
83
+ export type Layout = v.InferOutput<typeof LayoutSchema>;
@@ -1,21 +1,22 @@
1
1
  import * as v from 'valibot';
2
- import { object, nullish } from '@uides/stepwise/schemas/common';
3
- import { DocumentData } from '@uides/stepwise/schemas/document';
2
+ import { DocumentDataSchema } from '@uides/stepwise/schemas/document';
4
3
 
5
4
  /**
6
5
  * As defined in outputs/entry_schema.py
7
6
  */
8
- export const Entry = object({
7
+ export const EntrySchema = v.strictObject({
9
8
  id: v.string(),
10
9
  gate_id: v.string(),
11
- document: DocumentData,
12
- 'document-refs': nullish(v.record(v.record(v.any()))),
10
+ document: DocumentDataSchema,
11
+ 'document-refs': v.nullish(
12
+ v.record(v.string(), v.record(v.string(), v.any()))
13
+ ),
13
14
  });
14
15
 
15
16
  /**
16
17
  * As defined in outputs/permission_schema.py
17
18
  */
18
- export const Permission = object({
19
+ export const PermissionSchema = v.strictObject({
19
20
  gate_display_name: v.string(),
20
21
  gate_id: v.string(),
21
22
  afm: v.string(),
@@ -11,7 +11,7 @@ import * as v from 'valibot';
11
11
  * @value `diff` Diff.
12
12
  * @value `link` Link.
13
13
  */
14
- export const ResourceFieldComponent = v.picklist([
14
+ export const ResourceFieldComponentSchema = v.picklist([
15
15
  'string',
16
16
  'boolean',
17
17
  'int',
@@ -28,7 +28,7 @@ export const ResourceFieldComponent = v.picklist([
28
28
  * @value `menu-action` Menu action.
29
29
  * @value `menu-action-show-details` Menu action showing details.
30
30
  */
31
- export const ObjectActionComponent = v.picklist([
31
+ export const ObjectActionComponentSchema = v.picklist([
32
32
  'button',
33
33
  'menu-action',
34
34
  'menu-action-show-details',
@@ -45,7 +45,7 @@ export const ObjectActionComponent = v.picklist([
45
45
  * @value `show-details` Show details.
46
46
  * @value `show-message` Show message.
47
47
  */
48
- export const ObjectActionHandler = v.picklist([
48
+ export const ObjectActionHandlerSchema = v.picklist([
49
49
  'download',
50
50
  'redirect',
51
51
  'new-tab',
@@ -62,7 +62,7 @@ export const ObjectActionHandler = v.picklist([
62
62
  * @value `auto` Auto.
63
63
  * @value `inline-form` Inline form.
64
64
  */
65
- export const ResourceActionComponent = v.picklist([
65
+ export const ResourceActionComponentSchema = v.picklist([
66
66
  'button',
67
67
  'auto',
68
68
  'inline-form',
@@ -77,7 +77,7 @@ export const ResourceActionComponent = v.picklist([
77
77
  * @value `show-message` Show message.
78
78
  * @value `show-modal` Show modal.
79
79
  */
80
- export const ResourceActionHandler = v.picklist([
80
+ export const ResourceActionHandlerSchema = v.picklist([
81
81
  'download',
82
82
  'load-data',
83
83
  'refresh-data',
@@ -91,4 +91,4 @@ export const ResourceActionHandler = v.picklist([
91
91
  * @value `node` Node.
92
92
  * @value `tree` Tree.
93
93
  */
94
- export const AccessPolicy = v.picklist(['node', 'tree']);
94
+ export const AccessPolicySchema = v.picklist(['node', 'tree']);
@@ -1,14 +1,16 @@
1
1
  import * as v from 'valibot';
2
- import { object, nullish } from '@uides/stepwise/schemas/common';
3
- import { ResourceFieldComponent } from '@uides/stepwise/schemas/resource/enums';
2
+ import { ResourceFieldComponentSchema } from '@uides/stepwise/schemas/resource/enums';
4
3
 
5
- export const ResourceFieldDisplay = object({
4
+ export const ResourceFieldDisplaySchema = v.strictObject({
6
5
  title: v.string(),
7
- component: ResourceFieldComponent,
8
- choices: nullish(v.record(v.any())),
9
- 'choices-order': nullish(v.string()),
6
+ component: ResourceFieldComponentSchema,
7
+ choices: v.nullish(v.record(v.string(), v.any())),
8
+ 'choices-order': v.nullish(v.string()),
10
9
  });
11
10
 
12
- export const ResourceField = object({
13
- display: v.record(v.record(ResourceFieldDisplay)),
11
+ export const ResourceFieldSchema = v.strictObject({
12
+ display: v.record(
13
+ v.string(),
14
+ v.record(v.string(), ResourceFieldDisplaySchema)
15
+ ),
14
16
  });
@@ -1,31 +1,36 @@
1
1
  import * as v from 'valibot';
2
- import { object, nullish } from '@uides/stepwise/schemas/common';
3
2
  import { FieldsSchema } from '@uides/stepwise/schemas/field';
4
3
  import {
5
- ObjectActionComponent,
6
- ObjectActionHandler,
4
+ ObjectActionComponentSchema,
5
+ ObjectActionHandlerSchema,
7
6
  } from '@uides/stepwise/schemas/resource/enums';
8
7
 
9
- export const ObjectActionDisplay = object({
8
+ export const ObjectActionDisplaySchema = v.strictObject({
10
9
  title: v.string(),
11
- component: ObjectActionComponent,
12
- 'component-params': v.record(v.string()),
13
- handler: nullish(ObjectActionHandler),
10
+ component: ObjectActionComponentSchema,
11
+ 'component-params': v.record(v.string(), v.string()),
12
+ handler: v.nullish(ObjectActionHandlerSchema),
14
13
  });
15
14
 
16
- export const ObjectAction = object({
17
- display: v.record(v.record(ObjectActionDisplay)),
18
- arguments: nullish(FieldsSchema),
15
+ export const ObjectActionSchema = v.strictObject({
16
+ display: v.record(
17
+ v.string(),
18
+ v.record(v.string(), ObjectActionDisplaySchema)
19
+ ),
20
+ arguments: v.nullish(FieldsSchema),
19
21
  'argument-order': v.string(),
20
- confirm: nullish(v.boolean()),
22
+ confirm: v.nullish(v.boolean()),
21
23
  });
22
24
 
23
- export const ObjectActionConfigDisplay = object({
24
- title: nullish(v.string()),
25
+ export const ObjectActionConfigDisplaySchema = v.strictObject({
26
+ title: v.nullish(v.string()),
25
27
  component: v.literal('menu'),
26
- icon: nullish(v.string()),
28
+ icon: v.nullish(v.string()),
27
29
  });
28
30
 
29
- export const ObjectActionConfig = object({
30
- display: v.record(v.record(ObjectActionConfigDisplay)),
31
+ export const ObjectActionConfigSchema = v.strictObject({
32
+ display: v.record(
33
+ v.string(),
34
+ v.record(v.string(), ObjectActionConfigDisplaySchema)
35
+ ),
31
36
  });
@@ -1,28 +1,30 @@
1
1
  import * as v from 'valibot';
2
- import { object, nullish } from '@uides/stepwise/schemas/common';
3
2
  import { FieldsSchema } from '@uides/stepwise/schemas/field';
4
3
  import {
5
- ResourceActionComponent,
6
- ResourceActionHandler,
4
+ ResourceActionComponentSchema,
5
+ ResourceActionHandlerSchema,
7
6
  } from '@uides/stepwise/schemas/resource/enums';
8
7
 
9
- export const ResourceActionPagination = object({
10
- type: nullish(v.picklist(['offset', 'index-value'])),
8
+ export const ResourceActionPaginationSchema = v.strictObject({
9
+ type: v.nullish(v.picklist(['offset', 'index-value'])),
11
10
  limit: v.array(v.number()),
12
- 'limit-default': nullish(v.number()),
13
- count: nullish(v.picklist(['on', 'off', 'estimate'])),
11
+ 'limit-default': v.nullish(v.number()),
12
+ count: v.nullish(v.picklist(['on', 'off', 'estimate'])),
14
13
  });
15
14
 
16
- export const ResourceActionDisplay = object({
17
- title: nullish(v.string()),
18
- component: ResourceActionComponent,
19
- 'component-params': nullish(v.record(v.string())),
20
- handler: ResourceActionHandler,
21
- pagination: nullish(ResourceActionPagination),
15
+ export const ResourceActionDisplaySchema = v.strictObject({
16
+ title: v.nullish(v.string()),
17
+ component: ResourceActionComponentSchema,
18
+ 'component-params': v.nullish(v.record(v.string(), v.string())),
19
+ handler: ResourceActionHandlerSchema,
20
+ pagination: v.nullish(ResourceActionPaginationSchema),
22
21
  });
23
22
 
24
- export const ResourceAction = object({
25
- display: v.record(v.record(ResourceActionDisplay)),
26
- arguments: nullish(FieldsSchema),
27
- 'argument-order': nullish(v.string()),
23
+ export const ResourceActionSchema = v.strictObject({
24
+ display: v.record(
25
+ v.string(),
26
+ v.record(v.string(), ResourceActionDisplaySchema)
27
+ ),
28
+ arguments: v.nullish(FieldsSchema),
29
+ 'argument-order': v.nullish(v.string()),
28
30
  });
@@ -1,53 +1,52 @@
1
1
  import * as v from 'valibot';
2
- import { object, nullish } from '@uides/stepwise/schemas/common';
3
- import { AccessPolicy } from '@uides/stepwise/schemas/resource/enums';
4
- import { ResourceField } from '@uides/stepwise/schemas/resource/field';
2
+ import { AccessPolicySchema } from '@uides/stepwise/schemas/resource/enums';
3
+ import { ResourceFieldSchema } from '@uides/stepwise/schemas/resource/field';
5
4
  import {
6
- ObjectAction,
7
- ObjectActionConfig,
5
+ ObjectActionSchema,
6
+ ObjectActionConfigSchema,
8
7
  } from '@uides/stepwise/schemas/resource/object-action';
9
- import { ResourceAction } from '@uides/stepwise/schemas/resource/resource-action';
8
+ import { ResourceActionSchema } from '@uides/stepwise/schemas/resource/resource-action';
10
9
 
11
- export const ResourceDisplay = object({
10
+ export const ResourceDisplaySchema = v.strictObject({
12
11
  title: v.string(),
13
12
  });
14
13
 
15
- export const ResourceInfo = object({
16
- fields: v.record(ResourceField),
14
+ export const ResourceInfoSchema = v.strictObject({
15
+ fields: v.record(v.string(), ResourceFieldSchema),
17
16
  'field-order': v.string(),
18
- 'object-actions': v.record(ObjectAction),
19
- 'object-actions-config': ObjectActionConfig,
20
- 'object-action-component': nullish(v.string()),
17
+ 'object-actions': v.record(v.string(), ObjectActionSchema),
18
+ 'object-actions-config': ObjectActionConfigSchema,
19
+ 'object-action-component': v.nullish(v.string()),
21
20
  'object-action-order': v.string(),
22
- 'resource-actions': v.record(ResourceAction),
21
+ 'resource-actions': v.record(v.string(), ResourceActionSchema),
23
22
  'resource-action-order': v.string(),
24
- 'object-id': nullish(v.string()),
25
- display: v.record(v.record(ResourceDisplay)),
23
+ 'object-id': v.nullish(v.string()),
24
+ display: v.record(v.string(), v.record(v.string(), ResourceDisplaySchema)),
26
25
  });
27
26
 
28
- export const Resource = object({
27
+ export const ResourceSchema = v.strictObject({
29
28
  /** Unique identifier of the resource */
30
29
  refname: v.string(),
31
30
  /** String, display name of resource */
32
31
  display_name: v.string(),
33
32
  entity_codename: v.string(),
34
- access_policy: AccessPolicy,
33
+ access_policy: AccessPolicySchema,
35
34
  permission_role: v.string(),
36
35
  /**
37
36
  * Namespace spec of resource
38
37
  *
39
38
  * @see {@link Template.steps_spec} for a similar concept
40
39
  */
41
- info: ResourceInfo,
40
+ info: ResourceInfoSchema,
42
41
  /**
43
42
  * Resource actions
44
43
  *
45
44
  * Optional, only if resource has actions. The key is the action name,
46
45
  * the value is the path of the corresponding handler.
47
46
  */
48
- action_handlers: nullish(v.record(v.string())),
47
+ action_handlers: v.nullish(v.record(v.string(), v.string())),
49
48
  /**
50
49
  *
51
50
  */
52
- allowed_actions_on_object: nullish(v.string()),
51
+ allowed_actions_on_object: v.nullish(v.string()),
53
52
  });