@takeshape/schema 8.59.0 → 8.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/es/index.js +2 -1
  2. package/es/migration/index.js +11 -1
  3. package/es/migration/to/v3.0.0.js +19 -1
  4. package/es/migration/to/v3.12.3.js +81 -0
  5. package/es/migration/to/v3.13.0.js +21 -0
  6. package/es/migration/utils.js +0 -17
  7. package/es/project-schema/index.js +2 -0
  8. package/es/project-schema/v3.12.3.js +1 -0
  9. package/es/project-schema/v3.13.0.js +1 -0
  10. package/es/relationships.js +17 -0
  11. package/es/schema-util.js +9 -4
  12. package/es/schemas/index.js +5 -3
  13. package/es/schemas/index.ts +6 -2
  14. package/es/schemas/project-schema/v3.12.3.json +2358 -0
  15. package/es/schemas/project-schema/v3.13.0.json +2371 -0
  16. package/es/types/utils.js +7 -1
  17. package/es/validate.js +11 -14
  18. package/examples/latest/betzino.json +2325 -516
  19. package/examples/latest/blog-schema.json +14 -5
  20. package/examples/latest/brewery-schema.json +4 -1
  21. package/examples/latest/complex-project-schema.json +100 -1
  22. package/examples/latest/fabric-ecommerce.json +1 -1
  23. package/examples/latest/frank-and-fred-schema.json +673 -1
  24. package/examples/latest/massive-schema.json +272 -17
  25. package/examples/latest/mill-components-schema.json +43 -4
  26. package/examples/latest/pet-oneof-array.json +1 -1
  27. package/examples/latest/post-schema.json +6 -3
  28. package/examples/latest/pruned-shopify-product-schema.json +1 -1
  29. package/examples/latest/real-world-schema.json +18 -3
  30. package/examples/latest/recursive-repeater-schema.json +4 -1
  31. package/examples/latest/recursive-schema.json +4 -1
  32. package/examples/latest/rick-and-morty-ast.json +43 -10
  33. package/examples/latest/rick-and-morty-graphql.json +24 -6
  34. package/examples/latest/rick-and-morty-rest.json +1 -1
  35. package/examples/latest/schema-with-repeater-draftjs.json +10 -1
  36. package/examples/latest/shape-books-v3_2_0.json +40 -7
  37. package/examples/latest/shape-books.json +40 -7
  38. package/examples/latest/shopify-lookbook.json +11 -5
  39. package/examples/latest/shopify-store-with-widget.json +1 -1
  40. package/examples/latest/stripe-starter-resolved.json +5 -2
  41. package/examples/latest/user-schema-no-required.json +1 -1
  42. package/examples/latest/user-schema-with-defaults.json +1 -1
  43. package/lib/index.d.ts +1 -0
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +14 -0
  46. package/lib/migration/index.d.ts.map +1 -1
  47. package/lib/migration/index.js +12 -0
  48. package/lib/migration/to/v3.0.0.d.ts.map +1 -1
  49. package/lib/migration/to/v3.0.0.js +19 -1
  50. package/lib/migration/to/v3.12.3.d.ts +4 -0
  51. package/lib/migration/to/v3.12.3.d.ts.map +1 -0
  52. package/lib/migration/to/v3.12.3.js +91 -0
  53. package/lib/migration/to/v3.13.0.d.ts +4 -0
  54. package/lib/migration/to/v3.13.0.d.ts.map +1 -0
  55. package/lib/migration/to/v3.13.0.js +32 -0
  56. package/lib/migration/utils.d.ts +0 -2
  57. package/lib/migration/utils.d.ts.map +1 -1
  58. package/lib/migration/utils.js +0 -19
  59. package/lib/project-schema/index.d.ts +5 -1
  60. package/lib/project-schema/index.d.ts.map +1 -1
  61. package/lib/project-schema/index.js +43 -17
  62. package/lib/project-schema/latest.d.ts +50 -16
  63. package/lib/project-schema/latest.d.ts.map +1 -1
  64. package/lib/project-schema/v3.12.3.d.ts +1307 -0
  65. package/lib/project-schema/v3.12.3.d.ts.map +1 -0
  66. package/lib/project-schema/v3.12.3.js +5 -0
  67. package/lib/project-schema/v3.13.0.d.ts +1318 -0
  68. package/lib/project-schema/v3.13.0.d.ts.map +1 -0
  69. package/lib/project-schema/v3.13.0.js +5 -0
  70. package/lib/project-schema/v4.0.0.d.ts +69 -0
  71. package/lib/project-schema/v4.0.0.d.ts.map +1 -1
  72. package/lib/relationships.d.ts +3 -0
  73. package/lib/relationships.d.ts.map +1 -0
  74. package/lib/relationships.js +24 -0
  75. package/lib/schema-util.d.ts +1 -0
  76. package/lib/schema-util.d.ts.map +1 -1
  77. package/lib/schema-util.js +9 -4
  78. package/lib/schemas/index.d.ts +2 -2
  79. package/lib/schemas/index.d.ts.map +1 -1
  80. package/lib/schemas/index.js +23 -19
  81. package/lib/schemas/index.ts +6 -2
  82. package/lib/schemas/project-schema/v3.12.3.json +2358 -0
  83. package/lib/schemas/project-schema/v3.13.0.json +2371 -0
  84. package/lib/types/types.d.ts +2 -2
  85. package/lib/types/types.d.ts.map +1 -1
  86. package/lib/types/utils.d.ts +4 -1
  87. package/lib/types/utils.d.ts.map +1 -1
  88. package/lib/types/utils.js +13 -2
  89. package/lib/validate.d.ts.map +1 -1
  90. package/lib/validate.js +11 -14
  91. package/package.json +4 -4
package/es/types/utils.js CHANGED
@@ -5,6 +5,7 @@ import coerce from 'semver/functions/coerce';
5
5
  import isPlainObject from 'lodash/isPlainObject';
6
6
  import isString from 'lodash/isString';
7
7
  import isArray from 'lodash/isArray';
8
+ import isUndefined from 'lodash/isUndefined';
8
9
  import has from 'lodash/has';
9
10
  import { CURRENT_SCHEMA_VERSION, latestSchemaJson } from '../schemas';
10
11
  import satisfies from 'semver/functions/satisfies';
@@ -72,7 +73,12 @@ export const isProjectSchemaV3_11 = createVersionPredicate('3.11.0');
72
73
  export const isProjectSchemaV3_12 = createVersionPredicate('3.12.0');
73
74
  export const isProjectSchemaV3_12_1 = createVersionPredicate('3.12.1');
74
75
  export const isProjectSchemaV3_12_2 = createVersionPredicate('3.12.2');
76
+ export const isProjectSchemaV3_12_3 = createVersionPredicate('3.12.3');
77
+ export const isProjectSchemaV3_13_0 = createVersionPredicate('3.13.0');
75
78
  export const isLatestProjectSchema = createVersionPredicate(CURRENT_SCHEMA_VERSION);
79
+ export function isV1XSchema(maybeSchema) {
80
+ return isObject(maybeSchema) && isString(maybeSchema.projectId) && isObject(maybeSchema.contentTypes) && (isUndefined(maybeSchema.schemaVersion) || maybeSchema.schemaVersion === '1' || maybeSchema.schemaVersion === '1.0.0');
81
+ }
76
82
  export function isV3XSchema(maybeSchema) {
77
83
  if (!isObject(maybeSchema) || !isString(maybeSchema.projectId) || !isString(maybeSchema.schemaVersion)) {
78
84
  return false;
@@ -91,7 +97,7 @@ export function isAnyProjectSchema(value) {
91
97
  }
92
98
 
93
99
  const maybeSchema = value;
94
- return isObject(value) && isString(maybeSchema.projectId) && (isProjectSchemaV1(maybeSchema) || isProjectSchemaV3(maybeSchema) || isProjectSchemaV3_1(maybeSchema) || isProjectSchemaV3_2(maybeSchema) || isProjectSchemaV3_3(maybeSchema) || isProjectSchemaV3_4(maybeSchema) || isProjectSchemaV3_5(maybeSchema) || isProjectSchemaV3_5_1(maybeSchema) || isProjectSchemaV3_6(maybeSchema) || isProjectSchemaV3_7(maybeSchema) || isProjectSchemaV3_8(maybeSchema) || isProjectSchemaV3_9(maybeSchema) || isProjectSchemaV3_10(maybeSchema) || isProjectSchemaV3_11(maybeSchema) || isProjectSchemaV3_12(maybeSchema) || isProjectSchemaV3_12_1(maybeSchema) || isProjectSchemaV3_12_2(maybeSchema));
100
+ return isObject(value) && isString(maybeSchema.projectId) && (isV1XSchema(maybeSchema) || isV3XSchema(maybeSchema));
95
101
  }
96
102
  export function isProjectSchemaWithServices(schema) {
97
103
  return typeof schema.dataKey !== 'undefined' && typeof schema.services !== 'undefined';
package/es/validate.js CHANGED
@@ -279,26 +279,26 @@ function validateIndexedShapeConfig(projectSchema, shapeName, config) {
279
279
  var _config$queries;
280
280
 
281
281
  const errors = [];
282
- const all = (_config$queries = config.queries) === null || _config$queries === void 0 ? void 0 : _config$queries.all;
282
+ const list = (_config$queries = config.queries) === null || _config$queries === void 0 ? void 0 : _config$queries.list;
283
283
 
284
- if (all) {
285
- if (projectSchema.queries[all.name] === undefined) {
284
+ if (list) {
285
+ if (projectSchema.queries[list.name] === undefined) {
286
286
  errors.push({
287
- path: ['indexedShapes', shapeName, 'queries', 'all', 'name'],
287
+ path: ['indexedShapes', shapeName, 'queries', 'list', 'name'],
288
288
  type: 'notFound',
289
- message: `Invalid query "${all.name}"`
289
+ message: `Invalid query "${list.name}"`
290
290
  });
291
291
  }
292
292
 
293
293
  const shape = projectSchema.shapes[shapeName]; // Resolved shapes are not checked
294
294
 
295
- if (shape && all.ignoreFields) {
296
- for (const fieldName of all.ignoreFields) {
295
+ if (shape && list.ignoreFields) {
296
+ for (const fieldName of list.ignoreFields) {
297
297
  var _properties;
298
298
 
299
299
  if (((_properties = shape.schema.properties) === null || _properties === void 0 ? void 0 : _properties[fieldName]) === undefined) {
300
300
  errors.push({
301
- path: ['indexedShapes', shapeName, 'queries', 'all', 'ignoreFields'],
301
+ path: ['indexedShapes', shapeName, 'queries', 'list', 'ignoreFields'],
302
302
  type: 'notFound',
303
303
  message: `Invalid property "${fieldName}" on shape "${shapeName}"`
304
304
  });
@@ -393,10 +393,8 @@ function validateRefs(projectSchema, additionalShapeNames = builtInShapeNames) {
393
393
  }
394
394
 
395
395
  function validateDirectives(projectSchema, additionalShapeIds = builtInModelShapeIds) {
396
- const errors = []; // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
397
-
398
- const projectShapeIds = new Set([...getModelShapeIds(projectSchema.shapes), ...additionalShapeIds]); // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
399
-
396
+ const errors = [];
397
+ const projectShapeIds = new Set([...getModelShapeIds(projectSchema.shapes), ...additionalShapeIds]);
400
398
  visitShapeProperties(projectSchema.shapes, (schema, path) => {
401
399
  if (schema['@relationship']) {
402
400
  var _schema$Relationship;
@@ -428,8 +426,7 @@ function validateDirectives(projectSchema, additionalShapeIds = builtInModelShap
428
426
  }
429
427
 
430
428
  function validateOneOfs(projectSchema) {
431
- const errors = []; // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
432
-
429
+ const errors = [];
433
430
  visitShapeProperties(projectSchema.shapes, (schema, path) => {
434
431
  const oneOfPath = schema.items ? ['items', 'oneOf'] : ['oneOf'];
435
432
  schema = schema.items ? schema.items : schema;