@takeshape/schema 8.68.7 → 8.72.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 (131) hide show
  1. package/es/index.js +1 -0
  2. package/es/migration/index.js +33 -107
  3. package/es/migration/to/v3.0.0.js +3 -3
  4. package/es/migration/to/v3.1.0.js +3 -3
  5. package/es/migration/to/v3.10.0.js +3 -3
  6. package/es/migration/to/v3.11.0.js +7 -6
  7. package/es/migration/to/v3.12.0.js +3 -3
  8. package/es/migration/to/v3.12.1.js +3 -3
  9. package/es/migration/to/v3.12.2.js +3 -3
  10. package/es/migration/to/v3.12.3.js +4 -4
  11. package/es/migration/to/v3.13.0.js +3 -3
  12. package/es/migration/to/v3.14.0.js +3 -3
  13. package/es/migration/to/v3.15.0.js +3 -3
  14. package/es/migration/to/v3.2.0.js +3 -3
  15. package/es/migration/to/v3.3.0.js +3 -3
  16. package/es/migration/to/v3.4.0.js +3 -3
  17. package/es/migration/to/v3.5.0.js +3 -3
  18. package/es/migration/to/v3.5.1.js +3 -3
  19. package/es/migration/to/v3.6.0.js +3 -3
  20. package/es/migration/to/v3.7.0.js +3 -3
  21. package/es/migration/to/v3.8.0.js +3 -3
  22. package/es/migration/to/v3.9.0.js +3 -3
  23. package/es/project-schema/index.js +64 -22
  24. package/es/project-schema/migrate.js +102 -0
  25. package/es/schema-util.js +1 -1
  26. package/es/schemas/index.js +34 -34
  27. package/es/schemas/index.ts +66 -66
  28. package/es/schemas/project-schema/latest.json +2359 -0
  29. package/es/schemas/project-schema/v1.0.0.json +1 -1
  30. package/es/schemas/project-schema/v3.0.0.json +1 -1
  31. package/es/schemas/project-schema/v3.15.0.json +7 -7
  32. package/es/schemas/project-schema.json +66 -19
  33. package/es/taxonomies.js +1 -1
  34. package/es/template-shapes/where.js +2 -2
  35. package/es/types/utils.js +1 -51
  36. package/es/validate.js +0 -16
  37. package/lib/index.d.ts +1 -0
  38. package/lib/index.d.ts.map +1 -1
  39. package/lib/index.js +14 -0
  40. package/lib/migration/index.d.ts +23 -4
  41. package/lib/migration/index.d.ts.map +1 -1
  42. package/lib/migration/index.js +32 -111
  43. package/lib/migration/to/v3.0.0.d.ts +3 -2
  44. package/lib/migration/to/v3.0.0.d.ts.map +1 -1
  45. package/lib/migration/to/v3.0.0.js +3 -3
  46. package/lib/migration/to/v3.1.0.d.ts +3 -3
  47. package/lib/migration/to/v3.1.0.d.ts.map +1 -1
  48. package/lib/migration/to/v3.1.0.js +3 -3
  49. package/lib/migration/to/v3.10.0.d.ts +3 -2
  50. package/lib/migration/to/v3.10.0.d.ts.map +1 -1
  51. package/lib/migration/to/v3.10.0.js +3 -3
  52. package/lib/migration/to/v3.11.0.d.ts +3 -3
  53. package/lib/migration/to/v3.11.0.d.ts.map +1 -1
  54. package/lib/migration/to/v3.11.0.js +7 -6
  55. package/lib/migration/to/v3.12.0.d.ts +3 -2
  56. package/lib/migration/to/v3.12.0.d.ts.map +1 -1
  57. package/lib/migration/to/v3.12.0.js +3 -3
  58. package/lib/migration/to/v3.12.1.d.ts +3 -2
  59. package/lib/migration/to/v3.12.1.d.ts.map +1 -1
  60. package/lib/migration/to/v3.12.1.js +3 -3
  61. package/lib/migration/to/v3.12.2.d.ts +3 -2
  62. package/lib/migration/to/v3.12.2.d.ts.map +1 -1
  63. package/lib/migration/to/v3.12.2.js +3 -3
  64. package/lib/migration/to/v3.12.3.d.ts +3 -2
  65. package/lib/migration/to/v3.12.3.d.ts.map +1 -1
  66. package/lib/migration/to/v3.12.3.js +4 -4
  67. package/lib/migration/to/v3.13.0.d.ts +3 -2
  68. package/lib/migration/to/v3.13.0.d.ts.map +1 -1
  69. package/lib/migration/to/v3.13.0.js +3 -3
  70. package/lib/migration/to/v3.14.0.d.ts +3 -2
  71. package/lib/migration/to/v3.14.0.d.ts.map +1 -1
  72. package/lib/migration/to/v3.14.0.js +3 -3
  73. package/lib/migration/to/v3.15.0.d.ts +3 -2
  74. package/lib/migration/to/v3.15.0.d.ts.map +1 -1
  75. package/lib/migration/to/v3.15.0.js +3 -3
  76. package/lib/migration/to/v3.2.0.d.ts +3 -2
  77. package/lib/migration/to/v3.2.0.d.ts.map +1 -1
  78. package/lib/migration/to/v3.2.0.js +3 -3
  79. package/lib/migration/to/v3.3.0.d.ts +3 -3
  80. package/lib/migration/to/v3.3.0.d.ts.map +1 -1
  81. package/lib/migration/to/v3.3.0.js +3 -3
  82. package/lib/migration/to/v3.4.0.d.ts +3 -2
  83. package/lib/migration/to/v3.4.0.d.ts.map +1 -1
  84. package/lib/migration/to/v3.4.0.js +3 -3
  85. package/lib/migration/to/v3.5.0.d.ts +3 -2
  86. package/lib/migration/to/v3.5.0.d.ts.map +1 -1
  87. package/lib/migration/to/v3.5.0.js +3 -3
  88. package/lib/migration/to/v3.5.1.d.ts +3 -2
  89. package/lib/migration/to/v3.5.1.d.ts.map +1 -1
  90. package/lib/migration/to/v3.5.1.js +3 -3
  91. package/lib/migration/to/v3.6.0.d.ts +3 -2
  92. package/lib/migration/to/v3.6.0.d.ts.map +1 -1
  93. package/lib/migration/to/v3.6.0.js +3 -3
  94. package/lib/migration/to/v3.7.0.d.ts +3 -2
  95. package/lib/migration/to/v3.7.0.d.ts.map +1 -1
  96. package/lib/migration/to/v3.7.0.js +3 -3
  97. package/lib/migration/to/v3.8.0.d.ts +3 -2
  98. package/lib/migration/to/v3.8.0.d.ts.map +1 -1
  99. package/lib/migration/to/v3.8.0.js +3 -3
  100. package/lib/migration/to/v3.9.0.d.ts +3 -2
  101. package/lib/migration/to/v3.9.0.d.ts.map +1 -1
  102. package/lib/migration/to/v3.9.0.js +3 -3
  103. package/lib/migration/types.d.ts +1 -0
  104. package/lib/migration/types.d.ts.map +1 -1
  105. package/lib/project-schema/index.d.ts +66 -43
  106. package/lib/project-schema/index.d.ts.map +1 -1
  107. package/lib/project-schema/index.js +139 -23
  108. package/lib/project-schema/migrate.d.ts +5 -0
  109. package/lib/project-schema/migrate.d.ts.map +1 -0
  110. package/lib/project-schema/migrate.js +113 -0
  111. package/lib/project-schema/v1.0.0.d.ts +1 -1
  112. package/lib/project-schema/v1.0.0.d.ts.map +1 -1
  113. package/lib/project-schema/v3.0.0.d.ts +1 -1
  114. package/lib/project-schema/v3.0.0.d.ts.map +1 -1
  115. package/lib/schema-util.js +1 -1
  116. package/lib/schemas/index.d.ts +7009 -7009
  117. package/lib/schemas/index.js +34 -34
  118. package/lib/schemas/index.ts +66 -66
  119. package/lib/schemas/project-schema/latest.json +2359 -0
  120. package/lib/schemas/project-schema/v1.0.0.json +1 -1
  121. package/lib/schemas/project-schema/v3.0.0.json +1 -1
  122. package/lib/schemas/project-schema/v3.15.0.json +7 -7
  123. package/lib/schemas/project-schema.json +66 -19
  124. package/lib/taxonomies.js +1 -1
  125. package/lib/template-shapes/where.js +2 -2
  126. package/lib/types/utils.d.ts +1 -29
  127. package/lib/types/utils.d.ts.map +1 -1
  128. package/lib/types/utils.js +0 -80
  129. package/lib/validate.d.ts.map +1 -1
  130. package/lib/validate.js +0 -16
  131. package/package.json +5 -5
@@ -274,7 +274,7 @@
274
274
  },
275
275
  "schemaVersion": {
276
276
  "type": "string",
277
- "enum": ["1"]
277
+ "enum": ["1", "1.0.0"]
278
278
  },
279
279
  "projectId": {
280
280
  "type": "string"
@@ -338,7 +338,7 @@
338
338
  },
339
339
  "schemaVersion": {
340
340
  "type": "string",
341
- "enum": ["3"]
341
+ "enum": ["3", "3.0.0"]
342
342
  },
343
343
  "projectId": {
344
344
  "type": "string"
@@ -215,7 +215,7 @@
215
215
  "title": "Shape Schema All Of",
216
216
  "type": "object",
217
217
  "properties": {
218
- "allOf": {"$ref": "#/definitions/objectOrRefArray"}
218
+ "allOf": {"$ref": "#/definitions/objectOrRefArray"}
219
219
  },
220
220
  "required": ["allOf"],
221
221
  "additionalProperties": false
@@ -227,7 +227,7 @@
227
227
  {
228
228
  "type": "object",
229
229
  "properties": {
230
- "allOf": {"$ref": "#/definitions/objectOrRefArray"}
230
+ "allOf": {"$ref": "#/definitions/objectOrRefArray"}
231
231
  },
232
232
  "required": ["allOf"]
233
233
  }
@@ -237,7 +237,7 @@
237
237
  "title": "ShapeSchemaExtends",
238
238
  "type": "object",
239
239
  "properties": {
240
- "extends": {"$ref": "#/definitions/objectOrRefArray"}
240
+ "extends": {"$ref": "#/definitions/objectOrRefArray"}
241
241
  },
242
242
  "required": ["extends"],
243
243
  "additionalProperties": false
@@ -249,7 +249,7 @@
249
249
  {
250
250
  "type": "object",
251
251
  "properties": {
252
- "extends": {"$ref": "#/definitions/objectOrRefArray"}
252
+ "extends": {"$ref": "#/definitions/objectOrRefArray"}
253
253
  },
254
254
  "required": ["extends"]
255
255
  }
@@ -259,7 +259,7 @@
259
259
  "title": "Shape Schema One Of",
260
260
  "type": "object",
261
261
  "properties": {
262
- "oneOf": {"$ref": "#/definitions/objectOrRefArray"}
262
+ "oneOf": {"$ref": "#/definitions/objectOrRefArray"}
263
263
  },
264
264
  "required": ["oneOf"],
265
265
  "additionalProperties": false
@@ -271,7 +271,7 @@
271
271
  {
272
272
  "type": "object",
273
273
  "properties": {
274
- "oneOf": {"$ref": "#/definitions/objectOrRefArray"}
274
+ "oneOf": {"$ref": "#/definitions/objectOrRefArray"}
275
275
  },
276
276
  "required": ["oneOf"],
277
277
  "additionalProperties": false
@@ -1439,7 +1439,7 @@
1439
1439
  "$ref": "#/definitions/schemaArray"
1440
1440
  },
1441
1441
  "extends": {
1442
- "$ref": "#/definitions/objectOrRefArray"
1442
+ "$ref": "#/definitions/objectOrRefArray"
1443
1443
  },
1444
1444
  "@relationship": {
1445
1445
  "$ref": "#/definitions/relationship"
@@ -3,24 +3,71 @@
3
3
  "$id": "https://schema.takeshape.io/project-schema#",
4
4
  "title": "Any Project Schema",
5
5
  "oneOf": [
6
- {"$ref": "https://schema.takeshape.io/project-schema/v1.0.0#"},
7
- {"$ref": "https://schema.takeshape.io/project-schema/v3.0.0#"},
8
- {"$ref": "https://schema.takeshape.io/project-schema/v3.1.0#"},
9
- {"$ref": "https://schema.takeshape.io/project-schema/v3.2.0#"},
10
- {"$ref": "https://schema.takeshape.io/project-schema/v3.3.0#"},
11
- {"$ref": "https://schema.takeshape.io/project-schema/v3.4.0#"},
12
- {"$ref": "https://schema.takeshape.io/project-schema/v3.5.0#"},
13
- {"$ref": "https://schema.takeshape.io/project-schema/v3.5.1#"},
14
- {"$ref": "https://schema.takeshape.io/project-schema/v3.6.0#"},
15
- {"$ref": "https://schema.takeshape.io/project-schema/v3.7.0#"},
16
- {"$ref": "https://schema.takeshape.io/project-schema/v3.8.0#"},
17
- {"$ref": "https://schema.takeshape.io/project-schema/v3.9.0#"},
18
- {"$ref": "https://schema.takeshape.io/project-schema/v3.10.0#"},
19
- {"$ref": "https://schema.takeshape.io/project-schema/v3.11.0#"},
20
- {"$ref": "https://schema.takeshape.io/project-schema/v3.12.0#"},
21
- {"$ref": "https://schema.takeshape.io/project-schema/v3.12.1#"},
22
- {"$ref": "https://schema.takeshape.io/project-schema/v3.12.2#"},
23
- {"$ref": "https://schema.takeshape.io/project-schema/v3.13.0#"},
24
- {"$ref": "https://schema.takeshape.io/project-schema/v3.15.0#"}
6
+ {
7
+ "$ref": "https://schema.takeshape.io/project-schema/v1.0.0#"
8
+ },
9
+ {
10
+ "$ref": "https://schema.takeshape.io/project-schema/v3.0.0#"
11
+ },
12
+ {
13
+ "$ref": "https://schema.takeshape.io/project-schema/v3.1.0#"
14
+ },
15
+ {
16
+ "$ref": "https://schema.takeshape.io/project-schema/v3.2.0#"
17
+ },
18
+ {
19
+ "$ref": "https://schema.takeshape.io/project-schema/v3.3.0#"
20
+ },
21
+ {
22
+ "$ref": "https://schema.takeshape.io/project-schema/v3.4.0#"
23
+ },
24
+ {
25
+ "$ref": "https://schema.takeshape.io/project-schema/v3.5.0#"
26
+ },
27
+ {
28
+ "$ref": "https://schema.takeshape.io/project-schema/v3.5.1#"
29
+ },
30
+ {
31
+ "$ref": "https://schema.takeshape.io/project-schema/v3.6.0#"
32
+ },
33
+ {
34
+ "$ref": "https://schema.takeshape.io/project-schema/v3.7.0#"
35
+ },
36
+ {
37
+ "$ref": "https://schema.takeshape.io/project-schema/v3.8.0#"
38
+ },
39
+ {
40
+ "$ref": "https://schema.takeshape.io/project-schema/v3.9.0#"
41
+ },
42
+ {
43
+ "$ref": "https://schema.takeshape.io/project-schema/v3.10.0#"
44
+ },
45
+ {
46
+ "$ref": "https://schema.takeshape.io/project-schema/v3.11.0#"
47
+ },
48
+ {
49
+ "$ref": "https://schema.takeshape.io/project-schema/v3.12.0#"
50
+ },
51
+ {
52
+ "$ref": "https://schema.takeshape.io/project-schema/v3.12.1#"
53
+ },
54
+ {
55
+ "$ref": "https://schema.takeshape.io/project-schema/v3.12.2#"
56
+ },
57
+ {
58
+ "$ref": "https://schema.takeshape.io/project-schema/v3.12.3#"
59
+ },
60
+ {
61
+ "$ref": "https://schema.takeshape.io/project-schema/v3.13.0#"
62
+ },
63
+ {
64
+ "$ref": "https://schema.takeshape.io/project-schema/v3.14.0#"
65
+ },
66
+ {
67
+ "$ref": "https://schema.takeshape.io/project-schema/v3.15.0#"
68
+ },
69
+ {
70
+ "$ref": "https://schema.takeshape.io/project-schema/v4.0.0#"
71
+ }
25
72
  ]
26
73
  }
package/es/taxonomies.js CHANGED
@@ -16,7 +16,7 @@ export function getFirstStringFieldV3(shape, projectSchema) {
16
16
  return null;
17
17
  }
18
18
 
19
- const schemaProperties = createSchemaPropertyAccessor(projectSchema, shape.schema);
19
+ const schemaProperties = createSchemaPropertyAccessor(projectSchema, shape);
20
20
  const {
21
21
  order
22
22
  } = forms.default;
@@ -137,7 +137,7 @@ function getConflictingProperties(projectSchema, shapes) {
137
137
  const allProps = {};
138
138
 
139
139
  for (const shape of Object.values(shapes)) {
140
- for (const [name, prop] of createSchemaPropertyList(projectSchema, shape.schema).getNodes()) {
140
+ for (const [name, prop] of createSchemaPropertyList(projectSchema, shape).getNodes()) {
141
141
  if (name in allProps && (allProps[name].type !== prop.type || !isEqualRelationship(allProps[name], prop))) {
142
142
  conflicts.add(name);
143
143
  }
@@ -303,7 +303,7 @@ export function getFields(typeName, shapes, context) {
303
303
  };
304
304
 
305
305
  for (const shape of shapes) {
306
- const nodes = createSchemaPropertyList(projectSchema, shape.schema).filterBy(([name, property]) => !skipField(name, property, projectSchema, tooDeep)).getNodes();
306
+ const nodes = createSchemaPropertyList(projectSchema, shape).filterBy(([name, property]) => !skipField(name, property, projectSchema, tooDeep)).getNodes();
307
307
 
308
308
  for (const [name, property] of nodes) {
309
309
  Object.assign(result, getPropertyComparisonType(name, property, shape.name, fieldContext));
package/es/types/utils.js CHANGED
@@ -1,13 +1,11 @@
1
1
  import { isRecord } from '@takeshape/util';
2
2
  import { ArgsType, RefType } from './types';
3
- import eq from 'semver/functions/eq';
4
3
  import coerce from 'semver/functions/coerce';
5
4
  import isPlainObject from 'lodash/isPlainObject';
6
5
  import isString from 'lodash/isString';
7
6
  import isArray from 'lodash/isArray';
8
- import isUndefined from 'lodash/isUndefined';
9
7
  import has from 'lodash/has';
10
- import { CURRENT_SCHEMA_VERSION, latestSchemaJson } from '../schemas';
8
+ import { latestSchemaJson } from '../schemas';
11
9
  import satisfies from 'semver/functions/satisfies';
12
10
  /** Resolver Type Utils **/
13
11
 
@@ -45,42 +43,6 @@ export function isAwsLambdaResolver(resolver) {
45
43
  export function isUtilResolver(resolver) {
46
44
  return utilResolver.properties.name.enum.includes(resolver.name);
47
45
  }
48
-
49
- function createVersionPredicate(schemaVersion) {
50
- const expectedSemver = coerce(schemaVersion);
51
- return projectSchema => {
52
- const schemaSemver = coerce(projectSchema.schemaVersion ?? '1');
53
- return Boolean(expectedSemver && schemaSemver && eq(schemaSemver, expectedSemver));
54
- };
55
- }
56
- /** Project Schema Version Utils **/
57
-
58
-
59
- export const isProjectSchemaV1 = createVersionPredicate('1');
60
- export const isProjectSchemaV3 = createVersionPredicate('3');
61
- export const isProjectSchemaV3_1 = createVersionPredicate('3.1.0');
62
- export const isProjectSchemaV3_2 = createVersionPredicate('3.2.0');
63
- export const isProjectSchemaV3_3 = createVersionPredicate('3.3.0');
64
- export const isProjectSchemaV3_4 = createVersionPredicate('3.4.0');
65
- export const isProjectSchemaV3_5 = createVersionPredicate('3.5.0');
66
- export const isProjectSchemaV3_5_1 = createVersionPredicate('3.5.1');
67
- export const isProjectSchemaV3_6 = createVersionPredicate('3.6.0');
68
- export const isProjectSchemaV3_7 = createVersionPredicate('3.7.0');
69
- export const isProjectSchemaV3_8 = createVersionPredicate('3.8.0');
70
- export const isProjectSchemaV3_9 = createVersionPredicate('3.9.0');
71
- export const isProjectSchemaV3_10 = createVersionPredicate('3.10.0');
72
- export const isProjectSchemaV3_11 = createVersionPredicate('3.11.0');
73
- export const isProjectSchemaV3_12 = createVersionPredicate('3.12.0');
74
- export const isProjectSchemaV3_12_1 = createVersionPredicate('3.12.1');
75
- export const isProjectSchemaV3_12_2 = createVersionPredicate('3.12.2');
76
- export const isProjectSchemaV3_12_3 = createVersionPredicate('3.12.3');
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');
80
- export const isLatestProjectSchema = createVersionPredicate(CURRENT_SCHEMA_VERSION);
81
- export function isV1XSchema(maybeSchema) {
82
- return isRecord(maybeSchema) && isString(maybeSchema.projectId) && isRecord(maybeSchema.contentTypes) && (isUndefined(maybeSchema.schemaVersion) || maybeSchema.schemaVersion === '1' || maybeSchema.schemaVersion === '1.0.0');
83
- }
84
46
  export function isV3XSchema(maybeSchema) {
85
47
  if (!isRecord(maybeSchema) || !isString(maybeSchema.projectId) || !isString(maybeSchema.schemaVersion)) {
86
48
  return false;
@@ -89,18 +51,6 @@ export function isV3XSchema(maybeSchema) {
89
51
  const version = coerce(maybeSchema.schemaVersion);
90
52
  return version ? satisfies(version, '^3.0.0') : false;
91
53
  }
92
- /**
93
- * Determine whether a given project schema is any project schema.
94
- */
95
-
96
- export function isAnyProjectSchema(value) {
97
- if (!isRecord(value)) {
98
- return false;
99
- }
100
-
101
- const maybeSchema = value;
102
- return isRecord(value) && isString(maybeSchema.projectId) && (isV1XSchema(maybeSchema) || isV3XSchema(maybeSchema));
103
- }
104
54
  export function isProjectSchemaWithServices(schema) {
105
55
  return typeof schema.dataKey !== 'undefined' && typeof schema.services !== 'undefined';
106
56
  }
package/es/validate.js CHANGED
@@ -290,22 +290,6 @@ function validateIndexedShapeConfig(projectSchema, shapeName, config) {
290
290
  message: `Invalid query "${list.name}"`
291
291
  });
292
292
  }
293
-
294
- const shape = projectSchema.shapes[shapeName]; // Resolved shapes are not checked
295
-
296
- if (shape && list.ignoreFields) {
297
- for (const fieldName of list.ignoreFields) {
298
- var _properties;
299
-
300
- if (((_properties = shape.schema.properties) === null || _properties === void 0 ? void 0 : _properties[fieldName]) === undefined) {
301
- errors.push({
302
- path: ['indexedShapes', shapeName, 'queries', 'list', 'ignoreFields'],
303
- type: 'notFound',
304
- message: `Invalid property "${fieldName}" on shape "${shapeName}"`
305
- });
306
- }
307
- }
308
- }
309
293
  }
310
294
 
311
295
  return errors;
package/lib/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export type { User } from './user-schema';
3
3
  export * from './content-schema-transform';
4
4
  export * from './get-is-leaf';
5
5
  export * from './project-schema';
6
+ export * from './project-schema/migrate';
6
7
  export * from './schema-util';
7
8
  export * from './services';
8
9
  export * from './template-shapes';
@@ -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;AAChC,cAAc,WAAW,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,0BAA0B,CAAC;AACzC,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
@@ -55,6 +55,20 @@ Object.keys(_projectSchema).forEach(function (key) {
55
55
  });
56
56
  });
57
57
 
58
+ var _migrate = require("./project-schema/migrate");
59
+
60
+ Object.keys(_migrate).forEach(function (key) {
61
+ if (key === "default" || key === "__esModule") return;
62
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
63
+ if (key in exports && exports[key] === _migrate[key]) return;
64
+ Object.defineProperty(exports, key, {
65
+ enumerable: true,
66
+ get: function () {
67
+ return _migrate[key];
68
+ }
69
+ });
70
+ });
71
+
58
72
  var _schemaUtil = require("./schema-util");
59
73
 
60
74
  Object.keys(_schemaUtil).forEach(function (key) {
@@ -1,7 +1,26 @@
1
- import type { ProjectSchema, AnyProjectSchema } from '../project-schema';
2
- import type { ProjectSchemaMigrationContext } from './types';
1
+ export declare const migrateTo: {
2
+ 'v3.0.0': import("./types").MigrateFunction<import("..").ProjectSchemaV1_0_0, import("..").ProjectSchemaV3_0_0>;
3
+ 'v3.1.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_0_0, import("..").ProjectSchemaV3_1_0>;
4
+ 'v3.2.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_1_0, import("..").ProjectSchemaV3_2_0>;
5
+ 'v3.3.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_2_0, import("..").ProjectSchemaV3_3_0>;
6
+ 'v3.4.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_3_0, import("..").ProjectSchemaV3_4_0>;
7
+ 'v3.5.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_4_0, import("..").ProjectSchemaV3_5_0>;
8
+ 'v3.5.1': import("./types").MigrateFunction<import("..").ProjectSchemaV3_5_0, import("..").ProjectSchemaV3_5_1>;
9
+ 'v3.6.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_5_1, import("..").ProjectSchemaV3_6_0>;
10
+ 'v3.7.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_6_0, import("..").ProjectSchemaV3_7_0>;
11
+ 'v3.8.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_7_0, import("..").ProjectSchemaV3_8_0>;
12
+ 'v3.9.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_8_0, import("..").ProjectSchemaV3_9_0>;
13
+ 'v3.10.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_9_0, import("..").ProjectSchemaV3_10_0>;
14
+ 'v3.11.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_10_0, import("..").ProjectSchemaV3_11_0>;
15
+ 'v3.12.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_11_0, import("..").ProjectSchemaV3_12_0>;
16
+ 'v3.12.1': import("./types").MigrateFunction<import("..").ProjectSchemaV3_12_0, import("..").ProjectSchemaV3_12_1>;
17
+ 'v3.12.2': import("./types").MigrateFunction<import("..").ProjectSchemaV3_12_1, import("..").ProjectSchemaV3_12_2>;
18
+ 'v3.12.3': import("./types").MigrateFunction<import("..").ProjectSchemaV3_12_2, import("..").ProjectSchemaV3_12_3>;
19
+ 'v3.13.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_12_3, import("..").ProjectSchemaV3_13_0>;
20
+ 'v3.14.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_13_0, import("..").ProjectSchemaV3_14_0>;
21
+ 'v3.15.0': import("./types").MigrateFunction<import("..").ProjectSchemaV3_14_0, import("..").ProjectSchemaV3_15_0>;
22
+ };
3
23
  export * from './utils';
4
24
  export declare const listTypePrefix = "PaginatedList";
5
- export declare function migrateToLatestProjectSchema(context: ProjectSchemaMigrationContext, projectSchema: AnyProjectSchema): Promise<ProjectSchema>;
6
- export declare function ensureLatest(context: ProjectSchemaMigrationContext, schema?: AnyProjectSchema): Promise<ProjectSchema | undefined>;
25
+ export type { ProjectSchemaMigrationContext } from './types';
7
26
  //# sourceMappingURL=index.d.ts.map
@@ -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;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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migration/index.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;CAqBrB,CAAC;AAEF,cAAc,SAAS,CAAC;AACxB,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,YAAY,EAAC,6BAA6B,EAAC,MAAM,SAAS,CAAC"}
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- listTypePrefix: true,
8
- migrateToLatestProjectSchema: true,
9
- ensureLatest: true
7
+ migrateTo: true,
8
+ listTypePrefix: true
10
9
  };
11
- exports.ensureLatest = ensureLatest;
12
- exports.listTypePrefix = void 0;
13
- exports.migrateToLatestProjectSchema = migrateToLatestProjectSchema;
14
-
15
- var _utils = require("../types/utils");
10
+ exports.migrateTo = exports.listTypePrefix = void 0;
16
11
 
17
12
  var _v = _interopRequireDefault(require("./to/v3.0.0"));
18
13
 
@@ -54,118 +49,44 @@ var _v19 = _interopRequireDefault(require("./to/v3.14.0"));
54
49
 
55
50
  var _v20 = _interopRequireDefault(require("./to/v3.15.0"));
56
51
 
57
- var _utils2 = require("./utils");
52
+ var _utils = require("./utils");
58
53
 
59
- Object.keys(_utils2).forEach(function (key) {
54
+ Object.keys(_utils).forEach(function (key) {
60
55
  if (key === "default" || key === "__esModule") return;
61
56
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
62
- if (key in exports && exports[key] === _utils2[key]) return;
57
+ if (key in exports && exports[key] === _utils[key]) return;
63
58
  Object.defineProperty(exports, key, {
64
59
  enumerable: true,
65
60
  get: function () {
66
- return _utils2[key];
61
+ return _utils[key];
67
62
  }
68
63
  });
69
64
  });
70
65
 
71
66
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
72
67
 
73
- const listTypePrefix = 'PaginatedList'; // eslint-disable-next-line complexity
74
-
75
- exports.listTypePrefix = listTypePrefix;
76
-
77
- async function migrateToLatestProjectSchema(context, projectSchema) {
78
- if (projectSchema.schemaVersion === '4.0.0') {
79
- throw new Error('You are using an unreleased schema version. Migration is not possible');
80
- }
81
-
82
- if ((0, _utils.isProjectSchemaV1)(projectSchema)) {
83
- projectSchema = (0, _v.default)(projectSchema);
84
- }
85
-
86
- if ((0, _utils.isProjectSchemaV3)(projectSchema)) {
87
- projectSchema = await (0, _v2.default)(context, projectSchema);
88
- }
89
-
90
- if ((0, _utils.isProjectSchemaV3_1)(projectSchema)) {
91
- projectSchema = (0, _v3.default)(projectSchema);
92
- }
93
-
94
- if ((0, _utils.isProjectSchemaV3_2)(projectSchema)) {
95
- projectSchema = await (0, _v4.default)(context, projectSchema);
96
- }
97
-
98
- if ((0, _utils.isProjectSchemaV3_3)(projectSchema)) {
99
- projectSchema = (0, _v5.default)(projectSchema);
100
- }
101
-
102
- if ((0, _utils.isProjectSchemaV3_4)(projectSchema)) {
103
- projectSchema = (0, _v6.default)(projectSchema);
104
- }
105
-
106
- if ((0, _utils.isProjectSchemaV3_5)(projectSchema)) {
107
- projectSchema = (0, _v7.default)(projectSchema);
108
- }
109
-
110
- if ((0, _utils.isProjectSchemaV3_5_1)(projectSchema)) {
111
- projectSchema = (0, _v8.default)(projectSchema);
112
- }
113
-
114
- if ((0, _utils.isProjectSchemaV3_6)(projectSchema)) {
115
- projectSchema = (0, _v9.default)(projectSchema);
116
- }
117
-
118
- if ((0, _utils.isProjectSchemaV3_7)(projectSchema)) {
119
- projectSchema = (0, _v10.default)(projectSchema);
120
- }
121
-
122
- if ((0, _utils.isProjectSchemaV3_8)(projectSchema)) {
123
- projectSchema = (0, _v11.default)(projectSchema);
124
- }
125
-
126
- if ((0, _utils.isProjectSchemaV3_9)(projectSchema)) {
127
- projectSchema = (0, _v12.default)(projectSchema);
128
- }
129
-
130
- if ((0, _utils.isProjectSchemaV3_10)(projectSchema)) {
131
- projectSchema = (0, _v13.default)(context, projectSchema);
132
- }
133
-
134
- if ((0, _utils.isProjectSchemaV3_11)(projectSchema)) {
135
- projectSchema = (0, _v14.default)(projectSchema);
136
- }
137
-
138
- if ((0, _utils.isProjectSchemaV3_12)(projectSchema)) {
139
- projectSchema = (0, _v15.default)(projectSchema);
140
- }
141
-
142
- if ((0, _utils.isProjectSchemaV3_12_1)(projectSchema)) {
143
- projectSchema = (0, _v16.default)(projectSchema);
144
- }
145
-
146
- if ((0, _utils.isProjectSchemaV3_12_2)(projectSchema)) {
147
- projectSchema = (0, _v17.default)(projectSchema);
148
- }
149
-
150
- if ((0, _utils.isProjectSchemaV3_12_3)(projectSchema)) {
151
- projectSchema = (0, _v18.default)(projectSchema);
152
- }
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
-
162
- return projectSchema;
163
- }
164
-
165
- async function ensureLatest(context, schema) {
166
- if (!schema || (0, _utils.isLatestProjectSchema)(schema)) {
167
- return schema;
168
- }
169
-
170
- return migrateToLatestProjectSchema(context, schema);
171
- }
68
+ const migrateTo = {
69
+ 'v3.0.0': _v.default,
70
+ 'v3.1.0': _v2.default,
71
+ 'v3.2.0': _v3.default,
72
+ 'v3.3.0': _v4.default,
73
+ 'v3.4.0': _v5.default,
74
+ 'v3.5.0': _v6.default,
75
+ 'v3.5.1': _v7.default,
76
+ 'v3.6.0': _v8.default,
77
+ 'v3.7.0': _v9.default,
78
+ 'v3.8.0': _v10.default,
79
+ 'v3.9.0': _v11.default,
80
+ 'v3.10.0': _v12.default,
81
+ 'v3.11.0': _v13.default,
82
+ 'v3.12.0': _v14.default,
83
+ 'v3.12.1': _v15.default,
84
+ 'v3.12.2': _v16.default,
85
+ 'v3.12.3': _v17.default,
86
+ 'v3.13.0': _v18.default,
87
+ 'v3.14.0': _v19.default,
88
+ 'v3.15.0': _v20.default
89
+ };
90
+ exports.migrateTo = migrateTo;
91
+ const listTypePrefix = 'PaginatedList';
92
+ exports.listTypePrefix = listTypePrefix;
@@ -1,4 +1,5 @@
1
1
  import type { ProjectSchemaV1_0_0, ProjectSchemaV3_0_0 } from '../../project-schema';
2
- declare function migrateToV3_0_0(projectSchema: ProjectSchemaV1_0_0): ProjectSchemaV3_0_0;
3
- export default migrateToV3_0_0;
2
+ import type { MigrateFunction } from '../types';
3
+ declare const migrate: MigrateFunction<ProjectSchemaV1_0_0, ProjectSchemaV3_0_0>;
4
+ export default migrate;
4
5
  //# sourceMappingURL=v3.0.0.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v3.0.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.0.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,mBAAmB,EASpB,MAAM,sBAAsB,CAAC;AAoO9B,iBAAS,eAAe,CAAC,aAAa,EAAE,mBAAmB,GAAG,mBAAmB,CAuBhF;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"v3.0.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.0.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,mBAAmB,EASpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAoO9C,QAAA,MAAM,OAAO,EAAE,eAAe,CAAC,mBAAmB,EAAE,mBAAmB,CAuBtE,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -247,7 +247,7 @@ function contentTypeToShape(contentType, contentTypeId) {
247
247
  };
248
248
  }
249
249
 
250
- function migrateToV3_0_0(projectSchema) {
250
+ const migrate = async (_, projectSchema) => {
251
251
  const {
252
252
  contentTypes,
253
253
  created,
@@ -272,7 +272,7 @@ function migrateToV3_0_0(projectSchema) {
272
272
  shapes,
273
273
  forms
274
274
  });
275
- }
275
+ };
276
276
 
277
- var _default = migrateToV3_0_0;
277
+ var _default = migrate;
278
278
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  import type { ProjectSchemaV3_0_0, ProjectSchemaV3_1_0 } from '../../project-schema';
2
- import type { ProjectSchemaMigrationContext } from '../types';
3
- declare function migrateToV3_1(context: ProjectSchemaMigrationContext, projectSchema: ProjectSchemaV3_0_0): Promise<ProjectSchemaV3_1_0>;
4
- export default migrateToV3_1;
2
+ import type { MigrateFunction } from '../types';
3
+ declare const migrate: MigrateFunction<ProjectSchemaV3_0_0, ProjectSchemaV3_1_0>;
4
+ export default migrate;
5
5
  //# sourceMappingURL=v3.1.0.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v3.1.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.1.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EAIpB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,UAAU,CAAC;AAiM5D,iBAAe,aAAa,CAC1B,OAAO,EAAE,6BAA6B,EACtC,aAAa,EAAE,mBAAmB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAgC9B;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"v3.1.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.1.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EAIpB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAiM9C,QAAA,MAAM,OAAO,EAAE,eAAe,CAAC,mBAAmB,EAAE,mBAAmB,CAgCtE,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -199,7 +199,7 @@ function mapAuthType(authType, auth) {
199
199
  return 'unknown';
200
200
  }
201
201
 
202
- async function migrateToV3_1(context, projectSchema) {
202
+ const migrate = async (context, projectSchema) => {
203
203
  const {
204
204
  encryptFn,
205
205
  decryptFn
@@ -227,7 +227,7 @@ async function migrateToV3_1(context, projectSchema) {
227
227
  services,
228
228
  schemaVersion: '3.1.0'
229
229
  });
230
- }
230
+ };
231
231
 
232
- var _default = migrateToV3_1;
232
+ var _default = migrate;
233
233
  exports.default = _default;
@@ -1,4 +1,5 @@
1
1
  import type { ProjectSchemaV3_9_0, ProjectSchemaV3_10_0 } from '../../project-schema';
2
- declare function migrateToV3_10(projectSchema: ProjectSchemaV3_9_0): ProjectSchemaV3_10_0;
3
- export default migrateToV3_10;
2
+ import type { MigrateFunction } from '../types';
3
+ declare const migrate: MigrateFunction<ProjectSchemaV3_9_0, ProjectSchemaV3_10_0>;
4
+ export default migrate;
4
5
  //# sourceMappingURL=v3.10.0.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v3.10.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.10.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EAOrB,MAAM,sBAAsB,CAAC;AA2E9B,iBAAS,cAAc,CAAC,aAAa,EAAE,mBAAmB,GAAG,oBAAoB,CAWhF;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"v3.10.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.10.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EAOrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AA2E9C,QAAA,MAAM,OAAO,EAAE,eAAe,CAAC,mBAAmB,EAAE,oBAAoB,CAWvE,CAAC;AAEF,eAAe,OAAO,CAAC"}