@takeshape/schema 8.47.0 → 8.50.1
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/flatten-templates.js +1 -1
- package/es/migration/index.js +6 -1
- package/es/migration/to/v3.10.0.js +54 -15
- package/es/migration/to/v3.12.1.js +10 -0
- package/es/project-schema/index.js +1 -0
- package/es/project-schema/v3.12.1.js +1 -0
- package/es/schemas/index.js +4 -3
- package/es/schemas/index.ts +4 -2
- package/es/schemas/project-schema/v3.12.1.json +2281 -0
- package/es/schemas/project-schema.json +2 -1
- package/es/template-shapes/templates.js +1 -1
- package/es/template-shapes/where.js +55 -19
- package/es/types/utils.js +2 -1
- package/es/validate.js +69 -4
- package/examples/latest/betzino.json +43364 -0
- package/examples/latest/blog-schema.json +1 -1
- package/examples/latest/brewery-schema.json +1 -1
- package/examples/latest/complex-project-schema.json +1 -1
- package/examples/latest/fabric-ecommerce.json +1 -1
- package/examples/latest/frank-and-fred-schema.json +1 -1
- package/examples/latest/massive-schema.json +1 -1
- package/examples/latest/mill-components-schema.json +1 -1
- package/examples/latest/pet-oneof-array.json +1 -1
- package/examples/latest/post-schema.json +1 -1
- package/examples/latest/pruned-shopify-product-schema.json +1 -1
- package/examples/latest/real-world-schema.json +1 -1
- package/examples/latest/recursive-repeater-schema.json +1 -1
- package/examples/latest/recursive-schema.json +1 -1
- package/examples/latest/rick-and-morty-ast.json +1 -1
- package/examples/latest/rick-and-morty-graphql.json +1 -1
- package/examples/latest/rick-and-morty-rest.json +1 -1
- package/examples/latest/schema-with-repeater-draftjs.json +1 -1
- package/examples/latest/shape-books-v3_2_0.json +1 -1
- package/examples/latest/shape-books.json +1 -1
- package/examples/latest/shopify-lookbook.json +1 -1
- package/examples/latest/shopify-store-with-widget.json +1 -1
- package/examples/latest/stripe-starter-resolved.json +1 -1
- package/examples/latest/user-schema-no-required.json +1 -1
- package/examples/latest/user-schema-with-defaults.json +1 -1
- package/examples/source/betzino.json +43364 -0
- package/lib/flatten-templates.js +1 -1
- package/lib/migration/index.d.ts.map +1 -1
- package/lib/migration/index.js +6 -0
- package/lib/migration/to/v3.10.0.d.ts.map +1 -1
- package/lib/migration/to/v3.10.0.js +55 -15
- package/lib/migration/to/v3.12.1.d.ts +4 -0
- package/lib/migration/to/v3.12.1.d.ts.map +1 -0
- package/lib/migration/to/v3.12.1.js +18 -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 +28 -15
- package/lib/project-schema/latest.d.ts +61 -2
- package/lib/project-schema/latest.d.ts.map +1 -1
- package/lib/project-schema/v3.12.1.d.ts +1274 -0
- package/lib/project-schema/v3.12.1.d.ts.map +1 -0
- package/lib/project-schema/v3.12.1.js +5 -0
- package/lib/schemas/index.d.ts +2 -2
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +19 -17
- package/lib/schemas/index.ts +4 -2
- package/lib/schemas/project-schema/v3.12.1.json +2281 -0
- package/lib/schemas/project-schema.json +2 -1
- package/lib/template-shapes/templates.js +1 -1
- package/lib/template-shapes/where.d.ts +2 -1
- package/lib/template-shapes/where.d.ts.map +1 -1
- package/lib/template-shapes/where.js +57 -21
- package/lib/types/types.d.ts +2 -2
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils.d.ts +3 -2
- package/lib/types/utils.d.ts.map +1 -1
- package/lib/types/utils.js +4 -2
- package/lib/validate.d.ts.map +1 -1
- package/lib/validate.js +70 -4
- package/package.json +4 -4
package/es/flatten-templates.js
CHANGED
|
@@ -17,7 +17,7 @@ export function flattenTemplates(projectSchema) {
|
|
|
17
17
|
const {
|
|
18
18
|
shapeName,
|
|
19
19
|
dependencies
|
|
20
|
-
} = resolveTemplate(
|
|
20
|
+
} = resolveTemplate(newSchema, ref.template, refItemToShapeName(ref));
|
|
21
21
|
set(newSchema, ref.path, ref.path[ref.path.length - 1] === '@ref' ? `local:${shapeName}` : shapeName);
|
|
22
22
|
Object.assign(newSchema.shapes, dependencies);
|
|
23
23
|
}
|
package/es/migration/index.js
CHANGED
|
@@ -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 } 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 } 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';
|
|
@@ -13,6 +13,7 @@ import migrateToV3_9_0 from './to/v3.9.0';
|
|
|
13
13
|
import migrateToV3_10 from './to/v3.10.0';
|
|
14
14
|
import migrateToV3_11_0 from './to/v3.11.0';
|
|
15
15
|
import migrateToV3_12_0 from './to/v3.12.0';
|
|
16
|
+
import migrateToV3_12_1 from './to/v3.12.1';
|
|
16
17
|
export * from './utils';
|
|
17
18
|
export const listTypePrefix = 'PaginatedList';
|
|
18
19
|
export async function migrateToLatestProjectSchema(context, projectSchema) {
|
|
@@ -76,6 +77,10 @@ export async function migrateToLatestProjectSchema(context, projectSchema) {
|
|
|
76
77
|
projectSchema = migrateToV3_12_0(projectSchema);
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
if (isProjectSchemaV3_12(projectSchema)) {
|
|
81
|
+
projectSchema = migrateToV3_12_1(projectSchema);
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
return projectSchema;
|
|
80
85
|
}
|
|
81
86
|
export async function ensureLatest(context, schema) {
|
|
@@ -1,22 +1,60 @@
|
|
|
1
1
|
import mapValues from 'lodash/mapValues';
|
|
2
|
+
import set from 'lodash/fp/set';
|
|
2
3
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
shape
|
|
7
|
-
} = query;
|
|
4
|
+
function $refToPath(ref) {
|
|
5
|
+
return ref.substr(2).split('/');
|
|
6
|
+
}
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
8
|
+
function $refToShapeName(ref) {
|
|
9
|
+
return $refToPath(ref)[1];
|
|
10
|
+
}
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
function findServiceIdForNamespace(projectSchema, namespace) {
|
|
13
|
+
if (projectSchema.services) {
|
|
14
|
+
for (const [serviceId, service] of Object.entries(projectSchema.services)) {
|
|
15
|
+
if (service.namespace === namespace) {
|
|
16
|
+
return serviceId;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
return
|
|
21
|
+
return 'local';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function updateRefSyntax(projectSchema, $ref) {
|
|
25
|
+
const shapeName = $refToShapeName($ref);
|
|
26
|
+
const parts = shapeName.split('_');
|
|
27
|
+
const serviceId = parts.length === 1 ? 'local' : findServiceIdForNamespace(projectSchema, parts[0]);
|
|
28
|
+
return `${serviceId}:${parts[parts.length - 1]}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function migrateQueryToV3_10(projectSchema) {
|
|
32
|
+
return (query, queryName) => {
|
|
33
|
+
const {
|
|
34
|
+
args,
|
|
35
|
+
shape
|
|
36
|
+
} = query;
|
|
37
|
+
|
|
38
|
+
if (typeof args === 'object' && ('oneOf' in args || 'allOf' in args || '$ref' in args || '@ref' in args)) {
|
|
39
|
+
// As of 11/15/2021 no production schemas contained queries with these args
|
|
40
|
+
throw new Error(`Query "${queryName}" contains an unsupported arg schema ${JSON.stringify(args)}. Please contact support`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof shape === 'object') {
|
|
44
|
+
if (shape.items.$ref) {
|
|
45
|
+
return set('shape.items', {
|
|
46
|
+
'@ref': updateRefSyntax(projectSchema, shape.items.$ref)
|
|
47
|
+
}, query);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!shape.items['@ref']) {
|
|
51
|
+
// As of 11/15/2021 no production schemas contained queries with array return shapes that are not @refs
|
|
52
|
+
throw new Error(`Query "${queryName}" contains an unsupported shape schema ${JSON.stringify(shape)}. Please contact support`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return query;
|
|
57
|
+
};
|
|
20
58
|
}
|
|
21
59
|
|
|
22
60
|
function migrateShapeToV3_10(shape) {
|
|
@@ -45,9 +83,10 @@ function migrateToV3_10(projectSchema) {
|
|
|
45
83
|
schemaVersion,
|
|
46
84
|
...rest
|
|
47
85
|
} = projectSchema;
|
|
86
|
+
const migrate = migrateQueryToV3_10(projectSchema);
|
|
48
87
|
return { ...rest,
|
|
49
|
-
queries: mapValues(queries,
|
|
50
|
-
mutations: mapValues(mutations,
|
|
88
|
+
queries: mapValues(queries, migrate),
|
|
89
|
+
mutations: mapValues(mutations, migrate),
|
|
51
90
|
shapes: mapValues(shapes, migrateShapeToV3_10),
|
|
52
91
|
schemaVersion: '3.10.0'
|
|
53
92
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/schemas/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// This file is generated by "pnpm json2ts"
|
|
2
|
-
export const CURRENT_SCHEMA_VERSION = '3.12.
|
|
2
|
+
export const CURRENT_SCHEMA_VERSION = '3.12.1';
|
|
3
3
|
export { default as anyProjectSchema } from './project-schema.json';
|
|
4
|
-
export { default as latestSchemaJson } from './project-schema/v3.12.
|
|
4
|
+
export { default as latestSchemaJson } from './project-schema/v3.12.1.json';
|
|
5
5
|
import projectSchemaV4_0_0 from './project-schema/v4.0.0.json';
|
|
6
|
+
import projectSchemaV3_12_1 from './project-schema/v3.12.1.json';
|
|
6
7
|
import projectSchemaV3_12_0 from './project-schema/v3.12.0.json';
|
|
7
8
|
import projectSchemaV3_11_0 from './project-schema/v3.11.0.json';
|
|
8
9
|
import projectSchemaV3_10_0 from './project-schema/v3.10.0.json';
|
|
@@ -30,4 +31,4 @@ import projectSchemaV3_0_0 from './project-schema/v3.0.0.json';
|
|
|
30
31
|
import metaSchemaV3_0_0 from './project-schema/meta-schema-v3.0.0.json';
|
|
31
32
|
import projectSchemaV1_0_0 from './project-schema/v1.0.0.json';
|
|
32
33
|
import metaSchemaV1_0_0 from './project-schema/meta-schema-v1.0.0.json';
|
|
33
|
-
export const allProjectSchemas = [projectSchemaV4_0_0, 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];
|
|
34
|
+
export const allProjectSchemas = [projectSchemaV4_0_0, 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];
|
package/es/schemas/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// This file is generated by "pnpm json2ts"
|
|
2
|
-
export const CURRENT_SCHEMA_VERSION = '3.12.
|
|
2
|
+
export const CURRENT_SCHEMA_VERSION = '3.12.1';
|
|
3
3
|
export {default as anyProjectSchema} from './project-schema.json';
|
|
4
|
-
export {default as latestSchemaJson} from './project-schema/v3.12.
|
|
4
|
+
export {default as latestSchemaJson} from './project-schema/v3.12.1.json';
|
|
5
5
|
import projectSchemaV4_0_0 from './project-schema/v4.0.0.json';
|
|
6
|
+
import projectSchemaV3_12_1 from './project-schema/v3.12.1.json';
|
|
6
7
|
import projectSchemaV3_12_0 from './project-schema/v3.12.0.json';
|
|
7
8
|
import projectSchemaV3_11_0 from './project-schema/v3.11.0.json';
|
|
8
9
|
import projectSchemaV3_10_0 from './project-schema/v3.10.0.json';
|
|
@@ -32,6 +33,7 @@ import projectSchemaV1_0_0 from './project-schema/v1.0.0.json';
|
|
|
32
33
|
import metaSchemaV1_0_0 from './project-schema/meta-schema-v1.0.0.json';
|
|
33
34
|
export const allProjectSchemas = [
|
|
34
35
|
projectSchemaV4_0_0,
|
|
36
|
+
projectSchemaV3_12_1,
|
|
35
37
|
projectSchemaV3_12_0,
|
|
36
38
|
projectSchemaV3_11_0,
|
|
37
39
|
projectSchemaV3_10_0,
|