@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.
- package/es/index.js +2 -1
- package/es/migration/index.js +11 -1
- package/es/migration/to/v3.0.0.js +19 -1
- package/es/migration/to/v3.12.3.js +81 -0
- package/es/migration/to/v3.13.0.js +21 -0
- package/es/migration/utils.js +0 -17
- package/es/project-schema/index.js +2 -0
- package/es/project-schema/v3.12.3.js +1 -0
- package/es/project-schema/v3.13.0.js +1 -0
- package/es/relationships.js +17 -0
- package/es/schema-util.js +9 -4
- package/es/schemas/index.js +5 -3
- package/es/schemas/index.ts +6 -2
- package/es/schemas/project-schema/v3.12.3.json +2358 -0
- package/es/schemas/project-schema/v3.13.0.json +2371 -0
- package/es/types/utils.js +7 -1
- package/es/validate.js +11 -14
- package/examples/latest/betzino.json +2325 -516
- package/examples/latest/blog-schema.json +14 -5
- package/examples/latest/brewery-schema.json +4 -1
- package/examples/latest/complex-project-schema.json +100 -1
- package/examples/latest/fabric-ecommerce.json +1 -1
- package/examples/latest/frank-and-fred-schema.json +673 -1
- package/examples/latest/massive-schema.json +272 -17
- package/examples/latest/mill-components-schema.json +43 -4
- package/examples/latest/pet-oneof-array.json +1 -1
- package/examples/latest/post-schema.json +6 -3
- package/examples/latest/pruned-shopify-product-schema.json +1 -1
- package/examples/latest/real-world-schema.json +18 -3
- package/examples/latest/recursive-repeater-schema.json +4 -1
- package/examples/latest/recursive-schema.json +4 -1
- package/examples/latest/rick-and-morty-ast.json +43 -10
- package/examples/latest/rick-and-morty-graphql.json +24 -6
- package/examples/latest/rick-and-morty-rest.json +1 -1
- package/examples/latest/schema-with-repeater-draftjs.json +10 -1
- package/examples/latest/shape-books-v3_2_0.json +40 -7
- package/examples/latest/shape-books.json +40 -7
- package/examples/latest/shopify-lookbook.json +11 -5
- package/examples/latest/shopify-store-with-widget.json +1 -1
- package/examples/latest/stripe-starter-resolved.json +5 -2
- package/examples/latest/user-schema-no-required.json +1 -1
- package/examples/latest/user-schema-with-defaults.json +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +14 -0
- package/lib/migration/index.d.ts.map +1 -1
- package/lib/migration/index.js +12 -0
- package/lib/migration/to/v3.0.0.d.ts.map +1 -1
- package/lib/migration/to/v3.0.0.js +19 -1
- package/lib/migration/to/v3.12.3.d.ts +4 -0
- package/lib/migration/to/v3.12.3.d.ts.map +1 -0
- package/lib/migration/to/v3.12.3.js +91 -0
- package/lib/migration/to/v3.13.0.d.ts +4 -0
- package/lib/migration/to/v3.13.0.d.ts.map +1 -0
- package/lib/migration/to/v3.13.0.js +32 -0
- package/lib/migration/utils.d.ts +0 -2
- package/lib/migration/utils.d.ts.map +1 -1
- package/lib/migration/utils.js +0 -19
- package/lib/project-schema/index.d.ts +5 -1
- package/lib/project-schema/index.d.ts.map +1 -1
- package/lib/project-schema/index.js +43 -17
- package/lib/project-schema/latest.d.ts +50 -16
- package/lib/project-schema/latest.d.ts.map +1 -1
- package/lib/project-schema/v3.12.3.d.ts +1307 -0
- package/lib/project-schema/v3.12.3.d.ts.map +1 -0
- package/lib/project-schema/v3.12.3.js +5 -0
- package/lib/project-schema/v3.13.0.d.ts +1318 -0
- package/lib/project-schema/v3.13.0.d.ts.map +1 -0
- package/lib/project-schema/v3.13.0.js +5 -0
- package/lib/project-schema/v4.0.0.d.ts +69 -0
- package/lib/project-schema/v4.0.0.d.ts.map +1 -1
- package/lib/relationships.d.ts +3 -0
- package/lib/relationships.d.ts.map +1 -0
- package/lib/relationships.js +24 -0
- package/lib/schema-util.d.ts +1 -0
- package/lib/schema-util.d.ts.map +1 -1
- package/lib/schema-util.js +9 -4
- package/lib/schemas/index.d.ts +2 -2
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +23 -19
- package/lib/schemas/index.ts +6 -2
- package/lib/schemas/project-schema/v3.12.3.json +2358 -0
- package/lib/schemas/project-schema/v3.13.0.json +2371 -0
- package/lib/types/types.d.ts +2 -2
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils.d.ts +4 -1
- package/lib/types/utils.d.ts.map +1 -1
- package/lib/types/utils.js +13 -2
- package/lib/validate.d.ts.map +1 -1
- package/lib/validate.js +11 -14
- 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) && (
|
|
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
|
|
282
|
+
const list = (_config$queries = config.queries) === null || _config$queries === void 0 ? void 0 : _config$queries.list;
|
|
283
283
|
|
|
284
|
-
if (
|
|
285
|
-
if (projectSchema.queries[
|
|
284
|
+
if (list) {
|
|
285
|
+
if (projectSchema.queries[list.name] === undefined) {
|
|
286
286
|
errors.push({
|
|
287
|
-
path: ['indexedShapes', shapeName, 'queries', '
|
|
287
|
+
path: ['indexedShapes', shapeName, 'queries', 'list', 'name'],
|
|
288
288
|
type: 'notFound',
|
|
289
|
-
message: `Invalid query "${
|
|
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 &&
|
|
296
|
-
for (const fieldName of
|
|
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', '
|
|
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 = [];
|
|
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 = [];
|
|
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;
|