@takeshape/schema 9.80.4 → 9.81.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/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
|
@@ -4,15 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
const migrate = async (_, projectSchema) => {
|
|
9
8
|
/**
|
|
10
9
|
* No migration needed all changes are backwards compatible.
|
|
11
10
|
*/
|
|
12
|
-
return {
|
|
11
|
+
return {
|
|
12
|
+
...projectSchema,
|
|
13
13
|
schemaVersion: '3.8.0'
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
|
|
17
16
|
var _default = migrate;
|
|
18
17
|
exports.default = _default;
|
|
@@ -4,19 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _util = require("@takeshape/util");
|
|
9
|
-
|
|
10
8
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
11
|
-
|
|
12
9
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
function omitOptions(resolver, names) {
|
|
17
12
|
if (resolver.options) {
|
|
18
13
|
const newOptions = (0, _omit.default)(resolver.options, names);
|
|
19
|
-
|
|
20
14
|
if ((0, _isEmpty.default)(newOptions)) {
|
|
21
15
|
delete resolver.options;
|
|
22
16
|
} else {
|
|
@@ -24,7 +18,6 @@ function omitOptions(resolver, names) {
|
|
|
24
18
|
}
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
const migrate = async (_, projectSchema) => {
|
|
29
22
|
/**
|
|
30
23
|
* Resolver props that are guaranteed in this version, and dependent on the
|
|
@@ -34,62 +27,53 @@ const migrate = async (_, projectSchema) => {
|
|
|
34
27
|
if (resolver.name.startsWith('takeshape')) {
|
|
35
28
|
if (!resolver.shapeName) {
|
|
36
29
|
var _resolver$options, _resolver$options2;
|
|
37
|
-
|
|
38
30
|
resolver.shapeName = ((_resolver$options = resolver.options) === null || _resolver$options === void 0 ? void 0 : _resolver$options.model) ?? ((_resolver$options2 = resolver.options) === null || _resolver$options2 === void 0 ? void 0 : _resolver$options2.indexedShape) ?? '';
|
|
39
31
|
omitOptions(resolver, ['model', 'indexedShape']);
|
|
40
32
|
}
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
if (resolver.name.startsWith('graphql')) {
|
|
44
35
|
if (!resolver.fieldName) {
|
|
45
36
|
var _resolver$options3;
|
|
46
|
-
|
|
47
37
|
resolver.fieldName = ((_resolver$options3 = resolver.options) === null || _resolver$options3 === void 0 ? void 0 : _resolver$options3.fieldName) ?? '';
|
|
48
38
|
omitOptions(resolver, ['fieldName']);
|
|
49
39
|
}
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
if (resolver.name.startsWith('awsLambda')) {
|
|
53
42
|
if (!resolver.functionName) {
|
|
54
43
|
var _resolver$options4;
|
|
55
|
-
|
|
56
44
|
resolver.functionName = ((_resolver$options4 = resolver.options) === null || _resolver$options4 === void 0 ? void 0 : _resolver$options4.functionName) ?? '';
|
|
57
45
|
omitOptions(resolver, ['functionName']);
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
|
-
|
|
61
48
|
if (resolver.name.startsWith('rest')) {
|
|
62
49
|
if (!resolver.path) {
|
|
63
50
|
if (resolver.pathParams) {
|
|
64
51
|
var _resolver$options5;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
serialize: {
|
|
52
|
+
resolver.path = {
|
|
53
|
+
...resolver.pathParams,
|
|
54
|
+
serialize: {
|
|
55
|
+
...resolver.pathParams.serialize,
|
|
68
56
|
template: (_resolver$options5 = resolver.options) === null || _resolver$options5 === void 0 ? void 0 : _resolver$options5.path
|
|
69
57
|
}
|
|
70
58
|
};
|
|
71
59
|
} else {
|
|
72
60
|
var _resolver$options6;
|
|
73
|
-
|
|
74
61
|
resolver.path = ((_resolver$options6 = resolver.options) === null || _resolver$options6 === void 0 ? void 0 : _resolver$options6.path) ?? '';
|
|
75
62
|
}
|
|
76
|
-
|
|
77
63
|
omitOptions(resolver, ['path']);
|
|
78
64
|
}
|
|
79
65
|
}
|
|
66
|
+
|
|
80
67
|
/**
|
|
81
68
|
* `resolver.name` was previously validated with app code and v3.9.0
|
|
82
69
|
* enumerates the previous validation, making this assertion safe.
|
|
83
70
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
71
|
return resolver;
|
|
87
72
|
};
|
|
73
|
+
|
|
88
74
|
/**
|
|
89
75
|
* Function will visit each resolver in the schema and mutate them.
|
|
90
76
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
77
|
(0, _util.visit)(projectSchema, ['resolver', '@resolver'], resolver => {
|
|
94
78
|
if (resolver.compose) {
|
|
95
79
|
resolver.compose.forEach(ensureResolverOptions);
|
|
@@ -97,10 +81,10 @@ const migrate = async (_, projectSchema) => {
|
|
|
97
81
|
ensureResolverOptions(resolver);
|
|
98
82
|
}
|
|
99
83
|
});
|
|
100
|
-
return {
|
|
84
|
+
return {
|
|
85
|
+
...projectSchema,
|
|
101
86
|
schemaVersion: '3.9.0'
|
|
102
87
|
};
|
|
103
88
|
};
|
|
104
|
-
|
|
105
89
|
var _default = migrate;
|
|
106
90
|
exports.default = _default;
|
package/dist/migration/utils.js
CHANGED
|
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.formatDate = formatDate;
|
|
7
7
|
exports.normalizeSchemaVersion = normalizeSchemaVersion;
|
|
8
|
-
|
|
9
8
|
function formatDate(timestamp) {
|
|
10
9
|
return (timestamp ? new Date(timestamp) : new Date()).toISOString();
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
function normalizeSchemaVersion(version) {
|
|
14
12
|
return version === undefined ? '1' : version;
|
|
15
13
|
}
|
package/dist/mocks.js
CHANGED
|
@@ -8,32 +8,29 @@ exports.createMockSchema = createMockSchema;
|
|
|
8
8
|
exports.createMockSchemaWithDefaults = createMockSchemaWithDefaults;
|
|
9
9
|
exports.createMockServiceConfig = createMockServiceConfig;
|
|
10
10
|
exports.createMockStoredServiceConfig = createMockStoredServiceConfig;
|
|
11
|
-
|
|
12
11
|
var _schemaUtil = require("./schema-util");
|
|
13
|
-
|
|
14
12
|
var _util = require("@takeshape/util");
|
|
15
|
-
|
|
16
13
|
/**
|
|
17
14
|
* Like emptySchema, but for tests.
|
|
18
15
|
*/
|
|
19
16
|
function createMockSchema(projectId, schema = {}) {
|
|
20
|
-
return {
|
|
17
|
+
return {
|
|
18
|
+
...(0, _schemaUtil.emptySchema)(projectId),
|
|
21
19
|
...schema,
|
|
22
20
|
projectId
|
|
23
21
|
};
|
|
24
22
|
}
|
|
23
|
+
|
|
25
24
|
/**
|
|
26
25
|
* Capturing a common pattern used in tests. Creates an empty schema, with defaults.
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
27
|
function createMockSchemaWithDefaults(projectId, schema = {}) {
|
|
31
|
-
return (0, _schemaUtil.applyDefaultsToSchema)({
|
|
28
|
+
return (0, _schemaUtil.applyDefaultsToSchema)({
|
|
29
|
+
...(0, _schemaUtil.emptySchema)(projectId),
|
|
32
30
|
...schema,
|
|
33
31
|
projectId
|
|
34
32
|
});
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
function createMockServiceConfig(serviceKey, serviceConfig) {
|
|
38
35
|
return {
|
|
39
36
|
id: serviceKey,
|
|
@@ -52,16 +49,16 @@ function createMockServiceConfig(serviceKey, serviceConfig) {
|
|
|
52
49
|
...serviceConfig
|
|
53
50
|
};
|
|
54
51
|
}
|
|
55
|
-
|
|
56
52
|
function createMockStoredServiceConfig(serviceKey, serviceConfig) {
|
|
57
|
-
return {
|
|
53
|
+
return {
|
|
54
|
+
...createMockServiceConfig(serviceKey),
|
|
58
55
|
authentication: 'encrypted-abc123',
|
|
59
56
|
...serviceConfig
|
|
60
57
|
};
|
|
61
58
|
}
|
|
62
|
-
|
|
63
59
|
function addMockIndexingConfig(shape) {
|
|
64
|
-
return {
|
|
60
|
+
return {
|
|
61
|
+
...shape,
|
|
65
62
|
loaders: {
|
|
66
63
|
list: {
|
|
67
64
|
query: `Query.get${shape.name}List`
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ProjectSchema = void 0;
|
|
7
|
-
|
|
8
7
|
var _refs = require("../refs");
|
|
9
|
-
|
|
10
8
|
var _schemaUtil = require("../schema-util");
|
|
11
|
-
|
|
12
9
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
13
|
-
|
|
14
10
|
var _shape = require("./shape");
|
|
15
|
-
|
|
16
11
|
var _query = require("./query");
|
|
17
|
-
|
|
18
12
|
var _service = require("./service");
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* Model object representing a ProjectSchema.
|
|
24
16
|
* Intended to help make it easier to find the right utils
|
|
@@ -26,107 +18,81 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
26
18
|
*/
|
|
27
19
|
class ProjectSchema {
|
|
28
20
|
_cache = {};
|
|
29
|
-
|
|
30
21
|
constructor(unfilteredProjectSchema) {
|
|
31
22
|
// You can pass a ProjectSchemaCompat in here, but we remove its values so they don't get passed through to getJSON.
|
|
32
23
|
// If you need to use this metadata it should be stored separately.
|
|
33
24
|
this._projectSchemaJSON = (0, _omit.default)(unfilteredProjectSchema, ['created', 'updated', 'version']);
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
get json() {
|
|
37
27
|
return this._projectSchemaJSON;
|
|
38
28
|
}
|
|
39
|
-
|
|
40
29
|
get projectId() {
|
|
41
30
|
return this.json.projectId;
|
|
42
31
|
}
|
|
43
|
-
|
|
44
32
|
get $schema() {
|
|
45
33
|
return this.json.$schema;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
get author() {
|
|
49
36
|
return this.json.author;
|
|
50
37
|
}
|
|
51
|
-
|
|
52
38
|
getShapeByName(shapeName) {
|
|
53
39
|
const shapeJSON = (0, _schemaUtil.getShape)(this.json, shapeName);
|
|
54
|
-
|
|
55
40
|
if (!shapeJSON) {
|
|
56
41
|
return undefined;
|
|
57
42
|
}
|
|
58
|
-
|
|
59
43
|
const shapeRefItem = (0, _refs.shapeToRefItem)(this.json, shapeJSON);
|
|
60
44
|
return new _shape.ShapeModel(this, shapeRefItem);
|
|
61
45
|
}
|
|
62
|
-
|
|
63
46
|
getShapeById(shapeId) {
|
|
64
47
|
const shapeJSON = (0, _schemaUtil.getShapeById)(this.json, shapeId);
|
|
65
|
-
|
|
66
48
|
if (!shapeJSON) {
|
|
67
49
|
return undefined;
|
|
68
50
|
}
|
|
69
|
-
|
|
70
51
|
const shapeRefItem = (0, _refs.shapeToRefItem)(this.json, shapeJSON);
|
|
71
52
|
return new _shape.ShapeModel(this, shapeRefItem);
|
|
72
53
|
}
|
|
73
|
-
|
|
74
54
|
getShapeByRef(shapeRef) {
|
|
75
55
|
return new _shape.ShapeModel(this, shapeRef);
|
|
76
56
|
}
|
|
77
|
-
|
|
78
57
|
get shapes() {
|
|
79
58
|
this._cache.shapes = this._cache.shapes ?? Object.keys(this.json.shapes).map(name => new _shape.ShapeModel(this, (0, _refs.shapeNameToRef)(this.json, name)));
|
|
80
59
|
return this._cache.shapes;
|
|
81
60
|
}
|
|
82
|
-
|
|
83
61
|
get refs() {
|
|
84
62
|
this._cache.refs = this._cache.refs ?? (0, _schemaUtil.getAllRefs)(this.json);
|
|
85
63
|
return this._cache.refs;
|
|
86
64
|
}
|
|
87
|
-
|
|
88
65
|
getQueryByName(queryName) {
|
|
89
66
|
return new _query.QueryModel(this, 'query', queryName);
|
|
90
67
|
}
|
|
91
|
-
|
|
92
68
|
get queries() {
|
|
93
69
|
this._cache.queries = this._cache.queries ?? Object.keys(this.json.queries).map(name => new _query.QueryModel(this, 'query', name));
|
|
94
70
|
return this._cache.queries;
|
|
95
71
|
}
|
|
96
|
-
|
|
97
72
|
getMutationByName(mutationName) {
|
|
98
73
|
return new _query.QueryModel(this, 'mutation', mutationName);
|
|
99
74
|
}
|
|
100
|
-
|
|
101
75
|
get mutations() {
|
|
102
76
|
this._cache.mutations = Object.keys(this.json.mutations).map(name => new _query.QueryModel(this, 'mutation', name));
|
|
103
77
|
return this._cache.mutations;
|
|
104
78
|
}
|
|
105
|
-
|
|
106
79
|
getServiceById(serviceId) {
|
|
107
80
|
return new _service.ServiceConfig(this, serviceId);
|
|
108
81
|
}
|
|
109
|
-
|
|
110
82
|
atRefToRefItem(atRef, template) {
|
|
111
83
|
return (0, _refs.atRefToRefItem)(this.json, atRef, template);
|
|
112
84
|
}
|
|
113
|
-
|
|
114
85
|
refItemToShape(refItem) {
|
|
115
86
|
return new _shape.ShapeModel(this, refItem);
|
|
116
87
|
}
|
|
117
|
-
|
|
118
88
|
getRef(refSchema) {
|
|
119
89
|
return (0, _refs.getRef)(this.json, refSchema);
|
|
120
90
|
}
|
|
121
|
-
|
|
122
91
|
shapeNameToRef(shapeName) {
|
|
123
92
|
return (0, _refs.shapeNameToRef)(this.json, shapeName);
|
|
124
93
|
}
|
|
125
|
-
|
|
126
94
|
shapeNameToRefItem(shapeName) {
|
|
127
95
|
return (0, _refs.shapeNameToRefItem)(this.json, shapeName);
|
|
128
96
|
}
|
|
129
|
-
|
|
130
97
|
}
|
|
131
|
-
|
|
132
98
|
exports.ProjectSchema = ProjectSchema;
|
package/dist/models/query.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.QueryModel = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Create a model object representing a query or mutation.
|
|
10
9
|
*/
|
|
@@ -14,31 +13,23 @@ class QueryModel {
|
|
|
14
13
|
this._queryName = _queryName;
|
|
15
14
|
this._rawQuery = projectSchemaModel.json[_queryType === 'query' ? 'queries' : 'mutations'][_queryName];
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
get queryType() {
|
|
19
17
|
return this._queryType;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
get name() {
|
|
23
20
|
return this._queryName;
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
get json() {
|
|
27
23
|
return this._rawQuery;
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
get description() {
|
|
31
26
|
return this.json.description;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
get resolver() {
|
|
35
29
|
return this.json.resolver;
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
get returnShape() {
|
|
39
32
|
return this.json.shape;
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
}
|
|
43
|
-
|
|
44
35
|
exports.QueryModel = QueryModel;
|
package/dist/models/service.js
CHANGED
|
@@ -4,31 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ServiceConfig = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Create a model object representing a service configuration.
|
|
10
9
|
*/
|
|
11
10
|
class ServiceConfig {
|
|
12
11
|
constructor(projectSchemaModel, _serviceId) {
|
|
13
12
|
var _projectSchemaModel$j;
|
|
14
|
-
|
|
15
13
|
this._serviceId = _serviceId;
|
|
16
|
-
|
|
17
14
|
if (!((_projectSchemaModel$j = projectSchemaModel.json.services) !== null && _projectSchemaModel$j !== void 0 && _projectSchemaModel$j[_serviceId])) {
|
|
18
15
|
throw new Error(`Could not create service model for ${_serviceId}`);
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
this._storedServiceConfig = projectSchemaModel.json.services[_serviceId];
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
get id() {
|
|
25
20
|
return this._serviceId;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
get json() {
|
|
29
23
|
return this._storedServiceConfig;
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
exports.ServiceConfig = ServiceConfig;
|
package/dist/models/shape.js
CHANGED
|
@@ -4,113 +4,84 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ShapeModel = void 0;
|
|
7
|
-
|
|
8
7
|
var _refs = require("../refs");
|
|
9
|
-
|
|
10
8
|
var _schemaUtil = require("../schema-util");
|
|
11
|
-
|
|
12
9
|
var _interfaces = require("../interfaces");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* Create a shape model from either a ref item or a ref string such as `rick:Character`
|
|
16
12
|
*/
|
|
17
13
|
class ShapeModel {
|
|
18
14
|
constructor(_projectSchemaModel, refArg) {
|
|
19
15
|
this._projectSchemaModel = _projectSchemaModel;
|
|
20
|
-
|
|
21
16
|
if (typeof refArg === 'string') {
|
|
22
17
|
const rawShape = (0, _schemaUtil.getShapeByRef)(_projectSchemaModel.json, refArg);
|
|
23
|
-
|
|
24
18
|
if (!rawShape) {
|
|
25
19
|
throw new Error(`Error creating shape model: ${refArg} is not in project schema`);
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
this._rawShape = rawShape;
|
|
29
22
|
this._shapeRefItem = _projectSchemaModel.atRefToRefItem(refArg);
|
|
30
23
|
this._shapeAtRef = refArg;
|
|
31
24
|
} else {
|
|
32
25
|
const rawShape = (0, _refs.refItemToShape)(_projectSchemaModel.json, refArg);
|
|
33
|
-
|
|
34
26
|
if (!rawShape) {
|
|
35
27
|
throw new Error(`Error creating shape model: ref item argument could not be resolved to a shape`);
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
this._rawShape = rawShape;
|
|
39
30
|
this._shapeRefItem = refArg;
|
|
40
31
|
this._shapeAtRef = `${refArg.serviceKey}:${refArg.typeName}`;
|
|
41
32
|
}
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
get json() {
|
|
45
35
|
return this._rawShape;
|
|
46
36
|
}
|
|
47
|
-
|
|
48
37
|
get id() {
|
|
49
38
|
return this._rawShape.id;
|
|
50
39
|
}
|
|
51
|
-
|
|
52
40
|
get name() {
|
|
53
41
|
return this._rawShape.name;
|
|
54
42
|
}
|
|
55
|
-
|
|
56
43
|
get title() {
|
|
57
44
|
return this._rawShape.title;
|
|
58
45
|
}
|
|
59
|
-
|
|
60
46
|
get description() {
|
|
61
47
|
return this._rawShape.description;
|
|
62
48
|
}
|
|
63
|
-
|
|
64
49
|
get schema() {
|
|
65
50
|
return this._rawShape.schema;
|
|
66
51
|
}
|
|
67
|
-
|
|
68
52
|
get schemaPropertyList() {
|
|
69
53
|
return (0, _schemaUtil.createSchemaPropertyList)(this._projectSchemaModel.json, this._rawShape);
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
get schemaPropertyAccessor() {
|
|
73
56
|
return (0, _schemaUtil.createSchemaPropertyAccessor)(this._projectSchemaModel.json, this._rawShape);
|
|
74
57
|
}
|
|
75
|
-
|
|
76
58
|
get refString() {
|
|
77
59
|
return this._shapeAtRef;
|
|
78
60
|
}
|
|
79
|
-
|
|
80
61
|
get refItem() {
|
|
81
62
|
return this._shapeRefItem;
|
|
82
63
|
}
|
|
83
|
-
|
|
84
64
|
get serviceId() {
|
|
85
65
|
return this._shapeRefItem.serviceKey;
|
|
86
66
|
}
|
|
87
|
-
|
|
88
67
|
get modelType() {
|
|
89
68
|
var _this$_rawShape$model;
|
|
90
|
-
|
|
91
69
|
return (_this$_rawShape$model = this._rawShape.model) === null || _this$_rawShape$model === void 0 ? void 0 : _this$_rawShape$model.type;
|
|
92
70
|
}
|
|
93
|
-
|
|
94
71
|
get interfaces() {
|
|
95
72
|
return this._rawShape.interfaces;
|
|
96
73
|
}
|
|
97
|
-
|
|
98
74
|
get isModel() {
|
|
99
75
|
return (0, _schemaUtil.isModelShape)(this._rawShape);
|
|
100
76
|
}
|
|
101
|
-
|
|
102
77
|
get isCached() {
|
|
103
78
|
return (0, _schemaUtil.isCachedShape)(this._rawShape);
|
|
104
79
|
}
|
|
105
|
-
|
|
106
80
|
get isAsset() {
|
|
107
81
|
return this._rawShape.id === 'ASSET';
|
|
108
82
|
}
|
|
109
|
-
|
|
110
83
|
get isInterfaceShape() {
|
|
111
84
|
return (0, _interfaces.isInterfaceShape)(this._rawShape);
|
|
112
85
|
}
|
|
113
|
-
|
|
114
86
|
}
|
|
115
|
-
|
|
116
87
|
exports.ShapeModel = ShapeModel;
|