@takeshape/schema 8.144.4 → 8.146.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/builtin-schema.d.ts.map +1 -1
- package/dist/builtin-schema.js +17 -0
- package/dist/get-is-leaf.d.ts +1 -1
- package/dist/get-is-leaf.d.ts.map +1 -1
- package/dist/get-is-leaf.js +3 -1
- package/dist/migration/index.d.ts +1 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +4 -1
- package/dist/migration/to/v3.0.0.d.ts.map +1 -1
- package/dist/migration/to/v3.18.0.d.ts +5 -0
- package/dist/migration/to/v3.18.0.d.ts.map +1 -0
- package/dist/migration/to/v3.18.0.js +85 -0
- package/dist/mocks.d.ts.map +1 -1
- package/dist/mocks.js +4 -2
- package/dist/project-schema/index.d.ts +4 -1
- package/dist/project-schema/index.d.ts.map +1 -1
- package/dist/project-schema/index.js +20 -3
- package/dist/project-schema/latest.d.ts +4 -139
- package/dist/project-schema/latest.d.ts.map +1 -1
- package/dist/project-schema/migrate.d.ts.map +1 -1
- package/dist/project-schema/migrate.js +4 -0
- package/dist/project-schema/v3.18.0.d.ts +1334 -0
- package/dist/project-schema/v3.18.0.d.ts.map +1 -0
- package/dist/project-schema/v3.18.0.js +5 -0
- package/dist/refs.d.ts +14 -2
- package/dist/refs.d.ts.map +1 -1
- package/dist/refs.js +26 -0
- package/dist/relationships.d.ts +28 -2
- package/dist/relationships.d.ts.map +1 -1
- package/dist/relationships.js +234 -19
- package/dist/rewrite.d.ts.map +1 -1
- package/dist/rewrite.js +10 -2
- package/dist/schema-util.d.ts +1 -18
- package/dist/schema-util.d.ts.map +1 -1
- package/dist/schema-util.js +36 -120
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +6 -4
- package/dist/schemas/index.ts +4 -2
- package/dist/schemas/project-schema/latest.json +2175 -2195
- package/dist/schemas/project-schema/v3.18.0.json +2350 -0
- package/dist/schemas/project-schema.json +3 -0
- package/dist/template-shapes/templates.d.ts +5 -0
- package/dist/template-shapes/templates.d.ts.map +1 -1
- package/dist/template-shapes/templates.js +59 -28
- package/dist/template-shapes/where.d.ts +3 -4
- package/dist/template-shapes/where.d.ts.map +1 -1
- package/dist/template-shapes/where.js +32 -26
- package/dist/types/types.d.ts +42 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +2 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/utils.js +9 -1
- package/dist/unions.d.ts.map +1 -1
- package/dist/unions.js +3 -1
- package/dist/util/detect-cycles.d.ts +3 -1
- package/dist/util/detect-cycles.d.ts.map +1 -1
- package/dist/util/detect-cycles.js +37 -28
- package/dist/util/form-config.d.ts +9 -0
- package/dist/util/form-config.d.ts.map +1 -0
- package/dist/util/form-config.js +97 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +13 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +75 -45
- package/es/builtin-schema.js +17 -0
- package/es/get-is-leaf.js +2 -1
- package/es/migration/index.js +3 -1
- package/es/migration/to/v3.18.0.js +72 -0
- package/es/mocks.js +4 -2
- package/es/project-schema/index.js +3 -1
- package/es/project-schema/migrate.js +5 -1
- package/es/project-schema/v3.18.0.js +1 -0
- package/es/refs.js +22 -1
- package/es/relationships.js +215 -19
- package/es/rewrite.js +10 -2
- package/es/schema-util.js +38 -119
- package/es/schemas/index.js +4 -3
- package/es/schemas/index.ts +4 -2
- package/es/schemas/project-schema/latest.json +2175 -2195
- package/es/schemas/project-schema/v3.18.0.json +2350 -0
- package/es/schemas/project-schema.json +3 -0
- package/es/template-shapes/templates.js +55 -29
- package/es/template-shapes/where.js +29 -23
- package/es/types/utils.js +8 -2
- package/es/unions.js +2 -1
- package/es/util/detect-cycles.js +36 -28
- package/es/util/form-config.js +85 -0
- package/es/util/index.js +2 -1
- package/es/validate.js +74 -46
- package/examples/latest/betzino.json +12383 -6066
- package/examples/latest/blog-schema.json +46 -25
- package/examples/latest/brewery-schema.json +14 -9
- package/examples/latest/complex-project-schema.json +442 -244
- package/examples/latest/complex-schema.json +17205 -0
- package/examples/latest/fabric-ecommerce.json +2 -2
- package/examples/latest/frank-and-fred-schema.json +5141 -2391
- package/examples/latest/klirr-schema.json +35445 -0
- package/examples/latest/massive-schema.json +1205 -640
- package/examples/latest/mill-components-schema.json +241 -113
- package/examples/latest/one-earth.json +14429 -0
- package/examples/latest/pet-oneof-array.json +2 -2
- package/examples/latest/post-schema.json +18 -11
- package/examples/latest/pruned-shopify-product-schema.json +2 -2
- package/examples/latest/real-world-schema.json +81 -41
- package/examples/latest/recursive-repeater-schema.json +14 -9
- package/examples/latest/recursive-schema.json +14 -9
- package/examples/latest/rick-and-morty-ast.json +138 -80
- package/examples/latest/rick-and-morty-graphql.json +78 -45
- package/examples/latest/rick-and-morty-rest.json +2 -2
- package/examples/latest/schema-with-repeater-draftjs.json +38 -23
- package/examples/latest/shape-books-v3_2_0.json +138 -80
- package/examples/latest/shape-books.json +138 -80
- package/examples/latest/shopify-lookbook.json +30 -16
- package/examples/latest/shopify-namespace-schema.json +364 -0
- package/examples/latest/shopify-store-with-widget.json +2 -2
- package/examples/latest/stripe-starter-resolved.json +14 -8
- package/examples/latest/user-schema-no-required.json +2 -2
- package/examples/latest/user-schema-with-defaults.json +2 -2
- package/examples/source/complex-schema.json +12760 -0
- package/examples/source/klirr-schema.json +27716 -0
- package/examples/source/one-earth.json +11897 -0
- package/examples/source/post-schema.json +0 -1
- package/package.json +5 -4
|
@@ -27,6 +27,11 @@ export declare function getIDQueryArgs(templateName: string): (context: unknown,
|
|
|
27
27
|
* Construct a shape name used for a mutation input shape.
|
|
28
28
|
*/
|
|
29
29
|
export declare function getMutationInputShapeName(verb: TemplateVerbs): (shapeName: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Create a shape name variant for an input.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getInputShapeName(shapeName: string): string;
|
|
34
|
+
export declare function getOutputShapeName(name: string): string;
|
|
30
35
|
/**
|
|
31
36
|
* Construct shapes for a mutation inputs, given source shape info.
|
|
32
37
|
*/
|
|
@@ -1 +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,
|
|
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;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAWtC,eAAO,MAAM,SAAS,YAoJH,OAAO,SAAS,KAAK,KAAG,gBAAgB,AApJP,CAAC;AACrD,eAAO,MAAM,kBAAkB,YAmJZ,OAAO,SAAS,KAAK,KAAG,gBAAgB,AAnJW,CAAC;AACvE,eAAO,MAAM,UAAU,YAwWJ,eAAe,SAAS,KAAK,KAAG,gBAAgB,AAxWA,CAAC;AACpE,eAAO,MAAM,YAAY,YAuWN,eAAe,SAAS,KAAK,KAAG,gBAAgB,AAvWK,CAAC;AACzE,eAAO,MAAM,UAAU,sBAgNI,eAAe,SAAS,KAAK,KAAG,gBAAgB,AAhNE,CAAC;AAC9E,eAAO,MAAM,UAAU,sBA+MI,eAAe,SAAS,KAAK,KAAG,gBAAgB,AA/ME,CAAC;AAC9E,eAAO,MAAM,aAAa,sBA8MC,eAAe,SAAS,KAAK,KAAG,gBAAgB,AA9MW,CAAC;AACvF,eAAO,MAAM,UAAU,sBA6MI,eAAe,SAAS,KAAK,KAAG,gBAAgB,AA7ME,CAAC;AAC9E,eAAO,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AgB,CAgF1E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,aACtC,OAAO,SAAS,KAAK,KAAG,gBAAgB,CAiB1D;AAED,eAAO,MAAM,gBAAgB,EAAE,YAwB9B,CAAC;AAuBF,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,aAC5D,eAAe,SAAS,KAAK,KAAG,gBAAgB,CA0BlE"}
|
|
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.commonSearchProps = exports.commonSearchArgs = exports.UpdateResult = exports.UpdateArgs = exports.TSSearchSortInput = exports.TSSearchArgs = exports.TSListArgs = exports.TSGetSingletonArgs = exports.TSGetArgs = exports.SearchResults = exports.PaginatedList = exports.DuplicateResult = exports.DuplicateArgs = exports.DeleteResult = exports.DeleteArgs = exports.CreateResult = exports.CreateArgs = exports.ContentStructureInput = void 0;
|
|
7
7
|
exports.getIDQueryArgs = getIDQueryArgs;
|
|
8
|
+
exports.getInputShapeName = getInputShapeName;
|
|
8
9
|
exports.getMutationArgs = getMutationArgs;
|
|
9
10
|
exports.getMutationInputShapeName = getMutationInputShapeName;
|
|
10
11
|
exports.getMutationResultType = getMutationResultType;
|
|
12
|
+
exports.getOutputShapeName = getOutputShapeName;
|
|
11
13
|
exports.getPaginatedListShape = getPaginatedListShape;
|
|
12
14
|
exports.getSearchResultsShape = getSearchResultsShape;
|
|
13
15
|
exports.getShapeListQueryArgs = getShapeListQueryArgs;
|
|
@@ -31,6 +33,8 @@ var _util2 = require("../util");
|
|
|
31
33
|
|
|
32
34
|
var _rewrite = require("../rewrite");
|
|
33
35
|
|
|
36
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
37
|
+
|
|
34
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
39
|
|
|
36
40
|
const TSGetArgs = getIDQueryArgs('TSGetArgs');
|
|
@@ -238,14 +242,41 @@ function getMutationInputShapeName(verb) {
|
|
|
238
242
|
return (0, _util.pascalCase)([verb, shapeName, 'input']);
|
|
239
243
|
};
|
|
240
244
|
}
|
|
241
|
-
|
|
242
245
|
/**
|
|
243
|
-
* Create a shape name variant for an input.
|
|
246
|
+
* Create a shape name variant for an input.
|
|
244
247
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
function getInputShapeName(shapeName) {
|
|
251
|
+
return shapeName === 'TSRelationship' ? shapeName : `${shapeName}Input`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function getOutputShapeName(name) {
|
|
255
|
+
return name.replace(/(?:Input|PartialInput)$/, '');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function rewriteRefs(shapeSchema, rewriteShapeName) {
|
|
259
|
+
const newSchema = (0, _util.deepClone)(shapeSchema);
|
|
260
|
+
(0, _util.visit)(newSchema, ['$ref', '@ref'], (_, path) => {
|
|
261
|
+
const parentPath = path.slice(0, -1);
|
|
262
|
+
const value = (0, _get.default)(newSchema, parentPath);
|
|
263
|
+
|
|
264
|
+
if ((value['@ref'] || value.$ref) && !parentPath.includes('@input') && !parentPath.includes('@output')) {
|
|
265
|
+
if (value['@ref']) {
|
|
266
|
+
const ref = value['@ref'];
|
|
267
|
+
const parts = ref.split(':');
|
|
268
|
+
value['@ref'] = `local:${rewriteShapeName(parts[1])}`;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (value.$ref) {
|
|
272
|
+
const ref = value.$ref;
|
|
273
|
+
const parts = ref.split('/');
|
|
274
|
+
parts[2] = rewriteShapeName(parts[2]);
|
|
275
|
+
value.$ref = parts.join('/');
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
return newSchema;
|
|
249
280
|
}
|
|
250
281
|
/**
|
|
251
282
|
* Construct shapes for a mutation inputs, given source shape info.
|
|
@@ -263,14 +294,19 @@ function getMutationArgs(templateName, verb) {
|
|
|
263
294
|
const inputName = getShapeName(shape.name);
|
|
264
295
|
const isSingleton = shape.model && shape.model.type === 'single';
|
|
265
296
|
const shouldRequireId = !isSingleton && (verb === _types.TemplateVerbs.Update || verb === _types.TemplateVerbs.Delete || verb === _types.TemplateVerbs.Duplicate);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
297
|
+
let rewrittenSchema;
|
|
298
|
+
let inputShapeSchema;
|
|
299
|
+
|
|
300
|
+
if (verb !== _types.TemplateVerbs.Delete) {
|
|
301
|
+
rewrittenSchema = (0, _rewrite.rewriteSchema)(shape.schema, {
|
|
302
|
+
removeDefault: isUpdate,
|
|
303
|
+
removeRequired: isUpdate,
|
|
304
|
+
replaceInput: true
|
|
305
|
+
});
|
|
306
|
+
inputShapeSchema = rewriteRefs(rewrittenSchema, getInputShapeName);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const inputShape = (0, _schemaUtil.createShape)(inputName, (0, _util2.mergeObjectSchemas)(shouldRequireId ? idSchema : undefined, inputShapeSchema), {
|
|
274
310
|
description: `${verb} ${shape.name} input`
|
|
275
311
|
});
|
|
276
312
|
const argsShapeName = (0, _refs.getFlattenedTemplateShapeName)(shape.name, templateName);
|
|
@@ -291,30 +327,25 @@ function getMutationArgs(templateName, verb) {
|
|
|
291
327
|
dependencies: {
|
|
292
328
|
[inputName]: inputShape,
|
|
293
329
|
[argsShapeName]: argsShape,
|
|
294
|
-
...(verb !== _types.TemplateVerbs.Delete && (0, _keyBy.default)((0, _schemaUtil.getShapeDependencies)(projectSchema, shape
|
|
295
|
-
|
|
330
|
+
...(verb !== _types.TemplateVerbs.Delete && (0, _keyBy.default)((0, _schemaUtil.getShapeDependencies)(projectSchema, // get the shape dependencies of the shape with the @input swapped
|
|
331
|
+
(0, _schemaUtil.createShape)(inputShape.name, rewrittenSchema), propSchema => {
|
|
332
|
+
if (propSchema['@resolver']) {
|
|
296
333
|
return false;
|
|
297
334
|
}
|
|
298
335
|
|
|
299
336
|
const shapeName = (0, _refs.getRefShapeName)(projectSchema, propSchema);
|
|
300
337
|
|
|
301
338
|
if (shapeName) {
|
|
302
|
-
return shapeName !== 'TSRelationship' && !projectSchema.shapes[getInputShapeName(shapeName
|
|
303
|
-
isPartial: isUpdate
|
|
304
|
-
})];
|
|
339
|
+
return shapeName !== 'TSRelationship' && !projectSchema.shapes[getInputShapeName(shapeName)];
|
|
305
340
|
}
|
|
306
341
|
|
|
307
342
|
return true;
|
|
308
343
|
}).map(shapeName => {
|
|
309
|
-
const shape = projectSchema.shapes[shapeName];
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
name,
|
|
315
|
-
id: name,
|
|
316
|
-
schema: rewrittenSchema
|
|
317
|
-
};
|
|
344
|
+
const shape = projectSchema.shapes[shapeName]; // We only allow partial input at the top-level
|
|
345
|
+
|
|
346
|
+
return (0, _schemaUtil.createShape)(getInputShapeName(shapeName), rewriteRefs((0, _rewrite.rewriteSchema)(shape.schema, {
|
|
347
|
+
replaceInput: true
|
|
348
|
+
}), getInputShapeName));
|
|
318
349
|
}), 'name')),
|
|
319
350
|
...(addStructure ? {
|
|
320
351
|
ContentStructureInput
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Maybe } from '@takeshape/util';
|
|
2
|
-
import type { PropertySchema, ProjectSchema, Shape } from '../project-schema';
|
|
3
|
-
import {
|
|
4
|
-
import { ResolvedTemplate } from './types';
|
|
1
|
+
import type { Maybe } from '@takeshape/util';
|
|
2
|
+
import type { PropertySchema, ProjectSchema, Shape, ObjectSchema, ShapeMap } from '../project-schema';
|
|
3
|
+
import type { ResolvedTemplate } from './types';
|
|
5
4
|
export declare const MAX_RELATIONSHIP_DEPTH = 1;
|
|
6
5
|
export declare const exceededRelationshipDepth: (depth?: number) => boolean;
|
|
7
6
|
declare type ComparisonOperatorKey = 'eq' | 'lt' | 'lte' | 'gt' | 'gte' | 'in' | 'match' | 'regexp';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"where.d.ts","sourceRoot":"","sources":["../../../src/template-shapes/where.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"where.d.ts","sourceRoot":"","sources":["../../../src/template-shapes/where.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAEpG,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAsB9C,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,yBAAyB,sBAAgB,OAA0C,CAAC;AAEjG,aAAK,qBAAqB,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE5F,aAAK,UAAU,GAAG,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;AAExC,cAAM,UAAU;IACd,MAAM,0BAAiC;IACvC,UAAU,cAAqB;IAE/B,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAI/B,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAO/C,UAAU,IAAI,QAAQ;CAiBvB;AAED,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,MAAM,EACN;IAAC,WAAW,EAAE,qBAAqB,EAAE,CAAC;IAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;CAAC,CAW1F,CAAC;AACF,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CASzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAuB,CAAC;AACrD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIvD,CAAC;AAqBF,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAc/F;AA4GD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,aAAa,EAAE,aAAa,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAwBD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA2BrH;AAYD,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,eAAe,GACvB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CA2FvC;AAkED,wBAAgB,aAAa,CAAC,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,gBAAgB,CA4BrG;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,KAAK,EAAE,GACtB;IAAC,MAAM,EAAE,YAAY,CAAC;IAAC,YAAY,EAAE,QAAQ,CAAA;CAAC,CAchD"}
|
|
@@ -10,25 +10,25 @@ exports.getPropertyComparisonType = getPropertyComparisonType;
|
|
|
10
10
|
exports.getWhereSearchArg = getWhereSearchArg;
|
|
11
11
|
exports.getWhereShape = getWhereShape;
|
|
12
12
|
|
|
13
|
-
var _util = require("@takeshape/util");
|
|
14
|
-
|
|
15
13
|
var _unset = _interopRequireDefault(require("lodash/unset"));
|
|
16
14
|
|
|
17
15
|
var _isFunction = _interopRequireDefault(require("lodash/isFunction"));
|
|
18
16
|
|
|
19
17
|
var _schemaUtil = require("../schema-util");
|
|
20
18
|
|
|
19
|
+
var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
|
|
20
|
+
|
|
21
|
+
var _blueimpMd = _interopRequireDefault(require("blueimp-md5"));
|
|
22
|
+
|
|
23
|
+
var _util = require("@takeshape/util");
|
|
24
|
+
|
|
21
25
|
var _apiVersion = require("../api-version");
|
|
22
26
|
|
|
23
27
|
var _refs = require("../refs");
|
|
24
28
|
|
|
25
29
|
var _unions = require("../unions");
|
|
26
30
|
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
|
|
30
|
-
|
|
31
|
-
var _blueimpMd = _interopRequireDefault(require("blueimp-md5"));
|
|
31
|
+
var _utils = require("../types/utils");
|
|
32
32
|
|
|
33
33
|
var _relationships = require("../relationships");
|
|
34
34
|
|
|
@@ -149,7 +149,7 @@ function getConflictingProperties(projectSchema, shapes) {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
if ((0,
|
|
152
|
+
if ((0, _utils.isObjectSchema)(shape.schema)) {
|
|
153
153
|
Object.assign(allProps, shape.schema.properties);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -192,7 +192,7 @@ function isId(name) {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
function isNonRelationshipRef(prop) {
|
|
195
|
-
return Boolean((0, _refs.hasRefProperty)(prop) && !prop
|
|
195
|
+
return Boolean((0, _refs.hasRefProperty)(prop) && !(0, _relationships.getRelationship)(prop));
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
function getPropType(projectSchema, name, prop) {
|
|
@@ -233,20 +233,17 @@ function truncateNames(names) {
|
|
|
233
233
|
// For unions of many types hash the names this reduces shape name size while still allowing reuse
|
|
234
234
|
return names.length > 80 ? (0, _blueimpMd.default)(names) : names;
|
|
235
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Get a formatted string of related shape names from a property schema with a
|
|
238
|
+
* relationship resolver
|
|
239
|
+
*/
|
|
236
240
|
|
|
237
|
-
function getRelatedShapeNames(projectSchema, prop) {
|
|
238
|
-
var _prop$Relationship;
|
|
239
241
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
function getRelationshipShapeName(refs) {
|
|
243
|
+
return refs.map(ref => {
|
|
244
|
+
const shapeName = ref.split(':')[1];
|
|
245
|
+
return (0, _util.pascalCase)(shapeName);
|
|
243
246
|
}).sort().join('');
|
|
244
|
-
|
|
245
|
-
if (!names) {
|
|
246
|
-
throw new Error(`Relationship property ${prop.title} is missing related shapes`);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return names;
|
|
250
247
|
}
|
|
251
248
|
|
|
252
249
|
function joinShapeNames(shapes) {
|
|
@@ -265,8 +262,16 @@ function getTypeName(name, prop, shapeName, context) {
|
|
|
265
262
|
return `TSWhereID`;
|
|
266
263
|
}
|
|
267
264
|
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
const relationship = (0, _relationships.getRelationship)(prop);
|
|
266
|
+
|
|
267
|
+
if (relationship) {
|
|
268
|
+
const relationshipName = getRelationshipShapeName(relationship.refs);
|
|
269
|
+
|
|
270
|
+
if (!relationshipName) {
|
|
271
|
+
throw new Error(`Relationship property "${prop.title ?? ''}" is missing related shapes`);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const shapeNames = truncateNames(relationshipName);
|
|
270
275
|
return `TSWhere${shapeNames}Relationship`;
|
|
271
276
|
}
|
|
272
277
|
|
|
@@ -298,7 +303,7 @@ function skipField({
|
|
|
298
303
|
exceededRelationshipDepth,
|
|
299
304
|
isIndexedShape
|
|
300
305
|
}) {
|
|
301
|
-
return Boolean(prop['@sensitive'] || !isIndexedShape && prop['@resolver'] || prop
|
|
306
|
+
return Boolean(prop['@sensitive'] || !isIndexedShape && prop['@resolver'] || (0, _utils.isPropertySchemaWithRelationship)(prop) && exceededRelationshipDepth || (name === '_enabled' || name === '_enabledAt') && workflowsEnabled);
|
|
302
307
|
}
|
|
303
308
|
|
|
304
309
|
function getFields(typeName, shapes, context) {
|
|
@@ -388,11 +393,12 @@ function getPropertyComparisonType(name, prop, shapeName, context) {
|
|
|
388
393
|
|
|
389
394
|
let props;
|
|
390
395
|
const propOrItems = prop.items ?? prop;
|
|
396
|
+
const relationship = (0, _relationships.getRelationship)(prop);
|
|
391
397
|
|
|
392
398
|
if (isId(name)) {
|
|
393
399
|
props = getFieldTypeComparison('id');
|
|
394
|
-
} else if (
|
|
395
|
-
const shapes =
|
|
400
|
+
} else if (relationship) {
|
|
401
|
+
const shapes = (0, _relationships.getRelationshipShapes)(projectSchema.shapes, relationship.refs);
|
|
396
402
|
props = getFields(typeName, shapes, { ...context,
|
|
397
403
|
relationshipDepth: relationshipDepth + 1
|
|
398
404
|
});
|
|
@@ -453,7 +459,7 @@ function findEmpty(shapes) {
|
|
|
453
459
|
const empty = new Set();
|
|
454
460
|
|
|
455
461
|
for (const [shapeName, shape] of Object.entries(shapes)) {
|
|
456
|
-
if ((0,
|
|
462
|
+
if ((0, _utils.isObjectSchema)(shape.schema) && Object.keys(shape.schema.properties).length === 0) {
|
|
457
463
|
empty.add(shapeName);
|
|
458
464
|
}
|
|
459
465
|
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SetRequired, Merge, PartialDeep, SetOptional } from 'type-fest';
|
|
2
|
-
import type { ProjectSchema, ProjectSchemaV3_0_0, ProjectSchemaV3_1_0, ProjectSchemaV3_2_0, ProjectSchemaV3_3_0, ProjectSchemaV3_4_0, ProjectSchemaV3_5_0, ProjectSchemaV3_5_1, ProjectSchemaV3_6_0, ProjectSchemaV3_7_0, ProjectSchemaV3_8_0, ProjectSchemaV3_9_0, ProjectSchemaV3_10_0, ProjectSchemaV3_11_0, ProjectSchemaV3_12_0, ProjectSchemaV3_12_1, ProjectSchemaV3_12_2, ProjectSchemaV3_12_3, ProjectSchemaV3_13_0, ProjectSchemaV3_14_0, ProjectSchemaV3_15_0, ProjectSchemaV3_16_0, ProjectSchemaV3_17_0, ProjectSchemaV3_17_1, Query, PropertySchema, StoredServiceMap, ServiceConfig, OAuth2Authentication, CustomAuthentication, ServiceAuthentication, AnyProjectSchema } from '../project-schema';
|
|
2
|
+
import type { ProjectSchema, ProjectSchemaV3_0_0, ProjectSchemaV3_1_0, ProjectSchemaV3_2_0, ProjectSchemaV3_3_0, ProjectSchemaV3_4_0, ProjectSchemaV3_5_0, ProjectSchemaV3_5_1, ProjectSchemaV3_6_0, ProjectSchemaV3_7_0, ProjectSchemaV3_8_0, ProjectSchemaV3_9_0, ProjectSchemaV3_10_0, ProjectSchemaV3_11_0, ProjectSchemaV3_12_0, ProjectSchemaV3_12_1, ProjectSchemaV3_12_2, ProjectSchemaV3_12_3, ProjectSchemaV3_13_0, ProjectSchemaV3_14_0, ProjectSchemaV3_15_0, ProjectSchemaV3_16_0, ProjectSchemaV3_17_0, ProjectSchemaV3_17_1, ProjectSchemaV3_18_0, Query, PropertySchema, StoredServiceMap, ServiceConfig, OAuth2Authentication, CustomAuthentication, ServiceAuthentication, AnyProjectSchema, Ref } from '../project-schema';
|
|
3
3
|
import type { Overwrite } from '@takeshape/util';
|
|
4
4
|
import { SERVICE_OBJECT_PATTERN_NAME } from '../schema-util';
|
|
5
5
|
/**
|
|
@@ -7,7 +7,7 @@ import { SERVICE_OBJECT_PATTERN_NAME } from '../schema-util';
|
|
|
7
7
|
* only type used in most runtime code. Updating this to a new version should
|
|
8
8
|
* trigger type errors that clue you in to code that needs review.
|
|
9
9
|
*/
|
|
10
|
-
export declare type ProjectSchemaV3X = ProjectSchemaV3_17_1 | ProjectSchemaV3_17_0 | ProjectSchemaV3_16_0 | ProjectSchemaV3_15_0 | ProjectSchemaV3_14_0 | ProjectSchemaV3_13_0 | ProjectSchemaV3_12_3 | ProjectSchemaV3_12_2 | ProjectSchemaV3_12_1 | ProjectSchemaV3_12_0 | ProjectSchemaV3_11_0 | ProjectSchemaV3_10_0 | ProjectSchemaV3_9_0 | ProjectSchemaV3_8_0 | ProjectSchemaV3_7_0 | ProjectSchemaV3_6_0 | ProjectSchemaV3_5_1 | ProjectSchemaV3_5_0 | ProjectSchemaV3_4_0 | ProjectSchemaV3_3_0 | ProjectSchemaV3_2_0 | ProjectSchemaV3_1_0 | ProjectSchemaV3_0_0;
|
|
10
|
+
export declare type ProjectSchemaV3X = ProjectSchemaV3_18_0 | ProjectSchemaV3_17_1 | ProjectSchemaV3_17_0 | ProjectSchemaV3_16_0 | ProjectSchemaV3_15_0 | ProjectSchemaV3_14_0 | ProjectSchemaV3_13_0 | ProjectSchemaV3_12_3 | ProjectSchemaV3_12_2 | ProjectSchemaV3_12_1 | ProjectSchemaV3_12_0 | ProjectSchemaV3_11_0 | ProjectSchemaV3_10_0 | ProjectSchemaV3_9_0 | ProjectSchemaV3_8_0 | ProjectSchemaV3_7_0 | ProjectSchemaV3_6_0 | ProjectSchemaV3_5_1 | ProjectSchemaV3_5_0 | ProjectSchemaV3_4_0 | ProjectSchemaV3_3_0 | ProjectSchemaV3_2_0 | ProjectSchemaV3_1_0 | ProjectSchemaV3_0_0;
|
|
11
11
|
export declare const projectSchemaImportOptionalProps: readonly ["projectId", "created", "updated", "dataKey", "version", "locales", "defaultLocale", "author"];
|
|
12
12
|
export declare type ProjectSchemaImport = SetOptional<AnyProjectSchema, typeof projectSchemaImportOptionalProps[number]>;
|
|
13
13
|
export interface Content {
|
|
@@ -143,5 +143,45 @@ export declare type ShopifyServiceConfig = Overwrite<ServiceConfig, {
|
|
|
143
143
|
}>;
|
|
144
144
|
export declare type SchemaPath = Array<string | number>;
|
|
145
145
|
export declare type MinimalProjectSchema = Pick<ProjectSchema, 'shapes' | 'queries' | 'mutations'>;
|
|
146
|
+
/**
|
|
147
|
+
* Shapes
|
|
148
|
+
*/
|
|
149
|
+
export declare type ShapeRefs = Ref[];
|
|
150
|
+
/**
|
|
151
|
+
* Relationships
|
|
152
|
+
*/
|
|
153
|
+
export declare type PropertySchemaWithRelationship = Merge<PropertySchema, {
|
|
154
|
+
'@resolver': {
|
|
155
|
+
name: 'takeshape:getRelated';
|
|
156
|
+
service: 'takeshape:local';
|
|
157
|
+
options?: {
|
|
158
|
+
nullable?: boolean;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
}>;
|
|
162
|
+
/**
|
|
163
|
+
* New relationship data, drawn from a PropertySchema.
|
|
164
|
+
*/
|
|
165
|
+
export interface Relationship {
|
|
166
|
+
isMultiple: boolean;
|
|
167
|
+
refs: ShapeRefs;
|
|
168
|
+
hasBackreference: boolean;
|
|
169
|
+
backreferenceName?: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The old relationship format, used in client UI.
|
|
173
|
+
*/
|
|
174
|
+
export interface LegacyRelationship {
|
|
175
|
+
shapeIds: string[];
|
|
176
|
+
type?: 'single' | 'multiple';
|
|
177
|
+
}
|
|
178
|
+
export interface RelationshipEnv {
|
|
179
|
+
shapeId: string;
|
|
180
|
+
path: string[];
|
|
181
|
+
hasBackreference: boolean;
|
|
182
|
+
relatedName?: string;
|
|
183
|
+
schema: PropertySchema;
|
|
184
|
+
shapeName: string;
|
|
185
|
+
}
|
|
146
186
|
export {};
|
|
147
187
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AAC5E,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AAC5E,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,GAAG,EACJ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAC,2BAA2B,EAAC,MAAM,gBAAgB,CAAC;AAE3D;;;;GAIG;AACH,oBAAY,gBAAgB,GACxB,oBAA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B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ProjectSchema, DirectiveMappingArray, DirectiveMappingMap, Directi
|
|
|
2
2
|
import type { Maybe } from '@takeshape/util';
|
|
3
3
|
import type { ShopifyServiceConfig, RESTServiceConfig, GraphQLServiceConfig, OpenAPIServiceConfig, EncryptedServiceConfig, SchemaWithArgs, SchemaWithRef, ServiceConfigWithOAuth2Authentication, ServiceConfigWithCustomAuthentication, LatestProjectSchemaWithServices, ProjectSchemaV3X } from './types';
|
|
4
4
|
import { ArgsType, RefType } from './types';
|
|
5
|
+
import { PropertySchemaWithRelationship } from '.';
|
|
5
6
|
/** Resolver Type Utils **/
|
|
6
7
|
/**
|
|
7
8
|
* Only tests that the shape is right, not that the name is correct. That's a job for the validator.
|
|
@@ -101,4 +102,5 @@ export declare const getArgsType: (argsSchema: SchemaWithArgs) => Maybe<ArgsType
|
|
|
101
102
|
* @param refSchema Any schema that may have a `ref` property.
|
|
102
103
|
*/
|
|
103
104
|
export declare const getRefType: (refSchema: SchemaWithRef) => Maybe<RefType>;
|
|
105
|
+
export declare function isPropertySchemaWithRelationship(schema: PropertySchema): schema is PropertySchemaWithRelationship;
|
|
104
106
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/types/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EACzB,gCAAgC,EAChC,8BAA8B,EAC9B,aAAa,EACb,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,SAAS,EACT,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,6CAA6C,EAC7C,2CAA2C,EAC3C,WAAW,EACX,WAAW,EACX,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,qCAAqC,EACrC,qCAAqC,EACrC,+BAA+B,EAC/B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/types/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EACzB,gCAAgC,EAChC,8BAA8B,EAC9B,aAAa,EACb,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,SAAS,EACT,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,kBAAkB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gB,uCAAuC,CACrD,kBAAkB,EAAE,GAAG,GACtB,kBAAkB,IAAI,qCAAqC,CAM7D;AAED,4BAA4B;AAE5B,wBAAgB,uBAAuB,CAAC,mBAAmB,EAAE,GAAG,GAAG,mBAAmB,IAAI,qBAAqB,CAE9G;AAED,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,qBAAqB,GAAG,cAAc,IAAI,oBAAoB,CAEpH;AAED,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,qBAAqB,GAAG,cAAc,IAAI,mBAAmB,CAElH;AAED,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,qBAAqB,GACpC,cAAc,IAAI,0BAA0B,CAE9C;AAED,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,qBAAqB,GAAG,cAAc,IAAI,oBAAoB,CAEpH;AAED,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,qBAAqB,GACpC,cAAc,IAAI,0BAA0B,CAE9C;AAED,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,qBAAqB,GAAG,cAAc,IAAI,oBAAoB,CAEpH;AAED,2BAA2B;AAE3B;;;;GAIG;AACH,eAAO,MAAM,WAAW,eAAgB,cAAc,KAAG,MAAM,QAAQ,CAQtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,cAAe,aAAa,KAAG,MAAM,OAAO,CAQlE,CAAC;AAEF,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI,8BAA8B,CAGjH"}
|
package/dist/types/utils.js
CHANGED
|
@@ -36,6 +36,7 @@ exports.isParameterSerializeStyleForPathParams = isParameterSerializeStyleForPat
|
|
|
36
36
|
exports.isParameterSerializeStyleForSearchParams = isParameterSerializeStyleForSearchParams;
|
|
37
37
|
exports.isParameterSerializeStyleOptions = isParameterSerializeStyleOptions;
|
|
38
38
|
exports.isProjectSchemaWithServices = isProjectSchemaWithServices;
|
|
39
|
+
exports.isPropertySchemaWithRelationship = isPropertySchemaWithRelationship;
|
|
39
40
|
exports.isRESTServiceConfig = isRESTServiceConfig;
|
|
40
41
|
exports.isRefSchema = isRefSchema;
|
|
41
42
|
exports.isRefSchemaLegacy = isRefSchemaLegacy;
|
|
@@ -375,4 +376,11 @@ const getRefType = refSchema => {
|
|
|
375
376
|
}
|
|
376
377
|
};
|
|
377
378
|
|
|
378
|
-
exports.getRefType = getRefType;
|
|
379
|
+
exports.getRefType = getRefType;
|
|
380
|
+
|
|
381
|
+
function isPropertySchemaWithRelationship(schema) {
|
|
382
|
+
var _schema$Resolver;
|
|
383
|
+
|
|
384
|
+
schema = schema['@output'] ?? schema;
|
|
385
|
+
return ((_schema$Resolver = schema['@resolver']) === null || _schema$Resolver === void 0 ? void 0 : _schema$Resolver.name) === 'takeshape:getRelated';
|
|
386
|
+
}
|
package/dist/unions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unions.d.ts","sourceRoot":"","sources":["../../src/unions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAIpD,OAAO,EAAsB,iBAAiB,EAAS,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"unions.d.ts","sourceRoot":"","sources":["../../src/unions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAIpD,OAAO,EAAsB,iBAAiB,EAAS,MAAM,4BAA4B,CAAC;AAM1F,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAmB3G;AAUD,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI,WAAW,CAE3E;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,GAAG,YAAY,CAOnG;AAMD,oBAAY,uBAAuB,GAAG,CAAC,aAAa,EAAE,aAAa,KAAK,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAGrG,eAAO,MAAM,qBAAqB,EAAE,uBA0BnC,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,uBASjC,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,uBAAuB,mBAE5C,aAAa,UACpB,cAAc,OACjB,OAAO,MAAM,EAAE,OAAO,CAAC,KAC3B,OAAO,MAAM,EAAE,OAAO,CAAC,CAiB3B;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,kBA3BZ,aAAa,UACpB,cAAc,OACjB,OAAO,MAAM,EAAE,OAAO,CAAC,KAC3B,OAAO,MAAM,EAAE,OAAO,CAwB4C,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,kBAlCV,aAAa,UACpB,cAAc,OACjB,OAAO,MAAM,EAAE,OAAO,CAAC,KAC3B,OAAO,MAAM,EAAE,OAAO,CA+BwC,CAAC"}
|
package/dist/unions.js
CHANGED
|
@@ -24,6 +24,8 @@ var _errors = require("@takeshape/errors");
|
|
|
24
24
|
|
|
25
25
|
var _schemaUtil = require("./schema-util");
|
|
26
26
|
|
|
27
|
+
var _templates = require("./template-shapes/templates");
|
|
28
|
+
|
|
27
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
30
|
|
|
29
31
|
function enumerateOneOfKeys(projectSchema, oneOf) {
|
|
@@ -38,7 +40,7 @@ function enumerateOneOfKeys(projectSchema, oneOf) {
|
|
|
38
40
|
if (projectSchema.shapes[shapeName]) {
|
|
39
41
|
const shapeId = projectSchema.shapes[shapeName].id;
|
|
40
42
|
result.push({
|
|
41
|
-
propName: (0, _util.camelCase)(refItem.typeName),
|
|
43
|
+
propName: (0, _templates.getOutputShapeName)((0, _util.camelCase)(refItem.typeName)),
|
|
42
44
|
propSchema: child,
|
|
43
45
|
shapeName,
|
|
44
46
|
shapeId
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ProjectSchema, PropertySchema } from '../project-schema';
|
|
2
|
+
declare type SchemaPredicate = (projectSchema: ProjectSchema, propSchema: PropertySchema, shapeName?: string, propName?: string) => boolean;
|
|
2
3
|
/**
|
|
3
4
|
* Use a basic depth-first search to determine whether a schema contains a cycle
|
|
4
5
|
*/
|
|
5
|
-
export declare function hasCycle(projectSchema: ProjectSchema, schema: PropertySchema,
|
|
6
|
+
export declare function hasCycle(projectSchema: ProjectSchema, schema: PropertySchema, predicate?: SchemaPredicate): boolean;
|
|
7
|
+
export {};
|
|
6
8
|
//# sourceMappingURL=detect-cycles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-cycles.d.ts","sourceRoot":"","sources":["../../../src/util/detect-cycles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"detect-cycles.d.ts","sourceRoot":"","sources":["../../../src/util/detect-cycles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAUhE,aAAK,eAAe,GAAG,CACrB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,cAAc,EAC1B,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC;AAEb;;GAEG;AACH,wBAAgB,QAAQ,CACtB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,cAAc,EACtB,SAAS,GAAE,eAA6B,GACvC,OAAO,CAiDT"}
|
|
@@ -7,53 +7,62 @@ exports.hasCycle = hasCycle;
|
|
|
7
7
|
|
|
8
8
|
var _refs = require("../refs");
|
|
9
9
|
|
|
10
|
+
var _util = require("@takeshape/util");
|
|
11
|
+
|
|
10
12
|
function immutableSetAdd(set, str) {
|
|
11
13
|
const result = new Set(set);
|
|
12
14
|
result.add(str);
|
|
13
15
|
return result;
|
|
14
16
|
}
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* Use a basic depth-first search to determine whether a schema contains a cycle
|
|
17
20
|
*/
|
|
21
|
+
function hasCycle(projectSchema, schema, predicate = (0, _util.value)(true)) {
|
|
22
|
+
const hasCycleHelper = (schema, shapesSeen = new Set(), shapeName, propName) => {
|
|
23
|
+
if (!predicate(projectSchema, schema, shapeName, propName)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
18
26
|
|
|
27
|
+
const refItem = (0, _refs.getRef)(projectSchema, schema);
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
if (refItem) {
|
|
30
|
+
const refShape = (0, _refs.refItemToShape)(projectSchema, refItem); // If we have a refItem, but no shape, this is a dangling ref and has no cycles
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
if (!refShape) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
25
35
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
if (shapesSeen.has(refShape.name)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
return true;
|
|
40
|
+
return hasCycleHelper(refShape.schema, immutableSetAdd(shapesSeen, refShape.name), refShape.name);
|
|
32
41
|
}
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
}
|
|
43
|
+
const combo = schema.oneOf ?? schema.allOf ?? schema.extends;
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
if (combo) {
|
|
46
|
+
return combo.some(childSchema => hasCycleHelper(childSchema, shapesSeen, shapeName, propName));
|
|
47
|
+
}
|
|
38
48
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
if (schema.items) {
|
|
50
|
+
return hasCycleHelper(schema.items, shapesSeen, shapeName, propName);
|
|
51
|
+
}
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
const {
|
|
54
|
+
properties
|
|
55
|
+
} = schema;
|
|
46
56
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
if (properties) {
|
|
58
|
+
return Object.keys(properties).some(name => {
|
|
59
|
+
const propSchema = properties[name];
|
|
60
|
+
return hasCycleHelper(propSchema, shapesSeen, shapeName, name);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
50
63
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const propSchema = properties[name];
|
|
54
|
-
return hasCycle(projectSchema, propSchema, shapesSeen);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
57
66
|
|
|
58
|
-
return
|
|
67
|
+
return hasCycleHelper(schema);
|
|
59
68
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormConfig, FormMap } from '../project-schema';
|
|
2
|
+
import { Maybe } from '@takeshape/util';
|
|
3
|
+
import { ProjectSchema } from '../project-schema';
|
|
4
|
+
export declare function normalizeForms(projectSchema: ProjectSchema): FormMap;
|
|
5
|
+
/**
|
|
6
|
+
* Find the form config for a given shape name and the form key.
|
|
7
|
+
*/
|
|
8
|
+
export declare function findShapeFormConfig(projectSchema: ProjectSchema, shapeName: string, formName: string): Maybe<FormConfig>;
|
|
9
|
+
//# sourceMappingURL=form-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-config.d.ts","sourceRoot":"","sources":["../../../src/util/form-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAY,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAIhD,wBAAgB,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAmDpE;AAID;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,KAAK,CAAC,UAAU,CAAC,CAYnB"}
|