@takeshape/schema 8.165.1 → 8.167.2
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/schema-util.js
CHANGED
|
@@ -716,9 +716,8 @@ function getShapeDependencies(projectSchema, shape, predicate) {
|
|
|
716
716
|
const shapeNames = new Set();
|
|
717
717
|
|
|
718
718
|
const findDependencies = schema => {
|
|
719
|
-
schema = schema.items ?? schema;
|
|
720
|
-
|
|
721
719
|
if (!predicate || predicate(schema)) {
|
|
720
|
+
schema = schema.items ?? schema;
|
|
722
721
|
const refItem = (0, _refs.getRef)(projectSchema, schema);
|
|
723
722
|
|
|
724
723
|
if (refItem) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/template-shapes/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/template-shapes/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAiB,cAAc,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AACvG,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,YAsWJ,eAAe,SAAS,KAAK,KAAG,gBAAgB,AAtWA,CAAC;AACpE,eAAO,MAAM,YAAY,YAqWN,eAAe,SAAS,KAAK,KAAG,gBAAgB,AArWK,CAAC;AACzE,eAAO,MAAM,UAAU,sBAkNI,eAAe,SAAS,KAAK,KAAG,gBAAgB,AA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;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AA2BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,uBAM9C,eAAe,SAAS,KAAK,KAAG,gBAAgB,CA4E1E;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"}
|
|
@@ -255,24 +255,21 @@ function getOutputShapeName(name) {
|
|
|
255
255
|
return name.replace(/(?:Input|PartialInput)$/, '');
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
function rewriteRefs(shapeSchema, rewriteShapeName) {
|
|
258
|
+
function rewriteRefs(context, shapeSchema, rewriteShapeName) {
|
|
259
259
|
const newSchema = (0, _util.deepClone)(shapeSchema);
|
|
260
260
|
(0, _util.visit)(newSchema, ['$ref', '@ref'], (_, path) => {
|
|
261
261
|
const parentPath = path.slice(0, -1);
|
|
262
262
|
const value = (0, _get.default)(newSchema, parentPath);
|
|
263
263
|
|
|
264
264
|
if ((value['@ref'] || value.$ref) && !parentPath.includes('@input') && !parentPath.includes('@output')) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
value['@ref'] = `local:${rewriteShapeName(
|
|
269
|
-
}
|
|
265
|
+
const refItem = (0, _refs.getRef)(context, value);
|
|
266
|
+
|
|
267
|
+
if (refItem) {
|
|
268
|
+
value['@ref'] = refItem.isForeign ? (0, _refs.refItemToAtRef)(refItem) : `local:${rewriteShapeName((0, _refs.refItemToShapeName)(refItem))}`;
|
|
270
269
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
parts[2] = rewriteShapeName(parts[2]);
|
|
275
|
-
value.$ref = parts.join('/');
|
|
270
|
+
if (value.$ref) {
|
|
271
|
+
delete value.$ref;
|
|
272
|
+
}
|
|
276
273
|
}
|
|
277
274
|
}
|
|
278
275
|
});
|
|
@@ -301,7 +298,7 @@ function getMutationArgs(templateName, verb) {
|
|
|
301
298
|
rewrittenSchema = (0, _createInputSchema.createInputSchema)(shape.schema, {
|
|
302
299
|
isUpdate
|
|
303
300
|
});
|
|
304
|
-
inputShapeSchema = rewriteRefs(rewrittenSchema, getInputShapeName);
|
|
301
|
+
inputShapeSchema = rewriteRefs(projectSchema, rewrittenSchema, getInputShapeName);
|
|
305
302
|
}
|
|
306
303
|
|
|
307
304
|
const inputShape = (0, _schemaUtil.createShape)(inputName, (0, _util2.mergeObjectSchemas)(shouldRequireId ? idSchema : undefined, inputShapeSchema), {
|
|
@@ -341,7 +338,7 @@ function getMutationArgs(templateName, verb) {
|
|
|
341
338
|
}).map(shapeName => {
|
|
342
339
|
const shape = projectSchema.shapes[shapeName]; // We only allow partial input at the top-level
|
|
343
340
|
|
|
344
|
-
return (0, _schemaUtil.createShape)(getInputShapeName(shapeName), rewriteRefs((0, _createInputSchema.createInputSchema)(shape.schema), getInputShapeName));
|
|
341
|
+
return (0, _schemaUtil.createShape)(getInputShapeName(shapeName), rewriteRefs(projectSchema, (0, _createInputSchema.createInputSchema)(shape.schema), getInputShapeName));
|
|
345
342
|
}), 'name')),
|
|
346
343
|
...(addStructure ? {
|
|
347
344
|
ContentStructureInput
|
package/es/schema-util.js
CHANGED
|
@@ -590,9 +590,8 @@ export function getShapeDependencies(projectSchema, shape, predicate) {
|
|
|
590
590
|
const shapeNames = new Set();
|
|
591
591
|
|
|
592
592
|
const findDependencies = schema => {
|
|
593
|
-
schema = schema.items ?? schema;
|
|
594
|
-
|
|
595
593
|
if (!predicate || predicate(schema)) {
|
|
594
|
+
schema = schema.items ?? schema;
|
|
596
595
|
const refItem = getRef(projectSchema, schema);
|
|
597
596
|
|
|
598
597
|
if (refItem) {
|
|
@@ -3,7 +3,7 @@ import { listTypePrefix } from '../migration';
|
|
|
3
3
|
import { deepClone, pascalCase, visit } from '@takeshape/util';
|
|
4
4
|
import keyBy from 'lodash/keyBy';
|
|
5
5
|
import { createShape, getShapeDependencies, isIndexedRemoteShape } from '../schema-util';
|
|
6
|
-
import { getFlattenedTemplateShapeName, getRefShapeName } from '../refs';
|
|
6
|
+
import { getFlattenedTemplateShapeName, getRef, getRefShapeName, refItemToAtRef, refItemToShapeName } from '../refs';
|
|
7
7
|
import { getWhereSearchArg } from './where';
|
|
8
8
|
import { mergeObjectSchemas, mergeSchemaProperties } from '../util';
|
|
9
9
|
import { createInputSchema } from '../create-input-schema';
|
|
@@ -200,24 +200,21 @@ export function getOutputShapeName(name) {
|
|
|
200
200
|
return name.replace(/(?:Input|PartialInput)$/, '');
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
function rewriteRefs(shapeSchema, rewriteShapeName) {
|
|
203
|
+
function rewriteRefs(context, shapeSchema, rewriteShapeName) {
|
|
204
204
|
const newSchema = deepClone(shapeSchema);
|
|
205
205
|
visit(newSchema, ['$ref', '@ref'], (_, path) => {
|
|
206
206
|
const parentPath = path.slice(0, -1);
|
|
207
207
|
const value = get(newSchema, parentPath);
|
|
208
208
|
|
|
209
209
|
if ((value['@ref'] || value.$ref) && !parentPath.includes('@input') && !parentPath.includes('@output')) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
value['@ref'] = `local:${rewriteShapeName(
|
|
214
|
-
}
|
|
210
|
+
const refItem = getRef(context, value);
|
|
211
|
+
|
|
212
|
+
if (refItem) {
|
|
213
|
+
value['@ref'] = refItem.isForeign ? refItemToAtRef(refItem) : `local:${rewriteShapeName(refItemToShapeName(refItem))}`;
|
|
215
214
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
parts[2] = rewriteShapeName(parts[2]);
|
|
220
|
-
value.$ref = parts.join('/');
|
|
215
|
+
if (value.$ref) {
|
|
216
|
+
delete value.$ref;
|
|
217
|
+
}
|
|
221
218
|
}
|
|
222
219
|
}
|
|
223
220
|
});
|
|
@@ -246,7 +243,7 @@ export function getMutationArgs(templateName, verb) {
|
|
|
246
243
|
rewrittenSchema = createInputSchema(shape.schema, {
|
|
247
244
|
isUpdate
|
|
248
245
|
});
|
|
249
|
-
inputShapeSchema = rewriteRefs(rewrittenSchema, getInputShapeName);
|
|
246
|
+
inputShapeSchema = rewriteRefs(projectSchema, rewrittenSchema, getInputShapeName);
|
|
250
247
|
}
|
|
251
248
|
|
|
252
249
|
const inputShape = createShape(inputName, mergeObjectSchemas(shouldRequireId ? idSchema : undefined, inputShapeSchema), {
|
|
@@ -286,7 +283,7 @@ export function getMutationArgs(templateName, verb) {
|
|
|
286
283
|
}).map(shapeName => {
|
|
287
284
|
const shape = projectSchema.shapes[shapeName]; // We only allow partial input at the top-level
|
|
288
285
|
|
|
289
|
-
return createShape(getInputShapeName(shapeName), rewriteRefs(createInputSchema(shape.schema), getInputShapeName));
|
|
286
|
+
return createShape(getInputShapeName(shapeName), rewriteRefs(projectSchema, createInputSchema(shape.schema), getInputShapeName));
|
|
290
287
|
}), 'name')),
|
|
291
288
|
...(addStructure ? {
|
|
292
289
|
ContentStructureInput
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.167.2",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"examples"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@takeshape/errors": "8.
|
|
25
|
-
"@takeshape/json-schema": "8.
|
|
26
|
-
"@takeshape/util": "8.
|
|
24
|
+
"@takeshape/errors": "8.167.2",
|
|
25
|
+
"@takeshape/json-schema": "8.167.2",
|
|
26
|
+
"@takeshape/util": "8.167.2",
|
|
27
27
|
"ajv": "^8.10.0",
|
|
28
28
|
"ajv-formats": "^2.1.1",
|
|
29
29
|
"blueimp-md5": "^2.10.0",
|