@takeshape/schema 9.80.4 → 9.81.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/dist/api-version.js +0 -9
  2. package/dist/builtin-schema.js +0 -5
  3. package/dist/content-schema-transform.js +4 -52
  4. package/dist/create-input-schema.js +7 -19
  5. package/dist/enum.js +0 -3
  6. package/dist/flatten-templates.js +0 -11
  7. package/dist/get-is-leaf.js +8 -18
  8. package/dist/index.js +0 -58
  9. package/dist/interfaces.js +2 -26
  10. package/dist/layers/layers.js +23 -103
  11. package/dist/layers/refs.js +26 -69
  12. package/dist/layers/type-utils.js +11 -43
  13. package/dist/layers/visitor.js +0 -6
  14. package/dist/migration/index.js +0 -51
  15. package/dist/migration/to/v3.0.0.js +31 -45
  16. package/dist/migration/to/v3.1.0.js +15 -41
  17. package/dist/migration/to/v3.10.0.js +6 -20
  18. package/dist/migration/to/v3.11.0.js +8 -20
  19. package/dist/migration/to/v3.12.0.js +2 -3
  20. package/dist/migration/to/v3.12.1.js +2 -3
  21. package/dist/migration/to/v3.12.2.js +2 -3
  22. package/dist/migration/to/v3.12.3.js +16 -21
  23. package/dist/migration/to/v3.13.0.js +2 -7
  24. package/dist/migration/to/v3.14.0.js +2 -3
  25. package/dist/migration/to/v3.15.0.js +2 -3
  26. package/dist/migration/to/v3.16.0.js +2 -3
  27. package/dist/migration/to/v3.17.0.js +4 -9
  28. package/dist/migration/to/v3.17.1.js +2 -3
  29. package/dist/migration/to/v3.18.0.js +2 -15
  30. package/dist/migration/to/v3.18.1.js +2 -7
  31. package/dist/migration/to/v3.18.2.js +8 -10
  32. package/dist/migration/to/v3.19.0.js +2 -3
  33. package/dist/migration/to/v3.2.0.js +2 -3
  34. package/dist/migration/to/v3.20.0.js +10 -11
  35. package/dist/migration/to/v3.21.0.js +2 -3
  36. package/dist/migration/to/v3.22.0.js +4 -9
  37. package/dist/migration/to/v3.23.0.js +2 -3
  38. package/dist/migration/to/v3.24.0.js +2 -3
  39. package/dist/migration/to/v3.25.0.js +2 -3
  40. package/dist/migration/to/v3.26.0.js +2 -3
  41. package/dist/migration/to/v3.27.0.js +2 -3
  42. package/dist/migration/to/v3.28.0.js +2 -3
  43. package/dist/migration/to/v3.29.0.js +2 -3
  44. package/dist/migration/to/v3.3.0.js +3 -4
  45. package/dist/migration/to/v3.30.0.js +2 -3
  46. package/dist/migration/to/v3.31.0.js +2 -12
  47. package/dist/migration/to/v3.32.0.js +12 -22
  48. package/dist/migration/to/v3.33.0.js +2 -3
  49. package/dist/migration/to/v3.34.0.js +14 -43
  50. package/dist/migration/to/v3.35.0.js +2 -3
  51. package/dist/migration/to/v3.36.0.js +6 -10
  52. package/dist/migration/to/v3.37.0.js +2 -3
  53. package/dist/migration/to/v3.38.0.js +2 -3
  54. package/dist/migration/to/v3.39.0.js +6 -13
  55. package/dist/migration/to/v3.4.0.js +2 -3
  56. package/dist/migration/to/v3.5.0.js +2 -3
  57. package/dist/migration/to/v3.5.1.js +2 -3
  58. package/dist/migration/to/v3.6.0.js +2 -3
  59. package/dist/migration/to/v3.7.0.js +2 -3
  60. package/dist/migration/to/v3.8.0.js +2 -3
  61. package/dist/migration/to/v3.9.0.js +8 -24
  62. package/dist/migration/utils.js +0 -2
  63. package/dist/mocks.js +9 -12
  64. package/dist/models/project-schema.js +0 -34
  65. package/dist/models/query.js +0 -9
  66. package/dist/models/service.js +0 -8
  67. package/dist/models/shape.js +0 -29
  68. package/dist/project-schema/index.js +1 -105
  69. package/dist/project-schema/migrate.js +1 -54
  70. package/dist/refs.js +39 -159
  71. package/dist/relationships.js +13 -57
  72. package/dist/scalars.js +0 -1
  73. package/dist/schema-transform.js +0 -11
  74. package/dist/schema-util.js +75 -271
  75. package/dist/schemas/index.js +0 -64
  76. package/dist/services.js +24 -44
  77. package/dist/taxonomies.js +0 -13
  78. package/dist/template-shapes/index.js +1 -8
  79. package/dist/template-shapes/templates.js +9 -40
  80. package/dist/template-shapes/types.js +4 -5
  81. package/dist/template-shapes/where.js +14 -110
  82. package/dist/types/index.js +0 -4
  83. package/dist/types/types.js +41 -13
  84. package/dist/types/utils.js +15 -89
  85. package/dist/unions.js +8 -38
  86. package/dist/util/api-indexing.js +2 -19
  87. package/dist/util/detect-cycles.js +2 -16
  88. package/dist/util/find-shape-at-path.js +1 -15
  89. package/dist/util/form-config.js +6 -23
  90. package/dist/util/get-conflicting-properties.js +7 -17
  91. package/dist/util/get-return-shape.js +0 -11
  92. package/dist/util/has-arg.js +0 -6
  93. package/dist/util/index.js +0 -18
  94. package/dist/util/merge.js +28 -74
  95. package/dist/util/patch-schema.js +5 -13
  96. package/dist/validate.js +15 -234
  97. package/dist/versions.js +0 -2
  98. package/dist/workflows.js +0 -15
  99. package/es/api-version.js +0 -4
  100. package/es/content-schema-transform.js +4 -38
  101. package/es/create-input-schema.js +7 -14
  102. package/es/enum.js +0 -2
  103. package/es/flatten-templates.js +0 -4
  104. package/es/get-is-leaf.js +8 -13
  105. package/es/index.js +1 -0
  106. package/es/interfaces.js +2 -14
  107. package/es/layers/layers.js +23 -90
  108. package/es/layers/refs.js +22 -45
  109. package/es/layers/type-utils.js +11 -16
  110. package/es/layers/visitor.js +0 -3
  111. package/es/migration/to/v3.0.0.js +31 -38
  112. package/es/migration/to/v3.1.0.js +16 -34
  113. package/es/migration/to/v3.10.0.js +6 -17
  114. package/es/migration/to/v3.11.0.js +8 -18
  115. package/es/migration/to/v3.12.0.js +2 -2
  116. package/es/migration/to/v3.12.1.js +2 -2
  117. package/es/migration/to/v3.12.2.js +2 -2
  118. package/es/migration/to/v3.12.3.js +16 -19
  119. package/es/migration/to/v3.13.0.js +2 -4
  120. package/es/migration/to/v3.14.0.js +2 -2
  121. package/es/migration/to/v3.15.0.js +2 -2
  122. package/es/migration/to/v3.16.0.js +2 -2
  123. package/es/migration/to/v3.17.0.js +4 -4
  124. package/es/migration/to/v3.17.1.js +2 -2
  125. package/es/migration/to/v3.18.0.js +2 -10
  126. package/es/migration/to/v3.18.1.js +2 -3
  127. package/es/migration/to/v3.18.2.js +8 -8
  128. package/es/migration/to/v3.19.0.js +2 -2
  129. package/es/migration/to/v3.2.0.js +2 -2
  130. package/es/migration/to/v3.20.0.js +10 -9
  131. package/es/migration/to/v3.21.0.js +2 -2
  132. package/es/migration/to/v3.22.0.js +4 -6
  133. package/es/migration/to/v3.23.0.js +2 -2
  134. package/es/migration/to/v3.24.0.js +2 -2
  135. package/es/migration/to/v3.25.0.js +2 -2
  136. package/es/migration/to/v3.26.0.js +2 -2
  137. package/es/migration/to/v3.27.0.js +2 -2
  138. package/es/migration/to/v3.28.0.js +2 -2
  139. package/es/migration/to/v3.29.0.js +2 -2
  140. package/es/migration/to/v3.3.0.js +3 -3
  141. package/es/migration/to/v3.30.0.js +2 -2
  142. package/es/migration/to/v3.31.0.js +2 -5
  143. package/es/migration/to/v3.32.0.js +12 -21
  144. package/es/migration/to/v3.33.0.js +2 -2
  145. package/es/migration/to/v3.34.0.js +16 -32
  146. package/es/migration/to/v3.35.0.js +2 -2
  147. package/es/migration/to/v3.36.0.js +6 -8
  148. package/es/migration/to/v3.37.0.js +2 -2
  149. package/es/migration/to/v3.38.0.js +2 -2
  150. package/es/migration/to/v3.39.0.js +6 -12
  151. package/es/migration/to/v3.4.0.js +2 -2
  152. package/es/migration/to/v3.5.0.js +2 -2
  153. package/es/migration/to/v3.5.1.js +2 -2
  154. package/es/migration/to/v3.6.0.js +2 -2
  155. package/es/migration/to/v3.7.0.js +2 -2
  156. package/es/migration/to/v3.8.0.js +2 -2
  157. package/es/migration/to/v3.9.0.js +8 -20
  158. package/es/mocks.js +10 -6
  159. package/es/models/project-schema.js +0 -26
  160. package/es/models/query.js +0 -7
  161. package/es/models/service.js +0 -6
  162. package/es/models/shape.js +1 -25
  163. package/es/project-schema/index.js +0 -5
  164. package/es/project-schema/migrate.js +3 -51
  165. package/es/refs.js +40 -96
  166. package/es/relationships.js +14 -42
  167. package/es/schema-transform.js +0 -7
  168. package/es/schema-util.js +75 -180
  169. package/es/services.js +18 -27
  170. package/es/taxonomies.js +0 -9
  171. package/es/template-shapes/index.js +1 -4
  172. package/es/template-shapes/templates.js +9 -18
  173. package/es/template-shapes/types.js +3 -4
  174. package/es/template-shapes/where.js +14 -94
  175. package/es/types/types.js +43 -10
  176. package/es/types/utils.js +16 -24
  177. package/es/unions.js +8 -22
  178. package/es/util/api-indexing.js +2 -12
  179. package/es/util/detect-cycles.js +2 -14
  180. package/es/util/find-shape-at-path.js +2 -12
  181. package/es/util/form-config.js +7 -19
  182. package/es/util/get-conflicting-properties.js +8 -14
  183. package/es/util/get-return-shape.js +0 -8
  184. package/es/util/has-arg.js +0 -3
  185. package/es/util/merge.js +28 -55
  186. package/es/util/patch-schema.js +5 -7
  187. package/es/validate.js +15 -194
  188. package/es/workflows.js +0 -6
  189. package/package.json +5 -5
@@ -4,7 +4,6 @@ import omit from 'lodash/omit';
4
4
  import { ShapeModel } from './shape';
5
5
  import { QueryModel } from './query';
6
6
  import { ServiceConfig } from './service';
7
-
8
7
  /**
9
8
  * Model object representing a ProjectSchema.
10
9
  * Intended to help make it easier to find the right utils
@@ -12,105 +11,80 @@ import { ServiceConfig } from './service';
12
11
  */
13
12
  export class ProjectSchema {
14
13
  _cache = {};
15
-
16
14
  constructor(unfilteredProjectSchema) {
17
15
  // You can pass a ProjectSchemaCompat in here, but we remove its values so they don't get passed through to getJSON.
18
16
  // If you need to use this metadata it should be stored separately.
19
17
  this._projectSchemaJSON = omit(unfilteredProjectSchema, ['created', 'updated', 'version']);
20
18
  }
21
-
22
19
  get json() {
23
20
  return this._projectSchemaJSON;
24
21
  }
25
-
26
22
  get projectId() {
27
23
  return this.json.projectId;
28
24
  }
29
-
30
25
  get $schema() {
31
26
  return this.json.$schema;
32
27
  }
33
-
34
28
  get author() {
35
29
  return this.json.author;
36
30
  }
37
-
38
31
  getShapeByName(shapeName) {
39
32
  const shapeJSON = getShape(this.json, shapeName);
40
-
41
33
  if (!shapeJSON) {
42
34
  return undefined;
43
35
  }
44
-
45
36
  const shapeRefItem = shapeToRefItem(this.json, shapeJSON);
46
37
  return new ShapeModel(this, shapeRefItem);
47
38
  }
48
-
49
39
  getShapeById(shapeId) {
50
40
  const shapeJSON = getShapeById(this.json, shapeId);
51
-
52
41
  if (!shapeJSON) {
53
42
  return undefined;
54
43
  }
55
-
56
44
  const shapeRefItem = shapeToRefItem(this.json, shapeJSON);
57
45
  return new ShapeModel(this, shapeRefItem);
58
46
  }
59
-
60
47
  getShapeByRef(shapeRef) {
61
48
  return new ShapeModel(this, shapeRef);
62
49
  }
63
-
64
50
  get shapes() {
65
51
  this._cache.shapes = this._cache.shapes ?? Object.keys(this.json.shapes).map(name => new ShapeModel(this, shapeNameToRef(this.json, name)));
66
52
  return this._cache.shapes;
67
53
  }
68
-
69
54
  get refs() {
70
55
  this._cache.refs = this._cache.refs ?? getAllRefs(this.json);
71
56
  return this._cache.refs;
72
57
  }
73
-
74
58
  getQueryByName(queryName) {
75
59
  return new QueryModel(this, 'query', queryName);
76
60
  }
77
-
78
61
  get queries() {
79
62
  this._cache.queries = this._cache.queries ?? Object.keys(this.json.queries).map(name => new QueryModel(this, 'query', name));
80
63
  return this._cache.queries;
81
64
  }
82
-
83
65
  getMutationByName(mutationName) {
84
66
  return new QueryModel(this, 'mutation', mutationName);
85
67
  }
86
-
87
68
  get mutations() {
88
69
  this._cache.mutations = Object.keys(this.json.mutations).map(name => new QueryModel(this, 'mutation', name));
89
70
  return this._cache.mutations;
90
71
  }
91
-
92
72
  getServiceById(serviceId) {
93
73
  return new ServiceConfig(this, serviceId);
94
74
  }
95
-
96
75
  atRefToRefItem(atRef, template) {
97
76
  return atRefToRefItem(this.json, atRef, template);
98
77
  }
99
-
100
78
  refItemToShape(refItem) {
101
79
  return new ShapeModel(this, refItem);
102
80
  }
103
-
104
81
  getRef(refSchema) {
105
82
  return getRef(this.json, refSchema);
106
83
  }
107
-
108
84
  shapeNameToRef(shapeName) {
109
85
  return shapeNameToRef(this.json, shapeName);
110
86
  }
111
-
112
87
  shapeNameToRefItem(shapeName) {
113
88
  return shapeNameToRefItem(this.json, shapeName);
114
89
  }
115
-
116
90
  }
@@ -7,29 +7,22 @@ export class QueryModel {
7
7
  this._queryName = _queryName;
8
8
  this._rawQuery = projectSchemaModel.json[_queryType === 'query' ? 'queries' : 'mutations'][_queryName];
9
9
  }
10
-
11
10
  get queryType() {
12
11
  return this._queryType;
13
12
  }
14
-
15
13
  get name() {
16
14
  return this._queryName;
17
15
  }
18
-
19
16
  get json() {
20
17
  return this._rawQuery;
21
18
  }
22
-
23
19
  get description() {
24
20
  return this.json.description;
25
21
  }
26
-
27
22
  get resolver() {
28
23
  return this.json.resolver;
29
24
  }
30
-
31
25
  get returnShape() {
32
26
  return this.json.shape;
33
27
  }
34
-
35
28
  }
@@ -4,22 +4,16 @@
4
4
  export class ServiceConfig {
5
5
  constructor(projectSchemaModel, _serviceId) {
6
6
  var _projectSchemaModel$j;
7
-
8
7
  this._serviceId = _serviceId;
9
-
10
8
  if (!((_projectSchemaModel$j = projectSchemaModel.json.services) !== null && _projectSchemaModel$j !== void 0 && _projectSchemaModel$j[_serviceId])) {
11
9
  throw new Error(`Could not create service model for ${_serviceId}`);
12
10
  }
13
-
14
11
  this._storedServiceConfig = projectSchemaModel.json.services[_serviceId];
15
12
  }
16
-
17
13
  get id() {
18
14
  return this._serviceId;
19
15
  }
20
-
21
16
  get json() {
22
17
  return this._storedServiceConfig;
23
18
  }
24
-
25
19
  }
@@ -1,105 +1,81 @@
1
1
  import { refItemToShape } from '../refs';
2
2
  import { createSchemaPropertyAccessor, createSchemaPropertyList, getShapeByRef, isCachedShape, isModelShape } from '../schema-util';
3
3
  import { isInterfaceShape } from '../interfaces';
4
+
4
5
  /**
5
6
  * Create a shape model from either a ref item or a ref string such as `rick:Character`
6
7
  */
7
-
8
8
  export class ShapeModel {
9
9
  constructor(_projectSchemaModel, refArg) {
10
10
  this._projectSchemaModel = _projectSchemaModel;
11
-
12
11
  if (typeof refArg === 'string') {
13
12
  const rawShape = getShapeByRef(_projectSchemaModel.json, refArg);
14
-
15
13
  if (!rawShape) {
16
14
  throw new Error(`Error creating shape model: ${refArg} is not in project schema`);
17
15
  }
18
-
19
16
  this._rawShape = rawShape;
20
17
  this._shapeRefItem = _projectSchemaModel.atRefToRefItem(refArg);
21
18
  this._shapeAtRef = refArg;
22
19
  } else {
23
20
  const rawShape = refItemToShape(_projectSchemaModel.json, refArg);
24
-
25
21
  if (!rawShape) {
26
22
  throw new Error(`Error creating shape model: ref item argument could not be resolved to a shape`);
27
23
  }
28
-
29
24
  this._rawShape = rawShape;
30
25
  this._shapeRefItem = refArg;
31
26
  this._shapeAtRef = `${refArg.serviceKey}:${refArg.typeName}`;
32
27
  }
33
28
  }
34
-
35
29
  get json() {
36
30
  return this._rawShape;
37
31
  }
38
-
39
32
  get id() {
40
33
  return this._rawShape.id;
41
34
  }
42
-
43
35
  get name() {
44
36
  return this._rawShape.name;
45
37
  }
46
-
47
38
  get title() {
48
39
  return this._rawShape.title;
49
40
  }
50
-
51
41
  get description() {
52
42
  return this._rawShape.description;
53
43
  }
54
-
55
44
  get schema() {
56
45
  return this._rawShape.schema;
57
46
  }
58
-
59
47
  get schemaPropertyList() {
60
48
  return createSchemaPropertyList(this._projectSchemaModel.json, this._rawShape);
61
49
  }
62
-
63
50
  get schemaPropertyAccessor() {
64
51
  return createSchemaPropertyAccessor(this._projectSchemaModel.json, this._rawShape);
65
52
  }
66
-
67
53
  get refString() {
68
54
  return this._shapeAtRef;
69
55
  }
70
-
71
56
  get refItem() {
72
57
  return this._shapeRefItem;
73
58
  }
74
-
75
59
  get serviceId() {
76
60
  return this._shapeRefItem.serviceKey;
77
61
  }
78
-
79
62
  get modelType() {
80
63
  var _this$_rawShape$model;
81
-
82
64
  return (_this$_rawShape$model = this._rawShape.model) === null || _this$_rawShape$model === void 0 ? void 0 : _this$_rawShape$model.type;
83
65
  }
84
-
85
66
  get interfaces() {
86
67
  return this._rawShape.interfaces;
87
68
  }
88
-
89
69
  get isModel() {
90
70
  return isModelShape(this._rawShape);
91
71
  }
92
-
93
72
  get isCached() {
94
73
  return isCachedShape(this._rawShape);
95
74
  }
96
-
97
75
  get isAsset() {
98
76
  return this._rawShape.id === 'ASSET';
99
77
  }
100
-
101
78
  get isInterfaceShape() {
102
79
  return isInterfaceShape(this._rawShape);
103
80
  }
104
-
105
81
  }
@@ -49,26 +49,21 @@ export * from './v3.37.0';
49
49
  export * from './v3.38.0';
50
50
  export * from './v3.39.0';
51
51
  export * from './v4.0.0';
52
-
53
52
  // Schema type utilities
54
53
  function createVersionPredicate(expectedVersion) {
55
54
  return projectSchema => {
56
55
  let {
57
56
  schemaVersion
58
57
  } = projectSchema;
59
-
60
58
  if (!schemaVersion || schemaVersion === '1') {
61
59
  schemaVersion = '1.0.0';
62
60
  }
63
-
64
61
  if (schemaVersion === '3') {
65
62
  schemaVersion = '3.0.0';
66
63
  }
67
-
68
64
  return Boolean(expectedVersion && schemaVersion && expectedVersion === schemaVersion);
69
65
  };
70
66
  }
71
-
72
67
  export const isProjectSchemaJSONV1_0_0 = createVersionPredicate('1.0.0');
73
68
  export const isProjectSchemaJSONV3_0_0 = createVersionPredicate('3.0.0');
74
69
  export const isProjectSchemaJSONV3_1_0 = createVersionPredicate('3.1.0');
@@ -1,210 +1,162 @@
1
1
  // This file is generated by "pnpm json2ts"
2
+
2
3
  import { migrateTo } from '../migration';
3
- import { isProjectSchemaJSONV1_0_0, isProjectSchemaJSONV3_0_0, isProjectSchemaJSONV3_1_0, isProjectSchemaJSONV3_2_0, isProjectSchemaJSONV3_3_0, isProjectSchemaJSONV3_4_0, isProjectSchemaJSONV3_5_0, isProjectSchemaJSONV3_5_1, isProjectSchemaJSONV3_6_0, isProjectSchemaJSONV3_7_0, isProjectSchemaJSONV3_8_0, isProjectSchemaJSONV3_9_0, isProjectSchemaJSONV3_10_0, isProjectSchemaJSONV3_11_0, isProjectSchemaJSONV3_12_0, isProjectSchemaJSONV3_12_1, isProjectSchemaJSONV3_12_2, isProjectSchemaJSONV3_12_3, isProjectSchemaJSONV3_13_0, isProjectSchemaJSONV3_14_0, isProjectSchemaJSONV3_15_0, isProjectSchemaJSONV3_16_0, isProjectSchemaJSONV3_17_0, isProjectSchemaJSONV3_17_1, isProjectSchemaJSONV3_18_0, isProjectSchemaJSONV3_18_1, isProjectSchemaJSONV3_18_2, isProjectSchemaJSONV3_19_0, isProjectSchemaJSONV3_20_0, isProjectSchemaJSONV3_21_0, isProjectSchemaJSONV3_22_0, isProjectSchemaJSONV3_23_0, isProjectSchemaJSONV3_24_0, isProjectSchemaJSONV3_25_0, isProjectSchemaJSONV3_26_0, isProjectSchemaJSONV3_27_0, isProjectSchemaJSONV3_28_0, isProjectSchemaJSONV3_29_0, isProjectSchemaJSONV3_30_0, isProjectSchemaJSONV3_31_0, isProjectSchemaJSONV3_32_0, isProjectSchemaJSONV3_33_0, isProjectSchemaJSONV3_34_0, isProjectSchemaJSONV3_35_0, isProjectSchemaJSONV3_36_0, isProjectSchemaJSONV3_37_0, isProjectSchemaJSONV3_38_0, isProjectSchemaJSONV4_0_0, isLatestProjectSchemaJSON } from './index'; // eslint-disable-next-line complexity
4
+ import { isProjectSchemaJSONV1_0_0, isProjectSchemaJSONV3_0_0, isProjectSchemaJSONV3_1_0, isProjectSchemaJSONV3_2_0, isProjectSchemaJSONV3_3_0, isProjectSchemaJSONV3_4_0, isProjectSchemaJSONV3_5_0, isProjectSchemaJSONV3_5_1, isProjectSchemaJSONV3_6_0, isProjectSchemaJSONV3_7_0, isProjectSchemaJSONV3_8_0, isProjectSchemaJSONV3_9_0, isProjectSchemaJSONV3_10_0, isProjectSchemaJSONV3_11_0, isProjectSchemaJSONV3_12_0, isProjectSchemaJSONV3_12_1, isProjectSchemaJSONV3_12_2, isProjectSchemaJSONV3_12_3, isProjectSchemaJSONV3_13_0, isProjectSchemaJSONV3_14_0, isProjectSchemaJSONV3_15_0, isProjectSchemaJSONV3_16_0, isProjectSchemaJSONV3_17_0, isProjectSchemaJSONV3_17_1, isProjectSchemaJSONV3_18_0, isProjectSchemaJSONV3_18_1, isProjectSchemaJSONV3_18_2, isProjectSchemaJSONV3_19_0, isProjectSchemaJSONV3_20_0, isProjectSchemaJSONV3_21_0, isProjectSchemaJSONV3_22_0, isProjectSchemaJSONV3_23_0, isProjectSchemaJSONV3_24_0, isProjectSchemaJSONV3_25_0, isProjectSchemaJSONV3_26_0, isProjectSchemaJSONV3_27_0, isProjectSchemaJSONV3_28_0, isProjectSchemaJSONV3_29_0, isProjectSchemaJSONV3_30_0, isProjectSchemaJSONV3_31_0, isProjectSchemaJSONV3_32_0, isProjectSchemaJSONV3_33_0, isProjectSchemaJSONV3_34_0, isProjectSchemaJSONV3_35_0, isProjectSchemaJSONV3_36_0, isProjectSchemaJSONV3_37_0, isProjectSchemaJSONV3_38_0, isProjectSchemaJSONV4_0_0, isLatestProjectSchemaJSON } from './index';
4
5
 
6
+ // eslint-disable-next-line complexity
5
7
  export async function migrateToLatestProjectSchema(context, projectSchema) {
6
8
  if (isLatestProjectSchemaJSON(projectSchema)) {
7
9
  return projectSchema;
8
10
  }
9
-
10
11
  if (isProjectSchemaJSONV1_0_0(projectSchema)) {
11
12
  projectSchema = await migrateTo['v3.0.0'](context, projectSchema);
12
13
  }
13
-
14
14
  if (isProjectSchemaJSONV3_0_0(projectSchema)) {
15
15
  projectSchema = await migrateTo['v3.1.0'](context, projectSchema);
16
16
  }
17
-
18
17
  if (isProjectSchemaJSONV3_1_0(projectSchema)) {
19
18
  projectSchema = await migrateTo['v3.2.0'](context, projectSchema);
20
19
  }
21
-
22
20
  if (isProjectSchemaJSONV3_2_0(projectSchema)) {
23
21
  projectSchema = await migrateTo['v3.3.0'](context, projectSchema);
24
22
  }
25
-
26
23
  if (isProjectSchemaJSONV3_3_0(projectSchema)) {
27
24
  projectSchema = await migrateTo['v3.4.0'](context, projectSchema);
28
25
  }
29
-
30
26
  if (isProjectSchemaJSONV3_4_0(projectSchema)) {
31
27
  projectSchema = await migrateTo['v3.5.0'](context, projectSchema);
32
28
  }
33
-
34
29
  if (isProjectSchemaJSONV3_5_0(projectSchema)) {
35
30
  projectSchema = await migrateTo['v3.5.1'](context, projectSchema);
36
31
  }
37
-
38
32
  if (isProjectSchemaJSONV3_5_1(projectSchema)) {
39
33
  projectSchema = await migrateTo['v3.6.0'](context, projectSchema);
40
34
  }
41
-
42
35
  if (isProjectSchemaJSONV3_6_0(projectSchema)) {
43
36
  projectSchema = await migrateTo['v3.7.0'](context, projectSchema);
44
37
  }
45
-
46
38
  if (isProjectSchemaJSONV3_7_0(projectSchema)) {
47
39
  projectSchema = await migrateTo['v3.8.0'](context, projectSchema);
48
40
  }
49
-
50
41
  if (isProjectSchemaJSONV3_8_0(projectSchema)) {
51
42
  projectSchema = await migrateTo['v3.9.0'](context, projectSchema);
52
43
  }
53
-
54
44
  if (isProjectSchemaJSONV3_9_0(projectSchema)) {
55
45
  projectSchema = await migrateTo['v3.10.0'](context, projectSchema);
56
46
  }
57
-
58
47
  if (isProjectSchemaJSONV3_10_0(projectSchema)) {
59
48
  projectSchema = await migrateTo['v3.11.0'](context, projectSchema);
60
49
  }
61
-
62
50
  if (isProjectSchemaJSONV3_11_0(projectSchema)) {
63
51
  projectSchema = await migrateTo['v3.12.0'](context, projectSchema);
64
52
  }
65
-
66
53
  if (isProjectSchemaJSONV3_12_0(projectSchema)) {
67
54
  projectSchema = await migrateTo['v3.12.1'](context, projectSchema);
68
55
  }
69
-
70
56
  if (isProjectSchemaJSONV3_12_1(projectSchema)) {
71
57
  projectSchema = await migrateTo['v3.12.2'](context, projectSchema);
72
58
  }
73
-
74
59
  if (isProjectSchemaJSONV3_12_2(projectSchema)) {
75
60
  projectSchema = await migrateTo['v3.12.3'](context, projectSchema);
76
61
  }
77
-
78
62
  if (isProjectSchemaJSONV3_12_3(projectSchema)) {
79
63
  projectSchema = await migrateTo['v3.13.0'](context, projectSchema);
80
64
  }
81
-
82
65
  if (isProjectSchemaJSONV3_13_0(projectSchema)) {
83
66
  projectSchema = await migrateTo['v3.14.0'](context, projectSchema);
84
67
  }
85
-
86
68
  if (isProjectSchemaJSONV3_14_0(projectSchema)) {
87
69
  projectSchema = await migrateTo['v3.15.0'](context, projectSchema);
88
70
  }
89
-
90
71
  if (isProjectSchemaJSONV3_15_0(projectSchema)) {
91
72
  projectSchema = await migrateTo['v3.16.0'](context, projectSchema);
92
73
  }
93
-
94
74
  if (isProjectSchemaJSONV3_16_0(projectSchema)) {
95
75
  projectSchema = await migrateTo['v3.17.0'](context, projectSchema);
96
76
  }
97
-
98
77
  if (isProjectSchemaJSONV3_17_0(projectSchema)) {
99
78
  projectSchema = await migrateTo['v3.17.1'](context, projectSchema);
100
79
  }
101
-
102
80
  if (isProjectSchemaJSONV3_17_1(projectSchema)) {
103
81
  projectSchema = await migrateTo['v3.18.0'](context, projectSchema);
104
82
  }
105
-
106
83
  if (isProjectSchemaJSONV3_18_0(projectSchema)) {
107
84
  projectSchema = await migrateTo['v3.18.1'](context, projectSchema);
108
85
  }
109
-
110
86
  if (isProjectSchemaJSONV3_18_1(projectSchema)) {
111
87
  projectSchema = await migrateTo['v3.18.2'](context, projectSchema);
112
88
  }
113
-
114
89
  if (isProjectSchemaJSONV3_18_2(projectSchema)) {
115
90
  projectSchema = await migrateTo['v3.19.0'](context, projectSchema);
116
91
  }
117
-
118
92
  if (isProjectSchemaJSONV3_19_0(projectSchema)) {
119
93
  projectSchema = await migrateTo['v3.20.0'](context, projectSchema);
120
94
  }
121
-
122
95
  if (isProjectSchemaJSONV3_20_0(projectSchema)) {
123
96
  projectSchema = await migrateTo['v3.21.0'](context, projectSchema);
124
97
  }
125
-
126
98
  if (isProjectSchemaJSONV3_21_0(projectSchema)) {
127
99
  projectSchema = await migrateTo['v3.22.0'](context, projectSchema);
128
100
  }
129
-
130
101
  if (isProjectSchemaJSONV3_22_0(projectSchema)) {
131
102
  projectSchema = await migrateTo['v3.23.0'](context, projectSchema);
132
103
  }
133
-
134
104
  if (isProjectSchemaJSONV3_23_0(projectSchema)) {
135
105
  projectSchema = await migrateTo['v3.24.0'](context, projectSchema);
136
106
  }
137
-
138
107
  if (isProjectSchemaJSONV3_24_0(projectSchema)) {
139
108
  projectSchema = await migrateTo['v3.25.0'](context, projectSchema);
140
109
  }
141
-
142
110
  if (isProjectSchemaJSONV3_25_0(projectSchema)) {
143
111
  projectSchema = await migrateTo['v3.26.0'](context, projectSchema);
144
112
  }
145
-
146
113
  if (isProjectSchemaJSONV3_26_0(projectSchema)) {
147
114
  projectSchema = await migrateTo['v3.27.0'](context, projectSchema);
148
115
  }
149
-
150
116
  if (isProjectSchemaJSONV3_27_0(projectSchema)) {
151
117
  projectSchema = await migrateTo['v3.28.0'](context, projectSchema);
152
118
  }
153
-
154
119
  if (isProjectSchemaJSONV3_28_0(projectSchema)) {
155
120
  projectSchema = await migrateTo['v3.29.0'](context, projectSchema);
156
121
  }
157
-
158
122
  if (isProjectSchemaJSONV3_29_0(projectSchema)) {
159
123
  projectSchema = await migrateTo['v3.30.0'](context, projectSchema);
160
124
  }
161
-
162
125
  if (isProjectSchemaJSONV3_30_0(projectSchema)) {
163
126
  projectSchema = await migrateTo['v3.31.0'](context, projectSchema);
164
127
  }
165
-
166
128
  if (isProjectSchemaJSONV3_31_0(projectSchema)) {
167
129
  projectSchema = await migrateTo['v3.32.0'](context, projectSchema);
168
130
  }
169
-
170
131
  if (isProjectSchemaJSONV3_32_0(projectSchema)) {
171
132
  projectSchema = await migrateTo['v3.33.0'](context, projectSchema);
172
133
  }
173
-
174
134
  if (isProjectSchemaJSONV3_33_0(projectSchema)) {
175
135
  projectSchema = await migrateTo['v3.34.0'](context, projectSchema);
176
136
  }
177
-
178
137
  if (isProjectSchemaJSONV3_34_0(projectSchema)) {
179
138
  projectSchema = await migrateTo['v3.35.0'](context, projectSchema);
180
139
  }
181
-
182
140
  if (isProjectSchemaJSONV3_35_0(projectSchema)) {
183
141
  projectSchema = await migrateTo['v3.36.0'](context, projectSchema);
184
142
  }
185
-
186
143
  if (isProjectSchemaJSONV3_36_0(projectSchema)) {
187
144
  projectSchema = await migrateTo['v3.37.0'](context, projectSchema);
188
145
  }
189
-
190
146
  if (isProjectSchemaJSONV3_37_0(projectSchema)) {
191
147
  projectSchema = await migrateTo['v3.38.0'](context, projectSchema);
192
148
  }
193
-
194
149
  if (isProjectSchemaJSONV3_38_0(projectSchema)) {
195
150
  projectSchema = await migrateTo['v3.39.0'](context, projectSchema);
196
151
  }
197
-
198
152
  if (isProjectSchemaJSONV4_0_0(projectSchema)) {
199
153
  throw new Error('You are using an unreleased schema version. Migration is not possible');
200
154
  }
201
-
202
155
  return projectSchema;
203
156
  }
204
157
  export async function ensureLatest(context, schema) {
205
158
  if (!schema || isLatestProjectSchemaJSON(schema)) {
206
159
  return schema;
207
160
  }
208
-
209
161
  return migrateToLatestProjectSchema(context, schema);
210
162
  }