@takeshape/schema 8.188.2 → 8.189.4
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/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.18.1.d.ts +5 -0
- package/dist/migration/to/v3.18.1.d.ts.map +1 -0
- package/dist/migration/to/v3.18.1.js +28 -0
- 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 +1 -2
- 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.1.d.ts +1333 -0
- package/dist/project-schema/v3.18.1.d.ts.map +1 -0
- package/dist/project-schema/v3.18.1.js +5 -0
- package/dist/schema-util.d.ts.map +1 -1
- package/dist/schema-util.js +13 -11
- 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 +4 -3
- package/dist/schemas/project-schema/v3.18.1.json +2351 -0
- package/dist/schemas/project-schema.json +3 -0
- package/dist/types/types.d.ts +2 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/util/has-arg.d.ts +4 -2
- package/dist/util/has-arg.d.ts.map +1 -1
- package/dist/util/has-arg.js +6 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +31 -2
- package/es/migration/index.js +3 -1
- package/es/migration/to/v3.18.1.js +16 -0
- package/es/project-schema/index.js +3 -1
- package/es/project-schema/migrate.js +5 -1
- package/es/project-schema/v3.18.1.js +1 -0
- package/es/schema-util.js +11 -9
- package/es/schemas/index.js +4 -3
- package/es/schemas/index.ts +4 -2
- package/es/schemas/project-schema/latest.json +4 -3
- package/es/schemas/project-schema/v3.18.1.json +2351 -0
- package/es/schemas/project-schema.json +3 -0
- package/es/util/has-arg.js +4 -1
- package/es/validate.js +28 -3
- package/examples/latest/betzino.json +2276 -2276
- package/examples/latest/blog-schema.json +44 -44
- package/examples/latest/brewery-schema.json +38 -38
- package/examples/latest/complex-project-schema.json +272 -272
- package/examples/latest/complex-schema.json +1 -1
- package/examples/latest/fabric-ecommerce.json +23 -23
- package/examples/latest/frank-and-fred-schema.json +1616 -1616
- package/examples/latest/klirr-schema.json +1951 -1951
- package/examples/latest/massive-schema.json +428 -428
- package/examples/latest/mill-components-schema.json +200 -200
- package/examples/latest/one-earth.json +613 -613
- package/examples/latest/pet-oneof-array.json +38 -38
- package/examples/latest/post-schema.json +38 -38
- package/examples/latest/pruned-shopify-product-schema.json +8 -8
- package/examples/latest/real-world-schema.json +80 -80
- package/examples/latest/recursive-repeater-schema.json +20 -20
- package/examples/latest/recursive-schema.json +20 -20
- package/examples/latest/rick-and-morty-ast.json +150 -150
- package/examples/latest/rick-and-morty-graphql.json +114 -114
- package/examples/latest/rick-and-morty-rest.json +5 -5
- package/examples/latest/schema-with-repeater-draftjs.json +20 -20
- package/examples/latest/shape-books-v3_2_0.json +122 -122
- package/examples/latest/shape-books.json +122 -122
- package/examples/latest/shopify-lookbook.json +44 -44
- package/examples/latest/shopify-store-with-widget.json +80 -80
- package/examples/latest/stripe-starter-resolved.json +83 -83
- package/examples/latest/user-schema-no-required.json +20 -20
- package/examples/latest/user-schema-with-defaults.json +20 -20
- package/package.json +4 -4
package/es/util/has-arg.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { findSchemaAtPath } from './find-shape-at-path';
|
|
2
|
+
export function getArgs(prop) {
|
|
3
|
+
return '@args' in prop ? prop['@args'] : 'args' in prop ? prop.args : undefined;
|
|
4
|
+
}
|
|
2
5
|
export function hasArg(projectSchema, prop, argPath) {
|
|
3
6
|
var _projectSchema$shapes;
|
|
4
7
|
|
|
5
|
-
const args =
|
|
8
|
+
const args = getArgs(prop);
|
|
6
9
|
|
|
7
10
|
if (!args) {
|
|
8
11
|
return false;
|
package/es/validate.js
CHANGED
|
@@ -16,14 +16,18 @@ import { getAllNamespaceShapes, getAllRefsInShapes } from './schema-util';
|
|
|
16
16
|
import { builtInShapes } from './builtin-schema';
|
|
17
17
|
import { isValidTemplate } from './template-shapes';
|
|
18
18
|
import { isBasicResolver, isComposeResolver } from './types/utils';
|
|
19
|
-
import { refItemToAtRef, refItemToShapeName, parseReturnShape } from './refs';
|
|
19
|
+
import { refItemToAtRef, refItemToShapeName, parseReturnShape, getRefShapeName } from './refs';
|
|
20
20
|
import { scalars } from './scalars';
|
|
21
21
|
import { isUnionSchema } from './unions';
|
|
22
22
|
import { isEnumLikeSchema } from './enum';
|
|
23
23
|
import metaSchemaV3_9_0 from './schemas/project-schema/meta-schema-v3.9.0.json';
|
|
24
24
|
import { isIntegerLike } from '@takeshape/util';
|
|
25
25
|
import forOwn from 'lodash/forOwn';
|
|
26
|
+
import uniqBy from 'lodash/uniqBy';
|
|
27
|
+
import initial from 'lodash/initial';
|
|
28
|
+
import last from 'lodash/last';
|
|
26
29
|
import { getRelationship } from './relationships';
|
|
30
|
+
import get from 'lodash/get';
|
|
27
31
|
|
|
28
32
|
function findDuplicates(items) {
|
|
29
33
|
const seen = {};
|
|
@@ -373,6 +377,18 @@ function validateRefs(projectSchema, additionalShapeNames = builtInShapeNames) {
|
|
|
373
377
|
message: `allOf cannot be self-referential`
|
|
374
378
|
});
|
|
375
379
|
}
|
|
380
|
+
|
|
381
|
+
const parentPath = initial(item.path);
|
|
382
|
+
const parentSchema = get(projectSchema, parentPath);
|
|
383
|
+
const propName = last(item.path);
|
|
384
|
+
|
|
385
|
+
if (propName === '@ref' && parentSchema.$ref) {
|
|
386
|
+
errors.push({
|
|
387
|
+
type: 'conflict',
|
|
388
|
+
path: parentPath,
|
|
389
|
+
message: `Ref cannot have both @ref and $ref`
|
|
390
|
+
});
|
|
391
|
+
}
|
|
376
392
|
});
|
|
377
393
|
}
|
|
378
394
|
|
|
@@ -432,14 +448,23 @@ function validateOneOfs(projectSchema) {
|
|
|
432
448
|
const oneOfPath = property.items ? ['items', 'oneOf'] : ['oneOf'];
|
|
433
449
|
const relationship = getRelationship(property);
|
|
434
450
|
const schema = property.items ? property.items : property;
|
|
451
|
+
const isUnion = isUnionSchema(schema);
|
|
435
452
|
|
|
436
|
-
if (schema.oneOf && !relationship && !
|
|
453
|
+
if (schema.oneOf && !relationship && !isUnion && !isEnumLikeSchema(schema)) {
|
|
437
454
|
errors.push({
|
|
438
|
-
type: '
|
|
455
|
+
type: 'conflict',
|
|
439
456
|
path: propertyPath.concat(oneOfPath),
|
|
440
457
|
message: `Invalid oneOf must contain only @ref or title + enum/const schemas`
|
|
441
458
|
});
|
|
442
459
|
}
|
|
460
|
+
|
|
461
|
+
if (isUnion && schema.oneOf.length !== uniqBy(schema.oneOf, refSchema => getRefShapeName(projectSchema, refSchema)).length) {
|
|
462
|
+
errors.push({
|
|
463
|
+
type: 'conflict',
|
|
464
|
+
path: propertyPath.concat(oneOfPath),
|
|
465
|
+
message: `Invalid oneOf must not contain duplicate references`
|
|
466
|
+
});
|
|
467
|
+
}
|
|
443
468
|
});
|
|
444
469
|
return errors;
|
|
445
470
|
}
|