@gravity-ui/dynamic-forms 5.23.0 → 5.24.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.
Files changed (116) hide show
  1. package/build/cjs/lib/core/types/specs.d.ts +1 -1
  2. package/build/cjs/lib/kit/components/Inputs/MultiSelect/MultiSelect.js +24 -13
  3. package/build/cjs/lib/unstable/core/types/components.d.ts +3 -13
  4. package/build/cjs/lib/unstable/core/types/schema.d.ts +14 -7
  5. package/build/cjs/lib/unstable/core/useSchemaRenderer/types/state.d.ts +3 -0
  6. package/build/cjs/lib/unstable/core/utils/definers.d.ts +27 -13
  7. package/build/cjs/lib/unstable/kit/components/HTMLContent/HTMLContent.d.ts +2 -1
  8. package/build/cjs/lib/unstable/kit/components/HTMLContent/HTMLContent.js +12 -2
  9. package/build/cjs/lib/unstable/kit/components/LayoutContainer/LayoutContainer.css +3 -0
  10. package/build/cjs/lib/unstable/kit/components/LayoutContainer/LayoutContainer.d.ts +1 -0
  11. package/build/cjs/lib/unstable/kit/components/LayoutContainer/LayoutContainer.js +2 -2
  12. package/build/cjs/lib/unstable/kit/entities/Alert/Alert.css +16 -0
  13. package/build/cjs/lib/unstable/kit/entities/Alert/Alert.js +26 -7
  14. package/build/cjs/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.d.ts +0 -1
  15. package/build/cjs/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.js +4 -2
  16. package/build/cjs/lib/unstable/kit/entities/ArrayTable/ArrayTable.d.ts +0 -1
  17. package/build/cjs/lib/unstable/kit/entities/ArrayTable/ArrayTable.js +5 -3
  18. package/build/cjs/lib/unstable/kit/entities/FewOfNested/FewOfNested.css +3 -0
  19. package/build/cjs/lib/unstable/kit/entities/Label/Label.js +4 -4
  20. package/build/cjs/lib/unstable/kit/entities/Monaco/Monaco.js +3 -1
  21. package/build/cjs/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.d.ts +0 -1
  22. package/build/cjs/lib/unstable/kit/entities/ObjectInline/ObjectInline.d.ts +0 -1
  23. package/build/cjs/lib/unstable/kit/entities/OneOfNested/OneOfNested.css +3 -0
  24. package/build/cjs/lib/unstable/kit/entities/TextContent/TextContent.js +4 -4
  25. package/build/cjs/lib/unstable/kit/form-entities/CheckboxGroupInput/CheckboxGroupInput.d.ts +0 -1
  26. package/build/cjs/lib/unstable/kit/form-entities/CheckboxGroupInput/CheckboxGroupInput.js +3 -1
  27. package/build/cjs/lib/unstable/kit/form-entities/CheckboxInput/CheckboxInput.js +3 -1
  28. package/build/cjs/lib/unstable/kit/form-entities/ColorPickerInput/ColorPickerInput.js +3 -1
  29. package/build/cjs/lib/unstable/kit/form-entities/DateInput/DateInput.js +3 -2
  30. package/build/cjs/lib/unstable/kit/form-entities/FileInput/FileInput.js +3 -1
  31. package/build/cjs/lib/unstable/kit/form-entities/MultiSelectInput/MultiSelectInput.js +4 -2
  32. package/build/cjs/lib/unstable/kit/form-entities/NumberInput/NumberInput.js +3 -2
  33. package/build/cjs/lib/unstable/kit/form-entities/NumberWithScaleInput/NumberWithScaleInput.js +3 -2
  34. package/build/cjs/lib/unstable/kit/form-entities/PasswordInput/PasswordInput.js +3 -2
  35. package/build/cjs/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.js +3 -1
  36. package/build/cjs/lib/unstable/kit/form-entities/RangeSliderInput/RangeSliderInput.js +9 -8
  37. package/build/cjs/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.js +3 -1
  38. package/build/cjs/lib/unstable/kit/form-entities/SelectInput/SelectInput.js +4 -2
  39. package/build/cjs/lib/unstable/kit/form-entities/SliderInput/SliderInput.js +3 -1
  40. package/build/cjs/lib/unstable/kit/form-entities/StringInput/StringInput.js +3 -2
  41. package/build/cjs/lib/unstable/kit/form-entities/StringNumberWithScaleInput/StringNumberWithScaleInput.js +4 -3
  42. package/build/cjs/lib/unstable/kit/form-entities/SwitchInput/SwitchInput.js +3 -1
  43. package/build/cjs/lib/unstable/kit/form-entities/TextAreaInput/TextAreaInput.js +3 -2
  44. package/build/cjs/lib/unstable/kit/form-layouts/FormColumn/FormColumn.js +8 -6
  45. package/build/cjs/lib/unstable/kit/form-layouts/FormRow/FormRow.js +8 -6
  46. package/build/cjs/lib/unstable/kit/index.d.ts +1 -0
  47. package/build/cjs/lib/unstable/kit/index.js +1 -0
  48. package/build/cjs/lib/unstable/kit/layouts/Accordeon/Accordeon.js +6 -4
  49. package/build/cjs/lib/unstable/kit/layouts/Card/Card.js +8 -6
  50. package/build/cjs/lib/unstable/kit/layouts/Section/Section.js +8 -6
  51. package/build/cjs/lib/unstable/kit/layouts/Transparent/Transparent.js +5 -3
  52. package/build/cjs/lib/unstable/kit/overview-layouts/OverviewColumn/OverviewColumn.js +7 -5
  53. package/build/cjs/lib/unstable/kit/overview-layouts/OverviewRow/OverviewRow.js +7 -5
  54. package/build/cjs/lib/unstable/kit/utils/index.d.ts +1 -1
  55. package/build/cjs/lib/unstable/kit/utils/index.js +1 -7
  56. package/build/cjs/lib/unstable/kit/utils/transformer.d.ts +10 -17
  57. package/build/cjs/lib/unstable/kit/utils/transformer.js +542 -2778
  58. package/build/esm/lib/core/types/specs.d.ts +1 -1
  59. package/build/esm/lib/kit/components/Inputs/MultiSelect/MultiSelect.js +24 -13
  60. package/build/esm/lib/unstable/core/types/components.d.ts +3 -13
  61. package/build/esm/lib/unstable/core/types/schema.d.ts +14 -7
  62. package/build/esm/lib/unstable/core/useSchemaRenderer/types/state.d.ts +3 -0
  63. package/build/esm/lib/unstable/core/utils/definers.d.ts +27 -13
  64. package/build/esm/lib/unstable/kit/components/HTMLContent/HTMLContent.d.ts +2 -1
  65. package/build/esm/lib/unstable/kit/components/HTMLContent/HTMLContent.js +12 -2
  66. package/build/esm/lib/unstable/kit/components/LayoutContainer/LayoutContainer.css +3 -0
  67. package/build/esm/lib/unstable/kit/components/LayoutContainer/LayoutContainer.d.ts +1 -0
  68. package/build/esm/lib/unstable/kit/components/LayoutContainer/LayoutContainer.js +2 -2
  69. package/build/esm/lib/unstable/kit/entities/Alert/Alert.css +16 -0
  70. package/build/esm/lib/unstable/kit/entities/Alert/Alert.d.ts +1 -0
  71. package/build/esm/lib/unstable/kit/entities/Alert/Alert.js +29 -9
  72. package/build/esm/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.d.ts +0 -1
  73. package/build/esm/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.js +4 -2
  74. package/build/esm/lib/unstable/kit/entities/ArrayTable/ArrayTable.d.ts +0 -1
  75. package/build/esm/lib/unstable/kit/entities/ArrayTable/ArrayTable.js +5 -3
  76. package/build/esm/lib/unstable/kit/entities/FewOfNested/FewOfNested.css +3 -0
  77. package/build/esm/lib/unstable/kit/entities/Label/Label.js +5 -5
  78. package/build/esm/lib/unstable/kit/entities/Monaco/Monaco.js +3 -1
  79. package/build/esm/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.d.ts +0 -1
  80. package/build/esm/lib/unstable/kit/entities/ObjectInline/ObjectInline.d.ts +0 -1
  81. package/build/esm/lib/unstable/kit/entities/OneOfNested/OneOfNested.css +3 -0
  82. package/build/esm/lib/unstable/kit/entities/TextContent/TextContent.js +5 -5
  83. package/build/esm/lib/unstable/kit/form-entities/CheckboxGroupInput/CheckboxGroupInput.d.ts +0 -1
  84. package/build/esm/lib/unstable/kit/form-entities/CheckboxGroupInput/CheckboxGroupInput.js +3 -1
  85. package/build/esm/lib/unstable/kit/form-entities/CheckboxInput/CheckboxInput.js +3 -1
  86. package/build/esm/lib/unstable/kit/form-entities/ColorPickerInput/ColorPickerInput.js +3 -1
  87. package/build/esm/lib/unstable/kit/form-entities/DateInput/DateInput.js +3 -2
  88. package/build/esm/lib/unstable/kit/form-entities/FileInput/FileInput.js +3 -1
  89. package/build/esm/lib/unstable/kit/form-entities/MultiSelectInput/MultiSelectInput.js +4 -2
  90. package/build/esm/lib/unstable/kit/form-entities/NumberInput/NumberInput.js +3 -2
  91. package/build/esm/lib/unstable/kit/form-entities/NumberWithScaleInput/NumberWithScaleInput.js +3 -2
  92. package/build/esm/lib/unstable/kit/form-entities/PasswordInput/PasswordInput.js +3 -2
  93. package/build/esm/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.js +3 -1
  94. package/build/esm/lib/unstable/kit/form-entities/RangeSliderInput/RangeSliderInput.js +9 -8
  95. package/build/esm/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.js +3 -1
  96. package/build/esm/lib/unstable/kit/form-entities/SelectInput/SelectInput.js +4 -2
  97. package/build/esm/lib/unstable/kit/form-entities/SliderInput/SliderInput.js +3 -1
  98. package/build/esm/lib/unstable/kit/form-entities/StringInput/StringInput.js +3 -2
  99. package/build/esm/lib/unstable/kit/form-entities/StringNumberWithScaleInput/StringNumberWithScaleInput.js +4 -3
  100. package/build/esm/lib/unstable/kit/form-entities/SwitchInput/SwitchInput.js +3 -1
  101. package/build/esm/lib/unstable/kit/form-entities/TextAreaInput/TextAreaInput.js +3 -2
  102. package/build/esm/lib/unstable/kit/form-layouts/FormColumn/FormColumn.js +8 -6
  103. package/build/esm/lib/unstable/kit/form-layouts/FormRow/FormRow.js +8 -6
  104. package/build/esm/lib/unstable/kit/index.d.ts +1 -0
  105. package/build/esm/lib/unstable/kit/index.js +1 -0
  106. package/build/esm/lib/unstable/kit/layouts/Accordeon/Accordeon.js +6 -4
  107. package/build/esm/lib/unstable/kit/layouts/Card/Card.js +8 -6
  108. package/build/esm/lib/unstable/kit/layouts/Section/Section.js +8 -6
  109. package/build/esm/lib/unstable/kit/layouts/Transparent/Transparent.js +5 -3
  110. package/build/esm/lib/unstable/kit/overview-layouts/OverviewColumn/OverviewColumn.js +7 -5
  111. package/build/esm/lib/unstable/kit/overview-layouts/OverviewRow/OverviewRow.js +7 -5
  112. package/build/esm/lib/unstable/kit/utils/index.d.ts +1 -1
  113. package/build/esm/lib/unstable/kit/utils/index.js +1 -1
  114. package/build/esm/lib/unstable/kit/utils/transformer.d.ts +10 -17
  115. package/build/esm/lib/unstable/kit/utils/transformer.js +543 -2778
  116. package/package.json +1 -1
@@ -1,231 +1,95 @@
1
1
  "use strict";
2
- /* eslint-disable complexity */
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.stringInputTypeRules = exports.objectInputTypeRules = exports.numberInputTypeRules = exports.booleanInputTypeRules = exports.arrayInputTypeRules = exports.layoutRules = void 0;
5
3
  exports.specToJsonSchema = specToJsonSchema;
6
4
  const tslib_1 = require("tslib");
7
5
  const get_1 = tslib_1.__importDefault(require("lodash/get"));
6
+ const isObject_1 = tslib_1.__importDefault(require("lodash/isObject"));
8
7
  const set_1 = tslib_1.__importDefault(require("lodash/set"));
9
8
  const core_1 = require("../../../core");
10
9
  const core_2 = require("../../core");
11
- exports.layoutRules = {
12
- row: (_spec, mutableSchema) => {
13
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'row');
14
- },
15
- row_verbose: (_spec, mutableSchema) => {
16
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'row');
17
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.descriptionType', 'bottom');
18
- },
19
- column: (_spec, mutableSchema) => {
20
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'column');
21
- },
22
- accordeon: (_spec, mutableSchema) => {
23
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'accordeon');
24
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.togglerProps.view', 'clear');
25
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.withIndent', true);
26
- },
27
- section: (_spec, mutableSchema) => {
28
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'section');
29
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.variant', 'subheader-2');
30
- },
31
- section2: (_spec, mutableSchema) => {
32
- // the new section title default (subheader-1) matches the old section2 title size
33
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'section');
34
- },
35
- group: (_spec, mutableSchema) => {
36
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'section');
37
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.variant', 'subheader-2');
38
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.withIndent', true);
39
- },
40
- group2: (_spec, mutableSchema) => {
41
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'section');
42
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.withIndent', true);
43
- },
44
- table_item: (_spec, mutableSchema) => {
45
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'cell');
46
- },
47
- transparent: (_spec, mutableSchema) => {
48
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
49
- },
50
- card_accordeon: (_spec, mutableSchema) => {
51
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'card');
52
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.likeAccordeon', true);
53
- },
54
- card_section: (_spec, mutableSchema) => {
55
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'card');
56
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.likeAccordeon', false);
57
- },
58
- accordeon_card: (_spec, mutableSchema) => {
59
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'card');
60
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.likeAccordeon', true);
61
- },
62
- };
63
- exports.arrayInputTypeRules = {
64
- select: (spec, mutableSchema, ctx) => {
65
- var _a;
66
- if (spec.defaultValue) {
67
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
68
- }
69
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Array);
70
- if (spec.required) {
71
- (0, set_1.default)(mutableSchema, 'allOf', [
72
- ...(mutableSchema.allOf || []),
73
- { not: { enum: [null, undefined, '', false] } },
74
- ]);
75
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
76
- }
77
- if (spec.maxLength) {
78
- const maxItems = Number(spec.maxLength);
79
- if (!isNaN(maxItems)) {
80
- (0, set_1.default)(mutableSchema, 'maxItems', maxItems);
81
- }
82
- }
83
- if (spec.minLength) {
84
- const minItems = Number(spec.minLength);
85
- if (!isNaN(minItems)) {
86
- (0, set_1.default)(mutableSchema, 'minItems', minItems);
87
- }
88
- }
89
- if (spec.enum) {
90
- (0, set_1.default)(mutableSchema, 'items.enum', spec.enum);
91
- }
92
- // items for old select not expected
93
- // if (spec.items) {}
94
- if (spec.description) {
95
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.enumDescriptions', spec.description);
96
- }
97
- if (spec.validator && spec.validator !== 'base') {
98
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
99
- }
10
+ const viewSpecRules = {
11
+ disabled: (spec, mutableSchema) => {
100
12
  if (spec.viewSpec.disabled) {
101
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
102
- }
103
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Array);
104
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'select');
105
- if (spec.viewSpec.layout) {
106
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
107
- if (layoutRule) {
108
- layoutRule(spec, mutableSchema, ctx);
109
- }
110
- else if (process.env.NODE_ENV !== 'production') {
111
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
112
- }
113
- }
114
- if (spec.viewSpec.layoutTitle) {
115
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
13
+ (0, set_1.default)(mutableSchema, 'nodeParameters.flags.disabled', true);
116
14
  }
117
- if (spec.viewSpec.layoutDescription) {
118
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
15
+ },
16
+ layout: (spec, mutableSchema) => {
17
+ const layout = spec.viewSpec.layout;
18
+ if (!layout) {
19
+ return;
119
20
  }
120
- if (spec.viewSpec.layoutOpen !== undefined) {
121
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
122
- }
123
- // itemLabel for old select not expected
124
- // if (spec.viewSpec.itemLabel) {}
125
- // itemPrefix for old select not expected
126
- // if (spec.viewSpec.itemPrefix) {}
127
- // table for old select not expected
128
- // if (spec.viewSpec.table) {}
129
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
130
- console.warn(`[dynamic-forms] Unknown array select view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
131
- }
132
- if (spec.viewSpec.placeholder) {
133
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
134
- }
135
- // addButtonPosition for old select not expected
136
- // if (spec.viewSpec.addButtonPosition) {}
137
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
138
- console.warn(`[dynamic-forms] Unknown array select view spec key: "hidden"`);
139
- }
140
- if (spec.viewSpec.selectParams) {
141
- if (spec.viewSpec.selectParams.filterPlaceholder) {
142
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.filterPlaceholder', spec.viewSpec.selectParams.filterPlaceholder);
143
- }
144
- if (spec.viewSpec.selectParams.meta) {
145
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.optionsMeta', spec.viewSpec.selectParams.meta);
146
- }
21
+ if (layout === 'row_verbose') {
22
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'row');
23
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.descriptionType', 'bottom');
147
24
  }
148
- if (spec.viewSpec.inputProps) {
149
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
150
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
151
- });
25
+ else if (layout === 'accordeon') {
26
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'accordeon');
27
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.togglerProps.view', 'clear');
28
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.withIndent', true);
152
29
  }
153
- if (spec.viewSpec.layoutProps) {
154
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
155
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
156
- });
30
+ else if (layout === 'section') {
31
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'section');
32
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.variant', 'subheader-2');
157
33
  }
158
- // checkboxGroupParams for old select not expected
159
- // if (spec.viewSpec.checkboxGroupParams) {}
160
- },
161
- table: (spec, mutableSchema, ctx) => {
162
- var _a;
163
- if (spec.defaultValue) {
164
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
34
+ else if (layout === 'section2') {
35
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'section');
165
36
  }
166
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Array);
167
- if (spec.required) {
168
- (0, set_1.default)(mutableSchema, 'allOf', [
169
- ...(mutableSchema.allOf || []),
170
- { not: { enum: [null, undefined, '', false] } },
171
- ]);
172
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
37
+ else if (layout === 'group') {
38
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'section');
39
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.variant', 'subheader-2');
40
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.withIndent', true);
173
41
  }
174
- if (spec.maxLength) {
175
- const maxItems = Number(spec.maxLength);
176
- if (!isNaN(maxItems)) {
177
- (0, set_1.default)(mutableSchema, 'maxItems', maxItems);
178
- }
42
+ else if (layout === 'group2') {
43
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'section');
44
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.withIndent', true);
179
45
  }
180
- if (spec.minLength) {
181
- const minItems = Number(spec.minLength);
182
- if (!isNaN(minItems)) {
183
- (0, set_1.default)(mutableSchema, 'minItems', minItems);
184
- }
46
+ else if (layout === 'table_item') {
47
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'cell');
185
48
  }
186
- // enum for old table not expected
187
- // if (spec.enum) {}
188
- if (spec.items && (0, core_1.isObjectSpec)(spec.items)) {
189
- Object.entries(spec.items.properties || {}).forEach(([key, value]) => {
190
- (0, set_1.default)(mutableSchema, ['items', 'properties', key], specToJsonSchema(value, (0, get_1.default)(mutableSchema, ['items', 'properties', key])));
191
- });
49
+ else if (layout === 'card_accordeon' || layout === 'accordeon_card') {
50
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'card');
51
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.likeAccordeon', true);
192
52
  }
193
- // description for old table not expected
194
- // if (spec.description) {}
195
- if (spec.validator && spec.validator !== 'base') {
196
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
53
+ else if (layout === 'card_section') {
54
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'card');
55
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.likeAccordeon', false);
197
56
  }
198
- if (spec.viewSpec.disabled) {
199
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
200
- }
201
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Array);
202
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'table');
203
- if (spec.viewSpec.layout) {
204
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
205
- if (layoutRule) {
206
- layoutRule(spec, mutableSchema, ctx);
207
- }
208
- else if (process.env.NODE_ENV !== 'production') {
209
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
210
- }
57
+ else {
58
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', layout);
211
59
  }
60
+ },
61
+ layoutTitle: (spec, mutableSchema) => {
212
62
  if (spec.viewSpec.layoutTitle) {
213
63
  (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
214
64
  }
65
+ },
66
+ layoutDescription: (spec, mutableSchema) => {
215
67
  if (spec.viewSpec.layoutDescription) {
216
68
  (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
217
69
  }
70
+ },
71
+ layoutOpen: (spec, mutableSchema) => {
218
72
  if (spec.viewSpec.layoutOpen !== undefined) {
219
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
73
+ (0, set_1.default)(mutableSchema, 'nodeParameters.flags.open', spec.viewSpec.layoutOpen);
220
74
  }
221
- if (spec.viewSpec.itemLabel) {
75
+ },
76
+ itemLabel: (spec, mutableSchema) => {
77
+ if ('itemLabel' in spec.viewSpec && spec.viewSpec.itemLabel) {
222
78
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.addButtonText', spec.viewSpec.itemLabel);
223
79
  }
224
- // itemPrefix for old table not expected
225
- // if (spec.viewSpec.itemPrefix) {}
226
- if (spec.viewSpec.table) {
80
+ },
81
+ itemPrefix: (spec, mutableSchema) => {
82
+ if ('itemPrefix' in spec.viewSpec && spec.viewSpec.itemPrefix) {
83
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.itemPrefix', spec.viewSpec.itemPrefix);
84
+ }
85
+ },
86
+ table: (spec, mutableSchema) => {
87
+ var _a;
88
+ if (spec.type === core_1.SpecTypes.Array &&
89
+ spec.viewSpec.table &&
90
+ ((_a = spec.items) === null || _a === void 0 ? void 0 : _a.type) === core_1.SpecTypes.Object) {
227
91
  const order = [];
228
- spec.viewSpec.table.forEach(({ description, label, property, width }) => {
92
+ spec.viewSpec.table.forEach(({ description, label, property }) => {
229
93
  order.push(property);
230
94
  if (label) {
231
95
  (0, set_1.default)(mutableSchema, ['items', 'properties', property, 'title'], label);
@@ -233,2240 +97,77 @@ exports.arrayInputTypeRules = {
233
97
  if (description) {
234
98
  (0, set_1.default)(mutableSchema, ['items', 'properties', property, 'description'], description);
235
99
  }
236
- if (width !== undefined && process.env.NODE_ENV !== 'production') {
237
- console.warn(`[dynamic-forms] Unknown array table view spec key: "table[].width", value - ${width}`);
238
- }
239
100
  });
240
101
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.order', order);
241
102
  }
242
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
243
- console.warn(`[dynamic-forms] Unknown array table view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
244
- }
245
- // placeholder for old table not expected
246
- // if (spec.viewSpec.placeholder) {}
247
- if (spec.viewSpec.addButtonPosition && process.env.NODE_ENV !== 'production') {
248
- console.warn(`[dynamic-forms] Unknown array table view spec key: "addButtonPosition", value - ${spec.viewSpec.addButtonPosition}`);
249
- }
250
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
251
- console.warn(`[dynamic-forms] Unknown array table view spec key: "hidden"`);
252
- }
253
- // selectParams for old table not expected
254
- // if (spec.viewSpec.selectParams) {}
255
- if (spec.viewSpec.inputProps) {
256
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
257
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
258
- });
259
- }
260
- if (spec.viewSpec.layoutProps) {
261
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
262
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
263
- });
264
- }
265
- // checkboxGroupParams for old table not expected
266
- // if (spec.viewSpec.checkboxGroupParams) {}
267
- },
268
- base: (spec, mutableSchema, ctx) => {
269
- var _a;
270
- if (spec.defaultValue) {
271
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
272
- }
273
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Array);
274
- if (spec.required) {
275
- (0, set_1.default)(mutableSchema, 'allOf', [
276
- ...(mutableSchema.allOf || []),
277
- { not: { enum: [null, undefined, '', false] } },
278
- ]);
279
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
280
- }
281
- if (spec.maxLength) {
282
- const maxItems = Number(spec.maxLength);
283
- if (!isNaN(maxItems)) {
284
- (0, set_1.default)(mutableSchema, 'maxItems', maxItems);
285
- }
286
- }
287
- if (spec.minLength) {
288
- const minItems = Number(spec.minLength);
289
- if (!isNaN(minItems)) {
290
- (0, set_1.default)(mutableSchema, 'minItems', minItems);
291
- }
292
- }
293
- // enum for old base not expected
294
- // if (spec.enum) {}
295
- if (spec.items) {
296
- (0, set_1.default)(mutableSchema, 'items', specToJsonSchema(spec.items, (0, get_1.default)(mutableSchema, 'items')));
297
- }
298
- // description for old base not expected
299
- // if (spec.description) {}
300
- if (spec.validator && spec.validator !== 'base') {
301
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
302
- }
303
- if (spec.viewSpec.disabled) {
304
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
305
- }
306
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Array);
307
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'base');
308
- if (spec.viewSpec.layout) {
309
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
310
- if (layoutRule) {
311
- layoutRule(spec, mutableSchema, ctx);
312
- }
313
- else if (process.env.NODE_ENV !== 'production') {
314
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
315
- }
316
- }
317
- if (spec.viewSpec.layoutTitle) {
318
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
319
- }
320
- if (spec.viewSpec.layoutDescription) {
321
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
322
- }
323
- if (spec.viewSpec.layoutOpen !== undefined) {
324
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
325
- }
326
- if (spec.viewSpec.itemLabel) {
327
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.addButtonText', spec.viewSpec.itemLabel);
328
- }
329
- if (spec.viewSpec.itemPrefix && process.env.NODE_ENV !== 'production') {
330
- console.warn(`[dynamic-forms] Unknown array base view spec key: "itemPrefix", value - ${spec.viewSpec.itemPrefix}`);
331
- }
332
- // table for old base not expected
333
- // if (spec.viewSpec.table) {}
334
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
335
- console.warn(`[dynamic-forms] Unknown array base view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
336
- }
337
- // placeholder for old base not expected
338
- // if (spec.viewSpec.placeholder) {}
339
- if (spec.viewSpec.addButtonPosition && process.env.NODE_ENV !== 'production') {
340
- console.warn(`[dynamic-forms] Unknown array base view spec key: "addButtonPosition", value - ${spec.viewSpec.addButtonPosition}`);
341
- }
342
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
343
- console.warn(`[dynamic-forms] Unknown array base view spec key: "hidden"`);
344
- }
345
- // selectParams for old base not expected
346
- // if (spec.viewSpec.selectParams) {}
347
- if (spec.viewSpec.inputProps) {
348
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
349
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
350
- });
351
- }
352
- if (spec.viewSpec.layoutProps) {
353
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
354
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
355
- });
356
- }
357
- // checkboxGroupParams for old base not expected
358
- // if (spec.viewSpec.checkboxGroupParams) {}
359
- },
360
- checkbox_group: (spec, mutableSchema, ctx) => {
361
- var _a;
362
- if (spec.defaultValue) {
363
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
364
- }
365
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Array);
366
- if (spec.required) {
367
- (0, set_1.default)(mutableSchema, 'allOf', [
368
- ...(mutableSchema.allOf || []),
369
- { not: { enum: [null, undefined, '', false] } },
370
- ]);
371
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
372
- }
373
- if (spec.maxLength) {
374
- const maxItems = Number(spec.maxLength);
375
- if (!isNaN(maxItems)) {
376
- (0, set_1.default)(mutableSchema, 'maxItems', maxItems);
377
- }
378
- }
379
- if (spec.minLength) {
380
- const minItems = Number(spec.minLength);
381
- if (!isNaN(minItems)) {
382
- (0, set_1.default)(mutableSchema, 'minItems', minItems);
383
- }
384
- }
385
- if (spec.enum) {
386
- (0, set_1.default)(mutableSchema, 'items.enum', spec.enum);
387
- }
388
- // items for old checkbox_group not expected
389
- // if (spec.items) {}
390
- if (spec.description) {
391
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.enumDescriptions', spec.description);
392
- }
393
- if (spec.validator && spec.validator !== 'base') {
394
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
395
- }
396
- if (spec.viewSpec.disabled) {
397
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
398
- }
399
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Array);
400
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'checkbox_group');
401
- if (spec.viewSpec.layout) {
402
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
403
- if (layoutRule) {
404
- layoutRule(spec, mutableSchema, ctx);
405
- }
406
- else if (process.env.NODE_ENV !== 'production') {
407
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
408
- }
409
- }
410
- if (spec.viewSpec.layoutTitle) {
411
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
412
- }
413
- if (spec.viewSpec.layoutDescription) {
414
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
415
- }
416
- if (spec.viewSpec.layoutOpen !== undefined) {
417
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
418
- }
419
- // itemLabel for old checkbox_group not expected
420
- // if (spec.viewSpec.itemLabel) {}
421
- // itemPrefix for old checkbox_group not expected
422
- // if (spec.viewSpec.itemPrefix) {}
423
- // table for old checkbox_group not expected
424
- // if (spec.viewSpec.table) {}
425
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
426
- console.warn(`[dynamic-forms] Unknown array checkbox_group view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
427
- }
428
- // placeholder for old checkbox_group not expected
429
- // if (spec.viewSpec.placeholder) {}
430
- // addButtonPosition for old checkbox_group not expected
431
- // if (spec.viewSpec.addButtonPosition) {}
432
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
433
- console.warn(`[dynamic-forms] Unknown array checkbox_group view spec key: "hidden"`);
434
- }
435
- // selectParams for old checkbox_group not expected
436
- // if (spec.viewSpec.selectParams) {}
437
- if (spec.viewSpec.inputProps) {
438
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
439
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
440
- });
441
- }
442
- if (spec.viewSpec.layoutProps) {
443
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
444
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
445
- });
446
- }
447
- if (spec.viewSpec.checkboxGroupParams) {
448
- if (spec.viewSpec.checkboxGroupParams.placement) {
449
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.direction', spec.viewSpec.checkboxGroupParams.placement === 'vertical' ? 'column' : 'row');
450
- }
451
- if (spec.viewSpec.checkboxGroupParams.disabled) {
452
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.optionsDisabled', spec.viewSpec.checkboxGroupParams.disabled);
453
- }
454
- }
455
- },
456
- };
457
- exports.booleanInputTypeRules = {
458
- base: (spec, mutableSchema, ctx) => {
459
- var _a;
460
- if (spec.defaultValue !== undefined) {
461
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
462
- }
463
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Boolean);
464
- if (spec.required) {
465
- (0, set_1.default)(mutableSchema, 'allOf', [
466
- ...(mutableSchema.allOf || []),
467
- { not: { enum: [null, undefined, '', false] } },
468
- ]);
469
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
470
- }
471
- if (spec.validator && spec.validator !== 'base') {
472
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
473
- }
474
- if (spec.viewSpec.disabled) {
475
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
476
- }
477
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Boolean);
478
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'base');
479
- if (spec.viewSpec.layout) {
480
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
481
- if (layoutRule) {
482
- layoutRule(spec, mutableSchema, ctx);
483
- }
484
- else if (process.env.NODE_ENV !== 'production') {
485
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
486
- }
487
- }
488
- if (spec.viewSpec.layoutTitle) {
489
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
490
- }
491
- if (spec.viewSpec.layoutDescription) {
492
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
493
- }
494
- if (spec.viewSpec.layoutOpen !== undefined) {
495
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
496
- }
497
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
498
- console.warn(`[dynamic-forms] Unknown boolean base view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
499
- }
500
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
501
- console.warn(`[dynamic-forms] Unknown boolean base view spec key: "hidden"`);
502
- }
503
- if (spec.viewSpec.inputProps) {
504
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
505
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
506
- });
507
- }
508
- if (spec.viewSpec.layoutProps) {
509
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
510
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
511
- });
512
- }
513
- if (spec.viewSpec.viewColor) {
514
- (0, set_1.default)(mutableSchema, 'nodeParameters.overviewEntityProps.viewColor', spec.viewSpec.viewColor);
515
- }
516
103
  },
517
- switch: (spec, mutableSchema, ctx) => {
518
- var _a;
519
- if (spec.defaultValue !== undefined) {
520
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
521
- }
522
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Boolean);
523
- if (spec.required) {
524
- (0, set_1.default)(mutableSchema, 'allOf', [
525
- ...(mutableSchema.allOf || []),
526
- { not: { enum: [null, undefined, '', false] } },
527
- ]);
528
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
529
- }
530
- if (spec.validator && spec.validator !== 'base') {
531
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
532
- }
533
- if (spec.viewSpec.disabled) {
534
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
535
- }
536
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Boolean);
537
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'switch');
538
- if (spec.viewSpec.layout) {
539
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
540
- if (layoutRule) {
541
- layoutRule(spec, mutableSchema, ctx);
542
- }
543
- else if (process.env.NODE_ENV !== 'production') {
544
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
545
- }
546
- }
547
- if (spec.viewSpec.layoutTitle) {
548
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
549
- }
550
- if (spec.viewSpec.layoutDescription) {
551
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
552
- }
553
- if (spec.viewSpec.layoutOpen !== undefined) {
554
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
555
- }
556
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
557
- console.warn(`[dynamic-forms] Unknown boolean switch view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
558
- }
559
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
560
- console.warn(`[dynamic-forms] Unknown boolean switch view spec key: "hidden"`);
561
- }
562
- if (spec.viewSpec.inputProps) {
563
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
564
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
565
- });
566
- }
567
- if (spec.viewSpec.layoutProps) {
568
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
569
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
570
- });
571
- }
572
- if (spec.viewSpec.viewColor) {
573
- (0, set_1.default)(mutableSchema, 'nodeParameters.overviewEntityProps.viewColor', spec.viewSpec.viewColor);
574
- }
575
- },
576
- };
577
- exports.numberInputTypeRules = {
578
- base: (spec, mutableSchema, ctx) => {
579
- var _a;
580
- if (spec.defaultValue !== undefined) {
581
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
582
- }
583
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Number);
584
- if (spec.required) {
585
- (0, set_1.default)(mutableSchema, 'allOf', [
586
- ...(mutableSchema.allOf || []),
587
- { not: { enum: [null, undefined, '', false] } },
588
- ]);
589
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
590
- }
591
- if (spec.maximum !== undefined) {
592
- const maximum = Number(spec.maximum);
593
- if (!isNaN(maximum)) {
594
- (0, set_1.default)(mutableSchema, 'maximum', maximum);
595
- }
596
- }
597
- if (spec.minimum !== undefined) {
598
- const minimum = Number(spec.minimum);
599
- if (!isNaN(minimum)) {
600
- (0, set_1.default)(mutableSchema, 'minimum', minimum);
601
- }
602
- }
603
- if (spec.format === 'int64') {
604
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Integer);
605
- }
606
- if (spec.validator && spec.validator !== 'base') {
607
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
608
- }
609
- if (spec.viewSpec.disabled) {
610
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
611
- }
612
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Number);
613
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'base');
614
- if (spec.viewSpec.layout) {
615
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
616
- if (layoutRule) {
617
- layoutRule(spec, mutableSchema, ctx);
618
- }
619
- else if (process.env.NODE_ENV !== 'production') {
620
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
621
- }
622
- }
623
- if (spec.viewSpec.layoutTitle) {
624
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
625
- }
626
- if (spec.viewSpec.layoutDescription) {
627
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
628
- }
629
- if (spec.viewSpec.layoutOpen !== undefined) {
630
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
631
- }
632
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
633
- console.warn(`[dynamic-forms] Unknown number base view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
634
- }
635
- if (spec.viewSpec.placeholder) {
636
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
637
- }
638
- if (spec.viewSpec.copy) {
639
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
640
- }
641
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
642
- console.warn(`[dynamic-forms] Unknown number base view spec key: "hidden"`);
643
- }
644
- if (spec.viewSpec.inputProps) {
645
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
646
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
647
- });
648
- }
649
- if (spec.viewSpec.layoutProps) {
650
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
651
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
652
- });
653
- }
654
- },
655
- range_input_picker: (spec, mutableSchema, ctx) => {
656
- var _a;
657
- if (spec.defaultValue !== undefined) {
658
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
659
- }
660
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Number);
661
- if (spec.required) {
662
- (0, set_1.default)(mutableSchema, 'allOf', [
663
- ...(mutableSchema.allOf || []),
664
- { not: { enum: [null, undefined, '', false] } },
665
- ]);
666
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
667
- }
668
- if (spec.maximum !== undefined) {
669
- const maximum = Number(spec.maximum);
670
- if (!isNaN(maximum)) {
671
- (0, set_1.default)(mutableSchema, 'maximum', maximum);
672
- }
673
- }
674
- if (spec.minimum !== undefined) {
675
- const minimum = Number(spec.minimum);
676
- if (!isNaN(minimum)) {
677
- (0, set_1.default)(mutableSchema, 'minimum', minimum);
678
- }
679
- }
680
- if (spec.format === 'int64') {
681
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Integer);
682
- }
683
- if (spec.validator && spec.validator !== 'base') {
684
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
685
- }
686
- if (spec.viewSpec.disabled) {
687
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
688
- }
689
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Number);
690
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'slider');
691
- if (spec.viewSpec.layout) {
692
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
693
- if (layoutRule) {
694
- layoutRule(spec, mutableSchema, ctx);
695
- }
696
- else if (process.env.NODE_ENV !== 'production') {
697
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
698
- }
699
- }
700
- if (spec.viewSpec.layoutTitle) {
701
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
702
- }
703
- if (spec.viewSpec.layoutDescription) {
704
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
705
- }
706
- if (spec.viewSpec.layoutOpen !== undefined) {
707
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
708
- }
709
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
710
- console.warn(`[dynamic-forms] Unknown number range_input_picker view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
711
- }
712
- if (spec.viewSpec.placeholder && process.env.NODE_ENV !== 'production') {
713
- console.warn(`[dynamic-forms] Unknown number range_input_picker view spec key: "placeholder", value - ${spec.viewSpec.placeholder}`);
714
- }
715
- if (spec.viewSpec.copy) {
716
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
717
- }
718
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
719
- console.warn(`[dynamic-forms] Unknown number range_input_picker view spec key: "hidden"`);
720
- }
721
- if (spec.viewSpec.inputProps) {
722
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
723
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
724
- });
725
- }
726
- if (spec.viewSpec.layoutProps) {
727
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
728
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
729
- });
730
- }
731
- },
732
- };
733
- exports.objectInputTypeRules = {
734
- oneof: (spec, mutableSchema) => {
735
- var _a, _b, _c, _d, _e;
736
- const booleanToggler = ((_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler) === 'checkbox' ||
737
- ((_b = spec.viewSpec.oneOfParams) === null || _b === void 0 ? void 0 : _b.toggler) === 'switch';
738
- if (spec.defaultValue !== undefined) {
739
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
740
- }
741
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
742
- if (spec.required) {
743
- (0, set_1.default)(mutableSchema, 'allOf', [
744
- ...(mutableSchema.allOf || []),
745
- { not: { enum: [null, undefined, '', false] } },
746
- ]);
747
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
748
- }
749
- if (spec.properties) {
750
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
751
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
752
- if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
753
- (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
754
- }
755
- });
756
- if (!booleanToggler) {
757
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', Object.keys(spec.properties));
758
- }
759
- }
760
- if (spec.description) {
761
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
762
- }
763
- else {
764
- const enumDescriptions = Object.fromEntries(Object.entries(spec.properties || {}).map(([key, value]) => [
765
- key,
766
- value.viewSpec.layoutTitle || key,
767
- ]));
768
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', enumDescriptions);
769
- }
770
- if (spec.validator && spec.validator !== 'base') {
771
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
772
- }
773
- if (spec.viewSpec.disabled) {
774
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
775
- }
776
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
777
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
778
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.withIndent', true);
779
- if (booleanToggler) {
780
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Boolean);
781
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Boolean);
782
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', ((_c = spec.viewSpec.oneOfParams) === null || _c === void 0 ? void 0 : _c.toggler) === 'switch' ? 'switch' : 'base');
783
- }
784
- else {
785
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.String);
786
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.String);
787
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', ((_d = spec.viewSpec.oneOfParams) === null || _d === void 0 ? void 0 : _d.toggler) === 'radio'
788
- ? 'radio_group'
789
- : 'segmented_radio_group');
790
- }
791
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
792
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
793
- if (spec.viewSpec.layoutTitle) {
794
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
795
- }
796
- if (spec.viewSpec.layoutDescription) {
797
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
798
- }
799
- if (spec.viewSpec.layoutOpen !== undefined) {
800
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
801
- }
802
- if (spec.viewSpec.order && !booleanToggler) {
803
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', spec.viewSpec.order);
804
- }
805
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
806
- console.warn(`[dynamic-forms] Unknown object oneof view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
807
- }
808
- if ((_e = spec.viewSpec.oneOfParams) === null || _e === void 0 ? void 0 : _e.booleanMap) {
809
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.booleanToKey', spec.viewSpec.oneOfParams.booleanMap);
810
- }
811
- if (spec.viewSpec.placeholder) {
812
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
813
- }
814
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
815
- console.warn(`[dynamic-forms] Unknown object oneof view spec key: "hidden"`);
816
- }
817
- if (spec.viewSpec.inputProps) {
818
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
819
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
820
- });
821
- }
822
- if (spec.viewSpec.layoutProps) {
823
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
824
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
825
- });
826
- }
827
- // delimiter for old oneof not expected
828
- // if (spec.viewSpec.delimiter) {}
829
- },
830
- oneof_flat: (spec, mutableSchema) => {
831
- var _a, _b, _c, _d, _e;
832
- const booleanToggler = ((_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler) === 'checkbox' ||
833
- ((_b = spec.viewSpec.oneOfParams) === null || _b === void 0 ? void 0 : _b.toggler) === 'switch';
834
- if (spec.defaultValue !== undefined) {
835
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
836
- }
837
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
838
- if (spec.required) {
839
- (0, set_1.default)(mutableSchema, 'allOf', [
840
- ...(mutableSchema.allOf || []),
841
- { not: { enum: [null, undefined, '', false] } },
842
- ]);
843
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
844
- }
845
- if (spec.properties) {
846
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
847
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
848
- if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
849
- (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
850
- }
851
- });
852
- if (!booleanToggler) {
853
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', Object.keys(spec.properties));
854
- }
855
- }
856
- if (spec.description) {
857
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
858
- }
859
- if (spec.validator && spec.validator !== 'base') {
860
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
861
- }
862
- if (spec.viewSpec.disabled) {
863
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
864
- }
865
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
866
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
867
- if (booleanToggler) {
868
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Boolean);
869
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Boolean);
870
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', ((_c = spec.viewSpec.oneOfParams) === null || _c === void 0 ? void 0 : _c.toggler) === 'switch' ? 'switch' : 'base');
871
- }
872
- else {
873
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.String);
874
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.String);
875
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', ((_d = spec.viewSpec.oneOfParams) === null || _d === void 0 ? void 0 : _d.toggler) === 'radio'
876
- ? 'radio_group'
877
- : 'segmented_radio_group');
878
- }
879
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
880
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
881
- if (spec.viewSpec.layoutTitle) {
882
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
883
- }
884
- if (spec.viewSpec.layoutDescription) {
885
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
886
- }
887
- if (spec.viewSpec.layoutOpen !== undefined) {
888
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
889
- }
890
- if (spec.viewSpec.order && !booleanToggler) {
891
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', spec.viewSpec.order);
892
- }
893
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
894
- console.warn(`[dynamic-forms] Unknown object oneof_flat view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
895
- }
896
- if ((_e = spec.viewSpec.oneOfParams) === null || _e === void 0 ? void 0 : _e.booleanMap) {
897
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.booleanToKey', spec.viewSpec.oneOfParams.booleanMap);
898
- }
899
- if (spec.viewSpec.placeholder) {
900
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
901
- }
902
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
903
- console.warn(`[dynamic-forms] Unknown object oneof_flat view spec key: "hidden"`);
904
- }
905
- if (spec.viewSpec.inputProps) {
906
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
907
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
908
- });
909
- }
910
- if (spec.viewSpec.layoutProps) {
911
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
912
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
913
- });
914
- }
915
- // delimiter for old oneof_flat not expected
916
- // if (spec.viewSpec.delimiter) {}
917
- },
918
- card_oneof: (spec, mutableSchema) => {
919
- var _a, _b, _c, _d, _e;
920
- const booleanToggler = ((_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler) === 'checkbox' ||
921
- ((_b = spec.viewSpec.oneOfParams) === null || _b === void 0 ? void 0 : _b.toggler) === 'switch';
922
- if (spec.defaultValue !== undefined) {
923
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
924
- }
925
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
926
- if (spec.required) {
927
- (0, set_1.default)(mutableSchema, 'allOf', [
928
- ...(mutableSchema.allOf || []),
929
- { not: { enum: [null, undefined, '', false] } },
930
- ]);
931
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
932
- }
933
- if (spec.properties) {
934
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
935
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
936
- if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
937
- (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
938
- }
939
- });
940
- if (!booleanToggler) {
941
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', Object.keys(spec.properties));
942
- }
943
- }
944
- if (spec.description) {
945
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
946
- }
947
- if (spec.validator && spec.validator !== 'base') {
948
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
949
- }
950
- if (spec.viewSpec.disabled) {
951
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
952
- }
953
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
954
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
955
- if (booleanToggler) {
956
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Boolean);
957
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Boolean);
958
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', ((_c = spec.viewSpec.oneOfParams) === null || _c === void 0 ? void 0 : _c.toggler) === 'switch' ? 'switch' : 'base');
959
- }
960
- else {
961
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.String);
962
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.String);
963
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', ((_d = spec.viewSpec.oneOfParams) === null || _d === void 0 ? void 0 : _d.toggler) === 'select'
964
- ? 'select'
965
- : 'segmented_radio_group');
966
- }
967
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'card');
968
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
969
- if (spec.viewSpec.layoutTitle) {
970
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
971
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
972
- }
973
- if (spec.viewSpec.layoutDescription) {
974
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
975
- }
976
- if (spec.viewSpec.layoutOpen !== undefined) {
977
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
978
- }
979
- if (spec.viewSpec.order && !booleanToggler) {
980
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', spec.viewSpec.order);
981
- }
982
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
983
- console.warn(`[dynamic-forms] Unknown object card_oneof view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
984
- }
985
- if ((_e = spec.viewSpec.oneOfParams) === null || _e === void 0 ? void 0 : _e.booleanMap) {
986
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.booleanToKey', spec.viewSpec.oneOfParams.booleanMap);
987
- }
988
- if (spec.viewSpec.placeholder) {
989
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
990
- }
991
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
992
- console.warn(`[dynamic-forms] Unknown object card_oneof view spec key: "hidden"`);
993
- }
994
- if (spec.viewSpec.inputProps) {
995
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
996
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
997
- });
998
- }
999
- if (spec.viewSpec.layoutProps) {
1000
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1001
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1002
- });
1003
- }
1004
- // delimiter for old card_oneof not expected
1005
- // if (spec.viewSpec.delimiter) {}
1006
- },
1007
- secret: (spec, mutableSchema, ctx) => {
1008
- var _a;
1009
- if (spec.defaultValue !== undefined) {
1010
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1011
- }
1012
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1013
- if (spec.required) {
1014
- (0, set_1.default)(mutableSchema, 'allOf', [
1015
- ...(mutableSchema.allOf || []),
1016
- { not: { enum: [null, undefined, '', false] } },
1017
- ]);
1018
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1019
- }
1020
- if (spec.properties) {
1021
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1022
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1023
- });
1024
- }
1025
- // description for old secret not expected
1026
- // if (spec.description) {}
1027
- if (spec.validator && spec.validator !== 'base') {
1028
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1029
- }
1030
- if (spec.viewSpec.disabled) {
1031
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1032
- }
1033
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1034
- // there is no secret entity in the new kit yet, the name is kept as is
1035
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'secret');
1036
- if (spec.viewSpec.layout) {
1037
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1038
- if (layoutRule) {
1039
- layoutRule(spec, mutableSchema, ctx);
1040
- }
1041
- else if (process.env.NODE_ENV !== 'production') {
1042
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1043
- }
1044
- }
1045
- if (spec.viewSpec.layoutTitle) {
1046
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1047
- }
1048
- if (spec.viewSpec.layoutDescription) {
1049
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1050
- }
1051
- if (spec.viewSpec.layoutOpen !== undefined) {
1052
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1053
- }
1054
- if (spec.viewSpec.order) {
1055
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.order', spec.viewSpec.order);
1056
- }
1057
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1058
- console.warn(`[dynamic-forms] Unknown object secret view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1059
- }
1060
- // oneOfParams for old secret not expected
1061
- // if (spec.viewSpec.oneOfParams) {}
1062
- // placeholder for old secret not expected
1063
- // if (spec.viewSpec.placeholder) {}
1064
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1065
- console.warn(`[dynamic-forms] Unknown object secret view spec key: "hidden"`);
1066
- }
1067
- if (spec.viewSpec.inputProps) {
1068
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1069
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1070
- });
1071
- }
1072
- if (spec.viewSpec.layoutProps) {
1073
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1074
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1075
- });
1076
- }
1077
- // delimiter for old secret not expected
1078
- // if (spec.viewSpec.delimiter) {}
1079
- },
1080
- base: (spec, mutableSchema, ctx) => {
1081
- var _a;
1082
- if (spec.defaultValue !== undefined) {
1083
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1084
- }
1085
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1086
- if (spec.required) {
1087
- (0, set_1.default)(mutableSchema, 'allOf', [
1088
- ...(mutableSchema.allOf || []),
1089
- { not: { enum: [null, undefined, '', false] } },
1090
- ]);
1091
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1092
- }
1093
- if (spec.properties) {
1094
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1095
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1096
- });
1097
- }
1098
- // description for old base not expected
1099
- // if (spec.description) {}
1100
- if (spec.validator && spec.validator !== 'base') {
1101
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1102
- }
1103
- if (spec.viewSpec.disabled) {
1104
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1105
- }
1106
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1107
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'base');
1108
- if (spec.viewSpec.layout) {
1109
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1110
- if (layoutRule) {
1111
- layoutRule(spec, mutableSchema, ctx);
1112
- }
1113
- else if (process.env.NODE_ENV !== 'production') {
1114
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1115
- }
1116
- }
1117
- if (spec.viewSpec.layoutTitle) {
1118
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1119
- }
1120
- if (spec.viewSpec.layoutDescription) {
1121
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1122
- }
1123
- if (spec.viewSpec.layoutOpen !== undefined) {
1124
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1125
- }
1126
- if (spec.viewSpec.order) {
1127
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.order', spec.viewSpec.order);
1128
- }
1129
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1130
- console.warn(`[dynamic-forms] Unknown object base view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1131
- }
1132
- // oneOfParams for old base not expected
1133
- // if (spec.viewSpec.oneOfParams) {}
1134
- // placeholder for old base not expected
1135
- // if (spec.viewSpec.placeholder) {}
1136
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1137
- console.warn(`[dynamic-forms] Unknown object base view spec key: "hidden"`);
1138
- }
1139
- if (spec.viewSpec.inputProps) {
1140
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1141
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1142
- });
1143
- }
1144
- if (spec.viewSpec.layoutProps) {
1145
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1146
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1147
- });
1148
- }
1149
- if (spec.viewSpec.delimiter && process.env.NODE_ENV !== 'production') {
1150
- console.warn(`[dynamic-forms] Unknown object base view spec key: "delimiter", value - ${JSON.stringify(spec.viewSpec.delimiter, null, 2)}`);
1151
- }
1152
- },
1153
- text_link: (spec, mutableSchema, ctx) => {
1154
- var _a;
1155
- if (spec.defaultValue !== undefined) {
1156
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1157
- }
1158
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1159
- if (spec.required) {
1160
- (0, set_1.default)(mutableSchema, 'allOf', [
1161
- ...(mutableSchema.allOf || []),
1162
- { not: { enum: [null, undefined, '', false] } },
1163
- ]);
1164
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1165
- }
1166
- if (spec.properties) {
1167
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1168
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1169
- });
1170
- }
1171
- // description for old text_link not expected
1172
- // if (spec.description) {}
1173
- if (spec.validator && spec.validator !== 'base') {
1174
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1175
- }
1176
- if (spec.viewSpec.disabled) {
1177
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1178
- }
1179
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1180
- // there is no text_link entity in the new kit yet, the name is kept as is
1181
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'text_link');
1182
- if (spec.viewSpec.layout) {
1183
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1184
- if (layoutRule) {
1185
- layoutRule(spec, mutableSchema, ctx);
1186
- }
1187
- else if (process.env.NODE_ENV !== 'production') {
1188
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1189
- }
1190
- }
1191
- if (spec.viewSpec.layoutTitle) {
1192
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1193
- }
1194
- if (spec.viewSpec.layoutDescription) {
1195
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1196
- }
1197
- if (spec.viewSpec.layoutOpen !== undefined) {
1198
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1199
- }
1200
- // order for old text_link not expected
1201
- // if (spec.viewSpec.order) {}
1202
- if (spec.viewSpec.link) {
1203
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.link', spec.viewSpec.link);
1204
- }
1205
- // oneOfParams for old text_link not expected
1206
- // if (spec.viewSpec.oneOfParams) {}
1207
- // placeholder for old text_link not expected
1208
- // if (spec.viewSpec.placeholder) {}
1209
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1210
- console.warn(`[dynamic-forms] Unknown object text_link view spec key: "hidden"`);
1211
- }
1212
- if (spec.viewSpec.inputProps) {
1213
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1214
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1215
- });
1216
- }
1217
- if (spec.viewSpec.layoutProps) {
1218
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1219
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1220
- });
1221
- }
1222
- // delimiter for old text_link not expected
1223
- // if (spec.viewSpec.delimiter) {}
1224
- },
1225
- object_value: (spec, mutableSchema, ctx) => {
1226
- var _a;
1227
- if (spec.defaultValue !== undefined) {
1228
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1229
- }
1230
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1231
- if (spec.required) {
1232
- (0, set_1.default)(mutableSchema, 'allOf', [
1233
- ...(mutableSchema.allOf || []),
1234
- { not: { enum: [null, undefined, '', false] } },
1235
- ]);
1236
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1237
- }
1238
- if (spec.properties) {
1239
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1240
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1241
- });
1242
- }
1243
- // description for old object_value not expected
1244
- // if (spec.description) {}
1245
- if (spec.validator && spec.validator !== 'base') {
1246
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1247
- }
1248
- if (spec.viewSpec.disabled) {
1249
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1250
- }
1251
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1252
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'dot_value');
1253
- if (spec.viewSpec.layout) {
1254
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1255
- if (layoutRule) {
1256
- layoutRule(spec, mutableSchema, ctx);
1257
- }
1258
- else if (process.env.NODE_ENV !== 'production') {
1259
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1260
- }
1261
- }
1262
- if (spec.viewSpec.layoutTitle) {
1263
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1264
- }
1265
- if (spec.viewSpec.layoutDescription) {
1266
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1267
- }
1268
- if (spec.viewSpec.layoutOpen !== undefined) {
1269
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1270
- }
1271
- if (spec.viewSpec.order && process.env.NODE_ENV !== 'production') {
1272
- console.warn(`[dynamic-forms] Unknown object object_value view spec key: "order", value - ${JSON.stringify(spec.viewSpec.order)}`);
1273
- }
1274
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1275
- console.warn(`[dynamic-forms] Unknown object object_value view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1276
- }
1277
- // oneOfParams for old object_value not expected
1278
- // if (spec.viewSpec.oneOfParams) {}
1279
- // placeholder for old object_value not expected
1280
- // if (spec.viewSpec.placeholder) {}
1281
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1282
- console.warn(`[dynamic-forms] Unknown object object_value view spec key: "hidden"`);
1283
- }
1284
- if (spec.viewSpec.inputProps) {
1285
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1286
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1287
- });
1288
- }
1289
- if (spec.viewSpec.layoutProps) {
1290
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1291
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1292
- });
1293
- }
1294
- // delimiter for old object_value not expected
1295
- // if (spec.viewSpec.delimiter) {}
1296
- },
1297
- multi_oneof: (spec, mutableSchema) => {
1298
- var _a, _b;
1299
- if (spec.defaultValue !== undefined) {
1300
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1301
- }
1302
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1303
- if (spec.required) {
1304
- (0, set_1.default)(mutableSchema, 'allOf', [
1305
- ...(mutableSchema.allOf || []),
1306
- { not: { enum: [null, undefined, '', false] } },
1307
- ]);
1308
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1309
- }
1310
- if (spec.properties) {
1311
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1312
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1313
- if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
1314
- (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
1315
- }
1316
- });
1317
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', Object.keys(spec.properties));
1318
- }
1319
- if (spec.description) {
1320
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
1321
- }
1322
- if (spec.validator && spec.validator !== 'base') {
1323
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1324
- }
1325
- if (spec.viewSpec.disabled) {
1326
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1327
- }
1328
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1329
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'few_of_nested');
1330
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.withIndent', true);
1331
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Array);
1332
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Array);
1333
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', ((_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler) === 'checkbox' ? 'checkbox_group' : 'select');
1334
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
1335
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
1336
- if (spec.viewSpec.layoutTitle) {
1337
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
1338
- }
1339
- if (spec.viewSpec.layoutDescription) {
1340
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
1341
- }
1342
- if (spec.viewSpec.layoutOpen !== undefined) {
1343
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1344
- }
1345
- if (spec.viewSpec.order) {
1346
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', spec.viewSpec.order);
1347
- }
1348
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1349
- console.warn(`[dynamic-forms] Unknown object multi_oneof view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1350
- }
1351
- if (((_b = spec.viewSpec.oneOfParams) === null || _b === void 0 ? void 0 : _b.booleanMap) && process.env.NODE_ENV !== 'production') {
1352
- console.warn(`[dynamic-forms] Unknown object multi_oneof view spec key: "oneOfParams.booleanMap", value - ${JSON.stringify(spec.viewSpec.oneOfParams.booleanMap)}`);
1353
- }
1354
- if (spec.viewSpec.placeholder) {
1355
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
1356
- }
1357
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1358
- console.warn(`[dynamic-forms] Unknown object multi_oneof view spec key: "hidden"`);
1359
- }
1360
- if (spec.viewSpec.inputProps) {
1361
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1362
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1363
- });
1364
- }
1365
- if (spec.viewSpec.layoutProps) {
1366
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1367
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1368
- });
1369
- }
1370
- // delimiter for old multi_oneof not expected
1371
- // if (spec.viewSpec.delimiter) {}
1372
- },
1373
- multi_oneof_flat: (spec, mutableSchema) => {
1374
- var _a, _b;
1375
- if (spec.defaultValue !== undefined) {
1376
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1377
- }
1378
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1379
- if (spec.required) {
1380
- (0, set_1.default)(mutableSchema, 'allOf', [
1381
- ...(mutableSchema.allOf || []),
1382
- { not: { enum: [null, undefined, '', false] } },
1383
- ]);
1384
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1385
- }
1386
- if (spec.properties) {
1387
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1388
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1389
- if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
1390
- (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
1391
- }
1392
- });
1393
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', Object.keys(spec.properties));
1394
- }
1395
- if (spec.description) {
1396
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
1397
- }
1398
- if (spec.validator && spec.validator !== 'base') {
1399
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1400
- }
1401
- if (spec.viewSpec.disabled) {
1402
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1403
- }
1404
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1405
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'few_of_nested');
1406
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Array);
1407
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Array);
1408
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', ((_a = spec.viewSpec.oneOfParams) === null || _a === void 0 ? void 0 : _a.toggler) === 'checkbox' ? 'checkbox_group' : 'select');
1409
- (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
1410
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
1411
- if (spec.viewSpec.layoutTitle) {
1412
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
1413
- }
1414
- if (spec.viewSpec.layoutDescription) {
1415
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
1416
- }
1417
- if (spec.viewSpec.layoutOpen !== undefined) {
1418
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1419
- }
1420
- if (spec.viewSpec.order) {
1421
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', spec.viewSpec.order);
1422
- }
1423
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1424
- console.warn(`[dynamic-forms] Unknown object multi_oneof_flat view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1425
- }
1426
- if (((_b = spec.viewSpec.oneOfParams) === null || _b === void 0 ? void 0 : _b.booleanMap) && process.env.NODE_ENV !== 'production') {
1427
- console.warn(`[dynamic-forms] Unknown object multi_oneof_flat view spec key: "oneOfParams.booleanMap", value - ${JSON.stringify(spec.viewSpec.oneOfParams.booleanMap)}`);
1428
- }
1429
- if (spec.viewSpec.placeholder) {
1430
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
1431
- }
1432
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1433
- console.warn(`[dynamic-forms] Unknown object multi_oneof_flat view spec key: "hidden"`);
1434
- }
1435
- if (spec.viewSpec.inputProps) {
1436
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1437
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1438
- });
1439
- }
1440
- if (spec.viewSpec.layoutProps) {
1441
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1442
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1443
- });
1444
- }
1445
- // delimiter for old multi_oneof_flat not expected
1446
- // if (spec.viewSpec.delimiter) {}
1447
- },
1448
- inline: (spec, mutableSchema, ctx) => {
1449
- var _a;
1450
- if (spec.defaultValue !== undefined) {
1451
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1452
- }
1453
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1454
- if (spec.required) {
1455
- (0, set_1.default)(mutableSchema, 'allOf', [
1456
- ...(mutableSchema.allOf || []),
1457
- { not: { enum: [null, undefined, '', false] } },
1458
- ]);
1459
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1460
- }
1461
- if (spec.properties) {
1462
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1463
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1464
- });
1465
- }
1466
- // description for old inline not expected
1467
- // if (spec.description) {}
1468
- if (spec.validator && spec.validator !== 'base') {
1469
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1470
- }
1471
- if (spec.viewSpec.disabled) {
1472
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1473
- }
1474
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1475
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'inline');
1476
- if (spec.viewSpec.layout) {
1477
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1478
- if (layoutRule) {
1479
- layoutRule(spec, mutableSchema, ctx);
1480
- }
1481
- else if (process.env.NODE_ENV !== 'production') {
1482
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1483
- }
1484
- }
1485
- if (spec.viewSpec.layoutTitle) {
1486
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1487
- }
1488
- if (spec.viewSpec.layoutDescription) {
1489
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1490
- }
1491
- if (spec.viewSpec.layoutOpen !== undefined) {
1492
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1493
- }
1494
- if (spec.viewSpec.order) {
1495
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.order', spec.viewSpec.order);
1496
- }
1497
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1498
- console.warn(`[dynamic-forms] Unknown object inline view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1499
- }
1500
- // oneOfParams for old inline not expected
1501
- // if (spec.viewSpec.oneOfParams) {}
1502
- // placeholder for old inline not expected
1503
- // if (spec.viewSpec.placeholder) {}
1504
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1505
- console.warn(`[dynamic-forms] Unknown object inline view spec key: "hidden"`);
1506
- }
1507
- if (spec.viewSpec.inputProps) {
1508
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1509
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1510
- });
1511
- }
1512
- if (spec.viewSpec.layoutProps) {
1513
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1514
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1515
- });
1516
- }
1517
- if (spec.viewSpec.delimiter) {
1518
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.delimiter', spec.viewSpec.delimiter);
1519
- }
1520
- },
1521
- time_range_selector: (spec, mutableSchema, ctx) => {
1522
- var _a;
1523
- if (spec.defaultValue !== undefined) {
1524
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1525
- }
1526
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1527
- if (spec.required) {
1528
- (0, set_1.default)(mutableSchema, 'allOf', [
1529
- ...(mutableSchema.allOf || []),
1530
- { not: { enum: [null, undefined, '', false] } },
1531
- ]);
1532
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1533
- }
1534
- if (spec.properties) {
1535
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1536
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1537
- });
1538
- }
1539
- // description for old time_range_selector not expected
1540
- // if (spec.description) {}
1541
- if (spec.validator && spec.validator !== 'base') {
1542
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1543
- }
1544
- if (spec.viewSpec.disabled) {
1545
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1546
- }
1547
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1548
- // there is no time_range_selector entity in the new kit yet, the name is kept as is
1549
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'time_range_selector');
1550
- if (spec.viewSpec.layout) {
1551
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1552
- if (layoutRule) {
1553
- layoutRule(spec, mutableSchema, ctx);
1554
- }
1555
- else if (process.env.NODE_ENV !== 'production') {
1556
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1557
- }
1558
- }
1559
- if (spec.viewSpec.layoutTitle) {
1560
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1561
- }
1562
- if (spec.viewSpec.layoutDescription) {
1563
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1564
- }
1565
- if (spec.viewSpec.layoutOpen !== undefined) {
1566
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1567
- }
1568
- if (spec.viewSpec.order) {
1569
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.order', spec.viewSpec.order);
1570
- }
1571
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1572
- console.warn(`[dynamic-forms] Unknown object time_range_selector view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1573
- }
1574
- // oneOfParams for old time_range_selector not expected
1575
- // if (spec.viewSpec.oneOfParams) {}
1576
- if (spec.viewSpec.placeholder) {
1577
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
1578
- }
1579
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1580
- console.warn(`[dynamic-forms] Unknown object time_range_selector view spec key: "hidden"`);
1581
- }
1582
- if (spec.viewSpec.inputProps) {
1583
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1584
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1585
- });
1586
- }
1587
- if (spec.viewSpec.layoutProps) {
1588
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1589
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1590
- });
1591
- }
1592
- // delimiter for old time_range_selector not expected
1593
- // if (spec.viewSpec.delimiter) {}
1594
- },
1595
- range_input_picker: (spec, mutableSchema, ctx) => {
1596
- var _a;
1597
- if (spec.defaultValue !== undefined) {
1598
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1599
- }
1600
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Object);
1601
- if (spec.required) {
1602
- (0, set_1.default)(mutableSchema, 'allOf', [
1603
- ...(mutableSchema.allOf || []),
1604
- { not: { enum: [null, undefined, '', false] } },
1605
- ]);
1606
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1607
- }
1608
- if (spec.properties) {
1609
- Object.entries(spec.properties).forEach(([key, childSpec]) => {
1610
- (0, set_1.default)(mutableSchema, ['properties', key], specToJsonSchema(childSpec, (0, get_1.default)(mutableSchema, ['properties', key])));
1611
- });
1612
- }
1613
- // description for old range_input_picker not expected
1614
- // if (spec.description) {}
1615
- if (spec.validator && spec.validator !== 'base') {
1616
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1617
- }
1618
- if (spec.viewSpec.disabled) {
1619
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1620
- }
1621
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Object);
1622
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'range_input');
1623
- if (spec.viewSpec.layout) {
1624
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1625
- if (layoutRule) {
1626
- layoutRule(spec, mutableSchema, ctx);
1627
- }
1628
- else if (process.env.NODE_ENV !== 'production') {
1629
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1630
- }
1631
- }
1632
- if (spec.viewSpec.layoutTitle) {
1633
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1634
- }
1635
- if (spec.viewSpec.layoutDescription) {
1636
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1637
- }
1638
- if (spec.viewSpec.layoutOpen !== undefined) {
1639
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1640
- }
1641
- if (spec.viewSpec.order) {
1642
- if (spec.viewSpec.order.length === 2) {
1643
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.propertyKeys', spec.viewSpec.order);
1644
- }
1645
- else if (process.env.NODE_ENV !== 'production') {
1646
- console.warn(`[dynamic-forms] Unknown object range_input_picker view spec key: "order", value - ${JSON.stringify(spec.viewSpec.order)}`);
1647
- }
1648
- }
1649
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1650
- console.warn(`[dynamic-forms] Unknown object range_input_picker view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1651
- }
1652
- // oneOfParams for old range_input_picker not expected
1653
- // if (spec.viewSpec.oneOfParams) {}
1654
- // placeholder for old range_input_picker not expected
1655
- // if (spec.viewSpec.placeholder) {}
1656
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1657
- console.warn(`[dynamic-forms] Unknown object range_input_picker view spec key: "hidden"`);
1658
- }
1659
- if (spec.viewSpec.inputProps) {
1660
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1661
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1662
- });
1663
- }
1664
- if (spec.viewSpec.layoutProps) {
1665
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1666
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1667
- });
1668
- }
1669
- if (spec.viewSpec.delimiter && process.env.NODE_ENV !== 'production') {
1670
- console.warn(`[dynamic-forms] Unknown object range_input_picker view spec key: "delimiter", value - ${JSON.stringify(spec.viewSpec.delimiter)}`);
1671
- }
1672
- },
1673
- };
1674
- exports.stringInputTypeRules = {
1675
- password: (spec, mutableSchema, ctx) => {
1676
- var _a;
1677
- if (spec.defaultValue !== undefined) {
1678
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1679
- }
1680
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
1681
- if (spec.required) {
1682
- (0, set_1.default)(mutableSchema, 'allOf', [
1683
- ...(mutableSchema.allOf || []),
1684
- { not: { enum: [null, undefined, '', false] } },
1685
- ]);
1686
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1687
- }
1688
- if (spec.maxLength) {
1689
- const maxLength = Number(spec.maxLength);
1690
- if (!isNaN(maxLength)) {
1691
- (0, set_1.default)(mutableSchema, 'maxLength', maxLength);
1692
- }
1693
- }
1694
- if (spec.minLength) {
1695
- const minLength = Number(spec.minLength);
1696
- if (!isNaN(minLength)) {
1697
- (0, set_1.default)(mutableSchema, 'minLength', minLength);
1698
- }
1699
- }
1700
- if (spec.pattern) {
1701
- (0, set_1.default)(mutableSchema, 'pattern', spec.pattern);
1702
- }
1703
- if (spec.patternError) {
1704
- (0, set_1.default)(mutableSchema, 'nodeParameters.errorMessages.pattern', spec.patternError);
1705
- }
1706
- // enum for old password not expected
1707
- // if (spec.enum) {}
1708
- // description for old password not expected
1709
- // if (spec.description) {}
1710
- if (spec.validator && spec.validator !== 'base') {
1711
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1712
- }
1713
- if (spec.viewSpec.disabled) {
1714
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1715
- }
1716
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
1717
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'password');
1718
- if (spec.viewSpec.layout) {
1719
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1720
- if (layoutRule) {
1721
- layoutRule(spec, mutableSchema, ctx);
1722
- }
1723
- else if (process.env.NODE_ENV !== 'production') {
1724
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1725
- }
1726
- }
1727
- if (spec.viewSpec.layoutTitle) {
1728
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1729
- }
1730
- if (spec.viewSpec.layoutDescription) {
1731
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1732
- }
1733
- if (spec.viewSpec.layoutOpen !== undefined) {
1734
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1735
- }
1736
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1737
- console.warn(`[dynamic-forms] Unknown string password view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1738
- }
1739
- // sizeParams for old password not expected
1740
- // if (spec.viewSpec.sizeParams) {}
1741
- // monacoParams for old password not expected
1742
- // if (spec.viewSpec.monacoParams) {}
1743
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
1744
- console.warn(`[dynamic-forms] Unknown string password view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
1745
- }
1746
- if (spec.viewSpec.placeholder) {
1747
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
1748
- }
1749
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1750
- console.warn(`[dynamic-forms] Unknown string password view spec key: "hidden"`);
1751
- }
1752
- // textContentParams for old password not expected
1753
- // if (spec.viewSpec.textContentParams) {}
1754
- // fileInput for old password not expected
1755
- // if (spec.viewSpec.fileInput) {}
1756
- // dateInput for old password not expected
1757
- // if (spec.viewSpec.dateInput) {}
1758
- if (spec.viewSpec.copy) {
1759
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
1760
- }
1761
- // selectParams for old password not expected
1762
- // if (spec.viewSpec.selectParams) {}
1763
- // radioGroupParams for old password not expected
1764
- // if (spec.viewSpec.radioGroupParams) {}
1765
- if (spec.viewSpec.inputProps) {
1766
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1767
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1768
- });
1769
- }
1770
- if (spec.viewSpec.layoutProps) {
1771
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1772
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1773
- });
1774
- }
1775
- if (spec.viewSpec.generateRandomValueButton && process.env.NODE_ENV !== 'production') {
1776
- console.warn(`[dynamic-forms] Unknown string password view spec key: "generateRandomValueButton"`);
1777
- }
1778
- },
1779
- textarea: (spec, mutableSchema, ctx) => {
1780
- var _a;
1781
- if (spec.defaultValue !== undefined) {
1782
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1783
- }
1784
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
1785
- if (spec.required) {
1786
- (0, set_1.default)(mutableSchema, 'allOf', [
1787
- ...(mutableSchema.allOf || []),
1788
- { not: { enum: [null, undefined, '', false] } },
1789
- ]);
1790
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1791
- }
1792
- if (spec.maxLength) {
1793
- const maxLength = Number(spec.maxLength);
1794
- if (!isNaN(maxLength)) {
1795
- (0, set_1.default)(mutableSchema, 'maxLength', maxLength);
1796
- }
1797
- }
1798
- if (spec.minLength) {
1799
- const minLength = Number(spec.minLength);
1800
- if (!isNaN(minLength)) {
1801
- (0, set_1.default)(mutableSchema, 'minLength', minLength);
1802
- }
1803
- }
1804
- if (spec.pattern) {
1805
- (0, set_1.default)(mutableSchema, 'pattern', spec.pattern);
1806
- }
1807
- if (spec.patternError) {
1808
- (0, set_1.default)(mutableSchema, 'nodeParameters.errorMessages.pattern', spec.patternError);
1809
- }
1810
- // enum for old textarea not expected
1811
- // if (spec.enum) {}
1812
- // description for old textarea not expected
1813
- // if (spec.description) {}
1814
- if (spec.validator && spec.validator !== 'base') {
1815
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1816
- }
1817
- if (spec.viewSpec.disabled) {
1818
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1819
- }
1820
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
1821
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'textarea');
1822
- if (spec.viewSpec.layout) {
1823
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1824
- if (layoutRule) {
1825
- layoutRule(spec, mutableSchema, ctx);
1826
- }
1827
- else if (process.env.NODE_ENV !== 'production') {
1828
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1829
- }
1830
- }
1831
- if (spec.viewSpec.layoutTitle) {
1832
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1833
- }
1834
- if (spec.viewSpec.layoutDescription) {
1835
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1836
- }
1837
- if (spec.viewSpec.layoutOpen !== undefined) {
1838
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1839
- }
1840
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1841
- console.warn(`[dynamic-forms] Unknown string textarea view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1842
- }
1843
- // sizeParams for old textarea not expected
1844
- // if (spec.viewSpec.sizeParams) {}
1845
- // monacoParams for old textarea not expected
1846
- // if (spec.viewSpec.monacoParams) {}
1847
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
1848
- console.warn(`[dynamic-forms] Unknown string textarea view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
1849
- }
1850
- if (spec.viewSpec.placeholder) {
1851
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
1852
- }
1853
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1854
- console.warn(`[dynamic-forms] Unknown string textarea view spec key: "hidden"`);
1855
- }
1856
- // textContentParams for old textarea not expected
1857
- // if (spec.viewSpec.textContentParams) {}
1858
- // fileInput for old textarea not expected
1859
- // if (spec.viewSpec.fileInput) {}
1860
- // dateInput for old textarea not expected
1861
- // if (spec.viewSpec.dateInput) {}
1862
- if (spec.viewSpec.copy) {
1863
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
1864
- }
1865
- // selectParams for old textarea not expected
1866
- // if (spec.viewSpec.selectParams) {}
1867
- // radioGroupParams for old textarea not expected
1868
- // if (spec.viewSpec.radioGroupParams) {}
1869
- if (spec.viewSpec.inputProps) {
1870
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1871
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1872
- });
1873
- }
1874
- if (spec.viewSpec.layoutProps) {
1875
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1876
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1877
- });
1878
- }
1879
- if (spec.viewSpec.generateRandomValueButton && process.env.NODE_ENV !== 'production') {
1880
- console.warn(`[dynamic-forms] Unknown string textarea view spec key: "generateRandomValueButton"`);
1881
- }
1882
- },
1883
- select: (spec, mutableSchema, ctx) => {
1884
- var _a;
1885
- if (spec.defaultValue !== undefined) {
1886
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1887
- }
1888
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
1889
- if (spec.required) {
1890
- (0, set_1.default)(mutableSchema, 'allOf', [
1891
- ...(mutableSchema.allOf || []),
1892
- { not: { enum: [null, undefined, '', false] } },
1893
- ]);
1894
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1895
- }
1896
- // maxLength for old select not expected
1897
- // if (spec.maxLength) {}
1898
- // minLength for old select not expected
1899
- // if (spec.minLength) {}
1900
- // pattern for old select not expected
1901
- // if (spec.pattern) {}
1902
- // patternError for old select not expected
1903
- // if (spec.patternError) {}
1904
- if (spec.enum) {
1905
- (0, set_1.default)(mutableSchema, 'enum', spec.enum);
1906
- }
1907
- if (spec.description) {
1908
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.enumDescriptions', spec.description);
1909
- }
1910
- if (spec.validator && spec.validator !== 'base') {
1911
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
1912
- }
1913
- if (spec.viewSpec.disabled) {
1914
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
1915
- }
1916
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
1917
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'select');
1918
- if (spec.viewSpec.layout) {
1919
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
1920
- if (layoutRule) {
1921
- layoutRule(spec, mutableSchema, ctx);
1922
- }
1923
- else if (process.env.NODE_ENV !== 'production') {
1924
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
1925
- }
1926
- }
1927
- if (spec.viewSpec.layoutTitle) {
1928
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
1929
- }
1930
- if (spec.viewSpec.layoutDescription) {
1931
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
1932
- }
1933
- if (spec.viewSpec.layoutOpen !== undefined) {
1934
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
1935
- }
1936
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
1937
- console.warn(`[dynamic-forms] Unknown string select view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
1938
- }
1939
- // sizeParams for old select not expected
1940
- // if (spec.viewSpec.sizeParams) {}
1941
- // monacoParams for old select not expected
1942
- // if (spec.viewSpec.monacoParams) {}
1943
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
1944
- console.warn(`[dynamic-forms] Unknown string select view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
1945
- }
1946
- if (spec.viewSpec.placeholder) {
1947
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
1948
- }
1949
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
1950
- console.warn(`[dynamic-forms] Unknown string select view spec key: "hidden"`);
1951
- }
1952
- // textContentParams for old select not expected
1953
- // if (spec.viewSpec.textContentParams) {}
1954
- // fileInput for old select not expected
1955
- // if (spec.viewSpec.fileInput) {}
1956
- // dateInput for old select not expected
1957
- // if (spec.viewSpec.dateInput) {}
1958
- if (spec.viewSpec.copy) {
1959
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
1960
- }
1961
- if (spec.viewSpec.selectParams) {
1962
- if (spec.viewSpec.selectParams.filterPlaceholder) {
1963
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.filterPlaceholder', spec.viewSpec.selectParams.filterPlaceholder);
1964
- }
1965
- if (spec.viewSpec.selectParams.meta) {
1966
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.optionsMeta', spec.viewSpec.selectParams.meta);
1967
- }
1968
- }
1969
- // radioGroupParams for old select not expected
1970
- // if (spec.viewSpec.radioGroupParams) {}
1971
- if (spec.viewSpec.inputProps) {
1972
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
1973
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
1974
- });
1975
- }
1976
- if (spec.viewSpec.layoutProps) {
1977
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
1978
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
1979
- });
1980
- }
1981
- // generateRandomValueButton for old select not expected
1982
- // if (spec.viewSpec.generateRandomValueButton) {}
1983
- },
1984
- base: (spec, mutableSchema, ctx) => {
1985
- var _a;
1986
- if (spec.defaultValue !== undefined) {
1987
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
1988
- }
1989
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
1990
- if (spec.required) {
1991
- (0, set_1.default)(mutableSchema, 'allOf', [
1992
- ...(mutableSchema.allOf || []),
1993
- { not: { enum: [null, undefined, '', false] } },
1994
- ]);
1995
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
1996
- }
1997
- if (spec.maxLength) {
1998
- const maxLength = Number(spec.maxLength);
1999
- if (!isNaN(maxLength)) {
2000
- (0, set_1.default)(mutableSchema, 'maxLength', maxLength);
2001
- }
2002
- }
2003
- if (spec.minLength) {
2004
- const minLength = Number(spec.minLength);
2005
- if (!isNaN(minLength)) {
2006
- (0, set_1.default)(mutableSchema, 'minLength', minLength);
2007
- }
2008
- }
2009
- if (spec.pattern) {
2010
- (0, set_1.default)(mutableSchema, 'pattern', spec.pattern);
2011
- }
2012
- if (spec.patternError) {
2013
- (0, set_1.default)(mutableSchema, 'nodeParameters.errorMessages.pattern', spec.patternError);
2014
- }
2015
- // enum for old base not expected
2016
- // if (spec.enum) {}
2017
- // description for old base not expected
2018
- // if (spec.description) {}
2019
- if (spec.validator && spec.validator !== 'base') {
2020
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
2021
- }
2022
- if (spec.viewSpec.disabled) {
2023
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
2024
- }
2025
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
2026
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'base');
2027
- if (spec.viewSpec.layout) {
2028
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
2029
- if (layoutRule) {
2030
- layoutRule(spec, mutableSchema, ctx);
2031
- }
2032
- else if (process.env.NODE_ENV !== 'production') {
2033
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
2034
- }
2035
- }
2036
- if (spec.viewSpec.layoutTitle) {
2037
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
2038
- }
2039
- if (spec.viewSpec.layoutDescription) {
2040
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
2041
- }
2042
- if (spec.viewSpec.layoutOpen !== undefined) {
2043
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
2044
- }
2045
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
2046
- console.warn(`[dynamic-forms] Unknown string base view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
2047
- }
2048
- // sizeParams for old base not expected
2049
- // if (spec.viewSpec.sizeParams) {}
2050
- // monacoParams for old base not expected
2051
- // if (spec.viewSpec.monacoParams) {}
2052
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
2053
- console.warn(`[dynamic-forms] Unknown string base view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
2054
- }
2055
- if (spec.viewSpec.placeholder) {
2056
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
2057
- }
2058
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
2059
- console.warn(`[dynamic-forms] Unknown string base view spec key: "hidden"`);
2060
- }
2061
- // textContentParams for old base not expected
2062
- // if (spec.viewSpec.textContentParams) {}
2063
- // fileInput for old base not expected
2064
- // if (spec.viewSpec.fileInput) {}
2065
- // dateInput for old base not expected
2066
- // if (spec.viewSpec.dateInput) {}
2067
- if (spec.viewSpec.copy) {
2068
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
2069
- }
2070
- // selectParams for old base not expected
2071
- // if (spec.viewSpec.selectParams) {}
2072
- // radioGroupParams for old base not expected
2073
- // if (spec.viewSpec.radioGroupParams) {}
2074
- if (spec.viewSpec.inputProps) {
2075
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
2076
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
2077
- });
2078
- }
2079
- if (spec.viewSpec.layoutProps) {
2080
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
2081
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
2082
- });
2083
- }
2084
- if (spec.viewSpec.generateRandomValueButton && process.env.NODE_ENV !== 'production') {
2085
- console.warn(`[dynamic-forms] Unknown string base view spec key: "generateRandomValueButton"`);
2086
- }
2087
- },
2088
- file_input: (spec, mutableSchema, ctx) => {
2089
- var _a;
2090
- if (spec.defaultValue !== undefined) {
2091
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
2092
- }
2093
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
2094
- if (spec.required) {
2095
- (0, set_1.default)(mutableSchema, 'allOf', [
2096
- ...(mutableSchema.allOf || []),
2097
- { not: { enum: [null, undefined, '', false] } },
2098
- ]);
2099
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
2100
- }
2101
- if (spec.maxLength) {
2102
- const maxLength = Number(spec.maxLength);
2103
- if (!isNaN(maxLength)) {
2104
- (0, set_1.default)(mutableSchema, 'maxLength', maxLength);
2105
- }
2106
- }
2107
- if (spec.minLength) {
2108
- const minLength = Number(spec.minLength);
2109
- if (!isNaN(minLength)) {
2110
- (0, set_1.default)(mutableSchema, 'minLength', minLength);
2111
- }
2112
- }
2113
- // pattern for old file_input not expected
2114
- // if (spec.pattern) {}
2115
- // patternError for old file_input not expected
2116
- // if (spec.patternError) {}
2117
- // enum for old file_input not expected
2118
- // if (spec.enum) {}
2119
- // description for old file_input not expected
2120
- // if (spec.description) {}
2121
- if (spec.validator && spec.validator !== 'base') {
2122
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
2123
- }
2124
- if (spec.viewSpec.disabled) {
2125
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
2126
- }
2127
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
2128
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'file');
2129
- if (spec.viewSpec.layout) {
2130
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
2131
- if (layoutRule) {
2132
- layoutRule(spec, mutableSchema, ctx);
2133
- }
2134
- else if (process.env.NODE_ENV !== 'production') {
2135
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
2136
- }
2137
- }
2138
- if (spec.viewSpec.layoutTitle) {
2139
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
2140
- }
2141
- if (spec.viewSpec.layoutDescription) {
2142
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
2143
- }
2144
- if (spec.viewSpec.layoutOpen !== undefined) {
2145
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
2146
- }
2147
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
2148
- console.warn(`[dynamic-forms] Unknown string file_input view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
2149
- }
2150
- // sizeParams for old file_input not expected
2151
- // if (spec.viewSpec.sizeParams) {}
2152
- // monacoParams for old file_input not expected
2153
- // if (spec.viewSpec.monacoParams) {}
2154
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
2155
- console.warn(`[dynamic-forms] Unknown string file_input view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
2156
- }
2157
- // placeholder for old file_input not expected
2158
- // if (spec.viewSpec.placeholder) {}
2159
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
2160
- console.warn(`[dynamic-forms] Unknown string file_input view spec key: "hidden"`);
2161
- }
2162
- // textContentParams for old file_input not expected
2163
- // if (spec.viewSpec.textContentParams) {}
2164
- if (spec.viewSpec.fileInput) {
2165
- if (spec.viewSpec.fileInput.accept) {
2166
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.accept', [
2167
- spec.viewSpec.fileInput.accept,
2168
- ]);
2169
- }
2170
- if (spec.viewSpec.fileInput.readAsMethod) {
2171
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.readAsMethod', spec.viewSpec.fileInput.readAsMethod);
2172
- }
2173
- if (spec.viewSpec.fileInput.ignoreText && process.env.NODE_ENV !== 'production') {
2174
- console.warn(`[dynamic-forms] Unknown string file_input view spec key: "fileInput.ignoreText"`);
2175
- }
2176
- }
2177
- // dateInput for old file_input not expected
2178
- // if (spec.viewSpec.dateInput) {}
2179
- if (spec.viewSpec.copy) {
2180
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
2181
- }
2182
- // selectParams for old file_input not expected
2183
- // if (spec.viewSpec.selectParams) {}
2184
- // radioGroupParams for old file_input not expected
2185
- // if (spec.viewSpec.radioGroupParams) {}
2186
- if (spec.viewSpec.inputProps) {
2187
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
2188
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
2189
- });
2190
- }
2191
- if (spec.viewSpec.layoutProps) {
2192
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
2193
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
2194
- });
2195
- }
2196
- // generateRandomValueButton for old file_input not expected
2197
- // if (spec.viewSpec.generateRandomValueButton) {}
2198
- },
2199
- date_input: (spec, mutableSchema, ctx) => {
2200
- var _a;
2201
- if (spec.defaultValue !== undefined) {
2202
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
2203
- }
2204
- // json schema type is not set: the value may be a string, a date or a timestamp object
2205
- if (spec.required) {
2206
- (0, set_1.default)(mutableSchema, 'allOf', [
2207
- ...(mutableSchema.allOf || []),
2208
- { not: { enum: [null, undefined, '', false] } },
2209
- ]);
2210
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
2211
- }
2212
- // maxLength for old date_input not expected
2213
- // if (spec.maxLength) {}
2214
- // minLength for old date_input not expected
2215
- // if (spec.minLength) {}
2216
- // pattern for old date_input not expected
2217
- // if (spec.pattern) {}
2218
- // patternError for old date_input not expected
2219
- // if (spec.patternError) {}
2220
- // enum for old date_input not expected
2221
- // if (spec.enum) {}
2222
- // description for old date_input not expected
2223
- // if (spec.description) {}
2224
- if (spec.validator && spec.validator !== 'base') {
2225
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
2226
- }
2227
- if (spec.viewSpec.disabled) {
2228
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
2229
- }
2230
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Any);
2231
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'date');
2232
- if (spec.viewSpec.layout) {
2233
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
2234
- if (layoutRule) {
2235
- layoutRule(spec, mutableSchema, ctx);
2236
- }
2237
- else if (process.env.NODE_ENV !== 'production') {
2238
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
2239
- }
2240
- }
2241
- if (spec.viewSpec.layoutTitle) {
2242
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
2243
- }
2244
- if (spec.viewSpec.layoutDescription) {
2245
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
2246
- }
2247
- if (spec.viewSpec.layoutOpen !== undefined) {
2248
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
2249
- }
2250
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
2251
- console.warn(`[dynamic-forms] Unknown string date_input view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
2252
- }
2253
- // sizeParams for old date_input not expected
2254
- // if (spec.viewSpec.sizeParams) {}
2255
- // monacoParams for old date_input not expected
2256
- // if (spec.viewSpec.monacoParams) {}
2257
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
2258
- console.warn(`[dynamic-forms] Unknown string date_input view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
2259
- }
2260
- if (spec.viewSpec.placeholder) {
2261
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
2262
- }
2263
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
2264
- console.warn(`[dynamic-forms] Unknown string date_input view spec key: "hidden"`);
2265
- }
2266
- // textContentParams for old date_input not expected
2267
- // if (spec.viewSpec.textContentParams) {}
2268
- // fileInput for old date_input not expected
2269
- // if (spec.viewSpec.fileInput) {}
2270
- if (spec.viewSpec.dateInput) {
2271
- if (spec.viewSpec.dateInput.outputFormat) {
2272
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.outputFormat', spec.viewSpec.dateInput.outputFormat);
2273
- }
2274
- if (spec.viewSpec.dateInput.printFormat) {
2275
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.format', spec.viewSpec.dateInput.printFormat);
2276
- }
2277
- if (spec.viewSpec.dateInput.timeZone) {
2278
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.timeZone', spec.viewSpec.dateInput.timeZone);
2279
- }
2280
- }
2281
- if (spec.viewSpec.copy) {
2282
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
2283
- }
2284
- // selectParams for old date_input not expected
2285
- // if (spec.viewSpec.selectParams) {}
2286
- // radioGroupParams for old date_input not expected
2287
- // if (spec.viewSpec.radioGroupParams) {}
2288
- if (spec.viewSpec.inputProps) {
2289
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
2290
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
2291
- });
2292
- }
2293
- if (spec.viewSpec.layoutProps) {
2294
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
2295
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
2296
- });
2297
- }
2298
- // generateRandomValueButton for old date_input not expected
2299
- // if (spec.viewSpec.generateRandomValueButton) {}
2300
- },
2301
- color_picker: (spec, mutableSchema, ctx) => {
2302
- var _a;
2303
- if (spec.defaultValue !== undefined) {
2304
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
2305
- }
2306
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
2307
- if (spec.required) {
2308
- (0, set_1.default)(mutableSchema, 'allOf', [
2309
- ...(mutableSchema.allOf || []),
2310
- { not: { enum: [null, undefined, '', false] } },
2311
- ]);
2312
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
2313
- }
2314
- // maxLength for old color_picker not expected
2315
- // if (spec.maxLength) {}
2316
- // minLength for old color_picker not expected
2317
- // if (spec.minLength) {}
2318
- if (spec.pattern) {
2319
- (0, set_1.default)(mutableSchema, 'pattern', spec.pattern);
2320
- }
2321
- if (spec.patternError) {
2322
- (0, set_1.default)(mutableSchema, 'nodeParameters.errorMessages.pattern', spec.patternError);
2323
- }
2324
- // enum for old color_picker not expected
2325
- // if (spec.enum) {}
2326
- // description for old color_picker not expected
2327
- // if (spec.description) {}
2328
- if (spec.validator && spec.validator !== 'base') {
2329
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
2330
- }
2331
- if (spec.viewSpec.disabled) {
2332
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
2333
- }
2334
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
2335
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'color_picker');
2336
- if (spec.viewSpec.layout) {
2337
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
2338
- if (layoutRule) {
2339
- layoutRule(spec, mutableSchema, ctx);
2340
- }
2341
- else if (process.env.NODE_ENV !== 'production') {
2342
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
2343
- }
2344
- }
2345
- if (spec.viewSpec.layoutTitle) {
2346
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
2347
- }
2348
- if (spec.viewSpec.layoutDescription) {
2349
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
2350
- }
2351
- if (spec.viewSpec.layoutOpen !== undefined) {
2352
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
2353
- }
2354
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
2355
- console.warn(`[dynamic-forms] Unknown string color_picker view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
2356
- }
2357
- // sizeParams for old color_picker not expected
2358
- // if (spec.viewSpec.sizeParams) {}
2359
- // monacoParams for old color_picker not expected
2360
- // if (spec.viewSpec.monacoParams) {}
2361
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
2362
- console.warn(`[dynamic-forms] Unknown string color_picker view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
2363
- }
2364
- if (spec.viewSpec.placeholder && process.env.NODE_ENV !== 'production') {
2365
- console.warn(`[dynamic-forms] Unknown string color_picker view spec key: "placeholder", value - ${spec.viewSpec.placeholder}`);
2366
- }
2367
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
2368
- console.warn(`[dynamic-forms] Unknown string color_picker view spec key: "hidden"`);
2369
- }
2370
- // textContentParams for old color_picker not expected
2371
- // if (spec.viewSpec.textContentParams) {}
2372
- // fileInput for old color_picker not expected
2373
- // if (spec.viewSpec.fileInput) {}
2374
- // dateInput for old color_picker not expected
2375
- // if (spec.viewSpec.dateInput) {}
2376
- if (spec.viewSpec.copy) {
2377
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
2378
- }
2379
- // selectParams for old color_picker not expected
2380
- // if (spec.viewSpec.selectParams) {}
2381
- // radioGroupParams for old color_picker not expected
2382
- // if (spec.viewSpec.radioGroupParams) {}
2383
- if (spec.viewSpec.inputProps) {
2384
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
2385
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
2386
- });
2387
- }
2388
- if (spec.viewSpec.layoutProps) {
2389
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
2390
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
2391
- });
2392
- }
2393
- // generateRandomValueButton for old color_picker not expected
2394
- // if (spec.viewSpec.generateRandomValueButton) {}
2395
- },
2396
- number_with_scale: (spec, mutableSchema, ctx) => {
2397
- var _a;
2398
- const numberWithScaleSpec = spec;
2399
- if (spec.defaultValue !== undefined) {
2400
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
2401
- }
2402
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
2403
- if (spec.required) {
2404
- (0, set_1.default)(mutableSchema, 'allOf', [
2405
- ...(mutableSchema.allOf || []),
2406
- { not: { enum: [null, undefined, '', false] } },
2407
- ]);
2408
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
2409
- }
2410
- // maxLength for old number_with_scale not expected
2411
- // if (spec.maxLength) {}
2412
- // minLength for old number_with_scale not expected
2413
- // if (spec.minLength) {}
2414
- // pattern for old number_with_scale not expected
2415
- // if (spec.pattern) {}
2416
- // patternError for old number_with_scale not expected
2417
- // if (spec.patternError) {}
2418
- // enum for old number_with_scale not expected
2419
- // if (spec.enum) {}
2420
- // description for old number_with_scale not expected
2421
- // if (spec.description) {}
2422
- if (spec.validator && spec.validator !== 'base') {
2423
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
104
+ link: (spec, mutableSchema) => {
105
+ if (spec.viewSpec.link) {
106
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.link', spec.viewSpec.link);
2424
107
  }
2425
- // NumberWithScaleSpec keeps its numeric limits in the stringNumber keyword
2426
- if (numberWithScaleSpec.minimum !== undefined) {
2427
- const minimum = Number(numberWithScaleSpec.minimum);
2428
- if (!isNaN(minimum)) {
2429
- (0, set_1.default)(mutableSchema, 'stringNumber.minimum', `${minimum}`);
108
+ },
109
+ placeholder: (spec, mutableSchema) => {
110
+ if ('placeholder' in spec.viewSpec && spec.viewSpec.placeholder) {
111
+ if (spec.type === core_1.SpecTypes.String) {
112
+ (0, set_1.default)(mutableSchema, 'examples', [spec.viewSpec.placeholder]);
2430
113
  }
2431
- }
2432
- if (numberWithScaleSpec.maximum !== undefined) {
2433
- const maximum = Number(numberWithScaleSpec.maximum);
2434
- if (!isNaN(maximum)) {
2435
- (0, set_1.default)(mutableSchema, 'stringNumber.maximum', `${maximum}`);
114
+ else if (spec.type === core_1.SpecTypes.Array) {
115
+ (0, set_1.default)(mutableSchema, 'examples', [[spec.viewSpec.placeholder]]);
2436
116
  }
2437
117
  }
2438
- if (numberWithScaleSpec.format) {
2439
- (0, set_1.default)(mutableSchema, 'stringNumber.type', numberWithScaleSpec.format === 'int64'
2440
- ? core_2.JsonSchemaType.Integer
2441
- : core_2.JsonSchemaType.Number);
118
+ },
119
+ addButtonPosition: (spec, mutableSchema) => {
120
+ if ('addButtonPosition' in spec.viewSpec && spec.viewSpec.addButtonPosition) {
121
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.addButtonPosition', spec.viewSpec.addButtonPosition);
2442
122
  }
2443
- if (spec.viewSpec.disabled) {
2444
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
2445
- }
2446
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
2447
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'string_number_with_scale');
2448
- if (spec.viewSpec.layout) {
2449
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
2450
- if (layoutRule) {
2451
- layoutRule(spec, mutableSchema, ctx);
123
+ },
124
+ hidden: (spec, mutableSchema) => {
125
+ if (spec.viewSpec.hidden) {
126
+ (0, set_1.default)(mutableSchema, 'nodeParameters.flags.hidden', true);
127
+ }
128
+ },
129
+ selectParams: (spec, mutableSchema) => {
130
+ if ('selectParams' in spec.viewSpec && spec.viewSpec.selectParams) {
131
+ if (spec.viewSpec.selectParams.filterPlaceholder) {
132
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.filterPlaceholder', spec.viewSpec.selectParams.filterPlaceholder);
2452
133
  }
2453
- else if (process.env.NODE_ENV !== 'production') {
2454
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
134
+ if (spec.viewSpec.selectParams.meta) {
135
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.optionsMeta', spec.viewSpec.selectParams.meta);
2455
136
  }
2456
137
  }
2457
- if (spec.viewSpec.layoutTitle) {
2458
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
138
+ },
139
+ checkboxGroupParams: (spec, mutableSchema) => {
140
+ if (spec.type === core_1.SpecTypes.Array && spec.viewSpec.checkboxGroupParams) {
141
+ if (spec.viewSpec.checkboxGroupParams.placement) {
142
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.direction', spec.viewSpec.checkboxGroupParams.placement === 'vertical' ? 'column' : 'row');
143
+ }
144
+ if (spec.viewSpec.checkboxGroupParams.disabled) {
145
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.optionsDisabled', spec.viewSpec.checkboxGroupParams.disabled);
146
+ }
2459
147
  }
2460
- if (spec.viewSpec.layoutDescription) {
2461
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
148
+ },
149
+ viewColor: (spec, mutableSchema) => {
150
+ if (spec.type === core_1.SpecTypes.Boolean && spec.viewSpec.viewColor) {
151
+ (0, set_1.default)(mutableSchema, 'nodeParameters.overviewEntityProps.viewColor', spec.viewSpec.viewColor);
2462
152
  }
2463
- if (spec.viewSpec.layoutOpen !== undefined) {
2464
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
153
+ },
154
+ copy: (spec, mutableSchema) => {
155
+ if ('copy' in spec.viewSpec && spec.viewSpec.copy) {
156
+ (0, set_1.default)(mutableSchema, 'nodeParameters.flags.copy', true);
2465
157
  }
2466
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
2467
- console.warn(`[dynamic-forms] Unknown string number_with_scale view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
158
+ },
159
+ order: (spec, mutableSchema) => {
160
+ if (spec.type === core_1.SpecTypes.Object && spec.viewSpec.order) {
161
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.order', spec.viewSpec.order);
162
+ }
163
+ },
164
+ delimiter: (spec, mutableSchema) => {
165
+ if (spec.type === core_1.SpecTypes.Object && spec.viewSpec.delimiter) {
166
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.delimiter', spec.viewSpec.delimiter);
2468
167
  }
2469
- if (spec.viewSpec.sizeParams) {
168
+ },
169
+ sizeParams: (spec, mutableSchema) => {
170
+ if (spec.type === core_1.SpecTypes.String && spec.viewSpec.sizeParams) {
2470
171
  if (spec.viewSpec.sizeParams.defaultType) {
2471
172
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.defaultType', spec.viewSpec.sizeParams.defaultType);
2472
173
  }
@@ -2477,443 +178,506 @@ exports.stringInputTypeRules = {
2477
178
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.viewType', spec.viewSpec.sizeParams.viewType);
2478
179
  }
2479
180
  }
2480
- // monacoParams for old number_with_scale not expected
2481
- // if (spec.viewSpec.monacoParams) {}
2482
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
2483
- console.warn(`[dynamic-forms] Unknown string number_with_scale view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
2484
- }
2485
- if (spec.viewSpec.placeholder) {
2486
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
2487
- }
2488
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
2489
- console.warn(`[dynamic-forms] Unknown string number_with_scale view spec key: "hidden"`);
2490
- }
2491
- // textContentParams for old number_with_scale not expected
2492
- // if (spec.viewSpec.textContentParams) {}
2493
- // fileInput for old number_with_scale not expected
2494
- // if (spec.viewSpec.fileInput) {}
2495
- // dateInput for old number_with_scale not expected
2496
- // if (spec.viewSpec.dateInput) {}
2497
- if (spec.viewSpec.copy) {
2498
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
2499
- }
2500
- // selectParams for old number_with_scale not expected
2501
- // if (spec.viewSpec.selectParams) {}
2502
- // radioGroupParams for old number_with_scale not expected
2503
- // if (spec.viewSpec.radioGroupParams) {}
2504
- if (spec.viewSpec.inputProps) {
2505
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
2506
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
2507
- });
2508
- }
2509
- if (spec.viewSpec.layoutProps) {
2510
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
2511
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
2512
- });
181
+ },
182
+ monacoParams: (spec, mutableSchema) => {
183
+ if (spec.type === core_1.SpecTypes.String && spec.viewSpec.monacoParams) {
184
+ if (spec.viewSpec.monacoParams.language) {
185
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.language', spec.viewSpec.monacoParams.language);
186
+ }
187
+ if (spec.viewSpec.monacoParams.fontSize) {
188
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.options.fontSize', spec.viewSpec.monacoParams.fontSize);
189
+ }
2513
190
  }
2514
- // generateRandomValueButton for old number_with_scale not expected
2515
- // if (spec.viewSpec.generateRandomValueButton) {}
2516
191
  },
2517
- monaco_input: (spec, mutableSchema, ctx) => {
2518
- var _a;
2519
- if (spec.defaultValue !== undefined) {
2520
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
192
+ hideValues: (spec, mutableSchema) => {
193
+ if (spec.type === core_1.SpecTypes.String && spec.viewSpec.hideValues) {
194
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.hideValues', spec.viewSpec.hideValues);
2521
195
  }
2522
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
2523
- if (spec.required) {
2524
- (0, set_1.default)(mutableSchema, 'allOf', [
2525
- ...(mutableSchema.allOf || []),
2526
- { not: { enum: [null, undefined, '', false] } },
2527
- ]);
2528
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
196
+ },
197
+ textContentParams: (spec, mutableSchema) => {
198
+ if (spec.type !== core_1.SpecTypes.String || !spec.viewSpec.textContentParams) {
199
+ return;
2529
200
  }
2530
- if (spec.maxLength) {
2531
- const maxLength = Number(spec.maxLength);
2532
- if (!isNaN(maxLength)) {
2533
- (0, set_1.default)(mutableSchema, 'maxLength', maxLength);
201
+ const textContentParams = spec.viewSpec.textContentParams;
202
+ if (textContentParams.themeAlert) {
203
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.theme', textContentParams.themeAlert);
204
+ if (textContentParams.text) {
205
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.message', textContentParams.text);
2534
206
  }
2535
- }
2536
- if (spec.minLength) {
2537
- const minLength = Number(spec.minLength);
2538
- if (!isNaN(minLength)) {
2539
- (0, set_1.default)(mutableSchema, 'minLength', minLength);
207
+ if (textContentParams.titleAlert) {
208
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.title', textContentParams.titleAlert);
2540
209
  }
2541
- }
2542
- // pattern for old monaco_input not expected
2543
- // if (spec.pattern) {}
2544
- // patternError for old monaco_input not expected
2545
- // if (spec.patternError) {}
2546
- // enum for old monaco_input not expected
2547
- // if (spec.enum) {}
2548
- // description for old monaco_input not expected
2549
- // if (spec.description) {}
2550
- if (spec.validator && spec.validator !== 'base') {
2551
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
2552
- }
2553
- if (spec.viewSpec.disabled) {
2554
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
2555
- }
2556
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
2557
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'monaco');
2558
- if (spec.viewSpec.layout) {
2559
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
2560
- if (layoutRule) {
2561
- layoutRule(spec, mutableSchema, ctx);
210
+ if (textContentParams.viewAlert) {
211
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.view', textContentParams.viewAlert);
2562
212
  }
2563
- else if (process.env.NODE_ENV !== 'production') {
2564
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
213
+ }
214
+ else if (textContentParams.themeLabel) {
215
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.theme', textContentParams.themeLabel);
216
+ if (textContentParams.text) {
217
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.title', textContentParams.text);
2565
218
  }
2566
219
  }
2567
- if (spec.viewSpec.layoutTitle) {
2568
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
220
+ else if (textContentParams.text) {
221
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.title', textContentParams.text);
2569
222
  }
2570
- if (spec.viewSpec.layoutDescription) {
2571
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
223
+ if (textContentParams.icon) {
224
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.iconName', textContentParams.icon);
2572
225
  }
2573
- if (spec.viewSpec.layoutOpen !== undefined) {
2574
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
226
+ if (textContentParams.iconColor) {
227
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.iconProps.color', textContentParams.iconColor);
2575
228
  }
2576
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
2577
- console.warn(`[dynamic-forms] Unknown string monaco_input view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
229
+ },
230
+ fileInput: (spec, mutableSchema) => {
231
+ if (spec.type === core_1.SpecTypes.String && spec.viewSpec.fileInput) {
232
+ if (spec.viewSpec.fileInput.accept) {
233
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.accept', [
234
+ spec.viewSpec.fileInput.accept,
235
+ ]);
236
+ }
237
+ if (spec.viewSpec.fileInput.readAsMethod) {
238
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.readAsMethod', spec.viewSpec.fileInput.readAsMethod);
239
+ }
2578
240
  }
2579
- // sizeParams for old monaco_input not expected
2580
- // if (spec.viewSpec.sizeParams) {}
2581
- if (spec.viewSpec.monacoParams) {
2582
- if (spec.viewSpec.monacoParams.language) {
2583
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.language', spec.viewSpec.monacoParams.language);
241
+ },
242
+ dateInput: (spec, mutableSchema) => {
243
+ if (spec.type === core_1.SpecTypes.String && spec.viewSpec.dateInput) {
244
+ if (spec.viewSpec.dateInput.outputFormat) {
245
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.outputFormat', spec.viewSpec.dateInput.outputFormat);
2584
246
  }
2585
- if (spec.viewSpec.monacoParams.fontSize) {
2586
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.options.fontSize', spec.viewSpec.monacoParams.fontSize);
247
+ if (spec.viewSpec.dateInput.printFormat) {
248
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.format', spec.viewSpec.dateInput.printFormat);
2587
249
  }
2588
- if (process.env.NODE_ENV !== 'production') {
2589
- [
2590
- 'headerIconSize',
2591
- 'headerIconIndent',
2592
- 'headerTitleVariant',
2593
- 'headerDialogButtonSize',
2594
- 'headerDialogIconSize',
2595
- ].forEach((key) => {
2596
- var _a;
2597
- if (((_a = spec.viewSpec.monacoParams) === null || _a === void 0 ? void 0 : _a[key]) !== undefined) {
2598
- console.warn(`[dynamic-forms] Unknown string monaco_input view spec key: "monacoParams.${key}", value - ${spec.viewSpec.monacoParams[key]}`);
2599
- }
2600
- });
250
+ if (spec.viewSpec.dateInput.timeZone) {
251
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.timeZone', spec.viewSpec.dateInput.timeZone);
2601
252
  }
2602
253
  }
2603
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
2604
- console.warn(`[dynamic-forms] Unknown string monaco_input view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
2605
- }
2606
- if (spec.viewSpec.placeholder && process.env.NODE_ENV !== 'production') {
2607
- console.warn(`[dynamic-forms] Unknown string monaco_input view spec key: "placeholder", value - ${spec.viewSpec.placeholder}`);
2608
- }
2609
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
2610
- console.warn(`[dynamic-forms] Unknown string monaco_input view spec key: "hidden"`);
254
+ },
255
+ radioGroupParams: (spec, mutableSchema) => {
256
+ if (spec.type === core_1.SpecTypes.String && spec.viewSpec.radioGroupParams) {
257
+ if (spec.viewSpec.radioGroupParams.direction) {
258
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.direction', spec.viewSpec.radioGroupParams.direction);
259
+ }
260
+ if (spec.viewSpec.radioGroupParams.disabled) {
261
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.optionsDisabled', spec.viewSpec.radioGroupParams.disabled);
262
+ }
2611
263
  }
2612
- // textContentParams for old monaco_input not expected
2613
- // if (spec.viewSpec.textContentParams) {}
2614
- // fileInput for old monaco_input not expected
2615
- // if (spec.viewSpec.fileInput) {}
2616
- // dateInput for old monaco_input not expected
2617
- // if (spec.viewSpec.dateInput) {}
2618
- if (spec.viewSpec.copy) {
2619
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
264
+ },
265
+ generateRandomValueButton: (spec, mutableSchema) => {
266
+ if (spec.type === core_1.SpecTypes.String && spec.viewSpec.generateRandomValueButton) {
267
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.generateRandomValueButton', true);
2620
268
  }
2621
- // selectParams for old monaco_input not expected
2622
- // if (spec.viewSpec.selectParams) {}
2623
- // radioGroupParams for old monaco_input not expected
2624
- // if (spec.viewSpec.radioGroupParams) {}
269
+ },
270
+ inputProps: (spec, mutableSchema) => {
2625
271
  if (spec.viewSpec.inputProps) {
2626
272
  Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
2627
273
  (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
2628
274
  });
2629
275
  }
276
+ },
277
+ layoutProps: (spec, mutableSchema) => {
2630
278
  if (spec.viewSpec.layoutProps) {
2631
279
  Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
2632
280
  (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
2633
281
  });
2634
282
  }
2635
- // generateRandomValueButton for old monaco_input not expected
2636
- // if (spec.viewSpec.generateRandomValueButton) {}
2637
283
  },
2638
- text_content: (spec, mutableSchema, ctx) => {
2639
- var _a;
2640
- if (spec.defaultValue !== undefined) {
2641
- (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
2642
- }
2643
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
2644
- // required for old text_content not expected
2645
- // if (spec.required) {}
2646
- // maxLength for old text_content not expected
2647
- // if (spec.maxLength) {}
2648
- // minLength for old text_content not expected
2649
- // if (spec.minLength) {}
2650
- // pattern for old text_content not expected
2651
- // if (spec.pattern) {}
2652
- // patternError for old text_content not expected
2653
- // if (spec.patternError) {}
2654
- // enum for old text_content not expected
2655
- // if (spec.enum) {}
2656
- // description for old text_content not expected
2657
- // if (spec.description) {}
2658
- // validator for old text_content not expected
2659
- // if (spec.validator) {}
2660
- // disabled for old text_content not expected
2661
- // if (spec.viewSpec.disabled) {}
2662
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
2663
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'text_content');
2664
- if (spec.viewSpec.layout) {
2665
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
2666
- if (layoutRule) {
2667
- layoutRule(spec, mutableSchema, ctx);
2668
- }
2669
- else if (process.env.NODE_ENV !== 'production') {
2670
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
284
+ // eslint-disable-next-line complexity -- old viewSpec.type mapping, isolated per viewType
285
+ type: (spec, mutableSchema) => {
286
+ if (spec.viewSpec.type === 'oneof') {
287
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
288
+ if (spec.type === core_1.SpecTypes.Object) {
289
+ const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
290
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.withIndent', true);
291
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
292
+ Object.keys(spec.properties || {}).forEach((key) => {
293
+ if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
294
+ (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
295
+ }
296
+ });
297
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
298
+ if (spec.viewSpec.layoutTitle) {
299
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
300
+ }
301
+ if (spec.viewSpec.layoutDescription) {
302
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
303
+ }
304
+ if (spec.viewSpec.placeholder) {
305
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
306
+ }
307
+ if (spec.description && Object.keys(spec.description).length) {
308
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
309
+ }
310
+ else if (spec.properties) {
311
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', Object.fromEntries(Object.entries(spec.properties).map(([key, childSpec]) => [
312
+ key,
313
+ childSpec.viewSpec.layoutTitle || key,
314
+ ])));
315
+ }
316
+ if (booleanMap) {
317
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.booleanToKey', booleanMap);
318
+ }
319
+ if (toggler === 'checkbox' || toggler === 'switch') {
320
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Boolean);
321
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Boolean);
322
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', toggler === 'switch' ? 'switch' : 'base');
323
+ }
324
+ else {
325
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.String);
326
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.String);
327
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', toggler === 'radio' ? 'radio_group' : 'segmented_radio_group');
328
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
329
+ }
2671
330
  }
2672
331
  }
2673
- if (spec.viewSpec.layoutTitle) {
2674
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
2675
- }
2676
- if (spec.viewSpec.layoutDescription) {
2677
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
332
+ else if (spec.viewSpec.type === 'oneof_flat') {
333
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
334
+ if (spec.type === core_1.SpecTypes.Object) {
335
+ const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
336
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
337
+ Object.keys(spec.properties || {}).forEach((key) => {
338
+ if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
339
+ (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
340
+ }
341
+ });
342
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
343
+ if (spec.viewSpec.layoutTitle) {
344
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
345
+ }
346
+ if (spec.viewSpec.layoutDescription) {
347
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
348
+ }
349
+ if (spec.viewSpec.placeholder) {
350
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
351
+ }
352
+ if (spec.description && Object.keys(spec.description).length) {
353
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
354
+ }
355
+ else if (spec.properties) {
356
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', Object.fromEntries(Object.entries(spec.properties).map(([key, childSpec]) => [
357
+ key,
358
+ childSpec.viewSpec.layoutTitle || key,
359
+ ])));
360
+ }
361
+ if (booleanMap) {
362
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.booleanToKey', booleanMap);
363
+ }
364
+ if (toggler === 'checkbox' || toggler === 'switch') {
365
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Boolean);
366
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Boolean);
367
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', toggler === 'switch' ? 'switch' : 'base');
368
+ }
369
+ else {
370
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.String);
371
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.String);
372
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', toggler === 'radio' ? 'radio_group' : 'segmented_radio_group');
373
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
374
+ }
375
+ }
2678
376
  }
2679
- if (spec.viewSpec.layoutOpen !== undefined) {
2680
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
2681
- }
2682
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
2683
- console.warn(`[dynamic-forms] Unknown string text_content view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
2684
- }
2685
- // sizeParams for old text_content not expected
2686
- // if (spec.viewSpec.sizeParams) {}
2687
- // monacoParams for old text_content not expected
2688
- // if (spec.viewSpec.monacoParams) {}
2689
- // hideValues for old text_content not expected
2690
- // if (spec.viewSpec.hideValues) {}
2691
- // placeholder for old text_content not expected
2692
- // if (spec.viewSpec.placeholder) {}
2693
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
2694
- console.warn(`[dynamic-forms] Unknown string text_content view spec key: "hidden"`);
2695
- }
2696
- if (spec.viewSpec.textContentParams) {
2697
- // the new kit splits the old text_content into text_content, alert and label entities
2698
- if (spec.viewSpec.textContentParams.themeAlert) {
2699
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'alert');
2700
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.theme', spec.viewSpec.textContentParams.themeAlert);
2701
- if (spec.viewSpec.textContentParams.text) {
2702
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.message', spec.viewSpec.textContentParams.text);
377
+ else if (spec.viewSpec.type === 'card_oneof') {
378
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
379
+ if (spec.type === core_1.SpecTypes.Object) {
380
+ const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
381
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'card');
382
+ Object.keys(spec.properties || {}).forEach((key) => {
383
+ if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
384
+ (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
385
+ }
386
+ });
387
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
388
+ if (spec.viewSpec.layoutTitle) {
389
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
390
+ }
391
+ if (spec.viewSpec.layoutDescription) {
392
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
2703
393
  }
2704
- if (spec.viewSpec.textContentParams.titleAlert) {
2705
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.title', spec.viewSpec.textContentParams.titleAlert);
394
+ if (spec.viewSpec.placeholder) {
395
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
2706
396
  }
2707
- if (spec.viewSpec.textContentParams.viewAlert) {
2708
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.view', spec.viewSpec.textContentParams.viewAlert);
397
+ if (spec.description && Object.keys(spec.description).length) {
398
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
399
+ }
400
+ else if (spec.properties) {
401
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', Object.fromEntries(Object.entries(spec.properties).map(([key, childSpec]) => [
402
+ key,
403
+ childSpec.viewSpec.layoutTitle || key,
404
+ ])));
405
+ }
406
+ if (booleanMap) {
407
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.booleanToKey', booleanMap);
408
+ }
409
+ if (toggler === 'checkbox' || toggler === 'switch') {
410
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Boolean);
411
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Boolean);
412
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', toggler === 'switch' ? 'switch' : 'base');
413
+ }
414
+ else {
415
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.String);
416
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.String);
417
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', toggler === 'select' ? 'select' : 'segmented_radio_group');
418
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
2709
419
  }
2710
420
  }
2711
- else if (spec.viewSpec.textContentParams.themeLabel) {
2712
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'label');
2713
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.theme', spec.viewSpec.textContentParams.themeLabel);
2714
- if (spec.viewSpec.textContentParams.text) {
2715
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.title', spec.viewSpec.textContentParams.text);
421
+ }
422
+ else if (spec.viewSpec.type === 'multi_oneof') {
423
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'few_of_nested');
424
+ if (spec.type === core_1.SpecTypes.Object) {
425
+ const { toggler } = spec.viewSpec.oneOfParams || {};
426
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.withIndent', true);
427
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
428
+ Object.keys(spec.properties || {}).forEach((key) => {
429
+ if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
430
+ (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
431
+ }
432
+ });
433
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
434
+ if (spec.viewSpec.layoutTitle) {
435
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
436
+ }
437
+ if (spec.viewSpec.layoutDescription) {
438
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
439
+ }
440
+ if (spec.viewSpec.placeholder) {
441
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
442
+ }
443
+ if (spec.description && Object.keys(spec.description).length) {
444
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
445
+ }
446
+ else if (spec.properties) {
447
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', Object.fromEntries(Object.entries(spec.properties).map(([key, childSpec]) => [
448
+ key,
449
+ childSpec.viewSpec.layoutTitle || key,
450
+ ])));
451
+ }
452
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Array);
453
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Array);
454
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', toggler === 'checkbox' ? 'checkbox_group' : 'select');
455
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
456
+ }
457
+ }
458
+ else if (spec.viewSpec.type === 'multi_oneof_flat') {
459
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'few_of_nested');
460
+ if (spec.type === core_1.SpecTypes.Object) {
461
+ const { toggler } = spec.viewSpec.oneOfParams || {};
462
+ (0, set_1.default)(mutableSchema, 'nodeParameters.layout', 'transparent');
463
+ Object.keys(spec.properties || {}).forEach((key) => {
464
+ if (!(0, get_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'])) {
465
+ (0, set_1.default)(mutableSchema, ['properties', key, 'nodeParameters', 'layout'], 'transparent');
466
+ }
467
+ });
468
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.layout', 'row');
469
+ if (spec.viewSpec.layoutTitle) {
470
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.title', spec.viewSpec.layoutTitle);
471
+ }
472
+ if (spec.viewSpec.layoutDescription) {
473
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.description', spec.viewSpec.layoutDescription);
2716
474
  }
475
+ if (spec.viewSpec.placeholder) {
476
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
477
+ }
478
+ if (spec.description && Object.keys(spec.description).length) {
479
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', spec.description);
480
+ }
481
+ else if (spec.properties) {
482
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entityProps.enumDescriptions', Object.fromEntries(Object.entries(spec.properties).map(([key, childSpec]) => [
483
+ key,
484
+ childSpec.viewSpec.layoutTitle || key,
485
+ ])));
486
+ }
487
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.type', core_2.JsonSchemaType.Array);
488
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.type', core_2.NodeType.Array);
489
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.nodeParameters.entity', toggler === 'checkbox' ? 'checkbox_group' : 'select');
490
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
2717
491
  }
2718
- else if (spec.viewSpec.textContentParams.text) {
2719
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.title', spec.viewSpec.textContentParams.text);
492
+ }
493
+ else if (spec.viewSpec.type === 'object_value') {
494
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'dot_value');
495
+ }
496
+ else if (spec.viewSpec.type === 'text_content') {
497
+ const textContentParams = spec.type === core_1.SpecTypes.String ? spec.viewSpec.textContentParams : undefined;
498
+ if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeAlert) {
499
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'alert');
2720
500
  }
2721
- if (spec.viewSpec.textContentParams.icon) {
2722
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.iconName', spec.viewSpec.textContentParams.icon);
501
+ else if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeLabel) {
502
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'label');
2723
503
  }
2724
- if (spec.viewSpec.textContentParams.iconColor) {
2725
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.iconProps.color', spec.viewSpec.textContentParams.iconColor);
504
+ else {
505
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'text_content');
2726
506
  }
2727
507
  }
2728
- // fileInput for old text_content not expected
2729
- // if (spec.viewSpec.fileInput) {}
2730
- // dateInput for old text_content not expected
2731
- // if (spec.viewSpec.dateInput) {}
2732
- // copy for old text_content not expected
2733
- // if (spec.viewSpec.copy) {}
2734
- // selectParams for old text_content not expected
2735
- // if (spec.viewSpec.selectParams) {}
2736
- // radioGroupParams for old text_content not expected
2737
- // if (spec.viewSpec.radioGroupParams) {}
2738
- if (spec.viewSpec.inputProps) {
2739
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
2740
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
2741
- });
508
+ else if (spec.viewSpec.type === 'date_input') {
509
+ (0, set_1.default)(mutableSchema, 'type', undefined);
510
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'date');
511
+ (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Any);
2742
512
  }
2743
- if (spec.viewSpec.layoutProps) {
2744
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
2745
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
2746
- });
513
+ else if (spec.viewSpec.type === 'file_input') {
514
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'file');
515
+ }
516
+ else if (spec.viewSpec.type === 'monaco_input') {
517
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'monaco');
518
+ }
519
+ else if (spec.viewSpec.type === 'number_with_scale') {
520
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'string_number_with_scale');
521
+ }
522
+ else if (spec.viewSpec.type === 'range_input_picker') {
523
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', spec.type === core_1.SpecTypes.Number ? 'slider' : 'range_input');
524
+ }
525
+ else {
526
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', spec.viewSpec.type);
2747
527
  }
2748
- // generateRandomValueButton for old text_content not expected
2749
- // if (spec.viewSpec.generateRandomValueButton) {}
2750
528
  },
2751
- radio_group: (spec, mutableSchema, ctx) => {
2752
- var _a;
529
+ };
530
+ const specRules = {
531
+ defaultValue: (spec, mutableSchema) => {
2753
532
  if (spec.defaultValue !== undefined) {
2754
533
  (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
2755
534
  }
2756
- (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.String);
535
+ },
536
+ type: (spec, mutableSchema) => {
537
+ const specTypeToJsonSchemaType = {
538
+ [core_1.SpecTypes.Array]: core_2.JsonSchemaType.Array,
539
+ [core_1.SpecTypes.Boolean]: core_2.JsonSchemaType.Boolean,
540
+ [core_1.SpecTypes.Number]: core_2.JsonSchemaType.Number,
541
+ [core_1.SpecTypes.Object]: core_2.JsonSchemaType.Object,
542
+ [core_1.SpecTypes.String]: core_2.JsonSchemaType.String,
543
+ };
544
+ const specTypeToNodeType = {
545
+ [core_1.SpecTypes.Array]: core_2.NodeType.Array,
546
+ [core_1.SpecTypes.Boolean]: core_2.NodeType.Boolean,
547
+ [core_1.SpecTypes.Number]: core_2.NodeType.Number,
548
+ [core_1.SpecTypes.Object]: core_2.NodeType.Object,
549
+ [core_1.SpecTypes.String]: core_2.NodeType.String,
550
+ };
551
+ if (spec.type) {
552
+ (0, set_1.default)(mutableSchema, 'type', specTypeToJsonSchemaType[spec.type]);
553
+ (0, set_1.default)(mutableSchema, 'nodeParameters.type', specTypeToNodeType[spec.type]);
554
+ }
555
+ },
556
+ required: (spec, mutableSchema) => {
2757
557
  if (spec.required) {
2758
558
  (0, set_1.default)(mutableSchema, 'allOf', [
2759
559
  ...(mutableSchema.allOf || []),
2760
560
  { not: { enum: [null, undefined, '', false] } },
2761
561
  ]);
2762
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.required', true);
2763
- }
2764
- // maxLength for old radio_group not expected
2765
- // if (spec.maxLength) {}
2766
- // minLength for old radio_group not expected
2767
- // if (spec.minLength) {}
2768
- // pattern for old radio_group not expected
2769
- // if (spec.pattern) {}
2770
- // patternError for old radio_group not expected
2771
- // if (spec.patternError) {}
2772
- if (spec.enum) {
2773
- (0, set_1.default)(mutableSchema, 'enum', spec.enum);
562
+ (0, set_1.default)(mutableSchema, 'nodeParameters.flags.required', true);
2774
563
  }
2775
- if (spec.description) {
2776
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.enumDescriptions', spec.description);
564
+ },
565
+ maxLength: (spec, mutableSchema) => {
566
+ if (spec.type === core_1.SpecTypes.Array && spec.maxLength !== undefined) {
567
+ const maxItems = Number(spec.maxLength);
568
+ if (!Number.isNaN(maxItems)) {
569
+ (0, set_1.default)(mutableSchema, 'maxItems', maxItems);
570
+ }
2777
571
  }
2778
- if (spec.validator && spec.validator !== 'base') {
2779
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.validator', spec.validator);
572
+ if (spec.type === core_1.SpecTypes.String && spec.maxLength !== undefined) {
573
+ const maxLength = Number(spec.maxLength);
574
+ if (!Number.isNaN(maxLength)) {
575
+ (0, set_1.default)(mutableSchema, 'maxLength', maxLength);
576
+ }
2780
577
  }
2781
- if (spec.viewSpec.disabled) {
2782
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.disabled', true);
2783
- }
2784
- (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.String);
2785
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'radio_group');
2786
- if (spec.viewSpec.layout) {
2787
- const layoutRule = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules) === null || _a === void 0 ? void 0 : _a[spec.viewSpec.layout];
2788
- if (layoutRule) {
2789
- layoutRule(spec, mutableSchema, ctx);
578
+ },
579
+ minLength: (spec, mutableSchema) => {
580
+ if (spec.type === core_1.SpecTypes.Array && spec.minLength !== undefined) {
581
+ const minItems = Number(spec.minLength);
582
+ if (!Number.isNaN(minItems)) {
583
+ (0, set_1.default)(mutableSchema, 'minItems', minItems);
2790
584
  }
2791
- else if (process.env.NODE_ENV !== 'production') {
2792
- console.warn(`[dynamic-forms] Unknown view spec layout: ${spec.viewSpec.layout}`);
585
+ }
586
+ if (spec.type === core_1.SpecTypes.String && spec.minLength !== undefined) {
587
+ const minLength = Number(spec.minLength);
588
+ if (!Number.isNaN(minLength)) {
589
+ (0, set_1.default)(mutableSchema, 'minLength', minLength);
2793
590
  }
2794
591
  }
2795
- if (spec.viewSpec.layoutTitle) {
2796
- (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
592
+ },
593
+ items: (spec, mutableSchema, rules) => {
594
+ if (spec.type === core_1.SpecTypes.Array && spec.items) {
595
+ const childSchema = specToJsonSchema(spec.items, 'items' in mutableSchema &&
596
+ mutableSchema.items &&
597
+ !Array.isArray(mutableSchema.items)
598
+ ? Object.assign({}, mutableSchema.items) : {}, rules);
599
+ (0, set_1.default)(mutableSchema, 'items', childSchema);
2797
600
  }
2798
- if (spec.viewSpec.layoutDescription) {
2799
- (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
601
+ },
602
+ enum: (spec, mutableSchema) => {
603
+ var _a, _b, _c, _d;
604
+ if (spec.type === core_1.SpecTypes.Array &&
605
+ ((_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length) &&
606
+ (((_b = spec.items) === null || _b === void 0 ? void 0 : _b.type) === core_1.SpecTypes.String || !((_c = spec.items) === null || _c === void 0 ? void 0 : _c.type))) {
607
+ (0, set_1.default)(mutableSchema, 'items.enum', spec.enum);
2800
608
  }
2801
- if (spec.viewSpec.layoutOpen !== undefined) {
2802
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.open', spec.viewSpec.layoutOpen);
2803
- }
2804
- if (spec.viewSpec.link && process.env.NODE_ENV !== 'production') {
2805
- console.warn(`[dynamic-forms] Unknown string radio_group view spec key: "link", value - ${JSON.stringify(spec.viewSpec.link, null, 2)}`);
2806
- }
2807
- // sizeParams for old radio_group not expected
2808
- // if (spec.viewSpec.sizeParams) {}
2809
- // monacoParams for old radio_group not expected
2810
- // if (spec.viewSpec.monacoParams) {}
2811
- if (spec.viewSpec.hideValues && process.env.NODE_ENV !== 'production') {
2812
- console.warn(`[dynamic-forms] Unknown string radio_group view spec key: "hideValues", value - ${JSON.stringify(spec.viewSpec.hideValues)}`);
2813
- }
2814
- if (spec.viewSpec.placeholder && process.env.NODE_ENV !== 'production') {
2815
- console.warn(`[dynamic-forms] Unknown string radio_group view spec key: "placeholder", value - ${spec.viewSpec.placeholder}`);
2816
- }
2817
- if (spec.viewSpec.hidden && process.env.NODE_ENV !== 'production') {
2818
- console.warn(`[dynamic-forms] Unknown string radio_group view spec key: "hidden"`);
2819
- }
2820
- // textContentParams for old radio_group not expected
2821
- // if (spec.viewSpec.textContentParams) {}
2822
- // fileInput for old radio_group not expected
2823
- // if (spec.viewSpec.fileInput) {}
2824
- // dateInput for old radio_group not expected
2825
- // if (spec.viewSpec.dateInput) {}
2826
- if (spec.viewSpec.copy) {
2827
- (0, set_1.default)(mutableSchema, 'nodeParameters.layoutProps.copy', true);
2828
- }
2829
- // selectParams for old radio_group not expected
2830
- // if (spec.viewSpec.selectParams) {}
2831
- if (spec.viewSpec.radioGroupParams) {
2832
- if (spec.viewSpec.radioGroupParams.direction) {
2833
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.direction', spec.viewSpec.radioGroupParams.direction);
2834
- }
2835
- if (spec.viewSpec.radioGroupParams.disabled) {
2836
- (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.optionsDisabled', spec.viewSpec.radioGroupParams.disabled);
2837
- }
609
+ if (spec.type === core_1.SpecTypes.String && ((_d = spec.enum) === null || _d === void 0 ? void 0 : _d.length)) {
610
+ (0, set_1.default)(mutableSchema, 'enum', spec.enum);
2838
611
  }
2839
- if (spec.viewSpec.inputProps) {
2840
- Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
2841
- (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
2842
- });
612
+ },
613
+ description: (spec, mutableSchema) => {
614
+ if ('description' in spec && (0, isObject_1.default)(spec.description)) {
615
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.enumDescriptions', spec.description);
2843
616
  }
2844
- if (spec.viewSpec.layoutProps) {
2845
- Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
2846
- (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
2847
- });
617
+ },
618
+ validator: (spec, mutableSchema) => {
619
+ if (spec.validator && spec.validator !== 'base') {
620
+ (0, set_1.default)(mutableSchema, 'nodeParameters.validator', spec.validator);
2848
621
  }
2849
- // generateRandomValueButton for old radio_group not expected
2850
- // if (spec.viewSpec.generateRandomValueButton) {}
2851
622
  },
2852
- };
2853
- function specToJsonSchema(spec, jsonSchema, ctx) {
2854
- const context = {
2855
- arrayInputTypeRules: Object.assign(Object.assign({}, exports.arrayInputTypeRules), ctx === null || ctx === void 0 ? void 0 : ctx.arrayInputTypeRules),
2856
- booleanInputTypeRules: Object.assign(Object.assign({}, exports.booleanInputTypeRules), ctx === null || ctx === void 0 ? void 0 : ctx.booleanInputTypeRules),
2857
- numberInputTypeRules: Object.assign(Object.assign({}, exports.numberInputTypeRules), ctx === null || ctx === void 0 ? void 0 : ctx.numberInputTypeRules),
2858
- objectInputTypeRules: Object.assign(Object.assign({}, exports.objectInputTypeRules), ctx === null || ctx === void 0 ? void 0 : ctx.objectInputTypeRules),
2859
- stringInputTypeRules: Object.assign(Object.assign({}, exports.stringInputTypeRules), ctx === null || ctx === void 0 ? void 0 : ctx.stringInputTypeRules),
2860
- layoutRules: Object.assign(Object.assign({}, exports.layoutRules), ctx === null || ctx === void 0 ? void 0 : ctx.layoutRules),
2861
- };
2862
- const schema = jsonSchema || {};
2863
- if ((0, core_1.isArraySpec)(spec)) {
2864
- if (spec.viewSpec.type) {
2865
- const rule = context.arrayInputTypeRules[spec.viewSpec.type];
2866
- if (rule) {
2867
- rule(spec, schema, context);
2868
- }
2869
- else if (process.env.NODE_ENV !== 'production') {
2870
- console.warn(`[dynamic-forms] Unknown array view spec type: ${spec.viewSpec.type}`);
623
+ maximum: (spec, mutableSchema) => {
624
+ if (spec.type === core_1.SpecTypes.Number && spec.maximum !== undefined) {
625
+ const maximum = Number(spec.maximum);
626
+ if (!Number.isNaN(maximum)) {
627
+ (0, set_1.default)(mutableSchema, 'maximum', maximum);
2871
628
  }
2872
629
  }
2873
- }
2874
- if ((0, core_1.isBooleanSpec)(spec)) {
2875
- if (spec.viewSpec.type) {
2876
- const rule = context.booleanInputTypeRules[spec.viewSpec.type];
2877
- if (rule) {
2878
- rule(spec, schema, context);
2879
- }
2880
- else if (process.env.NODE_ENV !== 'production') {
2881
- console.warn(`[dynamic-forms] Unknown boolean view spec type: ${spec.viewSpec.type}`);
630
+ if (spec.type === core_1.SpecTypes.String && 'maximum' in spec && spec.maximum !== undefined) {
631
+ const maximum = Number(spec.maximum);
632
+ if (!Number.isNaN(maximum)) {
633
+ (0, set_1.default)(mutableSchema, 'stringNumber.maximum', `${spec.maximum}`);
2882
634
  }
2883
635
  }
2884
- }
2885
- if ((0, core_1.isNumberSpec)(spec)) {
2886
- if (spec.viewSpec.type) {
2887
- const rule = context.numberInputTypeRules[spec.viewSpec.type];
2888
- if (rule) {
2889
- rule(spec, schema, context);
2890
- }
2891
- else if (process.env.NODE_ENV !== 'production') {
2892
- console.warn(`[dynamic-forms] Unknown number view spec type: ${spec.viewSpec.type}`);
636
+ },
637
+ minimum: (spec, mutableSchema) => {
638
+ if (spec.type === core_1.SpecTypes.Number && spec.minimum !== undefined) {
639
+ const minimum = Number(spec.minimum);
640
+ if (!Number.isNaN(minimum)) {
641
+ (0, set_1.default)(mutableSchema, 'minimum', minimum);
2893
642
  }
2894
643
  }
2895
- }
2896
- if ((0, core_1.isObjectSpec)(spec)) {
2897
- if (spec.viewSpec.type) {
2898
- const rule = context.objectInputTypeRules[spec.viewSpec.type];
2899
- if (rule) {
2900
- rule(spec, schema, context);
2901
- }
2902
- else if (process.env.NODE_ENV !== 'production') {
2903
- console.warn(`[dynamic-forms] Unknown object view spec type: ${spec.viewSpec.type}`);
644
+ if (spec.type === core_1.SpecTypes.String && 'minimum' in spec && spec.minimum !== undefined) {
645
+ const minimum = Number(spec.minimum);
646
+ if (!Number.isNaN(minimum)) {
647
+ (0, set_1.default)(mutableSchema, 'stringNumber.minimum', `${spec.minimum}`);
2904
648
  }
2905
649
  }
2906
- }
2907
- if ((0, core_1.isStringSpec)(spec)) {
2908
- if (spec.viewSpec.type) {
2909
- const rule = context.stringInputTypeRules[spec.viewSpec.type];
2910
- if (rule) {
2911
- rule(spec, schema, context);
2912
- }
2913
- else if (process.env.NODE_ENV !== 'production') {
2914
- console.warn(`[dynamic-forms] Unknown string view spec type: ${spec.viewSpec.type}`);
2915
- }
650
+ },
651
+ format: (spec, mutableSchema) => {
652
+ if (spec.type === core_1.SpecTypes.Number && spec.format === 'int64') {
653
+ (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Integer);
654
+ }
655
+ },
656
+ properties: (spec, mutableSchema, rules) => {
657
+ if (spec.type === core_1.SpecTypes.Object && spec.properties) {
658
+ Object.entries(spec.properties).forEach(([key, childSpec]) => {
659
+ const childSchema = specToJsonSchema(childSpec, Object.assign({}, ((0, get_1.default)(mutableSchema, ['properties', key]) || {})), rules);
660
+ (0, set_1.default)(mutableSchema, ['properties', key], childSchema);
661
+ });
662
+ }
663
+ },
664
+ pattern: (spec, mutableSchema) => {
665
+ if (spec.type === core_1.SpecTypes.String && spec.pattern) {
666
+ (0, set_1.default)(mutableSchema, 'pattern', spec.pattern);
667
+ }
668
+ },
669
+ patternError: (spec, mutableSchema) => {
670
+ if (spec.type === core_1.SpecTypes.String && spec.patternError) {
671
+ (0, set_1.default)(mutableSchema, 'nodeParameters.errorMessages.pattern', spec.patternError);
2916
672
  }
2917
- }
2918
- return schema;
673
+ },
674
+ viewSpec: (spec, mutableSchema, rules) => {
675
+ Object.values(rules.viewSpecRules).forEach((rule) => rule(spec, mutableSchema, rules));
676
+ },
677
+ };
678
+ function specToJsonSchema(spec, mutableSchema = {}, rules) {
679
+ const mergedSpecRules = Object.assign(Object.assign({}, specRules), rules === null || rules === void 0 ? void 0 : rules.specRules);
680
+ const mergedViewSpecRules = Object.assign(Object.assign({}, viewSpecRules), rules === null || rules === void 0 ? void 0 : rules.viewSpecRules);
681
+ Object.values(mergedSpecRules).forEach((rule) => rule(spec, mutableSchema, { specRules: mergedSpecRules, viewSpecRules: mergedViewSpecRules }));
682
+ return mutableSchema;
2919
683
  }