@takeshape/schema 8.218.3 → 8.219.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.
Files changed (85) 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.23.0.d.ts +5 -0
  5. package/dist/migration/to/v3.23.0.d.ts.map +1 -0
  6. package/dist/migration/to/v3.23.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 +34 -2
  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.23.0.d.ts +1377 -0
  15. package/dist/project-schema/v3.23.0.d.ts.map +1 -0
  16. package/dist/project-schema/v3.23.0.js +5 -0
  17. package/dist/refs.d.ts +9 -0
  18. package/dist/refs.d.ts.map +1 -1
  19. package/dist/refs.js +44 -0
  20. package/dist/schema-util.d.ts +0 -9
  21. package/dist/schema-util.d.ts.map +1 -1
  22. package/dist/schema-util.js +1 -24
  23. package/dist/schemas/index.d.ts +2 -2
  24. package/dist/schemas/index.d.ts.map +1 -1
  25. package/dist/schemas/index.js +6 -4
  26. package/dist/schemas/index.ts +4 -2
  27. package/dist/schemas/project-schema/latest.json +80 -2
  28. package/dist/schemas/project-schema/v3.23.0.json +2452 -0
  29. package/dist/schemas/project-schema.json +3 -0
  30. package/dist/services.js +1 -1
  31. package/dist/types/types.d.ts +2 -2
  32. package/dist/types/types.d.ts.map +1 -1
  33. package/dist/types/utils.d.ts +2 -1
  34. package/dist/types/utils.d.ts.map +1 -1
  35. package/dist/types/utils.js +6 -1
  36. package/dist/util/api-indexing.js +1 -1
  37. package/dist/validate.d.ts.map +1 -1
  38. package/dist/validate.js +24 -1
  39. package/es/migration/index.js +3 -1
  40. package/es/migration/to/v3.23.0.js +10 -0
  41. package/es/project-schema/index.js +3 -1
  42. package/es/project-schema/migrate.js +5 -1
  43. package/es/project-schema/v3.23.0.js +1 -0
  44. package/es/refs.js +38 -0
  45. package/es/schema-util.js +2 -19
  46. package/es/schemas/index.js +4 -3
  47. package/es/schemas/index.ts +4 -2
  48. package/es/schemas/project-schema/latest.json +80 -2
  49. package/es/schemas/project-schema/v3.23.0.json +2452 -0
  50. package/es/schemas/project-schema.json +3 -0
  51. package/es/services.js +2 -2
  52. package/es/types/utils.js +4 -1
  53. package/es/util/api-indexing.js +2 -2
  54. package/es/validate.js +25 -2
  55. package/examples/latest/betzino.json +1 -1
  56. package/examples/latest/blog-schema.json +1 -1
  57. package/examples/latest/brewery-schema.json +1 -1
  58. package/examples/latest/complex-project-schema.json +1 -1
  59. package/examples/latest/complex-schema.json +1 -1
  60. package/examples/latest/fabric-ecommerce.json +1 -1
  61. package/examples/latest/frank-and-fred-schema.json +1 -1
  62. package/examples/latest/klirr-schema.json +1 -1
  63. package/examples/latest/massive-schema.json +1 -1
  64. package/examples/latest/mill-components-schema.json +1 -1
  65. package/examples/latest/one-earth.json +1 -1
  66. package/examples/latest/pet-oneof-array.json +1 -1
  67. package/examples/latest/post-schema.json +1 -1
  68. package/examples/latest/pruned-shopify-product-schema.json +1 -1
  69. package/examples/latest/real-world-schema.json +1 -1
  70. package/examples/latest/recursive-repeater-schema.json +1 -1
  71. package/examples/latest/recursive-schema.json +1 -1
  72. package/examples/latest/rick-and-morty-ast.json +1 -1
  73. package/examples/latest/rick-and-morty-graphql.json +1 -1
  74. package/examples/latest/rick-and-morty-rest.json +1 -1
  75. package/examples/latest/schema-with-repeater-draftjs.json +1 -1
  76. package/examples/latest/shape-books-v3_2_0.json +1 -1
  77. package/examples/latest/shape-books.json +1 -1
  78. package/examples/latest/shopify-lookbook.json +1 -1
  79. package/examples/latest/shopify-product-2022-07.json +1 -1
  80. package/examples/latest/shopify-store-with-widget.json +1 -1
  81. package/examples/latest/stripe-product-runtime-schema.json +1 -1
  82. package/examples/latest/stripe-starter-resolved.json +1 -1
  83. package/examples/latest/user-schema-no-required.json +1 -1
  84. package/examples/latest/user-schema-with-defaults.json +1 -1
  85. package/package.json +4 -4
@@ -96,6 +96,9 @@
96
96
  {
97
97
  "$ref": "https://schema.takeshape.io/project-schema/v3.22.0#"
98
98
  },
99
+ {
100
+ "$ref": "https://schema.takeshape.io/project-schema/v3.23.0#"
101
+ },
99
102
  {
100
103
  "$ref": "https://schema.takeshape.io/project-schema/v4.0.0#"
101
104
  }
package/es/services.js CHANGED
@@ -1,4 +1,4 @@
1
- import { mergeWithArrayMerge } from '@takeshape/util';
1
+ import { isDefined, mergeWithArrayMerge } from '@takeshape/util';
2
2
  import { createAjv } from '@takeshape/json-schema';
3
3
  import { SchemaValidationError } from '@takeshape/errors';
4
4
  import isNull from 'lodash/isNull';
@@ -170,7 +170,7 @@ export function getServiceObjectFields(projectSchema, shape, provider) {
170
170
  }
171
171
  export function getResolverServices(resolver) {
172
172
  const resolverArray = 'compose' in resolver ? resolver.compose : [resolver];
173
- return uniq(resolverArray.map(resolver => resolver.service));
173
+ return uniq(resolverArray.map(resolver => 'service' in resolver ? resolver.service : undefined).filter(isDefined));
174
174
  }
175
175
  export function isMissingAuth(service) {
176
176
  return service.authenticationType !== 'none' && isEmpty(service.authentication);
package/es/types/utils.js CHANGED
@@ -14,7 +14,10 @@ import satisfies from 'semver/functions/satisfies';
14
14
  */
15
15
 
16
16
  export function isBasicResolver(resolver) {
17
- return isString(resolver === null || resolver === void 0 ? void 0 : resolver.name) && isString(resolver.service);
17
+ return isRecord(resolver) && isString(resolver.name);
18
+ }
19
+ export function isServiceResolver(resolver) {
20
+ return isRecord(resolver) && isString(resolver.name) && isString(resolver.service);
18
21
  }
19
22
  export function isComposeResolver(resolver) {
20
23
  return Boolean(isArray(resolver === null || resolver === void 0 ? void 0 : resolver.compose) && resolver.compose.length && resolver.compose.every(isBasicResolver));
@@ -1,4 +1,4 @@
1
- import { isBasicResolver } from '../types';
1
+ import { isServiceResolver } from '../types';
2
2
  export function serviceHasIndexedShapes(schema, serviceId) {
3
3
  for (const config of Object.values(schema.indexedShapes ?? {})) {
4
4
  var _config$queries$list;
@@ -6,7 +6,7 @@ export function serviceHasIndexedShapes(schema, serviceId) {
6
6
  const queryName = (_config$queries$list = config.queries.list) === null || _config$queries$list === void 0 ? void 0 : _config$queries$list.name;
7
7
  const query = queryName && schema.queries[queryName];
8
8
 
9
- if (query && isBasicResolver(query.resolver) && query.resolver.service === serviceId) {
9
+ if (query && isServiceResolver(query.resolver) && query.resolver.service === serviceId) {
10
10
  return true;
11
11
  }
12
12
  }
package/es/validate.js CHANGED
@@ -16,7 +16,7 @@ import { getAllNamespaceShapes, getAllRefsInShapes } from './schema-util';
16
16
  import { builtInShapes } from './builtin-schema';
17
17
  import { isValidTemplate } from './template-shapes';
18
18
  import { isBasicResolver, isComposeResolver, isExtendsSchema, isObjectSchema } from './types/utils';
19
- import { refItemToAtRef, refItemToShapeName, parseReturnShape, getRefShapeName } from './refs';
19
+ import { refItemToAtRef, refItemToShapeName, parseReturnShape, getRefShapeName, parsePropertyRef, propertyRefItemToPath, createGetNamespace } from './refs';
20
20
  import { scalars } from './scalars';
21
21
  import { isUnionSchema } from './unions';
22
22
  import { isEnumLikeSchema } from './enum';
@@ -194,12 +194,13 @@ function validateResolver(projectSchema, basePath, resolver) {
194
194
  };
195
195
 
196
196
  const isLessThanV3_9_0 = lt(getSemver(projectSchema.schemaVersion), '3.9.0');
197
+ const getNamespace = createGetNamespace(projectSchema);
197
198
 
198
199
  const validateBasicResolver = resolver => {
199
200
  if (isBasicResolver(resolver)) {
200
201
  var _projectSchema$servic;
201
202
 
202
- if (resolver.service !== 'takeshape:local' && !((_projectSchema$servic = projectSchema.services) !== null && _projectSchema$servic !== void 0 && _projectSchema$servic[resolver.service])) {
203
+ if ('service' in resolver && resolver.service !== 'takeshape:local' && !((_projectSchema$servic = projectSchema.services) !== null && _projectSchema$servic !== void 0 && _projectSchema$servic[resolver.service])) {
203
204
  errors.push({
204
205
  type: 'notFound',
205
206
  path: basePath.concat(['service']),
@@ -246,6 +247,28 @@ function validateResolver(projectSchema, basePath, resolver) {
246
247
  });
247
248
  }
248
249
  }
250
+
251
+ if (resolver.name === 'delegate') {
252
+ const parsed = parsePropertyRef(resolver.to);
253
+
254
+ if (parsed) {
255
+ const targetResolver = get(projectSchema, propertyRefItemToPath(getNamespace, parsed));
256
+
257
+ if (!isBasicResolver(targetResolver) && !isComposeResolver(targetResolver)) {
258
+ errors.push({
259
+ type: 'notFound',
260
+ path: basePath.concat('to'),
261
+ message: `Missing resolver config at property ref "${resolver.to}"`
262
+ });
263
+ }
264
+ } else {
265
+ errors.push({
266
+ type: 'conflict',
267
+ path: basePath.concat('to'),
268
+ message: `Unable to parse property ref "${resolver.to}"`
269
+ });
270
+ }
271
+ }
249
272
  } else {
250
273
  errors.push({
251
274
  type: 'notFound',
@@ -52529,6 +52529,6 @@
52529
52529
  }
52530
52530
  }
52531
52531
  },
52532
- "schemaVersion": "3.22.0",
52532
+ "schemaVersion": "3.23.0",
52533
52533
  "services": {}
52534
52534
  }
@@ -403,6 +403,6 @@
403
403
  }
404
404
  }
405
405
  },
406
- "schemaVersion": "3.22.0",
406
+ "schemaVersion": "3.23.0",
407
407
  "services": {}
408
408
  }
@@ -386,6 +386,6 @@
386
386
  }
387
387
  }
388
388
  },
389
- "schemaVersion": "3.22.0",
389
+ "schemaVersion": "3.23.0",
390
390
  "services": {}
391
391
  }
@@ -4189,6 +4189,6 @@
4189
4189
  }
4190
4190
  }
4191
4191
  },
4192
- "schemaVersion": "3.22.0",
4192
+ "schemaVersion": "3.23.0",
4193
4193
  "services": {}
4194
4194
  }
@@ -17,7 +17,7 @@
17
17
  "apiVersion": "1",
18
18
  "queries": {},
19
19
  "mutations": {},
20
- "schemaVersion": "3.22.0",
20
+ "schemaVersion": "3.23.0",
21
21
  "created": "2019-06-20T12:58:43.119Z",
22
22
  "updated": "2020-04-29T10:10:28.182Z",
23
23
  "shapes": {
@@ -10509,5 +10509,5 @@
10509
10509
  }
10510
10510
  }
10511
10511
  },
10512
- "schemaVersion": "3.22.0"
10512
+ "schemaVersion": "3.23.0"
10513
10513
  }
@@ -23255,6 +23255,6 @@
23255
23255
  }
23256
23256
  }
23257
23257
  },
23258
- "schemaVersion": "3.22.0",
23258
+ "schemaVersion": "3.23.0",
23259
23259
  "services": {}
23260
23260
  }
@@ -34790,6 +34790,6 @@
34790
34790
  }
34791
34791
  }
34792
34792
  },
34793
- "schemaVersion": "3.22.0",
34793
+ "schemaVersion": "3.23.0",
34794
34794
  "services": {}
34795
34795
  }
@@ -7841,6 +7841,6 @@
7841
7841
  }
7842
7842
  }
7843
7843
  },
7844
- "schemaVersion": "3.22.0",
7844
+ "schemaVersion": "3.23.0",
7845
7845
  "services": {}
7846
7846
  }
@@ -1888,6 +1888,6 @@
1888
1888
  }
1889
1889
  }
1890
1890
  },
1891
- "schemaVersion": "3.22.0",
1891
+ "schemaVersion": "3.23.0",
1892
1892
  "services": {}
1893
1893
  }
@@ -14220,6 +14220,6 @@
14220
14220
  }
14221
14221
  }
14222
14222
  },
14223
- "schemaVersion": "3.22.0",
14223
+ "schemaVersion": "3.23.0",
14224
14224
  "services": {}
14225
14225
  }
@@ -392,6 +392,6 @@
392
392
  }
393
393
  }
394
394
  },
395
- "schemaVersion": "3.22.0",
395
+ "schemaVersion": "3.23.0",
396
396
  "services": {}
397
397
  }
@@ -230,6 +230,6 @@
230
230
  }
231
231
  }
232
232
  },
233
- "schemaVersion": "3.22.0",
233
+ "schemaVersion": "3.23.0",
234
234
  "services": {}
235
235
  }
@@ -9760,5 +9760,5 @@
9760
9760
  }
9761
9761
  }
9762
9762
  },
9763
- "schemaVersion": "3.22.0"
9763
+ "schemaVersion": "3.23.0"
9764
9764
  }
@@ -1045,6 +1045,6 @@
1045
1045
  }
1046
1046
  }
1047
1047
  },
1048
- "schemaVersion": "3.22.0",
1048
+ "schemaVersion": "3.23.0",
1049
1049
  "services": {}
1050
1050
  }
@@ -146,6 +146,6 @@
146
146
  }
147
147
  }
148
148
  },
149
- "schemaVersion": "3.22.0",
149
+ "schemaVersion": "3.23.0",
150
150
  "services": {}
151
151
  }
@@ -153,6 +153,6 @@
153
153
  }
154
154
  }
155
155
  },
156
- "schemaVersion": "3.22.0",
156
+ "schemaVersion": "3.23.0",
157
157
  "services": {}
158
158
  }
@@ -2824,5 +2824,5 @@
2824
2824
  }
2825
2825
  }
2826
2826
  },
2827
- "schemaVersion": "3.22.0"
2827
+ "schemaVersion": "3.23.0"
2828
2828
  }
@@ -2296,5 +2296,5 @@
2296
2296
  }
2297
2297
  }
2298
2298
  },
2299
- "schemaVersion": "3.22.0"
2299
+ "schemaVersion": "3.23.0"
2300
2300
  }
@@ -95,5 +95,5 @@
95
95
  }
96
96
  }
97
97
  },
98
- "schemaVersion": "3.22.0"
98
+ "schemaVersion": "3.23.0"
99
99
  }
@@ -401,6 +401,6 @@
401
401
  }
402
402
  }
403
403
  },
404
- "schemaVersion": "3.22.0",
404
+ "schemaVersion": "3.23.0",
405
405
  "services": {}
406
406
  }
@@ -1128,6 +1128,6 @@
1128
1128
  }
1129
1129
  }
1130
1130
  },
1131
- "schemaVersion": "3.22.0",
1131
+ "schemaVersion": "3.23.0",
1132
1132
  "services": {}
1133
1133
  }
@@ -1128,6 +1128,6 @@
1128
1128
  }
1129
1129
  }
1130
1130
  },
1131
- "schemaVersion": "3.22.0",
1131
+ "schemaVersion": "3.23.0",
1132
1132
  "services": {}
1133
1133
  }
@@ -1181,5 +1181,5 @@
1181
1181
  }
1182
1182
  }
1183
1183
  },
1184
- "schemaVersion": "3.22.0"
1184
+ "schemaVersion": "3.23.0"
1185
1185
  }
@@ -9,7 +9,7 @@
9
9
  "en-us"
10
10
  ],
11
11
  "apiVersion": "2",
12
- "schemaVersion": "3.22.0",
12
+ "schemaVersion": "3.23.0",
13
13
  "queries": {
14
14
  "getAsset": {
15
15
  "shape": "Asset",
@@ -12564,5 +12564,5 @@
12564
12564
  }
12565
12565
  }
12566
12566
  },
12567
- "schemaVersion": "3.22.0"
12567
+ "schemaVersion": "3.23.0"
12568
12568
  }
@@ -9,7 +9,7 @@
9
9
  "en-us"
10
10
  ],
11
11
  "apiVersion": "2",
12
- "schemaVersion": "3.22.0",
12
+ "schemaVersion": "3.23.0",
13
13
  "queries": {
14
14
  "getAsset": {
15
15
  "shape": "Asset",
@@ -29320,5 +29320,5 @@
29320
29320
  }
29321
29321
  }
29322
29322
  },
29323
- "schemaVersion": "3.22.0"
29323
+ "schemaVersion": "3.23.0"
29324
29324
  }
@@ -169,6 +169,6 @@
169
169
  }
170
170
  }
171
171
  },
172
- "schemaVersion": "3.22.0",
172
+ "schemaVersion": "3.23.0",
173
173
  "services": {}
174
174
  }
@@ -194,6 +194,6 @@
194
194
  }
195
195
  }
196
196
  },
197
- "schemaVersion": "3.22.0",
197
+ "schemaVersion": "3.23.0",
198
198
  "services": {}
199
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/schema",
3
- "version": "8.218.3",
3
+ "version": "8.219.0",
4
4
  "description": "TakeShape Schema",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -21,9 +21,9 @@
21
21
  "examples"
22
22
  ],
23
23
  "dependencies": {
24
- "@takeshape/errors": "8.218.3",
25
- "@takeshape/json-schema": "8.218.3",
26
- "@takeshape/util": "8.218.3",
24
+ "@takeshape/errors": "8.219.0",
25
+ "@takeshape/json-schema": "8.219.0",
26
+ "@takeshape/util": "8.219.0",
27
27
  "ajv": "^8.10.0",
28
28
  "ajv-formats": "^2.1.1",
29
29
  "blueimp-md5": "^2.10.0",