@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.
- package/dist/api-version.js +0 -9
- package/dist/builtin-schema.js +0 -5
- package/dist/content-schema-transform.js +4 -52
- package/dist/create-input-schema.js +7 -19
- package/dist/enum.js +0 -3
- package/dist/flatten-templates.js +0 -11
- package/dist/get-is-leaf.js +8 -18
- package/dist/index.js +0 -58
- package/dist/interfaces.js +2 -26
- package/dist/layers/layers.js +23 -103
- package/dist/layers/refs.js +26 -69
- package/dist/layers/type-utils.js +11 -43
- package/dist/layers/visitor.js +0 -6
- package/dist/migration/index.js +0 -51
- package/dist/migration/to/v3.0.0.js +31 -45
- package/dist/migration/to/v3.1.0.js +15 -41
- package/dist/migration/to/v3.10.0.js +6 -20
- package/dist/migration/to/v3.11.0.js +8 -20
- package/dist/migration/to/v3.12.0.js +2 -3
- package/dist/migration/to/v3.12.1.js +2 -3
- package/dist/migration/to/v3.12.2.js +2 -3
- package/dist/migration/to/v3.12.3.js +16 -21
- package/dist/migration/to/v3.13.0.js +2 -7
- package/dist/migration/to/v3.14.0.js +2 -3
- package/dist/migration/to/v3.15.0.js +2 -3
- package/dist/migration/to/v3.16.0.js +2 -3
- package/dist/migration/to/v3.17.0.js +4 -9
- package/dist/migration/to/v3.17.1.js +2 -3
- package/dist/migration/to/v3.18.0.js +2 -15
- package/dist/migration/to/v3.18.1.js +2 -7
- package/dist/migration/to/v3.18.2.js +8 -10
- package/dist/migration/to/v3.19.0.js +2 -3
- package/dist/migration/to/v3.2.0.js +2 -3
- package/dist/migration/to/v3.20.0.js +10 -11
- package/dist/migration/to/v3.21.0.js +2 -3
- package/dist/migration/to/v3.22.0.js +4 -9
- package/dist/migration/to/v3.23.0.js +2 -3
- package/dist/migration/to/v3.24.0.js +2 -3
- package/dist/migration/to/v3.25.0.js +2 -3
- package/dist/migration/to/v3.26.0.js +2 -3
- package/dist/migration/to/v3.27.0.js +2 -3
- package/dist/migration/to/v3.28.0.js +2 -3
- package/dist/migration/to/v3.29.0.js +2 -3
- package/dist/migration/to/v3.3.0.js +3 -4
- package/dist/migration/to/v3.30.0.js +2 -3
- package/dist/migration/to/v3.31.0.js +2 -12
- package/dist/migration/to/v3.32.0.js +12 -22
- package/dist/migration/to/v3.33.0.js +2 -3
- package/dist/migration/to/v3.34.0.js +14 -43
- package/dist/migration/to/v3.35.0.js +2 -3
- package/dist/migration/to/v3.36.0.js +6 -10
- package/dist/migration/to/v3.37.0.js +2 -3
- package/dist/migration/to/v3.38.0.js +2 -3
- package/dist/migration/to/v3.39.0.js +6 -13
- package/dist/migration/to/v3.4.0.js +2 -3
- package/dist/migration/to/v3.5.0.js +2 -3
- package/dist/migration/to/v3.5.1.js +2 -3
- package/dist/migration/to/v3.6.0.js +2 -3
- package/dist/migration/to/v3.7.0.js +2 -3
- package/dist/migration/to/v3.8.0.js +2 -3
- package/dist/migration/to/v3.9.0.js +8 -24
- package/dist/migration/utils.js +0 -2
- package/dist/mocks.js +9 -12
- package/dist/models/project-schema.js +0 -34
- package/dist/models/query.js +0 -9
- package/dist/models/service.js +0 -8
- package/dist/models/shape.js +0 -29
- package/dist/project-schema/index.js +1 -105
- package/dist/project-schema/migrate.js +1 -54
- package/dist/refs.js +39 -159
- package/dist/relationships.js +13 -57
- package/dist/scalars.js +0 -1
- package/dist/schema-transform.js +0 -11
- package/dist/schema-util.js +75 -271
- package/dist/schemas/index.js +0 -64
- package/dist/services.js +24 -44
- package/dist/taxonomies.js +0 -13
- package/dist/template-shapes/index.js +1 -8
- package/dist/template-shapes/templates.js +9 -40
- package/dist/template-shapes/types.js +4 -5
- package/dist/template-shapes/where.js +14 -110
- package/dist/types/index.js +0 -4
- package/dist/types/types.js +41 -13
- package/dist/types/utils.js +15 -89
- package/dist/unions.js +8 -38
- package/dist/util/api-indexing.js +2 -19
- package/dist/util/detect-cycles.js +2 -16
- package/dist/util/find-shape-at-path.js +1 -15
- package/dist/util/form-config.js +6 -23
- package/dist/util/get-conflicting-properties.js +7 -17
- package/dist/util/get-return-shape.js +0 -11
- package/dist/util/has-arg.js +0 -6
- package/dist/util/index.js +0 -18
- package/dist/util/merge.js +28 -74
- package/dist/util/patch-schema.js +5 -13
- package/dist/validate.js +15 -234
- package/dist/versions.js +0 -2
- package/dist/workflows.js +0 -15
- package/es/api-version.js +0 -4
- package/es/content-schema-transform.js +4 -38
- package/es/create-input-schema.js +7 -14
- package/es/enum.js +0 -2
- package/es/flatten-templates.js +0 -4
- package/es/get-is-leaf.js +8 -13
- package/es/index.js +1 -0
- package/es/interfaces.js +2 -14
- package/es/layers/layers.js +23 -90
- package/es/layers/refs.js +22 -45
- package/es/layers/type-utils.js +11 -16
- package/es/layers/visitor.js +0 -3
- package/es/migration/to/v3.0.0.js +31 -38
- package/es/migration/to/v3.1.0.js +16 -34
- package/es/migration/to/v3.10.0.js +6 -17
- package/es/migration/to/v3.11.0.js +8 -18
- package/es/migration/to/v3.12.0.js +2 -2
- package/es/migration/to/v3.12.1.js +2 -2
- package/es/migration/to/v3.12.2.js +2 -2
- package/es/migration/to/v3.12.3.js +16 -19
- package/es/migration/to/v3.13.0.js +2 -4
- package/es/migration/to/v3.14.0.js +2 -2
- package/es/migration/to/v3.15.0.js +2 -2
- package/es/migration/to/v3.16.0.js +2 -2
- package/es/migration/to/v3.17.0.js +4 -4
- package/es/migration/to/v3.17.1.js +2 -2
- package/es/migration/to/v3.18.0.js +2 -10
- package/es/migration/to/v3.18.1.js +2 -3
- package/es/migration/to/v3.18.2.js +8 -8
- package/es/migration/to/v3.19.0.js +2 -2
- package/es/migration/to/v3.2.0.js +2 -2
- package/es/migration/to/v3.20.0.js +10 -9
- package/es/migration/to/v3.21.0.js +2 -2
- package/es/migration/to/v3.22.0.js +4 -6
- package/es/migration/to/v3.23.0.js +2 -2
- package/es/migration/to/v3.24.0.js +2 -2
- package/es/migration/to/v3.25.0.js +2 -2
- package/es/migration/to/v3.26.0.js +2 -2
- package/es/migration/to/v3.27.0.js +2 -2
- package/es/migration/to/v3.28.0.js +2 -2
- package/es/migration/to/v3.29.0.js +2 -2
- package/es/migration/to/v3.3.0.js +3 -3
- package/es/migration/to/v3.30.0.js +2 -2
- package/es/migration/to/v3.31.0.js +2 -5
- package/es/migration/to/v3.32.0.js +12 -21
- package/es/migration/to/v3.33.0.js +2 -2
- package/es/migration/to/v3.34.0.js +16 -32
- package/es/migration/to/v3.35.0.js +2 -2
- package/es/migration/to/v3.36.0.js +6 -8
- package/es/migration/to/v3.37.0.js +2 -2
- package/es/migration/to/v3.38.0.js +2 -2
- package/es/migration/to/v3.39.0.js +6 -12
- package/es/migration/to/v3.4.0.js +2 -2
- package/es/migration/to/v3.5.0.js +2 -2
- package/es/migration/to/v3.5.1.js +2 -2
- package/es/migration/to/v3.6.0.js +2 -2
- package/es/migration/to/v3.7.0.js +2 -2
- package/es/migration/to/v3.8.0.js +2 -2
- package/es/migration/to/v3.9.0.js +8 -20
- package/es/mocks.js +10 -6
- package/es/models/project-schema.js +0 -26
- package/es/models/query.js +0 -7
- package/es/models/service.js +0 -6
- package/es/models/shape.js +1 -25
- package/es/project-schema/index.js +0 -5
- package/es/project-schema/migrate.js +3 -51
- package/es/refs.js +40 -96
- package/es/relationships.js +14 -42
- package/es/schema-transform.js +0 -7
- package/es/schema-util.js +75 -180
- package/es/services.js +18 -27
- package/es/taxonomies.js +0 -9
- package/es/template-shapes/index.js +1 -4
- package/es/template-shapes/templates.js +9 -18
- package/es/template-shapes/types.js +3 -4
- package/es/template-shapes/where.js +14 -94
- package/es/types/types.js +43 -10
- package/es/types/utils.js +16 -24
- package/es/unions.js +8 -22
- package/es/util/api-indexing.js +2 -12
- package/es/util/detect-cycles.js +2 -14
- package/es/util/find-shape-at-path.js +2 -12
- package/es/util/form-config.js +7 -19
- package/es/util/get-conflicting-properties.js +8 -14
- package/es/util/get-return-shape.js +0 -8
- package/es/util/has-arg.js +0 -3
- package/es/util/merge.js +28 -55
- package/es/util/patch-schema.js +5 -7
- package/es/validate.js +15 -194
- package/es/workflows.js +0 -6
- package/package.json +5 -5
package/es/services.js
CHANGED
|
@@ -8,42 +8,45 @@ import { latestSchemaJson } from './schemas';
|
|
|
8
8
|
import { formatError } from './validate';
|
|
9
9
|
import uniq from 'lodash/uniq';
|
|
10
10
|
import isEmpty from 'lodash/isEmpty';
|
|
11
|
+
|
|
11
12
|
/**
|
|
12
13
|
* Decrypt an encrypted authentication JSON string
|
|
13
14
|
* Throws an error if decryption fails
|
|
14
15
|
*/
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Decrypt an encrypted authentication JSON string
|
|
19
|
+
* Returns undefined if decryption fails
|
|
20
|
+
*/
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
17
23
|
/**
|
|
18
24
|
* Given a `StoredServiceConfig` returns a usable `ServiceConfig` with the
|
|
19
25
|
* authentication object decrypted.
|
|
20
26
|
*/
|
|
21
27
|
export function decryptServiceConfig(decryptFn, storedServiceConfig) {
|
|
22
28
|
let authentication;
|
|
23
|
-
|
|
24
29
|
if (isEncryptedServiceConfig(storedServiceConfig)) {
|
|
25
30
|
const decrypted = decryptFn(storedServiceConfig.authentication);
|
|
26
|
-
|
|
27
31
|
if (isServiceAuthentication(decrypted)) {
|
|
28
32
|
authentication = decrypted;
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
return {
|
|
36
|
+
...storedServiceConfig,
|
|
33
37
|
authentication
|
|
34
38
|
};
|
|
35
39
|
}
|
|
40
|
+
|
|
36
41
|
/**
|
|
37
42
|
* Given a `ServiceMapJSON` returns a usable `ServiceMap` with all the
|
|
38
43
|
* authentication objects decrypted.
|
|
39
44
|
*/
|
|
40
|
-
|
|
41
45
|
export async function decryptServiceMap(decryptFn, ServiceMapJSON) {
|
|
42
46
|
return Object.entries(ServiceMapJSON).reduce((result, [serviceKey, serviceConfig]) => {
|
|
43
47
|
return result.set(serviceKey, decryptServiceConfig(decryptFn, serviceConfig));
|
|
44
48
|
}, new Map());
|
|
45
49
|
}
|
|
46
|
-
|
|
47
50
|
function createServiceConfigValidator() {
|
|
48
51
|
const validator = createAjv();
|
|
49
52
|
const {
|
|
@@ -56,73 +59,66 @@ function createServiceConfigValidator() {
|
|
|
56
59
|
...serviceConfig
|
|
57
60
|
});
|
|
58
61
|
}
|
|
59
|
-
|
|
60
62
|
const serviceConfigValidator = createServiceConfigValidator();
|
|
63
|
+
|
|
61
64
|
/**
|
|
62
65
|
* Validates a `ServiceConfig` validator based on the JSON-schema.
|
|
63
66
|
*/
|
|
64
|
-
|
|
65
67
|
export function validateServiceConfig(maybeServiceConfig) {
|
|
66
68
|
var _serviceConfigValidat;
|
|
67
|
-
|
|
68
69
|
if (serviceConfigValidator(maybeServiceConfig)) {
|
|
69
70
|
return maybeServiceConfig;
|
|
70
71
|
}
|
|
71
|
-
|
|
72
72
|
throw new SchemaValidationError('ServiceConfig was invalid', (_serviceConfigValidat = serviceConfigValidator.errors) === null || _serviceConfigValidat === void 0 ? void 0 : _serviceConfigValidat.map(formatError));
|
|
73
73
|
}
|
|
74
|
+
|
|
74
75
|
/**
|
|
75
76
|
* Prepare a `ServiceConfig` object update, validating the overall structure
|
|
76
77
|
* and encrypting the `ServiceAuthentication` object.
|
|
77
78
|
*/
|
|
78
79
|
// eslint-disable-next-line max-params
|
|
79
|
-
|
|
80
80
|
export function prepareServiceUpdate(encryptFn, decryptFn, projectSchema, serviceConfigUpdate, serviceKey) {
|
|
81
81
|
const storedServiceConfig = getStoredServiceConfig(projectSchema, serviceKey);
|
|
82
82
|
let newServiceConfig = serviceConfigUpdate;
|
|
83
|
-
|
|
84
83
|
if (storedServiceConfig) {
|
|
85
84
|
const existingServiceConfig = decryptServiceConfig(decryptFn, storedServiceConfig);
|
|
86
85
|
newServiceConfig = mergeWithArrayMerge(existingServiceConfig, serviceConfigUpdate);
|
|
87
86
|
}
|
|
88
|
-
|
|
89
87
|
const {
|
|
90
88
|
authentication,
|
|
91
89
|
authenticationType
|
|
92
90
|
} = newServiceConfig;
|
|
93
|
-
|
|
94
91
|
if (authenticationType === 'none' || isNull(authentication)) {
|
|
95
92
|
delete newServiceConfig.authentication;
|
|
96
93
|
} else if (authentication !== undefined) {
|
|
97
94
|
// Add the discriminator to the authentication object, set authenticationType
|
|
98
95
|
// to ensure the update is correct for the auth type.
|
|
99
|
-
newServiceConfig.authentication = {
|
|
96
|
+
newServiceConfig.authentication = {
|
|
97
|
+
...authentication,
|
|
100
98
|
type: authenticationType
|
|
101
99
|
};
|
|
102
100
|
}
|
|
103
|
-
|
|
104
101
|
validateServiceConfig(newServiceConfig);
|
|
105
102
|
let serviceConfig;
|
|
106
|
-
|
|
107
103
|
if (newServiceConfig.authentication) {
|
|
108
|
-
serviceConfig = {
|
|
104
|
+
serviceConfig = {
|
|
105
|
+
...newServiceConfig,
|
|
109
106
|
authentication: encryptFn(newServiceConfig.authentication)
|
|
110
107
|
};
|
|
111
108
|
} else {
|
|
112
109
|
serviceConfig = newServiceConfig;
|
|
113
110
|
}
|
|
114
|
-
|
|
115
111
|
return serviceConfig;
|
|
116
112
|
}
|
|
113
|
+
|
|
117
114
|
/**
|
|
118
115
|
* Get a service config from a project schema.
|
|
119
116
|
*/
|
|
120
|
-
|
|
121
117
|
export function getStoredServiceConfig(projectSchema, serviceKey) {
|
|
122
118
|
var _projectSchema$servic;
|
|
123
|
-
|
|
124
119
|
return (_projectSchema$servic = projectSchema.services) === null || _projectSchema$servic === void 0 ? void 0 : _projectSchema$servic[serviceKey];
|
|
125
120
|
}
|
|
121
|
+
|
|
126
122
|
/**
|
|
127
123
|
* Get a `Map` keyed with all the service namespaces.
|
|
128
124
|
*
|
|
@@ -130,25 +126,20 @@ export function getStoredServiceConfig(projectSchema, serviceKey) {
|
|
|
130
126
|
*
|
|
131
127
|
* @returns A `Map` with namespaces as keys, and service keys as values.
|
|
132
128
|
*/
|
|
133
|
-
|
|
134
129
|
export function getServiceNamespaces(context) {
|
|
135
130
|
const namespaces = new Map();
|
|
136
131
|
const {
|
|
137
132
|
services
|
|
138
133
|
} = context;
|
|
139
|
-
|
|
140
134
|
if (services) {
|
|
141
135
|
Object.keys(services).forEach(serviceKey => {
|
|
142
136
|
var _services$serviceKey;
|
|
143
|
-
|
|
144
137
|
const namespace = (_services$serviceKey = services[serviceKey]) === null || _services$serviceKey === void 0 ? void 0 : _services$serviceKey.namespace;
|
|
145
|
-
|
|
146
138
|
if (namespace) {
|
|
147
139
|
namespaces.set(namespace, serviceKey);
|
|
148
140
|
}
|
|
149
141
|
});
|
|
150
142
|
}
|
|
151
|
-
|
|
152
143
|
return namespaces;
|
|
153
144
|
}
|
|
154
145
|
export function getServiceObjectFields(projectSchema, shape, provider) {
|
package/es/taxonomies.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import memoize from 'lodash/memoize';
|
|
2
2
|
import { createSchemaPropertyAccessor } from './schema-util';
|
|
3
|
-
|
|
4
3
|
function weakMemoize(fn) {
|
|
5
4
|
const memoized = memoize(fn);
|
|
6
5
|
memoized.cache = new WeakMap();
|
|
7
6
|
return memoized;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
export function getFirstStringFieldV3(shape, projectSchema) {
|
|
11
9
|
var _projectSchema$forms;
|
|
12
|
-
|
|
13
10
|
const forms = (_projectSchema$forms = projectSchema.forms) === null || _projectSchema$forms === void 0 ? void 0 : _projectSchema$forms[shape.name];
|
|
14
|
-
|
|
15
11
|
if (!forms || !forms.default) {
|
|
16
12
|
return null;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
const schemaProperties = createSchemaPropertyAccessor(projectSchema, shape);
|
|
20
15
|
const {
|
|
21
16
|
order
|
|
22
17
|
} = forms.default;
|
|
23
18
|
const name = order.find(name => {
|
|
24
19
|
var _schemaProperties$get;
|
|
25
|
-
|
|
26
20
|
return ((_schemaProperties$get = schemaProperties.getValue(name)) === null || _schemaProperties$get === void 0 ? void 0 : _schemaProperties$get.type) === 'string';
|
|
27
21
|
});
|
|
28
22
|
return name ? {
|
|
@@ -32,7 +26,6 @@ export function getFirstStringFieldV3(shape, projectSchema) {
|
|
|
32
26
|
}
|
|
33
27
|
export const getTaxonomyField = weakMemoize((shape, projectSchema) => {
|
|
34
28
|
var _shape$model;
|
|
35
|
-
|
|
36
29
|
return ((_shape$model = shape.model) === null || _shape$model === void 0 ? void 0 : _shape$model.type) === 'taxonomy' ? getFirstStringFieldV3(shape, projectSchema) : null;
|
|
37
30
|
});
|
|
38
31
|
export const getTaxonomies = weakMemoize(projectSchema => {
|
|
@@ -42,14 +35,12 @@ export const getTaxonomies = weakMemoize(projectSchema => {
|
|
|
42
35
|
return Object.keys(shapes).reduce((result, shapeName) => {
|
|
43
36
|
const shape = shapes[shapeName];
|
|
44
37
|
const field = getTaxonomyField(shape, projectSchema);
|
|
45
|
-
|
|
46
38
|
if (field) {
|
|
47
39
|
result.push({
|
|
48
40
|
shapeId: shape.id,
|
|
49
41
|
field
|
|
50
42
|
});
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
return result;
|
|
54
45
|
}, []);
|
|
55
46
|
});
|
|
@@ -17,23 +17,20 @@ const templateMappings = {
|
|
|
17
17
|
};
|
|
18
18
|
export function resolveTemplate(projectSchema, templateName, shapeName) {
|
|
19
19
|
const mapping = templateMappings[templateName];
|
|
20
|
-
|
|
21
20
|
if (!mapping) {
|
|
22
21
|
throw new Error(`Invalid shape template ${templateName}`);
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
if (projectSchema.shapes[shapeName] === undefined) {
|
|
26
24
|
throw new Error(`Unknown shape "${shapeName}" in template "${templateName}"`);
|
|
27
25
|
}
|
|
28
|
-
|
|
29
26
|
return mapping({
|
|
30
27
|
projectSchema
|
|
31
28
|
}, projectSchema.shapes[shapeName]);
|
|
32
29
|
}
|
|
30
|
+
|
|
33
31
|
/**
|
|
34
32
|
* Check if a string is a known template such as `PaginatedList`
|
|
35
33
|
*/
|
|
36
|
-
|
|
37
34
|
export function isValidTemplate(template) {
|
|
38
35
|
return Boolean(templateMappings[template]);
|
|
39
36
|
}
|
|
@@ -169,7 +169,6 @@ const idSchema = {
|
|
|
169
169
|
export function getIDQueryArgs(templateName) {
|
|
170
170
|
return (context, shape) => {
|
|
171
171
|
var _shape$model;
|
|
172
|
-
|
|
173
172
|
const schema = ((_shape$model = shape.model) === null || _shape$model === void 0 ? void 0 : _shape$model.type) !== 'single' ? mergeSchemaProperties(idSchema, localeProps) : localeProps;
|
|
174
173
|
const shapeName = getFlattenedTemplateShapeName(shape.name, templateName);
|
|
175
174
|
return {
|
|
@@ -180,10 +179,10 @@ export function getIDQueryArgs(templateName) {
|
|
|
180
179
|
};
|
|
181
180
|
};
|
|
182
181
|
}
|
|
182
|
+
|
|
183
183
|
/**
|
|
184
184
|
* Construct a shape name used for a mutation input shape.
|
|
185
185
|
*/
|
|
186
|
-
|
|
187
186
|
export function getMutationInputShapeName(verb) {
|
|
188
187
|
return shapeName => {
|
|
189
188
|
return formatShapeName([verb, shapeName, 'input'], {
|
|
@@ -191,33 +190,28 @@ export function getMutationInputShapeName(verb) {
|
|
|
191
190
|
});
|
|
192
191
|
};
|
|
193
192
|
}
|
|
193
|
+
|
|
194
194
|
/**
|
|
195
195
|
* Create a shape name variant for an input.
|
|
196
196
|
*/
|
|
197
|
-
|
|
198
197
|
export function getInputShapeName(shapeName) {
|
|
199
198
|
if (shapeName === 'TSRelationship') {
|
|
200
199
|
return shapeName;
|
|
201
200
|
}
|
|
202
|
-
|
|
203
201
|
return `${shapeName}Input`;
|
|
204
202
|
}
|
|
205
203
|
export function getOutputShapeName(name) {
|
|
206
204
|
return name.replace(/(?:Input|PartialInput)$/, '');
|
|
207
205
|
}
|
|
208
|
-
|
|
209
206
|
function rewriteRefs(context, shapeSchema, rewriteShapeName) {
|
|
210
207
|
const newSchema = deepClone(shapeSchema);
|
|
211
208
|
visit(newSchema, ['$ref', '@ref'], (_, path) => {
|
|
212
209
|
const parentPath = path.slice(0, -1);
|
|
213
210
|
const value = get(newSchema, parentPath);
|
|
214
|
-
|
|
215
211
|
if ((value['@ref'] || value.$ref) && !parentPath.includes('@input') && !parentPath.includes('@output')) {
|
|
216
212
|
const refItem = getRef(context, value);
|
|
217
|
-
|
|
218
213
|
if (refItem) {
|
|
219
214
|
value['@ref'] = refItem.isForeign ? refItemToAtRef(refItem) : `local:${rewriteShapeName(refItemToShapeName(refItem))}`;
|
|
220
|
-
|
|
221
215
|
if (value.$ref) {
|
|
222
216
|
delete value.$ref;
|
|
223
217
|
}
|
|
@@ -226,11 +220,10 @@ function rewriteRefs(context, shapeSchema, rewriteShapeName) {
|
|
|
226
220
|
});
|
|
227
221
|
return newSchema;
|
|
228
222
|
}
|
|
223
|
+
|
|
229
224
|
/**
|
|
230
225
|
* Construct shapes for a mutation inputs, given source shape info.
|
|
231
226
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
227
|
export function getMutationArgs(templateName, verb) {
|
|
235
228
|
const getShapeName = getMutationInputShapeName(verb);
|
|
236
229
|
const addLocale = verb === TemplateVerbs.Update || verb === TemplateVerbs.Duplicate;
|
|
@@ -244,14 +237,12 @@ export function getMutationArgs(templateName, verb) {
|
|
|
244
237
|
const shouldRequireId = !isSingleton && (verb === TemplateVerbs.Update || verb === TemplateVerbs.Delete || verb === TemplateVerbs.Duplicate);
|
|
245
238
|
let rewrittenSchema;
|
|
246
239
|
let inputShapeSchema;
|
|
247
|
-
|
|
248
240
|
if (verb !== TemplateVerbs.Delete) {
|
|
249
241
|
rewrittenSchema = createInputSchema(shape.schema, {
|
|
250
242
|
isUpdate
|
|
251
243
|
});
|
|
252
244
|
inputShapeSchema = rewriteRefs(projectSchema, rewrittenSchema, getInputShapeName);
|
|
253
245
|
}
|
|
254
|
-
|
|
255
246
|
const inputShape = createShape(inputName, mergeObjectSchemas(shouldRequireId ? idSchema : undefined, inputShapeSchema), {
|
|
256
247
|
description: `${verb} ${shape.name} input`
|
|
257
248
|
});
|
|
@@ -273,22 +264,21 @@ export function getMutationArgs(templateName, verb) {
|
|
|
273
264
|
dependencies: {
|
|
274
265
|
[inputName]: inputShape,
|
|
275
266
|
[argsShapeName]: argsShape,
|
|
276
|
-
...(verb !== TemplateVerbs.Delete && keyBy(getShapeDependencies(projectSchema,
|
|
267
|
+
...(verb !== TemplateVerbs.Delete && keyBy(getShapeDependencies(projectSchema,
|
|
268
|
+
// get the shape dependencies of the shape with the @input swapped
|
|
277
269
|
createShape(inputShape.name, rewrittenSchema), propSchema => {
|
|
278
270
|
if (propSchema['@resolver']) {
|
|
279
271
|
return false;
|
|
280
272
|
}
|
|
281
|
-
|
|
282
273
|
const shapeName = getRefShapeName(projectSchema, propSchema);
|
|
283
|
-
|
|
284
274
|
if (shapeName) {
|
|
285
275
|
return shapeName !== 'TSRelationship' && !projectSchema.shapes[getInputShapeName(shapeName)];
|
|
286
276
|
}
|
|
287
|
-
|
|
288
277
|
return true;
|
|
289
278
|
}).map(shapeName => {
|
|
290
|
-
const shape = projectSchema.shapes[shapeName];
|
|
279
|
+
const shape = projectSchema.shapes[shapeName];
|
|
291
280
|
|
|
281
|
+
// We only allow partial input at the top-level
|
|
292
282
|
return createShape(getInputShapeName(shapeName), rewriteRefs(projectSchema, createInputSchema(shape.schema), getInputShapeName));
|
|
293
283
|
}), 'name')),
|
|
294
284
|
...(addStructure ? {
|
|
@@ -404,7 +394,8 @@ export function getShapeListQueryArgs(templateName, legacyArgs) {
|
|
|
404
394
|
} = getWhereSearchArg(projectSchema, shapes);
|
|
405
395
|
return {
|
|
406
396
|
shapeName,
|
|
407
|
-
dependencies: {
|
|
397
|
+
dependencies: {
|
|
398
|
+
...dependencies,
|
|
408
399
|
TSSearchSortInput,
|
|
409
400
|
[shapeName]: createShape(shapeName, mergeObjectSchemas(commonSearchArgs, localeProps, legacyArgs ? legacyListArgs : undefined, isAllShapes ? shapeFilterProps : undefined, schema))
|
|
410
401
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export let TemplateVerbs
|
|
2
|
-
|
|
3
|
-
(function (TemplateVerbs) {
|
|
1
|
+
export let TemplateVerbs = /*#__PURE__*/function (TemplateVerbs) {
|
|
4
2
|
TemplateVerbs["Create"] = "create";
|
|
5
3
|
TemplateVerbs["Update"] = "update";
|
|
6
4
|
TemplateVerbs["Duplicate"] = "duplicate";
|
|
7
5
|
TemplateVerbs["Delete"] = "delete";
|
|
8
|
-
|
|
6
|
+
return TemplateVerbs;
|
|
7
|
+
}({});
|