@takeshape/schema 9.80.4 → 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
package/dist/index.js CHANGED
@@ -12,9 +12,7 @@ Object.defineProperty(exports, "builtInShapes", {
12
12
  return _builtinSchema.builtInShapes;
13
13
  }
14
14
  });
15
-
16
15
  var _contentSchemaTransform = require("./content-schema-transform");
17
-
18
16
  Object.keys(_contentSchemaTransform).forEach(function (key) {
19
17
  if (key === "default" || key === "__esModule") return;
20
18
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -26,9 +24,7 @@ Object.keys(_contentSchemaTransform).forEach(function (key) {
26
24
  }
27
25
  });
28
26
  });
29
-
30
27
  var _getIsLeaf = require("./get-is-leaf");
31
-
32
28
  Object.keys(_getIsLeaf).forEach(function (key) {
33
29
  if (key === "default" || key === "__esModule") return;
34
30
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -40,9 +36,7 @@ Object.keys(_getIsLeaf).forEach(function (key) {
40
36
  }
41
37
  });
42
38
  });
43
-
44
39
  var _projectSchema = require("./project-schema");
45
-
46
40
  Object.keys(_projectSchema).forEach(function (key) {
47
41
  if (key === "default" || key === "__esModule") return;
48
42
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -54,9 +48,7 @@ Object.keys(_projectSchema).forEach(function (key) {
54
48
  }
55
49
  });
56
50
  });
57
-
58
51
  var _migrate = require("./project-schema/migrate");
59
-
60
52
  Object.keys(_migrate).forEach(function (key) {
61
53
  if (key === "default" || key === "__esModule") return;
62
54
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -68,9 +60,7 @@ Object.keys(_migrate).forEach(function (key) {
68
60
  }
69
61
  });
70
62
  });
71
-
72
63
  var _schemaUtil = require("./schema-util");
73
-
74
64
  Object.keys(_schemaUtil).forEach(function (key) {
75
65
  if (key === "default" || key === "__esModule") return;
76
66
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -82,9 +72,7 @@ Object.keys(_schemaUtil).forEach(function (key) {
82
72
  }
83
73
  });
84
74
  });
85
-
86
75
  var _services = require("./services");
87
-
88
76
  Object.keys(_services).forEach(function (key) {
89
77
  if (key === "default" || key === "__esModule") return;
90
78
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -96,9 +84,7 @@ Object.keys(_services).forEach(function (key) {
96
84
  }
97
85
  });
98
86
  });
99
-
100
87
  var _templateShapes = require("./template-shapes");
101
-
102
88
  Object.keys(_templateShapes).forEach(function (key) {
103
89
  if (key === "default" || key === "__esModule") return;
104
90
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -110,9 +96,7 @@ Object.keys(_templateShapes).forEach(function (key) {
110
96
  }
111
97
  });
112
98
  });
113
-
114
99
  var _taxonomies = require("./taxonomies");
115
-
116
100
  Object.keys(_taxonomies).forEach(function (key) {
117
101
  if (key === "default" || key === "__esModule") return;
118
102
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -124,9 +108,7 @@ Object.keys(_taxonomies).forEach(function (key) {
124
108
  }
125
109
  });
126
110
  });
127
-
128
111
  var _workflows = require("./workflows");
129
-
130
112
  Object.keys(_workflows).forEach(function (key) {
131
113
  if (key === "default" || key === "__esModule") return;
132
114
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -138,9 +120,7 @@ Object.keys(_workflows).forEach(function (key) {
138
120
  }
139
121
  });
140
122
  });
141
-
142
123
  var _builtinSchema = require("./builtin-schema");
143
-
144
124
  Object.keys(_builtinSchema).forEach(function (key) {
145
125
  if (key === "default" || key === "__esModule") return;
146
126
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -152,9 +132,7 @@ Object.keys(_builtinSchema).forEach(function (key) {
152
132
  }
153
133
  });
154
134
  });
155
-
156
135
  var _authSchemas = require("./auth-schemas");
157
-
158
136
  Object.keys(_authSchemas).forEach(function (key) {
159
137
  if (key === "default" || key === "__esModule") return;
160
138
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -166,9 +144,7 @@ Object.keys(_authSchemas).forEach(function (key) {
166
144
  }
167
145
  });
168
146
  });
169
-
170
147
  var _apiVersion = require("./api-version");
171
-
172
148
  Object.keys(_apiVersion).forEach(function (key) {
173
149
  if (key === "default" || key === "__esModule") return;
174
150
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -180,9 +156,7 @@ Object.keys(_apiVersion).forEach(function (key) {
180
156
  }
181
157
  });
182
158
  });
183
-
184
159
  var _migration = require("./migration");
185
-
186
160
  Object.keys(_migration).forEach(function (key) {
187
161
  if (key === "default" || key === "__esModule") return;
188
162
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -194,9 +168,7 @@ Object.keys(_migration).forEach(function (key) {
194
168
  }
195
169
  });
196
170
  });
197
-
198
171
  var _validate = require("./validate");
199
-
200
172
  Object.keys(_validate).forEach(function (key) {
201
173
  if (key === "default" || key === "__esModule") return;
202
174
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -208,9 +180,7 @@ Object.keys(_validate).forEach(function (key) {
208
180
  }
209
181
  });
210
182
  });
211
-
212
183
  var _versions = require("./versions");
213
-
214
184
  Object.keys(_versions).forEach(function (key) {
215
185
  if (key === "default" || key === "__esModule") return;
216
186
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -222,9 +192,7 @@ Object.keys(_versions).forEach(function (key) {
222
192
  }
223
193
  });
224
194
  });
225
-
226
195
  var _mocks = require("./mocks");
227
-
228
196
  Object.keys(_mocks).forEach(function (key) {
229
197
  if (key === "default" || key === "__esModule") return;
230
198
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -236,9 +204,7 @@ Object.keys(_mocks).forEach(function (key) {
236
204
  }
237
205
  });
238
206
  });
239
-
240
207
  var _util = require("./util");
241
-
242
208
  Object.keys(_util).forEach(function (key) {
243
209
  if (key === "default" || key === "__esModule") return;
244
210
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -250,9 +216,7 @@ Object.keys(_util).forEach(function (key) {
250
216
  }
251
217
  });
252
218
  });
253
-
254
219
  var _scalars = require("./scalars");
255
-
256
220
  Object.keys(_scalars).forEach(function (key) {
257
221
  if (key === "default" || key === "__esModule") return;
258
222
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -264,9 +228,7 @@ Object.keys(_scalars).forEach(function (key) {
264
228
  }
265
229
  });
266
230
  });
267
-
268
231
  var _refs = require("./refs");
269
-
270
232
  Object.keys(_refs).forEach(function (key) {
271
233
  if (key === "default" || key === "__esModule") return;
272
234
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -278,9 +240,7 @@ Object.keys(_refs).forEach(function (key) {
278
240
  }
279
241
  });
280
242
  });
281
-
282
243
  var _unions = require("./unions");
283
-
284
244
  Object.keys(_unions).forEach(function (key) {
285
245
  if (key === "default" || key === "__esModule") return;
286
246
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -292,9 +252,7 @@ Object.keys(_unions).forEach(function (key) {
292
252
  }
293
253
  });
294
254
  });
295
-
296
255
  var _enum = require("./enum");
297
-
298
256
  Object.keys(_enum).forEach(function (key) {
299
257
  if (key === "default" || key === "__esModule") return;
300
258
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -306,9 +264,7 @@ Object.keys(_enum).forEach(function (key) {
306
264
  }
307
265
  });
308
266
  });
309
-
310
267
  var _patterns = require("./patterns");
311
-
312
268
  Object.keys(_patterns).forEach(function (key) {
313
269
  if (key === "default" || key === "__esModule") return;
314
270
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -320,9 +276,7 @@ Object.keys(_patterns).forEach(function (key) {
320
276
  }
321
277
  });
322
278
  });
323
-
324
279
  var _types = require("./types/types");
325
-
326
280
  Object.keys(_types).forEach(function (key) {
327
281
  if (key === "default" || key === "__esModule") return;
328
282
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -334,9 +288,7 @@ Object.keys(_types).forEach(function (key) {
334
288
  }
335
289
  });
336
290
  });
337
-
338
291
  var _utils = require("./types/utils");
339
-
340
292
  Object.keys(_utils).forEach(function (key) {
341
293
  if (key === "default" || key === "__esModule") return;
342
294
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -348,9 +300,7 @@ Object.keys(_utils).forEach(function (key) {
348
300
  }
349
301
  });
350
302
  });
351
-
352
303
  var _flattenTemplates = require("./flatten-templates");
353
-
354
304
  Object.keys(_flattenTemplates).forEach(function (key) {
355
305
  if (key === "default" || key === "__esModule") return;
356
306
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -362,9 +312,7 @@ Object.keys(_flattenTemplates).forEach(function (key) {
362
312
  }
363
313
  });
364
314
  });
365
-
366
315
  var _relationships = require("./relationships");
367
-
368
316
  Object.keys(_relationships).forEach(function (key) {
369
317
  if (key === "default" || key === "__esModule") return;
370
318
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -376,9 +324,7 @@ Object.keys(_relationships).forEach(function (key) {
376
324
  }
377
325
  });
378
326
  });
379
-
380
327
  var _createInputSchema = require("./create-input-schema");
381
-
382
328
  Object.keys(_createInputSchema).forEach(function (key) {
383
329
  if (key === "default" || key === "__esModule") return;
384
330
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -390,9 +336,7 @@ Object.keys(_createInputSchema).forEach(function (key) {
390
336
  }
391
337
  });
392
338
  });
393
-
394
339
  var _schemaTransform = require("./schema-transform");
395
-
396
340
  Object.keys(_schemaTransform).forEach(function (key) {
397
341
  if (key === "default" || key === "__esModule") return;
398
342
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -404,9 +348,7 @@ Object.keys(_schemaTransform).forEach(function (key) {
404
348
  }
405
349
  });
406
350
  });
407
-
408
351
  var _interfaces = require("./interfaces");
409
-
410
352
  Object.keys(_interfaces).forEach(function (key) {
411
353
  if (key === "default" || key === "__esModule") return;
412
354
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -11,26 +11,18 @@ exports.interfaceToUnion = interfaceToUnion;
11
11
  exports.isInterfaceRef = isInterfaceRef;
12
12
  exports.isInterfaceShape = isInterfaceShape;
13
13
  exports.pruneUnusedInterfaces = pruneUnusedInterfaces;
14
-
15
14
  var _refs = require("./refs");
16
-
17
15
  var _mapValues = _interopRequireDefault(require("lodash/mapValues"));
18
-
19
16
  var _unions = require("./unions");
20
-
21
17
  var _util = require("@takeshape/util");
22
-
23
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
-
25
19
  function isInterfaceShape(shape) {
26
20
  return (shape === null || shape === void 0 ? void 0 : shape.type) === 'interface';
27
21
  }
28
-
29
22
  function isInterfaceRef(context, propertySchema) {
30
23
  const ref = (0, _refs.getRef)(context, propertySchema);
31
24
  return Boolean(ref && isInterfaceShape((0, _refs.refItemToShape)(context, ref)));
32
25
  }
33
-
34
26
  function add(record, key, value) {
35
27
  if (!record[key]) {
36
28
  record[key] = new Set([value]);
@@ -38,61 +30,48 @@ function add(record, key, value) {
38
30
  record[key].add(value);
39
31
  }
40
32
  }
41
-
42
33
  function getImplementationsHelper(shapeMap, mapFn) {
43
34
  const result = {};
44
-
45
35
  for (const shape of Object.values(shapeMap)) {
46
36
  for (const interfaceName of shape.interfaces ?? []) {
47
37
  add(result, interfaceName, mapFn(shape));
48
38
  }
49
39
  }
50
-
51
40
  return result;
52
41
  }
53
-
54
42
  function getImplementationShapeMap(shapeMap) {
55
43
  return getImplementationsHelper(shapeMap, x => x);
56
44
  }
57
-
58
45
  function getImplementationShapeNameMap(shapeMap) {
59
46
  return getImplementationsHelper(shapeMap, shape => shape.name);
60
47
  }
61
-
62
48
  function pruneUnusedInterfaces(shapeMap) {
63
49
  return (0, _mapValues.default)(shapeMap, shape => {
64
50
  const {
65
51
  interfaces
66
52
  } = shape;
67
-
68
53
  if (interfaces !== null && interfaces !== void 0 && interfaces.length) {
69
54
  const filteredInterfaces = interfaces.filter(name => shapeMap[name]);
70
-
71
55
  if (interfaces.length !== filteredInterfaces.length) {
72
- return { ...shape,
56
+ return {
57
+ ...shape,
73
58
  interfaces: filteredInterfaces
74
59
  };
75
60
  }
76
61
  }
77
-
78
62
  return shape;
79
63
  });
80
64
  }
81
-
82
65
  function getImplementingShapes(shapeMap, interfaceName) {
83
66
  const implementingShapes = [];
84
-
85
67
  for (const shape of Object.values(shapeMap)) {
86
68
  var _shape$interfaces;
87
-
88
69
  if ((_shape$interfaces = shape.interfaces) !== null && _shape$interfaces !== void 0 && _shape$interfaces.includes(interfaceName)) {
89
70
  implementingShapes.push(shape);
90
71
  }
91
72
  }
92
-
93
73
  return implementingShapes;
94
74
  }
95
-
96
75
  function interfaceToUnion(context, interfaceName) {
97
76
  const shapes = getImplementingShapes(context.shapes, interfaceName);
98
77
  return {
@@ -101,10 +80,8 @@ function interfaceToUnion(context, interfaceName) {
101
80
  }))
102
81
  };
103
82
  }
104
-
105
83
  function getPossibleShapeNames(projectSchema, shape) {
106
84
  let names;
107
-
108
85
  if (isInterfaceShape(shape)) {
109
86
  names = getImplementingShapes(projectSchema.shapes, shape.name).map(shape => shape.name);
110
87
  } else if ((0, _unions.isUnionSchema)(shape.schema)) {
@@ -115,6 +92,5 @@ function getPossibleShapeNames(projectSchema, shape) {
115
92
  } else {
116
93
  names = [shape.name];
117
94
  }
118
-
119
95
  return names;
120
96
  }