@tsed/schema 6.90.0 → 6.93.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/.mocharc.js +5 -0
- package/.nycrc +27 -0
- package/lib/cjs/components/anyMapper.js +0 -1
- package/lib/cjs/components/anyMapper.js.map +1 -1
- package/lib/cjs/components/classMapper.d.ts +1 -1
- package/lib/cjs/components/classMapper.js +1 -1
- package/lib/cjs/components/classMapper.js.map +1 -1
- package/lib/cjs/components/index.d.ts +2 -0
- package/lib/cjs/components/index.js +2 -0
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/inheritedClassMapper.d.ts +1 -1
- package/lib/cjs/components/inheritedClassMapper.js +1 -1
- package/lib/cjs/components/inheritedClassMapper.js.map +1 -1
- package/lib/cjs/components/mapMapper.d.ts +1 -1
- package/lib/cjs/components/mapMapper.js +1 -1
- package/lib/cjs/components/mapMapper.js.map +1 -1
- package/lib/cjs/components/objectMapper.js +4 -1
- package/lib/cjs/components/objectMapper.js.map +1 -1
- package/lib/cjs/components/ofMapper.d.ts +3 -0
- package/lib/cjs/components/ofMapper.js +17 -0
- package/lib/cjs/components/ofMapper.js.map +1 -0
- package/lib/cjs/components/propertiesMapper.d.ts +3 -0
- package/lib/cjs/components/propertiesMapper.js +25 -0
- package/lib/cjs/components/propertiesMapper.js.map +1 -0
- package/lib/cjs/components/schemaMapper.d.ts +1 -1
- package/lib/cjs/components/schemaMapper.js +29 -31
- package/lib/cjs/components/schemaMapper.js.map +1 -1
- package/lib/cjs/decorators/common/requiredGroups.d.ts +1 -1
- package/lib/cjs/decorators/common/requiredGroups.js +6 -9
- package/lib/cjs/decorators/common/requiredGroups.js.map +1 -1
- package/lib/cjs/decorators/index.d.ts +1 -0
- package/lib/cjs/decorators/index.js +1 -0
- package/lib/cjs/decorators/index.js.map +1 -1
- package/lib/cjs/decorators/operations/inFile.d.ts +25 -0
- package/lib/cjs/decorators/operations/inFile.js +45 -0
- package/lib/cjs/decorators/operations/inFile.js.map +1 -0
- package/lib/cjs/decorators/operations/route.d.ts +3 -0
- package/lib/cjs/decorators/operations/route.js +10 -8
- package/lib/cjs/decorators/operations/route.js.map +1 -1
- package/lib/cjs/domain/JsonEntityStore.d.ts +3 -0
- package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
- package/lib/cjs/domain/JsonMethodStore.d.ts +22 -1
- package/lib/cjs/domain/JsonMethodStore.js +42 -5
- package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
- package/lib/cjs/registries/JsonSchemaMapperContainer.d.ts +3 -2
- package/lib/cjs/registries/JsonSchemaMapperContainer.js +7 -3
- package/lib/cjs/registries/JsonSchemaMapperContainer.js.map +1 -1
- package/lib/cjs/utils/getJsonEntityStore.d.ts +0 -4
- package/lib/cjs/utils/getJsonEntityStore.js +1 -8
- package/lib/cjs/utils/getJsonEntityStore.js.map +1 -1
- package/lib/cjs/utils/getRequiredProperties.js +1 -2
- package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
- package/lib/cjs/utils/mapRouteOptions.d.ts +1 -1
- package/lib/cjs/utils/mapRouteOptions.js +1 -1
- package/lib/cjs/utils/mapRouteOptions.js.map +1 -1
- package/lib/esm/components/anyMapper.js +0 -1
- package/lib/esm/components/anyMapper.js.map +1 -1
- package/lib/esm/components/classMapper.js +1 -1
- package/lib/esm/components/classMapper.js.map +1 -1
- package/lib/esm/components/index.js +2 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/inheritedClassMapper.js +1 -1
- package/lib/esm/components/inheritedClassMapper.js.map +1 -1
- package/lib/esm/components/mapMapper.js +1 -1
- package/lib/esm/components/mapMapper.js.map +1 -1
- package/lib/esm/components/objectMapper.js +4 -1
- package/lib/esm/components/objectMapper.js.map +1 -1
- package/lib/esm/components/ofMapper.js +13 -0
- package/lib/esm/components/ofMapper.js.map +1 -0
- package/lib/esm/components/propertiesMapper.js +21 -0
- package/lib/esm/components/propertiesMapper.js.map +1 -0
- package/lib/esm/components/schemaMapper.js +30 -32
- package/lib/esm/components/schemaMapper.js.map +1 -1
- package/lib/esm/decorators/common/requiredGroups.js +6 -9
- package/lib/esm/decorators/common/requiredGroups.js.map +1 -1
- package/lib/esm/decorators/index.js +1 -0
- package/lib/esm/decorators/index.js.map +1 -1
- package/lib/esm/decorators/operations/inFile.js +41 -0
- package/lib/esm/decorators/operations/inFile.js.map +1 -0
- package/lib/esm/decorators/operations/route.js +10 -8
- package/lib/esm/decorators/operations/route.js.map +1 -1
- package/lib/esm/domain/JsonEntityStore.js.map +1 -1
- package/lib/esm/domain/JsonMethodStore.js +44 -7
- package/lib/esm/domain/JsonMethodStore.js.map +1 -1
- package/lib/esm/registries/JsonSchemaMapperContainer.js +5 -2
- package/lib/esm/registries/JsonSchemaMapperContainer.js.map +1 -1
- package/lib/esm/utils/getJsonEntityStore.js +0 -6
- package/lib/esm/utils/getJsonEntityStore.js.map +1 -1
- package/lib/esm/utils/getRequiredProperties.js +1 -2
- package/lib/esm/utils/getRequiredProperties.js.map +1 -1
- package/lib/esm/utils/mapRouteOptions.js +1 -1
- package/lib/esm/utils/mapRouteOptions.js.map +1 -1
- package/lib/types/components/classMapper.d.ts +1 -1
- package/lib/types/components/index.d.ts +2 -0
- package/lib/types/components/inheritedClassMapper.d.ts +1 -1
- package/lib/types/components/mapMapper.d.ts +1 -1
- package/lib/types/components/ofMapper.d.ts +3 -0
- package/lib/types/components/propertiesMapper.d.ts +3 -0
- package/lib/types/components/schemaMapper.d.ts +1 -1
- package/lib/types/decorators/common/requiredGroups.d.ts +1 -1
- package/lib/types/decorators/index.d.ts +1 -0
- package/lib/types/decorators/operations/inFile.d.ts +25 -0
- package/lib/types/decorators/operations/route.d.ts +3 -0
- package/lib/types/domain/JsonEntityStore.d.ts +3 -0
- package/lib/types/domain/JsonMethodStore.d.ts +22 -1
- package/lib/types/registries/JsonSchemaMapperContainer.d.ts +3 -2
- package/lib/types/utils/getJsonEntityStore.d.ts +0 -4
- package/lib/types/utils/mapRouteOptions.d.ts +1 -1
- package/package.json +7 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonSchemaMapperContainer.js","sourceRoot":"","sources":["../../../src/registries/JsonSchemaMapperContainer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"JsonSchemaMapperContainer.js","sourceRoot":"","sources":["../../../src/registries/JsonSchemaMapperContainer.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,0BAA0B,GAAkC,IAAI,GAAG,EAAE,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY,EAAE,MAAwB;IAC7E,OAAO,0BAA0B,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,uBAAuB;IACvB,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,wBAAwB,CAAC,CAAC;KAC7D;IACD,OAAO,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,MAAW,EAAE,OAAY,EAAE,MAAY;IAC9E,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * @ignore\n */\nexport interface JsonSchemaMapper {\n (schema: any, options: any, parent?: any): any;\n}\n\n/**\n * @ignore\n */\nconst JsonSchemaMappersContainer: Map<string, JsonSchemaMapper> = new Map();\n\n/**\n * @ignore\n */\nexport function registerJsonSchemaMapper(type: string, mapper: JsonSchemaMapper) {\n return JsonSchemaMappersContainer.set(type, mapper);\n}\n\n/**\n * @ignore\n */\nexport function getJsonSchemaMapper(type: string): JsonSchemaMapper {\n // istanbul ignore next\n if (!JsonSchemaMappersContainer.has(type)) {\n throw new Error(`JsonSchema ${type} mapper doesn't exists`);\n }\n return JsonSchemaMappersContainer.get(type)!;\n}\n\n/**\n * @ignore\n */\nexport function execMapper(type: string, schema: any, options: any, parent?: any): any {\n return getJsonSchemaMapper(type)(schema, options, parent);\n}\n\nexport function hasMapper(type: string) {\n return JsonSchemaMappersContainer.has(type);\n}\n"]}
|
|
@@ -8,12 +8,6 @@ JsonEntitiesContainer.set(DecoratorTypes.CLASS, JsonClassStore);
|
|
|
8
8
|
JsonEntitiesContainer.set(DecoratorTypes.PROP, JsonPropertyStore);
|
|
9
9
|
JsonEntitiesContainer.set(DecoratorTypes.PARAM, JsonParameterStore);
|
|
10
10
|
JsonEntitiesContainer.set(DecoratorTypes.METHOD, JsonMethodStore);
|
|
11
|
-
/**
|
|
12
|
-
* @ignore
|
|
13
|
-
*/
|
|
14
|
-
export function isJsonEntityStore(model) {
|
|
15
|
-
return model.isStore;
|
|
16
|
-
}
|
|
17
11
|
export function getJsonEntityStore(...args) {
|
|
18
12
|
return JsonEntityStore.from(...args);
|
|
19
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getJsonEntityStore.js","sourceRoot":"","sources":["../../../src/utils/getJsonEntityStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAO,MAAM,YAAY,CAAC;AAChD,OAAO,EAAC,qBAAqB,EAAE,eAAe,EAAC,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAE1D,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAChE,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;AAClE,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AACpE,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"getJsonEntityStore.js","sourceRoot":"","sources":["../../../src/utils/getJsonEntityStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAO,MAAM,YAAY,CAAC;AAChD,OAAO,EAAC,qBAAqB,EAAE,eAAe,EAAC,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAE1D,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAChE,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;AAClE,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AACpE,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAsBlE,MAAM,UAAU,kBAAkB,CAA8C,GAAG,IAAW;IAC5F,OAAO,eAAe,CAAC,IAAI,CAAI,GAAG,IAAI,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {DecoratorTypes, Type} from \"@tsed/core\";\nimport {JsonEntitiesContainer, JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {JsonClassStore} from \"../domain/JsonClassStore\";\nimport {JsonPropertyStore} from \"../domain/JsonPropertyStore\";\nimport {JsonParameterStore} from \"../domain/JsonParameterStore\";\nimport {JsonMethodStore} from \"../domain/JsonMethodStore\";\n\nJsonEntitiesContainer.set(DecoratorTypes.CLASS, JsonClassStore);\nJsonEntitiesContainer.set(DecoratorTypes.PROP, JsonPropertyStore);\nJsonEntitiesContainer.set(DecoratorTypes.PARAM, JsonParameterStore);\nJsonEntitiesContainer.set(DecoratorTypes.METHOD, JsonMethodStore);\n\n/**\n * Get entity store from decorator args\n * @param target\n */\nexport function getJsonEntityStore<T extends JsonClassStore = JsonClassStore>(target: Type<any>): T;\nexport function getJsonEntityStore<T extends JsonPropertyStore = JsonPropertyStore>(\n target: Type<any> | any,\n propertyKey: string | symbol\n): T;\nexport function getJsonEntityStore<T extends JsonParameterStore = JsonParameterStore>(\n target: Type<any> | any,\n propertyKey: string | symbol,\n index: number\n): T;\nexport function getJsonEntityStore<T extends JsonMethodStore = JsonMethodStore>(\n target: Type<any> | any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor\n): T;\nexport function getJsonEntityStore<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T;\nexport function getJsonEntityStore<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T {\n return JsonEntityStore.from<T>(...args);\n}\n"]}
|
|
@@ -23,8 +23,7 @@ function mapRequiredProps(obj, schema, options = {}) {
|
|
|
23
23
|
if (props.includes(aliasedKey)) {
|
|
24
24
|
const propSchema = schema.get("properties")[key];
|
|
25
25
|
const serializeSchema = obj.properties[aliasedKey];
|
|
26
|
-
obj.properties[aliasedKey] = applyStringRule(serializeSchema, propSchema);
|
|
27
|
-
// obj.properties[aliasedKey] = mapNullableType(obj.properties[aliasedKey]);
|
|
26
|
+
obj.properties[aliasedKey] = applyStringRule(serializeSchema, propSchema);
|
|
28
27
|
return keys.concat(aliasedKey);
|
|
29
28
|
}
|
|
30
29
|
return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AAC;QAClB,CAAC,EAAE,QAAQ,CAAC,CAAC;KACd;IAED,OAAO,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAQ,EAAE,MAAkB,EAAE,OAA0B;IAC5F,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACxD,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,QAAQ,GAAG,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE1D,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAE7E,IAAI,QAAQ,CAAC,MAAM,EAAE;QACnB,OAAO;YACL,GAAG,GAAG;YACN,QAAQ;SACT,CAAC;KACH;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterRequiredGroups} from \"../hooks/alterRequiredGroups\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nfunction applyStringRule(obj: any, propSchema: JsonSchema) {\n if (!propSchema?.$allow.includes(\"\")) {\n if (([] as string[]).concat(propSchema?.get(\"type\")).includes(\"string\")) {\n const minLength = obj?.minLength;\n // Disallow empty string\n if (minLength === undefined) {\n return {\n ...obj,\n minLength: 1\n };\n }\n }\n }\n\n return obj;\n}\n\nfunction mapRequiredProps(obj: any, schema: JsonSchema, options: JsonSchemaOptions = {}) {\n const {useAlias} = options;\n const props = Object.keys(obj.properties || {});\n\n return (keys: string[], key: string) => {\n const aliasedKey = useAlias ? (schema.alias.get(key) as string) || key : key;\n\n if (props.includes(aliasedKey)) {\n const propSchema = schema.get(\"properties\")[key];\n const serializeSchema = obj.properties[aliasedKey];\n\n obj.properties[aliasedKey] = applyStringRule(serializeSchema, propSchema);\n\n return keys.concat(aliasedKey);\n }\n\n return keys;\n };\n}\n\nfunction extractRequiredProps(obj: any, schema: JsonSchema, options: JsonSchemaOptions): string[] {\n let required: string[] = obj.required || [];\n\n required = [...required, ...schema.$required];\n\n if (schema.get(\"properties\")) {\n required = Object.entries(schema.get(\"properties\")).reduce((required, [key, prop]: [string, any]) => {\n if (prop && prop.$selfRequired !== undefined) {\n return prop.$selfRequired ? required.concat(key) : required.filter((k) => k === key);\n }\n\n return required;\n }, required);\n }\n\n return alterRequiredGroups(uniq(required), schema, options);\n}\n\n/**\n * @ignore\n */\nexport function getRequiredProperties(obj: any, schema: JsonSchema, options: JsonSchemaOptions) {\n if (options.groups && options.groups.includes(\"partial\")) {\n return obj;\n }\n\n let required = extractRequiredProps(obj, schema, options);\n\n required = uniq(required).reduce(mapRequiredProps(obj, schema, options), []);\n\n if (required.length) {\n return {\n ...obj,\n required\n };\n }\n\n return obj;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapRouteOptions.js","sourceRoot":"","sources":["../../../src/utils/mapRouteOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEtD,MAAM,UAAU,eAAe,CAAC,IAAW;IACzC,IAAI,MAAM,GAAuB,SAAS,CAAC;IAC3C,IAAI,IAAI,GAAgC,SAAS,CAAC;IAElD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,EAAE;QACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE;YACvE,MAAM,GAAG,GAAG,CAAC,iBAAiB,EAAE,CAAC;YAEjC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,MAAM,EAAE;YACpD,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;YAElB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,CAAC,CAAC,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI;QACJ,MAAM;QACN,QAAQ;
|
|
1
|
+
{"version":3,"file":"mapRouteOptions.js","sourceRoot":"","sources":["../../../src/utils/mapRouteOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEtD,MAAM,UAAU,eAAe,CAAC,IAAW;IACzC,IAAI,MAAM,GAAuB,SAAS,CAAC;IAC3C,IAAI,IAAI,GAAgC,SAAS,CAAC;IAElD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,EAAE;QACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE;YACvE,MAAM,GAAG,GAAG,CAAC,iBAAiB,EAAE,CAAC;YAEjC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,MAAM,EAAE;YACpD,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;YAElB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,CAAC,CAAC,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI;QACJ,MAAM;QACN,GAAG,EAAE,QAAQ;KACd,CAAC;AACJ,CAAC","sourcesContent":["import {HTTP_METHODS} from \"../constants/httpMethods\";\n\nexport function mapRouteOptions(args: any[]) {\n let method: string | undefined = undefined;\n let path: string | RegExp | undefined = undefined;\n\n const handlers = args.filter((arg: any) => {\n if (typeof arg === \"string\" && HTTP_METHODS.includes(arg.toLowerCase())) {\n method = arg.toLocaleUpperCase();\n\n return false;\n }\n\n if (typeof arg === \"string\" || arg instanceof RegExp) {\n path = arg || \"/\";\n\n return false;\n }\n\n return !!arg;\n });\n\n return {\n path,\n method,\n use: handlers\n };\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JsonSchema } from "../domain/JsonSchema";
|
|
2
2
|
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
3
|
-
export declare function classMapper(value: JsonSchema, options
|
|
3
|
+
export declare function classMapper(value: JsonSchema, options: JsonSchemaOptions): any;
|
|
@@ -2,4 +2,4 @@ import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
|
2
2
|
/**
|
|
3
3
|
* @ignore
|
|
4
4
|
*/
|
|
5
|
-
export declare function inheritedClassMapper(obj: any, { target, ...options }
|
|
5
|
+
export declare function inheritedClassMapper(obj: any, { target, ...options }: JsonSchemaOptions): any;
|
|
@@ -6,4 +6,4 @@ import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
|
6
6
|
* @param options
|
|
7
7
|
* @ignore
|
|
8
8
|
*/
|
|
9
|
-
export declare function mapMapper(input: Map<string, any>, { ignore, ...options }
|
|
9
|
+
export declare function mapMapper(input: Map<string, any>, { ignore, ...options }: JsonSchemaOptions): any;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JsonSchema } from "../domain/JsonSchema";
|
|
2
2
|
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
3
|
-
export declare function schemaMapper(schema: JsonSchema, options
|
|
3
|
+
export declare function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any;
|
|
@@ -12,6 +12,7 @@ export * from "./operations/deprecated";
|
|
|
12
12
|
export * from "./operations/consumes";
|
|
13
13
|
export * from "./operations/contentType";
|
|
14
14
|
export * from "./operations/in";
|
|
15
|
+
export * from "./operations/inFile";
|
|
15
16
|
export * from "./operations/operationId";
|
|
16
17
|
export * from "./operations/operationPath";
|
|
17
18
|
export * from "./operations/path";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a input file parameter.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.
|
|
6
|
+
* But you can use this decorator on Method, to add extra in parameters like Authorization header.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Controller("/")
|
|
10
|
+
* class MyController {
|
|
11
|
+
* @Post("/")
|
|
12
|
+
* method(@InFile("file1") file: any) {
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
* :::
|
|
17
|
+
*
|
|
18
|
+
* @decorator
|
|
19
|
+
* @swagger
|
|
20
|
+
* @schema
|
|
21
|
+
* @input
|
|
22
|
+
* @operation
|
|
23
|
+
* @param name
|
|
24
|
+
*/
|
|
25
|
+
export declare function InFile(name: string): ParameterDecorator;
|
|
@@ -32,6 +32,9 @@ export interface RouteChainedDecorators {
|
|
|
32
32
|
* @param Summary
|
|
33
33
|
*/
|
|
34
34
|
Summary(Summary: string): this;
|
|
35
|
+
Use(...args: any[]): this;
|
|
36
|
+
UseAfter(...args: any[]): this;
|
|
37
|
+
UseBefore(...args: any[]): this;
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
37
40
|
* Describe a new route with a method and path.
|
|
@@ -16,6 +16,9 @@ export interface JsonEntityStoreOptions {
|
|
|
16
16
|
descriptor?: any;
|
|
17
17
|
type?: Type<any>;
|
|
18
18
|
collectionType?: Type<any>;
|
|
19
|
+
beforeMiddlewares?: Function[];
|
|
20
|
+
middlewares?: Function[];
|
|
21
|
+
afterMiddlewares?: Function[];
|
|
19
22
|
[key: string]: any;
|
|
20
23
|
}
|
|
21
24
|
export declare abstract class JsonEntityStore implements JsonEntityStoreOptions {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { JsonEntityStore } from "./JsonEntityStore";
|
|
1
|
+
import { JsonEntityStore, JsonEntityStoreOptions } from "./JsonEntityStore";
|
|
2
2
|
import { JsonOperation } from "./JsonOperation";
|
|
3
3
|
import type { JsonParameterStore } from "./JsonParameterStore";
|
|
4
4
|
import type { JsonClassStore } from "./JsonClassStore";
|
|
5
5
|
export declare class JsonMethodStore extends JsonEntityStore {
|
|
6
6
|
readonly parent: JsonClassStore;
|
|
7
|
+
middlewares: any[];
|
|
8
|
+
beforeMiddlewares: any[];
|
|
9
|
+
afterMiddlewares: any[];
|
|
10
|
+
constructor(options: JsonEntityStoreOptions);
|
|
7
11
|
/**
|
|
8
12
|
* Ref to JsonOperation when the decorated object is a method.
|
|
9
13
|
*/
|
|
@@ -16,4 +20,21 @@ export declare class JsonMethodStore extends JsonEntityStore {
|
|
|
16
20
|
get operationPaths(): Map<string, import("./JsonOperation").JsonMethodPath>;
|
|
17
21
|
getResponseOptions(status: number, contentType?: string): undefined | any;
|
|
18
22
|
protected build(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Append middlewares to the beforeMiddlewares list.
|
|
25
|
+
* @param args
|
|
26
|
+
* @returns {EndpointMetadata}
|
|
27
|
+
*/
|
|
28
|
+
before(args: Function[]): this;
|
|
29
|
+
/**
|
|
30
|
+
* Append middlewares to the afterMiddlewares list.
|
|
31
|
+
* @param args
|
|
32
|
+
* @returns {EndpointMetadata}
|
|
33
|
+
*/
|
|
34
|
+
after(args: Function[]): this;
|
|
35
|
+
/**
|
|
36
|
+
* Store all arguments collected via Annotation.
|
|
37
|
+
* @param args
|
|
38
|
+
*/
|
|
39
|
+
use(args: Function[]): this;
|
|
19
40
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @ignore
|
|
3
3
|
*/
|
|
4
4
|
export interface JsonSchemaMapper {
|
|
5
|
-
(schema: any, options: any): any;
|
|
5
|
+
(schema: any, options: any, parent?: any): any;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* @ignore
|
|
@@ -15,4 +15,5 @@ export declare function getJsonSchemaMapper(type: string): JsonSchemaMapper;
|
|
|
15
15
|
/**
|
|
16
16
|
* @ignore
|
|
17
17
|
*/
|
|
18
|
-
export declare function execMapper(type: string, schema: any, options: any): any;
|
|
18
|
+
export declare function execMapper(type: string, schema: any, options: any, parent?: any): any;
|
|
19
|
+
export declare function hasMapper(type: string): boolean;
|
|
@@ -4,10 +4,6 @@ import { JsonClassStore } from "../domain/JsonClassStore";
|
|
|
4
4
|
import { JsonPropertyStore } from "../domain/JsonPropertyStore";
|
|
5
5
|
import { JsonParameterStore } from "../domain/JsonParameterStore";
|
|
6
6
|
import { JsonMethodStore } from "../domain/JsonMethodStore";
|
|
7
|
-
/**
|
|
8
|
-
* @ignore
|
|
9
|
-
*/
|
|
10
|
-
export declare function isJsonEntityStore(model: any): model is JsonEntityStore;
|
|
11
7
|
/**
|
|
12
8
|
* Get entity store from decorator args
|
|
13
9
|
* @param target
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/schema",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.93.0",
|
|
4
4
|
"description": "JsonSchema module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "yarn run build:esm && yarn run build:cjs",
|
|
17
17
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
|
-
"build:esm": "tsc --build tsconfig.compile.esm.json"
|
|
18
|
+
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
19
|
+
"test": "cross-env NODE_ENV=test nyc mocha"
|
|
19
20
|
},
|
|
20
21
|
"keywords": [
|
|
21
22
|
"TypeScript",
|
|
@@ -28,8 +29,8 @@
|
|
|
28
29
|
"tsed"
|
|
29
30
|
],
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@tsed/core": "6.
|
|
32
|
-
"@tsed/openspec": "6.
|
|
32
|
+
"@tsed/core": "6.93.0",
|
|
33
|
+
"@tsed/openspec": "6.93.0",
|
|
33
34
|
"camel-case": "4.1.2",
|
|
34
35
|
"json-schema": "0.4.0",
|
|
35
36
|
"micromatch": "4.0.2",
|
|
@@ -44,8 +45,8 @@
|
|
|
44
45
|
"fs-extra": "9.0.1"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@tsed/core": "^6.
|
|
48
|
-
"@tsed/openspec": "^6.
|
|
48
|
+
"@tsed/core": "^6.93.0",
|
|
49
|
+
"@tsed/openspec": "^6.93.0"
|
|
49
50
|
},
|
|
50
51
|
"repository": "https://github.com/tsedio/tsed",
|
|
51
52
|
"bugs": {
|