@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.
Files changed (76) hide show
  1. package/dist/migration/index.d.ts +1 -0
  2. package/dist/migration/index.d.ts.map +1 -1
  3. package/dist/migration/index.js +4 -1
  4. package/dist/migration/to/v3.28.0.d.ts +5 -0
  5. package/dist/migration/to/v3.28.0.d.ts.map +1 -0
  6. package/dist/migration/to/v3.28.0.js +18 -0
  7. package/dist/project-schema/index.d.ts +4 -1
  8. package/dist/project-schema/index.d.ts.map +1 -1
  9. package/dist/project-schema/index.js +20 -3
  10. package/dist/project-schema/latest.d.ts +23 -4
  11. package/dist/project-schema/latest.d.ts.map +1 -1
  12. package/dist/project-schema/migrate.d.ts.map +1 -1
  13. package/dist/project-schema/migrate.js +4 -0
  14. package/dist/project-schema/v3.28.0.d.ts +1417 -0
  15. package/dist/project-schema/v3.28.0.d.ts.map +1 -0
  16. package/dist/project-schema/v3.28.0.js +5 -0
  17. package/dist/schemas/index.d.ts +2 -2
  18. package/dist/schemas/index.d.ts.map +1 -1
  19. package/dist/schemas/index.js +6 -4
  20. package/dist/schemas/index.ts +4 -2
  21. package/dist/schemas/project-schema/latest.json +49 -4
  22. package/dist/schemas/project-schema/v3.28.0.json +3013 -0
  23. package/dist/schemas/project-schema.json +3 -0
  24. package/dist/types/types.d.ts +2 -2
  25. package/dist/types/types.d.ts.map +1 -1
  26. package/dist/util/api-indexing.d.ts +3 -1
  27. package/dist/util/api-indexing.d.ts.map +1 -1
  28. package/dist/util/api-indexing.js +41 -9
  29. package/dist/util/merge.d.ts.map +1 -1
  30. package/dist/util/merge.js +12 -1
  31. package/dist/validate.d.ts.map +1 -1
  32. package/dist/validate.js +10 -9
  33. package/es/migration/index.js +3 -1
  34. package/es/migration/to/v3.28.0.js +10 -0
  35. package/es/project-schema/index.js +3 -1
  36. package/es/project-schema/migrate.js +5 -1
  37. package/es/project-schema/v3.28.0.js +1 -0
  38. package/es/schemas/index.js +4 -3
  39. package/es/schemas/index.ts +4 -2
  40. package/es/schemas/project-schema/latest.json +49 -4
  41. package/es/schemas/project-schema/v3.28.0.json +3013 -0
  42. package/es/schemas/project-schema.json +3 -0
  43. package/es/util/api-indexing.js +34 -7
  44. package/es/util/merge.js +11 -1
  45. package/es/validate.js +11 -10
  46. package/examples/latest/betzino.json +1 -1
  47. package/examples/latest/blog-schema.json +1 -1
  48. package/examples/latest/brewery-schema.json +1 -1
  49. package/examples/latest/complex-project-schema.json +1 -1
  50. package/examples/latest/complex-schema.json +1 -1
  51. package/examples/latest/fabric-ecommerce.json +1 -1
  52. package/examples/latest/frank-and-fred-schema.json +1 -1
  53. package/examples/latest/klirr-schema.json +1 -1
  54. package/examples/latest/massive-schema.json +1 -1
  55. package/examples/latest/mill-components-schema.json +1 -1
  56. package/examples/latest/one-earth.json +1 -1
  57. package/examples/latest/pet-oneof-array.json +1 -1
  58. package/examples/latest/post-schema.json +1 -1
  59. package/examples/latest/pruned-shopify-product-schema.json +1 -1
  60. package/examples/latest/real-world-schema.json +1 -1
  61. package/examples/latest/recursive-repeater-schema.json +1 -1
  62. package/examples/latest/recursive-schema.json +1 -1
  63. package/examples/latest/rick-and-morty-ast.json +1 -1
  64. package/examples/latest/rick-and-morty-graphql.json +1 -1
  65. package/examples/latest/rick-and-morty-rest.json +1 -1
  66. package/examples/latest/schema-with-repeater-draftjs.json +1 -1
  67. package/examples/latest/shape-books-v3_2_0.json +1 -1
  68. package/examples/latest/shape-books.json +1 -1
  69. package/examples/latest/shopify-lookbook.json +1 -1
  70. package/examples/latest/shopify-product-2022-07.json +1 -1
  71. package/examples/latest/shopify-store-with-widget.json +1 -1
  72. package/examples/latest/stripe-product-runtime-schema.json +1 -1
  73. package/examples/latest/stripe-starter-resolved.json +1 -1
  74. package/examples/latest/user-schema-no-required.json +1 -1
  75. package/examples/latest/user-schema-with-defaults.json +1 -1
  76. package/package.json +4 -4
@@ -111,6 +111,9 @@
111
111
  {
112
112
  "$ref": "https://schema.takeshape.io/project-schema/v3.27.0#"
113
113
  },
114
+ {
115
+ "$ref": "https://schema.takeshape.io/project-schema/v3.28.0#"
116
+ },
114
117
  {
115
118
  "$ref": "https://schema.takeshape.io/project-schema/v4.0.0#"
116
119
  }
@@ -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
- var _config$queries$list;
6
+ const listConfigs = config.queries.list;
5
7
 
6
- const queryName = (_config$queries$list = config.queries.list) === null || _config$queries$list === void 0 ? void 0 : _config$queries$list.name;
7
- const query = queryName && schema.queries[queryName];
8
+ if (listConfigs) {
9
+ for (const {
10
+ name: queryName
11
+ } of ensureArray(listConfigs)) {
12
+ const query = queryName && schema.queries[queryName];
8
13
 
9
- if (query && isServiceResolver(query.resolver) && query.resolver.service === serviceId) {
10
- return true;
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
- const queryConfig = indexingConfig.queries[op];
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 getListQueryIndexConfig = getQueryIndexConfigHelper('list');
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
- if (projectSchema.queries[list.name] === undefined) {
360
- errors.push({
361
- path: ['indexedShapes', shapeName, 'queries', 'list', 'name'],
362
- type: 'notFound',
363
- message: `Invalid query "${list.name}"`
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.27.0",
52528
+ "schemaVersion": "3.28.0",
52529
52529
  "services": {}
52530
52530
  }
@@ -399,6 +399,6 @@
399
399
  }
400
400
  }
401
401
  },
402
- "schemaVersion": "3.27.0",
402
+ "schemaVersion": "3.28.0",
403
403
  "services": {}
404
404
  }
@@ -382,6 +382,6 @@
382
382
  }
383
383
  }
384
384
  },
385
- "schemaVersion": "3.27.0",
385
+ "schemaVersion": "3.28.0",
386
386
  "services": {}
387
387
  }
@@ -4185,6 +4185,6 @@
4185
4185
  }
4186
4186
  }
4187
4187
  },
4188
- "schemaVersion": "3.27.0",
4188
+ "schemaVersion": "3.28.0",
4189
4189
  "services": {}
4190
4190
  }
@@ -15,7 +15,7 @@
15
15
  "apiVersion": "1",
16
16
  "queries": {},
17
17
  "mutations": {},
18
- "schemaVersion": "3.27.0",
18
+ "schemaVersion": "3.28.0",
19
19
  "shapes": {
20
20
  "DocumentUploadForm": {
21
21
  "id": "HJPFlRKkr",
@@ -10505,5 +10505,5 @@
10505
10505
  }
10506
10506
  }
10507
10507
  },
10508
- "schemaVersion": "3.27.0"
10508
+ "schemaVersion": "3.28.0"
10509
10509
  }
@@ -23251,6 +23251,6 @@
23251
23251
  }
23252
23252
  }
23253
23253
  },
23254
- "schemaVersion": "3.27.0",
23254
+ "schemaVersion": "3.28.0",
23255
23255
  "services": {}
23256
23256
  }
@@ -34786,6 +34786,6 @@
34786
34786
  }
34787
34787
  }
34788
34788
  },
34789
- "schemaVersion": "3.27.0",
34789
+ "schemaVersion": "3.28.0",
34790
34790
  "services": {}
34791
34791
  }
@@ -7837,6 +7837,6 @@
7837
7837
  }
7838
7838
  }
7839
7839
  },
7840
- "schemaVersion": "3.27.0",
7840
+ "schemaVersion": "3.28.0",
7841
7841
  "services": {}
7842
7842
  }
@@ -1884,6 +1884,6 @@
1884
1884
  }
1885
1885
  }
1886
1886
  },
1887
- "schemaVersion": "3.27.0",
1887
+ "schemaVersion": "3.28.0",
1888
1888
  "services": {}
1889
1889
  }
@@ -14216,6 +14216,6 @@
14216
14216
  }
14217
14217
  }
14218
14218
  },
14219
- "schemaVersion": "3.27.0",
14219
+ "schemaVersion": "3.28.0",
14220
14220
  "services": {}
14221
14221
  }
@@ -388,6 +388,6 @@
388
388
  }
389
389
  }
390
390
  },
391
- "schemaVersion": "3.27.0",
391
+ "schemaVersion": "3.28.0",
392
392
  "services": {}
393
393
  }
@@ -226,6 +226,6 @@
226
226
  }
227
227
  }
228
228
  },
229
- "schemaVersion": "3.27.0",
229
+ "schemaVersion": "3.28.0",
230
230
  "services": {}
231
231
  }
@@ -9756,5 +9756,5 @@
9756
9756
  }
9757
9757
  }
9758
9758
  },
9759
- "schemaVersion": "3.27.0"
9759
+ "schemaVersion": "3.28.0"
9760
9760
  }
@@ -1041,6 +1041,6 @@
1041
1041
  }
1042
1042
  }
1043
1043
  },
1044
- "schemaVersion": "3.27.0",
1044
+ "schemaVersion": "3.28.0",
1045
1045
  "services": {}
1046
1046
  }
@@ -142,6 +142,6 @@
142
142
  }
143
143
  }
144
144
  },
145
- "schemaVersion": "3.27.0",
145
+ "schemaVersion": "3.28.0",
146
146
  "services": {}
147
147
  }
@@ -149,6 +149,6 @@
149
149
  }
150
150
  }
151
151
  },
152
- "schemaVersion": "3.27.0",
152
+ "schemaVersion": "3.28.0",
153
153
  "services": {}
154
154
  }
@@ -2820,5 +2820,5 @@
2820
2820
  }
2821
2821
  }
2822
2822
  },
2823
- "schemaVersion": "3.27.0"
2823
+ "schemaVersion": "3.28.0"
2824
2824
  }
@@ -2292,5 +2292,5 @@
2292
2292
  }
2293
2293
  }
2294
2294
  },
2295
- "schemaVersion": "3.27.0"
2295
+ "schemaVersion": "3.28.0"
2296
2296
  }
@@ -91,5 +91,5 @@
91
91
  }
92
92
  }
93
93
  },
94
- "schemaVersion": "3.27.0"
94
+ "schemaVersion": "3.28.0"
95
95
  }
@@ -397,6 +397,6 @@
397
397
  }
398
398
  }
399
399
  },
400
- "schemaVersion": "3.27.0",
400
+ "schemaVersion": "3.28.0",
401
401
  "services": {}
402
402
  }
@@ -1124,6 +1124,6 @@
1124
1124
  }
1125
1125
  }
1126
1126
  },
1127
- "schemaVersion": "3.27.0",
1127
+ "schemaVersion": "3.28.0",
1128
1128
  "services": {}
1129
1129
  }
@@ -1124,6 +1124,6 @@
1124
1124
  }
1125
1125
  }
1126
1126
  },
1127
- "schemaVersion": "3.27.0",
1127
+ "schemaVersion": "3.28.0",
1128
1128
  "services": {}
1129
1129
  }
@@ -1177,5 +1177,5 @@
1177
1177
  }
1178
1178
  }
1179
1179
  },
1180
- "schemaVersion": "3.27.0"
1180
+ "schemaVersion": "3.28.0"
1181
1181
  }
@@ -5,7 +5,7 @@
5
5
  "en-us"
6
6
  ],
7
7
  "apiVersion": "2",
8
- "schemaVersion": "3.27.0",
8
+ "schemaVersion": "3.28.0",
9
9
  "queries": {
10
10
  "getAsset": {
11
11
  "shape": "Asset",
@@ -12560,5 +12560,5 @@
12560
12560
  }
12561
12561
  }
12562
12562
  },
12563
- "schemaVersion": "3.27.0"
12563
+ "schemaVersion": "3.28.0"
12564
12564
  }
@@ -5,7 +5,7 @@
5
5
  "en-us"
6
6
  ],
7
7
  "apiVersion": "2",
8
- "schemaVersion": "3.27.0",
8
+ "schemaVersion": "3.28.0",
9
9
  "queries": {
10
10
  "getAsset": {
11
11
  "shape": "Asset",
@@ -29316,5 +29316,5 @@
29316
29316
  }
29317
29317
  }
29318
29318
  },
29319
- "schemaVersion": "3.27.0"
29319
+ "schemaVersion": "3.28.0"
29320
29320
  }
@@ -165,6 +165,6 @@
165
165
  }
166
166
  }
167
167
  },
168
- "schemaVersion": "3.27.0",
168
+ "schemaVersion": "3.28.0",
169
169
  "services": {}
170
170
  }
@@ -190,6 +190,6 @@
190
190
  }
191
191
  }
192
192
  },
193
- "schemaVersion": "3.27.0",
193
+ "schemaVersion": "3.28.0",
194
194
  "services": {}
195
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/schema",
3
- "version": "8.281.0",
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.281.0",
34
- "@takeshape/util": "8.281.0",
35
- "@takeshape/json-schema": "8.281.0"
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",