@tsed/schema 6.102.8 → 6.103.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/lib/cjs/utils/getJsonSchema.js +11 -1
- package/lib/cjs/utils/getJsonSchema.js.map +1 -1
- package/lib/esm/utils/getJsonSchema.js +11 -1
- package/lib/esm/utils/getJsonSchema.js.map +1 -1
- package/lib/types/utils/getJsonSchema.d.ts +11 -1
- package/package.json +5 -5
- package/benchmark/cold-start.js +0 -17
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getJsonSchema = void 0;
|
|
4
|
-
require("@tsed/schema");
|
|
5
4
|
const SpecTypes_1 = require("../domain/SpecTypes");
|
|
6
5
|
const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperContainer");
|
|
7
6
|
const getJsonEntityStore_1 = require("./getJsonEntityStore");
|
|
7
|
+
require("../components/anyMapper");
|
|
8
|
+
require("../components/classMapper");
|
|
9
|
+
require("../components/genericsMapper");
|
|
10
|
+
require("../components/inheritedClassMapper");
|
|
11
|
+
require("../components/itemMapper");
|
|
12
|
+
require("../components/lazyRefMapper");
|
|
13
|
+
require("../components/mapMapper");
|
|
14
|
+
require("../components/objectMapper");
|
|
15
|
+
require("../components/ofMapper");
|
|
16
|
+
require("../components/propertiesMapper");
|
|
17
|
+
require("../components/schemaMapper");
|
|
8
18
|
/**
|
|
9
19
|
* @ignore
|
|
10
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/utils/getJsonSchema.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/utils/getJsonSchema.ts"],"names":[],"mappings":";;;AAEA,mDAA8C;AAE9C,uFAAmE;AACnE,6DAAwD;AACxD,mCAAiC;AACjC,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OAAO,CAAC,QAAQ,IAAI,qBAAS,CAAC,IAAI;QAC5C,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,IAAI,MAAM,CAAC,aAAa,KAAK,WAAW,EAAE;QACxC,OAAO,GAAG;YACR,GAAG,OAAO;YACV,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;YACtC,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,MAAM,EAAE,MAAA,MAAM,CAAC,SAAS,0CAAE,MAAM;SACjC,CAAC;KACH;IAED,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC;AArBD,sCAqBC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport type {JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\nimport \"../components/anyMapper\";\nimport \"../components/classMapper\";\nimport \"../components/genericsMapper\";\nimport \"../components/inheritedClassMapper\";\nimport \"../components/itemMapper\";\nimport \"../components/lazyRefMapper\";\nimport \"../components/mapMapper\";\nimport \"../components/objectMapper\";\nimport \"../components/ofMapper\";\nimport \"../components/propertiesMapper\";\nimport \"../components/schemaMapper\";\n\n/**\n * @ignore\n */\nconst CACHE_KEY = \"$cache:schemes\";\n\n/**\n * @ignore\n */\nfunction getKey(options: any) {\n return JSON.stringify(options);\n}\n\n/**\n * @ignore\n */\nfunction get(entity: JsonEntityStore, options: any) {\n const cache: Map<string, any> = entity.store.get(CACHE_KEY) || new Map();\n const key = getKey(options);\n\n if (!cache.has(key)) {\n const schema = execMapper(\"schema\", entity.schema, options);\n\n if (Object.keys(options.schemas).length) {\n schema.definitions = options.schemas;\n }\n\n cache.set(key, schema);\n }\n\n entity.store.set(CACHE_KEY, cache);\n\n return cache.get(key);\n}\n\nexport function getJsonSchema(model: Type<any> | any, options: JsonSchemaOptions = {}) {\n const entity = getJsonEntityStore(model);\n\n options = {\n endpoint: true,\n groups: [],\n ...options,\n specType: options.specType || SpecTypes.JSON,\n schemas: {}\n };\n\n if (entity.decoratorType === \"parameter\") {\n options = {\n ...options,\n genericTypes: entity.nestedGenerics[0],\n nestedGenerics: entity.nestedGenerics,\n groups: entity.parameter?.groups\n };\n }\n\n return get(entity, options);\n}\n"]}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import "@tsed/schema";
|
|
2
1
|
import { SpecTypes } from "../domain/SpecTypes.js";
|
|
3
2
|
import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
4
3
|
import { getJsonEntityStore } from "./getJsonEntityStore.js";
|
|
4
|
+
import "../components/anyMapper.js";
|
|
5
|
+
import "../components/classMapper.js";
|
|
6
|
+
import "../components/genericsMapper.js";
|
|
7
|
+
import "../components/inheritedClassMapper.js";
|
|
8
|
+
import "../components/itemMapper.js";
|
|
9
|
+
import "../components/lazyRefMapper.js";
|
|
10
|
+
import "../components/mapMapper.js";
|
|
11
|
+
import "../components/objectMapper.js";
|
|
12
|
+
import "../components/ofMapper.js";
|
|
13
|
+
import "../components/propertiesMapper.js";
|
|
14
|
+
import "../components/schemaMapper.js";
|
|
5
15
|
/**
|
|
6
16
|
* @ignore
|
|
7
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/utils/getJsonSchema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/utils/getJsonSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,yBAAyB,CAAC;AACjC,O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AC,CAAC;IAEzC,OAAO,GAAG;QACR,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE;QACV,GAAG,OAAO;QACV,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI;QAC5C,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,IAAI,MAAM,CAAC,aAAa,KAAK,WAAW,EAAE;QACxC,OAAO,GAAG;YACR,GAAG,OAAO;YACV,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;YACtC,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,MAAM,EAAE,MAAA,MAAM,CAAC,SAAS,0CAAE,MAAM;SACjC,CAAC;KACH;IAED,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport type {JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\nimport \"../components/anyMapper\";\nimport \"../components/classMapper\";\nimport \"../components/genericsMapper\";\nimport \"../components/inheritedClassMapper\";\nimport \"../components/itemMapper\";\nimport \"../components/lazyRefMapper\";\nimport \"../components/mapMapper\";\nimport \"../components/objectMapper\";\nimport \"../components/ofMapper\";\nimport \"../components/propertiesMapper\";\nimport \"../components/schemaMapper\";\n\n/**\n * @ignore\n */\nconst CACHE_KEY = \"$cache:schemes\";\n\n/**\n * @ignore\n */\nfunction getKey(options: any) {\n return JSON.stringify(options);\n}\n\n/**\n * @ignore\n */\nfunction get(entity: JsonEntityStore, options: any) {\n const cache: Map<string, any> = entity.store.get(CACHE_KEY) || new Map();\n const key = getKey(options);\n\n if (!cache.has(key)) {\n const schema = execMapper(\"schema\", entity.schema, options);\n\n if (Object.keys(options.schemas).length) {\n schema.definitions = options.schemas;\n }\n\n cache.set(key, schema);\n }\n\n entity.store.set(CACHE_KEY, cache);\n\n return cache.get(key);\n}\n\nexport function getJsonSchema(model: Type<any> | any, options: JsonSchemaOptions = {}) {\n const entity = getJsonEntityStore(model);\n\n options = {\n endpoint: true,\n groups: [],\n ...options,\n specType: options.specType || SpecTypes.JSON,\n schemas: {}\n };\n\n if (entity.decoratorType === \"parameter\") {\n options = {\n ...options,\n genericTypes: entity.nestedGenerics[0],\n nestedGenerics: entity.nestedGenerics,\n groups: entity.parameter?.groups\n };\n }\n\n return get(entity, options);\n}\n"]}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import "@tsed/schema";
|
|
3
2
|
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
3
|
+
import "../components/anyMapper";
|
|
4
|
+
import "../components/classMapper";
|
|
5
|
+
import "../components/genericsMapper";
|
|
6
|
+
import "../components/inheritedClassMapper";
|
|
7
|
+
import "../components/itemMapper";
|
|
8
|
+
import "../components/lazyRefMapper";
|
|
9
|
+
import "../components/mapMapper";
|
|
10
|
+
import "../components/objectMapper";
|
|
11
|
+
import "../components/ofMapper";
|
|
12
|
+
import "../components/propertiesMapper";
|
|
13
|
+
import "../components/schemaMapper";
|
|
4
14
|
export declare function getJsonSchema(model: Type<any> | any, options?: JsonSchemaOptions): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/schema",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.103.0",
|
|
4
4
|
"description": "JsonSchema module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"tsed"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tsed/openspec": "6.
|
|
35
|
+
"@tsed/openspec": "6.103.0",
|
|
36
36
|
"camel-case": "4.1.2",
|
|
37
37
|
"json-schema": "0.4.0",
|
|
38
38
|
"micromatch": "4.0.4",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@apidevtools/swagger-parser": "10.0.2",
|
|
45
|
-
"@tsed/core": "6.
|
|
46
|
-
"@tsed/openspec": "6.
|
|
45
|
+
"@tsed/core": "6.103.0",
|
|
46
|
+
"@tsed/openspec": "6.103.0",
|
|
47
47
|
"@types/fs-extra": "9.0.6",
|
|
48
48
|
"@types/json-schema": "7.0.7",
|
|
49
49
|
"@types/micromatch": "4.0.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"fs-extra": "9.0.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@tsed/core": "^6.
|
|
54
|
+
"@tsed/core": "^6.103.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"@tsed/code": {
|
package/benchmark/cold-start.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
function printMemory(event) {
|
|
2
|
-
const used = process.memoryUsage();
|
|
3
|
-
const obj = {event};
|
|
4
|
-
|
|
5
|
-
for (let key in used) {
|
|
6
|
-
// console.log(`${key} ${} MB`);
|
|
7
|
-
obj[key] = Math.round((used[key] / 1024 / 1024) * 100) / 100;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
obj.timestamp = Date.now();
|
|
11
|
-
|
|
12
|
-
console.log(JSON.stringify(obj));
|
|
13
|
-
}
|
|
14
|
-
console.time("benchmark");
|
|
15
|
-
require("@tsed/schema");
|
|
16
|
-
console.timeEnd("benchmark");
|
|
17
|
-
printMemory();
|