@takeshape/schema 8.20.1 → 8.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/es/enum.js +1 -1
  2. package/es/get-is-leaf.js +5 -5
  3. package/es/layers/type-utils.js +2 -2
  4. package/es/migration.js +59 -1
  5. package/es/project-schema/index.js +1 -0
  6. package/es/project-schema/v3.10.0.js +1 -0
  7. package/es/refs.js +19 -19
  8. package/es/schema-util.js +11 -7
  9. package/es/schemas/index.js +15 -15
  10. package/es/schemas/index.ts +26 -25
  11. package/es/schemas/project-schema/v3.10.0.json +2091 -0
  12. package/es/schemas/project-schema/v4.0.0.json +8 -6
  13. package/es/schemas/project-schema.json +2 -1
  14. package/es/types/types.js +1 -1
  15. package/es/types/utils.js +20 -19
  16. package/es/util/detect-cycles.js +1 -1
  17. package/es/validate.js +2 -2
  18. package/examples/dependencies/fabric-ecommerce.json +9716 -0
  19. package/examples/dependencies/pruned-shopify-product-schema.json +9672 -0
  20. package/examples/dependencies/shopify-store-with-widget.json +9854 -0
  21. package/examples/dependencies/stripe-starter-resolved.json +27345 -0
  22. package/examples/latest/blog-schema.json +32 -32
  23. package/examples/latest/brewery-schema.json +53 -53
  24. package/examples/latest/complex-project-schema.json +3278 -3278
  25. package/examples/latest/fabric-ecommerce.json +9097 -315
  26. package/examples/latest/frank-and-fred-schema.json +15588 -15588
  27. package/examples/latest/massive-schema.json +5836 -5836
  28. package/examples/latest/mill-components-schema.json +876 -876
  29. package/examples/latest/pet-oneof-array.json +77 -77
  30. package/examples/latest/post-schema.json +23 -23
  31. package/examples/latest/pruned-shopify-product-schema.json +2843 -2504
  32. package/examples/latest/real-world-schema.json +166 -166
  33. package/examples/latest/recursive-repeater-schema.json +14 -14
  34. package/examples/latest/recursive-schema.json +14 -14
  35. package/examples/latest/rick-and-morty-ast.json +1874 -1895
  36. package/examples/latest/rick-and-morty-graphql.json +1093 -1093
  37. package/examples/latest/rick-and-morty-rest.json +20 -20
  38. package/examples/latest/schema-with-repeater-draftjs.json +9 -9
  39. package/examples/latest/shape-books-v3_2_0.json +218 -218
  40. package/examples/latest/shape-books.json +218 -218
  41. package/examples/latest/shopify-lookbook.json +147 -147
  42. package/examples/latest/shopify-store-with-widget.json +5706 -5408
  43. package/examples/latest/stripe-starter-resolved.json +21000 -13065
  44. package/examples/latest/user-schema-no-required.json +19 -19
  45. package/examples/latest/user-schema-with-defaults.json +20 -20
  46. package/examples/source/fabric-ecommerce.json +0 -894
  47. package/examples/source/pruned-shopify-product-schema.json +1 -9333
  48. package/examples/source/rick-and-morty-ast.json +0 -21
  49. package/examples/source/shopify-store-with-widget.json +0 -8953
  50. package/examples/source/stripe-starter-resolved.json +0 -19409
  51. package/lib/content-schema-transform.d.ts +13 -13
  52. package/lib/content-schema-transform.d.ts.map +1 -1
  53. package/lib/enum.d.ts +2 -2
  54. package/lib/enum.d.ts.map +1 -1
  55. package/lib/enum.js +2 -2
  56. package/lib/get-is-leaf.d.ts +2 -2
  57. package/lib/get-is-leaf.d.ts.map +1 -1
  58. package/lib/get-is-leaf.js +5 -5
  59. package/lib/layers/type-utils.js +1 -1
  60. package/lib/migration.d.ts +6 -5
  61. package/lib/migration.d.ts.map +1 -1
  62. package/lib/migration.js +60 -0
  63. package/lib/project-schema/index.d.ts +3 -1
  64. package/lib/project-schema/index.d.ts.map +1 -1
  65. package/lib/project-schema/index.js +25 -12
  66. package/lib/project-schema/latest.d.ts +260 -238
  67. package/lib/project-schema/latest.d.ts.map +1 -1
  68. package/lib/project-schema/v1.0.0.d.ts +14 -7
  69. package/lib/project-schema/v1.0.0.d.ts.map +1 -1
  70. package/lib/project-schema/v3.0.0.d.ts +24 -25
  71. package/lib/project-schema/v3.0.0.d.ts.map +1 -1
  72. package/lib/project-schema/v3.1.0.d.ts +42 -43
  73. package/lib/project-schema/v3.1.0.d.ts.map +1 -1
  74. package/lib/project-schema/v3.10.0.d.ts +1202 -0
  75. package/lib/project-schema/v3.10.0.d.ts.map +1 -0
  76. package/lib/project-schema/v3.10.0.js +5 -0
  77. package/lib/project-schema/v3.2.0.d.ts +42 -43
  78. package/lib/project-schema/v3.2.0.d.ts.map +1 -1
  79. package/lib/project-schema/v3.3.0.d.ts +42 -43
  80. package/lib/project-schema/v3.3.0.d.ts.map +1 -1
  81. package/lib/project-schema/v3.4.0.d.ts +42 -43
  82. package/lib/project-schema/v3.4.0.d.ts.map +1 -1
  83. package/lib/project-schema/v3.5.0.d.ts +42 -43
  84. package/lib/project-schema/v3.5.0.d.ts.map +1 -1
  85. package/lib/project-schema/v3.5.1.d.ts +42 -43
  86. package/lib/project-schema/v3.5.1.d.ts.map +1 -1
  87. package/lib/project-schema/v3.6.0.d.ts +42 -43
  88. package/lib/project-schema/v3.6.0.d.ts.map +1 -1
  89. package/lib/project-schema/v3.7.0.d.ts +42 -43
  90. package/lib/project-schema/v3.7.0.d.ts.map +1 -1
  91. package/lib/project-schema/v3.8.0.d.ts +42 -43
  92. package/lib/project-schema/v3.8.0.d.ts.map +1 -1
  93. package/lib/project-schema/v3.9.0.d.ts +42 -43
  94. package/lib/project-schema/v3.9.0.d.ts.map +1 -1
  95. package/lib/project-schema/v4.0.0.d.ts +54 -52
  96. package/lib/project-schema/v4.0.0.d.ts.map +1 -1
  97. package/lib/refs.d.ts +8 -8
  98. package/lib/refs.d.ts.map +1 -1
  99. package/lib/refs.js +19 -19
  100. package/lib/schema-util.d.ts +23 -23
  101. package/lib/schema-util.d.ts.map +1 -1
  102. package/lib/schema-util.js +11 -7
  103. package/lib/schemas/index.d.ts +3421 -3420
  104. package/lib/schemas/index.d.ts.map +1 -1
  105. package/lib/schemas/index.js +26 -30
  106. package/lib/schemas/index.ts +26 -25
  107. package/lib/schemas/project-schema/v3.10.0.json +2091 -0
  108. package/lib/schemas/project-schema/v4.0.0.json +8 -6
  109. package/lib/schemas/project-schema.json +2 -1
  110. package/lib/types/types.d.ts +7 -7
  111. package/lib/types/types.d.ts.map +1 -1
  112. package/lib/types/types.js +1 -1
  113. package/lib/types/utils.d.ts +9 -8
  114. package/lib/types/utils.d.ts.map +1 -1
  115. package/lib/types/utils.js +25 -23
  116. package/lib/unions.d.ts +8 -8
  117. package/lib/unions.d.ts.map +1 -1
  118. package/lib/util/detect-cycles.d.ts +2 -2
  119. package/lib/util/detect-cycles.d.ts.map +1 -1
  120. package/lib/util/detect-cycles.js +1 -1
  121. package/lib/validate.js +1 -1
  122. package/lib/workflows.d.ts +2 -2
  123. package/lib/workflows.d.ts.map +1 -1
  124. package/package.json +5 -5
@@ -3,6 +3,7 @@
3
3
  "$id": "https://schema.takeshape.io/project-schema/v4.0.0#",
4
4
  "definitions": {
5
5
  "schemaArray": {
6
+ "title": "Schema Array",
6
7
  "type": "array",
7
8
  "minItems": 1,
8
9
  "items": {
@@ -10,10 +11,12 @@
10
11
  }
11
12
  },
12
13
  "nonNegativeInteger": {
14
+ "title": "Non Negative Integer",
13
15
  "type": "integer",
14
16
  "minimum": 0
15
17
  },
16
18
  "nonNegativeIntegerDefault0": {
19
+ "title": "Non Negative Integer Default 0",
17
20
  "allOf": [
18
21
  {
19
22
  "$ref": "#/definitions/nonNegativeInteger"
@@ -24,9 +27,11 @@
24
27
  ]
25
28
  },
26
29
  "simpleTypes": {
30
+ "title": "Simple Types",
27
31
  "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
28
32
  },
29
33
  "stringArray": {
34
+ "title": "String Array",
30
35
  "type": "array",
31
36
  "items": {
32
37
  "type": "string"
@@ -57,6 +62,7 @@
57
62
  "additionalProperties": false
58
63
  },
59
64
  "mappingString": {
65
+ "title": "Mapping String",
60
66
  "type": "string",
61
67
  "pattern": "^[\\w-]+(?::[\\w-]+)+(?:\\.[\\w-]+)+$"
62
68
  },
@@ -79,7 +85,7 @@
79
85
  "type": "object",
80
86
  "properties": {
81
87
  "@ref": {
82
- "$ref": "#/definitions/ref"
88
+ "type": "string"
83
89
  }
84
90
  },
85
91
  "required": ["@ref"]
@@ -89,7 +95,7 @@
89
95
  "type": "object",
90
96
  "properties": {
91
97
  "$ref": {
92
- "$ref": "#/definitions/ref"
98
+ "type": "string"
93
99
  }
94
100
  },
95
101
  "required": ["$ref"]
@@ -1220,10 +1226,6 @@
1220
1226
  "title": "Resolver",
1221
1227
  "oneOf": [{"$ref": "#/definitions/basicResolver"}, {"$ref": "#/definitions/composeResolver"}]
1222
1228
  },
1223
- "ref": {
1224
- "title": "Ref",
1225
- "type": "string"
1226
- },
1227
1229
  "query": {
1228
1230
  "title": "Query",
1229
1231
  "type": "object",
@@ -14,6 +14,7 @@
14
14
  {"$ref": "https://schema.takeshape.io/project-schema/v3.6.0#"},
15
15
  {"$ref": "https://schema.takeshape.io/project-schema/v3.7.0#"},
16
16
  {"$ref": "https://schema.takeshape.io/project-schema/v3.8.0#"},
17
- {"$ref": "https://schema.takeshape.io/project-schema/v3.9.0#"}
17
+ {"$ref": "https://schema.takeshape.io/project-schema/v3.9.0#"},
18
+ {"$ref": "https://schema.takeshape.io/project-schema/v3.10.0#"}
18
19
  ]
19
20
  }
package/es/types/types.js CHANGED
@@ -18,7 +18,7 @@
18
18
  */
19
19
  export let RefType;
20
20
  /**
21
- * Stub of a ContentSchema that may contain a `$ref` or `@ref`.
21
+ * Stub of a PropertySchema that may contain a `$ref` or `@ref`.
22
22
  */
23
23
 
24
24
  (function (RefType) {
package/es/types/utils.js CHANGED
@@ -6,7 +6,7 @@ import isPlainObject from 'lodash/isPlainObject';
6
6
  import isString from 'lodash/isString';
7
7
  import isArray from 'lodash/isArray';
8
8
  import has from 'lodash/has';
9
- import { CURRENT_SCHEMA_VERSION, latestMetaSchemaJson } from '../schemas';
9
+ import { CURRENT_SCHEMA_VERSION, latestSchemaJson } from '../schemas';
10
10
  import satisfies from 'semver/functions/satisfies';
11
11
  /** Resolver Type Utils **/
12
12
 
@@ -28,7 +28,7 @@ const {
28
28
  restResolver,
29
29
  awsLambdaResolver
30
30
  }
31
- } = latestMetaSchemaJson;
31
+ } = latestSchemaJson;
32
32
  export function isTakeshapeResolver(resolver) {
33
33
  return takeshapeResolver.properties.name.enum.includes(resolver.name);
34
34
  }
@@ -67,6 +67,7 @@ export const isProjectSchemaV3_6 = createVersionPredicate('3.6.0');
67
67
  export const isProjectSchemaV3_7 = createVersionPredicate('3.7.0');
68
68
  export const isProjectSchemaV3_8 = createVersionPredicate('3.8.0');
69
69
  export const isProjectSchemaV3_9 = createVersionPredicate('3.9.0');
70
+ export const isProjectSchemaV3_10 = createVersionPredicate('3.10.0');
70
71
  export const isLatestProjectSchema = createVersionPredicate(CURRENT_SCHEMA_VERSION);
71
72
  export function isV3XSchema(maybeSchema) {
72
73
  if (!isObject(maybeSchema) || !isString(maybeSchema.projectId) || !isString(maybeSchema.schemaVersion)) {
@@ -86,7 +87,7 @@ export function isAnyProjectSchema(value) {
86
87
  }
87
88
 
88
89
  const maybeSchema = value;
89
- 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));
90
+ 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));
90
91
  }
91
92
  export function isProjectSchemaWithServices(schema) {
92
93
  return typeof schema.dataKey !== 'undefined' && typeof schema.services !== 'undefined';
@@ -173,7 +174,7 @@ const {
173
174
  parameterSerializeStyleOptionsForSearchParams,
174
175
  parameterSerializeStyleOptionsForPathParams
175
176
  }
176
- } = latestMetaSchemaJson;
177
+ } = latestSchemaJson;
177
178
  export function isParameterSerializeStyleForSearchParams(maybeParam) {
178
179
  return Boolean(maybeParam && parameterSerializeStyleOptionsForSearchParams.properties.style.enum.includes(maybeParam));
179
180
  }
@@ -189,23 +190,26 @@ export function isParameterSerializeStyleOptions(maybeStyle) {
189
190
  }
190
191
  /** Typeguards for different types of shape schemas **/
191
192
 
192
- export function isRefSchema(maybeRefSchema) {
193
- return isString(maybeRefSchema['@ref']) || isString(maybeRefSchema.$ref);
193
+ export function isRefSchema(propertySchema) {
194
+ return isString(propertySchema['@ref']) || isString(propertySchema.$ref);
194
195
  }
195
- export function isRefSchemaLegacy(maybeRefSchema) {
196
- return isString(maybeRefSchema.$ref);
196
+ export function isRefSchemaLegacy(propertySchema) {
197
+ return isString(propertySchema.$ref);
197
198
  }
198
- export function isAllOfSchema(maybeExtendableSchema) {
199
- return isArray(maybeExtendableSchema.allOf);
199
+ export function isAllOfSchema(propertySchema) {
200
+ return isArray(propertySchema.allOf);
200
201
  }
201
- export function isOneOfSchema(maybeExclusiveOrSchema) {
202
- return isArray(maybeExclusiveOrSchema.oneOf);
202
+ export function isOneOfSchema(propertySchema) {
203
+ return isArray(propertySchema.oneOf);
203
204
  }
204
- export function isArraySchema(maybeArraySchema) {
205
- return maybeArraySchema.type === 'array' && isObject(maybeArraySchema.items);
205
+ export function isEnumSchema(obj) {
206
+ return isArray(obj.enum);
206
207
  }
207
- export function isObjectSchema(maybeObjectSchema) {
208
- return maybeObjectSchema.type === 'object' && isObject(maybeObjectSchema.properties);
208
+ export function isArraySchema(propertySchema) {
209
+ return propertySchema.type === 'array' && isObject(propertySchema.items);
210
+ }
211
+ export function isObjectSchema(propertySchema) {
212
+ return propertySchema.type === 'object' && isObject(propertySchema.properties);
209
213
  }
210
214
  /** Service Config Utils **/
211
215
 
@@ -274,9 +278,6 @@ export const getArgsType = argsSchema => {
274
278
  return ArgsType.args;
275
279
  }
276
280
  };
277
- export function isContentObjectSchema(maybeSchema) {
278
- return isRefSchema(maybeSchema) || isAllOfSchema(maybeSchema) || isObjectSchema(maybeSchema);
279
- }
280
281
  /**
281
282
  * A utility to return the type of ref present on a schema.
282
283
  *
@@ -27,7 +27,7 @@ export function hasCycle(projectSchema, schema, shapesSeen = new Set()) {
27
27
  return hasCycle(projectSchema, refShape.schema, immutableSetAdd(shapesSeen, refShape.name));
28
28
  }
29
29
 
30
- const combo = schema.oneOf ?? schema.allOf ?? schema.anyOf;
30
+ const combo = schema.oneOf ?? schema.allOf;
31
31
 
32
32
  if (combo) {
33
33
  return combo.some(childSchema => hasCycle(projectSchema, childSchema, shapesSeen));
package/es/validate.js CHANGED
@@ -16,7 +16,7 @@ import { isBasicResolver, isComposeResolver } from './types/utils';
16
16
  import { refItemToAtRef, refItemToShapeName } from './refs';
17
17
  import { scalars } from './scalars';
18
18
  import { enumerateOneOfKeys, isUnionSchema } from './unions';
19
- import { isEnumSchema } from './enum';
19
+ import { isEnumLikeSchema } from './enum';
20
20
  import metaSchemaV3_9_0 from './schemas/project-schema/meta-schema-v3.9.0.json';
21
21
 
22
22
  function findDuplicates(items) {
@@ -381,7 +381,7 @@ function validateOneOfs(projectSchema) {
381
381
  message: `Invalid refs to ${shapeNames}. oneOf unions cannot reference model shapes. Use @relationship instead`
382
382
  });
383
383
  }
384
- } else if (!isEnumSchema(schema)) {
384
+ } else if (!isEnumLikeSchema(schema)) {
385
385
  errors.push({
386
386
  type: 'json',
387
387
  path: path.concat(oneOfPath),