@apify/input_schema 3.16.1 → 3.18.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.
package/esm/index.mjs CHANGED
@@ -90,13 +90,12 @@ var schema_default = {
90
90
  stringEnumProperty: {
91
91
  title: "Enum property",
92
92
  type: "object",
93
- additionalProperties: false,
93
+ unevaluatedProperties: false,
94
94
  properties: {
95
95
  type: { enum: ["string"] },
96
96
  editor: { enum: ["select"] },
97
97
  title: { type: "string" },
98
98
  description: { type: "string" },
99
- default: { type: "string" },
100
99
  prefill: { type: "string" },
101
100
  example: { type: "string" },
102
101
  nullable: { type: "boolean" },
@@ -114,7 +113,16 @@ var schema_default = {
114
113
  minItems: 1
115
114
  }
116
115
  },
117
- required: ["type", "title", "description", "enum"]
116
+ required: ["type", "title", "description", "enum"],
117
+ if: {
118
+ properties: { nullable: { const: false } }
119
+ },
120
+ then: {
121
+ properties: { default: { type: "string" } }
122
+ },
123
+ else: {
124
+ properties: { default: { type: ["string", "null"] } }
125
+ }
118
126
  },
119
127
  stringProperty: {
120
128
  title: "String property",
@@ -139,49 +147,52 @@ var schema_default = {
139
147
  }
140
148
  },
141
149
  then: {
142
- if: {
143
- properties: {
144
- editor: { const: "datepicker" }
145
- }
146
- },
147
- then: {
148
- additionalProperties: false,
149
- properties: {
150
- type: { enum: ["string"] },
151
- title: { type: "string" },
152
- description: { type: "string" },
153
- default: { type: "string" },
154
- prefill: { type: "string" },
155
- example: { type: "string" },
156
- pattern: { type: "string" },
157
- nullable: { type: "boolean" },
158
- minLength: { type: "integer" },
159
- maxLength: { type: "integer" },
160
- editor: { enum: ["datepicker"] },
161
- sectionCaption: { type: "string" },
162
- sectionDescription: { type: "string" },
163
- dateType: { enum: ["absolute", "relative", "absoluteOrRelative"] }
164
- }
150
+ properties: {
151
+ type: { enum: ["string"] },
152
+ title: { type: "string" },
153
+ description: { type: "string" },
154
+ prefill: { type: "string" },
155
+ example: { type: "string" },
156
+ pattern: { type: "string" },
157
+ nullable: { type: "boolean" },
158
+ minLength: { type: "integer" },
159
+ maxLength: { type: "integer" },
160
+ sectionCaption: { type: "string" },
161
+ sectionDescription: { type: "string" },
162
+ isSecret: { enum: [false] }
165
163
  },
166
- else: {
167
- additionalProperties: false,
168
- properties: {
169
- type: { enum: ["string"] },
170
- title: { type: "string" },
171
- description: { type: "string" },
172
- default: { type: "string" },
173
- prefill: { type: "string" },
174
- example: { type: "string" },
175
- pattern: { type: "string" },
176
- nullable: { type: "boolean" },
177
- minLength: { type: "integer" },
178
- maxLength: { type: "integer" },
179
- editor: { enum: ["javascript", "python", "textfield", "textarea", "hidden", "fileupload"] },
180
- isSecret: { enum: [false] },
181
- sectionCaption: { type: "string" },
182
- sectionDescription: { type: "string" }
164
+ unevaluatedProperties: false,
165
+ allOf: [
166
+ {
167
+ if: {
168
+ properties: {
169
+ editor: { const: "datepicker" }
170
+ }
171
+ },
172
+ then: {
173
+ properties: {
174
+ editor: { enum: ["datepicker"] },
175
+ dateType: { enum: ["absolute", "relative", "absoluteOrRelative"] }
176
+ }
177
+ },
178
+ else: {
179
+ properties: {
180
+ editor: { enum: ["javascript", "python", "textfield", "textarea", "hidden", "fileupload"] }
181
+ }
182
+ }
183
+ },
184
+ {
185
+ if: {
186
+ properties: { nullable: { const: false } }
187
+ },
188
+ then: {
189
+ properties: { default: { type: "string" } }
190
+ },
191
+ else: {
192
+ properties: { default: { type: ["string", "null"] } }
193
+ }
183
194
  }
184
- }
195
+ ]
185
196
  },
186
197
  else: {
187
198
  additionalProperties: false,
@@ -204,86 +215,105 @@ var schema_default = {
204
215
  type: "object",
205
216
  properties: {
206
217
  type: { enum: ["array"] },
207
- editor: { enum: ["json", "requestListSources", "pseudoUrls", "globs", "keyValue", "stringList", "select", "hidden"] },
218
+ editor: { enum: ["json", "requestListSources", "pseudoUrls", "globs", "keyValue", "stringList", "select", "schemaBased", "hidden"] },
208
219
  isSecret: { type: "boolean" }
209
220
  },
210
- additionalProperties: true,
211
221
  required: ["type", "title", "description", "editor"],
212
222
  if: {
213
223
  properties: {
214
- isSecret: {
215
- not: {
216
- const: true
217
- }
218
- }
224
+ isSecret: { not: { const: true } }
219
225
  }
220
226
  },
221
227
  then: {
222
- if: {
223
- properties: {
224
- editor: { const: "select" }
225
- }
228
+ properties: {
229
+ type: { enum: ["array"] },
230
+ title: { type: "string" },
231
+ description: { type: "string" },
232
+ prefill: { type: "array" },
233
+ example: { type: "array" },
234
+ nullable: { type: "boolean" },
235
+ minItems: { type: "integer" },
236
+ maxItems: { type: "integer" },
237
+ uniqueItems: { type: "boolean" },
238
+ sectionCaption: { type: "string" },
239
+ sectionDescription: { type: "string" },
240
+ placeholderKey: { type: "string" },
241
+ placeholderValue: { type: "string" },
242
+ patternKey: { type: "string" },
243
+ patternValue: { type: "string" },
244
+ isSecret: { enum: [false] }
226
245
  },
227
- then: {
228
- additionalProperties: false,
229
- required: ["items"],
230
- properties: {
231
- type: { enum: ["array"] },
232
- editor: { enum: ["select"] },
233
- title: { type: "string" },
234
- description: { type: "string" },
235
- default: { type: "array" },
236
- prefill: { type: "array" },
237
- example: { type: "array" },
238
- nullable: { type: "boolean" },
239
- minItems: { type: "integer" },
240
- maxItems: { type: "integer" },
241
- uniqueItems: { type: "boolean" },
242
- sectionCaption: { type: "string" },
243
- sectionDescription: { type: "string" },
244
- items: {
245
- type: "object",
246
- additionalProperties: false,
247
- properties: {
248
- type: { enum: ["string"] },
249
- enum: {
250
- type: "array",
251
- items: { type: "string" },
252
- uniqueItems: true
253
- },
254
- enumTitles: {
255
- type: "array",
256
- items: { type: "string" }
246
+ unevaluatedProperties: false,
247
+ allOf: [
248
+ {
249
+ oneOf: [
250
+ {
251
+ required: ["editor"],
252
+ properties: {
253
+ editor: { enum: ["select"] },
254
+ items: { $ref: "#/definitions/arrayItemsSelect" }
255
+ }
256
+ },
257
+ {
258
+ required: ["editor"],
259
+ properties: {
260
+ editor: { enum: ["keyValue"] },
261
+ items: { $ref: "#/definitions/arrayItemsKeyValue" }
262
+ }
263
+ },
264
+ {
265
+ required: ["editor"],
266
+ properties: {
267
+ editor: { enum: ["stringList"] },
268
+ items: { $ref: "#/definitions/arrayItemsStringList" }
269
+ }
270
+ },
271
+ {
272
+ required: ["editor"],
273
+ properties: {
274
+ editor: { enum: ["globs"] },
275
+ items: { $ref: "#/definitions/arrayItemsGlobs" }
276
+ }
277
+ },
278
+ {
279
+ required: ["editor"],
280
+ properties: {
281
+ editor: { enum: ["pseudoUrls"] },
282
+ items: { $ref: "#/definitions/arrayItemsPseudoUrls" }
283
+ }
284
+ },
285
+ {
286
+ required: ["editor"],
287
+ properties: {
288
+ editor: { enum: ["requestListSources"] },
289
+ items: { $ref: "#/definitions/arrayItemsRequestListSources" }
290
+ }
291
+ },
292
+ {
293
+ required: ["editor"],
294
+ properties: {
295
+ editor: { enum: ["json", "schemaBased", "hidden"] },
296
+ items: { $ref: "#/definitions/arrayItems" }
257
297
  }
258
298
  },
259
- required: ["type", "enum"]
299
+ {
300
+ not: { required: ["editor"] },
301
+ properties: { items: { $ref: "#/definitions/arrayItems" } }
302
+ }
303
+ ]
304
+ },
305
+ {
306
+ if: {
307
+ properties: { nullable: { const: false } }
260
308
  },
261
- isSecret: { enum: [false] }
262
- }
263
- },
264
- else: {
265
- additionalProperties: false,
266
- properties: {
267
- type: { enum: ["array"] },
268
- editor: { enum: ["json", "requestListSources", "pseudoUrls", "globs", "keyValue", "stringList", "hidden"] },
269
- title: { type: "string" },
270
- description: { type: "string" },
271
- default: { type: "array" },
272
- prefill: { type: "array" },
273
- example: { type: "array" },
274
- nullable: { type: "boolean" },
275
- minItems: { type: "integer" },
276
- maxItems: { type: "integer" },
277
- uniqueItems: { type: "boolean" },
278
- sectionCaption: { type: "string" },
279
- sectionDescription: { type: "string" },
280
- placeholderKey: { type: "string" },
281
- placeholderValue: { type: "string" },
282
- patternKey: { type: "string" },
283
- patternValue: { type: "string" },
284
- isSecret: { enum: [false] }
309
+ then: {
310
+ properties: { default: { type: "array" } }
311
+ },
312
+ else: {
313
+ properties: { default: { type: ["array", "null"] } }
314
+ }
285
315
  }
286
- }
316
+ ]
287
317
  },
288
318
  else: {
289
319
  additionalProperties: false,
@@ -300,6 +330,7 @@ var schema_default = {
300
330
  uniqueItems: { type: "boolean" },
301
331
  sectionCaption: { type: "string" },
302
332
  sectionDescription: { type: "string" },
333
+ items: { $ref: "#/definitions/arrayItems" },
303
334
  isSecret: { enum: [true] }
304
335
  }
305
336
  }
@@ -307,31 +338,24 @@ var schema_default = {
307
338
  objectProperty: {
308
339
  title: "Object property",
309
340
  type: "object",
310
- additionalProperties: true,
311
341
  properties: {
312
342
  type: { enum: ["object"] },
313
343
  title: { type: "string" },
314
344
  description: { type: "string" },
315
- editor: { enum: ["json", "proxy", "hidden"] },
345
+ editor: { enum: ["json", "proxy", "schemaBased", "hidden"] },
316
346
  isSecret: { type: "boolean" }
317
347
  },
318
348
  required: ["type", "title", "description", "editor"],
319
349
  if: {
320
350
  properties: {
321
- isSecret: {
322
- not: {
323
- const: true
324
- }
325
- }
351
+ isSecret: { not: { const: true } }
326
352
  }
327
353
  },
328
354
  then: {
329
- additionalProperties: false,
330
355
  properties: {
331
356
  type: { enum: ["object"] },
332
357
  title: { type: "string" },
333
358
  description: { type: "string" },
334
- default: { type: "object" },
335
359
  prefill: { type: "object" },
336
360
  example: { type: "object" },
337
361
  patternKey: { type: "string" },
@@ -339,11 +363,46 @@ var schema_default = {
339
363
  nullable: { type: "boolean" },
340
364
  minProperties: { type: "integer" },
341
365
  maxProperties: { type: "integer" },
342
- editor: { enum: ["json", "proxy", "hidden"] },
366
+ editor: { enum: ["json", "proxy", "schemaBased", "hidden"] },
343
367
  sectionCaption: { type: "string" },
344
368
  sectionDescription: { type: "string" },
345
- isSecret: { enum: [false] }
346
- }
369
+ isSecret: { enum: [false] },
370
+ required: {
371
+ type: "array",
372
+ minItems: 0,
373
+ items: { type: "string" },
374
+ uniqueItems: true
375
+ },
376
+ additionalProperties: {
377
+ type: "boolean"
378
+ }
379
+ },
380
+ unevaluatedProperties: false,
381
+ allOf: [
382
+ {
383
+ oneOf: [
384
+ { properties: {
385
+ editor: { enum: ["proxy"] },
386
+ properties: { $ref: "#/definitions/subObjectPropertiesProxy" }
387
+ } },
388
+ { properties: {
389
+ editor: { enum: ["json", "schemaBased", "hidden"] },
390
+ properties: { $ref: "#/definitions/subObjectProperties" }
391
+ } }
392
+ ]
393
+ },
394
+ {
395
+ if: {
396
+ properties: { nullable: { const: false } }
397
+ },
398
+ then: {
399
+ properties: { default: { type: "object" } }
400
+ },
401
+ else: {
402
+ properties: { default: { type: ["object", "null"] } }
403
+ }
404
+ }
405
+ ]
347
406
  },
348
407
  else: {
349
408
  additionalProperties: false,
@@ -361,19 +420,28 @@ var schema_default = {
361
420
  editor: { enum: ["json", "hidden"] },
362
421
  sectionCaption: { type: "string" },
363
422
  sectionDescription: { type: "string" },
364
- isSecret: { enum: [true] }
423
+ properties: { $ref: "#/definitions/subObjectProperties" },
424
+ isSecret: { enum: [true] },
425
+ required: {
426
+ type: "array",
427
+ minItems: 0,
428
+ items: { type: "string" },
429
+ uniqueItems: true
430
+ },
431
+ additionalProperties: {
432
+ type: "boolean"
433
+ }
365
434
  }
366
435
  }
367
436
  },
368
437
  integerProperty: {
369
438
  title: "Integer property",
370
439
  type: "object",
371
- additionalProperties: false,
440
+ unevaluatedProperties: false,
372
441
  properties: {
373
442
  type: { enum: ["integer"] },
374
443
  title: { type: "string" },
375
444
  description: { type: "string" },
376
- default: { type: "integer" },
377
445
  prefill: { type: "integer" },
378
446
  example: { type: "integer" },
379
447
  nullable: { type: "boolean" },
@@ -384,17 +452,25 @@ var schema_default = {
384
452
  sectionCaption: { type: "string" },
385
453
  sectionDescription: { type: "string" }
386
454
  },
387
- required: ["type", "title", "description"]
455
+ required: ["type", "title", "description"],
456
+ if: {
457
+ properties: { nullable: { const: false } }
458
+ },
459
+ then: {
460
+ properties: { default: { type: "integer" } }
461
+ },
462
+ else: {
463
+ properties: { default: { type: ["integer", "null"] } }
464
+ }
388
465
  },
389
466
  booleanProperty: {
390
467
  title: "Boolean property",
391
468
  type: "object",
392
- additionalProperties: false,
469
+ unevaluatedProperties: false,
393
470
  properties: {
394
471
  type: { enum: ["boolean"] },
395
472
  title: { type: "string" },
396
473
  description: { type: "string" },
397
- default: { type: "boolean" },
398
474
  prefill: { type: "boolean" },
399
475
  example: { type: "boolean" },
400
476
  nullable: { type: "boolean" },
@@ -404,12 +480,21 @@ var schema_default = {
404
480
  sectionCaption: { type: "string" },
405
481
  sectionDescription: { type: "string" }
406
482
  },
407
- required: ["type", "title", "description"]
483
+ required: ["type", "title", "description"],
484
+ if: {
485
+ properties: { nullable: { const: false } }
486
+ },
487
+ then: {
488
+ properties: { default: { type: "boolean" } }
489
+ },
490
+ else: {
491
+ properties: { default: { type: ["boolean", "null"] } }
492
+ }
408
493
  },
409
494
  resourceProperty: {
410
495
  title: "Resource property",
411
496
  type: "object",
412
- additionalProperties: false,
497
+ unevaluatedProperties: false,
413
498
  properties: {
414
499
  type: { enum: ["string"] },
415
500
  title: { type: "string" },
@@ -428,7 +513,6 @@ var schema_default = {
428
513
  const: "READ"
429
514
  }
430
515
  },
431
- default: { type: "string" },
432
516
  prefill: { type: "string" },
433
517
  example: { type: "string" },
434
518
  nullable: { type: "boolean" },
@@ -449,13 +533,24 @@ var schema_default = {
449
533
  ]
450
534
  }
451
535
  }
536
+ },
537
+ {
538
+ if: {
539
+ properties: { nullable: { const: false } }
540
+ },
541
+ then: {
542
+ properties: { default: { type: "string" } }
543
+ },
544
+ else: {
545
+ properties: { default: { type: ["string", "null"] } }
546
+ }
452
547
  }
453
548
  ]
454
549
  },
455
550
  resourceArrayProperty: {
456
551
  title: "Resource array property",
457
552
  type: "object",
458
- additionalProperties: false,
553
+ unevaluatedProperties: false,
459
554
  properties: {
460
555
  type: { enum: ["array"] },
461
556
  title: { type: "string" },
@@ -473,7 +568,6 @@ var schema_default = {
473
568
  const: "READ"
474
569
  }
475
570
  },
476
- default: { type: "array" },
477
571
  prefill: { type: "array" },
478
572
  example: { type: "array" },
479
573
  nullable: { type: "boolean" },
@@ -498,13 +592,24 @@ var schema_default = {
498
592
  ]
499
593
  }
500
594
  }
595
+ },
596
+ {
597
+ if: {
598
+ properties: { nullable: { const: false } }
599
+ },
600
+ then: {
601
+ properties: { default: { type: "array" } }
602
+ },
603
+ else: {
604
+ properties: { default: { type: ["array", "null"] } }
605
+ }
501
606
  }
502
607
  ]
503
608
  },
504
609
  anyProperty: {
505
610
  title: "Any property",
506
611
  type: "object",
507
- additionalProperties: false,
612
+ unevaluatedProperties: false,
508
613
  properties: {
509
614
  type: {
510
615
  type: ["array"],
@@ -518,7 +623,6 @@ var schema_default = {
518
623
  },
519
624
  title: { type: "string" },
520
625
  description: { type: "string" },
521
- default: { type: ["object", "array", "string", "integer", "boolean"] },
522
626
  prefill: { type: ["object", "array", "string", "integer", "boolean"] },
523
627
  example: { type: ["object", "array", "string", "integer", "boolean"] },
524
628
  nullable: { type: "boolean" },
@@ -526,108 +630,758 @@ var schema_default = {
526
630
  sectionCaption: { type: "string" },
527
631
  sectionDescription: { type: "string" }
528
632
  },
529
- required: ["type", "title", "description", "editor"]
530
- }
531
- }
532
- };
533
-
534
- // src/input_schema.ts
535
- var { definitions } = schema_default;
536
- function parseAjvError(error, rootName, properties = {}, input = {}) {
537
- let fieldKey;
538
- let message;
539
- if (error.keyword === "type") {
540
- fieldKey = error.instancePath.split("/").pop();
541
- if (properties[fieldKey] && properties[fieldKey].nullable && input[fieldKey] === null) {
542
- return null;
543
- }
544
- message = m("inputSchema.validation.generic", { rootName, fieldKey, message: error.message });
545
- } else if (error.keyword === "required") {
546
- fieldKey = error.params.missingProperty;
547
- message = m("inputSchema.validation.required", { rootName, fieldKey });
548
- } else if (error.keyword === "additionalProperties") {
549
- fieldKey = error.params.additionalProperty;
550
- message = m("inputSchema.validation.additionalProperty", { rootName, fieldKey });
551
- } else if (error.keyword === "enum") {
552
- fieldKey = error.instancePath.split("/").pop();
553
- const errorMessage = `${error.message}: "${error.params.allowedValues.join('", "')}"`;
554
- message = m("inputSchema.validation.generic", { rootName, fieldKey, message: errorMessage });
555
- } else if (error.keyword === "const") {
556
- fieldKey = error.instancePath.split("/").pop();
557
- message = m("inputSchema.validation.generic", { rootName, fieldKey, message: error.message });
558
- } else {
559
- fieldKey = error.instancePath.split("/").pop();
560
- message = m("inputSchema.validation.generic", { rootName, fieldKey, message: error.message });
561
- }
562
- return { fieldKey, message };
563
- }
564
- __name(parseAjvError, "parseAjvError");
565
- var validateAgainstSchemaOrThrow = /* @__PURE__ */ __name((validator, obj, inputSchema, rootName) => {
566
- if (validator.validate(inputSchema, obj)) return;
567
- const errorMessage = parseAjvError(validator.errors[0], rootName)?.message;
568
- throw new Error(`Input schema is not valid (${errorMessage})`);
569
- }, "validateAgainstSchemaOrThrow");
570
- function validateBasicStructure(validator, obj) {
571
- const schemaWithoutProperties = {
572
- ...schema_default,
573
- properties: { ...schema_default.properties, properties: { type: "object" } }
574
- };
575
- validateAgainstSchemaOrThrow(validator, obj, schemaWithoutProperties, "schema");
576
- }
577
- __name(validateBasicStructure, "validateBasicStructure");
578
- function validateField(validator, fieldSchema, fieldKey) {
579
- const matchingDefinitions = Object.values(definitions).filter((definition2) => {
580
- return definition2.properties.type.enum ? definition2.properties.type.enum[0] === fieldSchema.type : Array.isArray(fieldSchema.type);
581
- });
582
- if (matchingDefinitions.length === 0) {
583
- const errorMessage = m("inputSchema.validation.noMatchingDefinition", { fieldKey });
584
- throw new Error(`Input schema is not valid (${errorMessage})`);
585
- }
586
- if (matchingDefinitions.length === 1) {
587
- validateAgainstSchemaOrThrow(validator, fieldSchema, matchingDefinitions[0], `schema.properties.${fieldKey}`);
588
- return;
589
- }
590
- if (fieldSchema.enum) {
591
- const definition2 = matchingDefinitions.filter((item) => !!item.properties.enum).pop();
592
- if (!definition2) throw new Error('Input schema validation failed to find "enum property" definition');
593
- validateAgainstSchemaOrThrow(validator, fieldSchema, definition2, `schema.properties.${fieldKey}.enum`);
594
- return;
595
- }
596
- if (fieldSchema.resourceType) {
597
- const definition2 = matchingDefinitions.filter((item) => !!item.properties.resourceType).pop();
598
- if (!definition2) throw new Error('Input schema validation failed to find "resource property" definition');
599
- validateAgainstSchemaOrThrow(validator, fieldSchema, definition2, `schema.properties.${fieldKey}`);
600
- return;
601
- }
602
- const definition = matchingDefinitions.filter((item) => !item.properties.enum && !item.properties.resourceType).pop();
603
- if (!definition) throw new Error('Input schema validation failed to find other than "enum property" definition');
604
- validateAgainstSchemaOrThrow(validator, fieldSchema, definition, `schema.properties.${fieldKey}`);
605
- }
606
- __name(validateField, "validateField");
607
- function validateProperties(inputSchema, validator) {
608
- Object.entries(inputSchema.properties).forEach(
609
- ([fieldKey, fieldSchema]) => validateField(validator, fieldSchema, fieldKey)
610
- );
611
- }
612
- __name(validateProperties, "validateProperties");
613
- function validateExistenceOfRequiredFields(inputSchema) {
614
- if (!inputSchema?.required?.length) return;
615
- Object.values(inputSchema?.required).forEach((fieldKey) => {
616
- if (inputSchema?.properties[fieldKey]) return;
617
- throw new Error(m("inputSchema.validation.missingRequiredField", { fieldKey }));
618
- });
619
- }
620
- __name(validateExistenceOfRequiredFields, "validateExistenceOfRequiredFields");
621
- function validateInputSchema(validator, inputSchema) {
622
- validateBasicStructure(validator, inputSchema);
623
- validateProperties(inputSchema, validator);
624
- validateExistenceOfRequiredFields(inputSchema);
625
- validateAgainstSchemaOrThrow(validator, inputSchema, schema_default, "schema");
626
- }
627
- __name(validateInputSchema, "validateInputSchema");
628
-
629
- // src/utilities.ts
630
- import { parse } from "acorn-loose";
633
+ required: ["type", "title", "description", "editor"],
634
+ if: {
635
+ properties: { nullable: { const: false } }
636
+ },
637
+ then: {
638
+ properties: { default: { type: ["object", "array", "string", "integer", "boolean"] } }
639
+ },
640
+ else: {
641
+ properties: { default: { type: ["object", "array", "string", "integer", "boolean", "null"] } }
642
+ }
643
+ },
644
+ subSchemaStringEnumProperty: {
645
+ title: "Sub-schema: Enum property",
646
+ type: "object",
647
+ additionalProperties: false,
648
+ properties: {
649
+ type: { enum: ["string"] },
650
+ editor: { enum: ["select"] },
651
+ title: { type: "string" },
652
+ description: { type: "string" },
653
+ nullable: { type: "boolean" },
654
+ enum: {
655
+ type: "array",
656
+ items: { type: "string" },
657
+ minItems: 1,
658
+ uniqueItems: true
659
+ },
660
+ enumTitles: {
661
+ type: "array",
662
+ items: { type: "string" },
663
+ minItems: 1
664
+ }
665
+ },
666
+ required: ["type", "title", "description", "enum"]
667
+ },
668
+ subSchemaStringProperty: {
669
+ title: "Sub-schema: String property",
670
+ type: "object",
671
+ additionalProperties: true,
672
+ properties: {
673
+ type: { enum: ["string"] },
674
+ title: { type: "string" },
675
+ description: { type: "string" },
676
+ nullable: { type: "boolean" },
677
+ editor: { enum: ["javascript", "python", "textfield", "textarea", "datepicker", "hidden", "fileupload"] }
678
+ },
679
+ required: ["type", "title", "description"],
680
+ if: {
681
+ properties: {
682
+ editor: { const: "datepicker" }
683
+ }
684
+ },
685
+ then: {
686
+ additionalProperties: false,
687
+ properties: {
688
+ type: { enum: ["string"] },
689
+ title: { type: "string" },
690
+ description: { type: "string" },
691
+ pattern: { type: "string" },
692
+ nullable: { type: "boolean" },
693
+ minLength: { type: "integer" },
694
+ maxLength: { type: "integer" },
695
+ editor: { enum: ["datepicker"] },
696
+ dateType: { enum: ["absolute", "relative", "absoluteOrRelative"] }
697
+ }
698
+ },
699
+ else: {
700
+ additionalProperties: false,
701
+ properties: {
702
+ type: { enum: ["string"] },
703
+ title: { type: "string" },
704
+ description: { type: "string" },
705
+ pattern: { type: "string" },
706
+ nullable: { type: "boolean" },
707
+ minLength: { type: "integer" },
708
+ maxLength: { type: "integer" },
709
+ editor: { enum: ["javascript", "python", "textfield", "textarea", "hidden", "fileupload"] }
710
+ }
711
+ }
712
+ },
713
+ subSchemaArrayProperty: {
714
+ title: "Sub-schema: Array property",
715
+ type: "object",
716
+ properties: {
717
+ type: { enum: ["array"] },
718
+ editor: { enum: ["json", "requestListSources", "pseudoUrls", "globs", "keyValue", "stringList", "select", "hidden"] },
719
+ title: { type: "string" },
720
+ description: { type: "string" },
721
+ nullable: { type: "boolean" },
722
+ minItems: { type: "integer" },
723
+ maxItems: { type: "integer" },
724
+ uniqueItems: { type: "boolean" },
725
+ placeholderKey: { type: "string" },
726
+ placeholderValue: { type: "string" },
727
+ patternKey: { type: "string" },
728
+ patternValue: { type: "string" }
729
+ },
730
+ required: ["type", "title", "description"],
731
+ unevaluatedProperties: false,
732
+ oneOf: [
733
+ {
734
+ required: ["editor"],
735
+ properties: {
736
+ editor: { enum: ["select"] },
737
+ items: { $ref: "#/definitions/arrayItemsSelect" }
738
+ }
739
+ },
740
+ {
741
+ required: ["editor"],
742
+ properties: {
743
+ editor: { enum: ["keyValue"] },
744
+ items: { $ref: "#/definitions/arrayItemsKeyValue" }
745
+ }
746
+ },
747
+ {
748
+ required: ["editor"],
749
+ properties: {
750
+ editor: { enum: ["stringList"] },
751
+ items: { $ref: "#/definitions/arrayItemsStringList" }
752
+ }
753
+ },
754
+ {
755
+ required: ["editor"],
756
+ properties: {
757
+ editor: { enum: ["globs"] },
758
+ items: { $ref: "#/definitions/arrayItemsGlobs" }
759
+ }
760
+ },
761
+ {
762
+ required: ["editor"],
763
+ properties: {
764
+ editor: { enum: ["pseudoUrls"] },
765
+ items: { $ref: "#/definitions/arrayItemsPseudoUrls" }
766
+ }
767
+ },
768
+ {
769
+ required: ["editor"],
770
+ properties: {
771
+ editor: { enum: ["requestListSources"] },
772
+ items: { $ref: "#/definitions/arrayItemsRequestListSources" }
773
+ }
774
+ },
775
+ {
776
+ required: ["editor"],
777
+ properties: {
778
+ editor: { enum: ["json", "schemaBased", "hidden"] },
779
+ items: { $ref: "#/definitions/arrayItems" }
780
+ }
781
+ },
782
+ {
783
+ not: { required: ["editor"] },
784
+ properties: { items: { $ref: "#/definitions/arrayItems" } }
785
+ }
786
+ ]
787
+ },
788
+ subSchemaIntegerProperty: {
789
+ title: "Sub-schema: Integer property",
790
+ type: "object",
791
+ additionalProperties: false,
792
+ properties: {
793
+ type: { enum: ["integer"] },
794
+ title: { type: "string" },
795
+ description: { type: "string" },
796
+ nullable: { type: "boolean" },
797
+ minimum: { type: "integer" },
798
+ maximum: { type: "integer" },
799
+ unit: { type: "string" },
800
+ editor: { enum: ["number", "hidden"] }
801
+ },
802
+ required: ["type", "title", "description"]
803
+ },
804
+ subSchemaBooleanProperty: {
805
+ title: "Sub-schema: Boolean property",
806
+ type: "object",
807
+ additionalProperties: false,
808
+ properties: {
809
+ type: { enum: ["boolean"] },
810
+ title: { type: "string" },
811
+ description: { type: "string" },
812
+ nullable: { type: "boolean" },
813
+ groupCaption: { type: "string" },
814
+ groupDescription: { type: "string" },
815
+ editor: { enum: ["checkbox", "hidden"] }
816
+ },
817
+ required: ["type", "title", "description"]
818
+ },
819
+ subSchemaObjectProperty: {
820
+ title: "Sub-schema: Object property",
821
+ type: "object",
822
+ additionalProperties: false,
823
+ properties: {
824
+ type: { enum: ["object"] },
825
+ title: { type: "string" },
826
+ description: { type: "string" },
827
+ patternKey: { type: "string" },
828
+ patternValue: { type: "string" },
829
+ nullable: { type: "boolean" },
830
+ minProperties: { type: "integer" },
831
+ maxProperties: { type: "integer" },
832
+ editor: { enum: ["json", "proxy", "hidden"] },
833
+ properties: { $ref: "#/definitions/subObjectProperties" },
834
+ required: {
835
+ type: "array",
836
+ minItems: 0,
837
+ items: { type: "string" },
838
+ uniqueItems: true
839
+ },
840
+ additionalProperties: {
841
+ type: "boolean"
842
+ }
843
+ },
844
+ required: ["type", "title", "description"]
845
+ },
846
+ subSchemaResourceProperty: {
847
+ title: "Sub-schema: Resource property",
848
+ type: "object",
849
+ additionalProperties: false,
850
+ properties: {
851
+ type: { enum: ["string"] },
852
+ title: { type: "string" },
853
+ description: { type: "string" },
854
+ editor: { enum: ["resourcePicker", "hidden"] },
855
+ resourceType: { enum: ["dataset", "keyValueStore", "requestQueue"] },
856
+ resourcePermissions: {
857
+ type: "array",
858
+ items: {
859
+ type: "string",
860
+ enum: ["READ", "WRITE"]
861
+ },
862
+ minItems: 1,
863
+ uniqueItems: true,
864
+ contains: {
865
+ const: "READ"
866
+ }
867
+ },
868
+ nullable: { type: "boolean" }
869
+ },
870
+ required: ["type", "title", "description", "resourceType"]
871
+ },
872
+ subSchemaResourceArrayProperty: {
873
+ title: "Sub-schema: Resource array property",
874
+ type: "object",
875
+ additionalProperties: false,
876
+ properties: {
877
+ type: { enum: ["array"] },
878
+ title: { type: "string" },
879
+ description: { type: "string" },
880
+ editor: { enum: ["resourcePicker", "hidden"] },
881
+ resourcePermissions: {
882
+ type: "array",
883
+ items: {
884
+ type: "string",
885
+ enum: ["READ", "WRITE"]
886
+ },
887
+ minItems: 1,
888
+ uniqueItems: true,
889
+ contains: {
890
+ const: "READ"
891
+ }
892
+ },
893
+ nullable: { type: "boolean" },
894
+ minItems: { type: "integer" },
895
+ maxItems: { type: "integer" },
896
+ uniqueItems: { type: "boolean" },
897
+ resourceType: { enum: ["dataset", "keyValueStore", "requestQueue"] }
898
+ },
899
+ required: ["type", "title", "description", "resourceType"]
900
+ },
901
+ arrayItems: {
902
+ title: "Utils: Array items definition",
903
+ type: "object",
904
+ properties: {
905
+ type: { enum: ["string", "integer", "boolean", "object", "array"] }
906
+ },
907
+ required: ["type"],
908
+ if: {
909
+ properties: {
910
+ type: { enum: ["object"] }
911
+ }
912
+ },
913
+ then: {
914
+ additionalProperties: false,
915
+ properties: {
916
+ type: { enum: ["object"] },
917
+ properties: {
918
+ type: "object",
919
+ patternProperties: {
920
+ "^": {
921
+ oneOf: [
922
+ { $ref: "#/definitions/subSchemaStringProperty" },
923
+ { $ref: "#/definitions/subSchemaStringEnumProperty" },
924
+ { $ref: "#/definitions/subSchemaArrayProperty" },
925
+ { $ref: "#/definitions/subSchemaObjectProperty" },
926
+ { $ref: "#/definitions/subSchemaIntegerProperty" },
927
+ { $ref: "#/definitions/subSchemaBooleanProperty" },
928
+ { $ref: "#/definitions/subSchemaResourceProperty" },
929
+ { $ref: "#/definitions/subSchemaResourceArrayProperty" }
930
+ ]
931
+ }
932
+ },
933
+ additionalProperties: false
934
+ },
935
+ required: {
936
+ type: "array",
937
+ minItems: 0,
938
+ items: { type: "string" },
939
+ uniqueItems: true
940
+ },
941
+ additionalProperties: {
942
+ type: "boolean"
943
+ }
944
+ }
945
+ },
946
+ else: {
947
+ if: {
948
+ properties: { type: { const: "array" } }
949
+ },
950
+ then: {
951
+ additionalProperties: false,
952
+ properties: {
953
+ type: { enum: ["array"] },
954
+ items: {
955
+ $ref: "#/definitions/arrayItems"
956
+ }
957
+ }
958
+ },
959
+ else: {
960
+ additionalProperties: false,
961
+ properties: {
962
+ type: { enum: ["string", "integer", "boolean"] }
963
+ }
964
+ }
965
+ }
966
+ },
967
+ arrayItemsSelect: {
968
+ title: "Utils: Array items select definition",
969
+ type: "object",
970
+ additionalProperties: false,
971
+ properties: {
972
+ type: { enum: ["string"] },
973
+ enum: {
974
+ type: "array",
975
+ items: { type: "string" },
976
+ uniqueItems: true
977
+ },
978
+ enumTitles: {
979
+ type: "array",
980
+ items: { type: "string" }
981
+ }
982
+ },
983
+ required: ["type", "enum"]
984
+ },
985
+ arrayItemsKeyValue: {
986
+ title: "Utils: Array items keyValue definition",
987
+ type: "object",
988
+ additionalProperties: false,
989
+ properties: {
990
+ type: { enum: ["object"] },
991
+ properties: {
992
+ type: "object",
993
+ properties: {
994
+ key: {
995
+ type: "object",
996
+ additionalProperties: false,
997
+ properties: {
998
+ type: { enum: ["string"] },
999
+ title: { type: "string" },
1000
+ description: { type: "string" },
1001
+ pattern: { type: "string" },
1002
+ minLength: { type: "integer" },
1003
+ maxLength: { type: "integer" }
1004
+ },
1005
+ required: ["type"]
1006
+ },
1007
+ value: {
1008
+ type: "object",
1009
+ additionalProperties: false,
1010
+ properties: {
1011
+ type: { enum: ["string"] },
1012
+ title: { type: "string" },
1013
+ description: { type: "string" },
1014
+ pattern: { type: "string" },
1015
+ minLength: { type: "integer" },
1016
+ maxLength: { type: "integer" }
1017
+ },
1018
+ required: ["type"]
1019
+ }
1020
+ },
1021
+ required: ["key", "value"],
1022
+ additionalProperties: false
1023
+ },
1024
+ required: {
1025
+ type: "array",
1026
+ minItems: 0,
1027
+ items: { type: "string" },
1028
+ uniqueItems: true
1029
+ },
1030
+ additionalProperties: { type: "boolean" }
1031
+ },
1032
+ required: ["type", "properties"]
1033
+ },
1034
+ arrayItemsStringList: {
1035
+ title: "Utils: Array items stringList definition",
1036
+ type: "object",
1037
+ additionalProperties: false,
1038
+ properties: {
1039
+ type: { enum: ["string"] },
1040
+ pattern: { type: "string" },
1041
+ minLength: { type: "integer" },
1042
+ maxLength: { type: "integer" }
1043
+ },
1044
+ required: ["type"]
1045
+ },
1046
+ arrayItemsGlobs: {
1047
+ title: "Utils: Array items globs definition",
1048
+ type: "object",
1049
+ additionalProperties: false,
1050
+ properties: {
1051
+ type: { enum: ["object"] },
1052
+ properties: {
1053
+ type: "object",
1054
+ additionalProperties: false,
1055
+ properties: {
1056
+ glob: {
1057
+ type: "object",
1058
+ additionalProperties: false,
1059
+ properties: {
1060
+ type: { enum: ["string"] },
1061
+ title: { type: "string" },
1062
+ description: { type: "string" },
1063
+ pattern: { type: "string" },
1064
+ minLength: { type: "integer" },
1065
+ maxLength: { type: "integer" }
1066
+ },
1067
+ required: ["type"]
1068
+ },
1069
+ method: {
1070
+ type: "object",
1071
+ additionalProperties: false,
1072
+ properties: {
1073
+ type: { enum: ["string"] },
1074
+ title: { type: "string" },
1075
+ description: { type: "string" },
1076
+ pattern: { type: "string" },
1077
+ minLength: { type: "integer" },
1078
+ maxLength: { type: "integer" }
1079
+ },
1080
+ required: ["type"]
1081
+ },
1082
+ payload: {
1083
+ type: "object",
1084
+ additionalProperties: false,
1085
+ properties: {
1086
+ type: { enum: ["string"] },
1087
+ title: { type: "string" },
1088
+ description: { type: "string" },
1089
+ pattern: { type: "string" },
1090
+ minLength: { type: "integer" },
1091
+ maxLength: { type: "integer" }
1092
+ },
1093
+ required: ["type"]
1094
+ },
1095
+ userData: {
1096
+ type: "object",
1097
+ additionalProperties: false,
1098
+ properties: {
1099
+ type: { enum: ["object"] },
1100
+ title: { type: "string" },
1101
+ description: { type: "string" },
1102
+ properties: { type: "object" }
1103
+ },
1104
+ required: ["type"]
1105
+ },
1106
+ headers: {
1107
+ type: "object",
1108
+ additionalProperties: false,
1109
+ properties: {
1110
+ type: { enum: ["object"] },
1111
+ title: { type: "string" },
1112
+ description: { type: "string" },
1113
+ properties: { type: "object" }
1114
+ },
1115
+ required: ["type"]
1116
+ }
1117
+ }
1118
+ },
1119
+ required: {
1120
+ type: "array",
1121
+ minItems: 0,
1122
+ items: { type: "string" },
1123
+ uniqueItems: true
1124
+ },
1125
+ additionalProperties: { type: "boolean" }
1126
+ },
1127
+ required: ["type"]
1128
+ },
1129
+ arrayItemsPseudoUrls: {
1130
+ title: "Utils: Array items pseudoUrls definition",
1131
+ type: "object",
1132
+ additionalProperties: false,
1133
+ properties: {
1134
+ type: { enum: ["object"] },
1135
+ properties: {
1136
+ type: "object",
1137
+ additionalProperties: false,
1138
+ properties: {
1139
+ purl: {
1140
+ type: "object",
1141
+ additionalProperties: false,
1142
+ properties: {
1143
+ type: { enum: ["string"] },
1144
+ title: { type: "string" },
1145
+ description: { type: "string" },
1146
+ pattern: { type: "string" },
1147
+ minLength: { type: "integer" },
1148
+ maxLength: { type: "integer" }
1149
+ },
1150
+ required: ["type"]
1151
+ },
1152
+ method: {
1153
+ type: "object",
1154
+ additionalProperties: false,
1155
+ properties: {
1156
+ type: { enum: ["string"] },
1157
+ title: { type: "string" },
1158
+ description: { type: "string" },
1159
+ pattern: { type: "string" },
1160
+ minLength: { type: "integer" },
1161
+ maxLength: { type: "integer" }
1162
+ },
1163
+ required: ["type"]
1164
+ },
1165
+ payload: {
1166
+ type: "object",
1167
+ additionalProperties: false,
1168
+ properties: {
1169
+ type: { enum: ["string"] },
1170
+ title: { type: "string" },
1171
+ description: { type: "string" },
1172
+ pattern: { type: "string" },
1173
+ minLength: { type: "integer" },
1174
+ maxLength: { type: "integer" }
1175
+ },
1176
+ required: ["type"]
1177
+ },
1178
+ userData: {
1179
+ type: "object",
1180
+ additionalProperties: false,
1181
+ properties: {
1182
+ type: { enum: ["object"] },
1183
+ title: { type: "string" },
1184
+ description: { type: "string" },
1185
+ properties: { type: "object" }
1186
+ },
1187
+ required: ["type"]
1188
+ },
1189
+ headers: {
1190
+ type: "object",
1191
+ additionalProperties: false,
1192
+ properties: {
1193
+ type: { enum: ["object"] },
1194
+ title: { type: "string" },
1195
+ description: { type: "string" },
1196
+ properties: { type: "object" }
1197
+ },
1198
+ required: ["type"]
1199
+ }
1200
+ }
1201
+ },
1202
+ required: {
1203
+ type: "array",
1204
+ minItems: 0,
1205
+ items: { type: "string" },
1206
+ uniqueItems: true
1207
+ },
1208
+ additionalProperties: { type: "boolean" }
1209
+ },
1210
+ required: ["type"]
1211
+ },
1212
+ arrayItemsRequestListSources: {
1213
+ title: "Utils: Array items requestListSources definition",
1214
+ type: "object",
1215
+ additionalProperties: false,
1216
+ properties: {
1217
+ type: { enum: ["object"] },
1218
+ properties: {
1219
+ type: "object",
1220
+ additionalProperties: false,
1221
+ properties: {
1222
+ url: {
1223
+ type: "object",
1224
+ additionalProperties: false,
1225
+ properties: {
1226
+ type: { enum: ["string"] },
1227
+ title: { type: "string" },
1228
+ description: { type: "string" },
1229
+ pattern: { type: "string" },
1230
+ minLength: { type: "integer" },
1231
+ maxLength: { type: "integer" }
1232
+ },
1233
+ required: ["type"]
1234
+ },
1235
+ method: {
1236
+ type: "object",
1237
+ additionalProperties: false,
1238
+ properties: {
1239
+ type: { enum: ["string"] },
1240
+ title: { type: "string" },
1241
+ description: { type: "string" },
1242
+ pattern: { type: "string" },
1243
+ minLength: { type: "integer" },
1244
+ maxLength: { type: "integer" }
1245
+ },
1246
+ required: ["type"]
1247
+ },
1248
+ payload: {
1249
+ type: "object",
1250
+ additionalProperties: false,
1251
+ properties: {
1252
+ type: { enum: ["string"] },
1253
+ title: { type: "string" },
1254
+ description: { type: "string" },
1255
+ pattern: { type: "string" },
1256
+ minLength: { type: "integer" },
1257
+ maxLength: { type: "integer" }
1258
+ },
1259
+ required: ["type"]
1260
+ },
1261
+ userData: {
1262
+ type: "object",
1263
+ additionalProperties: false,
1264
+ properties: {
1265
+ type: { enum: ["object"] },
1266
+ title: { type: "string" },
1267
+ description: { type: "string" },
1268
+ properties: { type: "object" }
1269
+ },
1270
+ required: ["type"]
1271
+ },
1272
+ headers: {
1273
+ type: "object",
1274
+ additionalProperties: false,
1275
+ properties: {
1276
+ type: { enum: ["object"] },
1277
+ title: { type: "string" },
1278
+ description: { type: "string" },
1279
+ properties: { type: "object" }
1280
+ },
1281
+ required: ["type"]
1282
+ }
1283
+ }
1284
+ },
1285
+ required: {
1286
+ type: "array",
1287
+ minItems: 0,
1288
+ items: { type: "string" },
1289
+ uniqueItems: true
1290
+ },
1291
+ additionalProperties: { type: "boolean" }
1292
+ },
1293
+ required: ["type"]
1294
+ },
1295
+ subObjectProperties: {
1296
+ title: "Utils: Sub-object properties definition",
1297
+ type: "object",
1298
+ patternProperties: {
1299
+ "^": {
1300
+ oneOf: [
1301
+ { $ref: "#/definitions/subSchemaStringProperty" },
1302
+ { $ref: "#/definitions/subSchemaStringEnumProperty" },
1303
+ { $ref: "#/definitions/subSchemaArrayProperty" },
1304
+ { $ref: "#/definitions/subSchemaObjectProperty" },
1305
+ { $ref: "#/definitions/subSchemaIntegerProperty" },
1306
+ { $ref: "#/definitions/subSchemaBooleanProperty" },
1307
+ { $ref: "#/definitions/subSchemaResourceProperty" },
1308
+ { $ref: "#/definitions/subSchemaResourceArrayProperty" }
1309
+ ]
1310
+ }
1311
+ },
1312
+ additionalProperties: false
1313
+ },
1314
+ subObjectPropertiesProxy: {
1315
+ title: "Utils: Sub-object properties proxy definition",
1316
+ type: "object",
1317
+ additionalProperties: false,
1318
+ properties: {
1319
+ useApifyProxy: {
1320
+ type: "object",
1321
+ additionalProperties: false,
1322
+ properties: {
1323
+ type: { enum: ["boolean"] },
1324
+ title: { type: "string" },
1325
+ description: { type: "string" }
1326
+ },
1327
+ required: ["type"]
1328
+ },
1329
+ apifyProxyGroups: {
1330
+ type: "object",
1331
+ additionalProperties: false,
1332
+ properties: {
1333
+ type: { enum: ["array"] },
1334
+ title: { type: "string" },
1335
+ description: { type: "string" },
1336
+ items: {
1337
+ type: ["object"],
1338
+ properties: {
1339
+ type: { enum: ["string"] }
1340
+ },
1341
+ additionalProperties: false,
1342
+ required: ["type"]
1343
+ }
1344
+ },
1345
+ required: ["type"]
1346
+ },
1347
+ proxyUrls: {
1348
+ type: "object",
1349
+ additionalProperties: false,
1350
+ properties: {
1351
+ type: { enum: ["array"] },
1352
+ title: { type: "string" },
1353
+ description: { type: "string" },
1354
+ items: {
1355
+ type: ["object"],
1356
+ properties: {
1357
+ type: { enum: ["string"] }
1358
+ },
1359
+ additionalProperties: false,
1360
+ required: ["type"]
1361
+ }
1362
+ },
1363
+ required: ["type"]
1364
+ },
1365
+ apifyProxyCountry: {
1366
+ type: "object",
1367
+ additionalProperties: false,
1368
+ properties: {
1369
+ type: { enum: ["string"] },
1370
+ title: { type: "string" },
1371
+ description: { type: "string" },
1372
+ pattern: { type: "string" },
1373
+ minLength: { type: "integer" },
1374
+ maxLength: { type: "integer" }
1375
+ },
1376
+ required: ["type"]
1377
+ }
1378
+ }
1379
+ }
1380
+ }
1381
+ };
1382
+
1383
+ // src/utilities.ts
1384
+ import { parse } from "acorn-loose";
631
1385
  import { countries } from "countries-list";
632
1386
  import { PROXY_URL_REGEX, URL_REGEX } from "@apify/consts";
633
1387
  import { isEncryptedValueForFieldSchema, isEncryptedValueForFieldType } from "@apify/input_secrets";
@@ -863,7 +1617,167 @@ ${globalSpaces}`);
863
1617
  return niceJson;
864
1618
  }
865
1619
  __name(makeInputJsFieldsReadable, "makeInputJsFieldsReadable");
1620
+ var DRAFT_2019_09_META_SCHEMA = "https://json-schema.org/draft/2019-09/schema";
1621
+ function ensureAjvSupportsDraft2019(ajvInstance) {
1622
+ const metaSchema = ajvInstance.getSchema(DRAFT_2019_09_META_SCHEMA);
1623
+ if (!metaSchema) {
1624
+ throw new Error(
1625
+ `The provided Ajv instance does not support draft-2019-09 (missing meta-schema ${DRAFT_2019_09_META_SCHEMA}).`
1626
+ );
1627
+ }
1628
+ }
1629
+ __name(ensureAjvSupportsDraft2019, "ensureAjvSupportsDraft2019");
1630
+
1631
+ // src/input_schema.ts
1632
+ var { definitions } = schema_default;
1633
+ var [fieldDefinitions, subFieldDefinitions] = Object.values(definitions).reduce((acc, definition) => {
1634
+ if (definition.title.startsWith("Utils:")) {
1635
+ return acc;
1636
+ }
1637
+ if (definition.title.startsWith("Sub-schema:")) {
1638
+ acc[1].push(definition);
1639
+ } else {
1640
+ acc[0].push(definition);
1641
+ }
1642
+ return acc;
1643
+ }, [[], []]);
1644
+ function parseAjvError(error, rootName, properties = {}, input = {}) {
1645
+ let fieldKey;
1646
+ let message;
1647
+ const cleanPropertyName = /* @__PURE__ */ __name((name) => {
1648
+ return name.replace(/^\/|\/$/g, "").replace(/\//g, ".");
1649
+ }, "cleanPropertyName");
1650
+ if (error.keyword === "type") {
1651
+ fieldKey = error.instancePath.split("/").pop();
1652
+ if (properties[fieldKey] && properties[fieldKey].nullable && input[fieldKey] === null) {
1653
+ return null;
1654
+ }
1655
+ message = m("inputSchema.validation.generic", { rootName, fieldKey, message: error.message });
1656
+ } else if (error.keyword === "required") {
1657
+ fieldKey = cleanPropertyName(`${error.instancePath}/${error.params.missingProperty}`);
1658
+ message = m("inputSchema.validation.required", { rootName, fieldKey });
1659
+ } else if (error.keyword === "additionalProperties") {
1660
+ fieldKey = cleanPropertyName(`${error.instancePath}/${error.params.additionalProperty}`);
1661
+ message = m("inputSchema.validation.additionalProperty", { rootName, fieldKey });
1662
+ } else if (error.keyword === "unevaluatedProperties") {
1663
+ fieldKey = cleanPropertyName(`${error.instancePath}/${error.params.unevaluatedProperty}`);
1664
+ message = m("inputSchema.validation.additionalProperty", { rootName, fieldKey });
1665
+ } else if (error.keyword === "enum") {
1666
+ fieldKey = cleanPropertyName(error.instancePath);
1667
+ const errorMessage = `${error.message}: "${error.params.allowedValues.join('", "')}"`;
1668
+ message = m("inputSchema.validation.generic", { rootName, fieldKey, message: errorMessage });
1669
+ } else if (error.keyword === "const") {
1670
+ fieldKey = cleanPropertyName(error.instancePath);
1671
+ message = m("inputSchema.validation.generic", { rootName, fieldKey, message: error.message });
1672
+ } else {
1673
+ fieldKey = cleanPropertyName(error.instancePath);
1674
+ message = m("inputSchema.validation.generic", { rootName, fieldKey, message: error.message });
1675
+ }
1676
+ return { fieldKey, message };
1677
+ }
1678
+ __name(parseAjvError, "parseAjvError");
1679
+ var validateAgainstSchemaOrThrow = /* @__PURE__ */ __name((validator, obj, inputSchema, rootName) => {
1680
+ if (validator.validate(inputSchema, obj)) return;
1681
+ const errorMessage = parseAjvError(validator.errors[0], rootName)?.message;
1682
+ throw new Error(`Input schema is not valid (${errorMessage})`);
1683
+ }, "validateAgainstSchemaOrThrow");
1684
+ function validateBasicStructure(validator, obj) {
1685
+ const schemaWithoutProperties = {
1686
+ ...schema_default,
1687
+ properties: { ...schema_default.properties, properties: { type: "object" } }
1688
+ };
1689
+ validateAgainstSchemaOrThrow(validator, obj, schemaWithoutProperties, "schema");
1690
+ }
1691
+ __name(validateBasicStructure, "validateBasicStructure");
1692
+ function validateField(validator, fieldSchema, fieldKey, isSubField = false) {
1693
+ const relevantDefinitions = isSubField ? subFieldDefinitions : fieldDefinitions;
1694
+ const matchingDefinitions = Object.values(relevantDefinitions).filter((definition2) => {
1695
+ return definition2.properties.type.enum ? definition2.properties.type.enum[0] === fieldSchema.type : Array.isArray(fieldSchema.type);
1696
+ });
1697
+ if (matchingDefinitions.length === 0) {
1698
+ const errorMessage = m("inputSchema.validation.noMatchingDefinition", { fieldKey });
1699
+ throw new Error(`Input schema is not valid (${errorMessage})`);
1700
+ }
1701
+ const enhanceDefinition = /* @__PURE__ */ __name((definition2) => {
1702
+ return {
1703
+ ...definition2,
1704
+ definitions
1705
+ };
1706
+ }, "enhanceDefinition");
1707
+ if (matchingDefinitions.length === 1) {
1708
+ validateAgainstSchemaOrThrow(validator, fieldSchema, enhanceDefinition(matchingDefinitions[0]), `schema.properties.${fieldKey}`);
1709
+ return;
1710
+ }
1711
+ if (fieldSchema.enum) {
1712
+ const definition2 = matchingDefinitions.filter((item) => !!item.properties.enum).pop();
1713
+ if (!definition2) throw new Error('Input schema validation failed to find "enum property" definition');
1714
+ validateAgainstSchemaOrThrow(validator, fieldSchema, enhanceDefinition(definition2), `schema.properties.${fieldKey}.enum`);
1715
+ return;
1716
+ }
1717
+ if (fieldSchema.resourceType) {
1718
+ const definition2 = matchingDefinitions.filter((item) => !!item.properties.resourceType).pop();
1719
+ if (!definition2) throw new Error('Input schema validation failed to find "resource property" definition');
1720
+ validateAgainstSchemaOrThrow(validator, fieldSchema, enhanceDefinition(definition2), `schema.properties.${fieldKey}`);
1721
+ return;
1722
+ }
1723
+ const definition = matchingDefinitions.filter((item) => !item.properties.enum && !item.properties.resourceType).pop();
1724
+ if (!definition) throw new Error('Input schema validation failed to find other than "enum property" definition');
1725
+ validateAgainstSchemaOrThrow(validator, fieldSchema, enhanceDefinition(definition), `schema.properties.${fieldKey}`);
1726
+ }
1727
+ __name(validateField, "validateField");
1728
+ function validateSubFields(validator, fieldSchema, fieldKey) {
1729
+ Object.entries(fieldSchema.properties).forEach(([subFieldKey, subFieldSchema]) => {
1730
+ if (subFieldSchema.type === "object" && subFieldSchema.properties) {
1731
+ validateSubFields(validator, subFieldSchema, `${fieldKey}.${subFieldKey}`);
1732
+ }
1733
+ if (subFieldSchema.type === "array" && subFieldSchema.items) {
1734
+ validateArrayField(validator, subFieldSchema, `${fieldKey}.${subFieldKey}`);
1735
+ }
1736
+ validateField(validator, subFieldSchema, `${fieldKey}.${subFieldKey}`, true);
1737
+ });
1738
+ }
1739
+ __name(validateSubFields, "validateSubFields");
1740
+ function validateArrayField(validator, fieldSchema, fieldKey) {
1741
+ const arraySchema = fieldSchema.items;
1742
+ if (!arraySchema) return;
1743
+ if (arraySchema.type === "object" && arraySchema.properties) {
1744
+ validateSubFields(validator, arraySchema, `${fieldKey}.items`);
1745
+ }
1746
+ if (arraySchema.type === "array" && arraySchema.items) {
1747
+ validateArrayField(validator, arraySchema, `${fieldKey}.items`);
1748
+ }
1749
+ }
1750
+ __name(validateArrayField, "validateArrayField");
1751
+ function validateProperties(inputSchema, validator) {
1752
+ Object.entries(inputSchema.properties).forEach(([fieldKey, fieldSchema]) => {
1753
+ if (fieldSchema.type === "object" && fieldSchema.properties) {
1754
+ validateSubFields(validator, fieldSchema, fieldKey);
1755
+ }
1756
+ if (fieldSchema.type === "array" && fieldSchema.items) {
1757
+ validateArrayField(validator, fieldSchema, fieldKey);
1758
+ }
1759
+ validateField(validator, fieldSchema, fieldKey);
1760
+ });
1761
+ }
1762
+ __name(validateProperties, "validateProperties");
1763
+ function validateExistenceOfRequiredFields(inputSchema) {
1764
+ if (!inputSchema?.required?.length) return;
1765
+ Object.values(inputSchema?.required).forEach((fieldKey) => {
1766
+ if (inputSchema?.properties[fieldKey]) return;
1767
+ throw new Error(m("inputSchema.validation.missingRequiredField", { fieldKey }));
1768
+ });
1769
+ }
1770
+ __name(validateExistenceOfRequiredFields, "validateExistenceOfRequiredFields");
1771
+ function validateInputSchema(validator, inputSchema) {
1772
+ ensureAjvSupportsDraft2019(validator);
1773
+ validateBasicStructure(validator, inputSchema);
1774
+ validateProperties(inputSchema, validator);
1775
+ validateExistenceOfRequiredFields(inputSchema);
1776
+ validateAgainstSchemaOrThrow(validator, inputSchema, schema_default, "schema");
1777
+ }
1778
+ __name(validateInputSchema, "validateInputSchema");
866
1779
  export {
1780
+ ensureAjvSupportsDraft2019,
867
1781
  schema_default as inputSchema,
868
1782
  m,
869
1783
  makeInputJsFieldsReadable,