@takeshape/schema 9.80.4 → 9.81.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 (189) hide show
  1. package/dist/api-version.js +0 -9
  2. package/dist/builtin-schema.js +0 -5
  3. package/dist/content-schema-transform.js +4 -52
  4. package/dist/create-input-schema.js +7 -19
  5. package/dist/enum.js +0 -3
  6. package/dist/flatten-templates.js +0 -11
  7. package/dist/get-is-leaf.js +8 -18
  8. package/dist/index.js +0 -58
  9. package/dist/interfaces.js +2 -26
  10. package/dist/layers/layers.js +23 -103
  11. package/dist/layers/refs.js +26 -69
  12. package/dist/layers/type-utils.js +11 -43
  13. package/dist/layers/visitor.js +0 -6
  14. package/dist/migration/index.js +0 -51
  15. package/dist/migration/to/v3.0.0.js +31 -45
  16. package/dist/migration/to/v3.1.0.js +15 -41
  17. package/dist/migration/to/v3.10.0.js +6 -20
  18. package/dist/migration/to/v3.11.0.js +8 -20
  19. package/dist/migration/to/v3.12.0.js +2 -3
  20. package/dist/migration/to/v3.12.1.js +2 -3
  21. package/dist/migration/to/v3.12.2.js +2 -3
  22. package/dist/migration/to/v3.12.3.js +16 -21
  23. package/dist/migration/to/v3.13.0.js +2 -7
  24. package/dist/migration/to/v3.14.0.js +2 -3
  25. package/dist/migration/to/v3.15.0.js +2 -3
  26. package/dist/migration/to/v3.16.0.js +2 -3
  27. package/dist/migration/to/v3.17.0.js +4 -9
  28. package/dist/migration/to/v3.17.1.js +2 -3
  29. package/dist/migration/to/v3.18.0.js +2 -15
  30. package/dist/migration/to/v3.18.1.js +2 -7
  31. package/dist/migration/to/v3.18.2.js +8 -10
  32. package/dist/migration/to/v3.19.0.js +2 -3
  33. package/dist/migration/to/v3.2.0.js +2 -3
  34. package/dist/migration/to/v3.20.0.js +10 -11
  35. package/dist/migration/to/v3.21.0.js +2 -3
  36. package/dist/migration/to/v3.22.0.js +4 -9
  37. package/dist/migration/to/v3.23.0.js +2 -3
  38. package/dist/migration/to/v3.24.0.js +2 -3
  39. package/dist/migration/to/v3.25.0.js +2 -3
  40. package/dist/migration/to/v3.26.0.js +2 -3
  41. package/dist/migration/to/v3.27.0.js +2 -3
  42. package/dist/migration/to/v3.28.0.js +2 -3
  43. package/dist/migration/to/v3.29.0.js +2 -3
  44. package/dist/migration/to/v3.3.0.js +3 -4
  45. package/dist/migration/to/v3.30.0.js +2 -3
  46. package/dist/migration/to/v3.31.0.js +2 -12
  47. package/dist/migration/to/v3.32.0.js +12 -22
  48. package/dist/migration/to/v3.33.0.js +2 -3
  49. package/dist/migration/to/v3.34.0.js +14 -43
  50. package/dist/migration/to/v3.35.0.js +2 -3
  51. package/dist/migration/to/v3.36.0.js +6 -10
  52. package/dist/migration/to/v3.37.0.js +2 -3
  53. package/dist/migration/to/v3.38.0.js +2 -3
  54. package/dist/migration/to/v3.39.0.js +6 -13
  55. package/dist/migration/to/v3.4.0.js +2 -3
  56. package/dist/migration/to/v3.5.0.js +2 -3
  57. package/dist/migration/to/v3.5.1.js +2 -3
  58. package/dist/migration/to/v3.6.0.js +2 -3
  59. package/dist/migration/to/v3.7.0.js +2 -3
  60. package/dist/migration/to/v3.8.0.js +2 -3
  61. package/dist/migration/to/v3.9.0.js +8 -24
  62. package/dist/migration/utils.js +0 -2
  63. package/dist/mocks.js +9 -12
  64. package/dist/models/project-schema.js +0 -34
  65. package/dist/models/query.js +0 -9
  66. package/dist/models/service.js +0 -8
  67. package/dist/models/shape.js +0 -29
  68. package/dist/project-schema/index.js +1 -105
  69. package/dist/project-schema/migrate.js +1 -54
  70. package/dist/refs.js +39 -159
  71. package/dist/relationships.js +13 -57
  72. package/dist/scalars.js +0 -1
  73. package/dist/schema-transform.js +0 -11
  74. package/dist/schema-util.js +75 -271
  75. package/dist/schemas/index.js +0 -64
  76. package/dist/services.js +24 -44
  77. package/dist/taxonomies.js +0 -13
  78. package/dist/template-shapes/index.js +1 -8
  79. package/dist/template-shapes/templates.js +9 -40
  80. package/dist/template-shapes/types.js +4 -5
  81. package/dist/template-shapes/where.js +14 -110
  82. package/dist/types/index.js +0 -4
  83. package/dist/types/types.js +41 -13
  84. package/dist/types/utils.js +15 -89
  85. package/dist/unions.js +8 -38
  86. package/dist/util/api-indexing.js +2 -19
  87. package/dist/util/detect-cycles.js +2 -16
  88. package/dist/util/find-shape-at-path.js +1 -15
  89. package/dist/util/form-config.js +6 -23
  90. package/dist/util/get-conflicting-properties.js +7 -17
  91. package/dist/util/get-return-shape.js +0 -11
  92. package/dist/util/has-arg.js +0 -6
  93. package/dist/util/index.js +0 -18
  94. package/dist/util/merge.js +28 -74
  95. package/dist/util/patch-schema.js +5 -13
  96. package/dist/validate.js +15 -234
  97. package/dist/versions.js +0 -2
  98. package/dist/workflows.js +0 -15
  99. package/es/api-version.js +0 -4
  100. package/es/content-schema-transform.js +4 -38
  101. package/es/create-input-schema.js +7 -14
  102. package/es/enum.js +0 -2
  103. package/es/flatten-templates.js +0 -4
  104. package/es/get-is-leaf.js +8 -13
  105. package/es/index.js +1 -0
  106. package/es/interfaces.js +2 -14
  107. package/es/layers/layers.js +23 -90
  108. package/es/layers/refs.js +22 -45
  109. package/es/layers/type-utils.js +11 -16
  110. package/es/layers/visitor.js +0 -3
  111. package/es/migration/to/v3.0.0.js +31 -38
  112. package/es/migration/to/v3.1.0.js +16 -34
  113. package/es/migration/to/v3.10.0.js +6 -17
  114. package/es/migration/to/v3.11.0.js +8 -18
  115. package/es/migration/to/v3.12.0.js +2 -2
  116. package/es/migration/to/v3.12.1.js +2 -2
  117. package/es/migration/to/v3.12.2.js +2 -2
  118. package/es/migration/to/v3.12.3.js +16 -19
  119. package/es/migration/to/v3.13.0.js +2 -4
  120. package/es/migration/to/v3.14.0.js +2 -2
  121. package/es/migration/to/v3.15.0.js +2 -2
  122. package/es/migration/to/v3.16.0.js +2 -2
  123. package/es/migration/to/v3.17.0.js +4 -4
  124. package/es/migration/to/v3.17.1.js +2 -2
  125. package/es/migration/to/v3.18.0.js +2 -10
  126. package/es/migration/to/v3.18.1.js +2 -3
  127. package/es/migration/to/v3.18.2.js +8 -8
  128. package/es/migration/to/v3.19.0.js +2 -2
  129. package/es/migration/to/v3.2.0.js +2 -2
  130. package/es/migration/to/v3.20.0.js +10 -9
  131. package/es/migration/to/v3.21.0.js +2 -2
  132. package/es/migration/to/v3.22.0.js +4 -6
  133. package/es/migration/to/v3.23.0.js +2 -2
  134. package/es/migration/to/v3.24.0.js +2 -2
  135. package/es/migration/to/v3.25.0.js +2 -2
  136. package/es/migration/to/v3.26.0.js +2 -2
  137. package/es/migration/to/v3.27.0.js +2 -2
  138. package/es/migration/to/v3.28.0.js +2 -2
  139. package/es/migration/to/v3.29.0.js +2 -2
  140. package/es/migration/to/v3.3.0.js +3 -3
  141. package/es/migration/to/v3.30.0.js +2 -2
  142. package/es/migration/to/v3.31.0.js +2 -5
  143. package/es/migration/to/v3.32.0.js +12 -21
  144. package/es/migration/to/v3.33.0.js +2 -2
  145. package/es/migration/to/v3.34.0.js +16 -32
  146. package/es/migration/to/v3.35.0.js +2 -2
  147. package/es/migration/to/v3.36.0.js +6 -8
  148. package/es/migration/to/v3.37.0.js +2 -2
  149. package/es/migration/to/v3.38.0.js +2 -2
  150. package/es/migration/to/v3.39.0.js +6 -12
  151. package/es/migration/to/v3.4.0.js +2 -2
  152. package/es/migration/to/v3.5.0.js +2 -2
  153. package/es/migration/to/v3.5.1.js +2 -2
  154. package/es/migration/to/v3.6.0.js +2 -2
  155. package/es/migration/to/v3.7.0.js +2 -2
  156. package/es/migration/to/v3.8.0.js +2 -2
  157. package/es/migration/to/v3.9.0.js +8 -20
  158. package/es/mocks.js +10 -6
  159. package/es/models/project-schema.js +0 -26
  160. package/es/models/query.js +0 -7
  161. package/es/models/service.js +0 -6
  162. package/es/models/shape.js +1 -25
  163. package/es/project-schema/index.js +0 -5
  164. package/es/project-schema/migrate.js +3 -51
  165. package/es/refs.js +40 -96
  166. package/es/relationships.js +14 -42
  167. package/es/schema-transform.js +0 -7
  168. package/es/schema-util.js +75 -180
  169. package/es/services.js +18 -27
  170. package/es/taxonomies.js +0 -9
  171. package/es/template-shapes/index.js +1 -4
  172. package/es/template-shapes/templates.js +9 -18
  173. package/es/template-shapes/types.js +3 -4
  174. package/es/template-shapes/where.js +14 -94
  175. package/es/types/types.js +43 -10
  176. package/es/types/utils.js +16 -24
  177. package/es/unions.js +8 -22
  178. package/es/util/api-indexing.js +2 -12
  179. package/es/util/detect-cycles.js +2 -14
  180. package/es/util/find-shape-at-path.js +2 -12
  181. package/es/util/form-config.js +7 -19
  182. package/es/util/get-conflicting-properties.js +8 -14
  183. package/es/util/get-return-shape.js +0 -8
  184. package/es/util/has-arg.js +0 -3
  185. package/es/util/merge.js +28 -55
  186. package/es/util/patch-schema.js +5 -7
  187. package/es/validate.js +15 -194
  188. package/es/workflows.js +0 -6
  189. package/package.json +5 -5
@@ -9,76 +9,50 @@ exports.getFields = getFields;
9
9
  exports.getPropertyComparisonType = getPropertyComparisonType;
10
10
  exports.getWhereSearchArg = getWhereSearchArg;
11
11
  exports.getWhereShape = getWhereShape;
12
-
13
12
  var _unset = _interopRequireDefault(require("lodash/unset"));
14
-
15
13
  var _isFunction = _interopRequireDefault(require("lodash/isFunction"));
16
-
17
14
  var _schemaUtil = require("../schema-util");
18
-
19
15
  var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
20
-
21
16
  var _blueimpMd = _interopRequireDefault(require("blueimp-md5"));
22
-
23
17
  var _util = require("@takeshape/util");
24
-
25
18
  var _apiVersion = require("../api-version");
26
-
27
19
  var _refs = require("../refs");
28
-
29
20
  var _unions = require("../unions");
30
-
31
21
  var _utils = require("../types/utils");
32
-
33
22
  var _relationships = require("../relationships");
34
-
35
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
-
37
24
  const MAX_RELATIONSHIP_DEPTH = 1;
38
25
  exports.MAX_RELATIONSHIP_DEPTH = MAX_RELATIONSHIP_DEPTH;
39
-
40
26
  const exceededRelationshipDepth = (depth = 0) => depth >= MAX_RELATIONSHIP_DEPTH;
41
-
42
27
  exports.exceededRelationshipDepth = exceededRelationshipDepth;
43
-
44
28
  class ShapeCache {
45
29
  thunks = new Map();
46
30
  unresolved = new Set();
47
-
48
31
  has(shapeName) {
49
32
  return this.thunks.has(shapeName);
50
33
  }
51
-
52
34
  set(shapeName, thunk) {
53
35
  this.thunks.set(shapeName, thunk);
54
-
55
36
  if ((0, _isFunction.default)(thunk)) {
56
37
  this.unresolved.add(shapeName);
57
38
  }
58
39
  }
59
-
60
40
  resolveAll() {
61
41
  while (this.unresolved.size) {
62
42
  const shapeName = this.unresolved.values().next().value;
63
43
  const thunk = this.thunks.get(shapeName);
64
-
65
44
  if ((0, _isFunction.default)(thunk)) {
66
45
  this.thunks.set(shapeName, thunk());
67
46
  this.unresolved.delete(shapeName);
68
47
  }
69
48
  }
70
-
71
49
  const result = {};
72
-
73
50
  for (const [shapeName, shape] of this.thunks) {
74
51
  result[shapeName] = shape;
75
52
  }
76
-
77
53
  return result;
78
54
  }
79
-
80
55
  }
81
-
82
56
  const fieldTypeComparison = {
83
57
  id: {
84
58
  comparators: ['eq', 'in'],
@@ -137,39 +111,31 @@ const boolOpDescriptionMap = {
137
111
  NOT: 'NOT takes a single condition that must not appear in the matching results.'
138
112
  };
139
113
  exports.boolOpDescriptionMap = boolOpDescriptionMap;
140
-
141
114
  function getConflictingProperties(projectSchema, shapes) {
142
115
  const conflicts = new Set();
143
116
  const allProps = {};
144
-
145
117
  for (const shape of Object.values(shapes)) {
146
118
  for (const [name, prop] of (0, _schemaUtil.createSchemaPropertyList)(projectSchema, shape).getNodes()) {
147
119
  if (name in allProps && (allProps[name].type !== prop.type || !(0, _relationships.isEqualRelationship)(allProps[name], prop))) {
148
120
  conflicts.add(name);
149
121
  }
150
122
  }
151
-
152
123
  if ((0, _utils.isObjectSchema)(shape.schema)) {
153
124
  Object.assign(allProps, shape.schema.properties);
154
125
  }
155
126
  }
156
-
157
127
  return conflicts;
158
128
  }
159
-
160
129
  function getFieldTypeComparison(fieldType) {
161
130
  const comparison = fieldTypeComparison[fieldType];
162
-
163
131
  if (!comparison) {
164
132
  return undefined;
165
133
  }
166
-
167
134
  const {
168
135
  comparators,
169
136
  type
170
137
  } = comparison;
171
138
  const result = {};
172
-
173
139
  for (const op of comparators) {
174
140
  const description = comparatorDescriptions[op];
175
141
  result[op] = op === 'in' ? {
@@ -183,73 +149,57 @@ function getFieldTypeComparison(fieldType) {
183
149
  type
184
150
  };
185
151
  }
186
-
187
152
  return result;
188
153
  }
189
-
190
154
  function isId(name) {
191
155
  return name === '_id' || name === '_contentTypeId' || name === '_shapeId';
192
156
  }
193
-
194
157
  function isNonRelationshipRef(prop) {
195
158
  return Boolean((0, _refs.hasRefProperty)(prop) && !(0, _relationships.getRelationship)(prop));
196
159
  }
197
-
198
160
  function getPropType(projectSchema, name, prop) {
199
161
  if (prop['@workflow']) {
200
162
  return 'workflow';
201
163
  }
202
-
203
164
  if (prop['@tag'] === 'draftjs') {
204
165
  return 'draftjs';
205
166
  }
206
-
207
167
  if (prop['@tag'] === 'mdx') {
208
168
  return 'mdx';
209
169
  }
210
-
211
170
  if (prop.format === 'date-time') {
212
171
  return 'date';
213
172
  }
214
-
215
173
  if (isId(name)) {
216
174
  return 'id';
217
175
  }
218
-
219
176
  if (isNonRelationshipRef(prop)) {
220
177
  const followed = (0, _refs.followRef)(projectSchema, prop);
221
-
222
178
  if (followed.enum) {
223
179
  return 'string';
224
180
  }
225
-
226
181
  return 'object';
227
182
  }
228
-
229
183
  return prop.type;
230
184
  }
231
-
232
185
  function truncateNames(names) {
233
186
  // For unions of many types hash the names this reduces shape name size while still allowing reuse
234
187
  return names.length > 80 ? (0, _blueimpMd.default)(names) : names;
235
188
  }
189
+
236
190
  /**
237
191
  * Get a formatted string of related shape names from a property schema with a
238
192
  * relationship resolver
239
193
  */
240
-
241
-
242
194
  function getRelationshipShapeName(refs) {
243
195
  return refs.map(ref => {
244
196
  const shapeName = ref.split(':')[1];
245
197
  return (0, _util.formatShapeName)(shapeName);
246
198
  }).sort().join('');
247
199
  }
248
-
249
200
  function joinShapeNames(shapes) {
250
201
  return shapes.sort().join('');
251
202
  }
252
-
253
203
  function getTypeName(name, prop, shapeName, context) {
254
204
  const {
255
205
  projectSchema,
@@ -257,34 +207,26 @@ function getTypeName(name, prop, shapeName, context) {
257
207
  conflictingProperties
258
208
  } = context;
259
209
  let type = getPropType(projectSchema, name, prop);
260
-
261
210
  if (isId(name)) {
262
211
  return `TSWhereID`;
263
212
  }
264
-
265
213
  const relationship = (0, _relationships.getRelationship)(prop);
266
-
267
214
  if (relationship) {
268
215
  const relationshipName = getRelationshipShapeName(relationship.refs);
269
-
270
216
  if (!relationshipName) {
271
217
  throw new Error(`Relationship property "${prop.title ?? ''}" is missing related shapes`);
272
218
  }
273
-
274
219
  const shapeNames = truncateNames(relationshipName);
275
220
  return `TSWhere${shapeNames}Relationship`;
276
221
  }
277
-
278
222
  if ((0, _unions.isUnionSchema)(prop)) {
279
223
  if (prop.oneOf.length > 1) {
280
224
  const shapeNames = truncateNames(joinShapeNames((0, _unions.enumerateOneOfKeys)(projectSchema, prop.oneOf).map(child => child.shapeName)));
281
225
  return `TSWhere${shapeNames}Union`;
282
226
  }
283
-
284
227
  type = 'object';
285
228
  prop = prop.oneOf[0];
286
229
  }
287
-
288
230
  if (type === 'object' || type === 'array') {
289
231
  const prefix = `TS${relationshipDepth >= MAX_RELATIONSHIP_DEPTH ? 'Shallow' : ''}Where`;
290
232
  const fieldName = `${conflictingProperties !== null && conflictingProperties !== void 0 && conflictingProperties.has(name) ? '_' : ''}${(0, _util.formatShapeName)(name)}`;
@@ -292,10 +234,8 @@ function getTypeName(name, prop, shapeName, context) {
292
234
  const suffix = refItem ? (0, _refs.refItemToShapeName)(refItem) : `${shapeName}${fieldName}`;
293
235
  return `${prefix}${suffix}`;
294
236
  }
295
-
296
237
  return `TSWhere${(0, _util.pascalCase)(type)}`;
297
238
  }
298
-
299
239
  function skipField({
300
240
  name,
301
241
  prop,
@@ -306,7 +246,6 @@ function skipField({
306
246
  const isRelationship = (0, _utils.isPropertySchemaWithRelationship)(prop);
307
247
  return Boolean(prop['@sensitive'] || prop['@resolver'] && !isIndexedShape && !isRelationship || isRelationship && exceededRelationshipDepth || (name === '_enabled' || name === '_enabledAt') && workflowsEnabled);
308
248
  }
309
-
310
249
  function getFields(typeName, shapes, context) {
311
250
  const {
312
251
  relationshipDepth,
@@ -316,10 +255,10 @@ function getFields(typeName, shapes, context) {
316
255
  const result = {};
317
256
  const tooDeep = exceededRelationshipDepth(relationshipDepth);
318
257
  const conflictingProperties = shapes.length ? getConflictingProperties(projectSchema, shapes) : undefined;
319
- const fieldContext = { ...context,
258
+ const fieldContext = {
259
+ ...context,
320
260
  conflictingProperties
321
261
  };
322
-
323
262
  for (const shape of shapes) {
324
263
  const nodes = (0, _schemaUtil.createSchemaPropertyList)(projectSchema, shape).filterBy(([name, prop]) => !skipField({
325
264
  name,
@@ -328,18 +267,14 @@ function getFields(typeName, shapes, context) {
328
267
  isIndexedShape: (0, _schemaUtil.isCachedShape)(shape),
329
268
  exceededRelationshipDepth: exceededRelationshipDepth(relationshipDepth)
330
269
  })).getNodes();
331
-
332
270
  for (const [name, property] of nodes) {
333
271
  Object.assign(result, getPropertyComparisonType(name, property, shape.name, fieldContext));
334
272
  }
335
273
  }
336
-
337
274
  return tooDeep || booleanOperators === false ? result : Object.assign(result, getBooleanOperatorTypes(typeName));
338
275
  }
339
-
340
276
  function getBooleanOperatorTypes(typeName) {
341
277
  const result = {};
342
-
343
278
  for (const op of booleanOperators) {
344
279
  const refSchema = {
345
280
  '@ref': `local:${typeName}`
@@ -349,10 +284,8 @@ function getBooleanOperatorTypes(typeName) {
349
284
  items: refSchema
350
285
  };
351
286
  }
352
-
353
287
  return result;
354
288
  }
355
-
356
289
  function getPropertyComparisonType(name, prop, shapeName, context) {
357
290
  const {
358
291
  shapeCache,
@@ -360,7 +293,6 @@ function getPropertyComparisonType(name, prop, shapeName, context) {
360
293
  relationshipDepth,
361
294
  conflictingProperties
362
295
  } = context;
363
-
364
296
  if (skipField({
365
297
  name,
366
298
  prop,
@@ -370,54 +302,49 @@ function getPropertyComparisonType(name, prop, shapeName, context) {
370
302
  })) {
371
303
  return undefined;
372
304
  }
373
-
374
305
  const fieldType = getPropType(projectSchema, name, prop) ?? 'string';
375
306
  const typeName = getTypeName(name, prop, shapeName, context);
376
307
  const relationship = (0, _relationships.getRelationship)(prop);
377
-
378
308
  if ((0, _refs.hasRefProperty)(prop.items ?? prop)) {
379
309
  if (!(0, _refs.hasResolvableRef)(projectSchema, prop.items ?? prop)) {
380
310
  return undefined;
381
311
  }
382
-
383
312
  if (prop.items) {
384
- prop = { ...prop,
313
+ prop = {
314
+ ...prop,
385
315
  items: (0, _refs.followRef)(projectSchema, prop.items)
386
316
  };
387
317
  } else {
388
318
  prop = (0, _refs.followRef)(projectSchema, prop);
389
319
  }
390
320
  }
391
-
392
321
  if (!shapeCache.has(typeName) && !projectSchema.shapes[typeName]) {
393
322
  shapeCache.set(typeName, () => {
394
323
  var _prop$items;
395
-
396
324
  let props;
397
325
  const propOrItems = prop.items ?? prop;
398
-
399
326
  if (isId(name)) {
400
327
  props = getFieldTypeComparison('id');
401
328
  } else if (relationship) {
402
329
  const shapes = (0, _relationships.getRelationshipShapes)(projectSchema.shapes, relationship.refs);
403
- props = getFields(typeName, shapes, { ...context,
330
+ props = getFields(typeName, shapes, {
331
+ ...context,
404
332
  relationshipDepth: relationshipDepth + 1
405
333
  });
406
334
  } else if ((0, _unions.isUnionSchema)(propOrItems)) {
407
335
  const shapes = (0, _unions.enumerateOneOfKeys)(projectSchema, propOrItems.oneOf).map(option => projectSchema.shapes[option.shapeName]);
408
- props = getFields(typeName, shapes, { ...context,
336
+ props = getFields(typeName, shapes, {
337
+ ...context,
409
338
  booleanOperators: false
410
339
  });
411
340
  } else if (fieldType === 'object' || fieldType === 'array' && ((_prop$items = prop.items) === null || _prop$items === void 0 ? void 0 : _prop$items.type) === 'object') {
412
341
  var _prop$items2;
413
-
414
342
  const properties = ((_prop$items2 = prop.items) === null || _prop$items2 === void 0 ? void 0 : _prop$items2.properties) ?? prop.properties;
415
-
416
343
  if (properties) {
417
344
  props = props ?? {};
418
- const fieldContext = { ...context,
345
+ const fieldContext = {
346
+ ...context,
419
347
  conflictingProperties: undefined // non-union objects have no conflicts
420
-
421
348
  };
422
349
 
423
350
  for (const propName of Object.keys(properties)) {
@@ -426,26 +353,21 @@ function getPropertyComparisonType(name, prop, shapeName, context) {
426
353
  }
427
354
  } else {
428
355
  var _prop$items3;
429
-
430
356
  // Treat non-object arrays as their base type
431
357
  let type;
432
-
433
358
  if (typeof ((_prop$items3 = prop.items) === null || _prop$items3 === void 0 ? void 0 : _prop$items3.type) === 'string') {
434
359
  type = prop.items.type;
435
360
  } else {
436
361
  type = fieldType;
437
362
  }
438
-
439
363
  props = getFieldTypeComparison(type);
440
364
  }
441
-
442
365
  return (0, _schemaUtil.createShape)(typeName, {
443
366
  type: 'object',
444
367
  properties: props ?? {}
445
368
  });
446
369
  });
447
370
  }
448
-
449
371
  if (shapeCache.has(typeName) || projectSchema.shapes[typeName]) {
450
372
  const fieldName = `${conflictingProperties !== null && conflictingProperties !== void 0 && conflictingProperties.has(name) ? `${shapeName}_` : ''}${name}`;
451
373
  return {
@@ -455,85 +377,67 @@ function getPropertyComparisonType(name, prop, shapeName, context) {
455
377
  };
456
378
  }
457
379
  }
458
-
459
380
  function findEmpty(shapes) {
460
381
  const empty = new Set();
461
-
462
382
  for (const [shapeName, shape] of Object.entries(shapes)) {
463
383
  if ((0, _utils.isObjectSchema)(shape.schema) && Object.keys(shape.schema.properties).length === 0) {
464
384
  empty.add(shapeName);
465
385
  }
466
386
  }
467
-
468
387
  return empty;
469
388
  }
470
-
471
389
  function getRefSummary(shapes) {
472
390
  const result = {};
473
-
474
391
  for (const ref of (0, _schemaUtil.getAllRefsInShapes)({
475
392
  shapes,
476
393
  services: {}
477
394
  })) {
478
395
  const path = ref.path.slice(1, ref.path.length - 1);
479
-
480
396
  if (result[ref.typeName]) {
481
397
  result[ref.typeName].push(path);
482
398
  } else {
483
399
  result[ref.typeName] = [path];
484
400
  }
485
401
  }
486
-
487
402
  return result;
488
403
  }
489
-
490
404
  function pruneEmpty(shapes) {
491
405
  let toPrune = findEmpty(shapes);
492
-
493
406
  if (toPrune.size) {
494
407
  const refSummary = getRefSummary(shapes);
495
-
496
408
  while (toPrune.size) {
497
409
  for (const shapeName of toPrune) {
498
410
  (0, _unset.default)(shapes, shapeName);
499
-
500
411
  for (const path of refSummary[shapeName] ?? []) {
501
412
  (0, _unset.default)(shapes, path);
502
413
  }
503
414
  }
504
-
505
415
  toPrune = findEmpty(shapes);
506
416
  }
507
417
  }
508
-
509
418
  return shapes;
510
419
  }
511
-
512
420
  function getReferencedShape(context) {
513
421
  return prop => {
514
422
  const ref = (0, _refs.getRef)(context, prop);
515
423
  return ref && (0, _refs.refItemToShape)(context, ref);
516
424
  };
517
425
  }
426
+
518
427
  /**
519
428
  * Expand union shapes
520
429
  */
521
-
522
-
523
430
  function expandUnionShapes(projectSchema, shapes) {
524
431
  return (0, _uniqBy.default)(shapes.flatMap(shape => (0, _unions.isUnionSchema)(shape.schema) ? shape.schema.oneOf.map(getReferencedShape(projectSchema)).filter(_util.isDefined) : shape), 'name');
525
432
  }
526
-
527
433
  function getWhereShape(projectSchema, selectedShapes) {
528
434
  const shapeName = selectedShapes.length === 1 ? `TSWhere${(0, _util.pascalCase)(selectedShapes[0].name)}Input` : 'TSWhereInput';
529
-
530
435
  if (projectSchema.shapes[shapeName]) {
531
436
  return {
532
437
  shapeName,
533
438
  dependencies: {}
534
439
  };
535
440
  }
536
-
537
441
  const expandedShapes = expandUnionShapes(projectSchema, selectedShapes);
538
442
  const isManyContentTypes = expandedShapes.length > 1;
539
443
  const shapeCache = new ShapeCache();
@@ -547,7 +451,8 @@ function getWhereShape(projectSchema, selectedShapes) {
547
451
  dependencies: pruneEmpty({
548
452
  [shapeName]: (0, _schemaUtil.createShape)(shapeName, {
549
453
  type: 'object',
550
- properties: { ...fields,
454
+ properties: {
455
+ ...fields,
551
456
  ...(isManyContentTypes && getBooleanOperatorTypes(shapeName))
552
457
  }
553
458
  }),
@@ -555,7 +460,6 @@ function getWhereShape(projectSchema, selectedShapes) {
555
460
  })
556
461
  };
557
462
  }
558
-
559
463
  function getWhereSearchArg(projectSchema, selectedShapes) {
560
464
  const {
561
465
  shapeName,
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _types = require("./types");
8
-
9
7
  Object.keys(_types).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _types[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_types).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _utils = require("./utils");
21
-
22
18
  Object.keys(_utils).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _utils[key]) return;
@@ -7,30 +7,58 @@ exports.projectSchemaImportOptionalProps = exports.legacyProjectSchemaImportOpti
7
7
  const projectSchemaImportOptionalProps = ['projectId', 'locales', 'defaultLocale', 'author'];
8
8
  exports.projectSchemaImportOptionalProps = projectSchemaImportOptionalProps;
9
9
  const legacyProjectSchemaImportOptionalProps = ['created', 'updated', 'version', 'dataKey'];
10
- exports.legacyProjectSchemaImportOptionalProps = legacyProjectSchemaImportOptionalProps;
11
10
 
12
11
  /**
13
- * Types of refs
12
+ * Remote service configuration types
14
13
  */
15
- let RefType;
14
+
16
15
  /**
17
- * Stub of a PropertySchema that may contain a `$ref` or `@ref`.
16
+ * Old service authentication
17
+ * @deprecated
18
18
  */
19
19
 
20
- exports.RefType = RefType;
20
+ /**
21
+ * Support null sentinels for authentication
22
+ */
21
23
 
22
- (function (RefType) {
24
+ /**
25
+ * A type suitable for service object updates, mostly concerns authentication
26
+ * requirements.
27
+ */
28
+ exports.legacyProjectSchemaImportOptionalProps = legacyProjectSchemaImportOptionalProps;
29
+ /**
30
+ * Types of refs
31
+ */
32
+ let RefType = /*#__PURE__*/function (RefType) {
23
33
  RefType["@ref"] = "@ref";
24
34
  RefType["$ref"] = "$ref";
25
- })(RefType || (exports.RefType = RefType = {}));
26
-
35
+ return RefType;
36
+ }({});
37
+ /**
38
+ * Stub of a PropertySchema that may contain a `$ref` or `@ref`.
39
+ */
40
+ exports.RefType = RefType;
27
41
  /**
28
42
  * Types of args
29
43
  */
30
- let ArgsType;
31
- exports.ArgsType = ArgsType;
32
-
33
- (function (ArgsType) {
44
+ let ArgsType = /*#__PURE__*/function (ArgsType) {
34
45
  ArgsType["@args"] = "@args";
35
46
  ArgsType["args"] = "args";
36
- })(ArgsType || (exports.ArgsType = ArgsType = {}));
47
+ return ArgsType;
48
+ }({});
49
+ /**
50
+ * Types supporting schema iterators
51
+ */
52
+ /**
53
+ * Shapes
54
+ */
55
+ /**
56
+ * Relationships
57
+ */
58
+ /**
59
+ * New relationship data, drawn from a PropertySchema.
60
+ */
61
+ /**
62
+ * The old relationship format, used in client UI.
63
+ */
64
+ exports.ArgsType = ArgsType;