@takeshape/schema 8.39.3 → 8.43.1
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/flatten-templates.js +2 -1
- package/es/layers/layers.js +1 -1
- package/es/layers/type-utils.js +8 -11
- package/es/schemas/project-schema/v4.0.0.json +110 -58
- package/lib/flatten-templates.d.ts.map +1 -1
- package/lib/flatten-templates.js +3 -1
- package/lib/layers/layers.d.ts +3 -3
- package/lib/layers/layers.d.ts.map +1 -1
- package/lib/layers/layers.js +1 -1
- package/lib/layers/refs.d.ts +11 -11
- package/lib/layers/refs.d.ts.map +1 -1
- package/lib/layers/type-utils.d.ts +6 -7
- package/lib/layers/type-utils.d.ts.map +1 -1
- package/lib/layers/type-utils.js +8 -13
- package/lib/layers/visitor.d.ts +3 -3
- package/lib/layers/visitor.d.ts.map +1 -1
- package/lib/project-schema/v4.0.0.d.ts +72 -55
- package/lib/project-schema/v4.0.0.d.ts.map +1 -1
- package/lib/schemas/index.d.ts +87 -25
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/project-schema/v4.0.0.json +110 -58
- package/package.json +4 -4
package/es/flatten-templates.js
CHANGED
|
@@ -2,6 +2,7 @@ import { resolveTemplate, isValidTemplate } from './template-shapes';
|
|
|
2
2
|
import { getAllRefs } from './schema-util';
|
|
3
3
|
import set from 'lodash/set';
|
|
4
4
|
import { deepClone } from '@takeshape/util';
|
|
5
|
+
import { refItemToShapeName } from './refs';
|
|
5
6
|
export function flattenTemplates(projectSchema) {
|
|
6
7
|
const templateRefs = getAllRefs(projectSchema, ref => Boolean(ref.template));
|
|
7
8
|
|
|
@@ -16,7 +17,7 @@ export function flattenTemplates(projectSchema) {
|
|
|
16
17
|
const {
|
|
17
18
|
shapeName,
|
|
18
19
|
dependencies
|
|
19
|
-
} = resolveTemplate(projectSchema, ref.template, ref
|
|
20
|
+
} = resolveTemplate(projectSchema, ref.template, refItemToShapeName(ref));
|
|
20
21
|
set(newSchema, ref.path, shapeName);
|
|
21
22
|
Object.assign(newSchema.shapes, dependencies);
|
|
22
23
|
}
|
package/es/layers/layers.js
CHANGED
|
@@ -173,7 +173,7 @@ export function collectReferencedShapeNames(layerId, refSet) {
|
|
|
173
173
|
const collect = schema => {
|
|
174
174
|
const args = schema['@args'];
|
|
175
175
|
|
|
176
|
-
if (args &&
|
|
176
|
+
if (args && typeof args === 'object') {
|
|
177
177
|
Object.values(args.properties).forEach(collect);
|
|
178
178
|
}
|
|
179
179
|
|
package/es/layers/type-utils.js
CHANGED
|
@@ -128,18 +128,15 @@ export function isParameterSerializeStyleOptions(maybeStyle) {
|
|
|
128
128
|
export function isRefSchema(maybeRefSchema) {
|
|
129
129
|
return isString(maybeRefSchema['@ref']) || isString(maybeRefSchema.$ref);
|
|
130
130
|
}
|
|
131
|
-
export function isAllOfSchema(
|
|
132
|
-
return isArray(
|
|
131
|
+
export function isAllOfSchema(schema) {
|
|
132
|
+
return isArray(schema.allOf);
|
|
133
133
|
}
|
|
134
|
-
export function isOneOfSchema(
|
|
135
|
-
return isArray(
|
|
134
|
+
export function isOneOfSchema(schema) {
|
|
135
|
+
return isArray(schema.oneOf);
|
|
136
136
|
}
|
|
137
|
-
export function isArraySchema(
|
|
138
|
-
return
|
|
137
|
+
export function isArraySchema(schema) {
|
|
138
|
+
return schema.type === 'array' && isObject(schema.items);
|
|
139
139
|
}
|
|
140
|
-
export function isObjectSchema(
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
export function isContentObjectSchema(maybeSchema) {
|
|
144
|
-
return isRefSchema(maybeSchema) || isAllOfSchema(maybeSchema) || isObjectSchema(maybeSchema);
|
|
140
|
+
export function isObjectSchema(schema) {
|
|
141
|
+
return schema.type === 'object' && isObject(schema.properties);
|
|
145
142
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"type": "array",
|
|
8
8
|
"minItems": 1,
|
|
9
9
|
"items": {
|
|
10
|
-
"$ref": "#/definitions/
|
|
10
|
+
"$ref": "#/definitions/propertySchema"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"nonNegativeInteger": {
|
|
@@ -100,14 +100,29 @@
|
|
|
100
100
|
},
|
|
101
101
|
"required": ["$ref"]
|
|
102
102
|
},
|
|
103
|
+
"shapeSchemaEnum": {
|
|
104
|
+
"title": "Shape Schema Enum",
|
|
105
|
+
"type": "object",
|
|
106
|
+
"properties": {
|
|
107
|
+
"enum": {
|
|
108
|
+
"type": "array",
|
|
109
|
+
"items": {
|
|
110
|
+
"type": "string"
|
|
111
|
+
},
|
|
112
|
+
"minItems": 1
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"additionalProperties": false,
|
|
116
|
+
"required": ["enum"]
|
|
117
|
+
},
|
|
103
118
|
"objectSchema": {
|
|
104
119
|
"title": "Object Schema",
|
|
120
|
+
"type": "object",
|
|
105
121
|
"allOf": [
|
|
106
122
|
{
|
|
107
|
-
"$ref": "#/definitions/
|
|
123
|
+
"$ref": "#/definitions/propertySchema"
|
|
108
124
|
},
|
|
109
125
|
{
|
|
110
|
-
"type": "object",
|
|
111
126
|
"properties": {
|
|
112
127
|
"type": {
|
|
113
128
|
"type": "string",
|
|
@@ -116,7 +131,7 @@
|
|
|
116
131
|
"properties": {
|
|
117
132
|
"type": "object",
|
|
118
133
|
"additionalProperties": {
|
|
119
|
-
"$ref": "#/definitions/
|
|
134
|
+
"$ref": "#/definitions/propertySchema"
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
},
|
|
@@ -124,12 +139,12 @@
|
|
|
124
139
|
}
|
|
125
140
|
]
|
|
126
141
|
},
|
|
127
|
-
"
|
|
128
|
-
"title": "Array Schema",
|
|
142
|
+
"returnShapeArraySchema": {
|
|
143
|
+
"title": "Return Shape Array Schema",
|
|
129
144
|
"type": "object",
|
|
130
145
|
"allOf": [
|
|
131
146
|
{
|
|
132
|
-
"$ref": "#/definitions/
|
|
147
|
+
"$ref": "#/definitions/propertySchema"
|
|
133
148
|
},
|
|
134
149
|
{
|
|
135
150
|
"properties": {
|
|
@@ -138,29 +153,26 @@
|
|
|
138
153
|
"const": "array"
|
|
139
154
|
},
|
|
140
155
|
"items": {
|
|
141
|
-
"
|
|
156
|
+
"oneOf": [
|
|
157
|
+
{"$ref": "#/definitions/refSchema"},
|
|
158
|
+
{
|
|
159
|
+
"type": "object",
|
|
160
|
+
"properties": {
|
|
161
|
+
"type": {
|
|
162
|
+
"enum": ["boolean", "integer", "number", "string"]
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"required": ["type"]
|
|
166
|
+
}
|
|
167
|
+
]
|
|
142
168
|
}
|
|
143
169
|
},
|
|
144
170
|
"required": ["type", "items"]
|
|
145
171
|
}
|
|
146
172
|
]
|
|
147
173
|
},
|
|
148
|
-
"
|
|
149
|
-
"title": "
|
|
150
|
-
"type": "object",
|
|
151
|
-
"properties": {
|
|
152
|
-
"enum": {
|
|
153
|
-
"type": "array",
|
|
154
|
-
"items": {
|
|
155
|
-
"type": "string"
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
"required": ["enum"],
|
|
160
|
-
"additionalProperties": false
|
|
161
|
-
},
|
|
162
|
-
"allOfSchema": {
|
|
163
|
-
"title": "All Of Schema",
|
|
174
|
+
"shapeSchemaAllOf": {
|
|
175
|
+
"title": "Shape Schema All Of",
|
|
164
176
|
"type": "object",
|
|
165
177
|
"properties": {
|
|
166
178
|
"allOf": {
|
|
@@ -184,8 +196,37 @@
|
|
|
184
196
|
"required": ["allOf"],
|
|
185
197
|
"additionalProperties": false
|
|
186
198
|
},
|
|
187
|
-
"
|
|
188
|
-
"title": "
|
|
199
|
+
"allOfSchema": {
|
|
200
|
+
"title": "AllOfSchema",
|
|
201
|
+
"allOf": [
|
|
202
|
+
{"$ref": "#/definitions/propertySchema"},
|
|
203
|
+
{
|
|
204
|
+
"type": "object",
|
|
205
|
+
"properties": {
|
|
206
|
+
"allOf": {
|
|
207
|
+
"type": "array",
|
|
208
|
+
"items": {
|
|
209
|
+
"oneOf": [
|
|
210
|
+
{
|
|
211
|
+
"$ref": "#/definitions/refSchema"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"$ref": "#/definitions/refSchemaLegacy"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"$ref": "#/definitions/objectSchema"
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
"unevaluatedProperties": true
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
"required": ["allOf"]
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
"shapeSchemaOneOf": {
|
|
229
|
+
"title": "Shape Schema One Of",
|
|
189
230
|
"type": "object",
|
|
190
231
|
"properties": {
|
|
191
232
|
"oneOf": {
|
|
@@ -209,30 +250,46 @@
|
|
|
209
250
|
"required": ["oneOf"],
|
|
210
251
|
"additionalProperties": false
|
|
211
252
|
},
|
|
212
|
-
"
|
|
213
|
-
"title": "
|
|
214
|
-
"
|
|
215
|
-
|
|
216
|
-
{
|
|
217
|
-
"$ref": "#/definitions/allOfSchema"
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
"$ref": "#/definitions/oneOfSchema"
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
"$ref": "#/definitions/refSchema"
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
"$ref": "#/definitions/refSchemaLegacy"
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
"$ref": "#/definitions/objectSchema"
|
|
230
|
-
},
|
|
253
|
+
"oneOfSchema": {
|
|
254
|
+
"title": "OneOfSchema",
|
|
255
|
+
"allOf": [
|
|
256
|
+
{"$ref": "#/definitions/propertySchema"},
|
|
231
257
|
{
|
|
232
|
-
"
|
|
258
|
+
"type": "object",
|
|
259
|
+
"properties": {
|
|
260
|
+
"oneOf": {
|
|
261
|
+
"type": "array",
|
|
262
|
+
"items": {
|
|
263
|
+
"oneOf": [
|
|
264
|
+
{
|
|
265
|
+
"$ref": "#/definitions/refSchema"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"$ref": "#/definitions/refSchemaLegacy"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"$ref": "#/definitions/objectSchema"
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
"unevaluatedProperties": true
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"required": ["oneOf"],
|
|
279
|
+
"additionalProperties": false
|
|
233
280
|
}
|
|
234
281
|
]
|
|
235
282
|
},
|
|
283
|
+
"shapeSchema": {
|
|
284
|
+
"title": "Shape Schema",
|
|
285
|
+
"type": "object",
|
|
286
|
+
"oneOf": [
|
|
287
|
+
{"$ref": "#/definitions/shapeSchemaAllOf"},
|
|
288
|
+
{"$ref": "#/definitions/shapeSchemaOneOf"},
|
|
289
|
+
{"$ref": "#/definitions/shapeSchemaEnum"},
|
|
290
|
+
{"$ref": "#/definitions/objectSchema"}
|
|
291
|
+
]
|
|
292
|
+
},
|
|
236
293
|
"queryMap": {
|
|
237
294
|
"title": "Query Map",
|
|
238
295
|
"type": "object",
|
|
@@ -244,11 +301,11 @@
|
|
|
244
301
|
},
|
|
245
302
|
"args": {
|
|
246
303
|
"title": "Args",
|
|
247
|
-
"oneOf": [{"type": "string"}, {"$ref": "#/definitions/
|
|
304
|
+
"oneOf": [{"type": "string"}, {"$ref": "#/definitions/objectSchema"}]
|
|
248
305
|
},
|
|
249
306
|
"returnShape": {
|
|
250
307
|
"title": "Return Shape",
|
|
251
|
-
"oneOf": [{"type": "string"}, {"$ref": "#/definitions/
|
|
308
|
+
"oneOf": [{"type": "string"}, {"$ref": "#/definitions/returnShapeArraySchema"}]
|
|
252
309
|
},
|
|
253
310
|
"directiveConfigItem": {
|
|
254
311
|
"title": "Directive Config Item",
|
|
@@ -1249,8 +1306,8 @@
|
|
|
1249
1306
|
},
|
|
1250
1307
|
"required": ["resolver", "shape"]
|
|
1251
1308
|
},
|
|
1252
|
-
"
|
|
1253
|
-
"title": "
|
|
1309
|
+
"propertySchema": {
|
|
1310
|
+
"title": "Property Schema",
|
|
1254
1311
|
"type": "object",
|
|
1255
1312
|
"properties": {
|
|
1256
1313
|
"$ref": {
|
|
@@ -1301,7 +1358,7 @@
|
|
|
1301
1358
|
"format": "regex"
|
|
1302
1359
|
},
|
|
1303
1360
|
"items": {
|
|
1304
|
-
"$ref": "#/definitions/
|
|
1361
|
+
"$ref": "#/definitions/propertySchema"
|
|
1305
1362
|
},
|
|
1306
1363
|
"maxItems": {
|
|
1307
1364
|
"$ref": "#/definitions/nonNegativeInteger"
|
|
@@ -1325,7 +1382,7 @@
|
|
|
1325
1382
|
"properties": {
|
|
1326
1383
|
"type": "object",
|
|
1327
1384
|
"additionalProperties": {
|
|
1328
|
-
"$ref": "#/definitions/
|
|
1385
|
+
"$ref": "#/definitions/propertySchema"
|
|
1329
1386
|
},
|
|
1330
1387
|
"default": {}
|
|
1331
1388
|
},
|
|
@@ -1442,12 +1499,7 @@
|
|
|
1442
1499
|
"enum": ["extend", "replace"]
|
|
1443
1500
|
},
|
|
1444
1501
|
"schema": {
|
|
1445
|
-
"
|
|
1446
|
-
{"$ref": "#/definitions/objectSchema"},
|
|
1447
|
-
{"$ref": "#/definitions/allOfSchema"},
|
|
1448
|
-
{"$ref": "#/definitions/oneOfSchema"},
|
|
1449
|
-
{"$ref": "#/definitions/enumSchema"}
|
|
1450
|
-
]
|
|
1502
|
+
"$ref": "#/definitions/shapeSchema"
|
|
1451
1503
|
}
|
|
1452
1504
|
},
|
|
1453
1505
|
"required": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatten-templates.d.ts","sourceRoot":"","sources":["../../src/flatten-templates.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"flatten-templates.d.ts","sourceRoot":"","sources":["../../src/flatten-templates.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAM/C,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,CAgB5E"}
|
package/lib/flatten-templates.js
CHANGED
|
@@ -13,6 +13,8 @@ var _set = _interopRequireDefault(require("lodash/set"));
|
|
|
13
13
|
|
|
14
14
|
var _util = require("@takeshape/util");
|
|
15
15
|
|
|
16
|
+
var _refs = require("./refs");
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
20
|
function flattenTemplates(projectSchema) {
|
|
@@ -29,7 +31,7 @@ function flattenTemplates(projectSchema) {
|
|
|
29
31
|
const {
|
|
30
32
|
shapeName,
|
|
31
33
|
dependencies
|
|
32
|
-
} = (0, _templateShapes.resolveTemplate)(projectSchema, ref.template,
|
|
34
|
+
} = (0, _templateShapes.resolveTemplate)(projectSchema, ref.template, (0, _refs.refItemToShapeName)(ref));
|
|
33
35
|
(0, _set.default)(newSchema, ref.path, shapeName);
|
|
34
36
|
Object.assign(newSchema.shapes, dependencies);
|
|
35
37
|
}
|
package/lib/layers/layers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertySchemaV4_0_0, FlattenedSchemaV4_0_0, LayerSchemaV4_0_0, ObjectSchemaV4_0_0, ProjectSchemaV4_0_0, QueryV4_0_0, ShapeMapV4_0_0 } from '../project-schema';
|
|
2
2
|
import { RefItemWithPath } from './refs';
|
|
3
3
|
export declare type GetLayer = (layerId: string) => LayerSchemaV4_0_0 | undefined;
|
|
4
|
-
export declare function isObjectSchemaV4_0_0(maybeObjectSchema:
|
|
4
|
+
export declare function isObjectSchemaV4_0_0(maybeObjectSchema: PropertySchemaV4_0_0): maybeObjectSchema is ObjectSchemaV4_0_0;
|
|
5
5
|
export declare type RefPredicate = (ref: RefItemWithPath) => boolean;
|
|
6
6
|
/**
|
|
7
7
|
* Walk through a `ProjectSchema` and collect all the `ref`s.
|
|
@@ -21,7 +21,7 @@ export declare function getAllRefsInQueries(context: SchemaContext, rootProperty
|
|
|
21
21
|
* @param predicate return true to include the ref in
|
|
22
22
|
*/
|
|
23
23
|
export declare function getAllRefs(projectSchema: SchemaContext, predicate?: RefPredicate): RefItemWithPath[];
|
|
24
|
-
export declare function collectReferencedShapeNames(layerId: string, refSet: Set<string>): (schema:
|
|
24
|
+
export declare function collectReferencedShapeNames(layerId: string, refSet: Set<string>): (schema: PropertySchemaV4_0_0) => void;
|
|
25
25
|
export declare function flattenSchema(projectSchema: ProjectSchemaV4_0_0, getLayer: GetLayer): FlattenedSchemaV4_0_0;
|
|
26
26
|
export {};
|
|
27
27
|
//# sourceMappingURL=layers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/layers/layers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/layers/layers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EAErB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EAEnB,WAAW,EACX,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAIL,eAAe,EAIhB,MAAM,QAAQ,CAAC;AAMhB,oBAAY,QAAQ,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;AA+B1E,wBAAgB,oBAAoB,CAAC,iBAAiB,EAAE,oBAAoB,GAAG,iBAAiB,IAAI,kBAAkB,CAErH;AA8BD,oBAAY,YAAY,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC;AAQ7D;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG,eAAe,EAAE,CA0BtG;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EAAE,EACnB,KAAK,EAAE,WAAW,EAClB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,GAC5C,eAAe,EAAE,CA8BnB;AAED,aAAK,aAAa,GAAG,IAAI,CAAC,qBAAqB,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC;AAErF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,gBAAgB,EAAE,SAAS,GAAG,WAAW,EACzC,SAAS,CAAC,EAAE,YAAY,GACvB,eAAe,EAAE,CAanB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG,eAAe,EAAE,CAMpG;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,YAErD,oBAAoB,KAAG,IAAI,CAkBrD;AAuFD,wBAAgB,aAAa,CAAC,aAAa,EAAE,mBAAmB,EAAE,QAAQ,EAAE,QAAQ,GAAG,qBAAqB,CAgF3G"}
|
package/lib/layers/layers.js
CHANGED
|
@@ -199,7 +199,7 @@ function collectReferencedShapeNames(layerId, refSet) {
|
|
|
199
199
|
const collect = schema => {
|
|
200
200
|
const args = schema['@args'];
|
|
201
201
|
|
|
202
|
-
if (args &&
|
|
202
|
+
if (args && typeof args === 'object') {
|
|
203
203
|
Object.values(args.properties).forEach(collect);
|
|
204
204
|
}
|
|
205
205
|
|
package/lib/layers/refs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import type { SchemaPath } from '../types';
|
|
3
3
|
import type { Maybe } from '@takeshape/util';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PropertySchemaV4_0_0, QueryV4_0_0, ShapeMapV4_0_0, ShapeV4_0_0, ReturnShapeV4_0_0 } from '../project-schema';
|
|
5
5
|
/**
|
|
6
6
|
* This interface describes a parsed `@ref` or `$ref`.
|
|
7
7
|
* The intended usage is to convert a schema with a ref to a RefItem which can then
|
|
@@ -54,19 +54,19 @@ export declare function atRefToRefItem(atRef: string, template?: string): RefIte
|
|
|
54
54
|
* Given a content schema and project schema, finds a `@ref` or `$ref` and
|
|
55
55
|
* returns a `RefItem` suitable for loading a referenced schema...
|
|
56
56
|
*/
|
|
57
|
-
export declare function getRef(refSchema:
|
|
58
|
-
export declare function getRefWithPath(refSchema:
|
|
57
|
+
export declare function getRef(refSchema: PropertySchemaV4_0_0): Maybe<RefItem>;
|
|
58
|
+
export declare function getRefWithPath(refSchema: PropertySchemaV4_0_0, schemaPath?: SchemaPath): Maybe<RefItemWithPath>;
|
|
59
59
|
/**
|
|
60
60
|
* Tests for a `@ref` or `$ref` property directly on the passed schema.
|
|
61
61
|
*
|
|
62
62
|
* @param schema Any schema that might could have a ref property.
|
|
63
63
|
*/
|
|
64
|
-
export declare function hasRefProperty(schema:
|
|
64
|
+
export declare function hasRefProperty(schema: PropertySchemaV4_0_0): boolean;
|
|
65
65
|
/**
|
|
66
66
|
* From a schema with a ref, will return the top-level ref, and potentially
|
|
67
67
|
* a ref item from a nested `items` property.
|
|
68
68
|
*/
|
|
69
|
-
export declare function getRefOrItemsRef(refSchema:
|
|
69
|
+
export declare function getRefOrItemsRef(refSchema: PropertySchemaV4_0_0, schemaPath?: SchemaPath): Maybe<RefItemWithPath>;
|
|
70
70
|
/**
|
|
71
71
|
* Turns a `RefItem` into an `@ref`.
|
|
72
72
|
*/
|
|
@@ -78,22 +78,22 @@ export declare function refItemToShape(shapes: ShapeMapV4_0_0, refItem: RefItem)
|
|
|
78
78
|
/**
|
|
79
79
|
* Helper fn to omit `ref` props from the target schema, and then extend it with the source schema.
|
|
80
80
|
*/
|
|
81
|
-
export declare const omitRefAndExtend: (targetSchema:
|
|
81
|
+
export declare const omitRefAndExtend: (targetSchema: PropertySchemaV4_0_0, sourceSchema: PropertySchemaV4_0_0) => import("lodash").Omit<PropertySchemaV4_0_0, "@ref" | "$ref"> & PropertySchemaV4_0_0;
|
|
82
82
|
/**
|
|
83
83
|
* If there is a $ref, this will insert a content schema from the top level
|
|
84
84
|
* in place of the reference.
|
|
85
85
|
*/
|
|
86
|
-
export declare function followRef(shapes: ShapeMapV4_0_0, contentSchema:
|
|
86
|
+
export declare function followRef(shapes: ShapeMapV4_0_0, contentSchema: PropertySchemaV4_0_0): PropertySchemaV4_0_0;
|
|
87
87
|
/**
|
|
88
88
|
* Returns whether a schema has refs.
|
|
89
89
|
*/
|
|
90
|
-
export declare function hasRef(contentSchema:
|
|
90
|
+
export declare function hasRef(contentSchema: PropertySchemaV4_0_0): boolean;
|
|
91
91
|
/**
|
|
92
92
|
* Returns whether a schema has refs which can be followed.
|
|
93
93
|
*/
|
|
94
|
-
export declare function hasResolvableRef(shapes: ShapeMapV4_0_0, contentSchema:
|
|
95
|
-
export declare function getArgsReferenceWithPath(argsSchema:
|
|
96
|
-
export declare function dereferenceSchema(shapes: ShapeMapV4_0_0, shapeOrFieldSchema:
|
|
94
|
+
export declare function hasResolvableRef(shapes: ShapeMapV4_0_0, contentSchema: PropertySchemaV4_0_0): boolean;
|
|
95
|
+
export declare function getArgsReferenceWithPath(argsSchema: PropertySchemaV4_0_0 | QueryV4_0_0, schemaPath?: SchemaPath): Maybe<RefItemWithPath>;
|
|
96
|
+
export declare function dereferenceSchema(shapes: ShapeMapV4_0_0, shapeOrFieldSchema: PropertySchemaV4_0_0, schemaPath?: SchemaPath): PropertySchemaV4_0_0;
|
|
97
97
|
export interface ParsedReturnShape {
|
|
98
98
|
isArray: boolean;
|
|
99
99
|
template?: string;
|
package/lib/layers/refs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../src/layers/refs.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../src/layers/refs.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,WAAW,EACX,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAS3B;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAIrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,CAEtG;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAW1D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAQxE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,oBAAoB,GAAG,KAAK,CAAC,OAAO,CAAC,CAKtE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MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,iBAAiB,CAqB5E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasicResolverV4_0_0, ComposeResolverV4_0_0, TakeshapeResolverV4_0_0, GraphqlResolverV4_0_0, RestResolverV4_0_0, AwsLambdaResolverV4_0_0, UtilResolverV4_0_0, DirectiveMappingMapV4_0_0, DirectiveConfigV4_0_0, DirectiveMappingArrayV4_0_0, ParameterSerializeContentOptionsV4_0_0, ParameterOpV4_0_0, ParameterOpNestedV4_0_0, ParameterOpMappingV4_0_0, ParameterOpValueV4_0_0,
|
|
1
|
+
import { BasicResolverV4_0_0, ComposeResolverV4_0_0, TakeshapeResolverV4_0_0, GraphqlResolverV4_0_0, RestResolverV4_0_0, AwsLambdaResolverV4_0_0, UtilResolverV4_0_0, DirectiveMappingMapV4_0_0, DirectiveConfigV4_0_0, DirectiveMappingArrayV4_0_0, ParameterSerializeContentOptionsV4_0_0, ParameterOpV4_0_0, ParameterOpNestedV4_0_0, ParameterOpMappingV4_0_0, ParameterOpValueV4_0_0, PropertySchemaV4_0_0, OneOfSchemaV4_0_0, AllOfSchemaV4_0_0, RefSchemaLegacyV4_0_0, RefSchemaV4_0_0, ParameterSerializeStyleOptionsV4_0_0, ParameterSerializeOptionsV4_0_0, ObjectSchemaV4_0_0, ParameterOpOpV4_0_0, ReturnShapeArraySchemaV4_0_0 } from '../project-schema';
|
|
2
2
|
/** Resolver Type Utils **/
|
|
3
3
|
/**
|
|
4
4
|
* Only tests that the shape is right, not that the name is correct. That's a job for the validator.
|
|
@@ -52,10 +52,9 @@ export declare function isParameterOpOp(maybeOp: ParameterOpV4_0_0): maybeOp is
|
|
|
52
52
|
*/
|
|
53
53
|
export declare function isParameterSerializeStyleOptions(maybeStyle: ParameterSerializeOptionsV4_0_0): maybeStyle is ParameterSerializeStyleOptionsV4_0_0;
|
|
54
54
|
/** Typeguards for different types of shape schemas **/
|
|
55
|
-
export declare function isRefSchema(maybeRefSchema:
|
|
56
|
-
export declare function isAllOfSchema(
|
|
57
|
-
export declare function isOneOfSchema(
|
|
58
|
-
export declare function isArraySchema(
|
|
59
|
-
export declare function isObjectSchema(
|
|
60
|
-
export declare function isContentObjectSchema(maybeSchema: ContentObjectSchemaV4_0_0 | ContentSchemaV4_0_0): maybeSchema is ContentObjectSchemaV4_0_0;
|
|
55
|
+
export declare function isRefSchema(maybeRefSchema: PropertySchemaV4_0_0): maybeRefSchema is RefSchemaV4_0_0 | RefSchemaLegacyV4_0_0;
|
|
56
|
+
export declare function isAllOfSchema(schema: PropertySchemaV4_0_0): schema is AllOfSchemaV4_0_0;
|
|
57
|
+
export declare function isOneOfSchema(schema: PropertySchemaV4_0_0): schema is OneOfSchemaV4_0_0;
|
|
58
|
+
export declare function isArraySchema(schema: PropertySchemaV4_0_0): schema is ReturnShapeArraySchemaV4_0_0;
|
|
59
|
+
export declare function isObjectSchema(schema: PropertySchemaV4_0_0): schema is ObjectSchemaV4_0_0;
|
|
61
60
|
//# sourceMappingURL=type-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../../src/layers/type-utils.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,sCAAsC,EACtC,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,
|
|
1
|
+
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../../src/layers/type-utils.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,E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
|
8
8
|
exports.isAwsLambdaResolver = isAwsLambdaResolver;
|
|
9
9
|
exports.isBasicResolver = isBasicResolver;
|
|
10
10
|
exports.isComposeResolver = isComposeResolver;
|
|
11
|
-
exports.isContentObjectSchema = isContentObjectSchema;
|
|
12
11
|
exports.isDirectiveConfig = isDirectiveConfig;
|
|
13
12
|
exports.isDirectiveMappingArray = isDirectiveMappingArray;
|
|
14
13
|
exports.isDirectiveMappingMap = isDirectiveMappingMap;
|
|
@@ -182,22 +181,18 @@ function isRefSchema(maybeRefSchema) {
|
|
|
182
181
|
return (0, _isString.default)(maybeRefSchema['@ref']) || (0, _isString.default)(maybeRefSchema.$ref);
|
|
183
182
|
}
|
|
184
183
|
|
|
185
|
-
function isAllOfSchema(
|
|
186
|
-
return (0, _isArray.default)(
|
|
184
|
+
function isAllOfSchema(schema) {
|
|
185
|
+
return (0, _isArray.default)(schema.allOf);
|
|
187
186
|
}
|
|
188
187
|
|
|
189
|
-
function isOneOfSchema(
|
|
190
|
-
return (0, _isArray.default)(
|
|
188
|
+
function isOneOfSchema(schema) {
|
|
189
|
+
return (0, _isArray.default)(schema.oneOf);
|
|
191
190
|
}
|
|
192
191
|
|
|
193
|
-
function isArraySchema(
|
|
194
|
-
return
|
|
192
|
+
function isArraySchema(schema) {
|
|
193
|
+
return schema.type === 'array' && (0, _util.isObject)(schema.items);
|
|
195
194
|
}
|
|
196
195
|
|
|
197
|
-
function isObjectSchema(
|
|
198
|
-
return
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function isContentObjectSchema(maybeSchema) {
|
|
202
|
-
return isRefSchema(maybeSchema) || isAllOfSchema(maybeSchema) || isObjectSchema(maybeSchema);
|
|
196
|
+
function isObjectSchema(schema) {
|
|
197
|
+
return schema.type === 'object' && (0, _util.isObject)(schema.properties);
|
|
203
198
|
}
|
package/lib/layers/visitor.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertySchemaV4_0_0, ShapeMapV4_0_0 } from '../project-schema';
|
|
2
2
|
import { SchemaPath } from '../types';
|
|
3
|
-
export declare type PropertyVisitorCallback = (schema:
|
|
4
|
-
export declare function visitSchemaProperties(schema:
|
|
3
|
+
export declare type PropertyVisitorCallback = (schema: PropertySchemaV4_0_0, path: SchemaPath) => void;
|
|
4
|
+
export declare function visitSchemaProperties(schema: PropertySchemaV4_0_0, path: Array<string | number>, callback: PropertyVisitorCallback): void;
|
|
5
5
|
export declare function visitShapeProperties(shapes: ShapeMapV4_0_0, callback: PropertyVisitorCallback): void;
|
|
6
6
|
//# sourceMappingURL=visitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../../../src/layers/visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../../../src/layers/visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,oBAAY,uBAAuB,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AAE/F,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC5B,QAAQ,EAAE,uBAAuB,GAChC,IAAI,CA4BN;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,uBAAuB,GAAG,IAAI,CAIpG"}
|