@takeshape/schema 8.66.1 → 8.68.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 (113) hide show
  1. package/es/content-schema-transform.js +2 -2
  2. package/es/index.js +2 -1
  3. package/es/migration/index.js +13 -2
  4. package/es/migration/to/v3.14.0.js +10 -0
  5. package/es/migration/to/v3.15.0.js +10 -0
  6. package/es/project-schema/index.js +2 -0
  7. package/es/project-schema/v3.13.1.js +1 -0
  8. package/es/project-schema/v3.14.0.js +1 -0
  9. package/es/project-schema/v3.15.0.js +1 -0
  10. package/es/refs.js +78 -1
  11. package/es/rewrite.js +58 -0
  12. package/es/schema-util.js +32 -118
  13. package/es/schemas/index.js +5 -3
  14. package/es/schemas/index.ts +6 -2
  15. package/es/schemas/project-schema/v3.14.0.json +2379 -0
  16. package/es/schemas/project-schema/v3.15.0.json +2359 -0
  17. package/es/schemas/project-schema.json +2 -1
  18. package/es/template-shapes/templates.js +56 -52
  19. package/es/template-shapes/types.js +8 -1
  20. package/es/types/utils.js +5 -0
  21. package/es/util/detect-cycles.js +2 -2
  22. package/es/util/index.js +2 -1
  23. package/es/util/merge.js +36 -0
  24. package/es/validate.js +2 -10
  25. package/examples/latest/betzino.json +1 -1
  26. package/examples/latest/blog-schema.json +1 -1
  27. package/examples/latest/brewery-schema.json +1 -1
  28. package/examples/latest/complex-project-schema.json +1 -1
  29. package/examples/latest/fabric-ecommerce.json +1 -1
  30. package/examples/latest/frank-and-fred-schema.json +1 -1
  31. package/examples/latest/massive-schema.json +1 -1
  32. package/examples/latest/mill-components-schema.json +1 -1
  33. package/examples/latest/pet-oneof-array.json +1 -1
  34. package/examples/latest/post-schema.json +1 -1
  35. package/examples/latest/pruned-shopify-product-schema.json +1 -1
  36. package/examples/latest/real-world-schema.json +1 -1
  37. package/examples/latest/recursive-repeater-schema.json +1 -1
  38. package/examples/latest/recursive-schema.json +1 -1
  39. package/examples/latest/rick-and-morty-ast.json +1 -1
  40. package/examples/latest/rick-and-morty-graphql.json +1 -1
  41. package/examples/latest/rick-and-morty-rest.json +1 -1
  42. package/examples/latest/schema-with-repeater-draftjs.json +1 -1
  43. package/examples/latest/shape-books-v3_2_0.json +1 -1
  44. package/examples/latest/shape-books.json +1 -1
  45. package/examples/latest/shopify-lookbook.json +1 -1
  46. package/examples/latest/shopify-store-with-widget.json +1 -1
  47. package/examples/latest/stripe-starter-resolved.json +1 -1
  48. package/examples/latest/user-schema-no-required.json +1 -1
  49. package/examples/latest/user-schema-with-defaults.json +1 -1
  50. package/lib/content-schema-transform.js +6 -6
  51. package/lib/index.d.ts +1 -0
  52. package/lib/index.d.ts.map +1 -1
  53. package/lib/index.js +14 -0
  54. package/lib/migration/index.d.ts.map +1 -1
  55. package/lib/migration/index.js +14 -1
  56. package/lib/migration/to/v3.14.0.d.ts +4 -0
  57. package/lib/migration/to/v3.14.0.d.ts.map +1 -0
  58. package/lib/migration/to/v3.14.0.js +18 -0
  59. package/lib/migration/to/v3.15.0.d.ts +4 -0
  60. package/lib/migration/to/v3.15.0.d.ts.map +1 -0
  61. package/lib/migration/to/v3.15.0.js +18 -0
  62. package/lib/project-schema/index.d.ts +5 -1
  63. package/lib/project-schema/index.d.ts.map +1 -1
  64. package/lib/project-schema/index.js +45 -19
  65. package/lib/project-schema/latest.d.ts +164 -23
  66. package/lib/project-schema/latest.d.ts.map +1 -1
  67. package/lib/project-schema/v3.13.1.d.ts +1413 -0
  68. package/lib/project-schema/v3.13.1.d.ts.map +1 -0
  69. package/lib/project-schema/v3.13.1.js +5 -0
  70. package/lib/project-schema/v3.14.0.d.ts +1437 -0
  71. package/lib/project-schema/v3.14.0.d.ts.map +1 -0
  72. package/lib/project-schema/v3.14.0.js +5 -0
  73. package/lib/project-schema/v3.15.0.d.ts +1459 -0
  74. package/lib/project-schema/v3.15.0.d.ts.map +1 -0
  75. package/lib/project-schema/v3.15.0.js +5 -0
  76. package/lib/refs.d.ts +11 -2
  77. package/lib/refs.d.ts.map +1 -1
  78. package/lib/refs.js +83 -0
  79. package/lib/rewrite.d.ts +10 -0
  80. package/lib/rewrite.d.ts.map +1 -0
  81. package/lib/rewrite.js +69 -0
  82. package/lib/schema-util.d.ts +3 -15
  83. package/lib/schema-util.d.ts.map +1 -1
  84. package/lib/schema-util.js +36 -135
  85. package/lib/schemas/index.d.ts +2302 -2
  86. package/lib/schemas/index.d.ts.map +1 -1
  87. package/lib/schemas/index.js +25 -21
  88. package/lib/schemas/index.ts +6 -2
  89. package/lib/schemas/project-schema/v3.14.0.json +2379 -0
  90. package/lib/schemas/project-schema/v3.15.0.json +2359 -0
  91. package/lib/schemas/project-schema.json +2 -1
  92. package/lib/template-shapes/templates.d.ts +11 -4
  93. package/lib/template-shapes/templates.d.ts.map +1 -1
  94. package/lib/template-shapes/templates.js +63 -57
  95. package/lib/template-shapes/types.d.ts +6 -0
  96. package/lib/template-shapes/types.d.ts.map +1 -1
  97. package/lib/template-shapes/types.js +11 -1
  98. package/lib/types/types.d.ts +2 -2
  99. package/lib/types/types.d.ts.map +1 -1
  100. package/lib/types/utils.d.ts +4 -1
  101. package/lib/types/utils.d.ts.map +1 -1
  102. package/lib/types/utils.js +10 -1
  103. package/lib/util/detect-cycles.d.ts +1 -1
  104. package/lib/util/detect-cycles.js +2 -2
  105. package/lib/util/index.d.ts +1 -0
  106. package/lib/util/index.d.ts.map +1 -1
  107. package/lib/util/index.js +13 -0
  108. package/lib/util/merge.d.ts +5 -0
  109. package/lib/util/merge.d.ts.map +1 -0
  110. package/lib/util/merge.js +51 -0
  111. package/lib/validate.d.ts.map +1 -1
  112. package/lib/validate.js +3 -10
  113. package/package.json +4 -4
@@ -20,6 +20,7 @@
20
20
  {"$ref": "https://schema.takeshape.io/project-schema/v3.12.0#"},
21
21
  {"$ref": "https://schema.takeshape.io/project-schema/v3.12.1#"},
22
22
  {"$ref": "https://schema.takeshape.io/project-schema/v3.12.2#"},
23
- {"$ref": "https://schema.takeshape.io/project-schema/v3.13.0#"}
23
+ {"$ref": "https://schema.takeshape.io/project-schema/v3.13.0#"},
24
+ {"$ref": "https://schema.takeshape.io/project-schema/v3.15.0#"}
24
25
  ]
25
26
  }
@@ -1,27 +1,26 @@
1
+ import { TemplateVerbs } from './types';
1
2
  import { listTypePrefix } from '../migration';
2
- import { isDefined, pascalCase } from '@takeshape/util';
3
+ import { pascalCase } from '@takeshape/util';
3
4
  import keyBy from 'lodash/keyBy';
4
- import { createShape, getShapeDependencies, isIndexedRemoteShape, mergeSchemaProperties } from '../schema-util';
5
+ import { createShape, getShapeDependencies, isIndexedRemoteShape } from '../schema-util';
5
6
  import { getFlattenedTemplateShapeName, getRefShapeName } from '../refs';
6
7
  import { getWhereSearchArg } from './where';
7
- const CREATE = 'create';
8
- const UPDATE = 'update';
9
- const DELETE = 'delete';
10
- const DUPLICATE = 'duplicate';
8
+ import { mergeObjectSchemas, mergeSchemaProperties } from '../util';
9
+ import { rewriteSchema } from '../rewrite';
11
10
  export const TSGetArgs = getIDQueryArgs('TSGetArgs');
12
11
  export const TSGetSingletonArgs = getIDQueryArgs('TSGetSingletonArgs');
13
12
  export const TSListArgs = getShapeListQueryArgs('TSListArgs', true);
14
13
  export const TSSearchArgs = getShapeListQueryArgs('TSSearchArgs', false);
15
- export const CreateArgs = getMutationArgs('CreateArgs', CREATE);
16
- export const UpdateArgs = getMutationArgs('UpdateArgs', UPDATE);
17
- export const DuplicateArgs = getMutationArgs('DuplicateArgs', DUPLICATE);
18
- export const DeleteArgs = getMutationArgs('DeleteArgs', DELETE);
14
+ export const CreateArgs = getMutationArgs('CreateArgs', TemplateVerbs.Create);
15
+ export const UpdateArgs = getMutationArgs('UpdateArgs', TemplateVerbs.Update);
16
+ export const DuplicateArgs = getMutationArgs('DuplicateArgs', TemplateVerbs.Duplicate);
17
+ export const DeleteArgs = getMutationArgs('DeleteArgs', TemplateVerbs.Delete);
19
18
  export const PaginatedList = getPaginatedListShape;
20
19
  export const SearchResults = getSearchResultsShape;
21
- export const CreateResult = getMutationResultType(CREATE);
22
- export const UpdateResult = getMutationResultType(UPDATE);
23
- export const DuplicateResult = getMutationResultType(DUPLICATE);
24
- export const DeleteResult = getMutationResultType(DELETE);
20
+ export const CreateResult = getMutationResultType(TemplateVerbs.Create);
21
+ export const UpdateResult = getMutationResultType(TemplateVerbs.Update);
22
+ export const DuplicateResult = getMutationResultType(TemplateVerbs.Duplicate);
23
+ export const DeleteResult = getMutationResultType(TemplateVerbs.Delete);
25
24
  export const TSSearchSortInput = createShape('TSSearchSortInput', {
26
25
  type: 'object',
27
26
  properties: {
@@ -166,25 +165,6 @@ const idSchema = {
166
165
  },
167
166
  required: ['_id']
168
167
  };
169
- export function rewriteSchema(shapeSchema) {
170
- return JSON.parse(JSON.stringify(shapeSchema), (key, value) => {
171
- if (typeof value === 'object') {
172
- var _value$required;
173
-
174
- // Remove required
175
- if ((_value$required = value.required) !== null && _value$required !== void 0 && _value$required.length) {
176
- delete value.required;
177
- } // Remove default
178
-
179
-
180
- if (value.type !== undefined && value.default !== undefined) {
181
- delete value.default;
182
- }
183
- }
184
-
185
- return value;
186
- });
187
- }
188
168
  export function getIDQueryArgs(templateName) {
189
169
  return (context, shape) => {
190
170
  var _shape$model;
@@ -199,25 +179,48 @@ export function getIDQueryArgs(templateName) {
199
179
  };
200
180
  };
201
181
  }
182
+ /**
183
+ * Construct a shape name used for a mutation input shape.
184
+ */
202
185
 
203
- function mergeObjectSchemas(...args) {
204
- return args.filter(isDefined).reduce(mergeSchemaProperties, {
205
- type: 'object',
206
- properties: {}
207
- });
186
+ export function getMutationInputShapeName(verb) {
187
+ return shapeName => {
188
+ return pascalCase([verb, shapeName, 'input']);
189
+ };
190
+ }
191
+
192
+ /**
193
+ * Create a shape name variant for an input. Updates will typically want a partial input.
194
+ */
195
+ function getInputShapeName(shapeName, {
196
+ isPartial
197
+ }) {
198
+ return isPartial ? `${shapeName}PartialInput` : `${shapeName}Input`;
208
199
  }
200
+ /**
201
+ * Construct shapes for a mutation inputs, given source shape info.
202
+ */
203
+
209
204
 
210
205
  export function getMutationArgs(templateName, verb) {
206
+ const getShapeName = getMutationInputShapeName(verb);
207
+ const addLocale = verb === TemplateVerbs.Update || verb === TemplateVerbs.Duplicate;
208
+ const addStructure = verb === TemplateVerbs.Update;
209
+ const isUpdate = verb === TemplateVerbs.Update || verb === TemplateVerbs.Duplicate;
211
210
  return ({
212
211
  projectSchema
213
212
  }, shape) => {
214
- const addLocale = verb === UPDATE || verb === DUPLICATE;
215
- const addStructure = verb === UPDATE;
216
- const inputName = pascalCase([verb, shape.name, 'input']);
213
+ const inputName = getShapeName(shape.name);
217
214
  const isSingleton = shape.model && shape.model.type === 'single';
218
- const requireId = !isSingleton && (verb === UPDATE || verb === DELETE || verb === DUPLICATE);
219
- const isUpdate = verb === UPDATE || verb === DUPLICATE;
220
- const inputShape = createShape(inputName, mergeObjectSchemas(requireId ? idSchema : undefined, verb !== DELETE ? isUpdate ? rewriteSchema(shape.schema) : shape.schema : undefined), {
215
+ const shouldRequireId = !isSingleton && (verb === TemplateVerbs.Update || verb === TemplateVerbs.Delete || verb === TemplateVerbs.Duplicate);
216
+ const rewrittenSchema = verb !== TemplateVerbs.Delete ? rewriteSchema(shape.schema, isUpdate ? {
217
+ removeDefault: true,
218
+ removeRequired: true,
219
+ replaceInput: true
220
+ } : {
221
+ replaceInput: true
222
+ }) : undefined;
223
+ const inputShape = createShape(inputName, mergeObjectSchemas(shouldRequireId ? idSchema : undefined, rewrittenSchema), {
221
224
  description: `${verb} ${shape.name} input`
222
225
  });
223
226
  const argsShapeName = getFlattenedTemplateShapeName(shape.name, templateName);
@@ -233,15 +236,12 @@ export function getMutationArgs(templateName, verb) {
233
236
  },
234
237
  required: ['input']
235
238
  }, addStructure ? contentStructureFields : undefined, addLocale ? localeProps : undefined));
236
-
237
- const getInputShapeName = shapeName => isUpdate ? `${shapeName}PartialInput` : `${shapeName}Input`;
238
-
239
239
  return {
240
240
  shapeName: argsShapeName,
241
241
  dependencies: {
242
242
  [inputName]: inputShape,
243
243
  [argsShapeName]: argsShape,
244
- ...(verb !== DELETE && keyBy(getShapeDependencies(projectSchema, shape, propSchema => {
244
+ ...(verb !== TemplateVerbs.Delete && keyBy(getShapeDependencies(projectSchema, shape, propSchema => {
245
245
  if (!propSchema['@resolver']) {
246
246
  return false;
247
247
  }
@@ -249,17 +249,21 @@ export function getMutationArgs(templateName, verb) {
249
249
  const shapeName = getRefShapeName(projectSchema, propSchema);
250
250
 
251
251
  if (shapeName) {
252
- return shapeName !== 'TSRelationship' && !projectSchema.shapes[getInputShapeName(shapeName)];
252
+ return shapeName !== 'TSRelationship' && !projectSchema.shapes[getInputShapeName(shapeName, {
253
+ isPartial: isUpdate
254
+ })];
253
255
  }
254
256
 
255
257
  return true;
256
258
  }).map(shapeName => {
257
259
  const shape = projectSchema.shapes[shapeName];
258
- const name = getInputShapeName(shapeName);
260
+ const name = getInputShapeName(shapeName, {
261
+ isPartial: isUpdate
262
+ });
259
263
  return { ...shape,
260
264
  name,
261
265
  id: name,
262
- schema: isUpdate ? rewriteSchema(shape.schema) : shape.schema
266
+ schema: rewrittenSchema
263
267
  };
264
268
  }), 'name')),
265
269
  ...(addStructure ? {
@@ -272,7 +276,7 @@ export function getMutationArgs(templateName, verb) {
272
276
  export function getMutationResultType(verb) {
273
277
  return (context, shape) => {
274
278
  const shapeName = pascalCase([verb, shape.name, 'result']);
275
- const result = verb === DELETE ? {
279
+ const result = verb === TemplateVerbs.Delete ? {
276
280
  type: 'boolean'
277
281
  } : {
278
282
  '@ref': `local:${shape.name}`
@@ -1 +1,8 @@
1
- export {};
1
+ export let TemplateVerbs;
2
+
3
+ (function (TemplateVerbs) {
4
+ TemplateVerbs["Create"] = "create";
5
+ TemplateVerbs["Update"] = "update";
6
+ TemplateVerbs["Duplicate"] = "duplicate";
7
+ TemplateVerbs["Delete"] = "delete";
8
+ })(TemplateVerbs || (TemplateVerbs = {}));
package/es/types/utils.js CHANGED
@@ -75,6 +75,8 @@ export const isProjectSchemaV3_12_1 = createVersionPredicate('3.12.1');
75
75
  export const isProjectSchemaV3_12_2 = createVersionPredicate('3.12.2');
76
76
  export const isProjectSchemaV3_12_3 = createVersionPredicate('3.12.3');
77
77
  export const isProjectSchemaV3_13_0 = createVersionPredicate('3.13.0');
78
+ export const isProjectSchemaV3_14_0 = createVersionPredicate('3.14.0');
79
+ export const isProjectSchemaV3_15_0 = createVersionPredicate('3.15.0');
78
80
  export const isLatestProjectSchema = createVersionPredicate(CURRENT_SCHEMA_VERSION);
79
81
  export function isV1XSchema(maybeSchema) {
80
82
  return isObject(maybeSchema) && isString(maybeSchema.projectId) && isObject(maybeSchema.contentTypes) && (isUndefined(maybeSchema.schemaVersion) || maybeSchema.schemaVersion === '1' || maybeSchema.schemaVersion === '1.0.0');
@@ -209,6 +211,9 @@ export function isRefSchemaLegacy(propertySchema) {
209
211
  export function isAllOfSchema(propertySchema) {
210
212
  return isArray(propertySchema.allOf);
211
213
  }
214
+ export function isExtendsSchema(propertySchema) {
215
+ return isArray(propertySchema.extends);
216
+ }
212
217
  export function isOneOfSchema(propertySchema) {
213
218
  return isArray(propertySchema.oneOf);
214
219
  }
@@ -6,7 +6,7 @@ function immutableSetAdd(set, str) {
6
6
  return result;
7
7
  }
8
8
  /**
9
- * Use a basic depth-first search to dertermine whether a schema contains a cycle
9
+ * Use a basic depth-first search to determine whether a schema contains a cycle
10
10
  */
11
11
 
12
12
 
@@ -27,7 +27,7 @@ export function hasCycle(projectSchema, schema, shapesSeen = new Set()) {
27
27
  return hasCycle(projectSchema, refShape.schema, immutableSetAdd(shapesSeen, refShape.name));
28
28
  }
29
29
 
30
- const combo = schema.oneOf ?? schema.allOf;
30
+ const combo = schema.oneOf ?? schema.allOf ?? schema.extends;
31
31
 
32
32
  if (combo) {
33
33
  return combo.some(childSchema => hasCycle(projectSchema, childSchema, shapesSeen));
package/es/util/index.js CHANGED
@@ -1 +1,2 @@
1
- export * from './detect-cycles';
1
+ export * from './detect-cycles';
2
+ export * from './merge';
@@ -0,0 +1,36 @@
1
+ import { isDefined } from '@takeshape/util';
2
+ import union from 'lodash/union';
3
+ export function mergeObjectSchemas(...args) {
4
+ return args.filter(isDefined).reduce(mergeSchemaProperties, {
5
+ type: 'object',
6
+ properties: {}
7
+ });
8
+ }
9
+ export function mergeSchemaProperties(base, overrides) {
10
+ const result = { ...base,
11
+ properties: { ...base.properties,
12
+ ...overrides.properties
13
+ }
14
+ };
15
+ const required = union(base.required, overrides.required);
16
+
17
+ if (required.length) {
18
+ result.required = required;
19
+ }
20
+
21
+ return result;
22
+ }
23
+ export function mergeFormProperties(base, overrides) {
24
+ const result = { ...base,
25
+ properties: { ...base.properties,
26
+ ...overrides.properties
27
+ }
28
+ };
29
+ const order = union(base.order, overrides.order);
30
+
31
+ if (order.length) {
32
+ result.order = order;
33
+ }
34
+
35
+ return result;
36
+ }
package/es/validate.js CHANGED
@@ -19,6 +19,7 @@ import { scalars } from './scalars';
19
19
  import { enumerateOneOfKeys, isUnionSchema } from './unions';
20
20
  import { isEnumLikeSchema } from './enum';
21
21
  import metaSchemaV3_9_0 from './schemas/project-schema/meta-schema-v3.9.0.json';
22
+ import { isIntegerLike } from '@takeshape/util';
22
23
 
23
24
  function findDuplicates(items) {
24
25
  const seen = {};
@@ -343,22 +344,13 @@ function getModelShapeIds(shapes) {
343
344
  }
344
345
 
345
346
  const builtInModelShapeIds = getModelShapeIds(builtInShapes);
346
-
347
- function isNumberLike(value) {
348
- if (typeof value === 'number') {
349
- return true;
350
- }
351
-
352
- return /^\d+$/.test(value);
353
- }
354
347
  /**
355
348
  * Verify the path has an allOf schema and not just prop named "allOf"
356
349
  */
357
350
 
358
-
359
351
  function isAllOfPath(path) {
360
352
  const index = path.indexOf('allOf');
361
- return index !== -1 && isNumberLike(path[index + 1]);
353
+ return index !== -1 && isIntegerLike(path[index + 1]);
362
354
  }
363
355
 
364
356
  function validateRefs(projectSchema, additionalShapeNames = builtInShapeNames) {
@@ -45168,6 +45168,6 @@
45168
45168
  }
45169
45169
  }
45170
45170
  },
45171
- "schemaVersion": "3.13.0",
45171
+ "schemaVersion": "3.15.0",
45172
45172
  "services": {}
45173
45173
  }
@@ -382,6 +382,6 @@
382
382
  }
383
383
  }
384
384
  },
385
- "schemaVersion": "3.13.0",
385
+ "schemaVersion": "3.15.0",
386
386
  "services": {}
387
387
  }
@@ -381,6 +381,6 @@
381
381
  }
382
382
  }
383
383
  },
384
- "schemaVersion": "3.13.0",
384
+ "schemaVersion": "3.15.0",
385
385
  "services": {}
386
386
  }
@@ -3991,6 +3991,6 @@
3991
3991
  }
3992
3992
  }
3993
3993
  },
3994
- "schemaVersion": "3.13.0",
3994
+ "schemaVersion": "3.15.0",
3995
3995
  "services": {}
3996
3996
  }
@@ -10516,5 +10516,5 @@
10516
10516
  }
10517
10517
  }
10518
10518
  },
10519
- "schemaVersion": "3.13.0"
10519
+ "schemaVersion": "3.15.0"
10520
10520
  }
@@ -20505,6 +20505,6 @@
20505
20505
  }
20506
20506
  }
20507
20507
  },
20508
- "schemaVersion": "3.13.0",
20508
+ "schemaVersion": "3.15.0",
20509
20509
  "services": {}
20510
20510
  }
@@ -7276,6 +7276,6 @@
7276
7276
  }
7277
7277
  }
7278
7278
  },
7279
- "schemaVersion": "3.13.0",
7279
+ "schemaVersion": "3.15.0",
7280
7280
  "services": {}
7281
7281
  }
@@ -1826,6 +1826,6 @@
1826
1826
  }
1827
1827
  }
1828
1828
  },
1829
- "schemaVersion": "3.13.0",
1829
+ "schemaVersion": "3.15.0",
1830
1830
  "services": {}
1831
1831
  }
@@ -404,6 +404,6 @@
404
404
  }
405
405
  }
406
406
  },
407
- "schemaVersion": "3.13.0",
407
+ "schemaVersion": "3.15.0",
408
408
  "services": {}
409
409
  }
@@ -223,6 +223,6 @@
223
223
  }
224
224
  }
225
225
  },
226
- "schemaVersion": "3.13.0",
226
+ "schemaVersion": "3.15.0",
227
227
  "services": {}
228
228
  }
@@ -9760,5 +9760,5 @@
9760
9760
  }
9761
9761
  }
9762
9762
  },
9763
- "schemaVersion": "3.13.0"
9763
+ "schemaVersion": "3.15.0"
9764
9764
  }
@@ -1005,6 +1005,6 @@
1005
1005
  }
1006
1006
  }
1007
1007
  },
1008
- "schemaVersion": "3.13.0",
1008
+ "schemaVersion": "3.15.0",
1009
1009
  "services": {}
1010
1010
  }
@@ -141,6 +141,6 @@
141
141
  }
142
142
  }
143
143
  },
144
- "schemaVersion": "3.13.0",
144
+ "schemaVersion": "3.15.0",
145
145
  "services": {}
146
146
  }
@@ -148,6 +148,6 @@
148
148
  }
149
149
  }
150
150
  },
151
- "schemaVersion": "3.13.0",
151
+ "schemaVersion": "3.15.0",
152
152
  "services": {}
153
153
  }
@@ -2706,5 +2706,5 @@
2706
2706
  }
2707
2707
  }
2708
2708
  },
2709
- "schemaVersion": "3.13.0"
2709
+ "schemaVersion": "3.15.0"
2710
2710
  }
@@ -2216,5 +2216,5 @@
2216
2216
  }
2217
2217
  }
2218
2218
  },
2219
- "schemaVersion": "3.13.0"
2219
+ "schemaVersion": "3.15.0"
2220
2220
  }
@@ -96,5 +96,5 @@
96
96
  }
97
97
  }
98
98
  },
99
- "schemaVersion": "3.13.0"
99
+ "schemaVersion": "3.15.0"
100
100
  }
@@ -386,6 +386,6 @@
386
386
  }
387
387
  }
388
388
  },
389
- "schemaVersion": "3.13.0",
389
+ "schemaVersion": "3.15.0",
390
390
  "services": {}
391
391
  }
@@ -1110,6 +1110,6 @@
1110
1110
  }
1111
1111
  }
1112
1112
  },
1113
- "schemaVersion": "3.13.0",
1113
+ "schemaVersion": "3.15.0",
1114
1114
  "services": {}
1115
1115
  }
@@ -1070,6 +1070,6 @@
1070
1070
  }
1071
1071
  }
1072
1072
  },
1073
- "schemaVersion": "3.13.0",
1073
+ "schemaVersion": "3.15.0",
1074
1074
  "services": {}
1075
1075
  }
@@ -1182,5 +1182,5 @@
1182
1182
  }
1183
1183
  }
1184
1184
  },
1185
- "schemaVersion": "3.13.0"
1185
+ "schemaVersion": "3.15.0"
1186
1186
  }
@@ -12534,5 +12534,5 @@
12534
12534
  }
12535
12535
  }
12536
12536
  },
12537
- "schemaVersion": "3.13.0"
12537
+ "schemaVersion": "3.15.0"
12538
12538
  }
@@ -29315,5 +29315,5 @@
29315
29315
  }
29316
29316
  }
29317
29317
  },
29318
- "schemaVersion": "3.13.0"
29318
+ "schemaVersion": "3.15.0"
29319
29319
  }
@@ -169,6 +169,6 @@
169
169
  }
170
170
  }
171
171
  },
172
- "schemaVersion": "3.13.0",
172
+ "schemaVersion": "3.15.0",
173
173
  "services": {}
174
174
  }
@@ -194,6 +194,6 @@
194
194
  }
195
195
  }
196
196
  },
197
- "schemaVersion": "3.13.0",
197
+ "schemaVersion": "3.15.0",
198
198
  "services": {}
199
199
  }
@@ -90,7 +90,7 @@ function getContentTransform({
90
90
  }) {
91
91
  const prepare = (schema, obj, name = '') => {
92
92
  const shapeName = (0, _refs.getRefShapeName)(projectSchema, schema);
93
- schema = (0, _schemaUtil.dereferenceSchema)(projectSchema, schema);
93
+ schema = (0, _refs.dereferenceSchema)(projectSchema, schema);
94
94
 
95
95
  if (accumulators) {
96
96
  accumulators.forEach(accumulator => {
@@ -129,7 +129,7 @@ function getContentTransform({
129
129
 
130
130
  if (value !== undefined) {
131
131
  assigned.add(sourceKey);
132
- const transform = findTransforms(transforms, (0, _schemaUtil.dereferenceSchema)(projectSchema, fieldSchema), name);
132
+ const transform = findTransforms(transforms, (0, _refs.dereferenceSchema)(projectSchema, fieldSchema), name);
133
133
  const getKey = transform !== null && transform !== void 0 && transform.keyTransform ? transform.keyTransform : keyTransform;
134
134
  result[getKey(name, fieldSchema, sourceKey)] = value;
135
135
  }
@@ -192,7 +192,7 @@ function getPropertyInfo(context, schema, path) {
192
192
  return;
193
193
  }
194
194
 
195
- const refSchema = (0, _schemaUtil.dereferenceSchema)(projectSchema, propSchema);
195
+ const refSchema = (0, _refs.dereferenceSchema)(projectSchema, propSchema);
196
196
  const nextPath = path.concat(transformKey(transforms, refSchema, name, keyTransform));
197
197
 
198
198
  if (rest.length) {
@@ -206,14 +206,14 @@ function getPropertyInfo(context, schema, path) {
206
206
  }
207
207
  } else if ((0, _unions.isUnionSchema)(currentSchema)) {
208
208
  for (const optionSchema of currentSchema.oneOf) {
209
- findProperty((0, _schemaUtil.dereferenceSchema)(projectSchema, optionSchema), name, rest, path);
209
+ findProperty((0, _refs.dereferenceSchema)(projectSchema, optionSchema), name, rest, path);
210
210
  }
211
211
  } else if ((0, _utils.isArraySchema)(currentSchema)) {
212
- findProperty((0, _schemaUtil.dereferenceSchema)(projectSchema, currentSchema.items), name, rest, path);
212
+ findProperty((0, _refs.dereferenceSchema)(projectSchema, currentSchema.items), name, rest, path);
213
213
  }
214
214
  };
215
215
 
216
216
  const [first, ...rest] = path.split('.');
217
- findProperty((0, _schemaUtil.dereferenceSchema)(projectSchema, schema), first, rest, []);
217
+ findProperty((0, _refs.dereferenceSchema)(projectSchema, schema), first, rest, []);
218
218
  return result;
219
219
  }
package/lib/index.d.ts CHANGED
@@ -26,4 +26,5 @@ export * from './types/types';
26
26
  export * from './types/utils';
27
27
  export * from './flatten-templates';
28
28
  export * from './relationships';
29
+ export * from './rewrite';
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,mBAAmB,EAAE,6BAA6B,EAAC,MAAM,mBAAmB,CAAC;AAE1F,YAAY,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,mBAAmB,EAAE,6BAA6B,EAAC,MAAM,mBAAmB,CAAC;AAE1F,YAAY,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
package/lib/index.js CHANGED
@@ -361,4 +361,18 @@ Object.keys(_relationships).forEach(function (key) {
361
361
  return _relationships[key];
362
362
  }
363
363
  });
364
+ });
365
+
366
+ var _rewrite = require("./rewrite");
367
+
368
+ Object.keys(_rewrite).forEach(function (key) {
369
+ if (key === "default" || key === "__esModule") return;
370
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
371
+ if (key in exports && exports[key] === _rewrite[key]) return;
372
+ Object.defineProperty(exports, key, {
373
+ enumerable: true,
374
+ get: function () {
375
+ return _rewrite[key];
376
+ }
377
+ });
364
378
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,SAAS,CAAC;AAyC3D,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,6BAA6B,EACtC,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAAC,aAAa,CAAC,CA8ExB;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,6BAA6B,EACtC,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAMpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,SAAS,CAAC;AA6C3D,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAG9C,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,6BAA6B,EACtC,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAAC,aAAa,CAAC,CAsFxB;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,6BAA6B,EACtC,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAMpC"}
@@ -50,6 +50,10 @@ var _v17 = _interopRequireDefault(require("./to/v3.12.3"));
50
50
 
51
51
  var _v18 = _interopRequireDefault(require("./to/v3.13.0"));
52
52
 
53
+ var _v19 = _interopRequireDefault(require("./to/v3.14.0"));
54
+
55
+ var _v20 = _interopRequireDefault(require("./to/v3.15.0"));
56
+
53
57
  var _utils2 = require("./utils");
54
58
 
55
59
  Object.keys(_utils2).forEach(function (key) {
@@ -66,7 +70,8 @@ Object.keys(_utils2).forEach(function (key) {
66
70
 
67
71
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
68
72
 
69
- const listTypePrefix = 'PaginatedList';
73
+ const listTypePrefix = 'PaginatedList'; // eslint-disable-next-line complexity
74
+
70
75
  exports.listTypePrefix = listTypePrefix;
71
76
 
72
77
  async function migrateToLatestProjectSchema(context, projectSchema) {
@@ -146,6 +151,14 @@ async function migrateToLatestProjectSchema(context, projectSchema) {
146
151
  projectSchema = (0, _v18.default)(projectSchema);
147
152
  }
148
153
 
154
+ if ((0, _utils.isProjectSchemaV3_13_0)(projectSchema)) {
155
+ projectSchema = (0, _v19.default)(projectSchema);
156
+ }
157
+
158
+ if ((0, _utils.isProjectSchemaV3_14_0)(projectSchema)) {
159
+ projectSchema = (0, _v20.default)(projectSchema);
160
+ }
161
+
149
162
  return projectSchema;
150
163
  }
151
164