@takeshape/schema 11.134.0 → 11.142.5
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,10 +1,10 @@
|
|
|
1
1
|
import type { ProjectSchemaJSON, PropertySchema } from '../project-schema/index.ts';
|
|
2
2
|
import type { ServiceLayers } from '../types/types.ts';
|
|
3
|
-
import type { Agent, ProjectSchema, Query, Shape } from './types.ts';
|
|
3
|
+
import type { Agent, GetShapeOptions, ProjectSchema, Query, Shape } from './types.ts';
|
|
4
4
|
export declare class ProjectSchemaImpl implements ProjectSchema {
|
|
5
5
|
#private;
|
|
6
6
|
constructor(projectSchemaJson: ProjectSchemaJSON, layers: ServiceLayers);
|
|
7
|
-
getShape(rawShapeRef: string): Shape | undefined;
|
|
7
|
+
getShape(rawShapeRef: string, options?: GetShapeOptions): Shape | undefined;
|
|
8
8
|
getQuery(rawQueryRef: string): Query | undefined;
|
|
9
9
|
ensureQuery(ref: string): Query;
|
|
10
10
|
getLocalQueries(): Query[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getAgent, getAgentMap } from "../agents.js";
|
|
2
|
+
import { allBuiltInShapes } from '../builtin-schema.js';
|
|
2
3
|
import { dereferenceObjectSchema, dereferenceSchema, getQuery, normalizePropertyRef, normalizeRefExpression, parsePropertyRef, parseRef, refItemToNamespacedShapeName } from "../refs.js";
|
|
3
4
|
import { getShape } from "../util/shapes.js";
|
|
4
5
|
import { createAgent } from "./agent.js";
|
|
@@ -17,14 +18,17 @@ export class ProjectSchemaImpl {
|
|
|
17
18
|
this.#queryCache = new Map();
|
|
18
19
|
this.#agentCache = new Map();
|
|
19
20
|
}
|
|
20
|
-
getShape(rawShapeRef) {
|
|
21
|
+
getShape(rawShapeRef, options) {
|
|
21
22
|
const shapeRef = normalizeRefExpression(this.#projectSchemaJson, rawShapeRef);
|
|
22
23
|
let shape = this.#shapeCache.get(shapeRef);
|
|
23
24
|
if (!shape) {
|
|
24
25
|
const refItem = parseRef(this.#projectSchemaJson, rawShapeRef);
|
|
25
26
|
if (refItem) {
|
|
26
27
|
const namespacedName = refItemToNamespacedShapeName(this.#projectSchemaJson, refItem);
|
|
27
|
-
|
|
28
|
+
let shapeJson = getShape(this.#projectSchemaJson, namespacedName);
|
|
29
|
+
if (!shapeJson && options?.includeAllBuiltIns) {
|
|
30
|
+
shapeJson = getShape({ shapes: allBuiltInShapes }, namespacedName);
|
|
31
|
+
}
|
|
28
32
|
if (shapeJson) {
|
|
29
33
|
shape = createShape(this, refItem, shapeJson);
|
|
30
34
|
this.#shapeCache.set(shapeRef, shape);
|
|
@@ -32,7 +36,7 @@ export class ProjectSchemaImpl {
|
|
|
32
36
|
else if (refItem.layerId !== 'local') {
|
|
33
37
|
const layerSchema = this.#layers[refItem.layerId]?.schema;
|
|
34
38
|
if (layerSchema) {
|
|
35
|
-
|
|
39
|
+
shapeJson = getShape(layerSchema, namespacedName);
|
|
36
40
|
if (shapeJson) {
|
|
37
41
|
shape = createShape(this, refItem, shapeJson);
|
|
38
42
|
this.#shapeCache.set(shapeRef, shape);
|
package/dist/models/types.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { AgentJSON, ObjectSchema, ProjectSchemaJSON, PropertySchema, QueryJSON, ShapeJSON } from '../project-schema/index.ts';
|
|
2
2
|
import type { RefItem } from '../refs.ts';
|
|
3
|
+
export interface GetShapeOptions {
|
|
4
|
+
includeAllBuiltIns?: boolean;
|
|
5
|
+
}
|
|
3
6
|
export interface ProjectSchema {
|
|
4
|
-
getShape(shapeRef: string): Shape | undefined;
|
|
7
|
+
getShape(shapeRef: string, options?: GetShapeOptions): Shape | undefined;
|
|
5
8
|
getQuery(queryRef: string): Query | undefined;
|
|
6
9
|
getLocalQueries(): Query[];
|
|
7
10
|
getLocalMutations(): Query[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.142.5",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"jsonpath-plus": "10.0.1",
|
|
53
53
|
"lodash": "4.17.21",
|
|
54
54
|
"minimatch": "3.1.2",
|
|
55
|
-
"p-map": "
|
|
56
|
-
"p-reduce": "
|
|
55
|
+
"p-map": "7.0.3",
|
|
56
|
+
"p-reduce": "3.0.0",
|
|
57
57
|
"semver": "7.7.2",
|
|
58
58
|
"tiny-invariant": "1.3.3",
|
|
59
|
-
"@takeshape/
|
|
60
|
-
"@takeshape/
|
|
61
|
-
"@takeshape/
|
|
59
|
+
"@takeshape/errors": "11.142.5",
|
|
60
|
+
"@takeshape/json-schema": "11.142.5",
|
|
61
|
+
"@takeshape/util": "11.142.5"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@takeshape/json-schema-to-typescript": "11.0.0",
|
|
@@ -75,12 +75,16 @@
|
|
|
75
75
|
"glob": "7.2.3",
|
|
76
76
|
"json-schema-to-ts": "3.1.1",
|
|
77
77
|
"shortid": "2.2.16",
|
|
78
|
-
"@takeshape/
|
|
79
|
-
"@takeshape/
|
|
78
|
+
"@takeshape/logger": "11.142.5",
|
|
79
|
+
"@takeshape/infra": "11.142.5"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=22"
|
|
83
83
|
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public",
|
|
86
|
+
"provenance": false
|
|
87
|
+
},
|
|
84
88
|
"scripts": {
|
|
85
89
|
"build": "tsc --project tsconfig.build.json",
|
|
86
90
|
"postbuild": "find './src/schemas/project-schema/' -maxdepth 1 -name '*.json' -exec rsync --quiet '{}' dist/schemas/project-schema/ \\; && find './src/schemas/' -maxdepth 1 -name '*.json' -exec rsync --quiet '{}' dist/schemas/ \\;",
|