@tsed/schema 6.96.2 → 6.98.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.
Files changed (81) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/components/objectMapper.js +6 -3
  3. package/lib/cjs/components/objectMapper.js.map +1 -1
  4. package/lib/cjs/components/schemaMapper.js +1 -1
  5. package/lib/cjs/components/schemaMapper.js.map +1 -1
  6. package/lib/cjs/decorators/index.js +2 -0
  7. package/lib/cjs/decorators/index.js.map +1 -1
  8. package/lib/cjs/decorators/operations/acceptMime.js +28 -0
  9. package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
  10. package/lib/cjs/decorators/operations/view.js +31 -0
  11. package/lib/cjs/decorators/operations/view.js.map +1 -0
  12. package/lib/cjs/domain/JsonMethodStore.js +37 -1
  13. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  14. package/lib/cjs/domain/JsonOperation.js +5 -9
  15. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  16. package/lib/cjs/domain/JsonOperationRoute.js +7 -0
  17. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  18. package/lib/cjs/domain/JsonParameterStore.js +13 -4
  19. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  20. package/lib/cjs/domain/JsonPropertyStore.js +5 -1
  21. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  22. package/lib/cjs/domain/JsonSchema.js +78 -60
  23. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  24. package/lib/cjs/domain/SpecTypes.js +3 -0
  25. package/lib/cjs/domain/SpecTypes.js.map +1 -1
  26. package/lib/cjs/utils/getOperationsRoutes.js.map +1 -1
  27. package/lib/cjs/utils/getSpec.js +3 -3
  28. package/lib/cjs/utils/getSpec.js.map +1 -1
  29. package/lib/cjs/utils/mapNullableType.js +30 -11
  30. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  31. package/lib/cjs/utils/ref.js +13 -10
  32. package/lib/cjs/utils/ref.js.map +1 -1
  33. package/lib/esm/components/objectMapper.js +6 -3
  34. package/lib/esm/components/objectMapper.js.map +1 -1
  35. package/lib/esm/components/schemaMapper.js +1 -1
  36. package/lib/esm/components/schemaMapper.js.map +1 -1
  37. package/lib/esm/decorators/index.js +2 -0
  38. package/lib/esm/decorators/index.js.map +1 -1
  39. package/lib/esm/decorators/operations/acceptMime.js +24 -0
  40. package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
  41. package/lib/esm/decorators/operations/view.js +27 -0
  42. package/lib/esm/decorators/operations/view.js.map +1 -0
  43. package/lib/esm/domain/JsonMethodStore.js +37 -1
  44. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  45. package/lib/esm/domain/JsonOperation.js +5 -9
  46. package/lib/esm/domain/JsonOperation.js.map +1 -1
  47. package/lib/esm/domain/JsonOperationRoute.js +7 -0
  48. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  49. package/lib/esm/domain/JsonParameterStore.js +13 -4
  50. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  51. package/lib/esm/domain/JsonPropertyStore.js +4 -0
  52. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  53. package/lib/esm/domain/JsonSchema.js +78 -60
  54. package/lib/esm/domain/JsonSchema.js.map +1 -1
  55. package/lib/esm/domain/SpecTypes.js +3 -0
  56. package/lib/esm/domain/SpecTypes.js.map +1 -1
  57. package/lib/esm/utils/getOperationsRoutes.js.map +1 -1
  58. package/lib/esm/utils/getSpec.js +3 -3
  59. package/lib/esm/utils/getSpec.js.map +1 -1
  60. package/lib/esm/utils/mapNullableType.js +31 -12
  61. package/lib/esm/utils/mapNullableType.js.map +1 -1
  62. package/lib/esm/utils/ref.js +13 -10
  63. package/lib/esm/utils/ref.js.map +1 -1
  64. package/lib/types/decorators/index.d.ts +2 -0
  65. package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
  66. package/lib/types/decorators/operations/view.d.ts +23 -0
  67. package/lib/types/domain/JsonMethodStore.d.ts +48 -0
  68. package/lib/types/domain/JsonOperationRoute.d.ts +5 -3
  69. package/lib/types/domain/JsonParameterStore.d.ts +23 -1
  70. package/lib/types/domain/JsonPropertyStore.d.ts +7 -0
  71. package/lib/types/domain/JsonSchema.d.ts +5 -11
  72. package/lib/types/domain/SpecTypes.d.ts +3 -0
  73. package/lib/types/utils/getOperationsRoutes.d.ts +2 -2
  74. package/package.json +6 -6
  75. package/.mocharc.js +0 -5
  76. package/.nycrc +0 -27
  77. package/lib/cjs/utils/isJsonClass.js +0 -12
  78. package/lib/cjs/utils/isJsonClass.js.map +0 -1
  79. package/lib/esm/utils/isJsonClass.js +0 -8
  80. package/lib/esm/utils/isJsonClass.js.map +0 -1
  81. package/lib/types/utils/isJsonClass.d.ts +0 -4
@@ -1,14 +1,30 @@
1
1
  import { Type } from "@tsed/core";
2
- import { JsonEntityStore } from "./JsonEntityStore";
2
+ import { JsonEntityStore, JsonEntityStoreOptions } from "./JsonEntityStore";
3
3
  import type { JsonMethodStore } from "./JsonMethodStore";
4
4
  import { JsonParameter } from "./JsonParameter";
5
5
  import { JsonSchema } from "./JsonSchema";
6
+ export interface JsonParameterStoreOptions extends JsonEntityStoreOptions {
7
+ dataPath?: string;
8
+ paramType?: string;
9
+ expression?: string;
10
+ }
11
+ export interface PipeMethods<T = any, R = any> {
12
+ transform(value: T, metadata: JsonParameterStore): R;
13
+ }
6
14
  export declare class JsonParameterStore extends JsonEntityStore {
15
+ paramType: string;
16
+ expression: string;
17
+ dataPath: string;
18
+ /**
19
+ * Define pipes can be called by the framework to transform input parameter
20
+ */
21
+ pipes: Type<PipeMethods>[];
7
22
  /**
8
23
  * Ref to JsonParameter when the decorated object is a parameter.
9
24
  */
10
25
  readonly parameter: JsonParameter;
11
26
  readonly parent: JsonMethodStore;
27
+ constructor(options: JsonParameterStoreOptions);
12
28
  get nestedGenerics(): Type<any>[][];
13
29
  set nestedGenerics(nestedGenerics: Type<any>[][]);
14
30
  /**
@@ -19,6 +35,7 @@ export declare class JsonParameterStore extends JsonEntityStore {
19
35
  set required(value: boolean);
20
36
  get allowedRequiredValues(): any[];
21
37
  static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[];
38
+ static get(target: Type<any>, propertyKey: string | symbol, index: number): JsonParameterStore;
22
39
  /**
23
40
  * Check precondition between value, required and allowedRequiredValues to know if the entity is required.
24
41
  * @param value
@@ -28,3 +45,8 @@ export declare class JsonParameterStore extends JsonEntityStore {
28
45
  protected getSchema(type: any): JsonSchema;
29
46
  protected build(): void;
30
47
  }
48
+ /**
49
+ * @alias JsonParameterStore
50
+ */
51
+ export declare type ParamMetadata = JsonParameterStore;
52
+ export declare const ParamMetadata: typeof JsonParameterStore;
@@ -1,3 +1,4 @@
1
+ import { Type } from "@tsed/core";
1
2
  import { JsonEntityStore } from "./JsonEntityStore";
2
3
  import type { JsonClassStore } from "./JsonClassStore";
3
4
  export declare class JsonPropertyStore extends JsonEntityStore {
@@ -20,4 +21,10 @@ export declare class JsonPropertyStore extends JsonEntityStore {
20
21
  */
21
22
  isRequired(value: any): boolean;
22
23
  protected build(): void;
24
+ static get(target: Type<any>, propertyKey: string | symbol): JsonPropertyStore;
23
25
  }
26
+ /**
27
+ * @alias JsonPropertyStore
28
+ */
29
+ export declare type PropertyMetadata = JsonPropertyStore;
30
+ export declare const PropertyMetadata: typeof JsonPropertyStore;
@@ -14,29 +14,19 @@ export interface JsonSchemaObject extends JSONSchema6, Record<string, any> {
14
14
  }
15
15
  export declare type AnyJsonSchema = Partial<JsonSchemaObject> | JsonSchema | JsonLazyRef | any;
16
16
  export declare class JsonSchema extends Map<string, any> implements NestedGenerics {
17
+ #private;
17
18
  readonly isJsonSchema = true;
18
19
  readonly $hooks: Hooks;
19
20
  readonly $required: Set<string>;
20
21
  readonly $allow: any[];
21
22
  $selfRequired: boolean;
22
23
  $forwardGroups: boolean;
23
- protected _nullable: boolean;
24
- protected _genericLabels: string[];
25
- protected _nestedGenerics: Type<any>[][];
26
- protected _alias: AliasMap;
27
- protected _itemSchema: JsonSchema;
28
- protected _target: Type<any>;
29
- protected _isGeneric: boolean;
30
- protected _isCollection: boolean;
31
- protected _ref: boolean;
32
24
  constructor(obj?: JsonSchema | Partial<JsonSchemaObject>);
33
25
  get alias(): AliasMap;
34
26
  get nestedGenerics(): any[];
35
27
  set nestedGenerics(value: any[]);
36
28
  get genericLabels(): string[];
37
29
  set genericLabels(value: string[]);
38
- get nullable(): boolean;
39
- set nullable(value: boolean);
40
30
  get isClass(): boolean;
41
31
  /**
42
32
  * Current schema is a collection
@@ -53,7 +43,11 @@ export declare class JsonSchema extends Map<string, any> implements NestedGeneri
53
43
  get genericType(): string;
54
44
  get class(): any;
55
45
  get canRef(): boolean;
46
+ get isNullable(): boolean;
47
+ get isReadOnly(): any;
48
+ get isWriteOnly(): any;
56
49
  static from(obj?: Partial<JsonSchemaObject>): JsonSchema;
50
+ nullable(value: boolean): void;
57
51
  itemSchema(obj?: AnyJsonSchema): JsonSchema;
58
52
  getAliasOf(property: AliasType): AliasType | undefined;
59
53
  addAlias(property: AliasType, alias: AliasType): this;
@@ -1,5 +1,8 @@
1
1
  export declare enum SpecTypes {
2
2
  JSON = "jsonschema",
3
+ /**
4
+ * @deprecated
5
+ */
3
6
  SWAGGER = "swagger2",
4
7
  OPENAPI = "openapi3"
5
8
  }
@@ -1,8 +1,8 @@
1
1
  import { Type } from "@tsed/core";
2
+ import { JsonMethodStore } from "../domain/JsonMethodStore";
2
3
  import { JsonOperationRoute } from "../domain/JsonOperationRoute";
3
- import { JsonEntityStore } from "../domain/JsonEntityStore";
4
4
  export interface GetOperationsRoutesOptions {
5
5
  withChildren?: boolean;
6
6
  basePath?: string;
7
7
  }
8
- export declare function getOperationsRoutes<Entity extends JsonEntityStore = JsonEntityStore>(token: Type<any> | any, options?: GetOperationsRoutesOptions): JsonOperationRoute<Entity>[];
8
+ export declare function getOperationsRoutes<Entity extends JsonMethodStore = JsonMethodStore>(token: Type<any> | any, options?: GetOperationsRoutesOptions): JsonOperationRoute<Entity>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/schema",
3
- "version": "6.96.2",
3
+ "version": "6.98.0",
4
4
  "description": "JsonSchema module for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -16,7 +16,7 @@
16
16
  "build": "yarn run build:esm && yarn run build:cjs",
17
17
  "build:cjs": "tsc --build tsconfig.compile.json",
18
18
  "build:esm": "tsc --build tsconfig.compile.esm.json",
19
- "test": "cross-env NODE_ENV=test nyc mocha"
19
+ "test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
20
20
  },
21
21
  "keywords": [
22
22
  "TypeScript",
@@ -29,8 +29,8 @@
29
29
  "tsed"
30
30
  ],
31
31
  "dependencies": {
32
- "@tsed/core": "6.96.2",
33
- "@tsed/openspec": "6.96.2",
32
+ "@tsed/core": "6.98.0",
33
+ "@tsed/openspec": "6.98.0",
34
34
  "camel-case": "4.1.2",
35
35
  "json-schema": "0.4.0",
36
36
  "micromatch": "4.0.2",
@@ -45,8 +45,8 @@
45
45
  "fs-extra": "9.0.1"
46
46
  },
47
47
  "peerDependencies": {
48
- "@tsed/core": "^6.96.2",
49
- "@tsed/openspec": "^6.96.2"
48
+ "@tsed/core": "^6.98.0",
49
+ "@tsed/openspec": "^6.98.0"
50
50
  },
51
51
  "repository": "https://github.com/tsedio/tsed",
52
52
  "bugs": {
package/.mocharc.js DELETED
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- ...require('@tsed/mocha-config')(),
3
- spec: ["{src,test}/**/*.spec.ts"],
4
- exclude: [],
5
- };
package/.nycrc DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "include": [
3
- "src/**/*.ts"
4
- ],
5
- "exclude": [
6
- "**/*.d.ts",
7
- "node_modules",
8
- "**/interfaces/**",
9
- "**/index.ts",
10
- "**/*.spec.ts"
11
- ],
12
- "extension": [
13
- ".ts"
14
- ],
15
- "require": [],
16
- "reporter": [
17
- "text-summary",
18
- "html",
19
- "lcov",
20
- "json"
21
- ],
22
- "check-coverage": true,
23
- "statements": 99.67,
24
- "branches": 91.32,
25
- "functions": 99.51,
26
- "lines": 99.81
27
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isJsonClass = void 0;
4
- const core_1 = require("@tsed/core");
5
- /**
6
- * @ignore
7
- */
8
- function isJsonClass(type) {
9
- return (0, core_1.isClass)(type) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this._target);
10
- }
11
- exports.isJsonClass = isJsonClass;
12
- //# sourceMappingURL=isJsonClass.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isJsonClass.js","sourceRoot":"","sources":["../../../src/utils/isJsonClass.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC;;GAEG;AACH,SAAgB,WAAW,CAAC,IAAS;IACnC,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAc,CAAC,CAAC;AAClH,CAAC;AAFD,kCAEC","sourcesContent":["import {isClass} from \"@tsed/core\";\n\n/**\n * @ignore\n */\nexport function isJsonClass(type: any) {\n return isClass(type) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this._target as any);\n}\n"]}
@@ -1,8 +0,0 @@
1
- import { isClass } from "@tsed/core";
2
- /**
3
- * @ignore
4
- */
5
- export function isJsonClass(type) {
6
- return isClass(type) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this._target);
7
- }
8
- //# sourceMappingURL=isJsonClass.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isJsonClass.js","sourceRoot":"","sources":["../../../src/utils/isJsonClass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,IAAS;IACnC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAc,CAAC,CAAC;AAClH,CAAC","sourcesContent":["import {isClass} from \"@tsed/core\";\n\n/**\n * @ignore\n */\nexport function isJsonClass(type: any) {\n return isClass(type) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this._target as any);\n}\n"]}
@@ -1,4 +0,0 @@
1
- /**
2
- * @ignore
3
- */
4
- export declare function isJsonClass(type: any): boolean;