@takeshape/schema 11.94.3 → 11.95.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/refs.d.ts +2 -1
- package/dist/refs.js +16 -5
- package/package.json +5 -6
package/dist/refs.d.ts
CHANGED
|
@@ -182,7 +182,8 @@ export declare function createGetNamespace(context: ServicesContext): GetNamespa
|
|
|
182
182
|
export declare function parsePropertyRef(refStr: string): Maybe<PropertyRefItem>;
|
|
183
183
|
export declare function serializePropertyRef({ shapeName, propertyName, layerId }: PropertyRefItem): string;
|
|
184
184
|
export declare function normalizePropertyRef(refStr: string): string;
|
|
185
|
-
export declare function propertyRefToShapeRef(propertyRef: string): string;
|
|
185
|
+
export declare function propertyRefToShapeRef(propertyRef: string): string | undefined;
|
|
186
|
+
export declare function mappingToShapeRefs(prop: Pick<PropertySchema, '@mapping'>): string[];
|
|
186
187
|
export declare function formatShapeRef(layerId: string, shapeName: string): string;
|
|
187
188
|
export declare function applyNamespace(namespace: string | undefined, name: string): string;
|
|
188
189
|
export declare function propertyRefItemToResolverPath(getNamespace: GetNamespace, item: PropertyRefItem): string[];
|
package/dist/refs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NotFoundError } from '@takeshape/errors';
|
|
2
|
-
import { deepCloneWith, isDefined, isIntegerLike, isIterableObject, isRecord, visit } from '@takeshape/util';
|
|
2
|
+
import { deepCloneWith, ensureArray, isDefined, isIntegerLike, isIterableObject, isRecord, visit } from '@takeshape/util';
|
|
3
3
|
import compact from 'lodash/compact.js';
|
|
4
4
|
import assign from 'lodash/fp/assign.js';
|
|
5
5
|
import omit from 'lodash/fp/omit.js';
|
|
@@ -440,7 +440,7 @@ export function createGetNamespace(context) {
|
|
|
440
440
|
export function parsePropertyRef(refStr) {
|
|
441
441
|
const [layerId, coordinate] = splitRefExpression(refStr);
|
|
442
442
|
const coordinateParts = coordinate.split('.');
|
|
443
|
-
if (coordinateParts.length === 1) {
|
|
443
|
+
if (coordinateParts.length === 1 && coordinateParts[0]) {
|
|
444
444
|
return { layerId, shapeName: 'Query', propertyName: coordinateParts[0] };
|
|
445
445
|
}
|
|
446
446
|
if (coordinateParts.length === 2) {
|
|
@@ -460,10 +460,21 @@ export function normalizePropertyRef(refStr) {
|
|
|
460
460
|
}
|
|
461
461
|
export function propertyRefToShapeRef(propertyRef) {
|
|
462
462
|
const parsed = parsePropertyRef(propertyRef);
|
|
463
|
-
|
|
464
|
-
|
|
463
|
+
return parsed && formatShapeRef(parsed.layerId, parsed.shapeName);
|
|
464
|
+
}
|
|
465
|
+
export function mappingToShapeRefs(prop) {
|
|
466
|
+
const mappings = prop['@mapping'];
|
|
467
|
+
if (mappings) {
|
|
468
|
+
const result = [];
|
|
469
|
+
for (const mapping of ensureArray(mappings)) {
|
|
470
|
+
const shapeRef = propertyRefToShapeRef(mapping);
|
|
471
|
+
if (shapeRef) {
|
|
472
|
+
result.push(shapeRef);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
465
476
|
}
|
|
466
|
-
return
|
|
477
|
+
return [];
|
|
467
478
|
}
|
|
468
479
|
export function formatShapeRef(layerId, shapeName) {
|
|
469
480
|
return layerId === LOCAL_LAYER_ID ? shapeName : `${layerId}:${shapeName}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.95.0",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"p-reduce": "^2.1.0",
|
|
59
59
|
"semver": "^7.3.2",
|
|
60
60
|
"tiny-invariant": "^1.2.0",
|
|
61
|
-
"@takeshape/
|
|
62
|
-
"@takeshape/
|
|
63
|
-
"@takeshape/
|
|
61
|
+
"@takeshape/errors": "11.95.0",
|
|
62
|
+
"@takeshape/json-schema": "11.95.0",
|
|
63
|
+
"@takeshape/util": "11.95.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@takeshape/json-schema-to-typescript": "^11.0.0",
|
|
@@ -75,9 +75,8 @@
|
|
|
75
75
|
"fs-extra": "^8.1.0",
|
|
76
76
|
"glob": "^7.1.6",
|
|
77
77
|
"json-schema-to-ts": "^3.1.1",
|
|
78
|
-
"meow": "^9.0.0",
|
|
79
78
|
"shortid": "^2.2.15",
|
|
80
|
-
"@takeshape/infra": "11.
|
|
79
|
+
"@takeshape/infra": "11.95.0"
|
|
81
80
|
},
|
|
82
81
|
"engines": {
|
|
83
82
|
"node": ">=20"
|