@takeshape/schema 8.33.0 → 8.36.2
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.
- package/es/index.js +3 -3
- package/es/migration/index.js +82 -0
- package/es/migration/to/v3.0.0.js +245 -0
- package/es/{migration-utils.js → migration/to/v3.1.0.js} +40 -8
- package/es/migration/to/v3.10.0.js +56 -0
- package/es/migration/to/v3.11.0.js +99 -0
- package/es/migration/to/v3.2.0.js +10 -0
- package/es/migration/to/v3.3.0.js +16 -0
- package/es/migration/to/v3.4.0.js +10 -0
- package/es/migration/to/v3.5.0.js +10 -0
- package/es/migration/to/v3.5.1.js +10 -0
- package/es/migration/to/v3.6.0.js +10 -0
- package/es/migration/to/v3.7.0.js +10 -0
- package/es/migration/to/v3.8.0.js +10 -0
- package/es/migration/to/v3.9.0.js +83 -0
- package/es/migration/types.js +1 -0
- package/es/migration/utils.js +23 -0
- package/es/schema-util.js +15 -10
- package/examples/v4_0_0/rick-and-morty-notes/{character-notes.layer.json → layers/character-notes.json} +0 -0
- package/examples/v4_0_0/rick-and-morty-notes/{rick-and-morty.layer.json → layers/rick-and-morty.json} +0 -0
- package/examples/v4_0_0/rick-and-morty-notes/{takeshape-assets.layer.json → layers/takeshape-assets.json} +0 -0
- package/examples/v4_0_0/rick-and-morty-notes/{takeshape-builtins.layer.json → layers/takeshape-builtins.json} +0 -0
- package/examples/v4_0_0/rick-and-morty-notes/{takeshape-static-sites.layer.json → layers/takeshape-static-sites.json} +0 -0
- package/examples/v4_0_0/shopify-lookbook/{andrews-store.layer.json → layers/andrews-store.json} +0 -0
- package/examples/v4_0_0/shopify-lookbook/{lookbook.layer.json → layers/lookbook.json} +0 -0
- package/examples/v4_0_0/shopify-lookbook/{takeshape-assets.layer.json → layers/takeshape-assets.json} +0 -0
- package/examples/v4_0_0/shopify-lookbook/{takeshape-builtins.layer.json → layers/takeshape-builtins.json} +0 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -36
- package/lib/migration/index.d.ts +7 -0
- package/lib/migration/index.d.ts.map +1 -0
- package/lib/migration/index.js +128 -0
- package/lib/migration/to/v3.0.0.d.ts +4 -0
- package/lib/migration/to/v3.0.0.d.ts.map +1 -0
- package/lib/migration/to/v3.0.0.js +260 -0
- package/lib/migration/to/v3.1.0.d.ts +5 -0
- package/lib/migration/to/v3.1.0.d.ts.map +1 -0
- package/lib/{migration-utils.js → migration/to/v3.1.0.js} +40 -10
- package/lib/migration/to/v3.10.0.d.ts +4 -0
- package/lib/migration/to/v3.10.0.d.ts.map +1 -0
- package/lib/migration/to/v3.10.0.js +66 -0
- package/lib/migration/to/v3.11.0.d.ts +5 -0
- package/lib/migration/to/v3.11.0.d.ts.map +1 -0
- package/lib/migration/to/v3.11.0.js +109 -0
- package/lib/migration/to/v3.2.0.d.ts +4 -0
- package/lib/migration/to/v3.2.0.d.ts.map +1 -0
- package/lib/migration/to/v3.2.0.js +18 -0
- package/lib/migration/to/v3.3.0.d.ts +5 -0
- package/lib/migration/to/v3.3.0.d.ts.map +1 -0
- package/lib/migration/to/v3.3.0.js +24 -0
- package/lib/migration/to/v3.4.0.d.ts +4 -0
- package/lib/migration/to/v3.4.0.d.ts.map +1 -0
- package/lib/migration/to/v3.4.0.js +18 -0
- package/lib/migration/to/v3.5.0.d.ts +4 -0
- package/lib/migration/to/v3.5.0.d.ts.map +1 -0
- package/lib/migration/to/v3.5.0.js +18 -0
- package/lib/migration/to/v3.5.1.d.ts +4 -0
- package/lib/migration/to/v3.5.1.d.ts.map +1 -0
- package/lib/migration/to/v3.5.1.js +18 -0
- package/lib/migration/to/v3.6.0.d.ts +4 -0
- package/lib/migration/to/v3.6.0.d.ts.map +1 -0
- package/lib/migration/to/v3.6.0.js +18 -0
- package/lib/migration/to/v3.7.0.d.ts +4 -0
- package/lib/migration/to/v3.7.0.d.ts.map +1 -0
- package/lib/migration/to/v3.7.0.js +18 -0
- package/lib/migration/to/v3.8.0.d.ts +4 -0
- package/lib/migration/to/v3.8.0.d.ts.map +1 -0
- package/lib/migration/to/v3.8.0.js +18 -0
- package/lib/migration/to/v3.9.0.d.ts +4 -0
- package/lib/migration/to/v3.9.0.d.ts.map +1 -0
- package/lib/migration/to/v3.9.0.js +91 -0
- package/lib/migration/types.d.ts +14 -0
- package/lib/migration/types.d.ts.map +1 -0
- package/lib/migration/types.js +5 -0
- package/lib/migration/utils.d.ts +5 -0
- package/lib/migration/utils.d.ts.map +1 -0
- package/lib/migration/utils.js +34 -0
- package/lib/schema-util.d.ts.map +1 -1
- package/lib/schema-util.js +16 -10
- package/package.json +6 -5
- package/es/migration.js +0 -677
- package/lib/migration-utils.d.ts +0 -18
- package/lib/migration-utils.d.ts.map +0 -1
- package/lib/migration.d.ts +0 -59
- package/lib/migration.d.ts.map +0 -1
- package/lib/migration.js +0 -739
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _forEach = _interopRequireDefault(require("lodash/forEach"));
|
|
9
|
+
|
|
10
|
+
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
11
|
+
|
|
12
|
+
var _util = require("@takeshape/util");
|
|
13
|
+
|
|
14
|
+
var _schemaUtil = require("../../schema-util");
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
const annotationMap = {
|
|
21
|
+
l10n: '@l10n',
|
|
22
|
+
sensitive: '@sensitive',
|
|
23
|
+
syncLocaleStructure: '@syncLocaleStructure'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function isColor(schema) {
|
|
27
|
+
const {
|
|
28
|
+
type,
|
|
29
|
+
properties
|
|
30
|
+
} = schema;
|
|
31
|
+
return Boolean(type === 'object' && properties && properties.hsl && properties.hsv && properties.rgb && properties.hex);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getModelType(contentType) {
|
|
35
|
+
if (contentType.single) {
|
|
36
|
+
return 'single';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (contentType.taxonomy) {
|
|
40
|
+
return 'taxonomy';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return 'multiple';
|
|
44
|
+
} // eslint-disable-next-line complexity
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function migrateToContentSchemaV3(params) {
|
|
48
|
+
const {
|
|
49
|
+
schema,
|
|
50
|
+
service,
|
|
51
|
+
name,
|
|
52
|
+
key,
|
|
53
|
+
setSource,
|
|
54
|
+
omitAllSources
|
|
55
|
+
} = params;
|
|
56
|
+
const {
|
|
57
|
+
type
|
|
58
|
+
} = schema;
|
|
59
|
+
const mapping = !omitAllSources && key && setSource !== false && name !== key ? `${service}.${key}` : undefined;
|
|
60
|
+
(0, _forEach.default)(schema, (value, key) => {
|
|
61
|
+
if (annotationMap[key]) {
|
|
62
|
+
const newAnnotation = annotationMap[key];
|
|
63
|
+
schema[newAnnotation] = value; // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
64
|
+
|
|
65
|
+
delete schema[key];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (type === 'string' || type === 'boolean' || type === 'number' || type === 'integer') {
|
|
70
|
+
return {
|
|
71
|
+
schema: { ...(0, _pick.default)(schema, _schemaUtil.scalarSchemaKeys),
|
|
72
|
+
'@mapping': mapping
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
relationship
|
|
79
|
+
} = schema;
|
|
80
|
+
|
|
81
|
+
if (relationship) {
|
|
82
|
+
const {
|
|
83
|
+
contentTypeIds,
|
|
84
|
+
type: relationshipType,
|
|
85
|
+
relatedName
|
|
86
|
+
} = relationship;
|
|
87
|
+
return {
|
|
88
|
+
schema: { ...(0, _pick.default)(schema, relationshipType === 'multiple' ? _schemaUtil.multipleRelationshipSchemaKeys : _schemaUtil.schemaMetadataKeys),
|
|
89
|
+
'@mapping': mapping,
|
|
90
|
+
...(0, _utils.getRelationshipSchema)({
|
|
91
|
+
shapeIds: contentTypeIds,
|
|
92
|
+
type: relationshipType ?? 'single',
|
|
93
|
+
// Type is optional on assets
|
|
94
|
+
relatedName
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (type === 'object' && schema.draftjs) {
|
|
101
|
+
return {
|
|
102
|
+
schema: { ...(0, _pick.default)(schema, _schemaUtil.scalarSchemaKeys),
|
|
103
|
+
'@mapping': mapping,
|
|
104
|
+
'@tag': 'draftjs'
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (isColor(schema)) {
|
|
110
|
+
return {
|
|
111
|
+
schema: { ...(0, _pick.default)(schema, _schemaUtil.scalarSchemaKeys),
|
|
112
|
+
$ref: '#/shapes/TSColor/schema',
|
|
113
|
+
'@mapping': mapping
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (type === 'object' && schema.properties) {
|
|
119
|
+
const properties = {};
|
|
120
|
+
const shapes = {};
|
|
121
|
+
const shapeTitle = [params.shapeTitle, (0, _util.pascalCase)(schema.title ?? params.name)].filter(Boolean).join(' ');
|
|
122
|
+
const shapeName = `${params.shapeName}${(0, _util.pascalCase)(params.name)}`;
|
|
123
|
+
const contentSourceId = `takeshape:local:${shapeName}`;
|
|
124
|
+
(0, _forEach.default)(schema.properties, (propSchema, name) => {
|
|
125
|
+
const {
|
|
126
|
+
schema: migratedPropSchema,
|
|
127
|
+
hoistedShapes
|
|
128
|
+
} = migrateToContentSchemaV3({ ...params,
|
|
129
|
+
shapeName,
|
|
130
|
+
shapeTitle,
|
|
131
|
+
depth: params.depth + 1,
|
|
132
|
+
schema: propSchema,
|
|
133
|
+
parentSchema: schema,
|
|
134
|
+
service: contentSourceId,
|
|
135
|
+
key: propSchema.key ?? name,
|
|
136
|
+
name,
|
|
137
|
+
setSource: true
|
|
138
|
+
});
|
|
139
|
+
properties[name] = migratedPropSchema;
|
|
140
|
+
Object.assign(shapes, hoistedShapes);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
if (params.depth > 0) {
|
|
144
|
+
const {
|
|
145
|
+
title,
|
|
146
|
+
description,
|
|
147
|
+
...rest
|
|
148
|
+
} = schema;
|
|
149
|
+
return {
|
|
150
|
+
schema: {
|
|
151
|
+
title,
|
|
152
|
+
description,
|
|
153
|
+
'@mapping': mapping,
|
|
154
|
+
$ref: `#/shapes/${shapeName}/schema`
|
|
155
|
+
},
|
|
156
|
+
hoistedShapes: { ...shapes,
|
|
157
|
+
[shapeName]: {
|
|
158
|
+
id: name === key ? shapeName : key,
|
|
159
|
+
name: shapeName,
|
|
160
|
+
title: shapeTitle,
|
|
161
|
+
schema: { ...(0, _pick.default)(rest, _schemaUtil.objectSchemaKeys),
|
|
162
|
+
type: 'object',
|
|
163
|
+
properties
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
schema: { ...(0, _pick.default)(schema, _schemaUtil.objectSchemaKeys),
|
|
172
|
+
properties,
|
|
173
|
+
'@mapping': mapping
|
|
174
|
+
},
|
|
175
|
+
hoistedShapes: shapes
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (schema.type === 'array' && schema.items) {
|
|
180
|
+
const {
|
|
181
|
+
schema: itemSchema,
|
|
182
|
+
hoistedShapes
|
|
183
|
+
} = migrateToContentSchemaV3({ ...params,
|
|
184
|
+
schema: schema.items,
|
|
185
|
+
parentSchema: schema,
|
|
186
|
+
service: 'parent',
|
|
187
|
+
setSource: false
|
|
188
|
+
});
|
|
189
|
+
return {
|
|
190
|
+
schema: { ...(0, _pick.default)(schema, _schemaUtil.arraySchemaKeys),
|
|
191
|
+
items: itemSchema,
|
|
192
|
+
'@mapping': mapping
|
|
193
|
+
},
|
|
194
|
+
hoistedShapes
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
throw new Error(`Unknown schema type "${type}"`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function contentTypeToShape(contentType, contentTypeId) {
|
|
202
|
+
const title = contentType.title ?? contentType.name;
|
|
203
|
+
const name = (0, _util.pascalCase)(contentType.name);
|
|
204
|
+
const contentSourceId = `takeshape:local:${name}`;
|
|
205
|
+
const {
|
|
206
|
+
schema,
|
|
207
|
+
hoistedShapes
|
|
208
|
+
} = migrateToContentSchemaV3({
|
|
209
|
+
shapeName: name,
|
|
210
|
+
shapeTitle: title,
|
|
211
|
+
schema: contentType.schema,
|
|
212
|
+
service: contentSourceId,
|
|
213
|
+
name: '',
|
|
214
|
+
key: '',
|
|
215
|
+
depth: 0
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
[name]: {
|
|
219
|
+
id: contentTypeId,
|
|
220
|
+
name,
|
|
221
|
+
title,
|
|
222
|
+
model: {
|
|
223
|
+
type: getModelType(contentType)
|
|
224
|
+
},
|
|
225
|
+
workflow: contentType.workflow,
|
|
226
|
+
schema: schema
|
|
227
|
+
},
|
|
228
|
+
...hoistedShapes
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function migrateToV3_0_0(projectSchema) {
|
|
233
|
+
const {
|
|
234
|
+
contentTypes,
|
|
235
|
+
created,
|
|
236
|
+
updated,
|
|
237
|
+
...rest
|
|
238
|
+
} = projectSchema;
|
|
239
|
+
const shapes = {};
|
|
240
|
+
const forms = {};
|
|
241
|
+
Object.keys(contentTypes).forEach(contentTypeId => {
|
|
242
|
+
const contentType = contentTypes[contentTypeId];
|
|
243
|
+
Object.assign(shapes, contentTypeToShape(contentType, contentTypeId));
|
|
244
|
+
forms[(0, _util.pascalCase)(contentType.name)] = contentType.forms;
|
|
245
|
+
}); // Use deepClone to drop undefined values, this improves compatibility with validation and testing
|
|
246
|
+
// Schemas are typically saved in Dynamo or JSON files which also remove undefined values
|
|
247
|
+
// Dropping them here is done for consistency's sake
|
|
248
|
+
|
|
249
|
+
return (0, _util.deepClone)({ ...rest,
|
|
250
|
+
...(0, _schemaUtil.getShapeQueriesAndMutations)(Object.values(shapes)),
|
|
251
|
+
schemaVersion: '3',
|
|
252
|
+
created: (0, _utils.formatDate)(created),
|
|
253
|
+
updated: (0, _utils.formatDate)(updated),
|
|
254
|
+
shapes,
|
|
255
|
+
forms
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
var _default = migrateToV3_0_0;
|
|
260
|
+
exports.default = _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
5
|
+
//# sourceMappingURL=v3.1.0.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -3,12 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.updateServiceConfigV3ToV3_1 = updateServiceConfigV3ToV3_1;
|
|
6
|
+
exports.default = void 0;
|
|
8
7
|
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var _util = require("@takeshape/util");
|
|
8
|
+
var _pReduce = _interopRequireDefault(require("p-reduce"));
|
|
12
9
|
|
|
13
10
|
var _isObject = _interopRequireDefault(require("lodash/isObject"));
|
|
14
11
|
|
|
@@ -16,11 +13,11 @@ var _isString = _interopRequireDefault(require("lodash/isString"));
|
|
|
16
13
|
|
|
17
14
|
var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
var _util = require("@takeshape/util");
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
var _utils = require("../../types/utils");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
21
|
|
|
25
22
|
/**
|
|
26
23
|
* `graphql:my-key` `my-key`
|
|
@@ -200,4 +197,37 @@ function mapAuthType(authType, auth) {
|
|
|
200
197
|
}
|
|
201
198
|
|
|
202
199
|
return 'unknown';
|
|
203
|
-
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async function migrateToV3_1(context, projectSchema) {
|
|
203
|
+
const {
|
|
204
|
+
encryptFn,
|
|
205
|
+
decryptFn
|
|
206
|
+
} = context;
|
|
207
|
+
let services;
|
|
208
|
+
/**
|
|
209
|
+
* Services can only be migrated if a dataKey is present, otherwise they will need to be discarded.
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
if (projectSchema.services) {
|
|
213
|
+
services = await (0, _pReduce.default)(Object.entries(projectSchema.services), async (serviceMap, [serviceKey, serviceConfig]) => {
|
|
214
|
+
const auth = serviceConfig.auth && decryptFn(serviceConfig.auth);
|
|
215
|
+
const updatedServiceConfig = updateServiceConfigV3ToV3_1({ ...serviceConfig,
|
|
216
|
+
auth
|
|
217
|
+
}, serviceKey);
|
|
218
|
+
const authentication = updatedServiceConfig === null || updatedServiceConfig === void 0 ? void 0 : updatedServiceConfig.authentication;
|
|
219
|
+
serviceMap[serviceKey] = { ...updatedServiceConfig,
|
|
220
|
+
authentication: authentication && (0, _isObject.default)(authentication) ? encryptFn(authentication) : authentication
|
|
221
|
+
};
|
|
222
|
+
return serviceMap;
|
|
223
|
+
}, {});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return (0, _util.deepClone)({ ...projectSchema,
|
|
227
|
+
services,
|
|
228
|
+
schemaVersion: '3.1.0'
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
var _default = migrateToV3_1;
|
|
233
|
+
exports.default = _default;
|
|
@@ -0,0 +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;AAuC9B,iBAAS,cAAc,CAAC,aAAa,EAAE,mBAAmB,GAAG,oBAAoB,CAUhF;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _mapValues = _interopRequireDefault(require("lodash/mapValues"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
function migrateQueryToV3_10(query, queryName) {
|
|
13
|
+
const {
|
|
14
|
+
args,
|
|
15
|
+
shape
|
|
16
|
+
} = query;
|
|
17
|
+
|
|
18
|
+
if (typeof args === 'object' && ('oneOf' in args || 'allOf' in args || '$ref' in args || '@ref' in args)) {
|
|
19
|
+
// As of 11/15/2021 no production schemas contained queries with these args
|
|
20
|
+
throw new Error(`Query "${queryName}" contains an unsupported arg schema ${JSON.stringify(args)}. Please contact support`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (typeof shape === 'object' && !shape.items['@ref']) {
|
|
24
|
+
// As of 11/15/2021 no production schemas contained queries with array return shapes that are not @refs
|
|
25
|
+
throw new Error(`Query "${queryName}" contains an unsupported shape schema ${JSON.stringify(shape)}. Please contact support`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return query;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function migrateShapeToV3_10(shape) {
|
|
32
|
+
const {
|
|
33
|
+
schema,
|
|
34
|
+
...rest
|
|
35
|
+
} = shape; // As of 11/15/2021 no production schemas contained shapes with array schemas
|
|
36
|
+
|
|
37
|
+
if ('type' in schema && schema.type === 'array') {
|
|
38
|
+
throw new Error(`Shape ${shape.name} uses an unsupported array schema. Please contact support`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const newSchema = '$ref' in schema || '@ref' in schema ? {
|
|
42
|
+
allOf: [schema]
|
|
43
|
+
} : schema;
|
|
44
|
+
return { ...rest,
|
|
45
|
+
schema: newSchema
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function migrateToV3_10(projectSchema) {
|
|
50
|
+
const {
|
|
51
|
+
queries,
|
|
52
|
+
mutations,
|
|
53
|
+
shapes,
|
|
54
|
+
schemaVersion,
|
|
55
|
+
...rest
|
|
56
|
+
} = projectSchema;
|
|
57
|
+
return { ...rest,
|
|
58
|
+
queries: (0, _mapValues.default)(queries, migrateQueryToV3_10),
|
|
59
|
+
mutations: (0, _mapValues.default)(mutations, migrateQueryToV3_10),
|
|
60
|
+
shapes: (0, _mapValues.default)(shapes, migrateShapeToV3_10),
|
|
61
|
+
schemaVersion: '3.10.0'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var _default = migrateToV3_10;
|
|
66
|
+
exports.default = _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ProjectSchemaV3_10_0, ProjectSchemaV3_11_0 } from '../../project-schema';
|
|
2
|
+
import type { ProjectSchemaMigrationContext } from '../types';
|
|
3
|
+
declare function migrateToV3_11_0({ decryptFn, encryptFn }: ProjectSchemaMigrationContext, projectSchema: ProjectSchemaV3_10_0): ProjectSchemaV3_11_0;
|
|
4
|
+
export default migrateToV3_11_0;
|
|
5
|
+
//# sourceMappingURL=v3.11.0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3.11.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.11.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EAUrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,UAAU,CAAC;AAG5D,iBAAS,gBAAgB,CACvB,EAAC,SAAS,EAAE,SAAS,EAAC,EAAE,6BAA6B,EACrD,aAAa,EAAE,oBAAoB,GAClC,oBAAoB,CA6FtB;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _fromPairs = _interopRequireDefault(require("lodash/fromPairs"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
function migrateToV3_11_0({
|
|
13
|
+
decryptFn,
|
|
14
|
+
encryptFn
|
|
15
|
+
}, projectSchema) {
|
|
16
|
+
const migratedServices = [];
|
|
17
|
+
|
|
18
|
+
for (const [serviceKey, serviceConfig] of Object.entries(projectSchema.services ?? {})) {
|
|
19
|
+
const {
|
|
20
|
+
authenticationType,
|
|
21
|
+
authentication
|
|
22
|
+
} = serviceConfig; // Migrate authentication, ensuring now required properties
|
|
23
|
+
|
|
24
|
+
if (authentication && authenticationType !== 'unknown' && authenticationType !== 'none') {
|
|
25
|
+
const decrypted = decryptFn(authentication);
|
|
26
|
+
|
|
27
|
+
if (!decrypted) {
|
|
28
|
+
throw new Error(`Service "${serviceKey}" authentication could not be decrypted. Please contact support.`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let migrated;
|
|
32
|
+
|
|
33
|
+
if (authenticationType === 'searchParams') {
|
|
34
|
+
migrated = {
|
|
35
|
+
params: decrypted,
|
|
36
|
+
type: authenticationType
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (authenticationType === 'basic') {
|
|
41
|
+
migrated = {
|
|
42
|
+
username: '',
|
|
43
|
+
password: '',
|
|
44
|
+
...decrypted,
|
|
45
|
+
type: authenticationType
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (authenticationType === 'bearer') {
|
|
50
|
+
migrated = {
|
|
51
|
+
token: '',
|
|
52
|
+
...decrypted,
|
|
53
|
+
type: authenticationType
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (authenticationType === 'oauth2Bearer') {
|
|
58
|
+
migrated = {
|
|
59
|
+
token: '',
|
|
60
|
+
...decrypted,
|
|
61
|
+
type: authenticationType
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (authenticationType === 'oauth2') {
|
|
66
|
+
migrated = {
|
|
67
|
+
grantType: 'clientCredentials',
|
|
68
|
+
clientId: '',
|
|
69
|
+
...decrypted,
|
|
70
|
+
type: authenticationType
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (authenticationType === 'aws') {
|
|
75
|
+
migrated = {
|
|
76
|
+
awsAccessKeyId: '',
|
|
77
|
+
awsSecretAccessKey: '',
|
|
78
|
+
...decrypted,
|
|
79
|
+
type: authenticationType
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (authenticationType === 'custom') {
|
|
84
|
+
migrated = { ...decrypted,
|
|
85
|
+
type: authenticationType
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (migrated) {
|
|
90
|
+
const migratedServiceConfig = { ...serviceConfig,
|
|
91
|
+
authentication: encryptFn(migrated)
|
|
92
|
+
};
|
|
93
|
+
migratedServices.push([serviceKey, migratedServiceConfig]);
|
|
94
|
+
} else {
|
|
95
|
+
migratedServices.push([serviceKey, serviceConfig]);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
migratedServices.push([serviceKey, serviceConfig]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return { ...projectSchema,
|
|
103
|
+
services: (0, _fromPairs.default)(migratedServices),
|
|
104
|
+
schemaVersion: '3.11.0'
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var _default = migrateToV3_11_0;
|
|
109
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3.2.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.2.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAEnF,iBAAS,aAAa,CAAC,aAAa,EAAE,mBAAmB,GAAG,mBAAmB,CAQ9E;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function migrateToV3_2(projectSchema) {
|
|
9
|
+
/**
|
|
10
|
+
* No migration needed all changes are backwards compatible.
|
|
11
|
+
*/
|
|
12
|
+
return { ...projectSchema,
|
|
13
|
+
schemaVersion: '3.2.0'
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var _default = migrateToV3_2;
|
|
18
|
+
exports.default = _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ProjectSchemaV3_2_0, ProjectSchemaV3_3_0 } from '../../project-schema';
|
|
2
|
+
import type { ProjectSchemaMigrationContext } from '../types';
|
|
3
|
+
declare function migrateToV3_3(context: ProjectSchemaMigrationContext, projectSchema: ProjectSchemaV3_2_0): Promise<ProjectSchemaV3_3_0>;
|
|
4
|
+
export default migrateToV3_3;
|
|
5
|
+
//# sourceMappingURL=v3.3.0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3.3.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.3.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACnF,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,UAAU,CAAC;AAE5D,iBAAe,aAAa,CAC1B,OAAO,EAAE,6BAA6B,EACtC,aAAa,EAAE,mBAAmB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAY9B;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
async function migrateToV3_3(context, projectSchema) {
|
|
9
|
+
const {
|
|
10
|
+
generateDataKeyFn
|
|
11
|
+
} = context;
|
|
12
|
+
const dataKey = projectSchema.dataKey ? projectSchema.dataKey : await generateDataKeyFn();
|
|
13
|
+
/**
|
|
14
|
+
* Generate a dataKey if none is present.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
return { ...projectSchema,
|
|
18
|
+
schemaVersion: '3.3.0',
|
|
19
|
+
dataKey
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var _default = migrateToV3_3;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3.4.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.4.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAEnF,iBAAS,aAAa,CAAC,aAAa,EAAE,mBAAmB,GAAG,mBAAmB,CAQ9E;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function migrateToV3_4(projectSchema) {
|
|
9
|
+
/**
|
|
10
|
+
* No migration needed all changes are backwards compatible.
|
|
11
|
+
*/
|
|
12
|
+
return { ...projectSchema,
|
|
13
|
+
schemaVersion: '3.4.0'
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var _default = migrateToV3_4;
|
|
18
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3.5.0.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.5.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAEnF,iBAAS,aAAa,CAAC,aAAa,EAAE,mBAAmB,GAAG,mBAAmB,CAQ9E;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function migrateToV3_5(projectSchema) {
|
|
9
|
+
/**
|
|
10
|
+
* No migration needed all changes are backwards compatible.
|
|
11
|
+
*/
|
|
12
|
+
return { ...projectSchema,
|
|
13
|
+
schemaVersion: '3.5.0'
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var _default = migrateToV3_5;
|
|
18
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3.5.1.d.ts","sourceRoot":"","sources":["../../../../src/migration/to/v3.5.1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAEnF,iBAAS,eAAe,CAAC,aAAa,EAAE,mBAAmB,GAAG,mBAAmB,CAQhF;AAED,eAAe,eAAe,CAAC"}
|