@takeshape/schema 9.80.3 → 9.81.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 (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
@@ -20,20 +20,22 @@ exports.refExpressionToShape = refExpressionToShape;
20
20
  exports.refItemToShape = refItemToShape;
21
21
  exports.refItemToString = refItemToString;
22
22
  exports.splitAtRef = splitAtRef;
23
-
24
23
  var _typeUtils = require("./type-utils");
25
-
26
24
  var _refs = require("../refs");
27
-
28
25
  var _assign = _interopRequireDefault(require("lodash/fp/assign"));
29
-
30
26
  var _omit = _interopRequireDefault(require("lodash/fp/omit"));
31
-
32
27
  var _util = require("@takeshape/util");
33
-
34
28
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
35
-
36
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
+ /**
31
+ * This interface describes a parsed `@ref` or `$ref`.
32
+ * The intended usage is to convert a schema with a ref to a RefItem which can then
33
+ * be passed to the various rich utilities in this file.
34
+ */
35
+
36
+ /**
37
+ * Adds a schema path, needed when visiting a whole schema to report errors.
38
+ */
37
39
 
38
40
  /**
39
41
  * Safely turn a "template" shape reference (`@args`, `args`, `shape`) into a `RefItem`
@@ -50,6 +52,7 @@ function refExpressionToRefItem(refExpression) {
50
52
  } = (0, _refs.parseTemplateShape)(refExpression);
51
53
  return atRefToRefItem(shapeName, template);
52
54
  }
55
+
53
56
  /**
54
57
  * Sugar for converting a `refExpression` directly into a shape, without the
55
58
  * intermediate `refItem`.
@@ -59,11 +62,10 @@ function refExpressionToRefItem(refExpression) {
59
62
  * A ref expression might include "template" name and refer to a local or remote
60
63
  * shape, `Foo` or `CreateArgs<Foo>` or `CreateArgs<remote:Foo>`.
61
64
  */
62
-
63
-
64
65
  function refExpressionToShape(shapes, refExpression) {
65
66
  return refItemToShape(shapes, refExpressionToRefItem(refExpression));
66
67
  }
68
+
67
69
  /**
68
70
  * Provided a service name and a referenced type. Supports 2 or 3 part
69
71
  * references, e.g., `shopify:my-store:ProductInput` or `my-store:ProductInput`.
@@ -71,27 +73,21 @@ function refExpressionToShape(shapes, refExpression) {
71
73
  * @returns
72
74
  * A 2 member array, where 0 is the service name, 1 is the referenced type.
73
75
  */
74
-
75
-
76
76
  function splitAtRef(atRef) {
77
77
  const refParts = atRef.split(':');
78
-
79
78
  if (refParts.length === 1) {
80
79
  return ['local', atRef];
81
80
  }
82
-
83
81
  if (refParts.length === 2) {
84
82
  return [refParts[0], refParts[1]];
85
83
  }
86
-
87
84
  throw new Error(`Invalid ref string ${atRef}`);
88
85
  }
86
+
89
87
  /**
90
88
  * Parses and returns a typeName, serviceKey, and potentially a namespace for
91
89
  * the type.
92
90
  */
93
-
94
-
95
91
  function atRefToRefItem(atRef, template) {
96
92
  const [serviceKey, typeName] = splitAtRef(atRef);
97
93
  return {
@@ -100,159 +96,133 @@ function atRefToRefItem(atRef, template) {
100
96
  template
101
97
  };
102
98
  }
99
+
103
100
  /**
104
101
  * Given a content schema and project schema, finds a `@ref` or `$ref` and
105
102
  * returns a `RefItem` suitable for loading a referenced schema...
106
103
  */
107
-
108
-
109
104
  function getRef(refSchema) {
110
105
  if (refSchema['@ref']) {
111
106
  // @ref: my-service:ShapeName
112
107
  return atRefToRefItem(refSchema['@ref']);
113
108
  }
114
109
  }
115
-
116
110
  function getRefWithPath(refSchema, schemaPath = []) {
117
111
  const refItem = getRef(refSchema);
118
-
119
112
  if (refItem) {
120
- return { ...refItem,
113
+ return {
114
+ ...refItem,
121
115
  path: schemaPath.concat(['@ref'])
122
116
  };
123
117
  }
124
118
  }
119
+
125
120
  /**
126
121
  * Tests for a `@ref` or `$ref` property directly on the passed schema.
127
122
  *
128
123
  * @param schema Any schema that might could have a ref property.
129
124
  */
130
-
131
-
132
125
  function hasRefProperty(schema) {
133
126
  return Boolean(schema['@ref'] ?? schema.$ref);
134
127
  }
128
+
135
129
  /**
136
130
  * From a schema with a ref, will return the top-level ref, and potentially
137
131
  * a ref item from a nested `items` property.
138
132
  */
139
-
140
-
141
133
  function getRefOrItemsRef(refSchema, schemaPath = []) {
142
134
  const refItem = getRefWithPath(refSchema, schemaPath);
143
-
144
135
  if (refItem) {
145
136
  return refItem;
146
137
  }
147
-
148
138
  if (refSchema.items) {
149
139
  return getRefOrItemsRef(refSchema.items, schemaPath.concat(['items']));
150
140
  }
151
141
  }
142
+
152
143
  /**
153
144
  * Turns a `RefItem` into an `@ref`.
154
145
  */
155
-
156
-
157
146
  function refItemToString(refItem) {
158
147
  return `${refItem.layerId}:${refItem.typeName}`;
159
148
  }
149
+
160
150
  /**
161
151
  * Get a Shape referenced by a `RefItem`.
162
152
  */
163
-
164
-
165
153
  function refItemToShape(shapes, refItem) {
166
154
  return shapes[refItemToString(refItem)];
167
155
  }
156
+
168
157
  /**
169
158
  * Helper fn to omit `ref` props from the target schema, and then extend it with the source schema.
170
159
  */
171
-
172
-
173
160
  const omitRefAndExtend = (targetSchema, sourceSchema) => (0, _assign.default)((0, _omit.default)(['@ref', '$ref'], targetSchema), sourceSchema);
161
+
174
162
  /**
175
163
  * If there is a $ref, this will insert a content schema from the top level
176
164
  * in place of the reference.
177
165
  */
178
-
179
-
180
166
  exports.omitRefAndExtend = omitRefAndExtend;
181
-
182
167
  function followRef(shapes, contentSchema) {
183
168
  const refItem = getRef(contentSchema);
184
-
185
169
  if (refItem) {
186
170
  var _refItemToShape;
187
-
188
171
  const referencedSchema = (_refItemToShape = refItemToShape(shapes, refItem)) === null || _refItemToShape === void 0 ? void 0 : _refItemToShape.schema;
189
-
190
172
  if (referencedSchema) {
191
173
  return omitRefAndExtend(contentSchema, referencedSchema);
192
174
  }
193
175
  }
194
-
195
176
  return contentSchema;
196
177
  }
178
+
197
179
  /**
198
180
  * Returns whether a schema has refs.
199
181
  */
200
-
201
-
202
182
  function hasRef(contentSchema) {
203
183
  if ((0, _typeUtils.isRefSchema)(contentSchema)) {
204
184
  return true;
205
185
  }
206
-
207
186
  if ((0, _typeUtils.isAllOfSchema)(contentSchema)) {
208
187
  return Boolean(contentSchema.allOf.find(hasRef));
209
188
  }
210
-
211
189
  if ((0, _typeUtils.isOneOfSchema)(contentSchema)) {
212
190
  return Boolean(contentSchema.oneOf.find(hasRef));
213
191
  }
214
-
215
192
  return false;
216
193
  }
194
+
217
195
  /**
218
196
  * Returns whether a schema has refs which can be followed.
219
197
  */
220
-
221
-
222
198
  function hasResolvableRef(shapes, contentSchema) {
223
199
  if ((0, _typeUtils.isRefSchema)(contentSchema)) {
224
200
  return Boolean(refItemToShape(shapes, getRef(contentSchema)));
225
201
  }
226
-
227
202
  if ((0, _typeUtils.isAllOfSchema)(contentSchema)) {
228
203
  return Boolean(contentSchema.allOf.find(s => hasResolvableRef(shapes, s)));
229
204
  }
230
-
231
205
  if ((0, _typeUtils.isOneOfSchema)(contentSchema)) {
232
206
  return Boolean(contentSchema.oneOf.find(s => hasResolvableRef(shapes, s)));
233
207
  }
234
-
235
208
  return false;
236
209
  }
237
-
238
210
  function getArgsReferenceWithPath(argsSchema, schemaPath = []) {
239
211
  const isQuery = ('args' in argsSchema);
240
212
  const args = isQuery ? argsSchema.args : argsSchema['@args'];
241
213
  const refItem = typeof args === 'string' ? refExpressionToRefItem(args) : undefined;
242
-
243
214
  if (refItem) {
244
- return { ...refItem,
215
+ return {
216
+ ...refItem,
245
217
  path: schemaPath.concat([isQuery ? 'args' : '@args'])
246
218
  };
247
219
  }
248
220
  }
221
+
249
222
  /*
250
223
  * Helper fn to omit `allOf` props from the target schema, and then extend it with the source schema.
251
224
  */
252
-
253
-
254
225
  const omitAllOfAndExtend = (targetSchema, sourceSchema) => (0, _assign.default)((0, _omit.default)(['allOf'], targetSchema), sourceSchema);
255
-
256
226
  function dereferenceSchema(shapes, shapeOrFieldSchema, schemaPath = []) {
257
227
  const resolveAll = (resolveSchema, resolvePath) => {
258
228
  try {
@@ -260,58 +230,45 @@ function dereferenceSchema(shapes, shapeOrFieldSchema, schemaPath = []) {
260
230
  const allOfSchema = resolveSchema.allOf.map((stub, index) => resolveAll(stub, [...resolvePath, 'allOf', index])).reduce((prev, curr) => (0, _util.mergeWithArrayConcat)(prev, curr), {});
261
231
  return (0, _isEmpty.default)(allOfSchema) ? undefined : omitAllOfAndExtend(resolveSchema, allOfSchema);
262
232
  }
263
-
264
233
  if ((0, _typeUtils.isRefSchema)(resolveSchema)) {
265
234
  const refItem = getRefWithPath(resolveSchema);
266
-
267
235
  if (!refItem) {
268
236
  throw new Error('ref could not be parsed');
269
237
  }
270
-
271
238
  const refSchema = refItemToShape(shapes, refItem);
272
-
273
239
  if (refSchema) {
274
240
  return resolveAll(omitRefAndExtend(resolveSchema, refSchema), refItem.path);
275
241
  }
276
-
277
242
  return;
278
243
  }
279
-
280
244
  return resolveSchema;
281
245
  } catch (err) {
282
246
  throw new Error(`error at '${resolvePath.join('.')}', ${err.message}`);
283
247
  }
284
248
  };
285
-
286
249
  return resolveAll(shapeOrFieldSchema, schemaPath) ?? shapeOrFieldSchema;
287
250
  }
288
-
289
251
  function parseReturnShape(shape) {
290
252
  if (typeof shape === 'object') {
291
253
  if ((0, _typeUtils.isRefSchema)(shape.items)) {
292
254
  const ref = getRef(shape.items);
293
-
294
255
  if (!ref) {
295
256
  throw new Error(`Could not parse ${JSON.stringify(shape.items)}: invalid ref`);
296
257
  }
297
-
298
258
  return {
299
259
  isArray: true,
300
260
  ref,
301
261
  shapeName: refItemToString(ref)
302
262
  };
303
263
  }
304
-
305
264
  if (typeof shape.items.type !== 'string') {
306
265
  throw new Error(`Could not parse ${JSON.stringify(shape.items)}: invalid type`);
307
266
  }
308
-
309
267
  return {
310
268
  isArray: true,
311
269
  shapeName: shape.items.type
312
270
  };
313
271
  }
314
-
315
272
  const ref = refExpressionToRefItem(shape);
316
273
  const shapeName = refItemToString(ref);
317
274
  return {
@@ -25,19 +25,12 @@ exports.isRefSchema = isRefSchema;
25
25
  exports.isRestResolver = isRestResolver;
26
26
  exports.isTakeshapeResolver = isTakeshapeResolver;
27
27
  exports.isUtilResolver = isUtilResolver;
28
-
29
28
  var _util = require("@takeshape/util");
30
-
31
29
  var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
32
-
33
30
  var _isString = _interopRequireDefault(require("lodash/isString"));
34
-
35
31
  var _isArray = _interopRequireDefault(require("lodash/isArray"));
36
-
37
32
  var _schemas = require("../schemas");
38
-
39
33
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
-
41
34
  /** Resolver Type Utils **/
42
35
 
43
36
  /**
@@ -46,11 +39,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
46
39
  function isBasicResolver(resolver) {
47
40
  return (0, _isString.default)(resolver === null || resolver === void 0 ? void 0 : resolver.name) && (0, _isString.default)(resolver.service);
48
41
  }
49
-
50
42
  function isComposeResolver(resolver) {
51
43
  return Boolean((0, _isArray.default)(resolver === null || resolver === void 0 ? void 0 : resolver.compose) && resolver.compose.length && resolver.compose.every(isBasicResolver));
52
44
  }
53
-
54
45
  const {
55
46
  definitions: {
56
47
  takeshapeResolver,
@@ -60,139 +51,116 @@ const {
60
51
  awsLambdaResolver
61
52
  }
62
53
  } = _schemas.latestSchemaJson;
63
-
64
54
  function isTakeshapeResolver(resolver) {
65
55
  return takeshapeResolver.properties.name.enum.includes(resolver.name);
66
56
  }
67
-
68
57
  function isGraphqlResolver(resolver) {
69
58
  return graphqlResolver.properties.name.enum.includes(resolver.name);
70
59
  }
71
-
72
60
  function isRestResolver(resolver) {
73
61
  return restResolver.properties.name.enum.includes(resolver.name);
74
62
  }
75
-
76
63
  function isAwsLambdaResolver(resolver) {
77
64
  return awsLambdaResolver.properties.name.enum.includes(resolver.name);
78
65
  }
79
-
80
66
  function isUtilResolver(resolver) {
81
67
  return utilResolver.properties.name.enum.includes(resolver.name);
82
68
  }
69
+
83
70
  /** Directive Mapping Utils **/
84
71
 
85
72
  /**
86
73
  * Determine whether the ambiguous Directive structure is a DirectiveMappingMap
87
74
  */
88
-
89
-
90
75
  function isDirectiveMappingMap(maybeMap) {
91
76
  return (0, _isPlainObject.default)(maybeMap) && Object.keys(maybeMap).length > 0;
92
77
  }
78
+
93
79
  /**
94
80
  * Determine whether the ambiguous Directive structure is a DirectiveMappingArray
95
81
  */
96
-
97
-
98
82
  function isDirectiveMappingArray(maybeArray) {
99
83
  return (0, _isArray.default)(maybeArray) && (0, _isArray.default)(maybeArray[0]) && (0, _isString.default)(maybeArray[0][0]) && (0, _isArray.default)(maybeArray[0][1]);
100
84
  }
85
+
101
86
  /**
102
87
  * Determine whether the ambiguous Directive structure is a DirectiveConfig array
103
88
  */
104
-
105
-
106
89
  function isDirectiveConfig(maybeConfig) {
107
90
  return (0, _isArray.default)(maybeConfig) && (0, _isArray.default)(maybeConfig[0]) && (0, _isString.default)(maybeConfig[0][0]) && (0, _util.isRecord)(maybeConfig[0][1]);
108
91
  }
92
+
109
93
  /**
110
94
  * Determine whether a ParameterSerializeOption is a content type serializer
111
95
  */
112
-
113
-
114
96
  function isParameterSerializeContentOptions(maybeContent) {
115
97
  return Boolean('contentType' in maybeContent && maybeContent.contentType);
116
98
  }
99
+
117
100
  /**
118
101
  * Determine whether an unknown variable is a `ParameterOp`
119
102
  */
120
-
121
-
122
103
  function isParameterOp(maybeOp) {
123
104
  const op = maybeOp;
124
-
125
105
  if (!op.path) {
126
106
  return false;
127
107
  }
128
-
129
108
  return isParameterOpNested(op) || isParameterOpMapping(op) || isParameterOpValue(op) || isParameterOpOp(op);
130
109
  }
110
+
131
111
  /**
132
112
  * Determine whether a `ParameterOp` is a `ParameterOpNested`
133
113
  */
134
-
135
-
136
114
  function isParameterOpNested(maybeOp) {
137
115
  return Boolean('ops' in maybeOp && maybeOp.ops);
138
116
  }
117
+
139
118
  /**
140
119
  * Determine whether a `ParameterOp` is a `ParameterOpMapping`
141
120
  */
142
-
143
-
144
121
  function isParameterOpMapping(maybeOp) {
145
122
  return Boolean('mapping' in maybeOp && maybeOp.mapping);
146
123
  }
124
+
147
125
  /**
148
126
  * Determine whether a `ParameterOp` is a `ParameterOpMapping`
149
127
  */
150
-
151
-
152
128
  function isParameterOpValue(maybeOp) {
153
129
  return Boolean('value' in maybeOp && maybeOp.value);
154
130
  }
131
+
155
132
  /**
156
133
  * Determine whether a `ParameterOp` is a `ParameterOpOp`
157
134
  */
158
-
159
-
160
135
  function isParameterOpOp(maybeOp) {
161
136
  const op = maybeOp;
162
-
163
137
  if (!op.op) {
164
138
  return false;
165
139
  }
166
-
167
140
  return !(isParameterOpNested(op) || isParameterOpMapping(op) || isParameterOpValue(op));
168
141
  }
142
+
169
143
  /**
170
144
  * Determine whether a ParameterSerializeOption is a style serializer
171
145
  */
172
-
173
-
174
146
  function isParameterSerializeStyleOptions(maybeStyle) {
175
147
  return Boolean('style' in maybeStyle && maybeStyle.style);
176
148
  }
177
- /** Typeguards for different types of shape schemas **/
178
149
 
150
+ /** Typeguards for different types of shape schemas **/
179
151
 
180
152
  function isRefSchema(maybeRefSchema) {
181
153
  return (0, _isString.default)(maybeRefSchema['@ref']) || (0, _isString.default)(maybeRefSchema.$ref);
182
154
  }
183
-
184
155
  function isAllOfSchema(schema) {
185
156
  return (0, _isArray.default)(schema.allOf);
186
157
  }
187
-
188
158
  function isOneOfSchema(schema) {
189
159
  return (0, _isArray.default)(schema.oneOf);
190
160
  }
191
-
192
161
  function isArraySchema(schema) {
193
162
  return schema.type === 'array' && (0, _util.isRecord)(schema.items);
194
163
  }
195
-
196
164
  function isObjectSchema(schema) {
197
165
  return schema.type === 'object' && (0, _util.isRecord)(schema.properties);
198
166
  }
@@ -5,15 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.visitSchemaProperties = visitSchemaProperties;
7
7
  exports.visitShapeProperties = visitShapeProperties;
8
-
9
8
  var _typeUtils = require("./type-utils");
10
-
11
9
  function visitSchemaProperties(schema, path, callback) {
12
10
  if ((0, _typeUtils.isObjectSchema)(schema)) {
13
11
  for (const [name, propSchema] of Object.entries(schema.properties)) {
14
12
  const newPath = [...path, 'properties', name];
15
13
  callback(propSchema, newPath);
16
-
17
14
  if ((0, _typeUtils.isObjectSchema)(propSchema) || (0, _typeUtils.isAllOfSchema)(propSchema) || (0, _typeUtils.isOneOfSchema)(propSchema)) {
18
15
  visitSchemaProperties(propSchema, newPath, callback);
19
16
  }
@@ -22,7 +19,6 @@ function visitSchemaProperties(schema, path, callback) {
22
19
  for (const [index, propSchema] of Object.entries(schema.allOf)) {
23
20
  const newPath = [...path, 'allOf', index];
24
21
  callback(propSchema, newPath);
25
-
26
22
  if ((0, _typeUtils.isObjectSchema)(propSchema) || (0, _typeUtils.isAllOfSchema)(propSchema) || (0, _typeUtils.isOneOfSchema)(propSchema)) {
27
23
  visitSchemaProperties(propSchema, newPath, callback);
28
24
  }
@@ -31,7 +27,6 @@ function visitSchemaProperties(schema, path, callback) {
31
27
  for (const [index, propSchema] of Object.entries(schema.oneOf)) {
32
28
  const newPath = [...path, 'oneOf', index];
33
29
  callback(propSchema, newPath);
34
-
35
30
  if ((0, _typeUtils.isObjectSchema)(propSchema) || (0, _typeUtils.isAllOfSchema)(propSchema) || (0, _typeUtils.isOneOfSchema)(propSchema)) {
36
31
  visitSchemaProperties(propSchema, newPath, callback);
37
32
  }
@@ -40,7 +35,6 @@ function visitSchemaProperties(schema, path, callback) {
40
35
  callback(schema, path);
41
36
  }
42
37
  }
43
-
44
38
  function visitShapeProperties(shapes, callback) {
45
39
  for (const [shapeName, shape] of Object.entries(shapes)) {
46
40
  visitSchemaProperties(shape.schema, ['shapes', shapeName, 'schema'], callback);
@@ -8,103 +8,54 @@ var _exportNames = {
8
8
  listTypePrefix: true
9
9
  };
10
10
  exports.migrateTo = exports.listTypePrefix = void 0;
11
-
12
11
  var _v = _interopRequireDefault(require("./to/v3.0.0"));
13
-
14
12
  var _v2 = _interopRequireDefault(require("./to/v3.1.0"));
15
-
16
13
  var _v3 = _interopRequireDefault(require("./to/v3.2.0"));
17
-
18
14
  var _v4 = _interopRequireDefault(require("./to/v3.3.0"));
19
-
20
15
  var _v5 = _interopRequireDefault(require("./to/v3.4.0"));
21
-
22
16
  var _v6 = _interopRequireDefault(require("./to/v3.5.0"));
23
-
24
17
  var _v7 = _interopRequireDefault(require("./to/v3.5.1"));
25
-
26
18
  var _v8 = _interopRequireDefault(require("./to/v3.6.0"));
27
-
28
19
  var _v9 = _interopRequireDefault(require("./to/v3.7.0"));
29
-
30
20
  var _v10 = _interopRequireDefault(require("./to/v3.8.0"));
31
-
32
21
  var _v11 = _interopRequireDefault(require("./to/v3.9.0"));
33
-
34
22
  var _v12 = _interopRequireDefault(require("./to/v3.10.0"));
35
-
36
23
  var _v13 = _interopRequireDefault(require("./to/v3.11.0"));
37
-
38
24
  var _v14 = _interopRequireDefault(require("./to/v3.12.0"));
39
-
40
25
  var _v15 = _interopRequireDefault(require("./to/v3.12.1"));
41
-
42
26
  var _v16 = _interopRequireDefault(require("./to/v3.12.2"));
43
-
44
27
  var _v17 = _interopRequireDefault(require("./to/v3.12.3"));
45
-
46
28
  var _v18 = _interopRequireDefault(require("./to/v3.13.0"));
47
-
48
29
  var _v19 = _interopRequireDefault(require("./to/v3.14.0"));
49
-
50
30
  var _v20 = _interopRequireDefault(require("./to/v3.15.0"));
51
-
52
31
  var _v21 = _interopRequireDefault(require("./to/v3.16.0"));
53
-
54
32
  var _v22 = _interopRequireDefault(require("./to/v3.17.0"));
55
-
56
33
  var _v23 = _interopRequireDefault(require("./to/v3.17.1"));
57
-
58
34
  var _v24 = _interopRequireDefault(require("./to/v3.18.0"));
59
-
60
35
  var _v25 = _interopRequireDefault(require("./to/v3.18.1"));
61
-
62
36
  var _v26 = _interopRequireDefault(require("./to/v3.18.2"));
63
-
64
37
  var _v27 = _interopRequireDefault(require("./to/v3.19.0"));
65
-
66
38
  var _v28 = _interopRequireDefault(require("./to/v3.20.0"));
67
-
68
39
  var _v29 = _interopRequireDefault(require("./to/v3.21.0"));
69
-
70
40
  var _v30 = _interopRequireDefault(require("./to/v3.22.0"));
71
-
72
41
  var _v31 = _interopRequireDefault(require("./to/v3.23.0"));
73
-
74
42
  var _v32 = _interopRequireDefault(require("./to/v3.24.0"));
75
-
76
43
  var _v33 = _interopRequireDefault(require("./to/v3.25.0"));
77
-
78
44
  var _v34 = _interopRequireDefault(require("./to/v3.26.0"));
79
-
80
45
  var _v35 = _interopRequireDefault(require("./to/v3.27.0"));
81
-
82
46
  var _v36 = _interopRequireDefault(require("./to/v3.28.0"));
83
-
84
47
  var _v37 = _interopRequireDefault(require("./to/v3.29.0"));
85
-
86
48
  var _v38 = _interopRequireDefault(require("./to/v3.30.0"));
87
-
88
49
  var _v39 = _interopRequireDefault(require("./to/v3.31.0"));
89
-
90
50
  var _v40 = _interopRequireDefault(require("./to/v3.32.0"));
91
-
92
51
  var _v41 = _interopRequireDefault(require("./to/v3.33.0"));
93
-
94
52
  var _v42 = _interopRequireDefault(require("./to/v3.34.0"));
95
-
96
53
  var _v43 = _interopRequireDefault(require("./to/v3.35.0"));
97
-
98
54
  var _v44 = _interopRequireDefault(require("./to/v3.36.0"));
99
-
100
55
  var _v45 = _interopRequireDefault(require("./to/v3.37.0"));
101
-
102
56
  var _v46 = _interopRequireDefault(require("./to/v3.38.0"));
103
-
104
57
  var _v47 = _interopRequireDefault(require("./to/v3.39.0"));
105
-
106
58
  var _utils = require("./utils");
107
-
108
59
  Object.keys(_utils).forEach(function (key) {
109
60
  if (key === "default" || key === "__esModule") return;
110
61
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -116,9 +67,7 @@ Object.keys(_utils).forEach(function (key) {
116
67
  }
117
68
  });
118
69
  });
119
-
120
70
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
121
-
122
71
  const migrateTo = {
123
72
  'v3.0.0': _v.default,
124
73
  'v3.1.0': _v2.default,