@takeshape/schema 8.145.0 → 8.149.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 (125) hide show
  1. package/dist/builtin-schema.d.ts.map +1 -1
  2. package/dist/builtin-schema.js +17 -0
  3. package/dist/get-is-leaf.d.ts +1 -1
  4. package/dist/get-is-leaf.d.ts.map +1 -1
  5. package/dist/get-is-leaf.js +3 -1
  6. package/dist/migration/index.d.ts +1 -0
  7. package/dist/migration/index.d.ts.map +1 -1
  8. package/dist/migration/index.js +4 -1
  9. package/dist/migration/to/v3.0.0.d.ts.map +1 -1
  10. package/dist/migration/to/v3.18.0.d.ts +5 -0
  11. package/dist/migration/to/v3.18.0.d.ts.map +1 -0
  12. package/dist/migration/to/v3.18.0.js +85 -0
  13. package/dist/mocks.d.ts.map +1 -1
  14. package/dist/mocks.js +4 -2
  15. package/dist/project-schema/index.d.ts +4 -1
  16. package/dist/project-schema/index.d.ts.map +1 -1
  17. package/dist/project-schema/index.js +20 -3
  18. package/dist/project-schema/latest.d.ts +4 -139
  19. package/dist/project-schema/latest.d.ts.map +1 -1
  20. package/dist/project-schema/migrate.d.ts.map +1 -1
  21. package/dist/project-schema/migrate.js +4 -0
  22. package/dist/project-schema/v3.18.0.d.ts +1334 -0
  23. package/dist/project-schema/v3.18.0.d.ts.map +1 -0
  24. package/dist/project-schema/v3.18.0.js +5 -0
  25. package/dist/refs.d.ts +14 -2
  26. package/dist/refs.d.ts.map +1 -1
  27. package/dist/refs.js +26 -0
  28. package/dist/relationships.d.ts +28 -2
  29. package/dist/relationships.d.ts.map +1 -1
  30. package/dist/relationships.js +234 -19
  31. package/dist/rewrite.d.ts.map +1 -1
  32. package/dist/rewrite.js +10 -2
  33. package/dist/schema-util.d.ts +1 -18
  34. package/dist/schema-util.d.ts.map +1 -1
  35. package/dist/schema-util.js +36 -120
  36. package/dist/schemas/index.d.ts +2 -2
  37. package/dist/schemas/index.d.ts.map +1 -1
  38. package/dist/schemas/index.js +6 -4
  39. package/dist/schemas/index.ts +4 -2
  40. package/dist/schemas/project-schema/latest.json +2175 -2195
  41. package/dist/schemas/project-schema/v3.18.0.json +2350 -0
  42. package/dist/schemas/project-schema.json +3 -0
  43. package/dist/template-shapes/templates.d.ts +5 -0
  44. package/dist/template-shapes/templates.d.ts.map +1 -1
  45. package/dist/template-shapes/templates.js +59 -28
  46. package/dist/template-shapes/where.d.ts +3 -4
  47. package/dist/template-shapes/where.d.ts.map +1 -1
  48. package/dist/template-shapes/where.js +32 -26
  49. package/dist/types/types.d.ts +42 -2
  50. package/dist/types/types.d.ts.map +1 -1
  51. package/dist/types/utils.d.ts +2 -0
  52. package/dist/types/utils.d.ts.map +1 -1
  53. package/dist/types/utils.js +9 -1
  54. package/dist/unions.d.ts.map +1 -1
  55. package/dist/unions.js +3 -1
  56. package/dist/util/detect-cycles.d.ts +3 -1
  57. package/dist/util/detect-cycles.d.ts.map +1 -1
  58. package/dist/util/detect-cycles.js +37 -28
  59. package/dist/util/form-config.d.ts +9 -0
  60. package/dist/util/form-config.d.ts.map +1 -0
  61. package/dist/util/form-config.js +97 -0
  62. package/dist/util/index.d.ts +1 -0
  63. package/dist/util/index.d.ts.map +1 -1
  64. package/dist/util/index.js +13 -0
  65. package/dist/validate.d.ts.map +1 -1
  66. package/dist/validate.js +75 -45
  67. package/es/builtin-schema.js +17 -0
  68. package/es/get-is-leaf.js +2 -1
  69. package/es/migration/index.js +3 -1
  70. package/es/migration/to/v3.18.0.js +72 -0
  71. package/es/mocks.js +4 -2
  72. package/es/project-schema/index.js +3 -1
  73. package/es/project-schema/migrate.js +5 -1
  74. package/es/project-schema/v3.18.0.js +1 -0
  75. package/es/refs.js +22 -1
  76. package/es/relationships.js +215 -19
  77. package/es/rewrite.js +10 -2
  78. package/es/schema-util.js +38 -119
  79. package/es/schemas/index.js +4 -3
  80. package/es/schemas/index.ts +4 -2
  81. package/es/schemas/project-schema/latest.json +2175 -2195
  82. package/es/schemas/project-schema/v3.18.0.json +2350 -0
  83. package/es/schemas/project-schema.json +3 -0
  84. package/es/template-shapes/templates.js +55 -29
  85. package/es/template-shapes/where.js +29 -23
  86. package/es/types/utils.js +8 -2
  87. package/es/unions.js +2 -1
  88. package/es/util/detect-cycles.js +36 -28
  89. package/es/util/form-config.js +85 -0
  90. package/es/util/index.js +2 -1
  91. package/es/validate.js +74 -46
  92. package/examples/latest/betzino.json +12383 -6066
  93. package/examples/latest/blog-schema.json +46 -25
  94. package/examples/latest/brewery-schema.json +14 -9
  95. package/examples/latest/complex-project-schema.json +442 -244
  96. package/examples/latest/complex-schema.json +17205 -0
  97. package/examples/latest/fabric-ecommerce.json +2 -2
  98. package/examples/latest/frank-and-fred-schema.json +5141 -2391
  99. package/examples/latest/klirr-schema.json +35445 -0
  100. package/examples/latest/massive-schema.json +1205 -640
  101. package/examples/latest/mill-components-schema.json +241 -113
  102. package/examples/latest/one-earth.json +14429 -0
  103. package/examples/latest/pet-oneof-array.json +2 -2
  104. package/examples/latest/post-schema.json +18 -11
  105. package/examples/latest/pruned-shopify-product-schema.json +2 -2
  106. package/examples/latest/real-world-schema.json +81 -41
  107. package/examples/latest/recursive-repeater-schema.json +14 -9
  108. package/examples/latest/recursive-schema.json +14 -9
  109. package/examples/latest/rick-and-morty-ast.json +138 -80
  110. package/examples/latest/rick-and-morty-graphql.json +78 -45
  111. package/examples/latest/rick-and-morty-rest.json +2 -2
  112. package/examples/latest/schema-with-repeater-draftjs.json +38 -23
  113. package/examples/latest/shape-books-v3_2_0.json +138 -80
  114. package/examples/latest/shape-books.json +138 -80
  115. package/examples/latest/shopify-lookbook.json +30 -16
  116. package/examples/latest/shopify-namespace-schema.json +364 -0
  117. package/examples/latest/shopify-store-with-widget.json +2 -2
  118. package/examples/latest/stripe-starter-resolved.json +14 -8
  119. package/examples/latest/user-schema-no-required.json +2 -2
  120. package/examples/latest/user-schema-with-defaults.json +2 -2
  121. package/examples/source/complex-schema.json +12760 -0
  122. package/examples/source/klirr-schema.json +27716 -0
  123. package/examples/source/one-earth.json +11897 -0
  124. package/examples/source/post-schema.json +0 -1
  125. package/package.json +5 -4
@@ -1,47 +1,243 @@
1
- export function getRelationshipSchema(relationship) {
2
- const itemSchema = {
3
- $ref: '#/shapes/TSRelationship/schema'
1
+ import { isDefined } from '@takeshape/util';
2
+ import { isPropertySchemaWithRelationship } from './types';
3
+ import { getShapeById, isModelShape } from './schema-util';
4
+ import { getRefShapeName, followRef } from './refs';
5
+ import { isUnionSchema } from './unions';
6
+ import { builtInShapes } from './builtin-schema';
7
+ import find from 'lodash/find';
8
+ /**
9
+ * Turn a LegacyRelationship into a partial PropertySchemaWithRelationship.
10
+ */
11
+
12
+ export function getRelationshipSchema(projectSchema, legacyRelationship) {
13
+ const propertySchema = {
14
+ '@args': 'TSRelationshipArgs',
15
+ '@resolver': {
16
+ name: 'takeshape:getRelated',
17
+ service: 'takeshape:local',
18
+ options: {
19
+ nullable: true
20
+ }
21
+ }
22
+ };
23
+ const shapeRefs = legacyRelationship.shapeIds.map(shapeId => {
24
+ const shape = getShapeById(projectSchema, shapeId) ?? find(builtInShapes, shape => shape.id === shapeId);
25
+ return shape && {
26
+ '@ref': `local:${shape.name}`
27
+ };
28
+ }).filter(isDefined);
29
+
30
+ if (!shapeRefs.length) {
31
+ throw new Error(`Invalid empty relationship ${JSON.stringify(legacyRelationship)}`);
32
+ }
33
+
34
+ const shapeRefsSchema = shapeRefs.length === 1 ? shapeRefs[0] : {
35
+ oneOf: shapeRefs
4
36
  };
5
37
 
6
- if (relationship.type === 'multiple') {
7
- return {
38
+ if (legacyRelationship.type === 'multiple') {
39
+ return { ...propertySchema,
8
40
  type: 'array',
9
- items: itemSchema,
10
- '@relationship': relationship
41
+ items: shapeRefsSchema,
42
+ '@input': {
43
+ type: 'array',
44
+ items: {
45
+ '@ref': 'local:TSRelationship'
46
+ }
47
+ }
11
48
  };
12
49
  }
13
50
 
14
- return { ...itemSchema,
15
- '@relationship': relationship
51
+ return { ...propertySchema,
52
+ ...shapeRefsSchema,
53
+ '@input': {
54
+ '@ref': 'local:TSRelationship'
55
+ }
56
+ };
57
+ }
58
+ /**
59
+ * Get a list of refs given a property schema with a relationship resolver.
60
+ */
61
+
62
+ export function getRelationshipShapeRefs(propertySchema) {
63
+ let refs = [];
64
+ const schema = propertySchema.items ?? propertySchema;
65
+
66
+ if (schema.oneOf) {
67
+ refs = schema.oneOf.map(schema => schema['@ref']).filter(isDefined);
68
+ } else if (schema['@ref']) {
69
+ refs = [schema['@ref']];
70
+ }
71
+
72
+ return refs;
73
+ }
74
+ /**
75
+ * Get a list of shapes given a property schema with a relationship resolver.
76
+ */
77
+
78
+ export function getRelationshipShapes(shapes, refs) {
79
+ return refs.map(ref => {
80
+ const shapeName = ref.split(':')[1];
81
+ const shape = shapes[shapeName];
82
+ return shape ? shape : undefined;
83
+ }).filter(isDefined);
84
+ }
85
+ /**
86
+ * Get a list of shape ids given a property schema with a relationship resolver.
87
+ */
88
+
89
+ export function getRelationshipShapeIds(shapes, refs) {
90
+ return refs.map(ref => {
91
+ const shapeName = ref.split(':')[1];
92
+ const shape = shapes[shapeName];
93
+ return shape ? shape.id : undefined;
94
+ }).filter(isDefined);
95
+ }
96
+ /**
97
+ * Turn a Relationship into a LegacyRelationship object.
98
+ */
99
+
100
+ export function getLegacyRelationship(projectSchema, relationship) {
101
+ return {
102
+ type: relationship.isMultiple ? 'multiple' : 'single',
103
+ shapeIds: getRelationshipShapeIds(projectSchema.shapes, relationship.refs)
104
+ };
105
+ }
106
+ /**
107
+ * Get relationship details from a PropertySchema.
108
+ */
109
+
110
+ export function getRelationship(propertySchema) {
111
+ var _propertySchema$Back, _propertySchema$Back2;
112
+
113
+ propertySchema = propertySchema['@output'] ?? propertySchema;
114
+
115
+ if (!isPropertySchemaWithRelationship(propertySchema)) {
116
+ return;
117
+ }
118
+
119
+ const isMultiple = propertySchema.type === 'array';
120
+ const hasBackreference = Boolean((_propertySchema$Back = propertySchema['@backreference']) === null || _propertySchema$Back === void 0 ? void 0 : _propertySchema$Back.enabled);
121
+ const backreferenceName = (_propertySchema$Back2 = propertySchema['@backreference']) === null || _propertySchema$Back2 === void 0 ? void 0 : _propertySchema$Back2.name;
122
+ const refs = getRelationshipShapeRefs(propertySchema);
123
+ return {
124
+ isMultiple,
125
+ refs,
126
+ hasBackreference,
127
+ backreferenceName
16
128
  };
17
- } // TODO: Code below will likely cause a conflict with @relationship PR...
129
+ }
130
+
131
+ function addRelationship(relationships, id, env) {
132
+ if (!relationships[id]) {
133
+ relationships[id] = [];
134
+ }
135
+
136
+ relationships[id].push(env);
137
+ }
138
+
139
+ export function findExistingRelationships(projectSchema, shapes) {
140
+ const relationships = {};
141
+ const shapeArray = Object.values(shapes);
142
+ const shapesSeen = new Set();
143
+ const shapeIds = new Set(shapeArray.map(shape => shape.id));
144
+
145
+ const findRelationships = (schema, path, parentShapeName) => {
146
+ const relationship = getRelationship(schema);
18
147
 
148
+ if (relationship) {
149
+ var _schema$Backreferenc;
150
+
151
+ const relatedShapeIds = getRelationshipShapeIds(shapes, relationship.refs);
152
+ const relatedName = (_schema$Backreferenc = schema['@backreference']) === null || _schema$Backreferenc === void 0 ? void 0 : _schema$Backreferenc.name;
153
+
154
+ for (const shapeId of relatedShapeIds) {
155
+ if (shapeIds.has(shapeId)) {
156
+ var _schema$Backreferenc2;
157
+
158
+ addRelationship(relationships, shapeId, {
159
+ relatedName,
160
+ path: path.slice(1),
161
+ shapeId: path[0],
162
+ hasBackreference: Boolean((_schema$Backreferenc2 = schema['@backreference']) === null || _schema$Backreferenc2 === void 0 ? void 0 : _schema$Backreferenc2.enabled),
163
+ schema,
164
+ shapeName: parentShapeName
165
+ });
166
+ }
167
+ }
168
+ }
169
+
170
+ const shapeName = getRefShapeName(projectSchema, schema);
171
+
172
+ if (shapeName && !shapes[shapeName]) {
173
+ return;
174
+ }
175
+
176
+ const prop = shapeName ? followRef(projectSchema, schema) : schema;
177
+
178
+ if (shapeName) {
179
+ // Skip shapes we have already seen to avoid cycles
180
+ if (shapesSeen.has(shapeName)) {
181
+ return;
182
+ }
183
+
184
+ shapesSeen.add(shapeName);
185
+ }
186
+
187
+ if (!relationship) {
188
+ if (prop.properties) {
189
+ for (const name of Object.keys(prop.properties)) {
190
+ findRelationships(prop.properties[name], path.concat(name), shapeName ?? parentShapeName);
191
+ }
192
+ } else if (prop.items) {
193
+ findRelationships(prop.items, path, shapeName ?? parentShapeName);
194
+ } else if (isUnionSchema(prop)) {
195
+ for (const child of prop.oneOf) {
196
+ findRelationships(child, path, shapeName ?? parentShapeName);
197
+ }
198
+ }
199
+ }
200
+ };
201
+
202
+ for (const shape of shapeArray) {
203
+ if (isModelShape(shape)) {
204
+ const {
205
+ schema,
206
+ id,
207
+ name
208
+ } = shape;
209
+ findRelationships(schema, [id], name);
210
+ }
211
+ }
212
+
213
+ return relationships;
214
+ }
19
215
  /**
20
216
  * Test whether two PropertySchemas have equal realtionships
21
217
  */
22
218
 
23
219
  export function isEqualRelationship(a, b) {
24
- var _a$Relationship, _b$Relationship;
220
+ const relationshipA = getRelationship(a);
221
+ const relationshipB = getRelationship(b); // non-relationships are considered equal in that they are both equal that regard
25
222
 
26
- // non-relationships are considered equal in that they are both equal that regard
27
- if (!a['@relationship'] && !b['@relationship']) {
223
+ if (!relationshipA && !relationshipB) {
28
224
  return true;
29
225
  }
30
226
 
31
- const idsA = (_a$Relationship = a['@relationship']) === null || _a$Relationship === void 0 ? void 0 : _a$Relationship.shapeIds;
227
+ const refsA = relationshipA === null || relationshipA === void 0 ? void 0 : relationshipA.refs;
32
228
 
33
- if (!idsA) {
229
+ if (!refsA) {
34
230
  return false;
35
231
  }
36
232
 
37
- const idsB = (_b$Relationship = b['@relationship']) === null || _b$Relationship === void 0 ? void 0 : _b$Relationship.shapeIds;
233
+ const refsB = relationshipB === null || relationshipB === void 0 ? void 0 : relationshipB.refs;
38
234
 
39
- if (!idsB || idsA.length !== idsB.length) {
235
+ if (!refsB || refsA.length !== refsB.length) {
40
236
  return false;
41
237
  }
42
238
 
43
- const idSet = new Set(idsA);
44
- return idsB.every(id => idSet.has(id));
239
+ const refSet = new Set(refsA);
240
+ return refsB.every(ref => refSet.has(ref));
45
241
  }
46
242
  /**
47
243
  * Test whether an array of PropertySchemas have unequal relationships
package/es/rewrite.js CHANGED
@@ -45,8 +45,16 @@ export function rewriteSchema(schema, options) {
45
45
  }
46
46
 
47
47
  if (options.replaceInput && isRecord(value['@input'])) {
48
- return { ...value['@input'],
49
- '@mapping': value['@mapping']
48
+ const {
49
+ '@input': input,
50
+ '@mapping': mapping,
51
+ title,
52
+ ...output
53
+ } = value;
54
+ return { ...input,
55
+ title,
56
+ '@mapping': mapping,
57
+ '@output': output
50
58
  };
51
59
  }
52
60
  }
package/es/schema-util.js CHANGED
@@ -2,21 +2,21 @@ import find from 'lodash/find';
2
2
  import mapValues from 'lodash/mapValues';
3
3
  import omitBy from 'lodash/omitBy';
4
4
  import pickBy from 'lodash/pickBy';
5
- import get from 'lodash/get';
6
5
  import keyBy from 'lodash/keyBy';
7
6
  import isObject from 'lodash/isObject';
8
7
  import curry from 'lodash/fp/curry';
9
8
  import orderBy from 'lodash/fp/orderBy';
10
9
  import uniq from 'lodash/uniq';
11
- import { deepClone, isDefined } from '@takeshape/util';
10
+ import { deepClone, isDefined, visit } from '@takeshape/util';
12
11
  import { defaultWorkflow, getStatusField } from './workflows';
13
12
  import { CURRENT_API_VERSION, CURRENT_SCHEMA_VERSION } from './versions';
14
13
  import { workflowsEnabled } from './api-version';
15
14
  import { builtInShapes, builtInForms } from './builtin-schema';
16
- import { getArgsType, isBasicResolver, isObjectSchema, isAllOfSchema, isRefSchema, isOneOfSchema, isExtendsSchema } from './types/utils';
15
+ import { getArgsType, isBasicResolver, isObjectSchema, isAllOfSchema, isOneOfSchema, isExtendsSchema, isArraySchema } from './types/utils';
17
16
  import { getStoredServiceConfig } from './services';
18
- import { createTemplateShapeName, dereferenceObjectSchema, dereferenceSchema, followRef, getRef, getRefOrItemsRef, getRefShapeName, parseReturnShape, refExpressionToRefItem, refItemToShape, refItemToShapeName, refItemToShapeSchema } from './refs';
17
+ import { createTemplateShapeName, dereferenceObjectSchema, dereferenceSchema, getRef, getRefOrItemsRef, getRefShapeName, parseReturnShape, refExpressionToRefItem, refItemToShape, refItemToShapeName, refItemToShapeSchema, atRefToRefItem, refToRefItem, parseTemplateShape, isRefItemWithPath } from './refs';
19
18
  import isEqual from 'lodash/isEqual';
19
+ import isString from 'lodash/isString';
20
20
  import { isUnionSchema } from './unions';
21
21
  import { mergeFormProperties, mergeSchemaProperties } from './util/merge';
22
22
  export const SERVICE_OBJECT_PATTERN_NAME = 'pattern:service-object';
@@ -41,7 +41,7 @@ export const objectSchemaKeys = [...commonSchemaKeys, 'properties', 'required'];
41
41
  export const arraySchemaKeys = [...commonSchemaKeys, 'items', 'additionalItems', 'maxItems', 'minItems', 'uniqueItems'];
42
42
  export const multipleRelationshipSchemaKeys = [...schemaMetadataKeys, 'maxItems', 'minItems']; // All properties except properties, items, additionalItems
43
43
 
44
- export const nonStructuralSchemaKeys = [...scalarSchemaKeys, '@relationship', '@backreference', 'required', 'maxItems', 'minItems', 'uniqueItems'];
44
+ export const nonStructuralSchemaKeys = [...scalarSchemaKeys, '@resolver', '@input', '@output', '@backreference', '@args', 'required', 'maxItems', 'minItems', 'uniqueItems'];
45
45
  export function getServiceIdFieldName(serviceFieldName) {
46
46
  return `${serviceFieldName}Id`;
47
47
  }
@@ -413,94 +413,6 @@ export function applyDefaultsToSchema(projectSchema) {
413
413
  })
414
414
  };
415
415
  }
416
-
417
- function addRelationship(relationships, id, env) {
418
- if (!relationships[id]) {
419
- relationships[id] = [];
420
- }
421
-
422
- relationships[id].push(env);
423
- }
424
- /**
425
- * Finds all relationships in the schema and returns an object indexed by shape.id that lists all of the shapes
426
- * properties that reference it
427
- */
428
-
429
-
430
- export function findExistingRelationships(projectSchema, shapes) {
431
- const relationships = {};
432
- const shapeArray = Object.values(shapes);
433
- const shapesSeen = new Set();
434
- const shapeIds = new Set(shapeArray.map(shape => shape.id));
435
-
436
- const findRelationships = (schema, path, parentShapeName) => {
437
- if (schema['@relationship']) {
438
- var _schema$Backreferenc;
439
-
440
- const {
441
- shapeIds: relatedShapeIds
442
- } = schema['@relationship'];
443
- const relatedName = (_schema$Backreferenc = schema['@backreference']) === null || _schema$Backreferenc === void 0 ? void 0 : _schema$Backreferenc.name;
444
-
445
- for (const shapeId of relatedShapeIds) {
446
- if (shapeIds.has(shapeId)) {
447
- var _schema$Backreferenc2;
448
-
449
- addRelationship(relationships, shapeId, {
450
- relatedName,
451
- path: path.slice(1),
452
- shapeId: path[0],
453
- hasBackreference: Boolean((_schema$Backreferenc2 = schema['@backreference']) === null || _schema$Backreferenc2 === void 0 ? void 0 : _schema$Backreferenc2.enabled),
454
- schema,
455
- shapeName: parentShapeName
456
- });
457
- }
458
- }
459
- }
460
-
461
- const shapeName = getRefShapeName(projectSchema, schema);
462
-
463
- if (shapeName && !shapes[shapeName]) {
464
- return;
465
- }
466
-
467
- const prop = shapeName ? followRef(projectSchema, schema) : schema;
468
-
469
- if (shapeName) {
470
- // Skip shapes we have already seen to avoid cycles
471
- if (shapesSeen.has(shapeName)) {
472
- return;
473
- }
474
-
475
- shapesSeen.add(shapeName);
476
- }
477
-
478
- if (prop.properties) {
479
- for (const name of Object.keys(prop.properties)) {
480
- findRelationships(prop.properties[name], path.concat(name), shapeName ?? parentShapeName);
481
- }
482
- } else if (prop.items) {
483
- findRelationships(prop.items, path, shapeName ?? parentShapeName);
484
- } else if (isUnionSchema(prop)) {
485
- for (const child of prop.oneOf) {
486
- findRelationships(child, path, shapeName ?? parentShapeName);
487
- }
488
- }
489
- };
490
-
491
- for (const shape of shapeArray) {
492
- if (isModelShape(shape)) {
493
- const {
494
- schema,
495
- id,
496
- name
497
- } = shape;
498
- findRelationships(schema, [id], name);
499
- }
500
- }
501
-
502
- return relationships;
503
- }
504
416
  export function stringifyQuerySource(providerId, serviceId) {
505
417
  return `${providerId}:${serviceId}`;
506
418
  }
@@ -741,7 +653,9 @@ function visitSchemaPropertiesHelper(entries, path, callback) {
741
653
  }
742
654
 
743
655
  export function visitSchemaProperties(schema, path, callback) {
744
- if (isObjectSchema(schema)) {
656
+ if (isArraySchema(schema)) {
657
+ visitSchemaPropertiesHelper(Object.entries(schema.items), [...path, 'items'], callback);
658
+ } else if (isObjectSchema(schema)) {
745
659
  visitSchemaPropertiesHelper(Object.entries(schema.properties), [...path, 'properties'], callback);
746
660
  } else if (isExtendsSchema(schema)) {
747
661
  visitSchemaPropertiesHelper(Object.entries(schema.extends), [...path, 'extends'], callback);
@@ -771,29 +685,41 @@ function addRef(refs, ref, predicate) {
771
685
 
772
686
  export function getAllRefsInShapes(projectSchema, predicate) {
773
687
  const items = [];
774
-
775
- const shapeVisitor = (schema, schemaPath) => {
776
- if (schema['@args'] && typeof schema['@args'] === 'object') {
777
- visitSchemaProperties(schema['@args'], schemaPath.concat(['@args']), (argSchema, argPath) => {
778
- addRef(items, getRefOrItemsRef(projectSchema, argSchema, argPath), predicate);
779
- });
688
+ const refPropNames = ['$ref', '@ref', '@args', 'args'];
689
+ visit(projectSchema.shapes, refPropNames, (ref, refPath) => {
690
+ // The client sometimes generates invalid schemas, like refs that are
691
+ // undefined. Treat ref as unknown and toss those out.
692
+ // See the `useShapeEditor > can deal with renames test`
693
+ if (!isString(ref)) {
694
+ return;
780
695
  }
781
696
 
782
- addRef(items, getArgsReferenceWithPath(projectSchema, schema, schemaPath), predicate);
783
- const newPath = schema.items ? schemaPath.concat('items') : schemaPath;
784
- const newSchema = schema.items ?? schema;
697
+ const propName = refPath[refPath.length - 1];
698
+ const path = ['shapes', ...refPath];
699
+ let refItem = {};
785
700
 
786
- if (isRefSchema(newSchema)) {
787
- addRef(items, getRefOrItemsRef(projectSchema, newSchema, newPath), predicate);
788
- } else if (isObjectSchema(newSchema) || isAllOfSchema(newSchema) || isOneOfSchema(newSchema)) {
789
- visitSchemaProperties(newSchema, newPath, shapeVisitor);
701
+ if (propName === '@ref') {
702
+ const {
703
+ shapeName,
704
+ template
705
+ } = parseTemplateShape(ref);
706
+ refItem = { ...atRefToRefItem(projectSchema, shapeName, template),
707
+ path
708
+ };
709
+ } else if (propName === '$ref') {
710
+ refItem = { ...refToRefItem(projectSchema, ref),
711
+ path
712
+ };
713
+ } else if (propName === '@args' || propName === 'args') {
714
+ refItem = { ...refExpressionToRefItem(projectSchema, ref),
715
+ path
716
+ };
790
717
  }
791
- };
792
-
793
- for (const [shapeName, shape] of Object.entries(projectSchema.shapes)) {
794
- visitSchemaProperties(shape.schema, ['shapes', shapeName, 'schema'], shapeVisitor);
795
- }
796
718
 
719
+ if (isRefItemWithPath(refItem)) {
720
+ addRef(items, refItem, predicate);
721
+ }
722
+ });
797
723
  return items;
798
724
  }
799
725
  /**
@@ -1187,13 +1113,6 @@ export const ensureQuery = (projectSchema, shapeName, resolver) => ensureQueryHe
1187
1113
  */
1188
1114
 
1189
1115
  export const ensureMutation = (projectSchema, shapeName, resolver) => ensureQueryHelper(projectSchema, shapeName, resolver, 'mutation');
1190
- /**
1191
- * Find the form config for a given shape name and the form key.
1192
- */
1193
-
1194
- export function findShapeFormConfig(projectSchema, shapeName, formName) {
1195
- return get(projectSchema, ['forms', shapeName, formName]);
1196
- }
1197
1116
 
1198
1117
  /**
1199
1118
  * Find the query in the schema that corresponds to the given shape and resolver.
@@ -1,7 +1,7 @@
1
1
  // This file is generated by "pnpm json2ts"
2
- export const CURRENT_SCHEMA_VERSION = '3.17.1';
2
+ export const CURRENT_SCHEMA_VERSION = '3.18.0';
3
3
  export { default as anyProjectSchema } from './project-schema.json';
4
- export { default as latestSchemaJson } from './project-schema/v3.17.1.json';
4
+ export { default as latestSchemaJson } from './project-schema/v3.18.0.json';
5
5
  import metaSchemaV1_0_0 from './project-schema/meta-schema-v1.0.0.json';
6
6
  import projectSchemaV1_0_0 from './project-schema/v1.0.0.json';
7
7
  import metaSchemaV3_0_0 from './project-schema/meta-schema-v3.0.0.json';
@@ -38,5 +38,6 @@ import projectSchemaV3_15_0 from './project-schema/v3.15.0.json';
38
38
  import projectSchemaV3_16_0 from './project-schema/v3.16.0.json';
39
39
  import projectSchemaV3_17_0 from './project-schema/v3.17.0.json';
40
40
  import projectSchemaV3_17_1 from './project-schema/v3.17.1.json';
41
+ import projectSchemaV3_18_0 from './project-schema/v3.18.0.json';
41
42
  import projectSchemaV4_0_0 from './project-schema/v4.0.0.json';
42
- export const allProjectSchemas = [metaSchemaV1_0_0, projectSchemaV1_0_0, metaSchemaV3_0_0, projectSchemaV3_0_0, metaSchemaV3_1_0, projectSchemaV3_1_0, metaSchemaV3_2_0, projectSchemaV3_2_0, metaSchemaV3_3_0, projectSchemaV3_3_0, metaSchemaV3_4_0, projectSchemaV3_4_0, metaSchemaV3_5_0, projectSchemaV3_5_0, metaSchemaV3_5_1, projectSchemaV3_5_1, metaSchemaV3_6_0, projectSchemaV3_6_0, metaSchemaV3_7_0, projectSchemaV3_7_0, metaSchemaV3_8_0, projectSchemaV3_8_0, metaSchemaV3_9_0, projectSchemaV3_9_0, projectSchemaV3_10_0, projectSchemaV3_11_0, projectSchemaV3_12_0, projectSchemaV3_12_1, projectSchemaV3_12_2, projectSchemaV3_12_3, projectSchemaV3_13_0, projectSchemaV3_14_0, projectSchemaV3_15_0, projectSchemaV3_16_0, projectSchemaV3_17_0, projectSchemaV3_17_1, projectSchemaV4_0_0];
43
+ export const allProjectSchemas = [metaSchemaV1_0_0, projectSchemaV1_0_0, metaSchemaV3_0_0, projectSchemaV3_0_0, metaSchemaV3_1_0, projectSchemaV3_1_0, metaSchemaV3_2_0, projectSchemaV3_2_0, metaSchemaV3_3_0, projectSchemaV3_3_0, metaSchemaV3_4_0, projectSchemaV3_4_0, metaSchemaV3_5_0, projectSchemaV3_5_0, metaSchemaV3_5_1, projectSchemaV3_5_1, metaSchemaV3_6_0, projectSchemaV3_6_0, metaSchemaV3_7_0, projectSchemaV3_7_0, metaSchemaV3_8_0, projectSchemaV3_8_0, metaSchemaV3_9_0, projectSchemaV3_9_0, projectSchemaV3_10_0, projectSchemaV3_11_0, projectSchemaV3_12_0, projectSchemaV3_12_1, projectSchemaV3_12_2, projectSchemaV3_12_3, projectSchemaV3_13_0, projectSchemaV3_14_0, projectSchemaV3_15_0, projectSchemaV3_16_0, projectSchemaV3_17_0, projectSchemaV3_17_1, projectSchemaV3_18_0, projectSchemaV4_0_0];
@@ -1,7 +1,7 @@
1
1
  // This file is generated by "pnpm json2ts"
2
- export const CURRENT_SCHEMA_VERSION = '3.17.1';
2
+ export const CURRENT_SCHEMA_VERSION = '3.18.0';
3
3
  export {default as anyProjectSchema} from './project-schema.json';
4
- export {default as latestSchemaJson} from './project-schema/v3.17.1.json';
4
+ export {default as latestSchemaJson} from './project-schema/v3.18.0.json';
5
5
  import metaSchemaV1_0_0 from './project-schema/meta-schema-v1.0.0.json';
6
6
  import projectSchemaV1_0_0 from './project-schema/v1.0.0.json';
7
7
  import metaSchemaV3_0_0 from './project-schema/meta-schema-v3.0.0.json';
@@ -38,6 +38,7 @@ import projectSchemaV3_15_0 from './project-schema/v3.15.0.json';
38
38
  import projectSchemaV3_16_0 from './project-schema/v3.16.0.json';
39
39
  import projectSchemaV3_17_0 from './project-schema/v3.17.0.json';
40
40
  import projectSchemaV3_17_1 from './project-schema/v3.17.1.json';
41
+ import projectSchemaV3_18_0 from './project-schema/v3.18.0.json';
41
42
  import projectSchemaV4_0_0 from './project-schema/v4.0.0.json';
42
43
  export const allProjectSchemas = [
43
44
  metaSchemaV1_0_0,
@@ -76,5 +77,6 @@ export const allProjectSchemas = [
76
77
  projectSchemaV3_16_0,
77
78
  projectSchemaV3_17_0,
78
79
  projectSchemaV3_17_1,
80
+ projectSchemaV3_18_0,
79
81
  projectSchemaV4_0_0
80
82
  ];