@gravity-ui/dynamic-forms 5.29.1 → 5.29.2

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.
@@ -1,10 +1,14 @@
1
1
  import { type Spec } from '../../../core';
2
2
  import { type ErrorMessages, type JsonSchema } from '../../core';
3
- type Rules = Record<string, (spec: Spec, mutableSchema: JsonSchema, rules: {
3
+ type Rules = Record<string, (spec: Partial<Spec & {
4
+ viewSpec: Partial<Spec['viewSpec']>;
5
+ }> | null | undefined, mutableSchema: JsonSchema, rules: {
4
6
  specRules: Rules;
5
7
  viewSpecRules: Rules;
6
8
  }, errorMessages: ErrorMessages) => void>;
7
- export declare function specToJsonSchema(spec: Spec, mutableSchema?: JsonSchema, rules?: {
9
+ export declare function specToJsonSchema(spec: Partial<Spec & {
10
+ viewSpec: Partial<Spec['viewSpec']>;
11
+ }> | null | undefined, mutableSchema?: JsonSchema, rules?: {
8
12
  specRules: Rules;
9
13
  viewSpecRules: Rules;
10
14
  }, errorMessages?: ErrorMessages): JsonSchema;
@@ -9,12 +9,14 @@ const core_1 = require("../../../core");
9
9
  const core_2 = require("../../core");
10
10
  const viewSpecRules = {
11
11
  disabled: (spec, mutableSchema) => {
12
- if (spec.viewSpec.disabled) {
12
+ var _a;
13
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.disabled) {
13
14
  (0, set_1.default)(mutableSchema, 'nodeParameters.flags.disabled', true);
14
15
  }
15
16
  },
16
17
  layout: (spec, mutableSchema) => {
17
- const layout = spec.viewSpec.layout;
18
+ var _a;
19
+ const layout = (_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layout;
18
20
  if (!layout) {
19
21
  return;
20
22
  }
@@ -59,35 +61,38 @@ const viewSpecRules = {
59
61
  }
60
62
  },
61
63
  layoutTitle: (spec, mutableSchema) => {
62
- if (spec.viewSpec.layoutTitle) {
64
+ var _a;
65
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutTitle) {
63
66
  (0, set_1.default)(mutableSchema, 'title', spec.viewSpec.layoutTitle);
64
67
  }
65
68
  },
66
69
  layoutDescription: (spec, mutableSchema) => {
67
- if (spec.viewSpec.layoutDescription) {
70
+ var _a;
71
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutDescription) {
68
72
  (0, set_1.default)(mutableSchema, 'description', spec.viewSpec.layoutDescription);
69
73
  }
70
74
  },
71
75
  layoutOpen: (spec, mutableSchema) => {
72
- if (spec.viewSpec.layoutOpen !== undefined) {
76
+ var _a;
77
+ if (((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutOpen) !== undefined) {
73
78
  (0, set_1.default)(mutableSchema, 'nodeParameters.flags.open', spec.viewSpec.layoutOpen);
74
79
  }
75
80
  },
76
81
  itemLabel: (spec, mutableSchema) => {
77
- if ('itemLabel' in spec.viewSpec && spec.viewSpec.itemLabel) {
82
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'itemLabel' in spec.viewSpec && spec.viewSpec.itemLabel) {
78
83
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.addButtonText', spec.viewSpec.itemLabel);
79
84
  }
80
85
  },
81
86
  itemPrefix: (spec, mutableSchema) => {
82
- if ('itemPrefix' in spec.viewSpec && spec.viewSpec.itemPrefix) {
87
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'itemPrefix' in spec.viewSpec && spec.viewSpec.itemPrefix) {
83
88
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.itemPrefix', spec.viewSpec.itemPrefix);
84
89
  }
85
90
  },
86
91
  table: (spec, mutableSchema) => {
87
- var _a;
88
- if (spec.type === core_1.SpecTypes.Array &&
89
- spec.viewSpec.table &&
90
- ((_a = spec.items) === null || _a === void 0 ? void 0 : _a.type) === core_1.SpecTypes.Object) {
92
+ var _a, _b;
93
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Array &&
94
+ ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.table) &&
95
+ ((_b = spec === null || spec === void 0 ? void 0 : spec.items) === null || _b === void 0 ? void 0 : _b.type) === core_1.SpecTypes.Object) {
91
96
  const order = [];
92
97
  spec.viewSpec.table.forEach(({ description, label, property }) => {
93
98
  order.push(property);
@@ -102,32 +107,39 @@ const viewSpecRules = {
102
107
  }
103
108
  },
104
109
  link: (spec, mutableSchema) => {
105
- if (spec.viewSpec.link) {
110
+ var _a;
111
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.link) {
106
112
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.link', spec.viewSpec.link);
107
113
  }
108
114
  },
109
115
  placeholder: (spec, mutableSchema) => {
110
- if ('placeholder' in spec.viewSpec && spec.viewSpec.placeholder) {
116
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'placeholder' in spec.viewSpec && spec.viewSpec.placeholder) {
111
117
  if (spec.type === core_1.SpecTypes.String) {
112
118
  (0, set_1.default)(mutableSchema, 'examples', [spec.viewSpec.placeholder]);
113
119
  }
114
120
  else if (spec.type === core_1.SpecTypes.Array) {
115
121
  (0, set_1.default)(mutableSchema, 'examples', [[spec.viewSpec.placeholder]]);
116
122
  }
123
+ else {
124
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
125
+ }
117
126
  }
118
127
  },
119
128
  addButtonPosition: (spec, mutableSchema) => {
120
- if ('addButtonPosition' in spec.viewSpec && spec.viewSpec.addButtonPosition) {
129
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) &&
130
+ 'addButtonPosition' in spec.viewSpec &&
131
+ spec.viewSpec.addButtonPosition) {
121
132
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.addButtonPosition', spec.viewSpec.addButtonPosition);
122
133
  }
123
134
  },
124
135
  hidden: (spec, mutableSchema) => {
125
- if (spec.viewSpec.hidden) {
136
+ var _a;
137
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.hidden) {
126
138
  (0, set_1.default)(mutableSchema, 'nodeParameters.flags.hidden', true);
127
139
  }
128
140
  },
129
141
  selectParams: (spec, mutableSchema) => {
130
- if ('selectParams' in spec.viewSpec && spec.viewSpec.selectParams) {
142
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'selectParams' in spec.viewSpec && spec.viewSpec.selectParams) {
131
143
  if (spec.viewSpec.selectParams.filterPlaceholder) {
132
144
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.filterPlaceholder', spec.viewSpec.selectParams.filterPlaceholder);
133
145
  }
@@ -137,7 +149,8 @@ const viewSpecRules = {
137
149
  }
138
150
  },
139
151
  checkboxGroupParams: (spec, mutableSchema) => {
140
- if (spec.type === core_1.SpecTypes.Array && spec.viewSpec.checkboxGroupParams) {
152
+ var _a;
153
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Array && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.checkboxGroupParams)) {
141
154
  if (spec.viewSpec.checkboxGroupParams.placement) {
142
155
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.direction', spec.viewSpec.checkboxGroupParams.placement === 'vertical' ? 'column' : 'row');
143
156
  }
@@ -147,31 +160,35 @@ const viewSpecRules = {
147
160
  }
148
161
  },
149
162
  viewColor: (spec, mutableSchema) => {
150
- if (spec.type === core_1.SpecTypes.Boolean && spec.viewSpec.viewColor) {
163
+ var _a;
164
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Boolean && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.viewColor)) {
151
165
  (0, set_1.default)(mutableSchema, 'nodeParameters.overviewEntityProps.viewColor', spec.viewSpec.viewColor);
152
166
  }
153
167
  },
154
168
  copy: (spec, mutableSchema) => {
155
- if ('copy' in spec.viewSpec && spec.viewSpec.copy) {
169
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'copy' in spec.viewSpec && spec.viewSpec.copy) {
156
170
  (0, set_1.default)(mutableSchema, 'nodeParameters.flags.copy', true);
157
171
  }
158
172
  },
159
173
  order: (spec, mutableSchema) => {
160
- if (spec.type === core_1.SpecTypes.Object &&
161
- spec.viewSpec.order &&
174
+ var _a;
175
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Object &&
176
+ ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.order) &&
162
177
  Object.keys(spec.viewSpec.order).length) {
163
178
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.order', spec.viewSpec.order);
164
179
  }
165
180
  },
166
181
  delimiter: (spec, mutableSchema) => {
167
- if (spec.type === core_1.SpecTypes.Object &&
168
- spec.viewSpec.delimiter &&
182
+ var _a;
183
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Object &&
184
+ ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.delimiter) &&
169
185
  Object.keys(spec.viewSpec.delimiter).length) {
170
186
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.delimiter', spec.viewSpec.delimiter);
171
187
  }
172
188
  },
173
189
  sizeParams: (spec, mutableSchema) => {
174
- if (spec.type === core_1.SpecTypes.String && spec.viewSpec.sizeParams) {
190
+ var _a;
191
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.sizeParams)) {
175
192
  if (spec.viewSpec.sizeParams.defaultType) {
176
193
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.defaultType', spec.viewSpec.sizeParams.defaultType);
177
194
  }
@@ -184,7 +201,8 @@ const viewSpecRules = {
184
201
  }
185
202
  },
186
203
  monacoParams: (spec, mutableSchema) => {
187
- if (spec.type === core_1.SpecTypes.String && spec.viewSpec.monacoParams) {
204
+ var _a;
205
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.monacoParams)) {
188
206
  if (spec.viewSpec.monacoParams.language) {
189
207
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.language', spec.viewSpec.monacoParams.language);
190
208
  }
@@ -194,12 +212,14 @@ const viewSpecRules = {
194
212
  }
195
213
  },
196
214
  hideValues: (spec, mutableSchema) => {
197
- if (spec.type === core_1.SpecTypes.String && spec.viewSpec.hideValues) {
215
+ var _a;
216
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.hideValues)) {
198
217
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.hideValues', spec.viewSpec.hideValues);
199
218
  }
200
219
  },
201
220
  textContentParams: (spec, mutableSchema) => {
202
- if (spec.type !== core_1.SpecTypes.String || !spec.viewSpec.textContentParams) {
221
+ var _a;
222
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) !== core_1.SpecTypes.String || !((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.textContentParams)) {
203
223
  return;
204
224
  }
205
225
  const textContentParams = spec.viewSpec.textContentParams;
@@ -232,7 +252,8 @@ const viewSpecRules = {
232
252
  }
233
253
  },
234
254
  fileInput: (spec, mutableSchema) => {
235
- if (spec.type === core_1.SpecTypes.String && spec.viewSpec.fileInput) {
255
+ var _a;
256
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.fileInput)) {
236
257
  if (spec.viewSpec.fileInput.accept) {
237
258
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.accept', [
238
259
  spec.viewSpec.fileInput.accept,
@@ -244,7 +265,8 @@ const viewSpecRules = {
244
265
  }
245
266
  },
246
267
  dateInput: (spec, mutableSchema) => {
247
- if (spec.type === core_1.SpecTypes.String && spec.viewSpec.dateInput) {
268
+ var _a;
269
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.dateInput)) {
248
270
  if (spec.viewSpec.dateInput.outputFormat) {
249
271
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.outputFormat', spec.viewSpec.dateInput.outputFormat);
250
272
  }
@@ -257,7 +279,8 @@ const viewSpecRules = {
257
279
  }
258
280
  },
259
281
  radioGroupParams: (spec, mutableSchema) => {
260
- if (spec.type === core_1.SpecTypes.String && spec.viewSpec.radioGroupParams) {
282
+ var _a;
283
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.radioGroupParams)) {
261
284
  if (spec.viewSpec.radioGroupParams.direction) {
262
285
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.direction', spec.viewSpec.radioGroupParams.direction);
263
286
  }
@@ -267,19 +290,22 @@ const viewSpecRules = {
267
290
  }
268
291
  },
269
292
  generateRandomValueButton: (spec, mutableSchema) => {
270
- if (spec.type === core_1.SpecTypes.String && spec.viewSpec.generateRandomValueButton) {
293
+ var _a;
294
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.generateRandomValueButton)) {
271
295
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.generateRandomValueButton', true);
272
296
  }
273
297
  },
274
298
  inputProps: (spec, mutableSchema) => {
275
- if (spec.viewSpec.inputProps) {
299
+ var _a;
300
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.inputProps) {
276
301
  Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
277
302
  (0, set_1.default)(mutableSchema, `nodeParameters.entityProps.${key}`, value);
278
303
  });
279
304
  }
280
305
  },
281
306
  layoutProps: (spec, mutableSchema) => {
282
- if (spec.viewSpec.layoutProps) {
307
+ var _a;
308
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutProps) {
283
309
  Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
284
310
  (0, set_1.default)(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
285
311
  });
@@ -287,7 +313,8 @@ const viewSpecRules = {
287
313
  },
288
314
  // eslint-disable-next-line complexity -- old viewSpec.type mapping, isolated per viewType
289
315
  type: (spec, mutableSchema) => {
290
- if (spec.viewSpec.type === 'oneof') {
316
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
317
+ if (((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.type) === 'oneof') {
291
318
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
292
319
  if (spec.type === core_1.SpecTypes.Object) {
293
320
  const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
@@ -333,7 +360,7 @@ const viewSpecRules = {
333
360
  }
334
361
  }
335
362
  }
336
- else if (spec.viewSpec.type === 'oneof_flat') {
363
+ else if (((_b = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _b === void 0 ? void 0 : _b.type) === 'oneof_flat') {
337
364
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
338
365
  if (spec.type === core_1.SpecTypes.Object) {
339
366
  const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
@@ -378,7 +405,7 @@ const viewSpecRules = {
378
405
  }
379
406
  }
380
407
  }
381
- else if (spec.viewSpec.type === 'card_oneof') {
408
+ else if (((_c = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _c === void 0 ? void 0 : _c.type) === 'card_oneof') {
382
409
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
383
410
  if (spec.type === core_1.SpecTypes.Object) {
384
411
  const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
@@ -423,7 +450,7 @@ const viewSpecRules = {
423
450
  }
424
451
  }
425
452
  }
426
- else if (spec.viewSpec.type === 'multi_oneof') {
453
+ else if (((_d = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _d === void 0 ? void 0 : _d.type) === 'multi_oneof') {
427
454
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'few_of_nested');
428
455
  if (spec.type === core_1.SpecTypes.Object) {
429
456
  const { toggler } = spec.viewSpec.oneOfParams || {};
@@ -459,7 +486,7 @@ const viewSpecRules = {
459
486
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
460
487
  }
461
488
  }
462
- else if (spec.viewSpec.type === 'multi_oneof_flat') {
489
+ else if (((_e = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _e === void 0 ? void 0 : _e.type) === 'multi_oneof_flat') {
463
490
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'few_of_nested');
464
491
  if (spec.type === core_1.SpecTypes.Object) {
465
492
  const { toggler } = spec.viewSpec.oneOfParams || {};
@@ -494,10 +521,10 @@ const viewSpecRules = {
494
521
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
495
522
  }
496
523
  }
497
- else if (spec.viewSpec.type === 'object_value') {
524
+ else if (((_f = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _f === void 0 ? void 0 : _f.type) === 'object_value') {
498
525
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'dot_value');
499
526
  }
500
- else if (spec.viewSpec.type === 'text_content') {
527
+ else if (((_g = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _g === void 0 ? void 0 : _g.type) === 'text_content') {
501
528
  const textContentParams = spec.type === core_1.SpecTypes.String ? spec.viewSpec.textContentParams : undefined;
502
529
  if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeAlert) {
503
530
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'alert');
@@ -509,31 +536,31 @@ const viewSpecRules = {
509
536
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'text_content');
510
537
  }
511
538
  }
512
- else if (spec.viewSpec.type === 'date_input') {
539
+ else if (((_h = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _h === void 0 ? void 0 : _h.type) === 'date_input') {
513
540
  (0, set_1.default)(mutableSchema, 'type', undefined);
514
541
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'date');
515
542
  (0, set_1.default)(mutableSchema, 'nodeParameters.type', core_2.NodeType.Any);
516
543
  }
517
- else if (spec.viewSpec.type === 'file_input') {
544
+ else if (((_j = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _j === void 0 ? void 0 : _j.type) === 'file_input') {
518
545
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'file');
519
546
  }
520
- else if (spec.viewSpec.type === 'monaco_input') {
547
+ else if (((_k = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _k === void 0 ? void 0 : _k.type) === 'monaco_input') {
521
548
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'monaco_input');
522
549
  }
523
- else if (spec.viewSpec.type === 'number_with_scale') {
550
+ else if (((_l = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _l === void 0 ? void 0 : _l.type) === 'number_with_scale') {
524
551
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', 'string_number_with_scale');
525
552
  }
526
- else if (spec.viewSpec.type === 'range_input_picker') {
553
+ else if (((_m = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _m === void 0 ? void 0 : _m.type) === 'range_input_picker') {
527
554
  (0, set_1.default)(mutableSchema, 'nodeParameters.entity', spec.type === core_1.SpecTypes.Number ? 'slider' : 'range_input');
528
555
  }
529
556
  else {
530
- (0, set_1.default)(mutableSchema, 'nodeParameters.entity', spec.viewSpec.type);
557
+ (0, set_1.default)(mutableSchema, 'nodeParameters.entity', (_o = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _o === void 0 ? void 0 : _o.type);
531
558
  }
532
559
  },
533
560
  };
534
561
  const specRules = {
535
562
  defaultValue: (spec, mutableSchema) => {
536
- if (spec.defaultValue !== undefined) {
563
+ if ((spec === null || spec === void 0 ? void 0 : spec.defaultValue) !== undefined) {
537
564
  (0, set_1.default)(mutableSchema, 'default', spec.defaultValue);
538
565
  }
539
566
  },
@@ -552,13 +579,13 @@ const specRules = {
552
579
  [core_1.SpecTypes.Object]: core_2.NodeType.Object,
553
580
  [core_1.SpecTypes.String]: core_2.NodeType.String,
554
581
  };
555
- if (spec.type) {
582
+ if (spec === null || spec === void 0 ? void 0 : spec.type) {
556
583
  (0, set_1.default)(mutableSchema, 'type', specTypeToJsonSchemaType[spec.type]);
557
584
  (0, set_1.default)(mutableSchema, 'nodeParameters.type', specTypeToNodeType[spec.type]);
558
585
  }
559
586
  },
560
587
  required: (spec, mutableSchema, _rules, errorMessages) => {
561
- if (spec.required) {
588
+ if (spec === null || spec === void 0 ? void 0 : spec.required) {
562
589
  (0, set_1.default)(mutableSchema, 'allOf', [
563
590
  ...(mutableSchema.allOf || []),
564
591
  {
@@ -572,13 +599,13 @@ const specRules = {
572
599
  }
573
600
  },
574
601
  maxLength: (spec, mutableSchema) => {
575
- if (spec.type === core_1.SpecTypes.Array && spec.maxLength !== undefined) {
602
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Array && (spec === null || spec === void 0 ? void 0 : spec.maxLength) !== undefined) {
576
603
  const maxItems = Number(spec.maxLength);
577
604
  if (!Number.isNaN(maxItems)) {
578
605
  (0, set_1.default)(mutableSchema, 'maxItems', maxItems);
579
606
  }
580
607
  }
581
- if (spec.type === core_1.SpecTypes.String && spec.maxLength !== undefined) {
608
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && (spec === null || spec === void 0 ? void 0 : spec.maxLength) !== undefined) {
582
609
  const maxLength = Number(spec.maxLength);
583
610
  if (!Number.isNaN(maxLength)) {
584
611
  (0, set_1.default)(mutableSchema, 'maxLength', maxLength);
@@ -586,13 +613,13 @@ const specRules = {
586
613
  }
587
614
  },
588
615
  minLength: (spec, mutableSchema) => {
589
- if (spec.type === core_1.SpecTypes.Array && spec.minLength !== undefined) {
616
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Array && (spec === null || spec === void 0 ? void 0 : spec.minLength) !== undefined) {
590
617
  const minItems = Number(spec.minLength);
591
618
  if (!Number.isNaN(minItems)) {
592
619
  (0, set_1.default)(mutableSchema, 'minItems', minItems);
593
620
  }
594
621
  }
595
- if (spec.type === core_1.SpecTypes.String && spec.minLength !== undefined) {
622
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && (spec === null || spec === void 0 ? void 0 : spec.minLength) !== undefined) {
596
623
  const minLength = Number(spec.minLength);
597
624
  if (!Number.isNaN(minLength)) {
598
625
  (0, set_1.default)(mutableSchema, 'minLength', minLength);
@@ -600,7 +627,7 @@ const specRules = {
600
627
  }
601
628
  },
602
629
  items: (spec, mutableSchema, rules, errorMessages) => {
603
- if (spec.type === core_1.SpecTypes.Array && spec.items) {
630
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Array && (spec === null || spec === void 0 ? void 0 : spec.items)) {
604
631
  const childSchema = specToJsonSchema(spec.items, 'items' in mutableSchema &&
605
632
  mutableSchema.items &&
606
633
  !Array.isArray(mutableSchema.items)
@@ -610,35 +637,36 @@ const specRules = {
610
637
  },
611
638
  enum: (spec, mutableSchema) => {
612
639
  var _a, _b, _c, _d;
613
- if (spec.type === core_1.SpecTypes.Array &&
640
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Array &&
614
641
  ((_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length) &&
615
642
  (((_b = spec.items) === null || _b === void 0 ? void 0 : _b.type) === core_1.SpecTypes.String || !((_c = spec.items) === null || _c === void 0 ? void 0 : _c.type))) {
616
643
  (0, set_1.default)(mutableSchema, 'items.enum', spec.enum);
617
644
  }
618
- if (spec.type === core_1.SpecTypes.String && ((_d = spec.enum) === null || _d === void 0 ? void 0 : _d.length)) {
645
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && ((_d = spec === null || spec === void 0 ? void 0 : spec.enum) === null || _d === void 0 ? void 0 : _d.length)) {
619
646
  (0, set_1.default)(mutableSchema, 'enum', spec.enum);
620
647
  }
621
648
  },
622
649
  description: (spec, mutableSchema) => {
623
- if ('description' in spec &&
650
+ if (spec &&
651
+ 'description' in spec &&
624
652
  (0, isObject_1.default)(spec.description) &&
625
653
  Object.keys(spec.description).length) {
626
654
  (0, set_1.default)(mutableSchema, 'nodeParameters.entityProps.enumDescriptions', spec.description);
627
655
  }
628
656
  },
629
657
  validator: (spec, mutableSchema) => {
630
- if (spec.validator && spec.validator !== 'base') {
658
+ if ((spec === null || spec === void 0 ? void 0 : spec.validator) && (spec === null || spec === void 0 ? void 0 : spec.validator) !== 'base') {
631
659
  (0, set_1.default)(mutableSchema, 'nodeParameters.validator', spec.validator);
632
660
  }
633
661
  },
634
662
  maximum: (spec, mutableSchema) => {
635
- if (spec.type === core_1.SpecTypes.Number && spec.maximum !== undefined) {
663
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Number && (spec === null || spec === void 0 ? void 0 : spec.maximum) !== undefined) {
636
664
  const maximum = Number(spec.maximum);
637
665
  if (!Number.isNaN(maximum)) {
638
666
  (0, set_1.default)(mutableSchema, 'maximum', maximum);
639
667
  }
640
668
  }
641
- if (spec.type === core_1.SpecTypes.String && 'maximum' in spec && spec.maximum !== undefined) {
669
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && 'maximum' in spec && (spec === null || spec === void 0 ? void 0 : spec.maximum) !== undefined) {
642
670
  const maximum = Number(spec.maximum);
643
671
  if (!Number.isNaN(maximum)) {
644
672
  (0, set_1.default)(mutableSchema, 'stringNumber.maximum', `${spec.maximum}`);
@@ -646,13 +674,13 @@ const specRules = {
646
674
  }
647
675
  },
648
676
  minimum: (spec, mutableSchema) => {
649
- if (spec.type === core_1.SpecTypes.Number && spec.minimum !== undefined) {
677
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Number && spec.minimum !== undefined) {
650
678
  const minimum = Number(spec.minimum);
651
679
  if (!Number.isNaN(minimum)) {
652
680
  (0, set_1.default)(mutableSchema, 'minimum', minimum);
653
681
  }
654
682
  }
655
- if (spec.type === core_1.SpecTypes.String && 'minimum' in spec && spec.minimum !== undefined) {
683
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && 'minimum' in spec && (spec === null || spec === void 0 ? void 0 : spec.minimum) !== undefined) {
656
684
  const minimum = Number(spec.minimum);
657
685
  if (!Number.isNaN(minimum)) {
658
686
  (0, set_1.default)(mutableSchema, 'stringNumber.minimum', `${spec.minimum}`);
@@ -660,21 +688,22 @@ const specRules = {
660
688
  }
661
689
  },
662
690
  format: (spec, mutableSchema) => {
663
- if (spec.type === core_1.SpecTypes.Number && spec.format === 'int64') {
691
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Number && spec.format === 'int64') {
664
692
  (0, set_1.default)(mutableSchema, 'type', core_2.JsonSchemaType.Integer);
665
693
  }
666
694
  },
667
695
  properties: (spec, mutableSchema, rules, errorMessages) => {
668
- if (spec.type === core_1.SpecTypes.Object && spec.properties) {
696
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.Object && spec.properties) {
669
697
  Object.entries(spec.properties).forEach(([key, childSpec]) => {
698
+ var _a, _b, _c, _d, _e;
670
699
  const childSchema = specToJsonSchema(childSpec, Object.assign({}, ((0, get_1.default)(mutableSchema, ['properties', key]) || {})), rules, errorMessages);
671
700
  (0, set_1.default)(mutableSchema, ['properties', key], childSchema);
672
701
  if (childSpec.required &&
673
- !(spec.viewSpec.type === 'oneof' ||
674
- spec.viewSpec.type === 'oneof_flat' ||
675
- spec.viewSpec.type === 'card_oneof' ||
676
- spec.viewSpec.type === 'multi_oneof' ||
677
- spec.viewSpec.type === 'multi_oneof_flat')) {
702
+ !(((_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.type) === 'oneof' ||
703
+ ((_b = spec.viewSpec) === null || _b === void 0 ? void 0 : _b.type) === 'oneof_flat' ||
704
+ ((_c = spec.viewSpec) === null || _c === void 0 ? void 0 : _c.type) === 'card_oneof' ||
705
+ ((_d = spec.viewSpec) === null || _d === void 0 ? void 0 : _d.type) === 'multi_oneof' ||
706
+ ((_e = spec.viewSpec) === null || _e === void 0 ? void 0 : _e.type) === 'multi_oneof_flat')) {
678
707
  (0, set_1.default)(mutableSchema, ['required'], [...((0, get_1.default)(mutableSchema, 'required') || []), key]);
679
708
  (0, set_1.default)(mutableSchema, 'nodeParameters.errorMessages.required', errorMessages.required);
680
709
  }
@@ -682,12 +711,12 @@ const specRules = {
682
711
  }
683
712
  },
684
713
  pattern: (spec, mutableSchema) => {
685
- if (spec.type === core_1.SpecTypes.String && spec.pattern) {
714
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && spec.pattern) {
686
715
  (0, set_1.default)(mutableSchema, 'pattern', spec.pattern);
687
716
  }
688
717
  },
689
718
  patternError: (spec, mutableSchema) => {
690
- if (spec.type === core_1.SpecTypes.String && spec.patternError) {
719
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === core_1.SpecTypes.String && (spec === null || spec === void 0 ? void 0 : spec.patternError)) {
691
720
  (0, set_1.default)(mutableSchema, 'nodeParameters.errorMessages.pattern', spec.patternError);
692
721
  }
693
722
  },
@@ -698,6 +727,8 @@ const specRules = {
698
727
  function specToJsonSchema(spec, mutableSchema = {}, rules, errorMessages = {}) {
699
728
  const mergedSpecRules = Object.assign(Object.assign({}, specRules), rules === null || rules === void 0 ? void 0 : rules.specRules);
700
729
  const mergedViewSpecRules = Object.assign(Object.assign({}, viewSpecRules), rules === null || rules === void 0 ? void 0 : rules.viewSpecRules);
701
- Object.values(mergedSpecRules).forEach((rule) => rule(spec, mutableSchema, { specRules: mergedSpecRules, viewSpecRules: mergedViewSpecRules }, errorMessages));
730
+ if (spec) {
731
+ Object.values(mergedSpecRules).forEach((rule) => rule(spec, mutableSchema, { specRules: mergedSpecRules, viewSpecRules: mergedViewSpecRules }, errorMessages));
732
+ }
702
733
  return mutableSchema;
703
734
  }
@@ -1,10 +1,14 @@
1
1
  import { type Spec } from '../../../core';
2
2
  import { type ErrorMessages, type JsonSchema } from '../../core';
3
- type Rules = Record<string, (spec: Spec, mutableSchema: JsonSchema, rules: {
3
+ type Rules = Record<string, (spec: Partial<Spec & {
4
+ viewSpec: Partial<Spec['viewSpec']>;
5
+ }> | null | undefined, mutableSchema: JsonSchema, rules: {
4
6
  specRules: Rules;
5
7
  viewSpecRules: Rules;
6
8
  }, errorMessages: ErrorMessages) => void>;
7
- export declare function specToJsonSchema(spec: Spec, mutableSchema?: JsonSchema, rules?: {
9
+ export declare function specToJsonSchema(spec: Partial<Spec & {
10
+ viewSpec: Partial<Spec['viewSpec']>;
11
+ }> | null | undefined, mutableSchema?: JsonSchema, rules?: {
8
12
  specRules: Rules;
9
13
  viewSpecRules: Rules;
10
14
  }, errorMessages?: ErrorMessages): JsonSchema;
@@ -5,12 +5,14 @@ import { SpecTypes } from '../../../core';
5
5
  import { JsonSchemaType, NodeType } from '../../core';
6
6
  const viewSpecRules = {
7
7
  disabled: (spec, mutableSchema) => {
8
- if (spec.viewSpec.disabled) {
8
+ var _a;
9
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.disabled) {
9
10
  set(mutableSchema, 'nodeParameters.flags.disabled', true);
10
11
  }
11
12
  },
12
13
  layout: (spec, mutableSchema) => {
13
- const layout = spec.viewSpec.layout;
14
+ var _a;
15
+ const layout = (_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layout;
14
16
  if (!layout) {
15
17
  return;
16
18
  }
@@ -55,35 +57,38 @@ const viewSpecRules = {
55
57
  }
56
58
  },
57
59
  layoutTitle: (spec, mutableSchema) => {
58
- if (spec.viewSpec.layoutTitle) {
60
+ var _a;
61
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutTitle) {
59
62
  set(mutableSchema, 'title', spec.viewSpec.layoutTitle);
60
63
  }
61
64
  },
62
65
  layoutDescription: (spec, mutableSchema) => {
63
- if (spec.viewSpec.layoutDescription) {
66
+ var _a;
67
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutDescription) {
64
68
  set(mutableSchema, 'description', spec.viewSpec.layoutDescription);
65
69
  }
66
70
  },
67
71
  layoutOpen: (spec, mutableSchema) => {
68
- if (spec.viewSpec.layoutOpen !== undefined) {
72
+ var _a;
73
+ if (((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutOpen) !== undefined) {
69
74
  set(mutableSchema, 'nodeParameters.flags.open', spec.viewSpec.layoutOpen);
70
75
  }
71
76
  },
72
77
  itemLabel: (spec, mutableSchema) => {
73
- if ('itemLabel' in spec.viewSpec && spec.viewSpec.itemLabel) {
78
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'itemLabel' in spec.viewSpec && spec.viewSpec.itemLabel) {
74
79
  set(mutableSchema, 'nodeParameters.entityProps.addButtonText', spec.viewSpec.itemLabel);
75
80
  }
76
81
  },
77
82
  itemPrefix: (spec, mutableSchema) => {
78
- if ('itemPrefix' in spec.viewSpec && spec.viewSpec.itemPrefix) {
83
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'itemPrefix' in spec.viewSpec && spec.viewSpec.itemPrefix) {
79
84
  set(mutableSchema, 'nodeParameters.entityProps.itemPrefix', spec.viewSpec.itemPrefix);
80
85
  }
81
86
  },
82
87
  table: (spec, mutableSchema) => {
83
- var _a;
84
- if (spec.type === SpecTypes.Array &&
85
- spec.viewSpec.table &&
86
- ((_a = spec.items) === null || _a === void 0 ? void 0 : _a.type) === SpecTypes.Object) {
88
+ var _a, _b;
89
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Array &&
90
+ ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.table) &&
91
+ ((_b = spec === null || spec === void 0 ? void 0 : spec.items) === null || _b === void 0 ? void 0 : _b.type) === SpecTypes.Object) {
87
92
  const order = [];
88
93
  spec.viewSpec.table.forEach(({ description, label, property }) => {
89
94
  order.push(property);
@@ -98,32 +103,39 @@ const viewSpecRules = {
98
103
  }
99
104
  },
100
105
  link: (spec, mutableSchema) => {
101
- if (spec.viewSpec.link) {
106
+ var _a;
107
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.link) {
102
108
  set(mutableSchema, 'nodeParameters.entityProps.link', spec.viewSpec.link);
103
109
  }
104
110
  },
105
111
  placeholder: (spec, mutableSchema) => {
106
- if ('placeholder' in spec.viewSpec && spec.viewSpec.placeholder) {
112
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'placeholder' in spec.viewSpec && spec.viewSpec.placeholder) {
107
113
  if (spec.type === SpecTypes.String) {
108
114
  set(mutableSchema, 'examples', [spec.viewSpec.placeholder]);
109
115
  }
110
116
  else if (spec.type === SpecTypes.Array) {
111
117
  set(mutableSchema, 'examples', [[spec.viewSpec.placeholder]]);
112
118
  }
119
+ else {
120
+ set(mutableSchema, 'nodeParameters.entityProps.placeholder', spec.viewSpec.placeholder);
121
+ }
113
122
  }
114
123
  },
115
124
  addButtonPosition: (spec, mutableSchema) => {
116
- if ('addButtonPosition' in spec.viewSpec && spec.viewSpec.addButtonPosition) {
125
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) &&
126
+ 'addButtonPosition' in spec.viewSpec &&
127
+ spec.viewSpec.addButtonPosition) {
117
128
  set(mutableSchema, 'nodeParameters.entityProps.addButtonPosition', spec.viewSpec.addButtonPosition);
118
129
  }
119
130
  },
120
131
  hidden: (spec, mutableSchema) => {
121
- if (spec.viewSpec.hidden) {
132
+ var _a;
133
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.hidden) {
122
134
  set(mutableSchema, 'nodeParameters.flags.hidden', true);
123
135
  }
124
136
  },
125
137
  selectParams: (spec, mutableSchema) => {
126
- if ('selectParams' in spec.viewSpec && spec.viewSpec.selectParams) {
138
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'selectParams' in spec.viewSpec && spec.viewSpec.selectParams) {
127
139
  if (spec.viewSpec.selectParams.filterPlaceholder) {
128
140
  set(mutableSchema, 'nodeParameters.entityProps.filterPlaceholder', spec.viewSpec.selectParams.filterPlaceholder);
129
141
  }
@@ -133,7 +145,8 @@ const viewSpecRules = {
133
145
  }
134
146
  },
135
147
  checkboxGroupParams: (spec, mutableSchema) => {
136
- if (spec.type === SpecTypes.Array && spec.viewSpec.checkboxGroupParams) {
148
+ var _a;
149
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Array && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.checkboxGroupParams)) {
137
150
  if (spec.viewSpec.checkboxGroupParams.placement) {
138
151
  set(mutableSchema, 'nodeParameters.entityProps.direction', spec.viewSpec.checkboxGroupParams.placement === 'vertical' ? 'column' : 'row');
139
152
  }
@@ -143,31 +156,35 @@ const viewSpecRules = {
143
156
  }
144
157
  },
145
158
  viewColor: (spec, mutableSchema) => {
146
- if (spec.type === SpecTypes.Boolean && spec.viewSpec.viewColor) {
159
+ var _a;
160
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Boolean && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.viewColor)) {
147
161
  set(mutableSchema, 'nodeParameters.overviewEntityProps.viewColor', spec.viewSpec.viewColor);
148
162
  }
149
163
  },
150
164
  copy: (spec, mutableSchema) => {
151
- if ('copy' in spec.viewSpec && spec.viewSpec.copy) {
165
+ if ((spec === null || spec === void 0 ? void 0 : spec.viewSpec) && 'copy' in spec.viewSpec && spec.viewSpec.copy) {
152
166
  set(mutableSchema, 'nodeParameters.flags.copy', true);
153
167
  }
154
168
  },
155
169
  order: (spec, mutableSchema) => {
156
- if (spec.type === SpecTypes.Object &&
157
- spec.viewSpec.order &&
170
+ var _a;
171
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Object &&
172
+ ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.order) &&
158
173
  Object.keys(spec.viewSpec.order).length) {
159
174
  set(mutableSchema, 'nodeParameters.entityProps.order', spec.viewSpec.order);
160
175
  }
161
176
  },
162
177
  delimiter: (spec, mutableSchema) => {
163
- if (spec.type === SpecTypes.Object &&
164
- spec.viewSpec.delimiter &&
178
+ var _a;
179
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Object &&
180
+ ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.delimiter) &&
165
181
  Object.keys(spec.viewSpec.delimiter).length) {
166
182
  set(mutableSchema, 'nodeParameters.entityProps.delimiter', spec.viewSpec.delimiter);
167
183
  }
168
184
  },
169
185
  sizeParams: (spec, mutableSchema) => {
170
- if (spec.type === SpecTypes.String && spec.viewSpec.sizeParams) {
186
+ var _a;
187
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.sizeParams)) {
171
188
  if (spec.viewSpec.sizeParams.defaultType) {
172
189
  set(mutableSchema, 'nodeParameters.entityProps.defaultType', spec.viewSpec.sizeParams.defaultType);
173
190
  }
@@ -180,7 +197,8 @@ const viewSpecRules = {
180
197
  }
181
198
  },
182
199
  monacoParams: (spec, mutableSchema) => {
183
- if (spec.type === SpecTypes.String && spec.viewSpec.monacoParams) {
200
+ var _a;
201
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.monacoParams)) {
184
202
  if (spec.viewSpec.monacoParams.language) {
185
203
  set(mutableSchema, 'nodeParameters.entityProps.language', spec.viewSpec.monacoParams.language);
186
204
  }
@@ -190,12 +208,14 @@ const viewSpecRules = {
190
208
  }
191
209
  },
192
210
  hideValues: (spec, mutableSchema) => {
193
- if (spec.type === SpecTypes.String && spec.viewSpec.hideValues) {
211
+ var _a;
212
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.hideValues)) {
194
213
  set(mutableSchema, 'nodeParameters.entityProps.hideValues', spec.viewSpec.hideValues);
195
214
  }
196
215
  },
197
216
  textContentParams: (spec, mutableSchema) => {
198
- if (spec.type !== SpecTypes.String || !spec.viewSpec.textContentParams) {
217
+ var _a;
218
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) !== SpecTypes.String || !((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.textContentParams)) {
199
219
  return;
200
220
  }
201
221
  const textContentParams = spec.viewSpec.textContentParams;
@@ -228,7 +248,8 @@ const viewSpecRules = {
228
248
  }
229
249
  },
230
250
  fileInput: (spec, mutableSchema) => {
231
- if (spec.type === SpecTypes.String && spec.viewSpec.fileInput) {
251
+ var _a;
252
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.fileInput)) {
232
253
  if (spec.viewSpec.fileInput.accept) {
233
254
  set(mutableSchema, 'nodeParameters.entityProps.accept', [
234
255
  spec.viewSpec.fileInput.accept,
@@ -240,7 +261,8 @@ const viewSpecRules = {
240
261
  }
241
262
  },
242
263
  dateInput: (spec, mutableSchema) => {
243
- if (spec.type === SpecTypes.String && spec.viewSpec.dateInput) {
264
+ var _a;
265
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.dateInput)) {
244
266
  if (spec.viewSpec.dateInput.outputFormat) {
245
267
  set(mutableSchema, 'nodeParameters.entityProps.outputFormat', spec.viewSpec.dateInput.outputFormat);
246
268
  }
@@ -253,7 +275,8 @@ const viewSpecRules = {
253
275
  }
254
276
  },
255
277
  radioGroupParams: (spec, mutableSchema) => {
256
- if (spec.type === SpecTypes.String && spec.viewSpec.radioGroupParams) {
278
+ var _a;
279
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.radioGroupParams)) {
257
280
  if (spec.viewSpec.radioGroupParams.direction) {
258
281
  set(mutableSchema, 'nodeParameters.entityProps.direction', spec.viewSpec.radioGroupParams.direction);
259
282
  }
@@ -263,19 +286,22 @@ const viewSpecRules = {
263
286
  }
264
287
  },
265
288
  generateRandomValueButton: (spec, mutableSchema) => {
266
- if (spec.type === SpecTypes.String && spec.viewSpec.generateRandomValueButton) {
289
+ var _a;
290
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.generateRandomValueButton)) {
267
291
  set(mutableSchema, 'nodeParameters.entityProps.generateRandomValueButton', true);
268
292
  }
269
293
  },
270
294
  inputProps: (spec, mutableSchema) => {
271
- if (spec.viewSpec.inputProps) {
295
+ var _a;
296
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.inputProps) {
272
297
  Object.entries(spec.viewSpec.inputProps).forEach(([key, value]) => {
273
298
  set(mutableSchema, `nodeParameters.entityProps.${key}`, value);
274
299
  });
275
300
  }
276
301
  },
277
302
  layoutProps: (spec, mutableSchema) => {
278
- if (spec.viewSpec.layoutProps) {
303
+ var _a;
304
+ if ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.layoutProps) {
279
305
  Object.entries(spec.viewSpec.layoutProps).forEach(([key, value]) => {
280
306
  set(mutableSchema, `nodeParameters.layoutProps.${key}`, value);
281
307
  });
@@ -283,7 +309,8 @@ const viewSpecRules = {
283
309
  },
284
310
  // eslint-disable-next-line complexity -- old viewSpec.type mapping, isolated per viewType
285
311
  type: (spec, mutableSchema) => {
286
- if (spec.viewSpec.type === 'oneof') {
312
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
313
+ if (((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.type) === 'oneof') {
287
314
  set(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
288
315
  if (spec.type === SpecTypes.Object) {
289
316
  const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
@@ -329,7 +356,7 @@ const viewSpecRules = {
329
356
  }
330
357
  }
331
358
  }
332
- else if (spec.viewSpec.type === 'oneof_flat') {
359
+ else if (((_b = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _b === void 0 ? void 0 : _b.type) === 'oneof_flat') {
333
360
  set(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
334
361
  if (spec.type === SpecTypes.Object) {
335
362
  const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
@@ -374,7 +401,7 @@ const viewSpecRules = {
374
401
  }
375
402
  }
376
403
  }
377
- else if (spec.viewSpec.type === 'card_oneof') {
404
+ else if (((_c = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _c === void 0 ? void 0 : _c.type) === 'card_oneof') {
378
405
  set(mutableSchema, 'nodeParameters.entity', 'one_of_nested');
379
406
  if (spec.type === SpecTypes.Object) {
380
407
  const { toggler, booleanMap } = spec.viewSpec.oneOfParams || {};
@@ -419,7 +446,7 @@ const viewSpecRules = {
419
446
  }
420
447
  }
421
448
  }
422
- else if (spec.viewSpec.type === 'multi_oneof') {
449
+ else if (((_d = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _d === void 0 ? void 0 : _d.type) === 'multi_oneof') {
423
450
  set(mutableSchema, 'nodeParameters.entity', 'few_of_nested');
424
451
  if (spec.type === SpecTypes.Object) {
425
452
  const { toggler } = spec.viewSpec.oneOfParams || {};
@@ -455,7 +482,7 @@ const viewSpecRules = {
455
482
  set(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
456
483
  }
457
484
  }
458
- else if (spec.viewSpec.type === 'multi_oneof_flat') {
485
+ else if (((_e = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _e === void 0 ? void 0 : _e.type) === 'multi_oneof_flat') {
459
486
  set(mutableSchema, 'nodeParameters.entity', 'few_of_nested');
460
487
  if (spec.type === SpecTypes.Object) {
461
488
  const { toggler } = spec.viewSpec.oneOfParams || {};
@@ -490,10 +517,10 @@ const viewSpecRules = {
490
517
  set(mutableSchema, 'nodeParameters.entityProps.toggler.items.enum', spec.viewSpec.order || Object.keys(spec.properties || {}));
491
518
  }
492
519
  }
493
- else if (spec.viewSpec.type === 'object_value') {
520
+ else if (((_f = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _f === void 0 ? void 0 : _f.type) === 'object_value') {
494
521
  set(mutableSchema, 'nodeParameters.entity', 'dot_value');
495
522
  }
496
- else if (spec.viewSpec.type === 'text_content') {
523
+ else if (((_g = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _g === void 0 ? void 0 : _g.type) === 'text_content') {
497
524
  const textContentParams = spec.type === SpecTypes.String ? spec.viewSpec.textContentParams : undefined;
498
525
  if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeAlert) {
499
526
  set(mutableSchema, 'nodeParameters.entity', 'alert');
@@ -505,31 +532,31 @@ const viewSpecRules = {
505
532
  set(mutableSchema, 'nodeParameters.entity', 'text_content');
506
533
  }
507
534
  }
508
- else if (spec.viewSpec.type === 'date_input') {
535
+ else if (((_h = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _h === void 0 ? void 0 : _h.type) === 'date_input') {
509
536
  set(mutableSchema, 'type', undefined);
510
537
  set(mutableSchema, 'nodeParameters.entity', 'date');
511
538
  set(mutableSchema, 'nodeParameters.type', NodeType.Any);
512
539
  }
513
- else if (spec.viewSpec.type === 'file_input') {
540
+ else if (((_j = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _j === void 0 ? void 0 : _j.type) === 'file_input') {
514
541
  set(mutableSchema, 'nodeParameters.entity', 'file');
515
542
  }
516
- else if (spec.viewSpec.type === 'monaco_input') {
543
+ else if (((_k = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _k === void 0 ? void 0 : _k.type) === 'monaco_input') {
517
544
  set(mutableSchema, 'nodeParameters.entity', 'monaco_input');
518
545
  }
519
- else if (spec.viewSpec.type === 'number_with_scale') {
546
+ else if (((_l = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _l === void 0 ? void 0 : _l.type) === 'number_with_scale') {
520
547
  set(mutableSchema, 'nodeParameters.entity', 'string_number_with_scale');
521
548
  }
522
- else if (spec.viewSpec.type === 'range_input_picker') {
549
+ else if (((_m = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _m === void 0 ? void 0 : _m.type) === 'range_input_picker') {
523
550
  set(mutableSchema, 'nodeParameters.entity', spec.type === SpecTypes.Number ? 'slider' : 'range_input');
524
551
  }
525
552
  else {
526
- set(mutableSchema, 'nodeParameters.entity', spec.viewSpec.type);
553
+ set(mutableSchema, 'nodeParameters.entity', (_o = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _o === void 0 ? void 0 : _o.type);
527
554
  }
528
555
  },
529
556
  };
530
557
  const specRules = {
531
558
  defaultValue: (spec, mutableSchema) => {
532
- if (spec.defaultValue !== undefined) {
559
+ if ((spec === null || spec === void 0 ? void 0 : spec.defaultValue) !== undefined) {
533
560
  set(mutableSchema, 'default', spec.defaultValue);
534
561
  }
535
562
  },
@@ -548,13 +575,13 @@ const specRules = {
548
575
  [SpecTypes.Object]: NodeType.Object,
549
576
  [SpecTypes.String]: NodeType.String,
550
577
  };
551
- if (spec.type) {
578
+ if (spec === null || spec === void 0 ? void 0 : spec.type) {
552
579
  set(mutableSchema, 'type', specTypeToJsonSchemaType[spec.type]);
553
580
  set(mutableSchema, 'nodeParameters.type', specTypeToNodeType[spec.type]);
554
581
  }
555
582
  },
556
583
  required: (spec, mutableSchema, _rules, errorMessages) => {
557
- if (spec.required) {
584
+ if (spec === null || spec === void 0 ? void 0 : spec.required) {
558
585
  set(mutableSchema, 'allOf', [
559
586
  ...(mutableSchema.allOf || []),
560
587
  {
@@ -568,13 +595,13 @@ const specRules = {
568
595
  }
569
596
  },
570
597
  maxLength: (spec, mutableSchema) => {
571
- if (spec.type === SpecTypes.Array && spec.maxLength !== undefined) {
598
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Array && (spec === null || spec === void 0 ? void 0 : spec.maxLength) !== undefined) {
572
599
  const maxItems = Number(spec.maxLength);
573
600
  if (!Number.isNaN(maxItems)) {
574
601
  set(mutableSchema, 'maxItems', maxItems);
575
602
  }
576
603
  }
577
- if (spec.type === SpecTypes.String && spec.maxLength !== undefined) {
604
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && (spec === null || spec === void 0 ? void 0 : spec.maxLength) !== undefined) {
578
605
  const maxLength = Number(spec.maxLength);
579
606
  if (!Number.isNaN(maxLength)) {
580
607
  set(mutableSchema, 'maxLength', maxLength);
@@ -582,13 +609,13 @@ const specRules = {
582
609
  }
583
610
  },
584
611
  minLength: (spec, mutableSchema) => {
585
- if (spec.type === SpecTypes.Array && spec.minLength !== undefined) {
612
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Array && (spec === null || spec === void 0 ? void 0 : spec.minLength) !== undefined) {
586
613
  const minItems = Number(spec.minLength);
587
614
  if (!Number.isNaN(minItems)) {
588
615
  set(mutableSchema, 'minItems', minItems);
589
616
  }
590
617
  }
591
- if (spec.type === SpecTypes.String && spec.minLength !== undefined) {
618
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && (spec === null || spec === void 0 ? void 0 : spec.minLength) !== undefined) {
592
619
  const minLength = Number(spec.minLength);
593
620
  if (!Number.isNaN(minLength)) {
594
621
  set(mutableSchema, 'minLength', minLength);
@@ -596,7 +623,7 @@ const specRules = {
596
623
  }
597
624
  },
598
625
  items: (spec, mutableSchema, rules, errorMessages) => {
599
- if (spec.type === SpecTypes.Array && spec.items) {
626
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Array && (spec === null || spec === void 0 ? void 0 : spec.items)) {
600
627
  const childSchema = specToJsonSchema(spec.items, 'items' in mutableSchema &&
601
628
  mutableSchema.items &&
602
629
  !Array.isArray(mutableSchema.items)
@@ -606,35 +633,36 @@ const specRules = {
606
633
  },
607
634
  enum: (spec, mutableSchema) => {
608
635
  var _a, _b, _c, _d;
609
- if (spec.type === SpecTypes.Array &&
636
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Array &&
610
637
  ((_a = spec.enum) === null || _a === void 0 ? void 0 : _a.length) &&
611
638
  (((_b = spec.items) === null || _b === void 0 ? void 0 : _b.type) === SpecTypes.String || !((_c = spec.items) === null || _c === void 0 ? void 0 : _c.type))) {
612
639
  set(mutableSchema, 'items.enum', spec.enum);
613
640
  }
614
- if (spec.type === SpecTypes.String && ((_d = spec.enum) === null || _d === void 0 ? void 0 : _d.length)) {
641
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && ((_d = spec === null || spec === void 0 ? void 0 : spec.enum) === null || _d === void 0 ? void 0 : _d.length)) {
615
642
  set(mutableSchema, 'enum', spec.enum);
616
643
  }
617
644
  },
618
645
  description: (spec, mutableSchema) => {
619
- if ('description' in spec &&
646
+ if (spec &&
647
+ 'description' in spec &&
620
648
  isObject(spec.description) &&
621
649
  Object.keys(spec.description).length) {
622
650
  set(mutableSchema, 'nodeParameters.entityProps.enumDescriptions', spec.description);
623
651
  }
624
652
  },
625
653
  validator: (spec, mutableSchema) => {
626
- if (spec.validator && spec.validator !== 'base') {
654
+ if ((spec === null || spec === void 0 ? void 0 : spec.validator) && (spec === null || spec === void 0 ? void 0 : spec.validator) !== 'base') {
627
655
  set(mutableSchema, 'nodeParameters.validator', spec.validator);
628
656
  }
629
657
  },
630
658
  maximum: (spec, mutableSchema) => {
631
- if (spec.type === SpecTypes.Number && spec.maximum !== undefined) {
659
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Number && (spec === null || spec === void 0 ? void 0 : spec.maximum) !== undefined) {
632
660
  const maximum = Number(spec.maximum);
633
661
  if (!Number.isNaN(maximum)) {
634
662
  set(mutableSchema, 'maximum', maximum);
635
663
  }
636
664
  }
637
- if (spec.type === SpecTypes.String && 'maximum' in spec && spec.maximum !== undefined) {
665
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && 'maximum' in spec && (spec === null || spec === void 0 ? void 0 : spec.maximum) !== undefined) {
638
666
  const maximum = Number(spec.maximum);
639
667
  if (!Number.isNaN(maximum)) {
640
668
  set(mutableSchema, 'stringNumber.maximum', `${spec.maximum}`);
@@ -642,13 +670,13 @@ const specRules = {
642
670
  }
643
671
  },
644
672
  minimum: (spec, mutableSchema) => {
645
- if (spec.type === SpecTypes.Number && spec.minimum !== undefined) {
673
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Number && spec.minimum !== undefined) {
646
674
  const minimum = Number(spec.minimum);
647
675
  if (!Number.isNaN(minimum)) {
648
676
  set(mutableSchema, 'minimum', minimum);
649
677
  }
650
678
  }
651
- if (spec.type === SpecTypes.String && 'minimum' in spec && spec.minimum !== undefined) {
679
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && 'minimum' in spec && (spec === null || spec === void 0 ? void 0 : spec.minimum) !== undefined) {
652
680
  const minimum = Number(spec.minimum);
653
681
  if (!Number.isNaN(minimum)) {
654
682
  set(mutableSchema, 'stringNumber.minimum', `${spec.minimum}`);
@@ -656,21 +684,22 @@ const specRules = {
656
684
  }
657
685
  },
658
686
  format: (spec, mutableSchema) => {
659
- if (spec.type === SpecTypes.Number && spec.format === 'int64') {
687
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Number && spec.format === 'int64') {
660
688
  set(mutableSchema, 'type', JsonSchemaType.Integer);
661
689
  }
662
690
  },
663
691
  properties: (spec, mutableSchema, rules, errorMessages) => {
664
- if (spec.type === SpecTypes.Object && spec.properties) {
692
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.Object && spec.properties) {
665
693
  Object.entries(spec.properties).forEach(([key, childSpec]) => {
694
+ var _a, _b, _c, _d, _e;
666
695
  const childSchema = specToJsonSchema(childSpec, Object.assign({}, (get(mutableSchema, ['properties', key]) || {})), rules, errorMessages);
667
696
  set(mutableSchema, ['properties', key], childSchema);
668
697
  if (childSpec.required &&
669
- !(spec.viewSpec.type === 'oneof' ||
670
- spec.viewSpec.type === 'oneof_flat' ||
671
- spec.viewSpec.type === 'card_oneof' ||
672
- spec.viewSpec.type === 'multi_oneof' ||
673
- spec.viewSpec.type === 'multi_oneof_flat')) {
698
+ !(((_a = spec.viewSpec) === null || _a === void 0 ? void 0 : _a.type) === 'oneof' ||
699
+ ((_b = spec.viewSpec) === null || _b === void 0 ? void 0 : _b.type) === 'oneof_flat' ||
700
+ ((_c = spec.viewSpec) === null || _c === void 0 ? void 0 : _c.type) === 'card_oneof' ||
701
+ ((_d = spec.viewSpec) === null || _d === void 0 ? void 0 : _d.type) === 'multi_oneof' ||
702
+ ((_e = spec.viewSpec) === null || _e === void 0 ? void 0 : _e.type) === 'multi_oneof_flat')) {
674
703
  set(mutableSchema, ['required'], [...(get(mutableSchema, 'required') || []), key]);
675
704
  set(mutableSchema, 'nodeParameters.errorMessages.required', errorMessages.required);
676
705
  }
@@ -678,12 +707,12 @@ const specRules = {
678
707
  }
679
708
  },
680
709
  pattern: (spec, mutableSchema) => {
681
- if (spec.type === SpecTypes.String && spec.pattern) {
710
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && spec.pattern) {
682
711
  set(mutableSchema, 'pattern', spec.pattern);
683
712
  }
684
713
  },
685
714
  patternError: (spec, mutableSchema) => {
686
- if (spec.type === SpecTypes.String && spec.patternError) {
715
+ if ((spec === null || spec === void 0 ? void 0 : spec.type) === SpecTypes.String && (spec === null || spec === void 0 ? void 0 : spec.patternError)) {
687
716
  set(mutableSchema, 'nodeParameters.errorMessages.pattern', spec.patternError);
688
717
  }
689
718
  },
@@ -694,6 +723,8 @@ const specRules = {
694
723
  export function specToJsonSchema(spec, mutableSchema = {}, rules, errorMessages = {}) {
695
724
  const mergedSpecRules = Object.assign(Object.assign({}, specRules), rules === null || rules === void 0 ? void 0 : rules.specRules);
696
725
  const mergedViewSpecRules = Object.assign(Object.assign({}, viewSpecRules), rules === null || rules === void 0 ? void 0 : rules.viewSpecRules);
697
- Object.values(mergedSpecRules).forEach((rule) => rule(spec, mutableSchema, { specRules: mergedSpecRules, viewSpecRules: mergedViewSpecRules }, errorMessages));
726
+ if (spec) {
727
+ Object.values(mergedSpecRules).forEach((rule) => rule(spec, mutableSchema, { specRules: mergedSpecRules, viewSpecRules: mergedViewSpecRules }, errorMessages));
728
+ }
698
729
  return mutableSchema;
699
730
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dynamic-forms",
3
- "version": "5.29.1",
3
+ "version": "5.29.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/cjs/index.js",