@takeshape/schema 8.215.4 → 8.217.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 (73) 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.22.0.d.ts +5 -0
  5. package/dist/migration/to/v3.22.0.d.ts.map +1 -0
  6. package/dist/migration/to/v3.22.0.js +44 -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 +15 -9
  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.22.0.d.ts +1345 -0
  15. package/dist/project-schema/v3.22.0.d.ts.map +1 -0
  16. package/dist/project-schema/v3.22.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 +22 -18
  22. package/dist/schemas/project-schema/v3.22.0.json +2375 -0
  23. package/dist/schemas/project-schema.json +3 -0
  24. package/dist/types/types.d.ts +8 -2
  25. package/dist/types/types.d.ts.map +1 -1
  26. package/dist/util/api-indexing.d.ts +7 -1
  27. package/dist/util/api-indexing.d.ts.map +1 -1
  28. package/dist/util/api-indexing.js +27 -1
  29. package/dist/validate.d.ts.map +1 -1
  30. package/dist/validate.js +22 -1
  31. package/es/migration/index.js +3 -1
  32. package/es/migration/to/v3.22.0.js +33 -0
  33. package/es/project-schema/index.js +3 -1
  34. package/es/project-schema/migrate.js +5 -1
  35. package/es/project-schema/v3.22.0.js +1 -0
  36. package/es/schemas/index.js +4 -3
  37. package/es/schemas/index.ts +4 -2
  38. package/es/schemas/project-schema/latest.json +22 -18
  39. package/es/schemas/project-schema/v3.22.0.json +2375 -0
  40. package/es/schemas/project-schema.json +3 -0
  41. package/es/util/api-indexing.js +24 -1
  42. package/es/validate.js +22 -1
  43. package/examples/latest/betzino.json +1 -1
  44. package/examples/latest/blog-schema.json +1 -1
  45. package/examples/latest/brewery-schema.json +1 -1
  46. package/examples/latest/complex-project-schema.json +1 -1
  47. package/examples/latest/complex-schema.json +1 -1
  48. package/examples/latest/fabric-ecommerce.json +1 -1
  49. package/examples/latest/frank-and-fred-schema.json +1 -1
  50. package/examples/latest/klirr-schema.json +1 -1
  51. package/examples/latest/massive-schema.json +1 -1
  52. package/examples/latest/mill-components-schema.json +1 -1
  53. package/examples/latest/one-earth.json +1 -1
  54. package/examples/latest/pet-oneof-array.json +1 -1
  55. package/examples/latest/post-schema.json +1 -1
  56. package/examples/latest/pruned-shopify-product-schema.json +1 -1
  57. package/examples/latest/real-world-schema.json +1 -1
  58. package/examples/latest/recursive-repeater-schema.json +1 -1
  59. package/examples/latest/recursive-schema.json +1 -1
  60. package/examples/latest/rick-and-morty-ast.json +1 -1
  61. package/examples/latest/rick-and-morty-graphql.json +1 -1
  62. package/examples/latest/rick-and-morty-rest.json +1 -1
  63. package/examples/latest/schema-with-repeater-draftjs.json +1 -1
  64. package/examples/latest/shape-books-v3_2_0.json +1 -1
  65. package/examples/latest/shape-books.json +1 -1
  66. package/examples/latest/shopify-lookbook.json +1 -1
  67. package/examples/latest/shopify-product-2022-07.json +2 -2
  68. package/examples/latest/shopify-store-with-widget.json +1 -1
  69. package/examples/latest/stripe-product-runtime-schema.json +7 -6
  70. package/examples/latest/stripe-starter-resolved.json +1 -1
  71. package/examples/latest/user-schema-no-required.json +1 -1
  72. package/examples/latest/user-schema-with-defaults.json +1 -1
  73. package/package.json +4 -4
@@ -93,6 +93,9 @@
93
93
  {
94
94
  "$ref": "https://schema.takeshape.io/project-schema/v3.21.0#"
95
95
  },
96
+ {
97
+ "$ref": "https://schema.takeshape.io/project-schema/v3.22.0#"
98
+ },
96
99
  {
97
100
  "$ref": "https://schema.takeshape.io/project-schema/v4.0.0#"
98
101
  }
@@ -12,4 +12,27 @@ export function serviceHasIndexedShapes(schema, serviceId) {
12
12
  }
13
13
 
14
14
  return false;
15
- }
15
+ }
16
+
17
+ function getQueryIndexConfigHelper(op) {
18
+ return ({
19
+ indexedShapes
20
+ }, shapeName) => {
21
+ const indexingConfig = indexedShapes === null || indexedShapes === void 0 ? void 0 : indexedShapes[shapeName];
22
+
23
+ if (indexingConfig) {
24
+ const queryConfig = indexingConfig.queries[op];
25
+
26
+ if (queryConfig) {
27
+ return {
28
+ shapeName,
29
+ ...indexingConfig.query,
30
+ ...queryConfig
31
+ };
32
+ }
33
+ }
34
+ };
35
+ }
36
+
37
+ export const getListQueryIndexConfig = getQueryIndexConfigHelper('list');
38
+ export const getGetQueryIndexConfig = getQueryIndexConfigHelper('get');
package/es/validate.js CHANGED
@@ -307,8 +307,17 @@ function validateQueryConfigs(projectSchema, additionalShapeNames = builtInShape
307
307
  return errors;
308
308
  }
309
309
 
310
+ function hasIdField(selectionSet, idField) {
311
+ // TODO allow GraphQL parser implementation to be passed in
312
+ const topLevel = selectionSet.replace(/^\s*{\s*/, '') // remove first {
313
+ .replace(/\s*}\s*$/, '') // remove last {
314
+ .replace(/{[^}]*}|:/g, '') // remove nested selections and :
315
+ .split(/\s+/g);
316
+ return topLevel.includes(idField);
317
+ }
318
+
310
319
  function validateIndexedShapeConfig(projectSchema, shapeName, config) {
311
- var _config$queries;
320
+ var _config$queries, _config$query;
312
321
 
313
322
  const errors = [];
314
323
  const list = (_config$queries = config.queries) === null || _config$queries === void 0 ? void 0 : _config$queries.list;
@@ -323,6 +332,18 @@ function validateIndexedShapeConfig(projectSchema, shapeName, config) {
323
332
  }
324
333
  }
325
334
 
335
+ if ((_config$query = config.query) !== null && _config$query !== void 0 && _config$query.selectionSet) {
336
+ const idField = config.idField ?? 'id';
337
+
338
+ if (!hasIdField(config.query.selectionSet, idField)) {
339
+ errors.push({
340
+ path: ['indexedShapes', shapeName, 'query', 'selectionSet'],
341
+ type: 'notFound',
342
+ message: `selectionSet must contain "${idField}"`
343
+ });
344
+ }
345
+ }
346
+
326
347
  return errors;
327
348
  }
328
349
 
@@ -52529,6 +52529,6 @@
52529
52529
  }
52530
52530
  }
52531
52531
  },
52532
- "schemaVersion": "3.21.0",
52532
+ "schemaVersion": "3.22.0",
52533
52533
  "services": {}
52534
52534
  }
@@ -403,6 +403,6 @@
403
403
  }
404
404
  }
405
405
  },
406
- "schemaVersion": "3.21.0",
406
+ "schemaVersion": "3.22.0",
407
407
  "services": {}
408
408
  }
@@ -386,6 +386,6 @@
386
386
  }
387
387
  }
388
388
  },
389
- "schemaVersion": "3.21.0",
389
+ "schemaVersion": "3.22.0",
390
390
  "services": {}
391
391
  }
@@ -4189,6 +4189,6 @@
4189
4189
  }
4190
4190
  }
4191
4191
  },
4192
- "schemaVersion": "3.21.0",
4192
+ "schemaVersion": "3.22.0",
4193
4193
  "services": {}
4194
4194
  }
@@ -17,7 +17,7 @@
17
17
  "apiVersion": "1",
18
18
  "queries": {},
19
19
  "mutations": {},
20
- "schemaVersion": "3.21.0",
20
+ "schemaVersion": "3.22.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.21.0"
10512
+ "schemaVersion": "3.22.0"
10513
10513
  }
@@ -23255,6 +23255,6 @@
23255
23255
  }
23256
23256
  }
23257
23257
  },
23258
- "schemaVersion": "3.21.0",
23258
+ "schemaVersion": "3.22.0",
23259
23259
  "services": {}
23260
23260
  }
@@ -34790,6 +34790,6 @@
34790
34790
  }
34791
34791
  }
34792
34792
  },
34793
- "schemaVersion": "3.21.0",
34793
+ "schemaVersion": "3.22.0",
34794
34794
  "services": {}
34795
34795
  }
@@ -7841,6 +7841,6 @@
7841
7841
  }
7842
7842
  }
7843
7843
  },
7844
- "schemaVersion": "3.21.0",
7844
+ "schemaVersion": "3.22.0",
7845
7845
  "services": {}
7846
7846
  }
@@ -1888,6 +1888,6 @@
1888
1888
  }
1889
1889
  }
1890
1890
  },
1891
- "schemaVersion": "3.21.0",
1891
+ "schemaVersion": "3.22.0",
1892
1892
  "services": {}
1893
1893
  }
@@ -14220,6 +14220,6 @@
14220
14220
  }
14221
14221
  }
14222
14222
  },
14223
- "schemaVersion": "3.21.0",
14223
+ "schemaVersion": "3.22.0",
14224
14224
  "services": {}
14225
14225
  }
@@ -392,6 +392,6 @@
392
392
  }
393
393
  }
394
394
  },
395
- "schemaVersion": "3.21.0",
395
+ "schemaVersion": "3.22.0",
396
396
  "services": {}
397
397
  }
@@ -230,6 +230,6 @@
230
230
  }
231
231
  }
232
232
  },
233
- "schemaVersion": "3.21.0",
233
+ "schemaVersion": "3.22.0",
234
234
  "services": {}
235
235
  }
@@ -9760,5 +9760,5 @@
9760
9760
  }
9761
9761
  }
9762
9762
  },
9763
- "schemaVersion": "3.21.0"
9763
+ "schemaVersion": "3.22.0"
9764
9764
  }
@@ -1045,6 +1045,6 @@
1045
1045
  }
1046
1046
  }
1047
1047
  },
1048
- "schemaVersion": "3.21.0",
1048
+ "schemaVersion": "3.22.0",
1049
1049
  "services": {}
1050
1050
  }
@@ -146,6 +146,6 @@
146
146
  }
147
147
  }
148
148
  },
149
- "schemaVersion": "3.21.0",
149
+ "schemaVersion": "3.22.0",
150
150
  "services": {}
151
151
  }
@@ -153,6 +153,6 @@
153
153
  }
154
154
  }
155
155
  },
156
- "schemaVersion": "3.21.0",
156
+ "schemaVersion": "3.22.0",
157
157
  "services": {}
158
158
  }
@@ -2824,5 +2824,5 @@
2824
2824
  }
2825
2825
  }
2826
2826
  },
2827
- "schemaVersion": "3.21.0"
2827
+ "schemaVersion": "3.22.0"
2828
2828
  }
@@ -2296,5 +2296,5 @@
2296
2296
  }
2297
2297
  }
2298
2298
  },
2299
- "schemaVersion": "3.21.0"
2299
+ "schemaVersion": "3.22.0"
2300
2300
  }
@@ -95,5 +95,5 @@
95
95
  }
96
96
  }
97
97
  },
98
- "schemaVersion": "3.21.0"
98
+ "schemaVersion": "3.22.0"
99
99
  }
@@ -401,6 +401,6 @@
401
401
  }
402
402
  }
403
403
  },
404
- "schemaVersion": "3.21.0",
404
+ "schemaVersion": "3.22.0",
405
405
  "services": {}
406
406
  }
@@ -1128,6 +1128,6 @@
1128
1128
  }
1129
1129
  }
1130
1130
  },
1131
- "schemaVersion": "3.21.0",
1131
+ "schemaVersion": "3.22.0",
1132
1132
  "services": {}
1133
1133
  }
@@ -1128,6 +1128,6 @@
1128
1128
  }
1129
1129
  }
1130
1130
  },
1131
- "schemaVersion": "3.21.0",
1131
+ "schemaVersion": "3.22.0",
1132
1132
  "services": {}
1133
1133
  }
@@ -1181,5 +1181,5 @@
1181
1181
  }
1182
1182
  }
1183
1183
  },
1184
- "schemaVersion": "3.21.0"
1184
+ "schemaVersion": "3.22.0"
1185
1185
  }
@@ -9,7 +9,7 @@
9
9
  "en-us"
10
10
  ],
11
11
  "apiVersion": "2",
12
- "schemaVersion": "3.21.0",
12
+ "schemaVersion": "3.22.0",
13
13
  "queries": {
14
14
  "getAsset": {
15
15
  "shape": "Asset",
@@ -39001,4 +39001,4 @@
39001
39001
  "authentication": "secret"
39002
39002
  }
39003
39003
  }
39004
- }
39004
+ }
@@ -12564,5 +12564,5 @@
12564
12564
  }
12565
12565
  }
12566
12566
  },
12567
- "schemaVersion": "3.21.0"
12567
+ "schemaVersion": "3.22.0"
12568
12568
  }
@@ -9,7 +9,7 @@
9
9
  "en-us"
10
10
  ],
11
11
  "apiVersion": "2",
12
- "schemaVersion": "3.21.0",
12
+ "schemaVersion": "3.22.0",
13
13
  "queries": {
14
14
  "getAsset": {
15
15
  "shape": "Asset",
@@ -4406,12 +4406,10 @@
4406
4406
  "Stripe_Product": {
4407
4407
  "queries": {
4408
4408
  "list": {
4409
- "name": "Stripe_listProducts",
4410
- "objectDepthLimit": 1
4409
+ "name": "Stripe_listProducts"
4411
4410
  },
4412
4411
  "get": {
4413
- "name": "Stripe_getProduct",
4414
- "objectDepthLimit": 1
4412
+ "name": "Stripe_getProduct"
4415
4413
  }
4416
4414
  },
4417
4415
  "triggers": [
@@ -4420,7 +4418,10 @@
4420
4418
  "query": "list",
4421
4419
  "interval": 1440
4422
4420
  }
4423
- ]
4421
+ ],
4422
+ "query": {
4423
+ "maxDepth": 1
4424
+ }
4424
4425
  }
4425
4426
  }
4426
4427
  }
@@ -29320,5 +29320,5 @@
29320
29320
  }
29321
29321
  }
29322
29322
  },
29323
- "schemaVersion": "3.21.0"
29323
+ "schemaVersion": "3.22.0"
29324
29324
  }
@@ -169,6 +169,6 @@
169
169
  }
170
170
  }
171
171
  },
172
- "schemaVersion": "3.21.0",
172
+ "schemaVersion": "3.22.0",
173
173
  "services": {}
174
174
  }
@@ -194,6 +194,6 @@
194
194
  }
195
195
  }
196
196
  },
197
- "schemaVersion": "3.21.0",
197
+ "schemaVersion": "3.22.0",
198
198
  "services": {}
199
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/schema",
3
- "version": "8.215.4",
3
+ "version": "8.217.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.215.4",
25
- "@takeshape/json-schema": "8.215.4",
26
- "@takeshape/util": "8.215.4",
24
+ "@takeshape/errors": "8.217.0",
25
+ "@takeshape/json-schema": "8.217.0",
26
+ "@takeshape/util": "8.217.0",
27
27
  "ajv": "^8.10.0",
28
28
  "ajv-formats": "^2.1.1",
29
29
  "blueimp-md5": "^2.10.0",