@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.
- package/es/enum.js +1 -1
- package/es/get-is-leaf.js +5 -5
- package/es/layers/type-utils.js +2 -2
- package/es/migration.js +59 -1
- package/es/project-schema/index.js +1 -0
- package/es/project-schema/v3.10.0.js +1 -0
- package/es/refs.js +19 -19
- package/es/schema-util.js +11 -7
- package/es/schemas/index.js +15 -15
- package/es/schemas/index.ts +26 -25
- package/es/schemas/project-schema/v3.10.0.json +2091 -0
- package/es/schemas/project-schema/v4.0.0.json +8 -6
- package/es/schemas/project-schema.json +2 -1
- package/es/types/types.js +1 -1
- package/es/types/utils.js +20 -19
- package/es/util/detect-cycles.js +1 -1
- package/es/validate.js +2 -2
- package/examples/dependencies/fabric-ecommerce.json +9716 -0
- package/examples/dependencies/pruned-shopify-product-schema.json +9672 -0
- package/examples/dependencies/shopify-store-with-widget.json +9854 -0
- package/examples/dependencies/stripe-starter-resolved.json +27345 -0
- package/examples/latest/blog-schema.json +32 -32
- package/examples/latest/brewery-schema.json +53 -53
- package/examples/latest/complex-project-schema.json +3278 -3278
- package/examples/latest/fabric-ecommerce.json +9097 -315
- package/examples/latest/frank-and-fred-schema.json +15588 -15588
- package/examples/latest/massive-schema.json +5836 -5836
- package/examples/latest/mill-components-schema.json +876 -876
- package/examples/latest/pet-oneof-array.json +77 -77
- package/examples/latest/post-schema.json +23 -23
- package/examples/latest/pruned-shopify-product-schema.json +2843 -2504
- package/examples/latest/real-world-schema.json +166 -166
- package/examples/latest/recursive-repeater-schema.json +14 -14
- package/examples/latest/recursive-schema.json +14 -14
- package/examples/latest/rick-and-morty-ast.json +1874 -1895
- package/examples/latest/rick-and-morty-graphql.json +1093 -1093
- package/examples/latest/rick-and-morty-rest.json +20 -20
- package/examples/latest/schema-with-repeater-draftjs.json +9 -9
- package/examples/latest/shape-books-v3_2_0.json +218 -218
- package/examples/latest/shape-books.json +218 -218
- package/examples/latest/shopify-lookbook.json +147 -147
- package/examples/latest/shopify-store-with-widget.json +5706 -5408
- package/examples/latest/stripe-starter-resolved.json +21000 -13065
- package/examples/latest/user-schema-no-required.json +19 -19
- package/examples/latest/user-schema-with-defaults.json +20 -20
- package/examples/source/fabric-ecommerce.json +0 -894
- package/examples/source/pruned-shopify-product-schema.json +1 -9333
- package/examples/source/rick-and-morty-ast.json +0 -21
- package/examples/source/shopify-store-with-widget.json +0 -8953
- package/examples/source/stripe-starter-resolved.json +0 -19409
- package/lib/content-schema-transform.d.ts +13 -13
- package/lib/content-schema-transform.d.ts.map +1 -1
- package/lib/enum.d.ts +2 -2
- package/lib/enum.d.ts.map +1 -1
- package/lib/enum.js +2 -2
- package/lib/get-is-leaf.d.ts +2 -2
- package/lib/get-is-leaf.d.ts.map +1 -1
- package/lib/get-is-leaf.js +5 -5
- package/lib/layers/type-utils.js +1 -1
- package/lib/migration.d.ts +6 -5
- package/lib/migration.d.ts.map +1 -1
- package/lib/migration.js +60 -0
- package/lib/project-schema/index.d.ts +3 -1
- package/lib/project-schema/index.d.ts.map +1 -1
- package/lib/project-schema/index.js +25 -12
- package/lib/project-schema/latest.d.ts +260 -238
- package/lib/project-schema/latest.d.ts.map +1 -1
- package/lib/project-schema/v1.0.0.d.ts +14 -7
- package/lib/project-schema/v1.0.0.d.ts.map +1 -1
- package/lib/project-schema/v3.0.0.d.ts +24 -25
- package/lib/project-schema/v3.0.0.d.ts.map +1 -1
- package/lib/project-schema/v3.1.0.d.ts +42 -43
- package/lib/project-schema/v3.1.0.d.ts.map +1 -1
- package/lib/project-schema/v3.10.0.d.ts +1202 -0
- package/lib/project-schema/v3.10.0.d.ts.map +1 -0
- package/lib/project-schema/v3.10.0.js +5 -0
- package/lib/project-schema/v3.2.0.d.ts +42 -43
- package/lib/project-schema/v3.2.0.d.ts.map +1 -1
- package/lib/project-schema/v3.3.0.d.ts +42 -43
- package/lib/project-schema/v3.3.0.d.ts.map +1 -1
- package/lib/project-schema/v3.4.0.d.ts +42 -43
- package/lib/project-schema/v3.4.0.d.ts.map +1 -1
- package/lib/project-schema/v3.5.0.d.ts +42 -43
- package/lib/project-schema/v3.5.0.d.ts.map +1 -1
- package/lib/project-schema/v3.5.1.d.ts +42 -43
- package/lib/project-schema/v3.5.1.d.ts.map +1 -1
- package/lib/project-schema/v3.6.0.d.ts +42 -43
- package/lib/project-schema/v3.6.0.d.ts.map +1 -1
- package/lib/project-schema/v3.7.0.d.ts +42 -43
- package/lib/project-schema/v3.7.0.d.ts.map +1 -1
- package/lib/project-schema/v3.8.0.d.ts +42 -43
- package/lib/project-schema/v3.8.0.d.ts.map +1 -1
- package/lib/project-schema/v3.9.0.d.ts +42 -43
- package/lib/project-schema/v3.9.0.d.ts.map +1 -1
- package/lib/project-schema/v4.0.0.d.ts +54 -52
- package/lib/project-schema/v4.0.0.d.ts.map +1 -1
- package/lib/refs.d.ts +8 -8
- package/lib/refs.d.ts.map +1 -1
- package/lib/refs.js +19 -19
- package/lib/schema-util.d.ts +23 -23
- package/lib/schema-util.d.ts.map +1 -1
- package/lib/schema-util.js +11 -7
- package/lib/schemas/index.d.ts +3421 -3420
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +26 -30
- package/lib/schemas/index.ts +26 -25
- package/lib/schemas/project-schema/v3.10.0.json +2091 -0
- package/lib/schemas/project-schema/v4.0.0.json +8 -6
- package/lib/schemas/project-schema.json +2 -1
- package/lib/types/types.d.ts +7 -7
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js +1 -1
- package/lib/types/utils.d.ts +9 -8
- package/lib/types/utils.d.ts.map +1 -1
- package/lib/types/utils.js +25 -23
- package/lib/unions.d.ts +8 -8
- package/lib/unions.d.ts.map +1 -1
- package/lib/util/detect-cycles.d.ts +2 -2
- package/lib/util/detect-cycles.d.ts.map +1 -1
- package/lib/util/detect-cycles.js +1 -1
- package/lib/validate.js +1 -1
- package/lib/workflows.d.ts +2 -2
- package/lib/workflows.d.ts.map +1 -1
- 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
|
-
"
|
|
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
|
-
"
|
|
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
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,
|
|
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
|
-
} =
|
|
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
|
-
} =
|
|
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(
|
|
193
|
-
return isString(
|
|
193
|
+
export function isRefSchema(propertySchema) {
|
|
194
|
+
return isString(propertySchema['@ref']) || isString(propertySchema.$ref);
|
|
194
195
|
}
|
|
195
|
-
export function isRefSchemaLegacy(
|
|
196
|
-
return isString(
|
|
196
|
+
export function isRefSchemaLegacy(propertySchema) {
|
|
197
|
+
return isString(propertySchema.$ref);
|
|
197
198
|
}
|
|
198
|
-
export function isAllOfSchema(
|
|
199
|
-
return isArray(
|
|
199
|
+
export function isAllOfSchema(propertySchema) {
|
|
200
|
+
return isArray(propertySchema.allOf);
|
|
200
201
|
}
|
|
201
|
-
export function isOneOfSchema(
|
|
202
|
-
return isArray(
|
|
202
|
+
export function isOneOfSchema(propertySchema) {
|
|
203
|
+
return isArray(propertySchema.oneOf);
|
|
203
204
|
}
|
|
204
|
-
export function
|
|
205
|
-
return
|
|
205
|
+
export function isEnumSchema(obj) {
|
|
206
|
+
return isArray(obj.enum);
|
|
206
207
|
}
|
|
207
|
-
export function
|
|
208
|
-
return
|
|
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
|
*
|
package/es/util/detect-cycles.js
CHANGED
|
@@ -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
|
|
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 {
|
|
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 (!
|
|
384
|
+
} else if (!isEnumLikeSchema(schema)) {
|
|
385
385
|
errors.push({
|
|
386
386
|
type: 'json',
|
|
387
387
|
path: path.concat(oneOfPath),
|