@tsed/schema 6.114.17 → 6.115.1

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 (110) 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/common/description.js +1 -2
  8. package/lib/cjs/decorators/common/description.js.map +1 -1
  9. package/lib/cjs/decorators/operations/redirect.js +1 -2
  10. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  11. package/lib/cjs/decorators/operations/returns.js +20 -20
  12. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  13. package/lib/cjs/decorators/operations/route.js +1 -4
  14. package/lib/cjs/decorators/operations/route.js.map +1 -1
  15. package/lib/cjs/domain/DecoratorContext.js +4 -1
  16. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  17. package/lib/cjs/domain/JsonClassStore.js +4 -7
  18. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  19. package/lib/cjs/domain/JsonEntityStore.js +37 -1
  20. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  21. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  22. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  23. package/lib/cjs/domain/JsonMethodStore.js +12 -12
  24. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  25. package/lib/cjs/domain/JsonOperation.js +12 -16
  26. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  27. package/lib/cjs/domain/JsonOperationPathsMap.js +1 -4
  28. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  29. package/lib/cjs/domain/JsonOperationRoute.js +8 -6
  30. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  31. package/lib/cjs/domain/JsonParameter.js +4 -4
  32. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  33. package/lib/cjs/domain/JsonParameterStore.js +12 -5
  34. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  35. package/lib/cjs/domain/JsonPropertyStore.js +1 -4
  36. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  37. package/lib/cjs/domain/JsonResponse.js +3 -6
  38. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  39. package/lib/cjs/domain/JsonSchema.js +58 -60
  40. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  41. package/lib/cjs/hooks/alterIgnore.js +2 -3
  42. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  43. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  44. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  45. package/lib/cjs/utils/getJsonSchema.js +1 -2
  46. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  47. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  48. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  49. package/lib/cjs/utils/mapNullableType.js +1 -1
  50. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  51. package/lib/cjs/utils/mergeOperation.js +1 -2
  52. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  53. package/lib/cjs/utils/transformToOS2.js +2 -2
  54. package/lib/cjs/utils/transformToOS2.js.map +1 -1
  55. package/lib/esm/components/lazyRefMapper.js +1 -2
  56. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  57. package/lib/esm/components/objectMapper.js +1 -1
  58. package/lib/esm/components/objectMapper.js.map +1 -1
  59. package/lib/esm/constants/httpStatusMessages.js +2 -4
  60. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  61. package/lib/esm/decorators/common/description.js +1 -2
  62. package/lib/esm/decorators/common/description.js.map +1 -1
  63. package/lib/esm/decorators/operations/redirect.js +1 -2
  64. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  65. package/lib/esm/decorators/operations/returns.js +20 -20
  66. package/lib/esm/decorators/operations/returns.js.map +1 -1
  67. package/lib/esm/decorators/operations/route.js +1 -4
  68. package/lib/esm/decorators/operations/route.js.map +1 -1
  69. package/lib/esm/domain/DecoratorContext.js +4 -1
  70. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  71. package/lib/esm/domain/JsonClassStore.js +4 -7
  72. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  73. package/lib/esm/domain/JsonEntityStore.js +37 -1
  74. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  75. package/lib/esm/domain/JsonLazyRef.js +2 -1
  76. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  77. package/lib/esm/domain/JsonMethodStore.js +12 -12
  78. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  79. package/lib/esm/domain/JsonOperation.js +12 -16
  80. package/lib/esm/domain/JsonOperation.js.map +1 -1
  81. package/lib/esm/domain/JsonOperationPathsMap.js +1 -4
  82. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  83. package/lib/esm/domain/JsonOperationRoute.js +8 -6
  84. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  85. package/lib/esm/domain/JsonParameter.js +4 -4
  86. package/lib/esm/domain/JsonParameter.js.map +1 -1
  87. package/lib/esm/domain/JsonParameterStore.js +12 -5
  88. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  89. package/lib/esm/domain/JsonPropertyStore.js +1 -4
  90. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  91. package/lib/esm/domain/JsonResponse.js +3 -6
  92. package/lib/esm/domain/JsonResponse.js.map +1 -1
  93. package/lib/esm/domain/JsonSchema.js +58 -60
  94. package/lib/esm/domain/JsonSchema.js.map +1 -1
  95. package/lib/esm/hooks/alterIgnore.js +2 -3
  96. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  97. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  98. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  99. package/lib/esm/utils/getJsonSchema.js +1 -2
  100. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  101. package/lib/esm/utils/getRequiredProperties.js +3 -3
  102. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  103. package/lib/esm/utils/mapNullableType.js +1 -1
  104. package/lib/esm/utils/mapNullableType.js.map +1 -1
  105. package/lib/esm/utils/mergeOperation.js +1 -2
  106. package/lib/esm/utils/mergeOperation.js.map +1 -1
  107. package/lib/esm/utils/transformToOS2.js +2 -2
  108. package/lib/esm/utils/transformToOS2.js.map +1 -1
  109. package/package.json +6 -6
  110. package/tsconfig.compile.esm.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/decorators/operations/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAkD7D,MAAM,qBAAsB,SAAQ,gBAAwC;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,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAqB,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC;QAE3G,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;IAES,QAAQ,CAAC,GAAW,EAAE,KAAU;QACxC,QAAQ,GA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MAAM,UAAU,OAAO,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACvE,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC","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,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAkD7D,MAAM,qBAAsB,SAAQ,gBAAwC;IACjE,OAAO,GAAa,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAGtG,UAAU;QAClB,MA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AgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACrE,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,OAAO,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACvE,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC","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"]}
@@ -5,9 +5,12 @@ import { JsonEntityStore } from "./JsonEntityStore.js";
5
5
  * @ignore
6
6
  */
7
7
  export class DecoratorContext extends Map {
8
+ methods;
9
+ decoratorType;
10
+ entity;
11
+ actions = [];
8
12
  constructor(opts = {}) {
9
13
  super();
10
- this.actions = [];
11
14
  Object.entries(opts).forEach(([key, value]) => {
12
15
  this.set(key, value);
13
16
  });
@@ -1 +1 @@
1
- {"version":3,"file":"DecoratorContext.js","sourceRoot":"","sources":["../../../src/domain/DecoratorContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAC,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AASlD;;GAEG;AACH,MAAM,OAAgB,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,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,E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M,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAE5C,IAAI,CAAC,UAAU,EAAE,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","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,OAAO,EAAsB,cAAc,EAAC,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AASlD;;GAEG;AACH,MAAM,OAAgB,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;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AAI,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","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"]}
@@ -4,13 +4,10 @@ import { JsonEntityStore } from "./JsonEntityStore.js";
4
4
  import { JsonSchema } from "./JsonSchema.js";
5
5
  import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
6
6
  let JsonClassStore = class JsonClassStore extends JsonEntityStore {
7
- constructor() {
8
- super(...arguments);
9
- /**
10
- * List of children JsonEntityStore (properties or methods or params)
11
- */
12
- this.children = new Map();
13
- }
7
+ /**
8
+ * List of children JsonEntityStore (properties or methods or params)
9
+ */
10
+ children = new Map();
14
11
  get path() {
15
12
  return this.store.get("path", "/");
16
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"JsonClassStore.js","sourceRoot":"","sources":["../../../src/domain/JsonClassStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAC,eAAe,EAAyB,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAG7E,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,eAAe;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,UAAU,CAAC,IAAI,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAzBY,cAAc;IAD1B,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC;GAC7B,cAAc,CAyB1B;SAzBY,cAAc","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,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAC,eAAe,EAAyB,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAG7E,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,eAAe;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,UAAU,CAAC,IAAI,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAzBY,cAAc;IAD1B,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC;GAC7B,cAAc,CAyB1B;SAzBY,cAAc","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"]}
@@ -4,8 +4,44 @@ import { classOf, decoratorTypeOf, descriptorOf, isArrayOrArrayClass, isClass, i
4
4
  */
5
5
  export const JsonEntitiesContainer = new Map();
6
6
  export class JsonEntityStore {
7
+ /**
8
+ * Original property key decorated by the decorator
9
+ */
10
+ propertyKey;
11
+ /**
12
+ * Alias of the property
13
+ */
14
+ propertyName;
15
+ /**
16
+ * Parameter index
17
+ */
18
+ index;
19
+ /**
20
+ * Method's descriptor
21
+ */
22
+ descriptor;
23
+ /**
24
+ * Decorator type used to declare the JsonSchemaStore.
25
+ */
26
+ decoratorType;
27
+ /**
28
+ * Type of the collection (Array, Map, Set, etc...)
29
+ */
30
+ collectionType;
31
+ token;
32
+ store;
33
+ isStore = true;
34
+ parent;
35
+ target;
36
+ /**
37
+ *
38
+ */
39
+ _type;
40
+ /**
41
+ * Ref to JsonSchema
42
+ */
43
+ _schema;
7
44
  constructor(options) {
8
- this.isStore = true;
9
45
  const { target, propertyKey, descriptor, index, decoratorType } = options;
10
46
  this.target = target;
11
47
  this.propertyKey = propertyKey;
@@ -1 +1 @@
1
- {"version":3,"file":"JsonEntityStore.js","sourceRoot":"","sources":["../../../src/domain/JsonEntityStore.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EAEf,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,aAAa,EACb,2BAA2B,EAC3B,MAAM,EACN,WAAW,EACX,KAAK,EAEN,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAyC,CAAC;AAiBtF,MAAM,OAAgB,eAAe;IAyCnC,YAAY,OAA+B;QAdlC,YAAO,GAAG,IAAI,CAAC;QAetB,MAAM,EAAC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,CAAC,IAAS;QAC3B,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE;YACtB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;SAC5B;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAElB,wHAAwH;YACxH,IAAI,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBAC3C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;aACrB;SACF;IACH,CAAC;CACF","sourcesContent":["import {\n classOf,\n decoratorTypeOf,\n DecoratorTypes,\n descriptorOf,\n isArrayOrArrayClass,\n isClass,\n isCollection,\n isDate,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n nameOf,\n prototypeOf,\n Store,\n Type\n} from \"@tsed/core\";\nimport type {JsonSchema} from \"./JsonSchema\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\nimport type {JsonPropertyStore} from \"./JsonPropertyStore\";\nimport type {JsonParameterStore} from \"./JsonParameterStore\";\n\n/**\n * @ignore\n */\nexport const JsonEntitiesContainer = new Map<DecoratorTypes, Type<JsonEntityStore>>();\n\nexport interface JsonEntityStoreOptions {\n decoratorType: DecoratorTypes;\n target: Type<any>;\n propertyKey?: string | symbol;\n index?: number;\n descriptor?: any;\n type?: Type<any>;\n collectionType?: Type<any>;\n beforeMiddlewares?: Function[];\n middlewares?: Function[];\n afterMiddlewares?: Function[];\n\n [key: string]: any;\n}\n\nexport abstract class JsonEntityStore implements JsonEntityStoreOptions {\n /**\n * Original property key decorated by the decorator\n */\n readonly propertyKey: string | symbol;\n /**\n * Alias of the property\n */\n readonly propertyName: string;\n /**\n * Parameter index\n */\n readonly index: number;\n /**\n * Method's descriptor\n */\n readonly descriptor: number;\n /**\n * Decorator type used to declare the JsonSchemaStore.\n */\n readonly decoratorType: DecoratorTypes;\n /**\n * Type of the collection (Array, Map, Set, etc...)\n */\n public collectionType: Type<any>;\n public token: Type<any>;\n readonly store: Store;\n readonly isStore = true;\n readonly parent: JsonEntityStore;\n readonly target: Type<any>;\n /**\n *\n */\n protected _type: Type<any>;\n /**\n * Ref to JsonSchema\n */\n protected _schema: JsonSchema;\n\n [key: string]: any;\n\n constructor(options: JsonEntityStoreOptions) {\n const {target, propertyKey, descriptor, index, decoratorType} = options;\n this.target = target;\n this.propertyKey = propertyKey!;\n this.propertyName = String(propertyKey);\n this.descriptor = descriptor;\n this.index = index!;\n this.decoratorType = decoratorType;\n this.token = target;\n this.store = options.store;\n this.parent = this;\n }\n\n /**\n * Return the class name of the entity.\n * @returns {string}\n */\n get targetName(): string {\n return nameOf(this.token);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isCollection(): boolean {\n return !!this.collectionType;\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isArray() {\n return isArrayOrArrayClass(this.collectionType);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isPrimitive() {\n return isPrimitiveOrPrimitiveClass(this._type);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isDate() {\n return isDate(this.computedType);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isObject() {\n return isObject(this.computedType);\n }\n\n /**\n *\n */\n get isClass() {\n return isClass(this.computedType);\n }\n\n /**\n * Return the JsonSchema\n */\n get schema(): JsonSchema {\n return this._schema;\n }\n\n get nestedGenerics(): Type<any>[][] {\n return this.schema.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.schema.nestedGenerics = nestedGenerics;\n }\n\n /**\n *\n * @returns {Type<any>}\n */\n get type(): Type<any> | any {\n return this._type;\n }\n\n /**\n * Get original type without transformation\n * @param value\n */\n set type(value: Type<any> | any) {\n this._type = value;\n this.build();\n }\n\n /**\n * Return the itemSchema computed type. if the type is a function used for recursive model, the function will be called to\n * get the right type.\n */\n get computedType() {\n return this.itemSchema.getComputedType();\n }\n\n get itemSchema(): JsonSchema {\n return this.isCollection ? this.schema.itemSchema() : this.schema;\n }\n\n get parentSchema(): JsonSchema {\n return this.parent.schema;\n }\n\n /**\n *\n * @param target\n */\n static from<T extends JsonClassStore = JsonClassStore>(target: Type<any>): T;\n static from<T extends JsonPropertyStore = JsonPropertyStore>(target: Type<any> | any, propertyKey: string | symbol): T;\n static from<T extends JsonParameterStore = JsonParameterStore>(target: Type<any> | any, propertyKey: string | symbol, index: number): T;\n static from<T extends JsonMethodStore = JsonMethodStore>(\n target: Type<any> | any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor\n ): T;\n static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T;\n static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T {\n if (args[0].isStore) {\n return args[0] as T;\n }\n\n const target = args[0];\n\n if (args.length > 1) {\n args[0] = prototypeOf(args[0]);\n }\n\n const store = Store.from(...args);\n\n if (!store.has(\"JsonEntityStore\")) {\n const decoratorType = decoratorTypeOf(args);\n const entityStore = JsonEntitiesContainer.get(decoratorType);\n\n // istanbul ignore next\n if (!entityStore) {\n throw Error(\"Unsupported json entity type\");\n }\n\n const jsonSchemaStore = new entityStore({\n store,\n decoratorType,\n target: classOf(target),\n propertyKey: args[1],\n index: typeof args[2] === \"number\" ? args[2] : undefined,\n descriptor: typeof args[2] === \"object\" ? args[2] : undefined\n });\n\n jsonSchemaStore.build();\n\n store.set(\"JsonEntityStore\", jsonSchemaStore);\n }\n\n return store.get<T>(\"JsonEntityStore\")!;\n }\n\n static fromMethod<T extends JsonMethodStore = JsonMethodStore>(target: any, propertyKey: string | symbol) {\n return this.from<T>(target, propertyKey, descriptorOf(target, propertyKey));\n }\n\n get<T = any>(key: string, defaultValue?: any) {\n return this.store.get<T>(key, defaultValue);\n }\n\n set(key: string, value?: any) {\n return this.store.set(key, value);\n }\n\n protected abstract build(): void;\n\n protected buildType(type: any) {\n if (isCollection(type)) {\n this.collectionType = type;\n } else {\n this._type = type;\n\n // issue #1534: Enum metadata stored as plain object instead of String (see: https://github.com/tsedio/tsed/issues/1534)\n if (this._type && isPlainObject(this._type)) {\n this._type = String;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"JsonEntityStore.js","sourceRoot":"","sources":["../../../src/domain/JsonEntityStore.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EAEf,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,aAAa,EACb,2BAA2B,EAC3B,MAAM,EACN,WAAW,EACX,KAAK,EAEN,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAyC,CAAC;AAiBtF,MAAM,OAAgB,eAAe;IACnC;;OAEG;IACM,WAAW,CAAkB;IACtC;;OAEG;IACM,YAAY,CAAS;IAC9B;;OAEG;IACM,KAAK,CAAS;IACvB;;OAEG;IACM,UAAU,CAAS;IAC5B;;OAEG;IACM,aAAa,CAAiB;IACvC;;OAEG;IACI,cAAc,CAAY;IAC1B,KAAK,CAAY;IACf,KAAK,CAAQ;IACb,OAAO,GAAG,IAAI,CAAC;IACf,MAAM,CAAkB;IACxB,MAAM,CAAY;IAC3B;;OAEG;IACO,KAAK,CAAY;IAC3B;;OAEG;IACO,OAAO,CAAa;IAI9B,YAAY,OAA+B;QACzC,MAAM,EAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAC,GAAG,OAAO,CAAC;QACxE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAY,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACxC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAM,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,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Class,\n isClass,\n isCollection,\n isDate,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n nameOf,\n prototypeOf,\n Store,\n Type\n} from \"@tsed/core\";\nimport type {JsonSchema} from \"./JsonSchema\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\nimport type {JsonPropertyStore} from \"./JsonPropertyStore\";\nimport type {JsonParameterStore} from \"./JsonParameterStore\";\n\n/**\n * @ignore\n */\nexport const JsonEntitiesContainer = new Map<DecoratorTypes, Type<JsonEntityStore>>();\n\nexport interface JsonEntityStoreOptions {\n decoratorType: DecoratorTypes;\n target: Type<any>;\n propertyKey?: string | symbol;\n index?: number;\n descriptor?: any;\n type?: Type<any>;\n collectionType?: Type<any>;\n beforeMiddlewares?: Function[];\n middlewares?: Function[];\n afterMiddlewares?: Function[];\n\n [key: string]: any;\n}\n\nexport abstract class JsonEntityStore implements JsonEntityStoreOptions {\n /**\n * Original property key decorated by the decorator\n */\n readonly propertyKey: string | symbol;\n /**\n * Alias of the property\n */\n readonly propertyName: string;\n /**\n * Parameter index\n */\n readonly index: number;\n /**\n * Method's descriptor\n */\n readonly descriptor: number;\n /**\n * Decorator type used to declare the JsonSchemaStore.\n */\n readonly decoratorType: DecoratorTypes;\n /**\n * Type of the collection (Array, Map, Set, etc...)\n */\n public collectionType: Type<any>;\n public token: Type<any>;\n readonly store: Store;\n readonly isStore = true;\n readonly parent: JsonEntityStore;\n readonly target: Type<any>;\n /**\n *\n */\n protected _type: Type<any>;\n /**\n * Ref to JsonSchema\n */\n protected _schema: JsonSchema;\n\n [key: string]: any;\n\n constructor(options: JsonEntityStoreOptions) {\n const {target, propertyKey, descriptor, index, decoratorType} = options;\n this.target = target;\n this.propertyKey = propertyKey!;\n this.propertyName = String(propertyKey);\n this.descriptor = descriptor;\n this.index = index!;\n this.decoratorType = decoratorType;\n this.token = target;\n this.store = options.store;\n this.parent = this;\n }\n\n /**\n * Return the class name of the entity.\n * @returns {string}\n */\n get targetName(): string {\n return nameOf(this.token);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isCollection(): boolean {\n return !!this.collectionType;\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isArray() {\n return isArrayOrArrayClass(this.collectionType);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isPrimitive() {\n return isPrimitiveOrPrimitiveClass(this._type);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isDate() {\n return isDate(this.computedType);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isObject() {\n return isObject(this.computedType);\n }\n\n /**\n *\n */\n get isClass() {\n return isClass(this.computedType);\n }\n\n /**\n * Return the JsonSchema\n */\n get schema(): JsonSchema {\n return this._schema;\n }\n\n get nestedGenerics(): Type<any>[][] {\n return this.schema.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.schema.nestedGenerics = nestedGenerics;\n }\n\n /**\n *\n * @returns {Type<any>}\n */\n get type(): Type<any> | any {\n return this._type;\n }\n\n /**\n * Get original type without transformation\n * @param value\n */\n set type(value: Type<any> | any) {\n this._type = value;\n this.build();\n }\n\n /**\n * Return the itemSchema computed type. if the type is a function used for recursive model, the function will be called to\n * get the right type.\n */\n get computedType() {\n return this.itemSchema.getComputedType();\n }\n\n get itemSchema(): JsonSchema {\n return this.isCollection ? this.schema.itemSchema() : this.schema;\n }\n\n get parentSchema(): JsonSchema {\n return this.parent.schema;\n }\n\n /**\n *\n * @param target\n */\n static from<T extends JsonClassStore = JsonClassStore>(target: Type<any>): T;\n static from<T extends JsonPropertyStore = JsonPropertyStore>(target: Type<any> | any, propertyKey: string | symbol): T;\n static from<T extends JsonParameterStore = JsonParameterStore>(target: Type<any> | any, propertyKey: string | symbol, index: number): T;\n static from<T extends JsonMethodStore = JsonMethodStore>(\n target: Type<any> | any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor\n ): T;\n static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T;\n static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T {\n if (args[0].isStore) {\n return args[0] as T;\n }\n\n const target = args[0];\n\n if (args.length > 1) {\n args[0] = prototypeOf(args[0]);\n }\n\n const store = Store.from(...args);\n\n if (!store.has(\"JsonEntityStore\")) {\n const decoratorType = decoratorTypeOf(args);\n const entityStore = JsonEntitiesContainer.get(decoratorType);\n\n // istanbul ignore next\n if (!entityStore) {\n throw Error(\"Unsupported json entity type\");\n }\n\n const jsonSchemaStore = new entityStore({\n store,\n decoratorType,\n target: classOf(target),\n propertyKey: args[1],\n index: typeof args[2] === \"number\" ? args[2] : undefined,\n descriptor: typeof args[2] === \"object\" ? args[2] : undefined\n });\n\n jsonSchemaStore.build();\n\n store.set(\"JsonEntityStore\", jsonSchemaStore);\n }\n\n return store.get<T>(\"JsonEntityStore\")!;\n }\n\n static fromMethod<T extends JsonMethodStore = JsonMethodStore>(target: any, propertyKey: string | symbol) {\n return this.from<T>(target, propertyKey, descriptorOf(target, propertyKey));\n }\n\n get<T = any>(key: string, defaultValue?: any) {\n return this.store.get<T>(key, defaultValue);\n }\n\n set(key: string, value?: any) {\n return this.store.set(key, value);\n }\n\n protected abstract build(): void;\n\n protected buildType(type: any) {\n if (isCollection(type)) {\n this.collectionType = type;\n } else {\n this._type = type;\n\n // issue #1534: Enum metadata stored as plain object instead of String (see: https://github.com/tsedio/tsed/issues/1534)\n if (this._type && isPlainObject(this._type)) {\n this._type = String;\n }\n }\n }\n}\n"]}
@@ -2,9 +2,10 @@ import { nameOf } from "@tsed/core";
2
2
  import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
3
3
  import { getJsonEntityStore } from "../utils/getJsonEntityStore.js";
4
4
  export class JsonLazyRef {
5
+ getType;
6
+ isLazyRef = true;
5
7
  constructor(getType) {
6
8
  this.getType = getType;
7
- this.isLazyRef = true;
8
9
  }
9
10
  get target() {
10
11
  return this.getType();
@@ -1 +1 @@
1
- {"version":3,"file":"JsonLazyRef.js","sourceRoot":"","sources":["../../../src/domain/JsonLazyRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAO,MAAM,YAAY,CAAC;AAExC,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAE/D,MAAM,OAAO,WAAW;IAGtB,YAAqB,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAFpC,cAAS,GAAG,IAAI,CAAC;IAEsB,CAAC;IAEjD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;IACnD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,OAA2B;QAChC,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;CACF","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getJsonEntityStore} from \"../utils/getJsonEntityStore\";\n\nexport class JsonLazyRef {\n readonly isLazyRef = true;\n\n constructor(readonly getType: () => Type<any>) {}\n\n get target() {\n return this.getType();\n }\n\n get schema() {\n return getJsonEntityStore(this.getType()).schema;\n }\n\n get name() {\n return nameOf(this.getType());\n }\n\n toJSON(options?: JsonSchemaOptions) {\n return this.getType() && execMapper(\"schema\", this.schema, options);\n }\n}\n"]}
1
+ {"version":3,"file":"JsonLazyRef.js","sourceRoot":"","sources":["../../../src/domain/JsonLazyRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAO,MAAM,YAAY,CAAC;AAExC,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAE/D,MAAM,OAAO,WAAW;IAGD;IAFZ,SAAS,GAAG,IAAI,CAAC;IAE1B,YAAqB,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IAAG,CAAC;IAEjD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;IACnD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,OAA2B;QAChC,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;CACF","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getJsonEntityStore} from \"../utils/getJsonEntityStore\";\n\nexport class JsonLazyRef {\n readonly isLazyRef = true;\n\n constructor(readonly getType: () => Type<any>) {}\n\n get target() {\n return this.getType();\n }\n\n get schema() {\n return getJsonEntityStore(this.getType()).schema;\n }\n\n get name() {\n return nameOf(this.getType());\n }\n\n toJSON(options?: JsonSchemaOptions) {\n return this.getType() && execMapper(\"schema\", this.schema, options);\n }\n}\n"]}
@@ -5,24 +5,24 @@ import { JsonOperation } from "./JsonOperation.js";
5
5
  import { JsonSchema } from "./JsonSchema.js";
6
6
  import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
7
7
  let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
8
+ parent = JsonEntityStore.from(this.target);
9
+ middlewares = [];
10
+ beforeMiddlewares = [];
11
+ afterMiddlewares = [];
12
+ /**
13
+ * Ref to JsonOperation when the decorated object is a method.
14
+ */
15
+ operation = new JsonOperation();
16
+ /**
17
+ * List of children JsonEntityStore (properties or methods or params)
18
+ */
19
+ children = new Map();
8
20
  constructor(options) {
9
21
  super({
10
22
  store: Store.fromMethod(options.target, options.propertyKey),
11
23
  descriptor: descriptorOf(options.target, options.propertyKey),
12
24
  ...options
13
25
  });
14
- this.parent = JsonEntityStore.from(this.target);
15
- this.middlewares = [];
16
- this.beforeMiddlewares = [];
17
- this.afterMiddlewares = [];
18
- /**
19
- * Ref to JsonOperation when the decorated object is a method.
20
- */
21
- this.operation = new JsonOperation();
22
- /**
23
- * List of children JsonEntityStore (properties or methods or params)
24
- */
25
- this.children = new Map();
26
26
  const { beforeMiddlewares = [], middlewares = [], afterMiddlewares = [] } = options;
27
27
  this.after(afterMiddlewares);
28
28
  this.before(beforeMiddlewares);
@@ -1 +1 @@
1
- {"version":3,"file":"JsonMethodStore.js","sourceRoot":"","sources":["../../../src/domain/JsonMethodStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAC5I,OAAO,EAAC,eAAe,EAAyB,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAa7E,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,eAAe;IAclD,YAAY,OAA+B;QACzC,KAAK,CAAC;YACJ,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EA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AI,CAAC,CAAC;QAElD,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC5B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;YACjC,aAAa;YACb,OAAO,IAAI,CAAC,KAAK,CAAC;SACnB;QAED,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI;SACvC,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACpC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACF,CAAA;AAlKY,eAAe;IAD3B,mBAAmB,CAAC,cAAc,CAAC,MAAM,CAAC;;GAC9B,eAAe,CAkK3B;SAlKY,eAAe;AAuL5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, isCollection, isFunction, isPromise, Metadata, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport {JsonOperation} from \"./JsonOperation\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport type {JsonParameterStore} from \"./JsonParameterStore\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\nexport interface JsonViewOptions {\n path: string;\n options: any;\n}\n\nexport interface JsonRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class JsonMethodStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n public middlewares: any[] = [];\n public beforeMiddlewares: any[] = [];\n public afterMiddlewares: any[] = [];\n /**\n * Ref to JsonOperation when the decorated object is a method.\n */\n readonly operation: JsonOperation = new JsonOperation();\n /**\n * List of children JsonEntityStore (properties or methods or params)\n */\n readonly children: Map<string | number, JsonParameterStore> = new Map();\n\n constructor(options: JsonEntityStoreOptions) {\n super({\n store: Store.fromMethod(options.target, options.propertyKey!),\n descriptor: descriptorOf(options.target, options.propertyKey!),\n ...options\n });\n\n const {beforeMiddlewares = [], middlewares = [], afterMiddlewares = []} = options;\n\n this.after(afterMiddlewares);\n this.before(beforeMiddlewares);\n this.use(middlewares);\n }\n\n get params(): JsonParameterStore[] {\n return this.parameters;\n }\n\n get view(): JsonViewOptions {\n return this.store.get(\"view\") as JsonViewOptions;\n }\n\n set view(view: JsonViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n get parameters(): JsonParameterStore[] {\n return [...this.children.values()] as JsonParameterStore[];\n }\n\n get operationPaths() {\n return this.operation.operationPaths;\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): JsonMethodStore {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<JsonMethodStore>(prototypeOf(target), propertyKey, descriptor);\n }\n\n getResponseOptions(status: number, contentType: string = \"application/json\"): undefined | any {\n const media = this.operation.getResponseOf(status).getMedia(contentType, false);\n\n if (media && media.has(\"schema\")) {\n const schema = media.get(\"schema\") as JsonSchema;\n\n return {type: schema.getComputedItemType(), groups: media.groups};\n }\n\n return {type: this.type};\n }\n\n /**\n * Append middlewares to the beforeMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public before(args: Function[]): this {\n this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Append middlewares to the afterMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public after(args: Function[]): this {\n this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Store all arguments collected via Annotation.\n * @param args\n */\n public use(args: Function[]) {\n this.middlewares = this.middlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Find the value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n public get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n\n public getParamTypes(): Record<string, boolean> {\n return [...this.children.values()].reduce(\n (obj, item) => ({\n ...obj,\n [item.paramType]: true\n }),\n {}\n );\n }\n\n protected build() {\n if (!this._type) {\n let type: any = Metadata.getReturnType(this.target, this.propertyKey);\n type = isPromise(type) ? undefined : type;\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n this.parent.children.set(this.propertyName, this);\n\n if (isCollection(this._type)) {\n this.collectionType = this._type;\n // @ts-ignore\n delete this._type;\n }\n\n this._schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n this._schema.itemSchema(this.type);\n }\n\n this.parent.schema.addProperty(this.propertyName, this.schema);\n }\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored into endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *```typescript\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *```\n *\n * @alias JsonMethodStore\n */\nexport type EndpointMetadata = JsonMethodStore;\nexport const EndpointMetadata = JsonMethodStore;\n"]}
1
+ {"version":3,"file":"JsonMethodStore.js","sourceRoot":"","sources":["../../../src/domain/JsonMethodStore.ts"],"names":[],"mappings":";AA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ge, descriptorOf, isCollection, isFunction, isPromise, Metadata, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport {JsonOperation} from \"./JsonOperation\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport type {JsonParameterStore} from \"./JsonParameterStore\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\nexport interface JsonViewOptions {\n path: string;\n options: any;\n}\n\nexport interface JsonRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class JsonMethodStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n public middlewares: any[] = [];\n public beforeMiddlewares: any[] = [];\n public afterMiddlewares: any[] = [];\n /**\n * Ref to JsonOperation when the decorated object is a method.\n */\n readonly operation: JsonOperation = new JsonOperation();\n /**\n * List of children JsonEntityStore (properties or methods or params)\n */\n readonly children: Map<string | number, JsonParameterStore> = new Map();\n\n constructor(options: JsonEntityStoreOptions) {\n super({\n store: Store.fromMethod(options.target, options.propertyKey!),\n descriptor: descriptorOf(options.target, options.propertyKey!),\n ...options\n });\n\n const {beforeMiddlewares = [], middlewares = [], afterMiddlewares = []} = options;\n\n this.after(afterMiddlewares);\n this.before(beforeMiddlewares);\n this.use(middlewares);\n }\n\n get params(): JsonParameterStore[] {\n return this.parameters;\n }\n\n get view(): JsonViewOptions {\n return this.store.get(\"view\") as JsonViewOptions;\n }\n\n set view(view: JsonViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n get parameters(): JsonParameterStore[] {\n return [...this.children.values()] as JsonParameterStore[];\n }\n\n get operationPaths() {\n return this.operation.operationPaths;\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): JsonMethodStore {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<JsonMethodStore>(prototypeOf(target), propertyKey, descriptor);\n }\n\n getResponseOptions(status: number, contentType: string = \"application/json\"): undefined | any {\n const media = this.operation.getResponseOf(status).getMedia(contentType, false);\n\n if (media && media.has(\"schema\")) {\n const schema = media.get(\"schema\") as JsonSchema;\n\n return {type: schema.getComputedItemType(), groups: media.groups};\n }\n\n return {type: this.type};\n }\n\n /**\n * Append middlewares to the beforeMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public before(args: Function[]): this {\n this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Append middlewares to the afterMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public after(args: Function[]): this {\n this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Store all arguments collected via Annotation.\n * @param args\n */\n public use(args: Function[]) {\n this.middlewares = this.middlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Find the value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n public get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n\n public getParamTypes(): Record<string, boolean> {\n return [...this.children.values()].reduce(\n (obj, item) => ({\n ...obj,\n [item.paramType]: true\n }),\n {}\n );\n }\n\n protected build() {\n if (!this._type) {\n let type: any = Metadata.getReturnType(this.target, this.propertyKey);\n type = isPromise(type) ? undefined : type;\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n this.parent.children.set(this.propertyName, this);\n\n if (isCollection(this._type)) {\n this.collectionType = this._type;\n // @ts-ignore\n delete this._type;\n }\n\n this._schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n this._schema.itemSchema(this.type);\n }\n\n this.parent.schema.addProperty(this.propertyName, this.schema);\n }\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored into endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *```typescript\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *```\n *\n * @alias JsonMethodStore\n */\nexport type EndpointMetadata = JsonMethodStore;\nexport const EndpointMetadata = JsonMethodStore;\n"]}
@@ -1,5 +1,3 @@
1
- var _JsonOperation_status, _JsonOperation_redirection;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
1
  import { deepMerge, uniq, uniqBy } from "@tsed/core";
4
2
  import { getStatusMessage } from "../constants/httpStatusMessages.js";
5
3
  import { isRedirectionStatus, isSuccessStatus } from "../utils/isSuccessStatus.js";
@@ -9,17 +7,17 @@ import { JsonRequestBody } from "./JsonRequestBody.js";
9
7
  import { JsonResponse } from "./JsonResponse.js";
10
8
  import { JsonSchema } from "./JsonSchema.js";
11
9
  export class JsonOperation extends JsonMap {
10
+ operationPaths = new Map();
11
+ #status;
12
+ #redirection = false;
12
13
  constructor(obj = {}) {
13
14
  super({ parameters: [], responses: new JsonMap(), ...obj });
14
- this.operationPaths = new Map();
15
- _JsonOperation_status.set(this, void 0);
16
- _JsonOperation_redirection.set(this, false);
17
15
  }
18
16
  get response() {
19
17
  return this.getResponses().get(this.getStatus().toString());
20
18
  }
21
19
  get status() {
22
- return __classPrivateFieldGet(this, _JsonOperation_status, "f");
20
+ return this.#status;
23
21
  }
24
22
  tags(tags) {
25
23
  super.set("tags", tags);
@@ -42,27 +40,27 @@ export class JsonOperation extends JsonMap {
42
40
  return this;
43
41
  }
44
42
  defaultStatus(status) {
45
- __classPrivateFieldSet(this, _JsonOperation_status, status, "f");
43
+ this.#status = status;
46
44
  return this;
47
45
  }
48
46
  getStatus() {
49
- return __classPrivateFieldGet(this, _JsonOperation_status, "f") || 200;
47
+ return this.#status || 200;
50
48
  }
51
49
  setRedirection(status = 302) {
52
- __classPrivateFieldSet(this, _JsonOperation_redirection, true, "f");
53
- __classPrivateFieldSet(this, _JsonOperation_status, status, "f");
50
+ this.#redirection = true;
51
+ this.#status = status;
54
52
  return this;
55
53
  }
56
54
  isRedirection(status) {
57
- if (__classPrivateFieldGet(this, _JsonOperation_redirection, "f")) {
55
+ if (this.#redirection) {
58
56
  if (status) {
59
57
  return isRedirectionStatus(status);
60
58
  }
61
59
  }
62
- return __classPrivateFieldGet(this, _JsonOperation_redirection, "f");
60
+ return this.#redirection;
63
61
  }
64
62
  addResponse(statusCode, response) {
65
- if ((isSuccessStatus(statusCode) || isRedirectionStatus(statusCode)) && !__classPrivateFieldGet(this, _JsonOperation_status, "f")) {
63
+ if ((isSuccessStatus(statusCode) || isRedirectionStatus(statusCode)) && !this.#status) {
66
64
  const res = this.getResponseOf(200);
67
65
  this.getResponses().set(statusCode.toString(), res).delete("200");
68
66
  this.defaultStatus(Number(statusCode));
@@ -182,11 +180,9 @@ export class JsonOperation extends JsonMap {
182
180
  return operation;
183
181
  }
184
182
  }
185
- _JsonOperation_status = new WeakMap(), _JsonOperation_redirection = new WeakMap();
186
183
  function toRequestBody(operation, { schema, in: _, ...props }) {
187
- var _a;
188
184
  const requestBody = new JsonRequestBody(props);
189
- const consumes = ((_a = operation.get("consumes")) === null || _a === void 0 ? void 0 : _a.length) ? operation.get("consumes") : ["application/json"];
185
+ const consumes = operation.get("consumes")?.length ? operation.get("consumes") : ["application/json"];
190
186
  consumes.forEach((consume) => {
191
187
  requestBody.addContent(consume, schema);
192
188
  });
@@ -1 +1 @@
1
- {"version":3,"file":"JsonOperation.js","sourceRoot":"","sources":["../../../src/domain/JsonOperation.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,SAAS,EAAE,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G,CAAC,CAAC;aAChD,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACxB,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;gBAC5B,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;aACpB;QACH,CAAC,CAAC,CAAC;QAEL,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEhD,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,WAAW,CAChB,IAAI,EACJ,aAAa,CAAC,MAAM,IAAI;gBACtB,IAAI,EAAE,aAAa,CAAC,IAAI;aACzB,CACF,CAAC;YAEF,IAAI,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAC7B,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;aAC1B;YAED,WAAW,EAAE,CAAC;SACf;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;SAC1B;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,WAAW,EAAE;QAChB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;SAChB;KACF;IAED,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEtB,OAAO,EAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAC,CAAC;AACrE,CAAC","sourcesContent":["import {deepMerge, uniq, uniqBy} from \"@tsed/core\";\nimport {OpenSpecSecurity, OpenSpecTag, OS3Operation} from \"@tsed/openspec\";\nimport {getStatusMessage} from \"../constants/httpStatusMessages\";\nimport {JsonHeader} from \"../interfaces/JsonOpenSpec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {isRedirectionStatus, isSuccessStatus} from \"../utils/isSuccessStatus\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonRequestBody} from \"./JsonRequestBody\";\nimport {JsonResponse} from \"./JsonResponse\";\nimport {JsonSchema} from \"./JsonSchema\";\n\nexport interface JsonMethodPath {\n path: string | RegExp;\n method: string;\n isFinal?: boolean;\n\n [key: string]: any;\n}\n\nexport interface JsonOperationOptions extends OS3Operation<JsonSchema, JsonParameter, JsonMap<JsonResponse>> {\n consumes: string[];\n produces: string[];\n}\n\nexport class JsonOperation extends JsonMap<JsonOperationOptions> {\n readonly operationPaths: Map<string, JsonMethodPath> = new Map();\n #status: number;\n #redirection: boolean = false;\n\n constructor(obj: Partial<JsonOperationOptions> = {}) {\n super({parameters: [], responses: new JsonMap(), ...obj});\n }\n\n get response(): JsonResponse | undefined {\n return this.getResponses().get(this.getStatus().toString());\n }\n\n get status() {\n return this.#status;\n }\n\n tags(tags: OpenSpecTag[]): this {\n super.set(\"tags\", tags);\n\n return this;\n }\n\n addTags(tags: OpenSpecTag[]) {\n tags = uniqBy([...(this.get(\"tags\") || []), ...tags], \"name\");\n\n return this.tags(tags);\n }\n\n summary(summary: string): this {\n super.set(\"summary\", summary);\n\n return this;\n }\n\n operationId(operationId: string): this {\n this.set(\"operationId\", operationId);\n\n return this;\n }\n\n responses(responses: JsonMap<any>): this {\n this.set(\"responses\", responses);\n\n return this;\n }\n\n defaultStatus(status: number) {\n this.#status = status;\n\n return this;\n }\n\n getStatus() {\n return this.#status || 200;\n }\n\n setRedirection(status = 302) {\n this.#redirection = true;\n this.#status = status;\n return this;\n }\n\n isRedirection(status?: number) {\n if (this.#redirection) {\n if (status) {\n return isRedirectionStatus(status);\n }\n }\n\n return this.#redirection;\n }\n\n addResponse(statusCode: string | number, response: JsonResponse) {\n if ((isSuccessStatus(statusCode) || isRedirectionStatus(statusCode)) && !this.#status) {\n const res = this.getResponseOf(200);\n\n this.getResponses().set(statusCode.toString(), res).delete(\"200\");\n\n this.defaultStatus(Number(statusCode));\n }\n\n const currentCode = statusCode === \"default\" ? this.getStatus().toString() : statusCode.toString();\n const currentResponse = this.getResponses().get(currentCode);\n\n if (!currentResponse) {\n response.status = Number(currentCode);\n this.getResponses().set(currentCode, response);\n } else {\n response.forEach((value, key) => {\n if (![\"content\"].includes(key)) {\n currentResponse.set(key, deepMerge(currentResponse.get(key), value));\n }\n });\n currentResponse.status = Number(currentCode);\n }\n\n return this;\n }\n\n getResponses() {\n return this.get(\"responses\") as JsonMap<JsonResponse>;\n }\n\n getResponseOf(status: number | string): JsonResponse {\n return (status === \"default\" ? this.response : this.getResponses().get(String(status))) || new JsonResponse();\n }\n\n ensureResponseOf(status: number | string): JsonResponse {\n this.addResponse(status, this.getResponseOf(status));\n return this.getResponseOf(status);\n }\n\n getHeadersOf(status: number): Record<string, JsonHeader & {example: string}> {\n return this.getResponseOf(status).get(\"headers\") || {};\n }\n\n getContentTypeOf(status: number): any {\n return [...this.getResponseOf(status).get(\"content\").keys()].slice(-1)[0];\n }\n\n security(security: OpenSpecSecurity): this {\n this.set(\"security\", security);\n\n return this;\n }\n\n addSecurityScopes(name: string, scopes: string[]) {\n const security = this.get(\"security\") || {};\n security[name] = uniq([...(security[name] || []), ...scopes]);\n\n return this.security(security);\n }\n\n description(description: string): this {\n super.set(\"description\", description);\n\n return this;\n }\n\n deprecated(deprecated: boolean): this {\n super.set(\"deprecated\", deprecated);\n\n return this;\n }\n\n parameters(parameters: JsonParameter[]): this {\n super.set(\"parameters\", parameters);\n\n return this;\n }\n\n addParameter(index: number, parameter: JsonParameter) {\n if (index === -1) {\n index = this.get(\"parameters\").length;\n }\n this.get(\"parameters\")[index] = parameter;\n }\n\n consumes(consumes: string[]): this {\n super.set(\"consumes\", consumes);\n\n return this;\n }\n\n produces(produces: string[]): this {\n super.set(\"produces\", produces);\n\n return this;\n }\n\n addProduce(produce: string) {\n const produces = uniq([].concat(this.get(\"produces\"), produce as never)).filter(Boolean);\n\n this.set(\"produces\", produces);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n this.operationPaths.set(String(method) + String(path), {\n ...options,\n method,\n path\n });\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const operation = super.toJSON({...options, ignore: [\"parameters\"]});\n const bodyParameters: JsonParameter[] = [];\n const parameters: any[] = [];\n\n if (operation.security) {\n operation.security = [].concat(operation.security);\n }\n\n this.get(\"parameters\").forEach((parameter: JsonParameter) => {\n if (!isParameterType(this.get(\"in\"))) {\n if (parameter.get(\"in\")) {\n if ([JsonParameterTypes.BODY, JsonParameterTypes.FILES].includes(parameter.get(\"in\"))) {\n bodyParameters.push(parameter);\n } else {\n parameters.push(...[].concat(parameter.toJSON(options)));\n }\n }\n }\n });\n\n operation.parameters = parameters.filter(Boolean);\n\n if (this.get(\"responses\").size === 0) {\n operation.responses = {\n \"200\": {\n description: getStatusMessage(200)\n }\n };\n }\n\n if (bodyParameters.length) {\n const parameter = buildSchemaFromBodyParameters(bodyParameters, options);\n operation.requestBody = toRequestBody(this, parameter).toJSON(options);\n }\n\n delete operation.consumes;\n delete operation.produces;\n\n return operation;\n }\n}\n\nfunction toRequestBody(operation: JsonOperation, {schema, in: _, ...props}: any) {\n const requestBody = new JsonRequestBody(props);\n\n const consumes = operation.get(\"consumes\")?.length ? operation.get(\"consumes\") : [\"application/json\"];\n\n consumes.forEach((consume: string) => {\n requestBody.addContent(consume, schema);\n });\n\n return requestBody;\n}\n\nfunction buildSchemaFromBodyParameters(parameters: JsonParameter[], options: JsonSchemaOptions) {\n let schema = new JsonSchema();\n const props: any = {};\n const refs: JsonSchema[] = [];\n let propsLength = 0;\n\n parameters.forEach((parameter) => {\n const name = parameter.getName();\n\n Array.from(parameter.entries())\n .filter(([key]) => ![\"in\", \"name\"].includes(key))\n .forEach(([key, value]) => {\n if (props[key] === undefined) {\n props[key] = value;\n }\n });\n\n const jsonParameter = parameter.toJSON(options);\n\n if (name) {\n schema.addProperty(\n name,\n jsonParameter.schema || {\n type: jsonParameter.type\n }\n );\n\n if (parameter.get(\"required\")) {\n schema.addRequired(name);\n }\n\n propsLength++;\n } else {\n refs.push(jsonParameter);\n }\n });\n\n if (!propsLength) {\n if (refs.length === 1) {\n return refs[0];\n }\n }\n\n schema.type(\"object\");\n\n return {schema: schema.toJSON(options), required: false, ...props};\n}\n"]}
1
+ {"version":3,"file":"JsonOperation.js","sourceRoot":"","sources":["../../../src/domain/JsonOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAexC,MAAM,OAAO,aAAc,SAAQ,OAA6B;IACrD,cAAc,GAAgC,IAAI,GAAG,EAAE,CAAC;IACjE,OAAO,CAAS;IAChB,YAAY,GAAY,KAAK,CAAC;IAE9B,YAAY,MAAqC,EAAE;QACjD,KAAK,CAAC,EAAC,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,OAAO,EAAE,EAAE,GAAG,GAAG,EAAC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAA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AK,EAAE,GAAG,KAAK,EAAC,CAAC;AACrE,CAAC","sourcesContent":["import {deepMerge, uniq, uniqBy} from \"@tsed/core\";\nimport {OpenSpecSecurity, OpenSpecTag, OS3Operation} from \"@tsed/openspec\";\nimport {getStatusMessage} from \"../constants/httpStatusMessages\";\nimport {JsonHeader} from \"../interfaces/JsonOpenSpec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {isRedirectionStatus, isSuccessStatus} from \"../utils/isSuccessStatus\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonRequestBody} from \"./JsonRequestBody\";\nimport {JsonResponse} from \"./JsonResponse\";\nimport {JsonSchema} from \"./JsonSchema\";\n\nexport interface JsonMethodPath {\n path: string | RegExp;\n method: string;\n isFinal?: boolean;\n\n [key: string]: any;\n}\n\nexport interface JsonOperationOptions extends OS3Operation<JsonSchema, JsonParameter, JsonMap<JsonResponse>> {\n consumes: string[];\n produces: string[];\n}\n\nexport class JsonOperation extends JsonMap<JsonOperationOptions> {\n readonly operationPaths: Map<string, JsonMethodPath> = new Map();\n #status: number;\n #redirection: boolean = false;\n\n constructor(obj: Partial<JsonOperationOptions> = {}) {\n super({parameters: [], responses: new JsonMap(), ...obj});\n }\n\n get response(): JsonResponse | undefined {\n return this.getResponses().get(this.getStatus().toString());\n }\n\n get status() {\n return this.#status;\n }\n\n tags(tags: OpenSpecTag[]): this {\n super.set(\"tags\", tags);\n\n return this;\n }\n\n addTags(tags: OpenSpecTag[]) {\n tags = uniqBy([...(this.get(\"tags\") || []), ...tags], \"name\");\n\n return this.tags(tags);\n }\n\n summary(summary: string): this {\n super.set(\"summary\", summary);\n\n return this;\n }\n\n operationId(operationId: string): this {\n this.set(\"operationId\", operationId);\n\n return this;\n }\n\n responses(responses: JsonMap<any>): this {\n this.set(\"responses\", responses);\n\n return this;\n }\n\n defaultStatus(status: number) {\n this.#status = status;\n\n return this;\n }\n\n getStatus() {\n return this.#status || 200;\n }\n\n setRedirection(status = 302) {\n this.#redirection = true;\n this.#status = status;\n return this;\n }\n\n isRedirection(status?: number) {\n if (this.#redirection) {\n if (status) {\n return isRedirectionStatus(status);\n }\n }\n\n return this.#redirection;\n }\n\n addResponse(statusCode: string | number, response: JsonResponse) {\n if ((isSuccessStatus(statusCode) || isRedirectionStatus(statusCode)) && !this.#status) {\n const res = this.getResponseOf(200);\n\n this.getResponses().set(statusCode.toString(), res).delete(\"200\");\n\n this.defaultStatus(Number(statusCode));\n }\n\n const currentCode = statusCode === \"default\" ? this.getStatus().toString() : statusCode.toString();\n const currentResponse = this.getResponses().get(currentCode);\n\n if (!currentResponse) {\n response.status = Number(currentCode);\n this.getResponses().set(currentCode, response);\n } else {\n response.forEach((value, key) => {\n if (![\"content\"].includes(key)) {\n currentResponse.set(key, deepMerge(currentResponse.get(key), value));\n }\n });\n currentResponse.status = Number(currentCode);\n }\n\n return this;\n }\n\n getResponses() {\n return this.get(\"responses\") as JsonMap<JsonResponse>;\n }\n\n getResponseOf(status: number | string): JsonResponse {\n return (status === \"default\" ? this.response : this.getResponses().get(String(status))) || new JsonResponse();\n }\n\n ensureResponseOf(status: number | string): JsonResponse {\n this.addResponse(status, this.getResponseOf(status));\n return this.getResponseOf(status);\n }\n\n getHeadersOf(status: number): Record<string, JsonHeader & {example: string}> {\n return this.getResponseOf(status).get(\"headers\") || {};\n }\n\n getContentTypeOf(status: number): any {\n return [...this.getResponseOf(status).get(\"content\").keys()].slice(-1)[0];\n }\n\n security(security: OpenSpecSecurity): this {\n this.set(\"security\", security);\n\n return this;\n }\n\n addSecurityScopes(name: string, scopes: string[]) {\n const security = this.get(\"security\") || {};\n security[name] = uniq([...(security[name] || []), ...scopes]);\n\n return this.security(security);\n }\n\n description(description: string): this {\n super.set(\"description\", description);\n\n return this;\n }\n\n deprecated(deprecated: boolean): this {\n super.set(\"deprecated\", deprecated);\n\n return this;\n }\n\n parameters(parameters: JsonParameter[]): this {\n super.set(\"parameters\", parameters);\n\n return this;\n }\n\n addParameter(index: number, parameter: JsonParameter) {\n if (index === -1) {\n index = this.get(\"parameters\").length;\n }\n this.get(\"parameters\")[index] = parameter;\n }\n\n consumes(consumes: string[]): this {\n super.set(\"consumes\", consumes);\n\n return this;\n }\n\n produces(produces: string[]): this {\n super.set(\"produces\", produces);\n\n return this;\n }\n\n addProduce(produce: string) {\n const produces = uniq([].concat(this.get(\"produces\"), produce as never)).filter(Boolean);\n\n this.set(\"produces\", produces);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n this.operationPaths.set(String(method) + String(path), {\n ...options,\n method,\n path\n });\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const operation = super.toJSON({...options, ignore: [\"parameters\"]});\n const bodyParameters: JsonParameter[] = [];\n const parameters: any[] = [];\n\n if (operation.security) {\n operation.security = [].concat(operation.security);\n }\n\n this.get(\"parameters\").forEach((parameter: JsonParameter) => {\n if (!isParameterType(this.get(\"in\"))) {\n if (parameter.get(\"in\")) {\n if ([JsonParameterTypes.BODY, JsonParameterTypes.FILES].includes(parameter.get(\"in\"))) {\n bodyParameters.push(parameter);\n } else {\n parameters.push(...[].concat(parameter.toJSON(options)));\n }\n }\n }\n });\n\n operation.parameters = parameters.filter(Boolean);\n\n if (this.get(\"responses\").size === 0) {\n operation.responses = {\n \"200\": {\n description: getStatusMessage(200)\n }\n };\n }\n\n if (bodyParameters.length) {\n const parameter = buildSchemaFromBodyParameters(bodyParameters, options);\n operation.requestBody = toRequestBody(this, parameter).toJSON(options);\n }\n\n delete operation.consumes;\n delete operation.produces;\n\n return operation;\n }\n}\n\nfunction toRequestBody(operation: JsonOperation, {schema, in: _, ...props}: any) {\n const requestBody = new JsonRequestBody(props);\n\n const consumes = operation.get(\"consumes\")?.length ? operation.get(\"consumes\") : [\"application/json\"];\n\n consumes.forEach((consume: string) => {\n requestBody.addContent(consume, schema);\n });\n\n return requestBody;\n}\n\nfunction buildSchemaFromBodyParameters(parameters: JsonParameter[], options: JsonSchemaOptions) {\n let schema = new JsonSchema();\n const props: any = {};\n const refs: JsonSchema[] = [];\n let propsLength = 0;\n\n parameters.forEach((parameter) => {\n const name = parameter.getName();\n\n Array.from(parameter.entries())\n .filter(([key]) => ![\"in\", \"name\"].includes(key))\n .forEach(([key, value]) => {\n if (props[key] === undefined) {\n props[key] = value;\n }\n });\n\n const jsonParameter = parameter.toJSON(options);\n\n if (name) {\n schema.addProperty(\n name,\n jsonParameter.schema || {\n type: jsonParameter.type\n }\n );\n\n if (parameter.get(\"required\")) {\n schema.addRequired(name);\n }\n\n propsLength++;\n } else {\n refs.push(jsonParameter);\n }\n });\n\n if (!propsLength) {\n if (refs.length === 1) {\n return refs[0];\n }\n }\n\n schema.type(\"object\");\n\n return {schema: schema.toJSON(options), required: false, ...props};\n}\n"]}
@@ -1,9 +1,5 @@
1
1
  import { OperationMethods } from "../constants/httpMethods.js";
2
2
  export class JsonOperationPathsMap extends Map {
3
- constructor() {
4
- super(...arguments);
5
- this.getKey = (method, path) => `${method}-${path}`;
6
- }
7
3
  setOperationPath(operationPath) {
8
4
  if (operationPath.method !== OperationMethods.CUSTOM) {
9
5
  const key = this.getKey(operationPath.method, operationPath.path);
@@ -12,6 +8,7 @@ export class JsonOperationPathsMap extends Map {
12
8
  this.setFinalRoute(key, operationPath);
13
9
  }
14
10
  }
11
+ getKey = (method, path) => `${method}-${path}`;
15
12
  updateFinalRouteState(key) {
16
13
  if (this.has(key)) {
17
14
  this.get(key).isFinal = false;
@@ -1 +1 @@
1
- {"version":3,"file":"JsonOperationPathsMap.js","sourceRoot":"","sources":["../../../src/domain/JsonOperationPathsMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAG1D,MAAM,OAAO,qBAAsB,SAAQ,GAA2B;IAAtE;;QAUY,WAAM,GAAG,CAAC,MAAc,EAAE,IAAS,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;IAYxE,CAAC;IArBC,gBAAgB,CAAC,aAA6B;QAC5C,IAAI,aAAa,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,EAAE;YACpD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;YAClE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAClF,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;SACxC;IACH,CAAC;IAIS,qBAAqB,CAAC,GAAW;QACzC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,OAAO,GAAG,KAAK,CAAC;SAChC;IACH,CAAC;IAES,aAAa,CAAC,GAAW,EAAE,aAA6B;QAChE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QAC7B,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import {OperationMethods} from \"../constants/httpMethods\";\nimport {JsonMethodPath} from \"./JsonOperation\";\n\nexport class JsonOperationPathsMap extends Map<string, JsonMethodPath> {\n setOperationPath(operationPath: JsonMethodPath) {\n if (operationPath.method !== OperationMethods.CUSTOM) {\n const key = this.getKey(operationPath.method, operationPath.path);\n this.updateFinalRouteState(key);\n this.updateFinalRouteState(this.getKey(OperationMethods.ALL, operationPath.path));\n this.setFinalRoute(key, operationPath);\n }\n }\n\n protected getKey = (method: string, path: any) => `${method}-${path}`;\n\n protected updateFinalRouteState(key: string) {\n if (this.has(key)) {\n this.get(key)!.isFinal = false;\n }\n }\n\n protected setFinalRoute(key: string, operationPath: JsonMethodPath) {\n this.set(key, operationPath);\n operationPath.isFinal = true;\n }\n}\n"]}
1
+ {"version":3,"file":"JsonOperationPathsMap.js","sourceRoot":"","sources":["../../../src/domain/JsonOperationPathsMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAG1D,MAAM,OAAO,qBAAsB,SAAQ,GAA2B;IACpE,gBAAgB,CAAC,aAA6B;QAC5C,IAAI,aAAa,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,EAAE;YACpD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;YAClE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAClF,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;SACxC;IACH,CAAC;IAES,MAAM,GAAG,CAAC,MAAc,EAAE,IAAS,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;IAE5D,qBAAqB,CAAC,GAAW;QACzC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,OAAO,GAAG,KAAK,CAAC;SAChC;IACH,CAAC;IAES,aAAa,CAAC,GAAW,EAAE,aAA6B;QAChE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QAC7B,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import {OperationMethods} from \"../constants/httpMethods\";\nimport {JsonMethodPath} from \"./JsonOperation\";\n\nexport class JsonOperationPathsMap extends Map<string, JsonMethodPath> {\n setOperationPath(operationPath: JsonMethodPath) {\n if (operationPath.method !== OperationMethods.CUSTOM) {\n const key = this.getKey(operationPath.method, operationPath.path);\n this.updateFinalRouteState(key);\n this.updateFinalRouteState(this.getKey(OperationMethods.ALL, operationPath.path));\n this.setFinalRoute(key, operationPath);\n }\n }\n\n protected getKey = (method: string, path: any) => `${method}-${path}`;\n\n protected updateFinalRouteState(key: string) {\n if (this.has(key)) {\n this.get(key)!.isFinal = false;\n }\n }\n\n protected setFinalRoute(key: string, operationPath: JsonMethodPath) {\n this.set(key, operationPath);\n operationPath.isFinal = true;\n }\n}\n"]}
@@ -1,5 +1,10 @@
1
1
  import { concatPath } from "../utils/concatPath.js";
2
2
  export class JsonOperationRoute {
3
+ token;
4
+ endpoint;
5
+ operationPath;
6
+ basePath;
7
+ paramsTypes;
3
8
  constructor(options) {
4
9
  Object.assign(this, options);
5
10
  this.paramsTypes = this.endpoint.getParamTypes();
@@ -8,19 +13,16 @@ export class JsonOperationRoute {
8
13
  return this.fullPath;
9
14
  }
10
15
  get path() {
11
- var _a;
12
- return (_a = this.operationPath) === null || _a === void 0 ? void 0 : _a.path;
16
+ return this.operationPath?.path;
13
17
  }
14
18
  get fullPath() {
15
19
  return concatPath(this.basePath, this.path);
16
20
  }
17
21
  get method() {
18
- var _a;
19
- return ((_a = this.operationPath) === null || _a === void 0 ? void 0 : _a.method) || "USE";
22
+ return this.operationPath?.method || "USE";
20
23
  }
21
24
  get isFinal() {
22
- var _a;
23
- return !!((_a = this.operationPath) === null || _a === void 0 ? void 0 : _a.isFinal);
25
+ return !!this.operationPath?.isFinal;
24
26
  }
25
27
  get name() {
26
28
  return `${this.endpoint.targetName}.${this.methodClassName}()`;
@@ -1 +1 @@
1
- {"version":3,"file":"JsonOperationRoute.js","sourceRoot":"","sources":["../../../src/domain/JsonOperationRoute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAE/C,MAAM,O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AAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,SAA0B,CAAC;IAClD,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACxE,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonMethodPath, JsonOperation} from \"./JsonOperation\";\nimport {concatPath} from \"../utils/concatPath\";\n\nexport class JsonOperationRoute<Entity extends JsonMethodStore = JsonMethodStore> {\n readonly token: Type<any>;\n readonly endpoint: Entity;\n readonly operationPath?: JsonMethodPath;\n readonly basePath?: string;\n readonly paramsTypes: Record<string, boolean>;\n\n constructor(options: Partial<JsonOperationRoute>) {\n Object.assign(this, options);\n\n this.paramsTypes = this.endpoint.getParamTypes();\n }\n\n get url() {\n return this.fullPath;\n }\n\n get path() {\n return this.operationPath?.path;\n }\n\n get fullPath() {\n return concatPath(this.basePath, this.path as any);\n }\n\n get method() {\n return this.operationPath?.method || \"USE\";\n }\n\n get isFinal() {\n return !!this.operationPath?.isFinal;\n }\n\n get name() {\n return `${this.endpoint.targetName}.${this.methodClassName}()`;\n }\n\n get className() {\n return this.endpoint.targetName;\n }\n\n get methodClassName() {\n return this.propertyKey;\n }\n\n get parameters() {\n return this.endpoint.parameters;\n }\n\n get propertyKey() {\n return String(this.endpoint.propertyKey);\n }\n\n get propertyName() {\n return this.endpoint.propertyName;\n }\n\n get store() {\n return this.endpoint.store;\n }\n\n get operation(): JsonOperation {\n return this.endpoint.operation as JsonOperation;\n }\n\n get operationId() {\n return this.operation.get(\"operationId\") || this.endpoint.propertyKey;\n }\n\n has(key: string) {\n return this.paramsTypes[key];\n }\n}\n"]}
1
+ {"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C,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;IACpC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,SAA0B,CAAC;IAClD,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACxE,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonMethodPath, JsonOperation} from \"./JsonOperation\";\nimport {concatPath} from \"../utils/concatPath\";\n\nexport class JsonOperationRoute<Entity extends JsonMethodStore = JsonMethodStore> {\n readonly token: Type<any>;\n readonly endpoint: Entity;\n readonly operationPath?: JsonMethodPath;\n readonly basePath?: string;\n readonly paramsTypes: Record<string, boolean>;\n\n constructor(options: Partial<JsonOperationRoute>) {\n Object.assign(this, options);\n\n this.paramsTypes = this.endpoint.getParamTypes();\n }\n\n get url() {\n return this.fullPath;\n }\n\n get path() {\n return this.operationPath?.path;\n }\n\n get fullPath() {\n return concatPath(this.basePath, this.path as any);\n }\n\n get method() {\n return this.operationPath?.method || \"USE\";\n }\n\n get isFinal() {\n return !!this.operationPath?.isFinal;\n }\n\n get name() {\n return `${this.endpoint.targetName}.${this.methodClassName}()`;\n }\n\n get className() {\n return this.endpoint.targetName;\n }\n\n get methodClassName() {\n return this.propertyKey;\n }\n\n get parameters() {\n return this.endpoint.parameters;\n }\n\n get propertyKey() {\n return String(this.endpoint.propertyKey);\n }\n\n get propertyName() {\n return this.endpoint.propertyName;\n }\n\n get store() {\n return this.endpoint.store;\n }\n\n get operation(): JsonOperation {\n return this.endpoint.operation as JsonOperation;\n }\n\n get operationId() {\n return this.operation.get(\"operationId\") || this.endpoint.propertyKey;\n }\n\n has(key: string) {\n return this.paramsTypes[key];\n }\n}\n"]}
@@ -5,10 +5,10 @@ import { JsonMap } from "./JsonMap.js";
5
5
  import { formatParameterType, isParameterType, JsonParameterTypes } from "./JsonParameterTypes.js";
6
6
  import { createRefName } from "../utils/ref.js";
7
7
  export class JsonParameter extends JsonMap {
8
- constructor() {
9
- super(...arguments);
10
- this.nestedGenerics = [];
11
- }
8
+ nestedGenerics = [];
9
+ groups;
10
+ $schema;
11
+ expression;
12
12
  getName() {
13
13
  const name = this.get("name");
14
14
  if (this.get("in") === "files") {