@takeshape/schema 8.281.0 → 8.282.3
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/dist/migration/index.d.ts +1 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +4 -1
- package/dist/migration/to/v3.28.0.d.ts +5 -0
- package/dist/migration/to/v3.28.0.d.ts.map +1 -0
- package/dist/migration/to/v3.28.0.js +18 -0
- package/dist/project-schema/index.d.ts +4 -1
- package/dist/project-schema/index.d.ts.map +1 -1
- package/dist/project-schema/index.js +20 -3
- package/dist/project-schema/latest.d.ts +23 -4
- package/dist/project-schema/latest.d.ts.map +1 -1
- package/dist/project-schema/migrate.d.ts.map +1 -1
- package/dist/project-schema/migrate.js +4 -0
- package/dist/project-schema/v3.28.0.d.ts +1417 -0
- package/dist/project-schema/v3.28.0.d.ts.map +1 -0
- package/dist/project-schema/v3.28.0.js +5 -0
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +6 -4
- package/dist/schemas/index.ts +4 -2
- package/dist/schemas/project-schema/latest.json +49 -4
- package/dist/schemas/project-schema/v3.28.0.json +3013 -0
- package/dist/schemas/project-schema.json +3 -0
- package/dist/types/types.d.ts +2 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/util/api-indexing.d.ts +3 -1
- package/dist/util/api-indexing.d.ts.map +1 -1
- package/dist/util/api-indexing.js +41 -9
- package/dist/util/merge.d.ts.map +1 -1
- package/dist/util/merge.js +12 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +10 -9
- package/es/migration/index.js +3 -1
- package/es/migration/to/v3.28.0.js +10 -0
- package/es/project-schema/index.js +3 -1
- package/es/project-schema/migrate.js +5 -1
- package/es/project-schema/v3.28.0.js +1 -0
- package/es/schemas/index.js +4 -3
- package/es/schemas/index.ts +4 -2
- package/es/schemas/project-schema/latest.json +49 -4
- package/es/schemas/project-schema/v3.28.0.json +3013 -0
- package/es/schemas/project-schema.json +3 -0
- package/es/util/api-indexing.js +34 -7
- package/es/util/merge.js +11 -1
- package/es/validate.js +11 -10
- package/examples/latest/betzino.json +1 -1
- 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/complex-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/klirr-schema.json +1 -1
- package/examples/latest/massive-schema.json +1 -1
- package/examples/latest/mill-components-schema.json +1 -1
- package/examples/latest/one-earth.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-product-2022-07.json +1 -1
- package/examples/latest/shopify-store-with-widget.json +1 -1
- package/examples/latest/stripe-product-runtime-schema.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/package.json +4 -4
package/es/util/api-indexing.js
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import { isServiceResolver } from '../types';
|
|
2
|
+
import { ensureArray } from '@takeshape/util';
|
|
3
|
+
import { getResolverServices } from '../services';
|
|
2
4
|
export function serviceHasIndexedShapes(schema, serviceId) {
|
|
3
5
|
for (const config of Object.values(schema.indexedShapes ?? {})) {
|
|
4
|
-
|
|
6
|
+
const listConfigs = config.queries.list;
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
if (listConfigs) {
|
|
9
|
+
for (const {
|
|
10
|
+
name: queryName
|
|
11
|
+
} of ensureArray(listConfigs)) {
|
|
12
|
+
const query = queryName && schema.queries[queryName];
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
if (query && isServiceResolver(query.resolver) && query.resolver.service === serviceId) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
}
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
return false;
|
|
15
22
|
}
|
|
23
|
+
export function getIndexedServices(projectSchema, configs) {
|
|
24
|
+
return ensureArray(configs).reduce((services, queryConfig) => {
|
|
25
|
+
const queryName = queryConfig === null || queryConfig === void 0 ? void 0 : queryConfig.name;
|
|
26
|
+
const query = queryName && projectSchema.queries[queryName];
|
|
27
|
+
return query ? [...services, ...getResolverServices(query.resolver)] : services;
|
|
28
|
+
}, []);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function flattenListQueryConfigs(shapeName, queryConfig, maybeConfigArray) {
|
|
32
|
+
return maybeConfigArray && ensureArray(maybeConfigArray).flatMap(config => ensureArray(config.args).map(args => ({
|
|
33
|
+
shapeName,
|
|
34
|
+
...queryConfig,
|
|
35
|
+
...config,
|
|
36
|
+
args
|
|
37
|
+
})));
|
|
38
|
+
}
|
|
16
39
|
|
|
17
40
|
function getQueryIndexConfigHelper(op) {
|
|
18
41
|
return ({
|
|
@@ -21,7 +44,11 @@ function getQueryIndexConfigHelper(op) {
|
|
|
21
44
|
const indexingConfig = indexedShapes === null || indexedShapes === void 0 ? void 0 : indexedShapes[shapeName];
|
|
22
45
|
|
|
23
46
|
if (indexingConfig) {
|
|
24
|
-
|
|
47
|
+
if (op === 'list') {
|
|
48
|
+
return flattenListQueryConfigs(shapeName, indexingConfig.query, indexingConfig.queries.list);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const queryConfig = indexingConfig.queries.get;
|
|
25
52
|
|
|
26
53
|
if (queryConfig) {
|
|
27
54
|
return {
|
|
@@ -34,5 +61,5 @@ function getQueryIndexConfigHelper(op) {
|
|
|
34
61
|
};
|
|
35
62
|
}
|
|
36
63
|
|
|
37
|
-
export const
|
|
64
|
+
export const getListQueryIndexConfigs = getQueryIndexConfigHelper('list');
|
|
38
65
|
export const getGetQueryIndexConfig = getQueryIndexConfigHelper('get');
|
package/es/util/merge.js
CHANGED
|
@@ -8,6 +8,7 @@ import last from 'lodash/last';
|
|
|
8
8
|
import omit from 'lodash/omit';
|
|
9
9
|
import { isExtendsSchema, isObjectSchema } from '../types';
|
|
10
10
|
import invariant from 'tiny-invariant';
|
|
11
|
+
import pickBy from 'lodash/pickBy';
|
|
11
12
|
export function mergeObjectSchemas(...args) {
|
|
12
13
|
return args.filter(isDefined).reduce(mergeSchemaProperties, {
|
|
13
14
|
type: 'object',
|
|
@@ -103,7 +104,15 @@ export function mergeFormConfigs(...configs) {
|
|
|
103
104
|
order: []
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
|
-
const mergeableSections = ['shapes', 'mutations', 'queries', 'forms', 'services'];
|
|
107
|
+
const mergeableSections = ['shapes', 'mutations', 'queries', 'forms', 'services', 'indexedShapes'];
|
|
108
|
+
|
|
109
|
+
const isMergeableSection = str => {
|
|
110
|
+
return mergeableSections.includes(str);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const pickUnmergeable = projectSchema => {
|
|
114
|
+
return pickBy(projectSchema, (_value, key) => !isMergeableSection(key));
|
|
115
|
+
};
|
|
107
116
|
|
|
108
117
|
function compareSection(section, original, updated) {
|
|
109
118
|
const changes = [];
|
|
@@ -279,6 +288,7 @@ export function mergeProjectSchemas(base, parent, head) {
|
|
|
279
288
|
applyChange(mergedSchema, parent, head, change);
|
|
280
289
|
}
|
|
281
290
|
|
|
291
|
+
Object.assign(mergedSchema, rebaseObject(pickUnmergeable(base), pickUnmergeable(parent), pickUnmergeable(head)));
|
|
282
292
|
return {
|
|
283
293
|
error: undefined,
|
|
284
294
|
mergedSchema
|
package/es/validate.js
CHANGED
|
@@ -21,7 +21,7 @@ import { scalars } from './scalars';
|
|
|
21
21
|
import { isUnionSchema } from './unions';
|
|
22
22
|
import { isEnumLikeSchema } from './enum';
|
|
23
23
|
import metaSchemaV3_9_0 from './schemas/project-schema/meta-schema-v3.9.0.json';
|
|
24
|
-
import { isIntegerLike, isRecord } from '@takeshape/util';
|
|
24
|
+
import { ensureArray, isIntegerLike, isRecord } from '@takeshape/util';
|
|
25
25
|
import forOwn from 'lodash/forOwn';
|
|
26
26
|
import uniqBy from 'lodash/uniqBy';
|
|
27
27
|
import initial from 'lodash/initial';
|
|
@@ -353,16 +353,17 @@ function validateIndexedShapeConfig(projectSchema, shapeName, config) {
|
|
|
353
353
|
var _config$queries, _config$query;
|
|
354
354
|
|
|
355
355
|
const errors = [];
|
|
356
|
-
const list = (_config$queries = config.queries) === null || _config$queries === void 0 ? void 0 : _config$queries.list;
|
|
357
356
|
|
|
358
|
-
if (list) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
357
|
+
if ((_config$queries = config.queries) !== null && _config$queries !== void 0 && _config$queries.list) {
|
|
358
|
+
ensureArray(config.queries.list).forEach((list, i) => {
|
|
359
|
+
if (projectSchema.queries[list.name] === undefined) {
|
|
360
|
+
errors.push({
|
|
361
|
+
path: Array.isArray(config.queries.list) ? ['indexedShapes', shapeName, 'queries', 'list', i, 'name'] : ['indexedShapes', shapeName, 'queries', 'list', 'name'],
|
|
362
|
+
type: 'notFound',
|
|
363
|
+
message: `Invalid query "${list.name}"`
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
});
|
|
366
367
|
}
|
|
367
368
|
|
|
368
369
|
if ((_config$query = config.query) !== null && _config$query !== void 0 && _config$query.selectionSet) {
|
|
@@ -52525,6 +52525,6 @@
|
|
|
52525
52525
|
}
|
|
52526
52526
|
}
|
|
52527
52527
|
},
|
|
52528
|
-
"schemaVersion": "3.
|
|
52528
|
+
"schemaVersion": "3.28.0",
|
|
52529
52529
|
"services": {}
|
|
52530
52530
|
}
|
|
@@ -10505,5 +10505,5 @@
|
|
|
10505
10505
|
}
|
|
10506
10506
|
}
|
|
10507
10507
|
},
|
|
10508
|
-
"schemaVersion": "3.
|
|
10508
|
+
"schemaVersion": "3.28.0"
|
|
10509
10509
|
}
|
|
@@ -23251,6 +23251,6 @@
|
|
|
23251
23251
|
}
|
|
23252
23252
|
}
|
|
23253
23253
|
},
|
|
23254
|
-
"schemaVersion": "3.
|
|
23254
|
+
"schemaVersion": "3.28.0",
|
|
23255
23255
|
"services": {}
|
|
23256
23256
|
}
|
|
@@ -34786,6 +34786,6 @@
|
|
|
34786
34786
|
}
|
|
34787
34787
|
}
|
|
34788
34788
|
},
|
|
34789
|
-
"schemaVersion": "3.
|
|
34789
|
+
"schemaVersion": "3.28.0",
|
|
34790
34790
|
"services": {}
|
|
34791
34791
|
}
|
|
@@ -14216,6 +14216,6 @@
|
|
|
14216
14216
|
}
|
|
14217
14217
|
}
|
|
14218
14218
|
},
|
|
14219
|
-
"schemaVersion": "3.
|
|
14219
|
+
"schemaVersion": "3.28.0",
|
|
14220
14220
|
"services": {}
|
|
14221
14221
|
}
|
|
@@ -12560,5 +12560,5 @@
|
|
|
12560
12560
|
}
|
|
12561
12561
|
}
|
|
12562
12562
|
},
|
|
12563
|
-
"schemaVersion": "3.
|
|
12563
|
+
"schemaVersion": "3.28.0"
|
|
12564
12564
|
}
|
|
@@ -29316,5 +29316,5 @@
|
|
|
29316
29316
|
}
|
|
29317
29317
|
}
|
|
29318
29318
|
},
|
|
29319
|
-
"schemaVersion": "3.
|
|
29319
|
+
"schemaVersion": "3.28.0"
|
|
29320
29320
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.282.3",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"p-reduce": "^2.1.0",
|
|
31
31
|
"semver": "^7.3.2",
|
|
32
32
|
"tiny-invariant": "^1.2.0",
|
|
33
|
-
"@takeshape/errors": "8.
|
|
34
|
-
"@takeshape/
|
|
35
|
-
"@takeshape/
|
|
33
|
+
"@takeshape/errors": "8.282.3",
|
|
34
|
+
"@takeshape/json-schema": "8.282.3",
|
|
35
|
+
"@takeshape/util": "8.282.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@takeshape/json-schema-to-typescript": "^11.0.0",
|