@takeshape/schema 8.37.0 → 8.38.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/flatten-templates.js +26 -0
- package/es/index.js +2 -1
- package/es/layers/layers.js +1 -1
- package/es/layers/refs.js +1 -1
- package/es/refs.js +74 -2
- package/es/schema-util.js +28 -17
- package/es/template-shapes/index.js +35 -0
- package/es/template-shapes/templates.js +379 -0
- package/es/template-shapes/types.js +1 -0
- package/es/template-shapes/where.js +501 -0
- package/es/validate.js +2 -2
- package/lib/flatten-templates.d.ts +3 -0
- package/lib/flatten-templates.d.ts.map +1 -0
- package/lib/flatten-templates.js +39 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +14 -0
- package/lib/layers/layers.js +3 -3
- package/lib/layers/refs.js +2 -2
- package/lib/refs.d.ts +26 -1
- package/lib/refs.d.ts.map +1 -1
- package/lib/refs.js +94 -11
- package/lib/schema-util.d.ts +7 -6
- package/lib/schema-util.d.ts.map +1 -1
- package/lib/schema-util.js +41 -29
- package/lib/template-shapes/index.d.ts +8 -0
- package/lib/template-shapes/index.d.ts.map +1 -0
- package/lib/template-shapes/index.js +46 -0
- package/lib/template-shapes/templates.d.ts +29 -0
- package/lib/template-shapes/templates.d.ts.map +1 -0
- package/lib/template-shapes/templates.js +427 -0
- package/lib/template-shapes/types.d.ts +10 -0
- package/lib/template-shapes/types.d.ts.map +1 -0
- package/lib/template-shapes/types.js +5 -0
- package/lib/template-shapes/where.d.ts +39 -0
- package/lib/template-shapes/where.d.ts.map +1 -0
- package/lib/template-shapes/where.js +534 -0
- package/lib/validate.js +1 -1
- package/package.json +4 -4
- package/es/template-shapes.js +0 -79
- package/lib/template-shapes.d.ts +0 -32
- package/lib/template-shapes.d.ts.map +0 -1
- package/lib/template-shapes.js +0 -101
package/lib/refs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/refs.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/refs.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAC,MAAM,SAAS,CAAC;AACzE,OAAO,KAAK,EAAC,cAAc,EAAE,KAAK,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAM3C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,oBAAY,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;AACjE,oBAAY,qBAAqB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,QAAQ,CAAC,CAAC;AAElF;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C,IAAI,EAAE,UAAU,CAAC;CAClB;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG;IAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,CAO7G;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;CAC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AAE,cAAc,GAAG,cAAc,CAWhG;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CActD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAchG"}
|
package/lib/refs.js
CHANGED
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.$refToAtRef = $refToAtRef;
|
|
7
7
|
exports.anyRefToShapeSchemaPath = anyRefToShapeSchemaPath;
|
|
8
8
|
exports.atRefToRefItem = atRefToRefItem;
|
|
9
|
+
exports.createTemplateShapeName = createTemplateShapeName;
|
|
9
10
|
exports.followRef = followRef;
|
|
11
|
+
exports.getFlattenedTemplateShapeName = getFlattenedTemplateShapeName;
|
|
10
12
|
exports.getRef = getRef;
|
|
11
13
|
exports.getRefOrItemsRef = getRefOrItemsRef;
|
|
12
14
|
exports.getRefShapeName = getRefShapeName;
|
|
@@ -15,6 +17,8 @@ exports.hasRef = hasRef;
|
|
|
15
17
|
exports.hasRefProperty = hasRefProperty;
|
|
16
18
|
exports.hasResolvableRef = hasResolvableRef;
|
|
17
19
|
exports.omitRefAndExtend = void 0;
|
|
20
|
+
exports.parseReturnShape = parseReturnShape;
|
|
21
|
+
exports.parseTemplateShape = parseTemplateShape;
|
|
18
22
|
exports.refExpressionToRefItem = refExpressionToRefItem;
|
|
19
23
|
exports.refExpressionToShape = refExpressionToShape;
|
|
20
24
|
exports.refItemToAtRef = refItemToAtRef;
|
|
@@ -25,10 +29,9 @@ exports.refItemToShapeSchema = refItemToShapeSchema;
|
|
|
25
29
|
exports.refSchemaToPath = refSchemaToPath;
|
|
26
30
|
exports.refToRefItem = refToRefItem;
|
|
27
31
|
exports.splitAtRef = splitAtRef;
|
|
32
|
+
exports.untemplate = void 0;
|
|
28
33
|
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var _templateShapes = require("./template-shapes");
|
|
34
|
+
var _types = require("./types");
|
|
32
35
|
|
|
33
36
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
34
37
|
|
|
@@ -40,6 +43,86 @@ var _services = require("./services");
|
|
|
40
43
|
|
|
41
44
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
45
|
|
|
46
|
+
const templateShapeRegex = /^(\w+)<([\w:-]+)>$/;
|
|
47
|
+
/**
|
|
48
|
+
* Parse a template like `PaginatedList<Post>` and return both the template and the shape name.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
function parseTemplateShape(shapeExpression) {
|
|
52
|
+
const matches = templateShapeRegex.exec(shapeExpression);
|
|
53
|
+
|
|
54
|
+
if (matches) {
|
|
55
|
+
return {
|
|
56
|
+
shapeName: matches[2],
|
|
57
|
+
template: matches[1]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
shapeName: shapeExpression,
|
|
63
|
+
template: undefined
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function parseReturnShape(projectSchema, shape) {
|
|
68
|
+
if (typeof shape === 'object') {
|
|
69
|
+
if ((0, _types.isRefSchema)(shape.items)) {
|
|
70
|
+
const ref = getRef(projectSchema, shape.items);
|
|
71
|
+
|
|
72
|
+
if (!ref) {
|
|
73
|
+
throw new Error(`Could not parse ${JSON.stringify(shape.items)}: invalid ref`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
isArray: true,
|
|
78
|
+
ref,
|
|
79
|
+
shapeName: refItemToShapeName(ref)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (typeof shape.items.type !== 'string') {
|
|
84
|
+
throw new Error(`Could not parse ${JSON.stringify(shape.items)}: invalid type`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
isArray: true,
|
|
89
|
+
shapeName: shape.items.type
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const ref = refExpressionToRefItem(projectSchema, shape);
|
|
94
|
+
const shapeName = refItemToShapeName(ref);
|
|
95
|
+
return {
|
|
96
|
+
isArray: false,
|
|
97
|
+
shapeName,
|
|
98
|
+
ref,
|
|
99
|
+
template: ref.template
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a template string like `PaginatedList<Post>` from a template and shape name.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
function createTemplateShapeName(template, shapeName) {
|
|
108
|
+
return `${template}<${shapeName}>`;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* If the string is a template like `PaginatedList<Post>`, return the shape name,
|
|
112
|
+
* in this case `Post`. Otherwise return the input.
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
const untemplate = input => {
|
|
117
|
+
return parseTemplateShape(input).shapeName;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
exports.untemplate = untemplate;
|
|
121
|
+
|
|
122
|
+
function getFlattenedTemplateShapeName(shapeName, template) {
|
|
123
|
+
return `${shapeName}${template ?? ''}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
43
126
|
function $refToPath(ref) {
|
|
44
127
|
return ref.substr(2).split('/');
|
|
45
128
|
}
|
|
@@ -81,7 +164,7 @@ function refExpressionToRefItem(context, refExpression) {
|
|
|
81
164
|
const {
|
|
82
165
|
shapeName,
|
|
83
166
|
template
|
|
84
|
-
} =
|
|
167
|
+
} = parseTemplateShape(refExpression);
|
|
85
168
|
|
|
86
169
|
if (shapeName.includes(':')) {
|
|
87
170
|
return atRefToRefItem(context, shapeName, template);
|
|
@@ -189,7 +272,7 @@ function getRefWithPath(context, refSchema, schemaPath = []) {
|
|
|
189
272
|
const refItem = getRef(context, refSchema);
|
|
190
273
|
|
|
191
274
|
if (refItem) {
|
|
192
|
-
const refType = (0,
|
|
275
|
+
const refType = (0, _types.getRefType)(refSchema);
|
|
193
276
|
return { ...refItem,
|
|
194
277
|
path: schemaPath.concat([refType])
|
|
195
278
|
};
|
|
@@ -319,15 +402,15 @@ function followRef(context, schema) {
|
|
|
319
402
|
|
|
320
403
|
|
|
321
404
|
function hasRef(schema) {
|
|
322
|
-
if ((0,
|
|
405
|
+
if ((0, _types.isRefSchema)(schema) || (0, _types.isRefSchemaLegacy)(schema)) {
|
|
323
406
|
return true;
|
|
324
407
|
}
|
|
325
408
|
|
|
326
|
-
if ((0,
|
|
409
|
+
if ((0, _types.isAllOfSchema)(schema)) {
|
|
327
410
|
return Boolean(schema.allOf.find(hasRef));
|
|
328
411
|
}
|
|
329
412
|
|
|
330
|
-
if ((0,
|
|
413
|
+
if ((0, _types.isOneOfSchema)(schema)) {
|
|
331
414
|
return Boolean(schema.oneOf.find(hasRef));
|
|
332
415
|
}
|
|
333
416
|
|
|
@@ -339,15 +422,15 @@ function hasRef(schema) {
|
|
|
339
422
|
|
|
340
423
|
|
|
341
424
|
function hasResolvableRef(context, schema) {
|
|
342
|
-
if ((0,
|
|
425
|
+
if ((0, _types.isRefSchema)(schema) || (0, _types.isRefSchemaLegacy)(schema)) {
|
|
343
426
|
return Boolean(refItemToShapeSchema(context, getRef(context, schema)));
|
|
344
427
|
}
|
|
345
428
|
|
|
346
|
-
if ((0,
|
|
429
|
+
if ((0, _types.isAllOfSchema)(schema)) {
|
|
347
430
|
return Boolean(schema.allOf.find(s => hasResolvableRef(context, s)));
|
|
348
431
|
}
|
|
349
432
|
|
|
350
|
-
if ((0,
|
|
433
|
+
if ((0, _types.isOneOfSchema)(schema)) {
|
|
351
434
|
return Boolean(schema.oneOf.find(s => hasResolvableRef(context, s)));
|
|
352
435
|
}
|
|
353
436
|
|
package/lib/schema-util.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { ProjectSchema, PropertySchema, FormConfig, Query, QueryMap, Shape, ShapeMap, ObjectSchema, ServiceConfig, ShapeV3_0_0, ShapeSchema } from './project-schema';
|
|
3
3
|
import type { LatestProjectSchemaWithServices, ServiceMap, ServiceInfo, SchemaWithArgs, SchemaPropertyName, SchemaPropertyNode, ProjectSchemaV3X, SchemaPath, SchemaWithRef } from './types/types';
|
|
4
4
|
import { Maybe } from '@takeshape/util';
|
|
5
|
-
import { RefItem, RefItemWithPath, ServicesShapesContext } from './refs';
|
|
5
|
+
import { RefItem, RefItemWithPath, ServicesContext, ServicesShapesContext } from './refs';
|
|
6
6
|
export declare const SERVICE_OBJECT_PATTERN_NAME = "pattern:service-object";
|
|
7
7
|
export declare function isBuiltinShape(shapeName: string): boolean;
|
|
8
8
|
export declare function isBuiltinQuery(name: string): boolean;
|
|
@@ -59,14 +59,14 @@ export declare function parseQueryResolver(resolver: string): {
|
|
|
59
59
|
export declare function getShapeById(projectSchema: ProjectSchema, shapeId: string): Shape | undefined;
|
|
60
60
|
export declare function isModelShape(shape: Shape): boolean;
|
|
61
61
|
export declare function isIndexedRemoteShape({ indexedShapes }: Pick<ProjectSchema, 'indexedShapes'>, shape: Shape): boolean;
|
|
62
|
-
export declare function getArgsReference(projectSchema:
|
|
63
|
-
export declare function getArgsReferenceWithPath(
|
|
64
|
-
export declare function getArgsShapeSchema(
|
|
62
|
+
export declare function getArgsReference(projectSchema: ServicesContext, argsSchema: SchemaWithArgs): Maybe<RefItem>;
|
|
63
|
+
export declare function getArgsReferenceWithPath(context: ServicesContext, argsSchema: SchemaWithArgs, schemaPath?: SchemaPath): Maybe<RefItemWithPath>;
|
|
64
|
+
export declare function getArgsShapeSchema(context: ServicesShapesContext, argsSchema: SchemaWithArgs): Maybe<ShapeSchema>;
|
|
65
65
|
export declare function shapeToPropertySchema(projectSchema: ProjectSchema, shape: Shape): PropertySchema;
|
|
66
66
|
export declare function projectSchemaToJSONSchema(projectSchema: ProjectSchema): {
|
|
67
67
|
definitions: Record<string, PropertySchema>;
|
|
68
68
|
};
|
|
69
|
-
export declare function getShapeDependencies(projectSchema: ProjectSchema, shape: Shape): string[];
|
|
69
|
+
export declare function getShapeDependencies(projectSchema: ProjectSchema, shape: Shape, predicate?: (propSchema: PropertySchema) => boolean): string[];
|
|
70
70
|
interface GetRelevantShapesParams {
|
|
71
71
|
shapeNames?: string[];
|
|
72
72
|
shapeIds?: string[];
|
|
@@ -81,7 +81,7 @@ export declare type RefPredicate = (ref: RefItemWithPath) => boolean;
|
|
|
81
81
|
/**
|
|
82
82
|
* Walk through a `ProjectSchema` and collect all the `ref`s.
|
|
83
83
|
*/
|
|
84
|
-
export declare function getAllRefsInShapes(projectSchema:
|
|
84
|
+
export declare function getAllRefsInShapes(projectSchema: ServicesShapesContext, predicate?: RefPredicate): RefItemWithPath[];
|
|
85
85
|
/**
|
|
86
86
|
* Get all refs
|
|
87
87
|
*/
|
|
@@ -214,5 +214,6 @@ export declare type ResolverWithDefaultMutation = 'takeshape:create' | 'takeshap
|
|
|
214
214
|
* Find the query in the schema that corresponds to the given shape and resolver.
|
|
215
215
|
*/
|
|
216
216
|
export declare const getDefaultMutationName: (shapeName: string, resolver: ResolverWithDefaultMutation) => string;
|
|
217
|
+
export declare function createShape(name: string, schema: ShapeSchema, rest?: Partial<Shape>): Shape;
|
|
217
218
|
export {};
|
|
218
219
|
//# sourceMappingURL=schema-util.d.ts.map
|
package/lib/schema-util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-util.d.ts","sourceRoot":"","sources":["../../src/schema-util.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,UAAU,EAEV,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,WAAW,EAGX,WAAW,EAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,+BAA+B,EAC/B,UAAU,EACV,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAElB,gBAAgB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I,CAAC,aAAa,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;AAgC9E;;GAEG;AACH,eAAO,MAAM,SAAS,kBAAmB,kBAAkB,aAAa,MAAM,YAAY,MAAM,KAAG,MAAM,GAAG,SAC9C,CAAC;AAC/D;;GAEG;AACH,eAAO,MAAM,YAAY,kBACR,kBAAkB,aACtB,MAAM,YACP,MAAM,KACf,MAAM,GAAG,SAA4E,CAAC;AAEzF;;;GAGG;AACH,eAAO,MAAM,WAAW,kBAAmB,kBAAkB,aAAa,MAAM,YAAY,MAAM,KAAG,MACrC,CAAC;AACjE;;;GAGG;AACH,eAAO,MAAM,cAAc,kBAAmB,kBAAkB,aAAa,MAAM,YAAY,MAAM,KAAG,MACrC,CAAC;AAEpE;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,KAAK,CAAC,UAAU,CAAC,CAEnB;AAED,oBAAY,2BAA2B,GACnC,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B;;GAEG;AACH,eAAO,MAAM,sBAAsB,cAAe,MAAM,YAAY,2BAA2B,KAAG,MAGjG,CAAC;AAEF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAQ3F"}
|
package/lib/schema-util.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.applyDefaultsToSchema = applyDefaultsToSchema;
|
|
|
9
9
|
exports.arraySchemaKeys = void 0;
|
|
10
10
|
exports.collectReferencedShapeNames = collectReferencedShapeNames;
|
|
11
11
|
exports.createSchemaPropertyList = exports.createSchemaPropertyAccessor = exports.commonSchemaKeys = void 0;
|
|
12
|
+
exports.createShape = createShape;
|
|
12
13
|
exports.dereferenceObjectSchema = dereferenceObjectSchema;
|
|
13
14
|
exports.dereferenceSchema = dereferenceSchema;
|
|
14
15
|
exports.emptySchema = emptySchema;
|
|
@@ -103,8 +104,6 @@ var _apiVersion = require("./api-version");
|
|
|
103
104
|
|
|
104
105
|
var _builtinSchema = require("./builtin-schema");
|
|
105
106
|
|
|
106
|
-
var _templateShapes = require("./template-shapes");
|
|
107
|
-
|
|
108
107
|
var _utils = require("./types/utils");
|
|
109
108
|
|
|
110
109
|
var _services = require("./services");
|
|
@@ -332,59 +331,59 @@ function getShapeQueriesAndMutations(shapeList) {
|
|
|
332
331
|
shapeName: name
|
|
333
332
|
},
|
|
334
333
|
description: `Get a ${name} by ID`,
|
|
335
|
-
args: isSingleton ? (0,
|
|
334
|
+
args: isSingleton ? (0, _refs.createTemplateShapeName)('TSGetSingletonArgs', name) : (0, _refs.createTemplateShapeName)('TSGetArgs', name)
|
|
336
335
|
};
|
|
337
336
|
mutations[`update${name}`] = {
|
|
338
|
-
shape: (0,
|
|
337
|
+
shape: (0, _refs.createTemplateShapeName)('UpdateResult', name),
|
|
339
338
|
resolver: {
|
|
340
339
|
name: 'takeshape:update',
|
|
341
340
|
service,
|
|
342
341
|
shapeName: name
|
|
343
342
|
},
|
|
344
343
|
description: `Update ${name}`,
|
|
345
|
-
args: (0,
|
|
344
|
+
args: (0, _refs.createTemplateShapeName)('UpdateArgs', name)
|
|
346
345
|
};
|
|
347
346
|
|
|
348
347
|
if (!isSingleton) {
|
|
349
348
|
queries[`get${name}List`] = {
|
|
350
|
-
shape: (0,
|
|
349
|
+
shape: (0, _refs.createTemplateShapeName)('PaginatedList', name),
|
|
351
350
|
resolver: {
|
|
352
351
|
name: 'takeshape:list',
|
|
353
352
|
service,
|
|
354
353
|
shapeName: name
|
|
355
354
|
},
|
|
356
355
|
description: `Returns a list ${name} in natural order.`,
|
|
357
|
-
args: (0,
|
|
356
|
+
args: (0, _refs.createTemplateShapeName)('TSListArgs', name)
|
|
358
357
|
};
|
|
359
358
|
mutations[`create${name}`] = {
|
|
360
|
-
shape: (0,
|
|
359
|
+
shape: (0, _refs.createTemplateShapeName)('CreateResult', name),
|
|
361
360
|
resolver: {
|
|
362
361
|
name: 'takeshape:create',
|
|
363
362
|
service,
|
|
364
363
|
shapeName: name
|
|
365
364
|
},
|
|
366
365
|
description: `Create ${name}`,
|
|
367
|
-
args: (0,
|
|
366
|
+
args: (0, _refs.createTemplateShapeName)('CreateArgs', name)
|
|
368
367
|
};
|
|
369
368
|
mutations[`duplicate${name}`] = {
|
|
370
|
-
shape: (0,
|
|
369
|
+
shape: (0, _refs.createTemplateShapeName)('DuplicateResult', name),
|
|
371
370
|
resolver: {
|
|
372
371
|
name: 'takeshape:duplicate',
|
|
373
372
|
service,
|
|
374
373
|
shapeName: name
|
|
375
374
|
},
|
|
376
375
|
description: `Duplicate ${name}`,
|
|
377
|
-
args: (0,
|
|
376
|
+
args: (0, _refs.createTemplateShapeName)('DuplicateArgs', name)
|
|
378
377
|
};
|
|
379
378
|
mutations[`delete${name}`] = {
|
|
380
|
-
shape: (0,
|
|
379
|
+
shape: (0, _refs.createTemplateShapeName)('DeleteResult', name),
|
|
381
380
|
resolver: {
|
|
382
381
|
name: 'takeshape:delete',
|
|
383
382
|
service,
|
|
384
383
|
shapeName: name
|
|
385
384
|
},
|
|
386
385
|
description: `Delete ${name}`,
|
|
387
|
-
args: (0,
|
|
386
|
+
args: (0, _refs.createTemplateShapeName)('DeleteArgs', name)
|
|
388
387
|
};
|
|
389
388
|
}
|
|
390
389
|
}
|
|
@@ -652,8 +651,8 @@ function getArgsReference(projectSchema, argsSchema) {
|
|
|
652
651
|
}
|
|
653
652
|
}
|
|
654
653
|
|
|
655
|
-
function getArgsReferenceWithPath(
|
|
656
|
-
const refItem = getArgsReference(
|
|
654
|
+
function getArgsReferenceWithPath(context, argsSchema, schemaPath = []) {
|
|
655
|
+
const refItem = getArgsReference(context, argsSchema);
|
|
657
656
|
|
|
658
657
|
if (refItem) {
|
|
659
658
|
const argsType = (0, _utils.getArgsType)(argsSchema);
|
|
@@ -663,14 +662,14 @@ function getArgsReferenceWithPath(projectSchema, argsSchema, schemaPath = []) {
|
|
|
663
662
|
}
|
|
664
663
|
}
|
|
665
664
|
|
|
666
|
-
function getArgsShapeSchema(
|
|
665
|
+
function getArgsShapeSchema(context, argsSchema) {
|
|
667
666
|
const args = argsSchema['@args'] ?? argsSchema.args;
|
|
668
667
|
|
|
669
668
|
if (args && typeof args === 'string') {
|
|
670
|
-
const refItem = getArgsReference(
|
|
669
|
+
const refItem = getArgsReference(context, argsSchema);
|
|
671
670
|
|
|
672
671
|
if (refItem) {
|
|
673
|
-
return (0, _refs.refItemToShapeSchema)(
|
|
672
|
+
return (0, _refs.refItemToShapeSchema)(context, refItem);
|
|
674
673
|
}
|
|
675
674
|
} else if (args) {
|
|
676
675
|
return args;
|
|
@@ -783,22 +782,25 @@ function projectSchemaToJSONSchema(projectSchema) {
|
|
|
783
782
|
};
|
|
784
783
|
}
|
|
785
784
|
|
|
786
|
-
function getShapeDependencies(projectSchema, shape) {
|
|
785
|
+
function getShapeDependencies(projectSchema, shape, predicate) {
|
|
787
786
|
const shapeNames = new Set();
|
|
788
787
|
|
|
789
788
|
const findDependencies = schema => {
|
|
790
789
|
schema = schema.items ?? schema;
|
|
791
|
-
const refItem = (0, _refs.getRef)(projectSchema, schema);
|
|
792
790
|
|
|
793
|
-
if (
|
|
794
|
-
const
|
|
791
|
+
if (!predicate || predicate(schema)) {
|
|
792
|
+
const refItem = (0, _refs.getRef)(projectSchema, schema);
|
|
793
|
+
|
|
794
|
+
if (refItem) {
|
|
795
|
+
const refShape = (0, _refs.refItemToShape)(projectSchema, refItem);
|
|
795
796
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
797
|
+
if (refShape && !shapeNames.has(refShape.name)) {
|
|
798
|
+
shapeNames.add(refShape.name);
|
|
799
|
+
findDependencies(dereferenceSchema(projectSchema, refShape.schema));
|
|
800
|
+
}
|
|
801
|
+
} else if ((0, _utils.isObjectSchema)(schema) || (0, _utils.isAllOfSchema)(schema) || (0, _utils.isOneOfSchema)(schema)) {
|
|
802
|
+
visitSchemaProperties(schema, [], findDependencies);
|
|
799
803
|
}
|
|
800
|
-
} else if ((0, _utils.isObjectSchema)(schema) || (0, _utils.isAllOfSchema)(schema) || (0, _utils.isOneOfSchema)(schema)) {
|
|
801
|
-
visitSchemaProperties(schema, [], findDependencies);
|
|
802
804
|
}
|
|
803
805
|
};
|
|
804
806
|
|
|
@@ -933,7 +935,7 @@ function getAllRefsInQuery(projectSchema, queryPath, query, predicate) {
|
|
|
933
935
|
}
|
|
934
936
|
|
|
935
937
|
if (query.shape) {
|
|
936
|
-
const refItem = (0,
|
|
938
|
+
const refItem = (0, _refs.parseReturnShape)(projectSchema, query.shape).ref;
|
|
937
939
|
|
|
938
940
|
if (refItem) {
|
|
939
941
|
addRef(refItems, { ...refItem,
|
|
@@ -1396,4 +1398,14 @@ const getDefaultMutationName = (shapeName, resolver) => {
|
|
|
1396
1398
|
return `${action}${shapeName}`;
|
|
1397
1399
|
};
|
|
1398
1400
|
|
|
1399
|
-
exports.getDefaultMutationName = getDefaultMutationName;
|
|
1401
|
+
exports.getDefaultMutationName = getDefaultMutationName;
|
|
1402
|
+
|
|
1403
|
+
function createShape(name, schema, rest) {
|
|
1404
|
+
return {
|
|
1405
|
+
name,
|
|
1406
|
+
id: name,
|
|
1407
|
+
title: name,
|
|
1408
|
+
schema,
|
|
1409
|
+
...rest
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResolvedTemplate } from './types';
|
|
2
|
+
import { ProjectSchema } from '../project-schema';
|
|
3
|
+
export declare function resolveTemplate(projectSchema: ProjectSchema, templateName: string, shapeName: string): ResolvedTemplate;
|
|
4
|
+
/**
|
|
5
|
+
* Check if a string is a known template such as `PaginatedList`
|
|
6
|
+
*/
|
|
7
|
+
export declare function isValidTemplate(template: string): boolean;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/template-shapes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAuB,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAmChD,wBAAgB,eAAe,CAC7B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,gBAAgB,CAOlB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isValidTemplate = isValidTemplate;
|
|
7
|
+
exports.resolveTemplate = resolveTemplate;
|
|
8
|
+
|
|
9
|
+
var _templates = require("./templates");
|
|
10
|
+
|
|
11
|
+
const templateMappings = {
|
|
12
|
+
TSGetArgs: _templates.TSGetArgs,
|
|
13
|
+
TSGetSingletonArgs: _templates.TSGetSingletonArgs,
|
|
14
|
+
TSListArgs: _templates.TSListArgs,
|
|
15
|
+
TSSearchArgs: _templates.TSSearchArgs,
|
|
16
|
+
CreateArgs: _templates.CreateArgs,
|
|
17
|
+
UpdateArgs: _templates.UpdateArgs,
|
|
18
|
+
DuplicateArgs: _templates.DuplicateArgs,
|
|
19
|
+
DeleteArgs: _templates.DeleteArgs,
|
|
20
|
+
PaginatedList: _templates.PaginatedList,
|
|
21
|
+
SearchResults: _templates.SearchResults,
|
|
22
|
+
CreateResult: _templates.CreateResult,
|
|
23
|
+
UpdateResult: _templates.UpdateResult,
|
|
24
|
+
DuplicateResult: _templates.DuplicateResult,
|
|
25
|
+
DeleteResult: _templates.DeleteResult
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function resolveTemplate(projectSchema, templateName, shapeName) {
|
|
29
|
+
const mapping = templateMappings[templateName];
|
|
30
|
+
|
|
31
|
+
if (!mapping) {
|
|
32
|
+
throw new Error(`Invalid shape template ${templateName}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return mapping({
|
|
36
|
+
projectSchema
|
|
37
|
+
}, projectSchema.shapes[shapeName]);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if a string is a known template such as `PaginatedList`
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
function isValidTemplate(template) {
|
|
45
|
+
return Boolean(templateMappings[template]);
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ObjectSchema, PropertySchema, Shape } from '../project-schema';
|
|
2
|
+
import type { ResolvedTemplate, TemplateContext } from './types';
|
|
3
|
+
export declare const TSGetArgs: (context: unknown, shape: Shape) => ResolvedTemplate;
|
|
4
|
+
export declare const TSGetSingletonArgs: (context: unknown, shape: Shape) => ResolvedTemplate;
|
|
5
|
+
export declare const TSListArgs: (context: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
6
|
+
export declare const TSSearchArgs: (context: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
7
|
+
export declare const CreateArgs: ({ projectSchema }: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
8
|
+
export declare const UpdateArgs: ({ projectSchema }: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
9
|
+
export declare const DuplicateArgs: ({ projectSchema }: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
10
|
+
export declare const DeleteArgs: ({ projectSchema }: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
11
|
+
export declare const PaginatedList: typeof getPaginatedListShape;
|
|
12
|
+
export declare const SearchResults: typeof getSearchResultsShape;
|
|
13
|
+
export declare const CreateResult: (context: unknown, shape: Shape) => ResolvedTemplate;
|
|
14
|
+
export declare const UpdateResult: (context: unknown, shape: Shape) => ResolvedTemplate;
|
|
15
|
+
export declare const DuplicateResult: (context: unknown, shape: Shape) => ResolvedTemplate;
|
|
16
|
+
export declare const DeleteResult: (context: unknown, shape: Shape) => ResolvedTemplate;
|
|
17
|
+
export declare const TSSearchSortInput: Shape;
|
|
18
|
+
export declare const commonSearchProps: Record<string, PropertySchema>;
|
|
19
|
+
export declare const localeProps: ObjectSchema;
|
|
20
|
+
export declare const termsProps: ObjectSchema;
|
|
21
|
+
export declare const ContentStructureInput: Shape;
|
|
22
|
+
export declare function getPaginatedListShape(context: unknown, shape: Shape): ResolvedTemplate;
|
|
23
|
+
export declare function getSearchResultsShape(context: unknown, shape: Shape): ResolvedTemplate;
|
|
24
|
+
export declare function getIDQueryArgs(templateName: string): (context: unknown, shape: Shape) => ResolvedTemplate;
|
|
25
|
+
export declare function getMutationArgs(templateName: string, verb: string): ({ projectSchema }: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
26
|
+
export declare function getMutationResultType(verb: string): (context: unknown, shape: Shape) => ResolvedTemplate;
|
|
27
|
+
export declare const commonSearchArgs: ObjectSchema;
|
|
28
|
+
export declare function getShapeListQueryArgs(templateName: string, legacyArgs: boolean): (context: TemplateContext, shape: Shape) => ResolvedTemplate;
|
|
29
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/template-shapes/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,cAAc,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AACxF,OAAO,KAAK,EAAC,gBAAgB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAC;AAa/D,eAAO,MAAM,SAAS,YAoKH,OAAO,SAAS,KAAK,KAAG,gBAAgB,AApKP,CAAC;AACrD,eAAO,MAAM,kBAAkB,YAmKZ,OAAO,SAAS,KAAK,KAAG,gBAAgB,AAnKW,CAAC;AACvE,eAAO,MAAM,U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