@takeshape/schema 8.225.0 → 8.228.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.
@@ -4,7 +4,7 @@ import type { Relationship, PropertySchemaWithRelationship, LegacyRelationship,
4
4
  /**
5
5
  * Turn a LegacyRelationship into a partial PropertySchemaWithRelationship.
6
6
  */
7
- export declare function getRelationshipSchema(projectSchema: ProjectSchema, legacyRelationship: LegacyRelationship): PropertySchemaWithRelationship;
7
+ export declare function getRelationshipSchema(projectSchema: ProjectSchema, relationship: LegacyRelationship | Relationship): PropertySchemaWithRelationship;
8
8
  /**
9
9
  * Get a list of refs given a property schema with a relationship resolver.
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/relationships.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AACrF,OAAO,KAAK,EACV,YAAY,EACZ,8BAA8B,EAC9B,kBAAkB,EAClB,SAAS,EACT,eAAe,EAChB,MAAM,SAAS,CAAC;AASjB;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,GACrC,8BAA8B,CAkDhC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,8BAA8B,GAAG,SAAS,CAWlG;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,GAAG,KAAK,EAAE,CAQhF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,CAQnF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,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wBAAgB,qBAAqB,CAAC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,GAAG,kBAAkB,CAKlH;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,CAAC,CAiBnF;AAUD,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,QAAQ,GACf,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAgEnC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,GAAG,OAAO,CAqBjF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,cAAc,EAAE,GAAG,OAAO,CAOhF"}
@@ -32,7 +32,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
32
32
  /**
33
33
  * Turn a LegacyRelationship into a partial PropertySchemaWithRelationship.
34
34
  */
35
- function getRelationshipSchema(projectSchema, legacyRelationship) {
35
+ function getRelationshipSchema(projectSchema, relationship) {
36
36
  const propertySchema = {
37
37
  '@args': 'TSRelationshipArgs',
38
38
  '@resolver': {
@@ -43,22 +43,33 @@ function getRelationshipSchema(projectSchema, legacyRelationship) {
43
43
  }
44
44
  }
45
45
  };
46
- const shapeRefs = legacyRelationship.shapeIds.map(shapeId => {
47
- const shape = (0, _schemaUtil.getShapeById)(projectSchema, shapeId) ?? (0, _find.default)(_builtinSchema.builtInShapes, shape => shape.id === shapeId);
48
- return shape && {
49
- '@ref': `local:${shape.name}`
50
- };
51
- }).filter(_util.isDefined);
46
+ let isMultiple;
47
+ let shapeRefs;
48
+
49
+ if ('shapeIds' in relationship) {
50
+ shapeRefs = relationship.shapeIds.map(shapeId => {
51
+ const shape = (0, _schemaUtil.getShapeById)(projectSchema, shapeId) ?? (0, _find.default)(_builtinSchema.builtInShapes, shape => shape.id === shapeId);
52
+ return shape && {
53
+ '@ref': `local:${shape.name}`
54
+ };
55
+ }).filter(_util.isDefined);
56
+ isMultiple = relationship.type === 'multiple';
57
+ } else {
58
+ shapeRefs = relationship.refs.map(refStr => ({
59
+ '@ref': refStr
60
+ }));
61
+ isMultiple = relationship.isMultiple;
62
+ }
52
63
 
53
64
  if (!shapeRefs.length) {
54
- throw new Error(`Invalid empty relationship ${JSON.stringify(legacyRelationship)}`);
65
+ throw new Error(`Invalid empty relationship ${JSON.stringify(relationship)}`);
55
66
  }
56
67
 
57
68
  const shapeRefsSchema = shapeRefs.length === 1 ? shapeRefs[0] : {
58
69
  oneOf: shapeRefs
59
70
  };
60
71
 
61
- if (legacyRelationship.type === 'multiple') {
72
+ if (isMultiple) {
62
73
  return { ...propertySchema,
63
74
  type: 'array',
64
75
  items: shapeRefsSchema,
@@ -2,4 +2,5 @@ import { FormConfig, ObjectSchema } from '../project-schema';
2
2
  export declare function mergeObjectSchemas(...args: Array<ObjectSchema | undefined>): ObjectSchema;
3
3
  export declare function mergeSchemaProperties(base: ObjectSchema, overrides: ObjectSchema): ObjectSchema;
4
4
  export declare function mergeFormProperties(base: FormConfig, overrides: FormConfig): FormConfig;
5
+ export declare function mergeFormConfigs(...configs: FormConfig[]): FormConfig;
5
6
  //# sourceMappingURL=merge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/util/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAI3D,wBAAgB,kBAAkB,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,YAAY,CAEzF;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,GAAG,YAAY,CAgB/F;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU,CAevF"}
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/util/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAI3D,wBAAgB,kBAAkB,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,YAAY,CAEzF;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,GAAG,YAAY,CAgB/F;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU,CAevF;AAED,wBAAgB,gBAAgB,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,CAErE"}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.mergeFormConfigs = mergeFormConfigs;
6
7
  exports.mergeFormProperties = mergeFormProperties;
7
8
  exports.mergeObjectSchemas = mergeObjectSchemas;
8
9
  exports.mergeSchemaProperties = mergeSchemaProperties;
@@ -48,4 +49,11 @@ function mergeFormProperties(base, overrides) {
48
49
  }
49
50
 
50
51
  return result;
52
+ }
53
+
54
+ function mergeFormConfigs(...configs) {
55
+ return configs.reduce(mergeFormProperties, {
56
+ properties: {},
57
+ order: []
58
+ });
51
59
  }
@@ -9,7 +9,7 @@ import find from 'lodash/find';
9
9
  * Turn a LegacyRelationship into a partial PropertySchemaWithRelationship.
10
10
  */
11
11
 
12
- export function getRelationshipSchema(projectSchema, legacyRelationship) {
12
+ export function getRelationshipSchema(projectSchema, relationship) {
13
13
  const propertySchema = {
14
14
  '@args': 'TSRelationshipArgs',
15
15
  '@resolver': {
@@ -20,22 +20,33 @@ export function getRelationshipSchema(projectSchema, legacyRelationship) {
20
20
  }
21
21
  }
22
22
  };
23
- const shapeRefs = legacyRelationship.shapeIds.map(shapeId => {
24
- const shape = getShapeById(projectSchema, shapeId) ?? find(builtInShapes, shape => shape.id === shapeId);
25
- return shape && {
26
- '@ref': `local:${shape.name}`
27
- };
28
- }).filter(isDefined);
23
+ let isMultiple;
24
+ let shapeRefs;
25
+
26
+ if ('shapeIds' in relationship) {
27
+ shapeRefs = relationship.shapeIds.map(shapeId => {
28
+ const shape = getShapeById(projectSchema, shapeId) ?? find(builtInShapes, shape => shape.id === shapeId);
29
+ return shape && {
30
+ '@ref': `local:${shape.name}`
31
+ };
32
+ }).filter(isDefined);
33
+ isMultiple = relationship.type === 'multiple';
34
+ } else {
35
+ shapeRefs = relationship.refs.map(refStr => ({
36
+ '@ref': refStr
37
+ }));
38
+ isMultiple = relationship.isMultiple;
39
+ }
29
40
 
30
41
  if (!shapeRefs.length) {
31
- throw new Error(`Invalid empty relationship ${JSON.stringify(legacyRelationship)}`);
42
+ throw new Error(`Invalid empty relationship ${JSON.stringify(relationship)}`);
32
43
  }
33
44
 
34
45
  const shapeRefsSchema = shapeRefs.length === 1 ? shapeRefs[0] : {
35
46
  oneOf: shapeRefs
36
47
  };
37
48
 
38
- if (legacyRelationship.type === 'multiple') {
49
+ if (isMultiple) {
39
50
  return { ...propertySchema,
40
51
  type: 'array',
41
52
  items: shapeRefsSchema,
package/es/util/merge.js CHANGED
@@ -33,4 +33,10 @@ export function mergeFormProperties(base, overrides) {
33
33
  }
34
34
 
35
35
  return result;
36
+ }
37
+ export function mergeFormConfigs(...configs) {
38
+ return configs.reduce(mergeFormProperties, {
39
+ properties: {},
40
+ order: []
41
+ });
36
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/schema",
3
- "version": "8.225.0",
3
+ "version": "8.228.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.225.0",
25
- "@takeshape/json-schema": "8.225.0",
26
- "@takeshape/util": "8.225.0",
24
+ "@takeshape/errors": "8.228.1",
25
+ "@takeshape/json-schema": "8.228.1",
26
+ "@takeshape/util": "8.228.1",
27
27
  "ajv": "^8.10.0",
28
28
  "ajv-formats": "^2.1.1",
29
29
  "blueimp-md5": "^2.10.0",