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