@takeshape/schema 8.66.2 → 8.68.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/es/content-schema-transform.js +2 -2
  2. package/es/index.js +2 -1
  3. package/es/migration/index.js +13 -2
  4. package/es/migration/to/v3.14.0.js +10 -0
  5. package/es/migration/to/v3.15.0.js +10 -0
  6. package/es/project-schema/index.js +2 -0
  7. package/es/project-schema/v3.13.1.js +1 -0
  8. package/es/project-schema/v3.14.0.js +1 -0
  9. package/es/project-schema/v3.15.0.js +1 -0
  10. package/es/refs.js +78 -1
  11. package/es/rewrite.js +58 -0
  12. package/es/schema-util.js +32 -118
  13. package/es/schemas/index.js +5 -3
  14. package/es/schemas/index.ts +6 -2
  15. package/es/schemas/project-schema/v3.14.0.json +2379 -0
  16. package/es/schemas/project-schema/v3.15.0.json +2359 -0
  17. package/es/schemas/project-schema.json +2 -1
  18. package/es/template-shapes/templates.js +56 -52
  19. package/es/template-shapes/types.js +8 -1
  20. package/es/types/utils.js +5 -0
  21. package/es/util/detect-cycles.js +2 -2
  22. package/es/util/index.js +2 -1
  23. package/es/util/merge.js +36 -0
  24. package/es/validate.js +2 -10
  25. package/examples/latest/betzino.json +1 -1
  26. package/examples/latest/blog-schema.json +1 -1
  27. package/examples/latest/brewery-schema.json +1 -1
  28. package/examples/latest/complex-project-schema.json +1 -1
  29. package/examples/latest/fabric-ecommerce.json +1 -1
  30. package/examples/latest/frank-and-fred-schema.json +1 -1
  31. package/examples/latest/massive-schema.json +1 -1
  32. package/examples/latest/mill-components-schema.json +1 -1
  33. package/examples/latest/pet-oneof-array.json +1 -1
  34. package/examples/latest/post-schema.json +1 -1
  35. package/examples/latest/pruned-shopify-product-schema.json +1 -1
  36. package/examples/latest/real-world-schema.json +1 -1
  37. package/examples/latest/recursive-repeater-schema.json +1 -1
  38. package/examples/latest/recursive-schema.json +1 -1
  39. package/examples/latest/rick-and-morty-ast.json +1 -1
  40. package/examples/latest/rick-and-morty-graphql.json +1 -1
  41. package/examples/latest/rick-and-morty-rest.json +1 -1
  42. package/examples/latest/schema-with-repeater-draftjs.json +1 -1
  43. package/examples/latest/shape-books-v3_2_0.json +1 -1
  44. package/examples/latest/shape-books.json +1 -1
  45. package/examples/latest/shopify-lookbook.json +1 -1
  46. package/examples/latest/shopify-store-with-widget.json +1 -1
  47. package/examples/latest/stripe-starter-resolved.json +1 -1
  48. package/examples/latest/user-schema-no-required.json +1 -1
  49. package/examples/latest/user-schema-with-defaults.json +1 -1
  50. package/lib/content-schema-transform.js +6 -6
  51. package/lib/index.d.ts +1 -0
  52. package/lib/index.d.ts.map +1 -1
  53. package/lib/index.js +14 -0
  54. package/lib/migration/index.d.ts.map +1 -1
  55. package/lib/migration/index.js +14 -1
  56. package/lib/migration/to/v3.14.0.d.ts +4 -0
  57. package/lib/migration/to/v3.14.0.d.ts.map +1 -0
  58. package/lib/migration/to/v3.14.0.js +18 -0
  59. package/lib/migration/to/v3.15.0.d.ts +4 -0
  60. package/lib/migration/to/v3.15.0.d.ts.map +1 -0
  61. package/lib/migration/to/v3.15.0.js +18 -0
  62. package/lib/project-schema/index.d.ts +5 -1
  63. package/lib/project-schema/index.d.ts.map +1 -1
  64. package/lib/project-schema/index.js +45 -19
  65. package/lib/project-schema/latest.d.ts +164 -23
  66. package/lib/project-schema/latest.d.ts.map +1 -1
  67. package/lib/project-schema/v3.13.1.d.ts +1413 -0
  68. package/lib/project-schema/v3.13.1.d.ts.map +1 -0
  69. package/lib/project-schema/v3.13.1.js +5 -0
  70. package/lib/project-schema/v3.14.0.d.ts +1437 -0
  71. package/lib/project-schema/v3.14.0.d.ts.map +1 -0
  72. package/lib/project-schema/v3.14.0.js +5 -0
  73. package/lib/project-schema/v3.15.0.d.ts +1459 -0
  74. package/lib/project-schema/v3.15.0.d.ts.map +1 -0
  75. package/lib/project-schema/v3.15.0.js +5 -0
  76. package/lib/refs.d.ts +11 -2
  77. package/lib/refs.d.ts.map +1 -1
  78. package/lib/refs.js +83 -0
  79. package/lib/rewrite.d.ts +10 -0
  80. package/lib/rewrite.d.ts.map +1 -0
  81. package/lib/rewrite.js +69 -0
  82. package/lib/schema-util.d.ts +3 -15
  83. package/lib/schema-util.d.ts.map +1 -1
  84. package/lib/schema-util.js +36 -135
  85. package/lib/schemas/index.d.ts +2302 -2
  86. package/lib/schemas/index.d.ts.map +1 -1
  87. package/lib/schemas/index.js +25 -21
  88. package/lib/schemas/index.ts +6 -2
  89. package/lib/schemas/project-schema/v3.14.0.json +2379 -0
  90. package/lib/schemas/project-schema/v3.15.0.json +2359 -0
  91. package/lib/schemas/project-schema.json +2 -1
  92. package/lib/template-shapes/templates.d.ts +11 -4
  93. package/lib/template-shapes/templates.d.ts.map +1 -1
  94. package/lib/template-shapes/templates.js +63 -57
  95. package/lib/template-shapes/types.d.ts +6 -0
  96. package/lib/template-shapes/types.d.ts.map +1 -1
  97. package/lib/template-shapes/types.js +11 -1
  98. package/lib/types/types.d.ts +2 -2
  99. package/lib/types/types.d.ts.map +1 -1
  100. package/lib/types/utils.d.ts +4 -1
  101. package/lib/types/utils.d.ts.map +1 -1
  102. package/lib/types/utils.js +10 -1
  103. package/lib/util/detect-cycles.d.ts +1 -1
  104. package/lib/util/detect-cycles.js +2 -2
  105. package/lib/util/index.d.ts +1 -0
  106. package/lib/util/index.d.ts.map +1 -1
  107. package/lib/util/index.js +13 -0
  108. package/lib/util/merge.d.ts +5 -0
  109. package/lib/util/merge.d.ts.map +1 -0
  110. package/lib/util/merge.js +51 -0
  111. package/lib/validate.d.ts.map +1 -1
  112. package/lib/validate.js +3 -10
  113. package/package.json +4 -4
@@ -1,9 +1,9 @@
1
1
  import forEach from 'lodash/forEach';
2
2
  import difference from 'lodash/difference';
3
3
  import pick from 'lodash/pick';
4
- import { getKey, dereferenceSchema } from './schema-util';
4
+ import { getKey } from './schema-util';
5
5
  import { isArraySchema, isObjectSchema } from './types/utils';
6
- import { getRefShapeName } from './refs';
6
+ import { getRefShapeName, dereferenceSchema } from './refs';
7
7
  import { enumerateOneOfKeys, isUnionSchema } from './unions';
8
8
  const typeCache = new WeakMap();
9
9
  export function getType(schema) {
package/es/index.js CHANGED
@@ -24,4 +24,5 @@ export * from './patterns';
24
24
  export * from './types/types';
25
25
  export * from './types/utils';
26
26
  export * from './flatten-templates';
27
- export * from './relationships';
27
+ export * from './relationships';
28
+ export * from './rewrite';
@@ -1,4 +1,4 @@
1
- import { isLatestProjectSchema, isProjectSchemaV1, isProjectSchemaV3, isProjectSchemaV3_1, isProjectSchemaV3_2, isProjectSchemaV3_3, isProjectSchemaV3_4, isProjectSchemaV3_5, isProjectSchemaV3_5_1, isProjectSchemaV3_6, isProjectSchemaV3_7, isProjectSchemaV3_8, isProjectSchemaV3_9, isProjectSchemaV3_10, isProjectSchemaV3_11, isProjectSchemaV3_12, isProjectSchemaV3_12_1, isProjectSchemaV3_12_2, isProjectSchemaV3_12_3 } from '../types/utils';
1
+ import { isLatestProjectSchema, isProjectSchemaV1, isProjectSchemaV3, isProjectSchemaV3_1, isProjectSchemaV3_2, isProjectSchemaV3_3, isProjectSchemaV3_4, isProjectSchemaV3_5, isProjectSchemaV3_5_1, isProjectSchemaV3_6, isProjectSchemaV3_7, isProjectSchemaV3_8, isProjectSchemaV3_9, isProjectSchemaV3_10, isProjectSchemaV3_11, isProjectSchemaV3_12, isProjectSchemaV3_12_1, isProjectSchemaV3_12_2, isProjectSchemaV3_12_3, isProjectSchemaV3_13_0, isProjectSchemaV3_14_0 } from '../types/utils';
2
2
  import migrateToV3 from './to/v3.0.0';
3
3
  import migrateToV3_1 from './to/v3.1.0';
4
4
  import migrateToV3_2 from './to/v3.2.0';
@@ -17,8 +17,11 @@ import migrateToV3_12_1 from './to/v3.12.1';
17
17
  import migrateToV3_12_2 from './to/v3.12.2';
18
18
  import migrateToV3_12_3 from './to/v3.12.3';
19
19
  import migrateToV3_13_0 from './to/v3.13.0';
20
+ import migrateToV3_14_0 from './to/v3.14.0';
21
+ import migrateToV3_15_0 from './to/v3.15.0';
20
22
  export * from './utils';
21
- export const listTypePrefix = 'PaginatedList';
23
+ export const listTypePrefix = 'PaginatedList'; // eslint-disable-next-line complexity
24
+
22
25
  export async function migrateToLatestProjectSchema(context, projectSchema) {
23
26
  if (projectSchema.schemaVersion === '4.0.0') {
24
27
  throw new Error('You are using an unreleased schema version. Migration is not possible');
@@ -96,6 +99,14 @@ export async function migrateToLatestProjectSchema(context, projectSchema) {
96
99
  projectSchema = migrateToV3_13_0(projectSchema);
97
100
  }
98
101
 
102
+ if (isProjectSchemaV3_13_0(projectSchema)) {
103
+ projectSchema = migrateToV3_14_0(projectSchema);
104
+ }
105
+
106
+ if (isProjectSchemaV3_14_0(projectSchema)) {
107
+ projectSchema = migrateToV3_15_0(projectSchema);
108
+ }
109
+
99
110
  return projectSchema;
100
111
  }
101
112
  export async function ensureLatest(context, schema) {
@@ -0,0 +1,10 @@
1
+ function migrateToV3_14_0(projectSchema) {
2
+ /**
3
+ * No migration needed all changes are backwards compatible.
4
+ */
5
+ return { ...projectSchema,
6
+ schemaVersion: '3.14.0'
7
+ };
8
+ }
9
+
10
+ export default migrateToV3_14_0;
@@ -0,0 +1,10 @@
1
+ function migrateToV3_15_0(projectSchema) {
2
+ /**
3
+ * No migration needed all changes are backwards compatible.
4
+ */
5
+ return { ...projectSchema,
6
+ schemaVersion: '3.15.0'
7
+ };
8
+ }
9
+
10
+ export default migrateToV3_15_0;
@@ -1,6 +1,8 @@
1
1
  // This file is generated by "pnpm json2ts"
2
2
  export * from './latest';
3
3
  export * from './v4.0.0';
4
+ export * from './v3.15.0';
5
+ export * from './v3.14.0';
4
6
  export * from './v3.13.0';
5
7
  export * from './v3.12.3';
6
8
  export * from './v3.12.2';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/es/refs.js CHANGED
@@ -1,8 +1,11 @@
1
- import { getRefType, isAllOfSchema, isOneOfSchema, isRefSchema, isRefSchemaLegacy } from './types';
1
+ import { getRefType, isAllOfSchema, isExtendsSchema, isObjectSchema, isOneOfSchema, isRefSchema, isRefSchemaLegacy } from './types';
2
2
  import get from 'lodash/get';
3
3
  import assign from 'lodash/fp/assign';
4
4
  import omit from 'lodash/fp/omit';
5
5
  import { getServiceNamespace, getServiceNamespaces } from './services';
6
+ import { mergeObjectSchemas } from './util/merge';
7
+ import { resolveSchema } from 'ajv/dist/compile';
8
+ import { isIntegerLike } from '@takeshape/util';
6
9
  const templateShapeRegex = /^(\w+)<([\w:-]+)>$/;
7
10
  /**
8
11
  * Parse a template like `PaginatedList<Post>` and return both the template and the shape name.
@@ -370,4 +373,78 @@ export function hasResolvableRef(context, schema) {
370
373
  }
371
374
 
372
375
  return false;
376
+ }
377
+
378
+ function isSelfReferential(path, shapeName) {
379
+ if (path[0] !== 'shapes' || path[1] !== shapeName) {
380
+ return false;
381
+ }
382
+
383
+ const index = path.findIndex(part => part === 'allOf' || part === 'extends');
384
+ return index !== -1 && isIntegerLike(path[index + 1]);
385
+ }
386
+ /**
387
+ * Given a schema, will resolve any `allOf` or `ref` objects. This function has
388
+ * to fully resolve all refs, because attempting to extend an object schema with
389
+ * a ref property would create an invalid schema, potentially containing both
390
+ * a ref and properties.
391
+ *
392
+ * If it can't create a valid schema it returns the input.
393
+ */
394
+
395
+
396
+ export function dereferenceSchema(context, shapeOrFieldSchema, schemaPath = []) {
397
+ const resolveAll = (resolveSchema, resolvePath) => {
398
+ try {
399
+ if (isAllOfSchema(resolveSchema)) {
400
+ return merge(resolveSchema.allOf, 'allOf', resolvePath);
401
+ }
402
+
403
+ if (isExtendsSchema(resolveSchema)) {
404
+ return merge(resolveSchema.extends, 'extends', resolvePath);
405
+ }
406
+
407
+ if (isRefSchema(resolveSchema)) {
408
+ const refItem = getRefWithPath(context, resolveSchema);
409
+
410
+ if (!refItem) {
411
+ throw new Error('ref could not be parsed');
412
+ }
413
+
414
+ const shape = refItemToShape(context, refItem);
415
+
416
+ if (shape && !isSelfReferential(resolvePath, shape.name)) {
417
+ return resolveAll(omitRefAndExtend(resolveSchema, shape.schema), refItem.path);
418
+ }
419
+
420
+ return;
421
+ }
422
+
423
+ return resolveSchema;
424
+ } catch (err) {
425
+ throw new Error(`error at '${resolvePath.join('.')}', ${err.message}`);
426
+ }
427
+ };
428
+
429
+ const merge = (schemas, propName, path) => {
430
+ const mergedSchema = schemas.map((schema, index) => {
431
+ const resolved = resolveAll(schema, [...path, propName, index]);
432
+ return resolved && isObjectSchema(resolved) ? resolved : undefined;
433
+ }).reduce((prev, curr) => mergeObjectSchemas(prev, curr), {
434
+ type: 'object',
435
+ properties: {}
436
+ });
437
+ return assign(omit(propName, resolveSchema), mergedSchema);
438
+ };
439
+
440
+ return resolveAll(shapeOrFieldSchema, schemaPath) ?? shapeOrFieldSchema;
441
+ }
442
+ export function dereferenceObjectSchema(context, shapeOrFieldSchema, schemaPath = []) {
443
+ const schema = dereferenceSchema(context, shapeOrFieldSchema, schemaPath);
444
+
445
+ if (!isObjectSchema(schema)) {
446
+ throw new Error(`provided schema at '${schemaPath.join('.')}' could not be resolved to an object schema`);
447
+ }
448
+
449
+ return schema;
373
450
  }
package/es/rewrite.js ADDED
@@ -0,0 +1,58 @@
1
+ import defaults from 'lodash/fp/defaults';
2
+ import { isObject } from '@takeshape/util';
3
+ const rewriteSchemaCache = new Map();
4
+
5
+ function getRewriteCache(options) {
6
+ // Ensure key order does not invalidate the cache
7
+ const key = JSON.stringify(options, Object.keys(options).sort());
8
+ let cache = rewriteSchemaCache.get(key);
9
+
10
+ if (!cache) {
11
+ cache = new WeakMap();
12
+ rewriteSchemaCache.set(key, cache);
13
+ }
14
+
15
+ return cache;
16
+ }
17
+ /**
18
+ * Rewrite a schema, applying optional modifications.
19
+ */
20
+ // eslint-disable-next-line @typescript-eslint/ban-types
21
+
22
+
23
+ export function rewriteSchema(schema, options) {
24
+ const rewriteCache = getRewriteCache(defaults({
25
+ removeDefault: false,
26
+ removeRequired: false,
27
+ replaceInput: false
28
+ }, options));
29
+ let rewrittenSchema = rewriteCache.get(schema);
30
+
31
+ if (rewrittenSchema) {
32
+ return rewrittenSchema;
33
+ }
34
+
35
+ rewrittenSchema = JSON.parse(JSON.stringify(schema), (_key, value) => {
36
+ if (isObject(value)) {
37
+ // Remove required
38
+ if (options.removeRequired && Array.isArray(value.required) && value.required.length) {
39
+ delete value.required;
40
+ } // Remove default
41
+
42
+
43
+ if (options.removeDefault && value.type !== undefined && value.default !== undefined) {
44
+ delete value.default;
45
+ }
46
+
47
+ if (options.replaceInput && isObject(value['@input'])) {
48
+ return { ...value['@input'],
49
+ '@mapping': value['@mapping']
50
+ };
51
+ }
52
+ }
53
+
54
+ return value;
55
+ });
56
+ rewriteCache.set(schema, rewrittenSchema);
57
+ return rewrittenSchema;
58
+ }
package/es/schema-util.js CHANGED
@@ -1,27 +1,24 @@
1
1
  import find from 'lodash/find';
2
2
  import mapValues from 'lodash/mapValues';
3
3
  import omitBy from 'lodash/omitBy';
4
- import omit from 'lodash/fp/omit';
5
- import assign from 'lodash/fp/assign';
6
4
  import pickBy from 'lodash/pickBy';
7
5
  import get from 'lodash/get';
8
- import union from 'lodash/union';
9
6
  import keyBy from 'lodash/keyBy';
10
- import isEmpty from 'lodash/isEmpty';
11
7
  import isObject from 'lodash/isObject';
12
8
  import curry from 'lodash/fp/curry';
13
9
  import orderBy from 'lodash/fp/orderBy';
14
10
  import uniq from 'lodash/uniq';
15
- import { deepClone, isDefined, mergeWithArrayConcat } from '@takeshape/util';
11
+ import { deepClone, isDefined } from '@takeshape/util';
16
12
  import { defaultWorkflow, getStatusField } from './workflows';
17
13
  import { CURRENT_API_VERSION, CURRENT_SCHEMA_VERSION } from './versions';
18
14
  import { workflowsEnabled } from './api-version';
19
15
  import { builtInShapes, builtInForms } from './builtin-schema';
20
- import { getArgsType, isBasicResolver, isObjectSchema, isAllOfSchema, isRefSchema, isOneOfSchema } from './types/utils';
16
+ import { getArgsType, isBasicResolver, isObjectSchema, isAllOfSchema, isRefSchema, isOneOfSchema, isExtendsSchema } from './types/utils';
21
17
  import { getStoredServiceConfig } from './services';
22
- import { createTemplateShapeName, followRef, getRef, getRefOrItemsRef, getRefShapeName, getRefWithPath, omitRefAndExtend, parseReturnShape, refExpressionToRefItem, refItemToShape, refItemToShapeName, refItemToShapeSchema } from './refs';
18
+ import { createTemplateShapeName, dereferenceObjectSchema, dereferenceSchema, followRef, getRef, getRefOrItemsRef, getRefShapeName, parseReturnShape, refExpressionToRefItem, refItemToShape, refItemToShapeName, refItemToShapeSchema } from './refs';
23
19
  import isEqual from 'lodash/isEqual';
24
20
  import { isUnionSchema } from './unions';
21
+ import { mergeFormProperties, mergeSchemaProperties } from './util/merge';
25
22
  export const SERVICE_OBJECT_PATTERN_NAME = 'pattern:service-object';
26
23
  export function isBuiltinShape(shapeName) {
27
24
  return Boolean(builtInShapes[shapeName]);
@@ -312,34 +309,6 @@ export function applyBuiltinPropertiesToShape(projectSchema, shape) {
312
309
  }
313
310
  }
314
311
  };
315
- }
316
- export function mergeSchemaProperties(base, overrides) {
317
- const result = { ...base,
318
- properties: { ...base.properties,
319
- ...overrides.properties
320
- }
321
- };
322
- const required = union(base.required, overrides.required);
323
-
324
- if (required.length) {
325
- result.required = required;
326
- }
327
-
328
- return result;
329
- }
330
- export function mergeFormProperties(base, overrides) {
331
- const result = { ...base,
332
- properties: { ...base.properties,
333
- ...overrides.properties
334
- }
335
- };
336
- const order = union(base.order, overrides.order);
337
-
338
- if (order.length) {
339
- result.order = order;
340
- }
341
-
342
- return result;
343
312
  } // Dependencies of these built-in shapes are automatically added by getBuiltinsUsed
344
313
 
345
314
  const requiredBuiltinShapes = ['Asset', 'TSRelationship', 'TsStaticSite'];
@@ -548,11 +517,6 @@ export function getArgsShapeSchema(context, argsSchema) {
548
517
  return args;
549
518
  }
550
519
  }
551
- /**
552
- * Helper fn to omit `allOf` props from the target schema, and then extend it with the source schema.
553
- */
554
-
555
- const omitAllOfAndExtend = (targetSchema, sourceSchema) => assign(omit(['allOf'], targetSchema), sourceSchema);
556
520
 
557
521
  const createShapeToPropertySchema = (projectSchema, definitions, definitionNames, useShapeIdDiscriminator = true) => {
558
522
  const rewriteRefs = (shape, addDiscriminator = false) => {
@@ -706,34 +670,27 @@ export function getRelevantShapes(projectSchema, params) {
706
670
 
707
671
  return {};
708
672
  }
709
- export function visitSchemaProperties(schema, path, callback) {
710
- if (isObjectSchema(schema)) {
711
- for (const [name, propSchema] of Object.entries(schema.properties)) {
712
- const newPath = [...path, 'properties', name];
713
- callback(propSchema, newPath);
714
673
 
715
- if (isObjectSchema(propSchema) || isAllOfSchema(propSchema) || isOneOfSchema(propSchema)) {
716
- visitSchemaProperties(propSchema, newPath, callback);
717
- }
718
- }
719
- } else if (isAllOfSchema(schema)) {
720
- for (const [index, propSchema] of Object.entries(schema.allOf)) {
721
- const newPath = [...path, 'allOf', index];
722
- callback(propSchema, newPath);
674
+ function visitSchemaPropertiesHelper(entries, path, callback) {
675
+ for (const [name, propSchema] of entries) {
676
+ const newPath = [...path, name];
677
+ callback(propSchema, newPath);
723
678
 
724
- if (isObjectSchema(propSchema) || isAllOfSchema(propSchema) || isOneOfSchema(propSchema)) {
725
- visitSchemaProperties(propSchema, newPath, callback);
726
- }
679
+ if (isObjectSchema(propSchema) || isExtendsSchema(propSchema) || isAllOfSchema(propSchema) || isOneOfSchema(propSchema)) {
680
+ visitSchemaProperties(propSchema, newPath, callback);
727
681
  }
728
- } else if (isOneOfSchema(schema)) {
729
- for (const [index, propSchema] of Object.entries(schema.oneOf)) {
730
- const newPath = [...path, 'oneOf', index];
731
- callback(propSchema, newPath);
682
+ }
683
+ }
732
684
 
733
- if (isObjectSchema(propSchema) || isAllOfSchema(propSchema) || isOneOfSchema(propSchema)) {
734
- visitSchemaProperties(propSchema, newPath, callback);
735
- }
736
- }
685
+ export function visitSchemaProperties(schema, path, callback) {
686
+ if (isObjectSchema(schema)) {
687
+ visitSchemaPropertiesHelper(Object.entries(schema.properties), [...path, 'properties'], callback);
688
+ } else if (isExtendsSchema(schema)) {
689
+ visitSchemaPropertiesHelper(Object.entries(schema.extends), [...path, 'extends'], callback);
690
+ } else if (isAllOfSchema(schema)) {
691
+ visitSchemaPropertiesHelper(Object.entries(schema.allOf), [...path, 'allOf'], callback);
692
+ } else if (isOneOfSchema(schema)) {
693
+ visitSchemaPropertiesHelper(Object.entries(schema.oneOf), [...path, 'oneOf'], callback);
737
694
  } else {
738
695
  callback(schema, path);
739
696
  }
@@ -1008,63 +965,14 @@ export function getProtectedSchema(schema) {
1008
965
  })
1009
966
  };
1010
967
  }
1011
- /**
1012
- * Given a schema, will resolve any `allOf` or `ref` objects. This function has
1013
- * to fully resolve all refs, because attempting to extend an object schema with
1014
- * a ref property would create an invalid schema, potentially containing both
1015
- * a ref and properties.
1016
- *
1017
- * If it can't create a valid schema it returns the input.
1018
- */
1019
-
1020
- export function dereferenceSchema(context, shapeOrFieldSchema, schemaPath = []) {
1021
- const resolveAll = (resolveSchema, resolvePath) => {
1022
- try {
1023
- if (isAllOfSchema(resolveSchema)) {
1024
- const allOfSchema = resolveSchema.allOf.map((stub, index) => resolveAll(stub, [...resolvePath, 'allOf', index])).reduce((prev, curr) => mergeWithArrayConcat(prev, curr), {});
1025
- return isEmpty(allOfSchema) ? undefined : omitAllOfAndExtend(resolveSchema, allOfSchema);
1026
- }
1027
-
1028
- if (isRefSchema(resolveSchema)) {
1029
- const refItem = getRefWithPath(context, resolveSchema);
1030
-
1031
- if (!refItem) {
1032
- throw new Error('ref could not be parsed');
1033
- }
1034
-
1035
- const refSchema = refItemToShapeSchema(context, refItem);
1036
-
1037
- if (refSchema) {
1038
- return resolveAll(omitRefAndExtend(resolveSchema, refSchema), refItem.path);
1039
- }
1040
-
1041
- return;
1042
- }
1043
-
1044
- return resolveSchema;
1045
- } catch (err) {
1046
- throw new Error(`error at '${resolvePath.join('.')}', ${err.message}`);
1047
- }
1048
- };
1049
-
1050
- return resolveAll(shapeOrFieldSchema, schemaPath) ?? shapeOrFieldSchema;
1051
- }
1052
- export function dereferenceObjectSchema(context, shapeOrFieldSchema, schemaPath = []) {
1053
- const schema = dereferenceSchema(context, shapeOrFieldSchema, schemaPath);
1054
-
1055
- if (!isObjectSchema(schema)) {
1056
- throw new Error(`provided schema at '${schemaPath.join('.')}' could not be resolved to an object schema`);
1057
- }
1058
-
1059
- return schema;
1060
- }
1061
968
  /**
1062
969
  * Creates a schema property list chainable fn, allowing you to manipulate and
1063
970
  * iterate the properties in a schema.
1064
971
  */
1065
972
 
1066
- export const createSchemaPropertyList = curry((context, shapeOrFieldSchema) => {
1067
- const schema = dereferenceSchema(context, shapeOrFieldSchema);
973
+ export const createSchemaPropertyList = curry((context, shapeOrSchema) => {
974
+ const propSchema = isShape(shapeOrSchema) ? shapeOrSchema.schema : shapeOrSchema;
975
+ const schema = dereferenceSchema(context, propSchema, isShape(shapeOrSchema) ? ['shapes', shapeOrSchema.name] : undefined);
1068
976
  const propertyIterator = new Map(isObjectSchema(schema) ? Object.entries(schema.properties) : undefined);
1069
977
  const defaultOrderByIteratees = [n => n[0]];
1070
978
  const defaultOrderByOrders = ['asc'];
@@ -1134,13 +1042,19 @@ export const createSchemaPropertyList = curry((context, shapeOrFieldSchema) => {
1134
1042
  };
1135
1043
  return self;
1136
1044
  });
1045
+
1046
+ function isShape(shapeOrSchema) {
1047
+ return 'schema' in shapeOrSchema;
1048
+ }
1137
1049
  /**
1138
1050
  * Creates a schema property accessor, allowing you to safely access schema
1139
1051
  * properties.
1140
1052
  */
1141
1053
 
1142
- export const createSchemaPropertyAccessor = curry((context, shapeOrFieldSchema) => {
1143
- const schema = dereferenceSchema(context, shapeOrFieldSchema);
1054
+
1055
+ export const createSchemaPropertyAccessor = curry((context, shapeOrSchema) => {
1056
+ const propSchema = isShape(shapeOrSchema) ? shapeOrSchema.schema : shapeOrSchema;
1057
+ const schema = dereferenceSchema(context, propSchema, isShape(shapeOrSchema) ? ['shapes', shapeOrSchema.name] : undefined);
1144
1058
  const propertyIterator = new Map(isObjectSchema(schema) ? Object.entries(schema.properties) : undefined);
1145
1059
 
1146
1060
  const _getValue = propertyName => {
@@ -1,8 +1,10 @@
1
1
  // This file is generated by "pnpm json2ts"
2
- export const CURRENT_SCHEMA_VERSION = '3.13.0';
2
+ export const CURRENT_SCHEMA_VERSION = '3.15.0';
3
3
  export { default as anyProjectSchema } from './project-schema.json';
4
- export { default as latestSchemaJson } from './project-schema/v3.13.0.json';
4
+ export { default as latestSchemaJson } from './project-schema/v3.15.0.json';
5
5
  import projectSchemaV4_0_0 from './project-schema/v4.0.0.json';
6
+ import projectSchemaV3_15_0 from './project-schema/v3.15.0.json';
7
+ import projectSchemaV3_14_0 from './project-schema/v3.14.0.json';
6
8
  import projectSchemaV3_13_0 from './project-schema/v3.13.0.json';
7
9
  import projectSchemaV3_12_3 from './project-schema/v3.12.3.json';
8
10
  import projectSchemaV3_12_2 from './project-schema/v3.12.2.json';
@@ -34,4 +36,4 @@ import projectSchemaV3_0_0 from './project-schema/v3.0.0.json';
34
36
  import metaSchemaV3_0_0 from './project-schema/meta-schema-v3.0.0.json';
35
37
  import projectSchemaV1_0_0 from './project-schema/v1.0.0.json';
36
38
  import metaSchemaV1_0_0 from './project-schema/meta-schema-v1.0.0.json';
37
- export const allProjectSchemas = [projectSchemaV4_0_0, projectSchemaV3_13_0, projectSchemaV3_12_3, projectSchemaV3_12_2, projectSchemaV3_12_1, projectSchemaV3_12_0, projectSchemaV3_11_0, projectSchemaV3_10_0, projectSchemaV3_9_0, metaSchemaV3_9_0, projectSchemaV3_8_0, metaSchemaV3_8_0, projectSchemaV3_7_0, metaSchemaV3_7_0, projectSchemaV3_6_0, metaSchemaV3_6_0, projectSchemaV3_5_1, metaSchemaV3_5_1, projectSchemaV3_5_0, metaSchemaV3_5_0, projectSchemaV3_4_0, metaSchemaV3_4_0, projectSchemaV3_3_0, metaSchemaV3_3_0, projectSchemaV3_2_0, metaSchemaV3_2_0, projectSchemaV3_1_0, metaSchemaV3_1_0, projectSchemaV3_0_0, metaSchemaV3_0_0, projectSchemaV1_0_0, metaSchemaV1_0_0];
39
+ export const allProjectSchemas = [projectSchemaV4_0_0, projectSchemaV3_15_0, projectSchemaV3_14_0, projectSchemaV3_13_0, projectSchemaV3_12_3, projectSchemaV3_12_2, projectSchemaV3_12_1, projectSchemaV3_12_0, projectSchemaV3_11_0, projectSchemaV3_10_0, projectSchemaV3_9_0, metaSchemaV3_9_0, projectSchemaV3_8_0, metaSchemaV3_8_0, projectSchemaV3_7_0, metaSchemaV3_7_0, projectSchemaV3_6_0, metaSchemaV3_6_0, projectSchemaV3_5_1, metaSchemaV3_5_1, projectSchemaV3_5_0, metaSchemaV3_5_0, projectSchemaV3_4_0, metaSchemaV3_4_0, projectSchemaV3_3_0, metaSchemaV3_3_0, projectSchemaV3_2_0, metaSchemaV3_2_0, projectSchemaV3_1_0, metaSchemaV3_1_0, projectSchemaV3_0_0, metaSchemaV3_0_0, projectSchemaV1_0_0, metaSchemaV1_0_0];
@@ -1,8 +1,10 @@
1
1
  // This file is generated by "pnpm json2ts"
2
- export const CURRENT_SCHEMA_VERSION = '3.13.0';
2
+ export const CURRENT_SCHEMA_VERSION = '3.15.0';
3
3
  export {default as anyProjectSchema} from './project-schema.json';
4
- export {default as latestSchemaJson} from './project-schema/v3.13.0.json';
4
+ export {default as latestSchemaJson} from './project-schema/v3.15.0.json';
5
5
  import projectSchemaV4_0_0 from './project-schema/v4.0.0.json';
6
+ import projectSchemaV3_15_0 from './project-schema/v3.15.0.json';
7
+ import projectSchemaV3_14_0 from './project-schema/v3.14.0.json';
6
8
  import projectSchemaV3_13_0 from './project-schema/v3.13.0.json';
7
9
  import projectSchemaV3_12_3 from './project-schema/v3.12.3.json';
8
10
  import projectSchemaV3_12_2 from './project-schema/v3.12.2.json';
@@ -36,6 +38,8 @@ import projectSchemaV1_0_0 from './project-schema/v1.0.0.json';
36
38
  import metaSchemaV1_0_0 from './project-schema/meta-schema-v1.0.0.json';
37
39
  export const allProjectSchemas = [
38
40
  projectSchemaV4_0_0,
41
+ projectSchemaV3_15_0,
42
+ projectSchemaV3_14_0,
39
43
  projectSchemaV3_13_0,
40
44
  projectSchemaV3_12_3,
41
45
  projectSchemaV3_12_2,