@tsed/schema 7.0.0-beta.10 → 7.0.0-beta.13

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 (128) hide show
  1. package/lib/cjs/components/lazyRefMapper.js +1 -2
  2. package/lib/cjs/components/lazyRefMapper.js.map +1 -1
  3. package/lib/cjs/components/objectMapper.js +1 -1
  4. package/lib/cjs/components/objectMapper.js.map +1 -1
  5. package/lib/cjs/constants/httpStatusMessages.js +2 -4
  6. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  7. package/lib/cjs/decorators/collections/collectionOf.js +3 -4
  8. package/lib/cjs/decorators/collections/collectionOf.js.map +1 -1
  9. package/lib/cjs/decorators/common/description.js +1 -2
  10. package/lib/cjs/decorators/common/description.js.map +1 -1
  11. package/lib/cjs/decorators/operations/redirect.js +1 -2
  12. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  13. package/lib/cjs/decorators/operations/returns.js +20 -20
  14. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  15. package/lib/cjs/decorators/operations/route.js +1 -4
  16. package/lib/cjs/decorators/operations/route.js.map +1 -1
  17. package/lib/cjs/domain/DecoratorContext.js +6 -3
  18. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  19. package/lib/cjs/domain/JsonClassStore.js +4 -7
  20. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  21. package/lib/cjs/domain/JsonEntityStore.js +37 -1
  22. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  23. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  24. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  25. package/lib/cjs/domain/JsonMethodStore.js +12 -12
  26. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  27. package/lib/cjs/domain/JsonOperation.js +12 -16
  28. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  29. package/lib/cjs/domain/JsonOperationPathsMap.js +1 -4
  30. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  31. package/lib/cjs/domain/JsonOperationRoute.js +8 -6
  32. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  33. package/lib/cjs/domain/JsonParameter.js +4 -4
  34. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  35. package/lib/cjs/domain/JsonParameterStore.js +12 -5
  36. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  37. package/lib/cjs/domain/JsonPropertyStore.js +1 -4
  38. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  39. package/lib/cjs/domain/JsonResponse.js +3 -6
  40. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  41. package/lib/cjs/domain/JsonSchema.js +58 -60
  42. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  43. package/lib/cjs/hooks/alterIgnore.js +2 -3
  44. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  45. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  46. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  47. package/lib/cjs/utils/getJsonPathParameters.js +20 -6
  48. package/lib/cjs/utils/getJsonPathParameters.js.map +1 -1
  49. package/lib/cjs/utils/getJsonSchema.js +4 -5
  50. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  51. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  52. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  53. package/lib/cjs/utils/mapNullableType.js +1 -1
  54. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  55. package/lib/cjs/utils/mergeOperation.js +1 -2
  56. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  57. package/lib/cjs/utils/operationIdFormatter.js +3 -3
  58. package/lib/cjs/utils/operationIdFormatter.js.map +1 -1
  59. package/lib/cjs/utils/ref.js +2 -2
  60. package/lib/cjs/utils/ref.js.map +1 -1
  61. package/lib/cjs/utils/transformToOS2.js +2 -2
  62. package/lib/cjs/utils/transformToOS2.js.map +1 -1
  63. package/lib/esm/components/lazyRefMapper.js +1 -2
  64. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  65. package/lib/esm/components/objectMapper.js +1 -1
  66. package/lib/esm/components/objectMapper.js.map +1 -1
  67. package/lib/esm/constants/httpStatusMessages.js +2 -4
  68. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  69. package/lib/esm/decorators/collections/collectionOf.js +3 -4
  70. package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
  71. package/lib/esm/decorators/common/description.js +1 -2
  72. package/lib/esm/decorators/common/description.js.map +1 -1
  73. package/lib/esm/decorators/operations/redirect.js +1 -2
  74. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  75. package/lib/esm/decorators/operations/returns.js +20 -20
  76. package/lib/esm/decorators/operations/returns.js.map +1 -1
  77. package/lib/esm/decorators/operations/route.js +1 -4
  78. package/lib/esm/decorators/operations/route.js.map +1 -1
  79. package/lib/esm/domain/DecoratorContext.js +5 -2
  80. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  81. package/lib/esm/domain/JsonClassStore.js +4 -7
  82. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  83. package/lib/esm/domain/JsonEntityStore.js +37 -1
  84. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  85. package/lib/esm/domain/JsonLazyRef.js +2 -1
  86. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  87. package/lib/esm/domain/JsonMethodStore.js +12 -12
  88. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  89. package/lib/esm/domain/JsonOperation.js +12 -16
  90. package/lib/esm/domain/JsonOperation.js.map +1 -1
  91. package/lib/esm/domain/JsonOperationPathsMap.js +1 -4
  92. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  93. package/lib/esm/domain/JsonOperationRoute.js +8 -6
  94. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  95. package/lib/esm/domain/JsonParameter.js +4 -4
  96. package/lib/esm/domain/JsonParameter.js.map +1 -1
  97. package/lib/esm/domain/JsonParameterStore.js +12 -5
  98. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  99. package/lib/esm/domain/JsonPropertyStore.js +1 -4
  100. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  101. package/lib/esm/domain/JsonResponse.js +3 -6
  102. package/lib/esm/domain/JsonResponse.js.map +1 -1
  103. package/lib/esm/domain/JsonSchema.js +58 -60
  104. package/lib/esm/domain/JsonSchema.js.map +1 -1
  105. package/lib/esm/hooks/alterIgnore.js +2 -3
  106. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  107. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  108. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  109. package/lib/esm/utils/getJsonPathParameters.js +20 -6
  110. package/lib/esm/utils/getJsonPathParameters.js.map +1 -1
  111. package/lib/esm/utils/getJsonSchema.js +4 -5
  112. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  113. package/lib/esm/utils/getRequiredProperties.js +3 -3
  114. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  115. package/lib/esm/utils/mapNullableType.js +1 -1
  116. package/lib/esm/utils/mapNullableType.js.map +1 -1
  117. package/lib/esm/utils/mergeOperation.js +1 -2
  118. package/lib/esm/utils/mergeOperation.js.map +1 -1
  119. package/lib/esm/utils/operationIdFormatter.js +1 -1
  120. package/lib/esm/utils/operationIdFormatter.js.map +1 -1
  121. package/lib/esm/utils/ref.js +1 -1
  122. package/lib/esm/utils/ref.js.map +1 -1
  123. package/lib/esm/utils/transformToOS2.js +2 -2
  124. package/lib/esm/utils/transformToOS2.js.map +1 -1
  125. package/lib/types/utils/getJsonSchema.d.ts +1 -1
  126. package/package.json +12 -10
  127. package/readme.md +2 -1
  128. package/tsconfig.compile.esm.json +2 -1
@@ -5,9 +5,8 @@ const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperConta
5
5
  const generics_1 = require("../utils/generics");
6
6
  const ref_1 = require("../utils/ref");
7
7
  function lazyRefMapper(input, options) {
8
- var _a;
9
8
  const name = input.name;
10
- if ((_a = options.$refs) === null || _a === void 0 ? void 0 : _a.find((t) => t === input.target)) {
9
+ if (options.$refs?.find((t) => t === input.target)) {
11
10
  return (0, ref_1.createRef)(name, input.schema, options);
12
11
  }
13
12
  options.$refs = [...(options.$refs || []), input.target];
@@ -1 +1 @@
1
- {"version":3,"file":"lazyRefMapper.js","sourceRoot":"","sources":["../../../src/components/lazyRefMapper.ts"],"names":[],"mappings":";;;AAEA,uFAAiF;AACjF,gDAAqD;AACrD,sCAA8C;AAE9C,SAAgB,aAAa,CAAC,KAAkB,EAAE,OAA0B;;IAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAExB,IAAI,MAAA,OAAO,CAAC,KAAK,0CAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE;QACvD,OAAO,IAAA,eAAS,EAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAA,6BAAkB,EAAC,OAAO,CAAC,CAAC,CAAC;IAEzD,OAAO,IAAA,WAAK,EAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAZD,sCAYC;AAED,IAAA,oDAAwB,EAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {createRef, toRef} from \"../utils/ref\";\n\nexport function lazyRefMapper(input: JsonLazyRef, options: JsonSchemaOptions) {\n const name = input.name;\n\n if (options.$refs?.find((t: any) => t === input.target)) {\n return createRef(name, input.schema, options);\n }\n\n options.$refs = [...(options.$refs || []), input.target];\n\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return toRef(input.schema, schema, options);\n}\n\nregisterJsonSchemaMapper(\"lazyRef\", lazyRefMapper);\n"]}
1
+ {"version":3,"file":"lazyRefMapper.js","sourceRoot":"","sources":["../../../src/components/lazyRefMapper.ts"],"names":[],"mappings":";;;AAEA,uFAAiF;AACjF,gDAAqD;AACrD,sCAA8C;AAE9C,SAAgB,aAAa,CAAC,KAAkB,EAAE,OAA0B;IAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAExB,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE;QACvD,OAAO,IAAA,eAAS,EAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAA,6BAAkB,EAAC,OAAO,CAAC,CAAC,CAAC;IAEzD,OAAO,IAAA,WAAK,EAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAZD,sCAYC;AAED,IAAA,oDAAwB,EAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {createRef, toRef} from \"../utils/ref\";\n\nexport function lazyRefMapper(input: JsonLazyRef, options: JsonSchemaOptions) {\n const name = input.name;\n\n if (options.$refs?.find((t: any) => t === input.target)) {\n return createRef(name, input.schema, options);\n }\n\n options.$refs = [...(options.$refs || []), input.target];\n\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return toRef(input.schema, schema, options);\n}\n\nregisterJsonSchemaMapper(\"lazyRef\", lazyRefMapper);\n"]}
@@ -17,7 +17,7 @@ function objectMapper(input, options) {
17
17
  if (options.withIgnoredProps !== false && !(0, alterIgnore_1.alterIgnore)(value, ctx)) {
18
18
  const opts = {
19
19
  ...options,
20
- groups: (input === null || input === void 0 ? void 0 : input.$forwardGroups) || (value === null || value === void 0 ? void 0 : value.$forwardGroups) ? options.groups : undefined
20
+ groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined
21
21
  };
22
22
  // remove groups to avoid bad schema generation over children models
23
23
  obj[key] = (0, JsonSchemaMapperContainer_1.execMapper)("item", value, opts);
@@ -1 +1 @@
1
- {"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC,sDAAiD;AAEjD,uFAA6F;AAC7F,8DAAyD;AAEzD;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,IAAA,yBAAW,EAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,MAAM,IAAI,GAAG;gBACX,GAAG,OAAO;gBACV,MAAM,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAA,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC;YACF,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,sCAAU,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,iCAAe,EAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACnD;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAnBD,oCAmBC;AAED,IAAA,oDAAwB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n const opts = {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n };\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, opts);\n obj[key] = mapNullableType(obj[key], value, opts);\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
1
+ {"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC,sDAAiD;AAEjD,uFAA6F;AAC7F,8DAAyD;AAEzD;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,IAAA,yBAAW,EAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,MAAM,IAAI,GAAG;gBACX,GAAG,OAAO;gBACV,MAAM,EAAE,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC;YACF,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,sCAAU,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,iCAAe,EAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACnD;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAnBD,oCAmBC;AAED,IAAA,oDAAwB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n const opts = {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n };\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, opts);\n obj[key] = mapNullableType(obj[key], value, opts);\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
@@ -14,13 +14,11 @@ exports.HTTP_STATUS_MESSAGES = statuses_1.default.codes.reduce((map, code) => {
14
14
  exports.HTTP_STATUS_MESSAGES["200"].label = "Success";
15
15
  exports.HTTP_STATUS_MESSAGES["200"].code = "SUCCESS";
16
16
  function getStatusConstant(status) {
17
- var _a;
18
- return (_a = exports.HTTP_STATUS_MESSAGES[status]) === null || _a === void 0 ? void 0 : _a.code;
17
+ return exports.HTTP_STATUS_MESSAGES[status]?.code;
19
18
  }
20
19
  exports.getStatusConstant = getStatusConstant;
21
20
  function getStatusMessage(status) {
22
- var _a;
23
- return (_a = exports.HTTP_STATUS_MESSAGES[status]) === null || _a === void 0 ? void 0 : _a.label;
21
+ return exports.HTTP_STATUS_MESSAGES[status]?.label;
24
22
  }
25
23
  exports.getStatusMessage = getStatusMessage;
26
24
  //# sourceMappingURL=httpStatusMessages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpStatusMessages.js","sourceRoot":"","sources":["../../../src/constants/httpStatusMessages.ts"],"names":[],"mappings":";;;;AAAA,gEAAgC;AAChC,6CAAyC;AAE5B,QAAA,oBAAoB,GAAG,kBAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAkD,EAAE,IAAY,EAAE,EAAE;IAC7H,MAAM,OAAO,GAAW,MAAM,CAAC,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,GAAG,GAAG;QACN,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAC;KAC9D,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,4BAAoB,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC;AAC9C,4BAAoB,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC;AAE7C,SAAgB,iBAAiB,CAAC,MAAuB;;IACvD,OAAO,MAAC,4BAA4B,CAAC,MAAM,CAAC,0CAAE,IAAI,CAAC;AACrD,CAAC;AAFD,8CAEC;AAED,SAAgB,gBAAgB,CAAC,MAAuB;;IACtD,OAAO,MAAC,4BAA4B,CAAC,MAAM,CAAC,0CAAE,KAAK,CAAC;AACtD,CAAC;AAFD,4CAEC","sourcesContent":["import statuses from \"statuses\";\nimport {constantCase} from \"change-case\";\n\nexport const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map: Record<string, {label: string; code: string}>, code: number) => {\n const message: string = String(statuses(code));\n return {\n ...map,\n [String(code)]: {label: message, code: constantCase(message)}\n };\n}, {});\n\nHTTP_STATUS_MESSAGES[\"200\"].label = \"Success\";\nHTTP_STATUS_MESSAGES[\"200\"].code = \"SUCCESS\";\n\nexport function getStatusConstant(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.code;\n}\n\nexport function getStatusMessage(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.label;\n}\n"]}
1
+ {"version":3,"file":"httpStatusMessages.js","sourceRoot":"","sources":["../../../src/constants/httpStatusMessages.ts"],"names":[],"mappings":";;;;AAAA,gEAAgC;AAChC,6CAAyC;AAE5B,QAAA,oBAAoB,GAAG,kBAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAkD,EAAE,IAAY,EAAE,EAAE;IAC7H,MAAM,OAAO,GAAW,MAAM,CAAC,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,GAAG,GAAG;QACN,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAA,0BAAY,EAAC,OAAO,CAAC,EAAC;KAC9D,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,4BAAoB,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC;AAC9C,4BAAoB,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC;AAE7C,SAAgB,iBAAiB,CAAC,MAAuB;IACvD,OAAQ,4BAA4B,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;AACrD,CAAC;AAFD,8CAEC;AAED,SAAgB,gBAAgB,CAAC,MAAuB;IACtD,OAAQ,4BAA4B,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;AACtD,CAAC;AAFD,4CAEC","sourcesContent":["import statuses from \"statuses\";\nimport {constantCase} from \"change-case\";\n\nexport const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map: Record<string, {label: string; code: string}>, code: number) => {\n const message: string = String(statuses(code));\n return {\n ...map,\n [String(code)]: {label: message, code: constantCase(message)}\n };\n}, {});\n\nHTTP_STATUS_MESSAGES[\"200\"].label = \"Success\";\nHTTP_STATUS_MESSAGES[\"200\"].code = \"SUCCESS\";\n\nexport function getStatusConstant(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.code;\n}\n\nexport function getStatusMessage(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.label;\n}\n"]}
@@ -35,20 +35,19 @@ const JsonEntityStore_1 = require("../../domain/JsonEntityStore");
35
35
  * @collections
36
36
  */
37
37
  function CollectionOf(type, collectionType) {
38
+ if (!type) {
39
+ throw new Error("A type is required on `@CollectionOf(type)` decorator. Please give a type or wrap it inside an arrow function if you have a circular reference.");
40
+ }
38
41
  const schema = {};
39
42
  let contains = false;
40
43
  const decorator = (...args) => {
41
44
  const store = JsonEntityStore_1.JsonEntityStore.from(...args);
42
- // const itemSchema = store.itemSchema.toJSON();
43
45
  if (collectionType) {
44
46
  store.collectionType = collectionType;
45
47
  store.schema.type(collectionType);
46
48
  }
47
49
  store.type = type;
48
- // console.log(type);
49
50
  store.itemSchema.type(type);
50
- // console.log(store.itemSchema.getComputedType(), schema);
51
- // store.itemSchema.assign({...itemSchema, type});
52
51
  store.schema.assign(schema);
53
52
  if (store.isArray && contains) {
54
53
  store.schema.set("contains", store.schema.get("items"));
@@ -1 +1 @@
1
- {"version":3,"file":"collectionOf.js","sourceRoot":"","sources":["../../../../src/decorators/collections/collectionOf.ts"],"names":[],"mappings":";;;AACA,kEAA6D;AAkE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,YAAY,CAAC,IAAS,EAAE,cAAoB;IAC1D,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAY,KAAK,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,GAAG,IAAS,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,iCAAe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C,QAAQ,GAAG,GAAG,EAAE;QACxB,QAAQ,GAAG,IAAI,CAAC;QAEhB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,CAAC,WAAW,GAAG,IAAI,EAAE,EAAE;QAC7C,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;QAEjC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AA9DD,oCA8DC;AAED;;;;GAIG;AACH,SAAgB,OAAO,CAAC,IAAS;IAC/B,OAAO,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAFD,0BAEC;AAED;;;;GAIG;AACH,SAAgB,KAAK,CAAC,IAAS;IAC7B,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAFD,sBAEC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\n\nexport interface ArrayOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value `minItems` MUST be a non-negative integer.\n * :::\n *\n * ::: tip\n * Omitting this keyword has the same behavior as a value of 0.\n * :::\n */\n MinItems(minItems: number): this;\n\n /**\n * The value `maxItems` MUST be a non-negative integer.\n *\n * An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.\n *\n * :: warning\n * The value `maxItems` MUST be a non-negative integer.\n * :::\n */\n MaxItems(maxItems: number): this;\n\n /**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * The array instance will be valid against \"contains\" if at least one of its elements is valid against the given schema.\n */\n Contains(): this;\n\n /**\n * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.\n */\n UniqueItems(uniqueItems?: boolean): this;\n}\n\nexport interface MapOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MinProperties(minProperties: number): this;\n\n /**\n * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MaxProperties(maxProperties: number): this;\n}\n\nexport interface CollectionOfChainedDecorators extends MapOfChainedDecorators, ArrayOfChainedDecorators {}\n\n/**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * ```typescript\n * class Model {\n * @CollectionOf(String).MinLength(0).MaxLength(0)\n * property: string[];\n * }\n * ```\n * ::: warning\n * You mustn't use the `type Type = string | number` as parameters Type.\n *\n * This example doesn't work:\n *\n * ```typescript\n * type Type = \"string\" | \"number\"\n * class Model {\n * @CollectionOf(Type)\n * property: Type[];\n * }\n * ```\n * :::\n *\n * @param {Type<any>} type\n * @param collectionType\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n */\nexport function CollectionOf(type: any, collectionType?: any): CollectionOfChainedDecorators {\n const schema: any = {};\n let contains: boolean = false;\n\n const decorator = (...args: any) => {\n const store = JsonEntityStore.from(...args);\n // const itemSchema = store.itemSchema.toJSON();\n\n if (collectionType) {\n store.collectionType = collectionType;\n store.schema.type(collectionType);\n }\n\n store.type = type;\n // console.log(type);\n store.itemSchema.type(type);\n // console.log(store.itemSchema.getComputedType(), schema);\n // store.itemSchema.assign({...itemSchema, type});\n store.schema.assign(schema);\n\n if (store.isArray && contains) {\n store.schema.set(\"contains\", store.schema.get(\"items\"));\n store.schema.delete(\"items\");\n }\n };\n\n decorator.MinItems = (minItems: number) => {\n schema.minItems = minItems;\n\n return decorator;\n };\n\n decorator.MaxItems = (maxItems: number) => {\n schema.maxItems = maxItems;\n\n return decorator;\n };\n decorator.MinProperties = (minProperties: number) => {\n schema.minProperties = minProperties;\n\n return decorator;\n };\n\n decorator.MaxProperties = (maxProperties: number) => {\n schema.maxProperties = maxProperties;\n\n return decorator;\n };\n\n decorator.Contains = () => {\n contains = true;\n\n return decorator;\n };\n\n decorator.UniqueItems = (uniqueItems = true) => {\n schema.uniqueItems = uniqueItems;\n\n return decorator;\n };\n\n return decorator;\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function ArrayOf(type: any): ArrayOfChainedDecorators {\n return CollectionOf(type, Array);\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function MapOf(type: any): MapOfChainedDecorators {\n return CollectionOf(type, Map);\n}\n"]}
1
+ {"version":3,"file":"collectionOf.js","sourceRoot":"","sources":["../../../../src/decorators/collections/collectionOf.ts"],"names":[],"mappings":";;;AACA,kEAA6D;AAkE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,YAAY,CAAC,IAAS,EAAE,cAAoB;IAC1D,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,iJAAiJ,CAClJ,CAAC;KACH;IAED,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAY,KAAK,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,GAAG,IAAS,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,iCAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAE5C,IAAI,cAAc,EAAE;YAClB,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;YACtC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SACnC;QAED,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE5B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,KAAK,CAAC,OAAO,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AAED;;;;GAIG;AACH,SAAgB,KAAK,CAAC,IAAS;IAC7B,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAFD,sBAEC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\n\nexport interface ArrayOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value `minItems` MUST be a non-negative integer.\n * :::\n *\n * ::: tip\n * Omitting this keyword has the same behavior as a value of 0.\n * :::\n */\n MinItems(minItems: number): this;\n\n /**\n * The value `maxItems` MUST be a non-negative integer.\n *\n * An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.\n *\n * :: warning\n * The value `maxItems` MUST be a non-negative integer.\n * :::\n */\n MaxItems(maxItems: number): this;\n\n /**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * The array instance will be valid against \"contains\" if at least one of its elements is valid against the given schema.\n */\n Contains(): this;\n\n /**\n * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.\n */\n UniqueItems(uniqueItems?: boolean): this;\n}\n\nexport interface MapOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MinProperties(minProperties: number): this;\n\n /**\n * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MaxProperties(maxProperties: number): this;\n}\n\nexport interface CollectionOfChainedDecorators extends MapOfChainedDecorators, ArrayOfChainedDecorators {}\n\n/**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * ```typescript\n * class Model {\n * @CollectionOf(String).MinLength(0).MaxLength(0)\n * property: string[];\n * }\n * ```\n * ::: warning\n * You mustn't use the `type Type = string | number` as parameters Type.\n *\n * This example doesn't work:\n *\n * ```typescript\n * type Type = \"string\" | \"number\"\n * class Model {\n * @CollectionOf(Type)\n * property: Type[];\n * }\n * ```\n * :::\n *\n * @param {Type<any>} type\n * @param collectionType\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n */\nexport function CollectionOf(type: any, collectionType?: any): CollectionOfChainedDecorators {\n if (!type) {\n throw new Error(\n \"A type is required on `@CollectionOf(type)` decorator. Please give a type or wrap it inside an arrow function if you have a circular reference.\"\n );\n }\n\n const schema: any = {};\n let contains: boolean = false;\n\n const decorator = (...args: any) => {\n const store = JsonEntityStore.from(...args);\n\n if (collectionType) {\n store.collectionType = collectionType;\n store.schema.type(collectionType);\n }\n\n store.type = type;\n store.itemSchema.type(type);\n\n store.schema.assign(schema);\n\n if (store.isArray && contains) {\n store.schema.set(\"contains\", store.schema.get(\"items\"));\n store.schema.delete(\"items\");\n }\n };\n\n decorator.MinItems = (minItems: number) => {\n schema.minItems = minItems;\n\n return decorator;\n };\n\n decorator.MaxItems = (maxItems: number) => {\n schema.maxItems = maxItems;\n\n return decorator;\n };\n decorator.MinProperties = (minProperties: number) => {\n schema.minProperties = minProperties;\n\n return decorator;\n };\n\n decorator.MaxProperties = (maxProperties: number) => {\n schema.maxProperties = maxProperties;\n\n return decorator;\n };\n\n decorator.Contains = () => {\n contains = true;\n\n return decorator;\n };\n\n decorator.UniqueItems = (uniqueItems = true) => {\n schema.uniqueItems = uniqueItems;\n\n return decorator;\n };\n\n return decorator;\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function ArrayOf(type: any): ArrayOfChainedDecorators {\n return CollectionOf(type, Array);\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function MapOf(type: any): MapOfChainedDecorators {\n return CollectionOf(type, Map);\n}\n"]}
@@ -57,7 +57,6 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
57
57
  */
58
58
  function Description(description) {
59
59
  return (0, jsonEntityFn_1.JsonEntityFn)((store, args) => {
60
- var _a;
61
60
  switch ((0, core_1.decoratorTypeOf)(args)) {
62
61
  case core_1.DecoratorTypes.PROP:
63
62
  case core_1.DecoratorTypes.CLASS:
@@ -67,7 +66,7 @@ function Description(description) {
67
66
  store.parameter.description(description);
68
67
  break;
69
68
  case core_1.DecoratorTypes.METHOD:
70
- (_a = store.operation) === null || _a === void 0 ? void 0 : _a.description(description);
69
+ store.operation?.description(description);
71
70
  break;
72
71
  }
73
72
  });
@@ -1 +1 @@
1
- {"version":3,"file":"description.js","sourceRoot":"","sources":["../../../../src/decorators/common/description.ts"],"names":[],"mappings":";;;AAAA,qCAAgF;AAEhF,iDAA4C;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,SAAgB,WAAW,CAAC,WAAgB;IAC1C,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAsB,EAAE,IAAyB,EAAE,EAAE;;QACxE,QAAQ,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,qBAAc,CAAC,IAAI,CAAC;YACzB,KAAK,qBAAc,CAAC,KAAK;gBACvB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACtC,MAAM;YAER,KAAK,qBAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACjE,MAAM;YAER,KAAK,qBAAc,CAAC,MAAM;gBACxB,MAAC,KAAyB,CAAC,SAAS,0CAAE,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC/D,MAAM;SACT;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,kCAiBC","sourcesContent":["import {DecoratorParameters, decoratorTypeOf, DecoratorTypes} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\nimport type {JsonMethodStore} from \"../../domain/JsonMethodStore\";\nimport type {JsonParameterStore} from \"../../domain/JsonParameterStore\";\n\n/**\n * Add a description to the class, method or property\n *\n * ## Examples\n * ### On class\n *\n * ```typescript\n * @Description(\"description\")\n * class Model {\n *\n * }\n * ```\n *\n * ### On method\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * @Description(\"description\")\n * async method() {}\n * }\n * ```\n *\n * ### On parameter\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * async method(@Description(\"description\") @PathParam(\"id\") id: string) {}\n * }\n * ```\n *\n * ### On property\n *\n * ```typescript\n * class Model {\n * @Description(\"description\")\n * id: string;\n * }\n * ```\n *\n * @param {string} description\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @classDecorator\n * @methodDecorator\n * @propertyDecorator\n * @parameterDecorator\n */\nexport function Description(description: any) {\n return JsonEntityFn((store: JsonEntityStore, args: DecoratorParameters) => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PROP:\n case DecoratorTypes.CLASS:\n store.schema.description(description);\n break;\n\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.description(description);\n break;\n\n case DecoratorTypes.METHOD:\n (store as JsonMethodStore).operation?.description(description);\n break;\n }\n });\n}\n"]}
1
+ {"version":3,"file":"description.js","sourceRoot":"","sources":["../../../../src/decorators/common/description.ts"],"names":[],"mappings":";;;AAAA,qCAAgF;AAEhF,iDAA4C;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,SAAgB,WAAW,CAAC,WAAgB;IAC1C,OAAO,IAAA,2BAAY,EAAC,CAAC,KAAsB,EAAE,IAAyB,EAAE,EAAE;QACxE,QAAQ,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,qBAAc,CAAC,IAAI,CAAC;YACzB,KAAK,qBAAc,CAAC,KAAK;gBACvB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACtC,MAAM;YAER,KAAK,qBAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACjE,MAAM;YAER,KAAK,qBAAc,CAAC,MAAM;gBACvB,KAAyB,CAAC,SAAS,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC/D,MAAM;SACT;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,kCAiBC","sourcesContent":["import {DecoratorParameters, decoratorTypeOf, DecoratorTypes} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\nimport type {JsonMethodStore} from \"../../domain/JsonMethodStore\";\nimport type {JsonParameterStore} from \"../../domain/JsonParameterStore\";\n\n/**\n * Add a description to the class, method or property\n *\n * ## Examples\n * ### On class\n *\n * ```typescript\n * @Description(\"description\")\n * class Model {\n *\n * }\n * ```\n *\n * ### On method\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * @Description(\"description\")\n * async method() {}\n * }\n * ```\n *\n * ### On parameter\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * async method(@Description(\"description\") @PathParam(\"id\") id: string) {}\n * }\n * ```\n *\n * ### On property\n *\n * ```typescript\n * class Model {\n * @Description(\"description\")\n * id: string;\n * }\n * ```\n *\n * @param {string} description\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @classDecorator\n * @methodDecorator\n * @propertyDecorator\n * @parameterDecorator\n */\nexport function Description(description: any) {\n return JsonEntityFn((store: JsonEntityStore, args: DecoratorParameters) => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PROP:\n case DecoratorTypes.CLASS:\n store.schema.description(description);\n break;\n\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.description(description);\n break;\n\n case DecoratorTypes.METHOD:\n (store as JsonMethodStore).operation?.description(description);\n break;\n }\n });\n}\n"]}
@@ -18,8 +18,7 @@ function Redirect(...args) {
18
18
  return options;
19
19
  }, { status: 302, url: "", meta: {} });
20
20
  return (0, core_1.useDecorators)((0, returns_1.Returns)(status).Location(url, meta), (0, jsonEntityFn_1.JsonEntityFn)((entity) => {
21
- var _a;
22
- (_a = entity.operation) === null || _a === void 0 ? void 0 : _a.setRedirection(status);
21
+ entity.operation?.setRedirection(status);
23
22
  }));
24
23
  }
25
24
  exports.Redirect = Redirect;
@@ -1 +1 @@
1
- {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../../../src/decorators/operations/redirect.ts"],"names":[],"mappings":";;;AAAA,qCAA6D;AAE7D,yDAAoD;AACpD,uCAAkC;AAqDlC,SAAgB,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,EAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,MAAM,CACrC,CAAC,OAAY,EAAE,KAAU,EAAE,EAAE;QAC3B,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;YACvB,OAAO,OAAO,CAAC;SAChB;QAED,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;YACpB,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;QACrB,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CACjC,CAAC;IACF,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EACnC,IAAA,2BAAY,EAAC,CAAC,MAAM,EAAE,EAAE;;QACtB,MAAA,MAAM,CAAC,SAAS,0CAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAxBD,4BAwBC","sourcesContent":["import {isNumber, isString, useDecorators} from \"@tsed/core\";\nimport {JsonHeader} from \"../../interfaces/JsonOpenSpec\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\nimport {Returns} from \"./returns\";\n\n/**\n * Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”.\n *\n * ```typescript\n * @Redirect('/foo/bar')\n * @Redirect(301, 'http://example.com').Type(Model)\n * private myMethod() {}\n * ```\n * Redirects can be a fully-qualified URL for redirecting to a different site:\n *\n * ```typescript\n * @Redirect('http://google.com');\n * private myMethod() {}\n * ```\n *\n * Redirects can be relative to the root of the host name. For example, if the application is on http://example.com/admin/post/new, the following would redirect to the URL http://example.com/admin:\n *\n * ```typescript\n * @Redirect('/admin');\n * ```\n * Redirects can be relative to the current URL. For example, from http://example.com/blog/admin/ (notice the trailing slash), the following would redirect to the URL http://example.com/blog/admin/post/new.\n *\n * ```typescript\n * @Redirect('post/new');\n * ```\n *\n * Redirecting to post/new from http://example.com/blog/admin (no trailing slash), will redirect to http://example.com/blog/post/new.\n *\n * If you found the above behavior confusing, think of path segments as directories (with trailing slashes) and files, it will start to make sense.\n *\n * Path-relative redirects are also possible. If you were on http://example.com/admin/post/new, the following would redirect to http//example.com/admin/post:\n *\n * ```typescript\n * @Redirect('..');\n * ``\n *\n * A back redirection redirects the request back to the referer, defaulting to / when the referer is missing.\n *\n * ```typescript\n * @Redirect('back');\n * ```\n *\n * @param url\n * @param meta\n * @decorator\n * @operation\n * @response\n * @headers\n */\nexport function Redirect(url: string, meta?: JsonHeader): Function;\nexport function Redirect(status: number, url: string, meta?: JsonHeader): Function;\nexport function Redirect(...args: any[]): Function {\n const {status, url, meta} = args.reduce(\n (options: any, value: any) => {\n if (isNumber(value)) {\n options.status = value;\n return options;\n }\n\n if (isString(value)) {\n options.url = value;\n return options;\n }\n\n options.meta = value;\n return options;\n },\n {status: 302, url: \"\", meta: {}}\n );\n return useDecorators(\n Returns(status).Location(url, meta),\n JsonEntityFn((entity) => {\n entity.operation?.setRedirection(status);\n })\n );\n}\n"]}
1
+ {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../../../src/decorators/operations/redirect.ts"],"names":[],"mappings":";;;AAAA,qCAA6D;AAE7D,yDAAoD;AACpD,uCAAkC;AAqDlC,SAAgB,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,EAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,MAAM,CACrC,CAAC,OAAY,EAAE,KAAU,EAAE,EAAE;QAC3B,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;YACvB,OAAO,OAAO,CAAC;SAChB;QAED,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;YACpB,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;QACrB,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CACjC,CAAC;IACF,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EACnC,IAAA,2BAAY,EAAC,CAAC,MAAM,EAAE,EAAE;QACtB,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAxBD,4BAwBC","sourcesContent":["import {isNumber, isString, useDecorators} from \"@tsed/core\";\nimport {JsonHeader} from \"../../interfaces/JsonOpenSpec\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\nimport {Returns} from \"./returns\";\n\n/**\n * Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”.\n *\n * ```typescript\n * @Redirect('/foo/bar')\n * @Redirect(301, 'http://example.com').Type(Model)\n * private myMethod() {}\n * ```\n * Redirects can be a fully-qualified URL for redirecting to a different site:\n *\n * ```typescript\n * @Redirect('http://google.com');\n * private myMethod() {}\n * ```\n *\n * Redirects can be relative to the root of the host name. For example, if the application is on http://example.com/admin/post/new, the following would redirect to the URL http://example.com/admin:\n *\n * ```typescript\n * @Redirect('/admin');\n * ```\n * Redirects can be relative to the current URL. For example, from http://example.com/blog/admin/ (notice the trailing slash), the following would redirect to the URL http://example.com/blog/admin/post/new.\n *\n * ```typescript\n * @Redirect('post/new');\n * ```\n *\n * Redirecting to post/new from http://example.com/blog/admin (no trailing slash), will redirect to http://example.com/blog/post/new.\n *\n * If you found the above behavior confusing, think of path segments as directories (with trailing slashes) and files, it will start to make sense.\n *\n * Path-relative redirects are also possible. If you were on http://example.com/admin/post/new, the following would redirect to http//example.com/admin/post:\n *\n * ```typescript\n * @Redirect('..');\n * ``\n *\n * A back redirection redirects the request back to the referer, defaulting to / when the referer is missing.\n *\n * ```typescript\n * @Redirect('back');\n * ```\n *\n * @param url\n * @param meta\n * @decorator\n * @operation\n * @response\n * @headers\n */\nexport function Redirect(url: string, meta?: JsonHeader): Function;\nexport function Redirect(status: number, url: string, meta?: JsonHeader): Function;\nexport function Redirect(...args: any[]): Function {\n const {status, url, meta} = args.reduce(\n (options: any, value: any) => {\n if (isNumber(value)) {\n options.status = value;\n return options;\n }\n\n if (isString(value)) {\n options.url = value;\n return options;\n }\n\n options.meta = value;\n return options;\n },\n {status: 302, url: \"\", meta: {}}\n );\n return useDecorators(\n Returns(status).Location(url, meta),\n JsonEntityFn((entity) => {\n entity.operation?.setRedirection(status);\n })\n );\n}\n"]}
@@ -28,26 +28,26 @@ function mapGenerics(types) {
28
28
  * @ignore
29
29
  */
30
30
  class ReturnDecoratorContext extends DecoratorContext_1.DecoratorContext {
31
+ methods = [
32
+ "contentType",
33
+ "description",
34
+ "examples",
35
+ "type",
36
+ "status",
37
+ "of",
38
+ "oneOf",
39
+ "allOf",
40
+ "anyOf",
41
+ "nested",
42
+ "header",
43
+ "headers",
44
+ "schema",
45
+ "title",
46
+ "groups",
47
+ "location"
48
+ ];
31
49
  constructor({ status, model }) {
32
50
  super();
33
- this.methods = [
34
- "contentType",
35
- "description",
36
- "examples",
37
- "type",
38
- "status",
39
- "of",
40
- "oneOf",
41
- "allOf",
42
- "anyOf",
43
- "nested",
44
- "header",
45
- "headers",
46
- "schema",
47
- "title",
48
- "groups",
49
- "location"
50
- ];
51
51
  this.model(model);
52
52
  this.status(status);
53
53
  }
@@ -106,10 +106,10 @@ class ReturnDecoratorContext extends DecoratorContext_1.DecoratorContext {
106
106
  this.addAction(() => {
107
107
  const schema = this.get("schema");
108
108
  if ((0, core_1.isCollection)(model)) {
109
- schema === null || schema === void 0 ? void 0 : schema.itemSchema({ type: types[0] });
109
+ schema?.itemSchema({ type: types[0] });
110
110
  }
111
111
  else {
112
- schema === null || schema === void 0 ? void 0 : schema.nestedGenerics.push(mapGenerics(types));
112
+ schema?.nestedGenerics.push(mapGenerics(types));
113
113
  }
114
114
  });
115
115
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"returns.js","sourceRoot":"","sources":["../../../../src/decorators/operations/returns.ts"],"names":[],"mappings":";;;AAAA,qCAWoB;AAEpB,2EAA0F;AAC1F,oEAA+D;AAC/D,kEAA6D;AAE7D,wDAAqE;AAErE,qEAA6D;AAC7D,2CAAwC;AAExC,iEAA4D;AAC5D,uDAAkD;AAgHlD;;GAEG;AACH,SAAS,MAAM,CAAC,IAAS;IACvB,OAAO,IAAA,eAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI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1B;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA+JD,SAAgB,OAAO,CAAC,MAAwB,EAAE,KAAqC;IACrF,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,MAAM;QACN,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAPD,0BAOC","sourcesContent":["import {\n decorateMethodsOf,\n decoratorTypeOf,\n DecoratorTypes,\n isArray,\n isCollection,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n isString,\n Type\n} from \"@tsed/core\";\nimport {OS3Example} from \"@tsed/openspec\";\nimport {getStatusMessage, HTTP_STATUS_MESSAGES} from \"../../constants/httpStatusMessages\";\nimport {DecoratorContext} from \"../../domain/DecoratorContext\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonResponse} from \"../../domain/JsonResponse\";\nimport {JsonSchema, JsonSchemaObject} from \"../../domain/JsonSchema\";\nimport {JsonHeader, JsonHeaders} from \"../../interfaces/JsonOpenSpec\";\nimport {getStatusModel} from \"../../utils/defineStatusModel\";\nimport {string} from \"../../utils/from\";\nimport {GenericValue} from \"../../utils/generics\";\nimport {isSuccessStatus} from \"../../utils/isSuccessStatus\";\nimport {mapHeaders} from \"../../utils/mapHeaders\";\n\nexport interface ReturnsChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n (target: Function): void;\n\n /**\n * Set a Content-Type for the current response\n * @param value\n * @constructor\n */\n ContentType(value: string): this;\n\n /**\n * Add a description\n * @param description\n */\n Description(description: string): this;\n\n /**\n * Add examples\n * @param examples\n */\n Examples(examples: Record<string, OS3Example>): this;\n\n Examples(examples: Record<string, any>): this;\n\n Examples(examples: any): this;\n\n /**\n * Change the model type\n * @param type\n */\n Type(type: Type<any> | any): this;\n\n /**\n * Change the status\n * @param status\n * @constructor\n */\n Status(status: string | number): this;\n\n /**\n * Add the nested types\n * @param types\n */\n Of(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n OneOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AllOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AnyOf(...types: GenericValue[]): this;\n\n /**\n * Declare a nested generic models\n * @param generics\n */\n Nested(...generics: GenericValue[]): this;\n\n /**\n * Add header.\n * @param key\n * @param value\n */\n Header(key: string, value: number | string | (JsonHeader & {value?: string | number | boolean})): this;\n\n /**\n * Add headers\n */\n Headers(headers: JsonHeaders): this;\n\n /**\n * Add location hea\n */\n Location(location: string, meta?: JsonHeader): this;\n\n /**\n * Assign partial schema\n * @param schema\n */\n Schema(schema: Partial<JsonSchemaObject> | JsonSchema): this;\n\n /**\n * Add an inline title for the return model.\n * @param title\n */\n Title(title: string): this;\n\n /**\n *\n * @param groups\n * @constructor\n */\n Groups(...groups: string[]): this;\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nfunction isEnum(type: any) {\n return isObject(type) && !(\"toJSON\" in type);\n}\n\nfunction mapGenerics(types: GenericValue[]) {\n return types.map((type) => {\n if (isEnum(type)) {\n return string().enum(Object.values(type));\n }\n return type;\n });\n}\n\n/**\n * @ignore\n */\nclass ReturnDecoratorContext extends DecoratorContext<ReturnsChainedDecorators> {\n readonly methods: string[] = [\n \"contentType\",\n \"description\",\n \"examples\",\n \"type\",\n \"status\",\n \"of\",\n \"oneOf\",\n \"allOf\",\n \"anyOf\",\n \"nested\",\n \"header\",\n \"headers\",\n \"schema\",\n \"title\",\n \"groups\",\n \"location\"\n ];\n\n constructor({status, model}: any) {\n super();\n\n this.model(model);\n this.status(status);\n }\n\n type(model: any) {\n return this.model(model);\n }\n\n model(model: any) {\n model && this.set(\"model\", model);\n return this;\n }\n\n status(status: number | string) {\n this.set(\"status\", status);\n\n if (status && getStatusMessage(status) && !this.get(\"description\")) {\n this.set(\"description\", getStatusMessage(status));\n\n if (!this.get(\"model\")) {\n this.model(getStatusModel(+status));\n }\n }\n\n return this;\n }\n\n headers(headers: JsonHeaders) {\n this.set(\"headers\", {\n ...(this.get(\"headers\") || {}),\n ...mapHeaders(headers)\n });\n\n return this;\n }\n\n header(key: string, value: string | JsonHeader) {\n return this.headers({[key]: value});\n }\n\n location(path: string, meta: JsonHeaders = {}) {\n this.headers({\n Location: {\n ...meta,\n value: path\n }\n });\n\n return this;\n }\n\n groups(...groups: string[]) {\n this.set(\"groups\", groups);\n return this;\n }\n\n nested(...generics: GenericValue[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n this.checkCollection(model);\n\n this.addAction((ctx) => {\n (this.get(\"schema\") as JsonSchema).nestedGenerics.push(mapGenerics(generics));\n });\n\n return this;\n }\n\n of(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n if (isCollection(model)) {\n schema?.itemSchema({type: types[0]});\n } else {\n schema?.nestedGenerics.push(mapGenerics(types));\n }\n });\n\n return this;\n }\n\n oneOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({oneOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n allOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({allOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n anyOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({anyOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n schema(partial: Partial<JsonSchemaObject>) {\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n schema!.assign(partial);\n });\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", isString(examples) ? [examples] : examples);\n return this;\n }\n\n title(title: string) {\n return this.schema({title});\n }\n\n protected checkPrimitive(model: any) {\n if (isPrimitiveOrPrimitiveClass(model)) {\n throw new Error(\"Returns.Of cannot be used with the following primitive classes: String, Number, Boolean\");\n }\n }\n\n protected checkCollection(model: any) {\n if (isCollection(model)) {\n throw new Error(\"Returns.Nested cannot be used with the following classes: Map, Set, Array, String, Number, Boolean\");\n }\n }\n\n protected getContentType() {\n const model = this.get(\"model\");\n let contentType = this.get(\"contentType\");\n\n if (model && !isPlainObject(model) && !isPrimitiveOrPrimitiveClass(model)) {\n contentType = contentType || \"application/json\";\n }\n\n return contentType;\n }\n\n protected getStatus() {\n return this.get(\"status\") || \"default\";\n }\n\n protected onInit(args: any[], decorator: any) {\n const type = decoratorTypeOf(args);\n switch (type) {\n case DecoratorTypes.METHOD:\n this.entity = JsonEntityStore.from(...args);\n if (this.entity.operation) {\n this.map();\n }\n break;\n case DecoratorTypes.CLASS:\n this.decoratorType = DecoratorTypes.CLASS;\n decorateMethodsOf(args[0], decorator);\n break;\n }\n }\n\n protected map() {\n const model = this.get(\"model\");\n const {entity, decoratorType} = this;\n const operation = this.entity.operation!;\n const currentStatus = this.getStatus();\n const response = operation.ensureResponseOf(currentStatus);\n const contentType = this.getContentType();\n\n let {description = response.get(\"description\")} = this.toObject();\n\n if (description) {\n description = decoratorType === DecoratorTypes.CLASS ? response.get(\"description\") || description : description;\n response.description(description);\n }\n\n const headers = this.getMergedKey(\"headers\", response.get(\"headers\"));\n\n if (headers) {\n response.headers(headers);\n }\n\n this.mapMedia(response);\n\n if (isSuccessStatus(this.get(\"status\")) || currentStatus === \"default\") {\n if (model) {\n entity.type = model;\n }\n }\n\n // additional info for OS2\n contentType && operation.addProduce(contentType);\n\n // run additional actions\n return this.runActions();\n }\n\n protected mapMedia(response: JsonResponse) {\n const contentType = this.getContentType();\n const model = this.get(\"model\");\n const media = response.getMedia(contentType || \"*/*\");\n const schema = media.get(\"schema\") || new JsonSchema({type: model});\n\n if (model) {\n if (isArray(model)) {\n schema.oneOf(model.map((type) => ({type})));\n } else {\n schema.type(model);\n }\n }\n\n this.set(\"schema\", schema);\n\n media.schema(schema);\n\n media.groups = this.get(\"groups\");\n\n const examples = this.get(\"examples\");\n\n if (examples) {\n media.examples(examples);\n }\n\n return media;\n }\n}\n\n/**\n * Add responses documentation for a specific status code.\n *\n * ## Usage\n *\n * Ts.ED v5/v6 API introducing the chaining decorator concept. Now a decorator like Returns can be used with another decorators like Description.\n *\n * ::: warning\n * v5 has a basic support of the chaining decorator to facilitate the migration to v6!\n * :::\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @Returns(404, String).Description(\"Not Found\")\n * @Returns(200, Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ::: tip\n * TypeScript and your IDE will discover automatically the chained decorators. But for more details you can look on @@ReturnsChainedDecorators@@ interface, to know\n * what chained decorators are available under Returns decorator.\n * :::\n *\n * This example will produce this documentation in swagger:\n *\n * ```json\n * {\n * \"responses\": {\n * \"404\": {\n * \"description\": \"Description\",\n * \"schema\": {\"type\": \"string\"}\n * },\n * \"2OO\": {\n * \"description\": \"Description\",\n * \"schema\": {\"$ref\": \"...\"}\n * }\n * }\n * }\n * ```\n *\n * ## Declaring an Array\n *\n * Use chained decorators to declare an array with model as following:\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/models\")\n * class ModelCtrl {\n * @Get(\"/\")\n * @Returns(200, Array).Of(Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {\n * }\n * }\n * ```\n *\n * Deprecated version:\n *\n * ```typescript\n * import {ReturnsArray} from \"@tsed/common\";\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @ReturnsArray(200, Model) // deprecated\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ### Declaring a generic model <Badge text=\"6+\"/>\n *\n * Sometime, it might be useful to use generic models. TypeScript doesn't store the generic type in the metadata. This is why we need to\n * declare explicitly the generic models with the decorators.\n *\n * One of the generic's usage, can be a paginated list. With Returns decorator it's now possible to declare generic type and generate the appropriate OpenSpec documentation.\n *\n * Starting with the pagination model, by using @@Generics@@ and @@CollectionOf@@:\n *\n * ```typescript\n * @Generics(\"T\")\n * class Pagination<T> {\n * @CollectionOf(\"T\")\n * data: T[];\n *\n * @Property()\n * totalCount: number;\n * }\n * ```\n *\n * Now, we need a model to be used with the generic Pagination model:\n *\n * ```typescript\n * class Product {\n * @Property()\n * id: string;\n *\n * @Property()\n * title: string;\n * }\n * ```\n *\n * Finally, we can use our models on a method as following:\n *\n * ```typescript\n * class Controller {\n * @OperationPath(\"POST\", \"/\")\n * @Returns(200, Pagination).Of(Product).Description(\"description\")\n * async method(): Promise<Pagination<Product> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * ### Declaring a nested generics models <Badge text=\"6+\"/>\n *\n * It's also possible to declare a nested generics models in order to have this type `Pagination<Submission<Product>>`:\n *\n * ```typescript\n * import {Generics, Property, Returns} from \"@tsed/schema\";\n * import {Post} from \"@tsed/common\";\n *\n * class Controller {\n * @Post(\"/\")\n * @Returns(200, Pagination).Of(Submission).Nested(Product).Description(\"description\")\n * async method(): Promise<Pagination<Submission<Product>> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * And here is the Submission model:\n *\n * ```typescript\n * import {Generics, Property} from \"@tsed/schema\";\n *\n * @Generics(\"T\")\n * class Submission<T> {\n * @Property()\n * _id: string;\n * @Property(\"T\")\n * data: T;\n * }\n * ```\n *\n * @param status\n * @param model\n * @decorator\n * @swagger\n * @schema\n * @response\n * @operation\n */\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[] | any): ReturnsChainedDecorators {\n const context = new ReturnDecoratorContext({\n status,\n model\n });\n\n return context.build();\n}\n"]}
1
+ {"version":3,"file":"returns.js","sourceRoot":"","sources":["../../../../src/decorators/operations/returns.ts"],"names":[],"mappings":";;;AAAA,qCAWoB;AAEpB,2EAA0F;AAC1F,oEAA+D;AAC/D,kEAA6D;AAE7D,wDAAqE;AAErE,qEAA6D;AAC7D,2CAAwC;AAExC,iEAA4D;AAC5D,uDAAkD;AAgHlD;;GAEG;AACH,SAAS,MAAM,CAAC,IAAS;IACvB,OAAO,IAAA,eAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,WAAW,CAAC,KAAqB;IACxC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE;YAChB,OAAO,IAAA,aAAM,GAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,sBAAuB,SAAQ,mCAA0C;IACpE,OAAO,GAAa;QAC3B,aAAa;QACb,aAAa;QACb,UAAU;QACV,MAAM;QACN,QAAQ;QACR,IAAI;QACJ,OAAO;QACP,OAAO;QACP,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,UAAU;KACX,CAAC;IAEF,YAAY,EAAC,MAAM,EAAE,KAAK,EAAM;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,KAAU;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC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B;SACF;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAErB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAEtC,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAC1B;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA+JD,SAAgB,OAAO,CAAC,MAAwB,EAAE,KAAqC;IACrF,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,MAAM;QACN,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAPD,0BAOC","sourcesContent":["import {\n decorateMethodsOf,\n decoratorTypeOf,\n DecoratorTypes,\n isArray,\n isCollection,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n isString,\n Type\n} from \"@tsed/core\";\nimport {OS3Example} from \"@tsed/openspec\";\nimport {getStatusMessage, HTTP_STATUS_MESSAGES} from \"../../constants/httpStatusMessages\";\nimport {DecoratorContext} from \"../../domain/DecoratorContext\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonResponse} from \"../../domain/JsonResponse\";\nimport {JsonSchema, JsonSchemaObject} from \"../../domain/JsonSchema\";\nimport {JsonHeader, JsonHeaders} from \"../../interfaces/JsonOpenSpec\";\nimport {getStatusModel} from \"../../utils/defineStatusModel\";\nimport {string} from \"../../utils/from\";\nimport {GenericValue} from \"../../utils/generics\";\nimport {isSuccessStatus} from \"../../utils/isSuccessStatus\";\nimport {mapHeaders} from \"../../utils/mapHeaders\";\n\nexport interface ReturnsChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n (target: Function): void;\n\n /**\n * Set a Content-Type for the current response\n * @param value\n * @constructor\n */\n ContentType(value: string): this;\n\n /**\n * Add a description\n * @param description\n */\n Description(description: string): this;\n\n /**\n * Add examples\n * @param examples\n */\n Examples(examples: Record<string, OS3Example>): this;\n\n Examples(examples: Record<string, any>): this;\n\n Examples(examples: any): this;\n\n /**\n * Change the model type\n * @param type\n */\n Type(type: Type<any> | any): this;\n\n /**\n * Change the status\n * @param status\n * @constructor\n */\n Status(status: string | number): this;\n\n /**\n * Add the nested types\n * @param types\n */\n Of(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n OneOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AllOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AnyOf(...types: GenericValue[]): this;\n\n /**\n * Declare a nested generic models\n * @param generics\n */\n Nested(...generics: GenericValue[]): this;\n\n /**\n * Add header.\n * @param key\n * @param value\n */\n Header(key: string, value: number | string | (JsonHeader & {value?: string | number | boolean})): this;\n\n /**\n * Add headers\n */\n Headers(headers: JsonHeaders): this;\n\n /**\n * Add location hea\n */\n Location(location: string, meta?: JsonHeader): this;\n\n /**\n * Assign partial schema\n * @param schema\n */\n Schema(schema: Partial<JsonSchemaObject> | JsonSchema): this;\n\n /**\n * Add an inline title for the return model.\n * @param title\n */\n Title(title: string): this;\n\n /**\n *\n * @param groups\n * @constructor\n */\n Groups(...groups: string[]): this;\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nfunction isEnum(type: any) {\n return isObject(type) && !(\"toJSON\" in type);\n}\n\nfunction mapGenerics(types: GenericValue[]) {\n return types.map((type) => {\n if (isEnum(type)) {\n return string().enum(Object.values(type));\n }\n return type;\n });\n}\n\n/**\n * @ignore\n */\nclass ReturnDecoratorContext extends DecoratorContext<ReturnsChainedDecorators> {\n readonly methods: string[] = [\n \"contentType\",\n \"description\",\n \"examples\",\n \"type\",\n \"status\",\n \"of\",\n \"oneOf\",\n \"allOf\",\n \"anyOf\",\n \"nested\",\n \"header\",\n \"headers\",\n \"schema\",\n \"title\",\n \"groups\",\n \"location\"\n ];\n\n constructor({status, model}: any) {\n super();\n\n this.model(model);\n this.status(status);\n }\n\n type(model: any) {\n return this.model(model);\n }\n\n model(model: any) {\n model && this.set(\"model\", model);\n return this;\n }\n\n status(status: number | string) {\n this.set(\"status\", status);\n\n if (status && getStatusMessage(status) && !this.get(\"description\")) {\n this.set(\"description\", getStatusMessage(status));\n\n if (!this.get(\"model\")) {\n this.model(getStatusModel(+status));\n }\n }\n\n return this;\n }\n\n headers(headers: JsonHeaders) {\n this.set(\"headers\", {\n ...(this.get(\"headers\") || {}),\n ...mapHeaders(headers)\n });\n\n return this;\n }\n\n header(key: string, value: string | JsonHeader) {\n return this.headers({[key]: value});\n }\n\n location(path: string, meta: JsonHeaders = {}) {\n this.headers({\n Location: {\n ...meta,\n value: path\n }\n });\n\n return this;\n }\n\n groups(...groups: string[]) {\n this.set(\"groups\", groups);\n return this;\n }\n\n nested(...generics: GenericValue[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n this.checkCollection(model);\n\n this.addAction((ctx) => {\n (this.get(\"schema\") as JsonSchema).nestedGenerics.push(mapGenerics(generics));\n });\n\n return this;\n }\n\n of(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n if (isCollection(model)) {\n schema?.itemSchema({type: types[0]});\n } else {\n schema?.nestedGenerics.push(mapGenerics(types));\n }\n });\n\n return this;\n }\n\n oneOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({oneOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n allOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({allOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n anyOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({anyOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n schema(partial: Partial<JsonSchemaObject>) {\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n schema!.assign(partial);\n });\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", isString(examples) ? [examples] : examples);\n return this;\n }\n\n title(title: string) {\n return this.schema({title});\n }\n\n protected checkPrimitive(model: any) {\n if (isPrimitiveOrPrimitiveClass(model)) {\n throw new Error(\"Returns.Of cannot be used with the following primitive classes: String, Number, Boolean\");\n }\n }\n\n protected checkCollection(model: any) {\n if (isCollection(model)) {\n throw new Error(\"Returns.Nested cannot be used with the following classes: Map, Set, Array, String, Number, Boolean\");\n }\n }\n\n protected getContentType() {\n const model = this.get(\"model\");\n let contentType = this.get(\"contentType\");\n\n if (model && !isPlainObject(model) && !isPrimitiveOrPrimitiveClass(model)) {\n contentType = contentType || \"application/json\";\n }\n\n return contentType;\n }\n\n protected getStatus() {\n return this.get(\"status\") || \"default\";\n }\n\n protected onInit(args: any[], decorator: any) {\n const type = decoratorTypeOf(args);\n switch (type) {\n case DecoratorTypes.METHOD:\n this.entity = JsonEntityStore.from(...args);\n if (this.entity.operation) {\n this.map();\n }\n break;\n case DecoratorTypes.CLASS:\n this.decoratorType = DecoratorTypes.CLASS;\n decorateMethodsOf(args[0], decorator);\n break;\n }\n }\n\n protected map() {\n const model = this.get(\"model\");\n const {entity, decoratorType} = this;\n const operation = this.entity.operation!;\n const currentStatus = this.getStatus();\n const response = operation.ensureResponseOf(currentStatus);\n const contentType = this.getContentType();\n\n let {description = response.get(\"description\")} = this.toObject();\n\n if (description) {\n description = decoratorType === DecoratorTypes.CLASS ? response.get(\"description\") || description : description;\n response.description(description);\n }\n\n const headers = this.getMergedKey(\"headers\", response.get(\"headers\"));\n\n if (headers) {\n response.headers(headers);\n }\n\n this.mapMedia(response);\n\n if (isSuccessStatus(this.get(\"status\")) || currentStatus === \"default\") {\n if (model) {\n entity.type = model;\n }\n }\n\n // additional info for OS2\n contentType && operation.addProduce(contentType);\n\n // run additional actions\n return this.runActions();\n }\n\n protected mapMedia(response: JsonResponse) {\n const contentType = this.getContentType();\n const model = this.get(\"model\");\n const media = response.getMedia(contentType || \"*/*\");\n const schema = media.get(\"schema\") || new JsonSchema({type: model});\n\n if (model) {\n if (isArray(model)) {\n schema.oneOf(model.map((type) => ({type})));\n } else {\n schema.type(model);\n }\n }\n\n this.set(\"schema\", schema);\n\n media.schema(schema);\n\n media.groups = this.get(\"groups\");\n\n const examples = this.get(\"examples\");\n\n if (examples) {\n media.examples(examples);\n }\n\n return media;\n }\n}\n\n/**\n * Add responses documentation for a specific status code.\n *\n * ## Usage\n *\n * Ts.ED v5/v6 API introducing the chaining decorator concept. Now a decorator like Returns can be used with another decorators like Description.\n *\n * ::: warning\n * v5 has a basic support of the chaining decorator to facilitate the migration to v6!\n * :::\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @Returns(404, String).Description(\"Not Found\")\n * @Returns(200, Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ::: tip\n * TypeScript and your IDE will discover automatically the chained decorators. But for more details you can look on @@ReturnsChainedDecorators@@ interface, to know\n * what chained decorators are available under Returns decorator.\n * :::\n *\n * This example will produce this documentation in swagger:\n *\n * ```json\n * {\n * \"responses\": {\n * \"404\": {\n * \"description\": \"Description\",\n * \"schema\": {\"type\": \"string\"}\n * },\n * \"2OO\": {\n * \"description\": \"Description\",\n * \"schema\": {\"$ref\": \"...\"}\n * }\n * }\n * }\n * ```\n *\n * ## Declaring an Array\n *\n * Use chained decorators to declare an array with model as following:\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/models\")\n * class ModelCtrl {\n * @Get(\"/\")\n * @Returns(200, Array).Of(Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {\n * }\n * }\n * ```\n *\n * Deprecated version:\n *\n * ```typescript\n * import {ReturnsArray} from \"@tsed/common\";\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @ReturnsArray(200, Model) // deprecated\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ### Declaring a generic model <Badge text=\"6+\"/>\n *\n * Sometime, it might be useful to use generic models. TypeScript doesn't store the generic type in the metadata. This is why we need to\n * declare explicitly the generic models with the decorators.\n *\n * One of the generic's usage, can be a paginated list. With Returns decorator it's now possible to declare generic type and generate the appropriate OpenSpec documentation.\n *\n * Starting with the pagination model, by using @@Generics@@ and @@CollectionOf@@:\n *\n * ```typescript\n * @Generics(\"T\")\n * class Pagination<T> {\n * @CollectionOf(\"T\")\n * data: T[];\n *\n * @Property()\n * totalCount: number;\n * }\n * ```\n *\n * Now, we need a model to be used with the generic Pagination model:\n *\n * ```typescript\n * class Product {\n * @Property()\n * id: string;\n *\n * @Property()\n * title: string;\n * }\n * ```\n *\n * Finally, we can use our models on a method as following:\n *\n * ```typescript\n * class Controller {\n * @OperationPath(\"POST\", \"/\")\n * @Returns(200, Pagination).Of(Product).Description(\"description\")\n * async method(): Promise<Pagination<Product> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * ### Declaring a nested generics models <Badge text=\"6+\"/>\n *\n * It's also possible to declare a nested generics models in order to have this type `Pagination<Submission<Product>>`:\n *\n * ```typescript\n * import {Generics, Property, Returns} from \"@tsed/schema\";\n * import {Post} from \"@tsed/common\";\n *\n * class Controller {\n * @Post(\"/\")\n * @Returns(200, Pagination).Of(Submission).Nested(Product).Description(\"description\")\n * async method(): Promise<Pagination<Submission<Product>> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * And here is the Submission model:\n *\n * ```typescript\n * import {Generics, Property} from \"@tsed/schema\";\n *\n * @Generics(\"T\")\n * class Submission<T> {\n * @Property()\n * _id: string;\n * @Property(\"T\")\n * data: T;\n * }\n * ```\n *\n * @param status\n * @param model\n * @decorator\n * @swagger\n * @schema\n * @response\n * @operation\n */\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[] | any): ReturnsChainedDecorators {\n const context = new ReturnDecoratorContext({\n status,\n model\n });\n\n return context.build();\n}\n"]}
@@ -5,10 +5,7 @@ const DecoratorContext_1 = require("../../domain/DecoratorContext");
5
5
  const mapRouteOptions_1 = require("../../utils/mapRouteOptions");
6
6
  const httpMethods_1 = require("../../constants/httpMethods");
7
7
  class RouteDecoratorContext extends DecoratorContext_1.DecoratorContext {
8
- constructor() {
9
- super(...arguments);
10
- this.methods = ["name", "description", "summary", "method", "id", "use", "useAfter", "useBefore"];
11
- }
8
+ methods = ["name", "description", "summary", "method", "id", "use", "useAfter", "useBefore"];
12
9
  beforeInit() {
13
10
  const path = this.get("path");
14
11
  const method = httpMethods_1.OperationMethods[this.get("method")] || httpMethods_1.OperationMethods.CUSTOM;
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/decorators/operations/route.ts"],"names":[],"mappings":";;;AAAA,oEAA+D;AAC/D,iEAA4D;AAC5D,6DAA6D;AAkD7D,MAAM,qBAAsB,SAAQ,mCAAwC;IAA5E;;QACW,YAAO,GAAa,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAmClH,CAAC;IAhCW,UAAU;QAClB,MAAM,IAAI,GAAW,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtC,MAAM,MAAM,GAAW,8BAAgB,CAAC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AM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAFD,oBAEC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,KAAK,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACrE,OAAO,KAAK,CAAC,GAAG,CAAC,8BAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC;AAFD,sBAEC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,OAAO,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACvE,OAAO,KAAK,CAAC,GAAG,CAAC,8BAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC;AAFD,0BAEC","sourcesContent":["import {DecoratorContext} from \"../../domain/DecoratorContext\";\nimport {mapRouteOptions} from \"../../utils/mapRouteOptions\";\nimport {OperationMethods} from \"../../constants/httpMethods\";\nimport {JsonMethodStore} from \"../../domain/JsonMethodStore\";\n\nexport interface RouteChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n /**\n * @param string\n * @constructor\n */\n Path(string: string): this;\n\n /**\n * Set the operation method\n * @param method\n */\n Method(method: OperationMethods | string): this;\n\n /**\n * Set the operation id\n * @param id\n */\n Id(id: string): this;\n\n /**\n * Set the operation id\n * @param name\n */\n Name(name: string): this;\n\n /**\n *\n * @param description\n */\n Description(description: string): this;\n\n /**\n * Summary\n * @constructor\n * @param Summary\n */\n Summary(Summary: string): this;\n\n Use(...args: any[]): this;\n\n UseAfter(...args: any[]): this;\n\n UseBefore(...args: any[]): this;\n}\n\nclass RouteDecoratorContext extends DecoratorContext<RouteChainedDecorators> {\n readonly methods: string[] = [\"name\", \"description\", \"summary\", \"method\", \"id\", \"use\", \"useAfter\", \"useBefore\"];\n protected entity: JsonMethodStore;\n\n protected beforeInit() {\n const path: string = this.get(\"path\");\n const method: string = OperationMethods[this.get(\"method\") as OperationMethods] || OperationMethods.CUSTOM;\n\n path && this.entity.operation.addOperationPath(method, path);\n }\n\n protected onMapKey(key: string, value: any) {\n switch (key) {\n case \"name\":\n case \"id\":\n this.entity.operation.operationId(value);\n return;\n case \"summary\":\n this.entity.operation.summary(value);\n return;\n case \"description\":\n this.entity.operation.description(value);\n return;\n case \"use\":\n this.entity.use(value);\n return;\n case \"useAfter\":\n this.entity.after(value);\n return;\n case \"useBefore\":\n this.entity.before(value);\n return;\n }\n\n return super.onMapKey(key, value);\n }\n}\n\n/**\n * Describe a new route with a method and path.\n *\n * ```typescript\n * @Controller('/')\n * export class Ctrl {\n *\n * @Route('GET', '/')\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param method\n * @param path\n * @param args\n * @decorator\n * @operation\n */\nexport function Route(method: string, path: string, ...args: any[]): RouteChainedDecorators;\nexport function Route(...args: any[]): RouteChainedDecorators;\nexport function Route(...args: any[]): RouteChainedDecorators {\n const routeOptions = mapRouteOptions(args);\n\n const context = new RouteDecoratorContext(routeOptions);\n\n return context.build();\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function All(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.ALL, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Get(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.GET, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Post(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.POST, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Put(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.PUT, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Delete(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.DELETE, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Head(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.HEAD, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Patch(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.PATCH, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Options(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.OPTIONS, path].concat(args));\n}\n"]}
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/decorators/operations/route.ts"],"names":[],"mappings":";;;AAAA,oEAA+D;AAC/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W;IACtE,OAAO,KAAK,CAAC,GAAG,CAAC,8BAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC;AAFD,wBAEC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,IAAI,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACpE,OAAO,KAAK,CAAC,GAAG,CAAC,8BAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAFD,oBAEC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,KAAK,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACrE,OAAO,KAAK,CAAC,GAAG,CAAC,8BAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC;AAFD,sBAEC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,OAAO,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACvE,OAAO,KAAK,CAAC,GAAG,CAAC,8BAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC;AAFD,0BAEC","sourcesContent":["import {DecoratorContext} from \"../../domain/DecoratorContext\";\nimport {mapRouteOptions} from \"../../utils/mapRouteOptions\";\nimport {OperationMethods} from \"../../constants/httpMethods\";\nimport {JsonMethodStore} from \"../../domain/JsonMethodStore\";\n\nexport interface RouteChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n /**\n * @param string\n * @constructor\n */\n Path(string: string): this;\n\n /**\n * Set the operation method\n * @param method\n */\n Method(method: OperationMethods | string): this;\n\n /**\n * Set the operation id\n * @param id\n */\n Id(id: string): this;\n\n /**\n * Set the operation id\n * @param name\n */\n Name(name: string): this;\n\n /**\n *\n * @param description\n */\n Description(description: string): this;\n\n /**\n * Summary\n * @constructor\n * @param Summary\n */\n Summary(Summary: string): this;\n\n Use(...args: any[]): this;\n\n UseAfter(...args: any[]): this;\n\n UseBefore(...args: any[]): this;\n}\n\nclass RouteDecoratorContext extends DecoratorContext<RouteChainedDecorators> {\n readonly methods: string[] = [\"name\", \"description\", \"summary\", \"method\", \"id\", \"use\", \"useAfter\", \"useBefore\"];\n protected declare entity: JsonMethodStore;\n\n protected beforeInit() {\n const path: string = this.get(\"path\");\n const method: string = OperationMethods[this.get(\"method\") as OperationMethods] || OperationMethods.CUSTOM;\n\n path && this.entity.operation.addOperationPath(method, path);\n }\n\n protected onMapKey(key: string, value: any) {\n switch (key) {\n case \"name\":\n case \"id\":\n this.entity.operation.operationId(value);\n return;\n case \"summary\":\n this.entity.operation.summary(value);\n return;\n case \"description\":\n this.entity.operation.description(value);\n return;\n case \"use\":\n this.entity.use(value);\n return;\n case \"useAfter\":\n this.entity.after(value);\n return;\n case \"useBefore\":\n this.entity.before(value);\n return;\n }\n\n return super.onMapKey(key, value);\n }\n}\n\n/**\n * Describe a new route with a method and path.\n *\n * ```typescript\n * @Controller('/')\n * export class Ctrl {\n *\n * @Route('GET', '/')\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param method\n * @param path\n * @param args\n * @decorator\n * @operation\n */\nexport function Route(method: string, path: string, ...args: any[]): RouteChainedDecorators;\nexport function Route(...args: any[]): RouteChainedDecorators;\nexport function Route(...args: any[]): RouteChainedDecorators {\n const routeOptions = mapRouteOptions(args);\n\n const context = new RouteDecoratorContext(routeOptions);\n\n return context.build();\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function All(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.ALL, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Get(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.GET, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Post(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.POST, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Put(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.PUT, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Delete(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.DELETE, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Head(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.HEAD, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Patch(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.PATCH, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Options(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.OPTIONS, path].concat(args));\n}\n"]}
@@ -2,15 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DecoratorContext = void 0;
4
4
  const core_1 = require("@tsed/core");
5
- const pascal_case_1 = require("pascal-case");
5
+ const change_case_1 = require("change-case");
6
6
  const JsonEntityStore_1 = require("./JsonEntityStore");
7
7
  /**
8
8
  * @ignore
9
9
  */
10
10
  class DecoratorContext extends Map {
11
+ methods;
12
+ decoratorType;
13
+ entity;
14
+ actions = [];
11
15
  constructor(opts = {}) {
12
16
  super();
13
- this.actions = [];
14
17
  Object.entries(opts).forEach(([key, value]) => {
15
18
  this.set(key, value);
16
19
  });
@@ -33,7 +36,7 @@ class DecoratorContext extends Map {
33
36
  });
34
37
  };
35
38
  this.methods.forEach((name) => {
36
- decorator[(0, pascal_case_1.pascalCase)(name)] = wrapKey(name);
39
+ decorator[(0, change_case_1.pascalCase)(name)] = wrapKey(name);
37
40
  });
38
41
  return decorator;
39
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DecoratorContext.js","sourceRoot":"","sources":["../../../src/domain/DecoratorContext.ts"],"names":[],"mappings":";;;AAAA,qCAA+D;AAC/D,6CAAuC;AACvC,uDAAkD;AASlD;;GAEG;AACH,MAAsB,gBAA0B,SAAQ,GAAgB;IAMtE,YAAY,OAAY,EAAE;QACxB,KAAK,EAAE,CAAC;QAHA,YAAO,GAA6B,EAAE,CAAC;QAK/C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC5C,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK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,CAAC;IAES,UAAU,KAAI,CAAC;IAEf,SAAS,KAAI,CAAC;CACzB;AApGD,4CAoGC","sourcesContent":["import {DecoratorParameters, DecoratorTypes} from \"@tsed/core\";\nimport {pascalCase} from \"pascal-case\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\n\n/**\n * @ignore\n */\nexport interface DecoratorActionHandler {\n (ctx: Map<string, any>): void;\n}\n\n/**\n * @ignore\n */\nexport abstract class DecoratorContext<T = any> extends Map<string, any> {\n readonly methods: string[];\n protected decoratorType: DecoratorTypes;\n protected entity: JsonEntityStore;\n protected actions: DecoratorActionHandler[] = [];\n\n constructor(opts: any = {}) {\n super();\n\n Object.entries(opts).forEach(([key, value]) => {\n this.set(key, value);\n });\n }\n\n addAction(cb: DecoratorActionHandler) {\n this.actions.push(cb);\n return this;\n }\n\n build(): T {\n const decorator: any = (...args: DecoratorParameters) => this.bind(args, decorator);\n\n const wrap = (cb: any) => {\n return (...args: any[]) => {\n cb(...args);\n return decorator;\n };\n };\n\n const wrapKey = (key: string) => {\n return wrap((...values: any[]) => {\n key in this ? (this as any)[key](...values) : this.set(key, values[0]);\n });\n };\n\n this.methods.forEach((name) => {\n decorator[pascalCase(name)] = wrapKey(name);\n });\n\n return decorator as unknown as T;\n }\n\n toObject(): any {\n return [...this.entries()].reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: value\n };\n }, {});\n }\n\n getMergedKey(key: string, defaultValue: any) {\n let value = this.get(key) || defaultValue;\n\n if (!value) {\n return;\n }\n\n if (this.decoratorType === DecoratorTypes.CLASS) {\n value = {\n ...value,\n ...(defaultValue || {})\n };\n }\n\n return {\n ...(defaultValue || {}),\n ...value\n };\n }\n\n protected bind(args: DecoratorParameters, decorator: any) {\n this.entity = JsonEntityStore.from(...args);\n\n this.beforeInit();\n this.onInit(args, decorator);\n this.afterInit();\n }\n\n protected onInit(args: DecoratorParameters, decorator: any): void {\n this.forEach((value, key) => {\n this.onMapKey(key, value);\n });\n }\n\n protected onMapKey(key: string, value: any): void {\n this.entity.set(key, value);\n }\n\n protected runActions() {\n this.actions.forEach((action: any) => {\n action(this);\n });\n\n return this;\n }\n\n protected beforeInit() {}\n\n protected afterInit() {}\n}\n"]}
1
+ {"version":3,"file":"DecoratorContext.js","sourceRoot":"","sources":["../../../src/domain/DecoratorContext.ts"],"names":[],"mappings":";;;AAAA,qCAA+D;AAC/D,6CAAuC;AACvC,uDAAkD;AASlD;;GAEG;AACH,MAAsB,gBAA0B,SAAQ,GAAgB;IAC7D,OAAO,CAAW;IACjB,aAAa,CAAiB;IAC9B,MAAM,CAAkB;IACxB,OAAO,GAA6B,EAAE,CAAC;IAEjD,YAAY,OAAY,EAAE;QACxB,KAAK,EAAE,CAAC;QAER,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC5C,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,SAAS,CAAC,EAA0B;QAClC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,MAAM,SAAS,GAAQ,CAAC,GAAG,IAAyB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAEpF,MAAM,IAAI,GAAG,CAAC,EAAO,EAAE,EAAE;YACvB,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;gBACxB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;gBACZ,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE;YAC9B,OAAO,IAAI,CAAC,CAAC,GAAG,MAAa,EAAE,EAAE;gBAC/B,GAAG,IAAI,IAAI,CAAC,CA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E,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAES,MAAM,CAAC,IAAyB,EAAE,SAAc;QACxD,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC1B,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;IAES,QAAQ,CAAC,GAAW,EAAE,KAAU;QACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAES,UAAU;QAClB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;YACnC,MAAM,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAES,UAAU,KAAI,CAAC;IAEf,SAAS,KAAI,CAAC;CACzB;AApGD,4CAoGC","sourcesContent":["import {DecoratorParameters, DecoratorTypes} from \"@tsed/core\";\nimport {pascalCase} from \"change-case\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\n\n/**\n * @ignore\n */\nexport interface DecoratorActionHandler {\n (ctx: Map<string, any>): void;\n}\n\n/**\n * @ignore\n */\nexport abstract class DecoratorContext<T = any> extends Map<string, any> {\n readonly methods: string[];\n protected decoratorType: DecoratorTypes;\n protected entity: JsonEntityStore;\n protected actions: DecoratorActionHandler[] = [];\n\n constructor(opts: any = {}) {\n super();\n\n Object.entries(opts).forEach(([key, value]) => {\n this.set(key, value);\n });\n }\n\n addAction(cb: DecoratorActionHandler) {\n this.actions.push(cb);\n return this;\n }\n\n build(): T {\n const decorator: any = (...args: DecoratorParameters) => this.bind(args, decorator);\n\n const wrap = (cb: any) => {\n return (...args: any[]) => {\n cb(...args);\n return decorator;\n };\n };\n\n const wrapKey = (key: string) => {\n return wrap((...values: any[]) => {\n key in this ? (this as any)[key](...values) : this.set(key, values[0]);\n });\n };\n\n this.methods.forEach((name) => {\n decorator[pascalCase(name)] = wrapKey(name);\n });\n\n return decorator as unknown as T;\n }\n\n toObject(): any {\n return [...this.entries()].reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: value\n };\n }, {});\n }\n\n getMergedKey(key: string, defaultValue: any) {\n let value = this.get(key) || defaultValue;\n\n if (!value) {\n return;\n }\n\n if (this.decoratorType === DecoratorTypes.CLASS) {\n value = {\n ...value,\n ...(defaultValue || {})\n };\n }\n\n return {\n ...(defaultValue || {}),\n ...value\n };\n }\n\n protected bind(args: DecoratorParameters, decorator: any) {\n this.entity = JsonEntityStore.from(...args);\n\n this.beforeInit();\n this.onInit(args, decorator);\n this.afterInit();\n }\n\n protected onInit(args: DecoratorParameters, decorator: any): void {\n this.forEach((value, key) => {\n this.onMapKey(key, value);\n });\n }\n\n protected onMapKey(key: string, value: any): void {\n this.entity.set(key, value);\n }\n\n protected runActions() {\n this.actions.forEach((action: any) => {\n action(this);\n });\n\n return this;\n }\n\n protected beforeInit() {}\n\n protected afterInit() {}\n}\n"]}
@@ -7,13 +7,10 @@ const JsonEntityStore_1 = require("./JsonEntityStore");
7
7
  const JsonSchema_1 = require("./JsonSchema");
8
8
  const jsonEntityComponent_1 = require("../decorators/config/jsonEntityComponent");
9
9
  let JsonClassStore = class JsonClassStore extends JsonEntityStore_1.JsonEntityStore {
10
- constructor() {
11
- super(...arguments);
12
- /**
13
- * List of children JsonEntityStore (properties or methods or params)
14
- */
15
- this.children = new Map();
16
- }
10
+ /**
11
+ * List of children JsonEntityStore (properties or methods or params)
12
+ */
13
+ children = new Map();
17
14
  get path() {
18
15
  return this.store.get("path", "/");
19
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"JsonClassStore.js","sourceRoot":"","sources":["../../../src/domain/JsonClassStore.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAG1C,uDAA0E;AAC1E,6CAAwC;AACxC,kFAA6E;AAG7E,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,iCAAe;IAAnD;;QACE;;WAEG;QACM,aAAQ,GAA8D,IAAI,GAAG,EAAE,CAAC;IAqB3F,CAAC;IAnBC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,IAAI,CAAC,IAAY;QACnB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAES,KAAK;QACb,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7B;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QAElC,IAAI,CAAC,OAAO,GAAG,uBAAU,CAAC,IAAI,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAzBY,cAAc;IAD1B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,KAAK,CAAC;GAC7B,cAAc,CAyB1B;AAzBY,wCAAc","sourcesContent":["import {DecoratorTypes} from \"@tsed/core\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport type {JsonPropertyStore} from \"./JsonPropertyStore\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\n@JsonEntityComponent(DecoratorTypes.CLASS)\nexport class JsonClassStore extends JsonEntityStore {\n /**\n * List of children JsonEntityStore (properties or methods or params)\n */\n readonly children: Map<string | number, JsonMethodStore | JsonPropertyStore> = new Map();\n\n get path() {\n return this.store.get(\"path\", \"/\");\n }\n\n set path(path: string) {\n this.store.set(\"path\", path);\n }\n\n protected build() {\n if (!this._type) {\n this.buildType(this.target);\n }\n\n this._type = this._type || Object;\n\n this._schema = JsonSchema.from({\n type: this.type\n });\n }\n}\n"]}
1
+ {"version":3,"file":"JsonClassStore.js","sourceRoot":"","sources":["../../../src/domain/JsonClassStore.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAG1C,uDAA0E;AAC1E,6CAAwC;AACxC,kFAA6E;AAG7E,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,iCAAe;IACjD;;OAEG;IACM,QAAQ,GAA8D,IAAI,GAAG,EAAE,CAAC;IAEzF,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,IAAI,CAAC,IAAY;QACnB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAES,KAAK;QACb,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7B;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QAElC,IAAI,CAAC,OAAO,GAAG,uBAAU,CAAC,IAAI,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAzBY,cAAc;IAD1B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,KAAK,CAAC;GAC7B,cAAc,CAyB1B;AAzBY,wCAAc","sourcesContent":["import {DecoratorTypes} from \"@tsed/core\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport type {JsonPropertyStore} from \"./JsonPropertyStore\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\n@JsonEntityComponent(DecoratorTypes.CLASS)\nexport class JsonClassStore extends JsonEntityStore {\n /**\n * List of children JsonEntityStore (properties or methods or params)\n */\n readonly children: Map<string | number, JsonMethodStore | JsonPropertyStore> = new Map();\n\n get path() {\n return this.store.get(\"path\", \"/\");\n }\n\n set path(path: string) {\n this.store.set(\"path\", path);\n }\n\n protected build() {\n if (!this._type) {\n this.buildType(this.target);\n }\n\n this._type = this._type || Object;\n\n this._schema = JsonSchema.from({\n type: this.type\n });\n }\n}\n"]}
@@ -7,8 +7,44 @@ const core_1 = require("@tsed/core");
7
7
  */
8
8
  exports.JsonEntitiesContainer = new Map();
9
9
  class JsonEntityStore {
10
+ /**
11
+ * Original property key decorated by the decorator
12
+ */
13
+ propertyKey;
14
+ /**
15
+ * Alias of the property
16
+ */
17
+ propertyName;
18
+ /**
19
+ * Parameter index
20
+ */
21
+ index;
22
+ /**
23
+ * Method's descriptor
24
+ */
25
+ descriptor;
26
+ /**
27
+ * Decorator type used to declare the JsonSchemaStore.
28
+ */
29
+ decoratorType;
30
+ /**
31
+ * Type of the collection (Array, Map, Set, etc...)
32
+ */
33
+ collectionType;
34
+ token;
35
+ store;
36
+ isStore = true;
37
+ parent;
38
+ target;
39
+ /**
40
+ *
41
+ */
42
+ _type;
43
+ /**
44
+ * Ref to JsonSchema
45
+ */
46
+ _schema;
10
47
  constructor(options) {
11
- this.isStore = true;
12
48
  const { target, propertyKey, descriptor, index, decoratorType } = options;
13
49
  this.target = target;
14
50
  this.propertyKey = propertyKey;