@takeshape/schema 8.32.0 → 8.33.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.
- package/es/migration-utils.js +186 -0
- package/es/migration.js +105 -4
- package/es/mocks.js +1 -0
- package/es/project-schema/index.js +1 -0
- package/es/project-schema/v3.11.0.js +1 -0
- package/es/schemas/index.js +4 -3
- package/es/schemas/index.ts +4 -2
- package/es/schemas/project-schema/v3.11.0.json +2135 -0
- package/es/services.js +57 -255
- package/es/types/types.js +9 -0
- package/es/types/utils.js +19 -12
- package/examples/latest/blog-schema.json +2 -1
- package/examples/latest/brewery-schema.json +2 -1
- package/examples/latest/complex-project-schema.json +2 -1
- package/examples/latest/fabric-ecommerce.json +2 -2
- package/examples/latest/frank-and-fred-schema.json +2 -1
- package/examples/latest/massive-schema.json +2 -1
- package/examples/latest/mill-components-schema.json +2 -1
- package/examples/latest/pet-oneof-array.json +2 -1
- package/examples/latest/post-schema.json +2 -1
- package/examples/latest/pruned-shopify-product-schema.json +2 -2
- package/examples/latest/real-world-schema.json +2 -1
- package/examples/latest/recursive-repeater-schema.json +2 -1
- package/examples/latest/recursive-schema.json +2 -1
- package/examples/latest/rick-and-morty-ast.json +1 -1
- package/examples/latest/rick-and-morty-graphql.json +1 -1
- package/examples/latest/rick-and-morty-rest.json +1 -1
- package/examples/latest/schema-with-repeater-draftjs.json +2 -1
- package/examples/latest/shape-books-v3_2_0.json +2 -1
- package/examples/latest/shape-books.json +2 -1
- package/examples/latest/shopify-lookbook.json +1 -1
- package/examples/latest/shopify-store-with-widget.json +2 -2
- package/examples/latest/stripe-starter-resolved.json +2 -2
- package/examples/latest/user-schema-no-required.json +2 -1
- package/examples/latest/user-schema-with-defaults.json +2 -1
- package/lib/migration-utils.d.ts +18 -0
- package/lib/migration-utils.d.ts.map +1 -0
- package/lib/migration-utils.js +203 -0
- package/lib/migration.d.ts +3 -3
- package/lib/migration.d.ts.map +1 -1
- package/lib/migration.js +110 -5
- package/lib/mocks.d.ts.map +1 -1
- package/lib/mocks.js +1 -0
- package/lib/project-schema/index.d.ts +3 -1
- package/lib/project-schema/index.d.ts.map +1 -1
- package/lib/project-schema/index.js +26 -13
- package/lib/project-schema/latest.d.ts +26 -17
- package/lib/project-schema/latest.d.ts.map +1 -1
- package/lib/project-schema/v3.11.0.d.ts +1211 -0
- package/lib/project-schema/v3.11.0.d.ts.map +1 -0
- package/lib/project-schema/v3.11.0.js +5 -0
- package/lib/schemas/index.d.ts +2051 -2
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +17 -15
- package/lib/schemas/index.ts +4 -2
- package/lib/schemas/project-schema/v3.11.0.json +2135 -0
- package/lib/services.d.ts +11 -27
- package/lib/services.d.ts.map +1 -1
- package/lib/services.js +54 -261
- package/lib/types/types.d.ts +16 -5
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js +9 -0
- package/lib/types/utils.d.ts +8 -5
- package/lib/types/utils.d.ts.map +1 -1
- package/lib/types/utils.js +25 -13
- package/lib/validate.d.ts +1 -1
- package/lib/validate.d.ts.map +1 -1
- package/package.json +4 -4
package/es/services.js
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { createSchemaValidator } from '@takeshape/json-schema';
|
|
5
|
-
import isObject from 'lodash/isObject';
|
|
1
|
+
import { mergeWithArrayMerge } from '@takeshape/util';
|
|
2
|
+
import { createAjv } from '@takeshape/json-schema';
|
|
3
|
+
import { SchemaValidationError } from '@takeshape/errors';
|
|
6
4
|
import isNull from 'lodash/isNull';
|
|
7
|
-
import
|
|
8
|
-
import isUndefined from 'lodash/isUndefined';
|
|
5
|
+
import { isEncryptedServiceConfig, isServiceAuthentication } from './types/utils';
|
|
9
6
|
import { getServiceInfo, SERVICE_OBJECT_PATTERN_NAME } from './schema-util';
|
|
10
|
-
|
|
7
|
+
import { latestSchemaJson } from './schemas';
|
|
8
|
+
import { formatError } from './validate';
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
10
|
+
* Decrypt an encrypted authentication JSON string
|
|
11
|
+
* Throws an error if decryption fails
|
|
13
12
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
provider: parts.length > 1 ? parts[0] : undefined,
|
|
18
|
-
id: parts.length > 1 ? parts[1] : parts[0]
|
|
19
|
-
};
|
|
20
|
-
}
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
14
|
+
|
|
21
15
|
/**
|
|
22
16
|
* Given a `StoredServiceConfig` returns a usable `ServiceConfig` with the
|
|
23
17
|
* authentication object decrypted.
|
|
24
18
|
*/
|
|
25
|
-
|
|
26
19
|
export function decryptServiceConfig(decryptFn, storedServiceConfig) {
|
|
27
20
|
let authentication;
|
|
28
21
|
|
|
29
22
|
if (isEncryptedServiceConfig(storedServiceConfig)) {
|
|
30
|
-
|
|
23
|
+
const decrypted = decryptFn(storedServiceConfig.authentication);
|
|
24
|
+
|
|
25
|
+
if (isServiceAuthentication(decrypted)) {
|
|
26
|
+
authentication = decrypted;
|
|
27
|
+
}
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
return { ...storedServiceConfig,
|
|
@@ -44,95 +41,70 @@ export async function decryptServiceMap(decryptFn, storedServiceMap) {
|
|
|
44
41
|
return result.set(serviceKey, decryptServiceConfig(decryptFn, serviceConfig));
|
|
45
42
|
}, new Map());
|
|
46
43
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Provides a `ServiceConfig` validator based on the JSON-schema.
|
|
49
|
-
*/
|
|
50
44
|
|
|
51
45
|
function createServiceConfigValidator() {
|
|
46
|
+
const validator = createAjv();
|
|
52
47
|
const {
|
|
53
|
-
serviceConfig
|
|
48
|
+
serviceConfig,
|
|
54
49
|
...definitions
|
|
55
|
-
} =
|
|
56
|
-
|
|
57
|
-
$id: '
|
|
50
|
+
} = latestSchemaJson.definitions;
|
|
51
|
+
return validator.compile({
|
|
52
|
+
$id: 'ServiceConfig',
|
|
58
53
|
definitions,
|
|
59
|
-
...
|
|
60
|
-
};
|
|
61
|
-
return createSchemaValidator(validationSchema);
|
|
54
|
+
...serviceConfig
|
|
55
|
+
});
|
|
62
56
|
}
|
|
57
|
+
|
|
58
|
+
const serviceConfigValidator = createServiceConfigValidator();
|
|
63
59
|
/**
|
|
64
|
-
*
|
|
65
|
-
* the `removeAdditional` setting, where valid properties are being stripped,
|
|
66
|
-
* this is validated separate from the overall config. May have something to do with
|
|
67
|
-
* JSON Schema's lack of handling for discriminated unions?
|
|
60
|
+
* Validates a `ServiceConfig` validator based on the JSON-schema.
|
|
68
61
|
*/
|
|
69
62
|
|
|
63
|
+
export function validateServiceConfig(maybeServiceConfig) {
|
|
64
|
+
var _serviceConfigValidat;
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...definitions
|
|
75
|
-
} = projectMetaSchema.definitions;
|
|
76
|
-
const validationSchema = {
|
|
77
|
-
$id: '#serviceAuthentication',
|
|
78
|
-
definitions,
|
|
79
|
-
...schema
|
|
80
|
-
};
|
|
81
|
-
return createSchemaValidator(validationSchema, [], {
|
|
82
|
-
removeAdditional: false
|
|
83
|
-
});
|
|
84
|
-
}
|
|
66
|
+
if (serviceConfigValidator(maybeServiceConfig)) {
|
|
67
|
+
return maybeServiceConfig;
|
|
68
|
+
}
|
|
85
69
|
|
|
86
|
-
|
|
87
|
-
|
|
70
|
+
throw new SchemaValidationError('ServiceConfig was invalid', (_serviceConfigValidat = serviceConfigValidator.errors) === null || _serviceConfigValidat === void 0 ? void 0 : _serviceConfigValidat.map(formatError));
|
|
71
|
+
}
|
|
88
72
|
/**
|
|
89
73
|
* Prepare a `ServiceConfig` object update, validating the overall structure
|
|
90
74
|
* and encrypting the `ServiceAuthentication` object.
|
|
91
75
|
*/
|
|
92
76
|
// eslint-disable-next-line max-params
|
|
93
77
|
|
|
94
|
-
export function prepareServiceUpdate(encryptFn, decryptFn, projectSchema,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const storedServiceConfig = (_projectSchema$servic = projectSchema.services) === null || _projectSchema$servic === void 0 ? void 0 : _projectSchema$servic[serviceKey];
|
|
98
|
-
let newServiceConfig = partialServiceConfig;
|
|
78
|
+
export function prepareServiceUpdate(encryptFn, decryptFn, projectSchema, serviceConfigUpdate, serviceKey) {
|
|
79
|
+
const storedServiceConfig = getStoredServiceConfig(projectSchema, serviceKey);
|
|
80
|
+
let newServiceConfig = serviceConfigUpdate;
|
|
99
81
|
|
|
100
82
|
if (storedServiceConfig) {
|
|
101
83
|
const existingServiceConfig = decryptServiceConfig(decryptFn, storedServiceConfig);
|
|
102
|
-
newServiceConfig = mergeWithArrayMerge(existingServiceConfig,
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (isNull(newServiceConfig.authentication)) {
|
|
106
|
-
delete newServiceConfig.authentication;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
let authentication;
|
|
110
|
-
|
|
111
|
-
if (newServiceConfig.authentication) {
|
|
112
|
-
// Copy authentication, to ensure validation doesn't remove any properties
|
|
113
|
-
authentication = deepClone(newServiceConfig.authentication);
|
|
114
|
-
const {
|
|
115
|
-
errorsText: authenticationErrors
|
|
116
|
-
} = serviceAuthenticationValidator(authentication);
|
|
117
|
-
|
|
118
|
-
if (authenticationErrors) {
|
|
119
|
-
throw new Error(authenticationErrors);
|
|
120
|
-
}
|
|
84
|
+
newServiceConfig = mergeWithArrayMerge(existingServiceConfig, serviceConfigUpdate);
|
|
121
85
|
}
|
|
122
86
|
|
|
123
87
|
const {
|
|
124
|
-
|
|
125
|
-
|
|
88
|
+
authentication,
|
|
89
|
+
authenticationType
|
|
90
|
+
} = newServiceConfig;
|
|
126
91
|
|
|
127
|
-
if (
|
|
128
|
-
|
|
92
|
+
if (authenticationType === 'none' || isNull(authentication)) {
|
|
93
|
+
delete newServiceConfig.authentication;
|
|
94
|
+
} else if (authentication !== undefined) {
|
|
95
|
+
// Add the discriminator to the authentication object, set authenticationType
|
|
96
|
+
// to ensure the update is correct for the auth type.
|
|
97
|
+
newServiceConfig.authentication = { ...authentication,
|
|
98
|
+
type: authenticationType
|
|
99
|
+
};
|
|
129
100
|
}
|
|
130
101
|
|
|
102
|
+
validateServiceConfig(newServiceConfig);
|
|
131
103
|
let serviceConfig;
|
|
132
104
|
|
|
133
|
-
if (authentication) {
|
|
105
|
+
if (newServiceConfig.authentication) {
|
|
134
106
|
serviceConfig = { ...newServiceConfig,
|
|
135
|
-
authentication: encryptFn(authentication)
|
|
107
|
+
authentication: encryptFn(newServiceConfig.authentication)
|
|
136
108
|
};
|
|
137
109
|
} else {
|
|
138
110
|
serviceConfig = newServiceConfig;
|
|
@@ -145,191 +117,21 @@ export function prepareServiceUpdate(encryptFn, decryptFn, projectSchema, partia
|
|
|
145
117
|
*/
|
|
146
118
|
|
|
147
119
|
export function getStoredServiceConfig(projectSchema, serviceKey) {
|
|
148
|
-
var _projectSchema$
|
|
149
|
-
|
|
150
|
-
return (_projectSchema$servic2 = projectSchema.services) === null || _projectSchema$servic2 === void 0 ? void 0 : _projectSchema$servic2[serviceKey];
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Migration-related Functions
|
|
154
|
-
*
|
|
155
|
-
* All the following code is used in the migration process. At some point
|
|
156
|
-
* migraton code should live outside the standard runtime code.
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Ensures a consistent service config, inluding updating the service
|
|
161
|
-
* authentication object.
|
|
162
|
-
*/
|
|
163
|
-
// eslint-disable-next-line complexity
|
|
164
|
-
|
|
165
|
-
export function updateServiceConfigV3ToV3_1(serviceConfig, serviceKey) {
|
|
166
|
-
if (isAnyServiceConfig(serviceConfig)) {
|
|
167
|
-
if (isString(serviceConfig.authentication) || isUndefined(serviceConfig.authentication)) {
|
|
168
|
-
return serviceConfig;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return serviceConfig;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const {
|
|
175
|
-
auth
|
|
176
|
-
} = serviceConfig;
|
|
177
|
-
const serviceParams = serviceConfig.params || {};
|
|
178
|
-
let {
|
|
179
|
-
provider: serviceKeyProvider,
|
|
180
|
-
id: serviceKeyId
|
|
181
|
-
} = parseV3ServiceStr(serviceKey);
|
|
182
|
-
const authType = serviceParams.authType || undefined;
|
|
183
|
-
const title = serviceParams.name || serviceKeyId;
|
|
184
|
-
|
|
185
|
-
if (serviceKeyId === 'vercel') {
|
|
186
|
-
serviceKeyProvider = 'vercel';
|
|
187
|
-
} else if (serviceKeyId === 'netlify') {
|
|
188
|
-
serviceKeyProvider = 'netlify';
|
|
189
|
-
} // Example schemas had this in params, which are untyped, so adding here just in case
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (serviceParams.type === 'rest') {
|
|
193
|
-
serviceKeyProvider = 'rest';
|
|
194
|
-
} else if (serviceParams.type === 'graphql' && serviceKeyProvider !== 'shopify') {
|
|
195
|
-
serviceKeyProvider = 'graphql';
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
let provider;
|
|
199
|
-
let authenticationType;
|
|
200
|
-
let serviceType;
|
|
201
|
-
let namespace;
|
|
202
|
-
|
|
203
|
-
if (serviceKeyProvider === 'shopify') {
|
|
204
|
-
provider = 'shopify';
|
|
205
|
-
authenticationType = 'oauth2Bearer';
|
|
206
|
-
serviceType = 'graphql';
|
|
207
|
-
namespace = serviceParams.namespace ?? 'Shopify';
|
|
208
|
-
} else if (serviceKeyProvider === 'takeshape') {
|
|
209
|
-
provider = 'takeshape';
|
|
210
|
-
authenticationType = 'none';
|
|
211
|
-
serviceType = 'takeshape';
|
|
212
|
-
namespace = serviceParams.namespace ?? 'TakeShape';
|
|
213
|
-
} else if (serviceKeyProvider === 'bigcommerce') {
|
|
214
|
-
provider = 'bigcommerce';
|
|
215
|
-
authenticationType = 'bearer';
|
|
216
|
-
serviceType = 'graphql';
|
|
217
|
-
namespace = serviceParams.namespace ?? 'BigCommerce';
|
|
218
|
-
} else if (serviceKeyProvider === 'rest') {
|
|
219
|
-
provider = 'generic';
|
|
220
|
-
authenticationType = mapAuthType(authType, auth);
|
|
221
|
-
serviceType = 'rest';
|
|
222
|
-
namespace = serviceParams.namespace ?? pascalCase(title);
|
|
223
|
-
} else if (serviceKeyProvider === 'graphql') {
|
|
224
|
-
provider = 'generic';
|
|
225
|
-
authenticationType = mapAuthType(authType, auth);
|
|
226
|
-
serviceType = 'graphql';
|
|
227
|
-
namespace = serviceParams.namespace ?? pascalCase(title);
|
|
228
|
-
} else if (serviceKeyProvider === 'vercel') {
|
|
229
|
-
provider = 'vercel';
|
|
230
|
-
authenticationType = 'oauth2Bearer';
|
|
231
|
-
serviceType = 'deployment';
|
|
232
|
-
} else if (serviceKeyProvider === 'netlify') {
|
|
233
|
-
provider = 'netlify';
|
|
234
|
-
authenticationType = 'oauth2Bearer';
|
|
235
|
-
serviceType = 'deployment';
|
|
236
|
-
} else {
|
|
237
|
-
provider = 'generic';
|
|
238
|
-
authenticationType = mapAuthType(authType, auth);
|
|
239
|
-
serviceType = 'unknown';
|
|
240
|
-
namespace = serviceParams.namespace ?? pascalCase(title);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const updatedServiceConfig = {
|
|
244
|
-
title,
|
|
245
|
-
id: serviceKey,
|
|
246
|
-
provider,
|
|
247
|
-
namespace,
|
|
248
|
-
serviceType,
|
|
249
|
-
authenticationType,
|
|
250
|
-
options: { ...serviceParams
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
if (serviceConfig.auth && isObject(serviceConfig.auth)) {
|
|
255
|
-
const authentication = updateServiceAuthentication(updatedServiceConfig.authenticationType, serviceConfig.auth, serviceParams);
|
|
256
|
-
return { ...updatedServiceConfig,
|
|
257
|
-
authentication
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return updatedServiceConfig;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* V1/V3 unencrypted `auth` -> V3.1 `authentication
|
|
265
|
-
*/
|
|
266
|
-
|
|
267
|
-
function updateServiceAuthentication(authenticationType, legacyAuth, legacyParams) {
|
|
268
|
-
if (authenticationType === 'oauth2Bearer') {
|
|
269
|
-
return {
|
|
270
|
-
token: legacyAuth.accessToken,
|
|
271
|
-
scope: legacyAuth.scope,
|
|
272
|
-
header: legacyParams.authHeader
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (authenticationType === 'searchParams' && legacyParams.authProp) {
|
|
277
|
-
return [{
|
|
278
|
-
name: legacyParams.authProp,
|
|
279
|
-
value: legacyAuth.accessToken
|
|
280
|
-
}];
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (authenticationType === 'basic') {
|
|
284
|
-
const [username, password] = Buffer.from(legacyAuth.accessToken, 'base64').toString('utf-8').split(':');
|
|
285
|
-
return {
|
|
286
|
-
username,
|
|
287
|
-
password
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (authenticationType === 'bearer') {
|
|
292
|
-
return {
|
|
293
|
-
token: legacyAuth.accessToken,
|
|
294
|
-
header: legacyParams.authHeader
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function mapAuthType(authType, auth) {
|
|
300
|
-
if (authType === 'none') {
|
|
301
|
-
return 'none';
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (authType === 'searchParams') {
|
|
305
|
-
return 'searchParams';
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (authType === 'bearer') {
|
|
309
|
-
return 'bearer';
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
if (authType === 'bearer') {
|
|
313
|
-
return 'basic';
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (!auth) {
|
|
317
|
-
return 'none';
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (auth) {
|
|
321
|
-
return 'bearer';
|
|
322
|
-
}
|
|
120
|
+
var _projectSchema$servic;
|
|
323
121
|
|
|
324
|
-
return
|
|
122
|
+
return (_projectSchema$servic = projectSchema.services) === null || _projectSchema$servic === void 0 ? void 0 : _projectSchema$servic[serviceKey];
|
|
325
123
|
}
|
|
326
|
-
|
|
327
124
|
export function getServiceNamespace(serviceConfig) {
|
|
328
125
|
var _serviceConfig$params;
|
|
329
126
|
|
|
330
127
|
if ('namespace' in serviceConfig && serviceConfig.namespace) {
|
|
331
128
|
return serviceConfig.namespace;
|
|
332
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* TODO This is only necessary if this fn gets called on a schema before migration.
|
|
132
|
+
* Figure that out and remove if possible.
|
|
133
|
+
**/
|
|
134
|
+
|
|
333
135
|
|
|
334
136
|
if ('params' in serviceConfig && (_serviceConfig$params = serviceConfig.params) !== null && _serviceConfig$params !== void 0 && _serviceConfig$params.namespace) {
|
|
335
137
|
return serviceConfig.params.namespace;
|
package/es/types/types.js
CHANGED
package/es/types/utils.js
CHANGED
|
@@ -68,6 +68,7 @@ export const isProjectSchemaV3_7 = createVersionPredicate('3.7.0');
|
|
|
68
68
|
export const isProjectSchemaV3_8 = createVersionPredicate('3.8.0');
|
|
69
69
|
export const isProjectSchemaV3_9 = createVersionPredicate('3.9.0');
|
|
70
70
|
export const isProjectSchemaV3_10 = createVersionPredicate('3.10.0');
|
|
71
|
+
export const isProjectSchemaV3_11 = createVersionPredicate('3.11.0');
|
|
71
72
|
export const isLatestProjectSchema = createVersionPredicate(CURRENT_SCHEMA_VERSION);
|
|
72
73
|
export function isV3XSchema(maybeSchema) {
|
|
73
74
|
if (!isObject(maybeSchema) || !isString(maybeSchema.projectId) || !isString(maybeSchema.schemaVersion)) {
|
|
@@ -87,7 +88,7 @@ export function isAnyProjectSchema(value) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
const maybeSchema = value;
|
|
90
|
-
return isObject(value) && isString(maybeSchema.projectId) && (isProjectSchemaV1(maybeSchema) || isProjectSchemaV3(maybeSchema) || isProjectSchemaV3_1(maybeSchema) || isProjectSchemaV3_2(maybeSchema) || isProjectSchemaV3_3(maybeSchema) || isProjectSchemaV3_4(maybeSchema) || isProjectSchemaV3_5(maybeSchema) || isProjectSchemaV3_5_1(maybeSchema) || isProjectSchemaV3_6(maybeSchema) || isProjectSchemaV3_7(maybeSchema) || isProjectSchemaV3_8(maybeSchema) || isProjectSchemaV3_9(maybeSchema) || isProjectSchemaV3_10(maybeSchema));
|
|
91
|
+
return isObject(value) && isString(maybeSchema.projectId) && (isProjectSchemaV1(maybeSchema) || isProjectSchemaV3(maybeSchema) || isProjectSchemaV3_1(maybeSchema) || isProjectSchemaV3_2(maybeSchema) || isProjectSchemaV3_3(maybeSchema) || isProjectSchemaV3_4(maybeSchema) || isProjectSchemaV3_5(maybeSchema) || isProjectSchemaV3_5_1(maybeSchema) || isProjectSchemaV3_6(maybeSchema) || isProjectSchemaV3_7(maybeSchema) || isProjectSchemaV3_8(maybeSchema) || isProjectSchemaV3_9(maybeSchema) || isProjectSchemaV3_10(maybeSchema) || isProjectSchemaV3_11(maybeSchema));
|
|
91
92
|
}
|
|
92
93
|
export function isProjectSchemaWithServices(schema) {
|
|
93
94
|
return typeof schema.dataKey !== 'undefined' && typeof schema.services !== 'undefined';
|
|
@@ -239,27 +240,33 @@ export function isEncryptedServiceConfig(maybeConfig) {
|
|
|
239
240
|
return isAnyServiceConfig(maybeConfig) && isString(maybeConfig.authentication);
|
|
240
241
|
}
|
|
241
242
|
export function isServiceConfigWithOAuth2Authentication(maybeServiceConfig) {
|
|
242
|
-
return isAnyServiceConfig(maybeServiceConfig) && maybeServiceConfig.
|
|
243
|
+
return isAnyServiceConfig(maybeServiceConfig) && isServiceAuthentication(maybeServiceConfig.authentication) && isOAuth2Authentication(maybeServiceConfig.authentication);
|
|
243
244
|
}
|
|
244
245
|
export function isServiceConfigWithCustomAuthentication(maybeServiceConfig) {
|
|
245
|
-
return isAnyServiceConfig(maybeServiceConfig) && maybeServiceConfig.
|
|
246
|
+
return isAnyServiceConfig(maybeServiceConfig) && isServiceAuthentication(maybeServiceConfig.authentication) && isCustomAuthentication(maybeServiceConfig.authentication);
|
|
246
247
|
}
|
|
247
248
|
/** Authentication Utils **/
|
|
248
249
|
|
|
249
250
|
export function isServiceAuthentication(maybeAuthentication) {
|
|
250
|
-
return maybeAuthentication
|
|
251
|
+
return maybeAuthentication === null || maybeAuthentication === void 0 ? void 0 : maybeAuthentication.type;
|
|
251
252
|
}
|
|
252
|
-
export function isBearerAuthentication(
|
|
253
|
-
return
|
|
253
|
+
export function isBearerAuthentication(authentication) {
|
|
254
|
+
return (authentication === null || authentication === void 0 ? void 0 : authentication.type) === 'bearer';
|
|
254
255
|
}
|
|
255
|
-
export function isBasicAuthentication(
|
|
256
|
-
return
|
|
256
|
+
export function isBasicAuthentication(authentication) {
|
|
257
|
+
return (authentication === null || authentication === void 0 ? void 0 : authentication.type) === 'basic';
|
|
257
258
|
}
|
|
258
|
-
export function isSearchParamsAuthentication(
|
|
259
|
-
return
|
|
259
|
+
export function isSearchParamsAuthentication(authentication) {
|
|
260
|
+
return (authentication === null || authentication === void 0 ? void 0 : authentication.type) === 'searchParams';
|
|
260
261
|
}
|
|
261
|
-
export function isOAuth2Authentication(
|
|
262
|
-
return
|
|
262
|
+
export function isOAuth2Authentication(authentication) {
|
|
263
|
+
return (authentication === null || authentication === void 0 ? void 0 : authentication.type) === 'oauth2';
|
|
264
|
+
}
|
|
265
|
+
export function isOAuth2BearerAuthentication(authentication) {
|
|
266
|
+
return (authentication === null || authentication === void 0 ? void 0 : authentication.type) === 'oauth2Bearer';
|
|
267
|
+
}
|
|
268
|
+
export function isCustomAuthentication(authentication) {
|
|
269
|
+
return (authentication === null || authentication === void 0 ? void 0 : authentication.type) === 'custom';
|
|
263
270
|
}
|
|
264
271
|
/** Miscellaneous Utils **/
|
|
265
272
|
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"provider": "shopify",
|
|
120
120
|
"serviceType": "graphql",
|
|
121
121
|
"authenticationType": "oauth2Bearer",
|
|
122
|
-
"authentication": "
|
|
122
|
+
"authentication": "abc",
|
|
123
123
|
"options": {
|
|
124
124
|
"shop": "michaels-store-takeshape",
|
|
125
125
|
"endpoint": "https://michaels-store-takeshape.myshopify.com/admin/api/2020-07/graphql.json"
|
|
@@ -10516,5 +10516,5 @@
|
|
|
10516
10516
|
}
|
|
10517
10517
|
}
|
|
10518
10518
|
},
|
|
10519
|
-
"schemaVersion": "3.
|
|
10519
|
+
"schemaVersion": "3.11.0"
|
|
10520
10520
|
}
|
|
@@ -19833,5 +19833,6 @@
|
|
|
19833
19833
|
}
|
|
19834
19834
|
}
|
|
19835
19835
|
},
|
|
19836
|
-
"schemaVersion": "3.
|
|
19836
|
+
"schemaVersion": "3.11.0",
|
|
19837
|
+
"services": {}
|
|
19837
19838
|
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"shop": "andrews-takeshape-store",
|
|
23
23
|
"endpoint": "https://andrews-takeshape-store.myshopify.com/admin/api/2020-07/graphql.json"
|
|
24
24
|
},
|
|
25
|
-
"authentication": "
|
|
25
|
+
"authentication": "abc"
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dataKey": "secret",
|
|
@@ -9760,5 +9760,5 @@
|
|
|
9760
9760
|
}
|
|
9761
9761
|
}
|
|
9762
9762
|
},
|
|
9763
|
-
"schemaVersion": "3.
|
|
9763
|
+
"schemaVersion": "3.11.0"
|
|
9764
9764
|
}
|
|
@@ -707,7 +707,7 @@
|
|
|
707
707
|
"namespace": "Shopify",
|
|
708
708
|
"serviceType": "graphql",
|
|
709
709
|
"authenticationType": "oauth2Bearer",
|
|
710
|
-
"authentication": "
|
|
710
|
+
"authentication": "abc",
|
|
711
711
|
"options": {
|
|
712
712
|
"type": "graphql",
|
|
713
713
|
"namespace": "Shopify",
|
|
@@ -12534,5 +12534,5 @@
|
|
|
12534
12534
|
}
|
|
12535
12535
|
}
|
|
12536
12536
|
},
|
|
12537
|
-
"schemaVersion": "3.
|
|
12537
|
+
"schemaVersion": "3.11.0"
|
|
12538
12538
|
}
|