@takeshape/schema 8.182.2 → 8.183.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.
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAC,MAAM,KAAK,CAAC;AACvD,OAAO,KAAK,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAmB,mBAAmB,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAEV,gBAAgB,EAChB,aAAa,EASb,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAwB,yBAAyB,EAAC,MAAM,mBAAmB,CAAC;AAoenF,oBAAY,sBAAsB,GAC9B;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,GAC1D;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,yBAAyB,EAAE,CAAA;CAAC,CAAC;AAE3E,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,yBAAyB,CAuBzE;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,sBAAsB,CAAC;CAClF;AACD,MAAM,WAAW,eAAe;IAC9B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,kBAAkB,CAAC,EAAE,MAAM,EAA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MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,sBAAsB,CAAC;CAClF;AACD,MAAM,WAAW,eAAe;IAC9B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;CACnE;AAqKD;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,sBAAsB,CAqB9F;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAgBnE;AAgBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,OAAO,GAAG,SAAS,CAQpE;AAgBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAQlE;AAqBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,OAAO,GAAG,mBAAmB,CAarF"}
package/dist/validate.js CHANGED
@@ -472,25 +472,12 @@ function validateOneOfs(projectSchema) {
472
472
  const relationship = (0, _relationships.getRelationship)(property);
473
473
  const schema = property.items ? property.items : property;
474
474
 
475
- if (schema.oneOf && !relationship) {
476
- if ((0, _unions.isUnionSchema)(schema)) {
477
- const modelsReferenced = (0, _unions.enumerateOneOfKeys)(projectSchema, schema.oneOf).map(child => child.shapeName).filter(shapeName => projectSchema.shapes[shapeName].model);
478
-
479
- if (modelsReferenced.length) {
480
- const shapeNames = modelsReferenced.join(', ');
481
- errors.push({
482
- type: 'json',
483
- path: propertyPath.concat(oneOfPath),
484
- message: `Invalid refs to ${shapeNames}. oneOf unions cannot reference model shapes. Use @relationship instead`
485
- });
486
- }
487
- } else if (!(0, _enum.isEnumLikeSchema)(schema)) {
488
- errors.push({
489
- type: 'json',
490
- path: propertyPath.concat(oneOfPath),
491
- message: `Invalid oneOf must contain only @ref or title + enum/const schemas`
492
- });
493
- }
475
+ if (schema.oneOf && !relationship && !(0, _unions.isUnionSchema)(schema) && !(0, _enum.isEnumLikeSchema)(schema)) {
476
+ errors.push({
477
+ type: 'json',
478
+ path: propertyPath.concat(oneOfPath),
479
+ message: `Invalid oneOf must contain only @ref or title + enum/const schemas`
480
+ });
494
481
  }
495
482
  });
496
483
  return errors;
package/es/validate.js CHANGED
@@ -18,7 +18,7 @@ import { isValidTemplate } from './template-shapes';
18
18
  import { isBasicResolver, isComposeResolver } from './types/utils';
19
19
  import { refItemToAtRef, refItemToShapeName, parseReturnShape } from './refs';
20
20
  import { scalars } from './scalars';
21
- import { enumerateOneOfKeys, isUnionSchema } from './unions';
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';
@@ -433,25 +433,12 @@ function validateOneOfs(projectSchema) {
433
433
  const relationship = getRelationship(property);
434
434
  const schema = property.items ? property.items : property;
435
435
 
436
- if (schema.oneOf && !relationship) {
437
- if (isUnionSchema(schema)) {
438
- const modelsReferenced = enumerateOneOfKeys(projectSchema, schema.oneOf).map(child => child.shapeName).filter(shapeName => projectSchema.shapes[shapeName].model);
439
-
440
- if (modelsReferenced.length) {
441
- const shapeNames = modelsReferenced.join(', ');
442
- errors.push({
443
- type: 'json',
444
- path: propertyPath.concat(oneOfPath),
445
- message: `Invalid refs to ${shapeNames}. oneOf unions cannot reference model shapes. Use @relationship instead`
446
- });
447
- }
448
- } else if (!isEnumLikeSchema(schema)) {
449
- errors.push({
450
- type: 'json',
451
- path: propertyPath.concat(oneOfPath),
452
- message: `Invalid oneOf must contain only @ref or title + enum/const schemas`
453
- });
454
- }
436
+ if (schema.oneOf && !relationship && !isUnionSchema(schema) && !isEnumLikeSchema(schema)) {
437
+ errors.push({
438
+ type: 'json',
439
+ path: propertyPath.concat(oneOfPath),
440
+ message: `Invalid oneOf must contain only @ref or title + enum/const schemas`
441
+ });
455
442
  }
456
443
  });
457
444
  return errors;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/schema",
3
- "version": "8.182.2",
3
+ "version": "8.183.1",
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.182.2",
25
- "@takeshape/json-schema": "8.182.2",
26
- "@takeshape/util": "8.182.2",
24
+ "@takeshape/errors": "8.183.1",
25
+ "@takeshape/json-schema": "8.183.1",
26
+ "@takeshape/util": "8.183.1",
27
27
  "ajv": "^8.10.0",
28
28
  "ajv-formats": "^2.1.1",
29
29
  "blueimp-md5": "^2.10.0",