@adaas/a-server 0.0.18 → 0.0.20

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 (173) hide show
  1. package/dist/index.d.mts +739 -0
  2. package/dist/index.d.ts +739 -36
  3. package/dist/index.js +1904 -102
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1862 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +6 -3
  8. package/src/channels/A-Websockets/A-Websockets.channel.ts +15 -0
  9. package/src/components/A-CommandController/A-CommandController.component.ts +0 -2
  10. package/src/components/A-EntityController/A-EntityController.component.ts +45 -1
  11. package/src/components/A-EntityRepository/A-EntityRepository.component.ts +25 -1
  12. package/src/components/A-ServerLogger/A_ServerLogger.component.ts +1 -1
  13. package/src/index.ts +75 -0
  14. package/tsconfig.build.json +9 -43
  15. package/tsconfig.json +4 -3
  16. package/tsup.config.ts +15 -0
  17. package/dist/src/channels/A-Http/A-Http.channel.constants.d.ts +0 -5
  18. package/dist/src/channels/A-Http/A-Http.channel.constants.js +0 -10
  19. package/dist/src/channels/A-Http/A-Http.channel.constants.js.map +0 -1
  20. package/dist/src/channels/A-Http/A-Http.channel.d.ts +0 -29
  21. package/dist/src/channels/A-Http/A-Http.channel.error.d.ts +0 -4
  22. package/dist/src/channels/A-Http/A-Http.channel.error.js +0 -9
  23. package/dist/src/channels/A-Http/A-Http.channel.error.js.map +0 -1
  24. package/dist/src/channels/A-Http/A-Http.channel.js +0 -154
  25. package/dist/src/channels/A-Http/A-Http.channel.js.map +0 -1
  26. package/dist/src/channels/A-Http/A-Http.channel.types.d.ts +0 -59
  27. package/dist/src/channels/A-Http/A-Http.channel.types.js +0 -3
  28. package/dist/src/channels/A-Http/A-Http.channel.types.js.map +0 -1
  29. package/dist/src/components/A-CommandController/A-CommandController.component.d.ts +0 -8
  30. package/dist/src/components/A-CommandController/A-CommandController.component.js +0 -56
  31. package/dist/src/components/A-CommandController/A-CommandController.component.js.map +0 -1
  32. package/dist/src/components/A-Controller/A-Controller.component.d.ts +0 -9
  33. package/dist/src/components/A-Controller/A-Controller.component.js +0 -60
  34. package/dist/src/components/A-Controller/A-Controller.component.js.map +0 -1
  35. package/dist/src/components/A-Controller/A-Controller.component.types.d.ts +0 -0
  36. package/dist/src/components/A-Controller/A-Controller.component.types.js +0 -2
  37. package/dist/src/components/A-Controller/A-Controller.component.types.js.map +0 -1
  38. package/dist/src/components/A-EntityController/A-EntityController.component.d.ts +0 -22
  39. package/dist/src/components/A-EntityController/A-EntityController.component.js +0 -188
  40. package/dist/src/components/A-EntityController/A-EntityController.component.js.map +0 -1
  41. package/dist/src/components/A-EntityController/A-EntityController.component.types.d.ts +0 -0
  42. package/dist/src/components/A-EntityController/A-EntityController.component.types.js +0 -2
  43. package/dist/src/components/A-EntityController/A-EntityController.component.types.js.map +0 -1
  44. package/dist/src/components/A-EntityRepository/A-EntityRepository.component.d.ts +0 -7
  45. package/dist/src/components/A-EntityRepository/A-EntityRepository.component.js +0 -96
  46. package/dist/src/components/A-EntityRepository/A-EntityRepository.component.js.map +0 -1
  47. package/dist/src/components/A-EntityRepository/A-EntityRepository.error.d.ts +0 -0
  48. package/dist/src/components/A-EntityRepository/A-EntityRepository.error.js +0 -2
  49. package/dist/src/components/A-EntityRepository/A-EntityRepository.error.js.map +0 -1
  50. package/dist/src/components/A-EntityRepository/A-EntityRepository.types.d.ts +0 -0
  51. package/dist/src/components/A-EntityRepository/A-EntityRepository.types.js +0 -2
  52. package/dist/src/components/A-EntityRepository/A-EntityRepository.types.js.map +0 -1
  53. package/dist/src/components/A-ListingController/A-ListingController.component.d.ts +0 -10
  54. package/dist/src/components/A-ListingController/A-ListingController.component.js +0 -72
  55. package/dist/src/components/A-ListingController/A-ListingController.component.js.map +0 -1
  56. package/dist/src/components/A-ListingController/A-ListingController.component.types.d.ts +0 -0
  57. package/dist/src/components/A-ListingController/A-ListingController.component.types.js +0 -2
  58. package/dist/src/components/A-ListingController/A-ListingController.component.types.js.map +0 -1
  59. package/dist/src/components/A-Router/A-Router.component.d.ts +0 -63
  60. package/dist/src/components/A-Router/A-Router.component.js +0 -221
  61. package/dist/src/components/A-Router/A-Router.component.js.map +0 -1
  62. package/dist/src/components/A-Router/A-Router.component.types.d.ts +0 -26
  63. package/dist/src/components/A-Router/A-Router.component.types.js +0 -17
  64. package/dist/src/components/A-Router/A-Router.component.types.js.map +0 -1
  65. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.d.ts +0 -9
  66. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.d.ts +0 -2
  67. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.js +0 -11
  68. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.defaults.js.map +0 -1
  69. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.js +0 -70
  70. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.js.map +0 -1
  71. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.d.ts +0 -7
  72. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.js +0 -3
  73. package/dist/src/components/A-ServerCORS/A_ServerCORS.component.types.js.map +0 -1
  74. package/dist/src/components/A-ServerError/A-ServerError.class.d.ts +0 -7
  75. package/dist/src/components/A-ServerError/A-ServerError.class.js +0 -88
  76. package/dist/src/components/A-ServerError/A-ServerError.class.js.map +0 -1
  77. package/dist/src/components/A-ServerError/A-ServerError.constants.d.ts +0 -0
  78. package/dist/src/components/A-ServerError/A-ServerError.constants.js +0 -2
  79. package/dist/src/components/A-ServerError/A-ServerError.constants.js.map +0 -1
  80. package/dist/src/components/A-ServerError/A-ServerError.types.d.ts +0 -13
  81. package/dist/src/components/A-ServerError/A-ServerError.types.js +0 -3
  82. package/dist/src/components/A-ServerError/A-ServerError.types.js.map +0 -1
  83. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.ts +0 -7
  84. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js +0 -81
  85. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js.map +0 -1
  86. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.d.ts +0 -0
  87. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.js +0 -2
  88. package/dist/src/components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.js.map +0 -1
  89. package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.d.ts +0 -22
  90. package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.js +0 -31
  91. package/dist/src/components/A-ServerLogger/A-ServerLogger.constants.js.map +0 -1
  92. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.d.ts +0 -43
  93. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.js +0 -167
  94. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.js.map +0 -1
  95. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.d.ts +0 -9
  96. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.js +0 -3
  97. package/dist/src/components/A-ServerLogger/A_ServerLogger.component.types.js.map +0 -1
  98. package/dist/src/components/A-ServerProxy/A-ServerProxy.component.d.ts +0 -9
  99. package/dist/src/components/A-ServerProxy/A-ServerProxy.component.js +0 -88
  100. package/dist/src/components/A-ServerProxy/A-ServerProxy.component.js.map +0 -1
  101. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.d.ts +0 -12
  102. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.js +0 -126
  103. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.js.map +0 -1
  104. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.d.ts +0 -10
  105. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.js +0 -109
  106. package/dist/src/components/A-StaticLoader/A-StaticLoader.component.types.js.map +0 -1
  107. package/dist/src/constants/env.constants.d.ts +0 -10
  108. package/dist/src/constants/env.constants.js +0 -20
  109. package/dist/src/constants/env.constants.js.map +0 -1
  110. package/dist/src/containers/A-Service/A-Service.container.d.ts +0 -30
  111. package/dist/src/containers/A-Service/A-Service.container.js +0 -200
  112. package/dist/src/containers/A-Service/A-Service.container.js.map +0 -1
  113. package/dist/src/containers/A-Service/A-Service.container.types.d.ts +0 -36
  114. package/dist/src/containers/A-Service/A-Service.container.types.js +0 -27
  115. package/dist/src/containers/A-Service/A-Service.container.types.js.map +0 -1
  116. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.d.ts +0 -39
  117. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.js +0 -69
  118. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.js.map +0 -1
  119. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.d.ts +0 -5
  120. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.js +0 -3
  121. package/dist/src/context/A-EntityFactory/A-EntityFactory.context.types.js.map +0 -1
  122. package/dist/src/context/A-HttpChannel/A-HttpChannel.context.d.ts +0 -12
  123. package/dist/src/context/A-HttpChannel/A-HttpChannel.context.js +0 -16
  124. package/dist/src/context/A-HttpChannel/A-HttpChannel.context.js.map +0 -1
  125. package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.d.ts +0 -10
  126. package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.js +0 -30
  127. package/dist/src/context/A-ListQueryFilter/A_ListQueryFilter.context.js.map +0 -1
  128. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.d.ts +0 -2
  129. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.js +0 -12
  130. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.constants.js.map +0 -1
  131. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.d.ts +0 -29
  132. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.js +0 -60
  133. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.context.js.map +0 -1
  134. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.d.ts +0 -18
  135. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.js +0 -3
  136. package/dist/src/context/A-ProxyConfig/A_ProxyConfig.types.js.map +0 -1
  137. package/dist/src/context/A-Server/A_Server.context.d.ts +0 -17
  138. package/dist/src/context/A-Server/A_Server.context.js +0 -22
  139. package/dist/src/context/A-Server/A_Server.context.js.map +0 -1
  140. package/dist/src/context/A-Server/A_Server.context.types.d.ts +0 -7
  141. package/dist/src/context/A-Server/A_Server.context.types.js +0 -3
  142. package/dist/src/context/A-Server/A_Server.context.types.js.map +0 -1
  143. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.d.ts +0 -16
  144. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.js +0 -28
  145. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.js.map +0 -1
  146. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.d.ts +0 -0
  147. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.js +0 -2
  148. package/dist/src/context/A-StaticConfig/A-StaticConfig.context.types.js.map +0 -1
  149. package/dist/src/entities/A-Request/A-Request.entity.d.ts +0 -31
  150. package/dist/src/entities/A-Request/A-Request.entity.js +0 -125
  151. package/dist/src/entities/A-Request/A-Request.entity.js.map +0 -1
  152. package/dist/src/entities/A-Request/A-Request.entity.types.d.ts +0 -21
  153. package/dist/src/entities/A-Request/A-Request.entity.types.js +0 -12
  154. package/dist/src/entities/A-Request/A-Request.entity.types.js.map +0 -1
  155. package/dist/src/entities/A-Response/A-Response.entity.d.ts +0 -28
  156. package/dist/src/entities/A-Response/A-Response.entity.js +0 -141
  157. package/dist/src/entities/A-Response/A-Response.entity.js.map +0 -1
  158. package/dist/src/entities/A-Response/A-Response.entity.types.d.ts +0 -19
  159. package/dist/src/entities/A-Response/A-Response.entity.types.js +0 -12
  160. package/dist/src/entities/A-Response/A-Response.entity.types.js.map +0 -1
  161. package/dist/src/entities/A-Route/A-Route.entity.d.ts +0 -17
  162. package/dist/src/entities/A-Route/A-Route.entity.js +0 -76
  163. package/dist/src/entities/A-Route/A-Route.entity.js.map +0 -1
  164. package/dist/src/entities/A-Route/A-Route.entity.types.d.ts +0 -0
  165. package/dist/src/entities/A-Route/A-Route.entity.types.js +0 -2
  166. package/dist/src/entities/A-Route/A-Route.entity.types.js.map +0 -1
  167. package/dist/src/entities/A_EntityList/A_EntityList.entity.d.ts +0 -46
  168. package/dist/src/entities/A_EntityList/A_EntityList.entity.js +0 -91
  169. package/dist/src/entities/A_EntityList/A_EntityList.entity.js.map +0 -1
  170. package/dist/src/entities/A_EntityList/A_EntityList.entity.types.d.ts +0 -21
  171. package/dist/src/entities/A_EntityList/A_EntityList.entity.types.js +0 -8
  172. package/dist/src/entities/A_EntityList/A_EntityList.entity.types.js.map +0 -1
  173. package/index.ts +0 -75
package/src/index.ts ADDED
@@ -0,0 +1,75 @@
1
+
2
+
3
+ // ============================================================================
4
+ // ADAAS A-Server SDK - Complete Export Manifest
5
+ // ============================================================================
6
+
7
+ // ============================================================================
8
+ // Channels Export
9
+ // ============================================================================
10
+ export { A_HTTPChannel } from './channels/A-Http/A-Http.channel';
11
+ export { A_HTTPChannelError } from './channels/A-Http/A-Http.channel.error';
12
+
13
+
14
+ // ============================================================================
15
+ // Constants Export
16
+ // ============================================================================
17
+ export * from './constants/env.constants';
18
+
19
+
20
+ // ============================================================================
21
+ // Containers Export
22
+ // ============================================================================
23
+ export { A_Service } from './containers/A-Service/A-Service.container';
24
+
25
+
26
+ // ============================================================================
27
+ // Contexts Export
28
+ // ============================================================================
29
+ export { A_Server } from './context/A-Server/A_Server.context';
30
+ export { A_ProxyConfig } from './context/A-ProxyConfig/A_ProxyConfig.context';
31
+ export { A_StaticConfig } from './context/A-StaticConfig/A-StaticConfig.context';
32
+ export { A_ListQueryFilter } from './context/A-ListQueryFilter/A_ListQueryFilter.context';
33
+ export { A_EntityFactory } from './context/A-EntityFactory/A-EntityFactory.context';
34
+ export { A_HTTPChannel_RequestContext } from './context/A-HttpChannel/A-HttpChannel.context';
35
+
36
+
37
+ // ============================================================================
38
+ // Entities Export
39
+ // ============================================================================
40
+ export { A_Request } from './entities/A-Request/A-Request.entity';
41
+ export { A_Response } from './entities/A-Response/A-Response.entity';
42
+ export { A_Route } from './entities/A-Route/A-Route.entity';
43
+ export { A_EntityList } from './entities/A_EntityList/A_EntityList.entity';
44
+
45
+
46
+ // ============================================================================
47
+ // Components Export
48
+ // ============================================================================
49
+ export { A_ServerLogger } from './components/A-ServerLogger/A_ServerLogger.component';
50
+ export { A_EntityController } from './components/A-EntityController/A-EntityController.component';
51
+ export { A_Router } from './components/A-Router/A-Router.component';
52
+ export { A_ServerHealthMonitor } from './components/A-ServerHealthMonitor/A-ServerHealthMonitor.component';
53
+ export { A_ServerProxy } from './components/A-ServerProxy/A-ServerProxy.component';
54
+ export { A_ServerCORS } from './components/A-ServerCORS/A_ServerCORS.component';
55
+ export { A_StaticLoader } from './components/A-StaticLoader/A-StaticLoader.component';
56
+ export { A_Controller } from './components/A-Controller/A-Controller.component';
57
+ export { A_ListingController } from './components/A-ListingController/A-ListingController.component';
58
+ export { A_CommandController } from './components/A-CommandController/A-CommandController.component';
59
+ export { A_EntityRepository } from './components/A-EntityRepository/A-EntityRepository.component';
60
+ export { A_ServerError } from './components/A-ServerError/A-ServerError.class';
61
+
62
+
63
+ // ============================================================================
64
+ // Types Export
65
+ // ============================================================================
66
+ export * from './containers/A-Service/A-Service.container.types';
67
+ export * from './context/A-ProxyConfig/A_ProxyConfig.types';
68
+ export * from './context/A-EntityFactory/A-EntityFactory.context.types';
69
+ export * from './entities/A-Request/A-Request.entity.types';
70
+ export * from './entities/A-Response/A-Response.entity.types';
71
+ export * from './components/A-ServerCORS/A_ServerCORS.component.types';
72
+ export * from './components/A-Router/A-Router.component.types';
73
+ export * from './components/A-ServerError/A-ServerError.types';
74
+ export * from './channels/A-Http/A-Http.channel.types';
75
+ export * from './channels/A-Http/A-Http.channel.constants';
@@ -1,62 +1,28 @@
1
1
  {
2
- "compileOnSave": false,
3
2
  "compilerOptions": {
4
- "outDir": "dist",
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "jsx": "react-jsx",
5
6
  "strict": true,
6
- "noImplicitAny": false,
7
- "noFallthroughCasesInSwitch": true,
8
- "downlevelIteration": true,
9
- "strictFunctionTypes": true,
10
- "strictNullChecks": true,
11
- "strictPropertyInitialization": true,
12
- "forceConsistentCasingInFileNames": true,
13
7
  "resolveJsonModule": true,
14
- "noErrorTruncation": true,
15
- "jsx": "react",
16
- "target": "es2015",
17
- "module": "commonjs",
18
- "moduleResolution": "node",
19
- "allowSyntheticDefaultImports": true,
20
8
  "esModuleInterop": true,
21
- "noUnusedLocals": false,
22
- "noUnusedParameters": false,
23
- "removeComments": false,
24
- "preserveConstEnums": true,
25
- "sourceMap": true,
26
- "baseUrl": ".",
9
+ "allowSyntheticDefaultImports": true,
27
10
  "experimentalDecorators": true,
28
11
  "skipLibCheck": true,
29
- "typeRoots": [
30
- "node_modules/@types"
31
- ],
12
+ "baseUrl": ".",
32
13
  "paths": {
33
- "@adaas/a-server/constants/*": ["src/constants/*"],
14
+ "@adaas/a-server/constants/*": ["src/constants/*"],
34
15
  "@adaas/a-server/defaults/*": ["src/defaults/*"],
35
16
  "@adaas/a-server/decorators/*": ["src/decorators/*"],
36
17
  "@adaas/a-server/helpers/*": ["src/helpers/*"],
37
18
  "@adaas/a-server/examples/*": ["src/examples/*"],
38
19
  "@adaas/a-server/entities/*": ["src/entities/*"],
39
20
  "@adaas/a-server/channels/*": ["src/channels/*"],
40
-
41
21
  "@adaas/a-server/context/*": ["src/context/*"],
42
22
  "@adaas/a-server/components/*": ["src/components/*"],
43
23
  "@adaas/a-server/containers/*": ["src/containers/*"]
44
- },
45
- "lib": [
46
- "dom",
47
- "esnext.asynciterable",
48
- "es2015",
49
- "es2016",
50
- "es2017.object"
51
- ]
24
+ }
52
25
  },
53
- "include": [
54
- "src/**/*",
55
- "index.ts"
56
- ],
57
- "exclude": [
58
- "node_modules/**/*",
59
- "dist/**/*",
60
- "node_modules/@types/mocha/index.d.ts"
61
- ]
26
+ "include": ["src/**/*", "index.ts"],
27
+ "exclude": ["node_modules", "dist"]
62
28
  }
package/tsconfig.json CHANGED
@@ -13,8 +13,9 @@
13
13
  "resolveJsonModule": true,
14
14
  "noErrorTruncation": true,
15
15
  "jsx": "react",
16
- "target": "ES6",
17
- "module": "commonjs",
16
+ "target": "es2020",
17
+ "module": "esnext",
18
+ "declaration": true,
18
19
  "moduleResolution": "node",
19
20
  "allowSyntheticDefaultImports": true,
20
21
  "esModuleInterop": true,
@@ -55,7 +56,7 @@
55
56
  "src/**/*",
56
57
  "tests/**/*",
57
58
  "examples/**/*",
58
- "index.ts"
59
+ "src/index.ts"
59
60
  ],
60
61
  "exclude": [
61
62
  "node_modules/**/*",
package/tsup.config.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"], // 👈 adjust if your main file is elsewhere
5
+ format: ["esm", "cjs"], // both Node (CJS) and ESM builds
6
+ dts: true, // generate declaration files
7
+ sourcemap: true, // helpful for debugging
8
+ clean: true, // clear dist/ before build
9
+ target: "es2020", // good for both Node 18+ and browsers
10
+ treeshake: true, // ✅ enable tree-shaking
11
+ skipNodeModulesBundle: true, // do NOT bundle node_modules (leave them external)
12
+ splitting: false, // one file per format (simpler)
13
+ minify: false, // optional: turn on if you want smaller bundle
14
+ platform: "neutral", // 👈 important: works in Node & browser
15
+ });
@@ -1,5 +0,0 @@
1
- export declare enum A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle {
2
- onAfterRequest = "onAfterHttpChannelRequest",
3
- onError = "onHttpChannelError",
4
- onBeforeRequest = "onBeforeHttpChannelRequest"
5
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle = void 0;
4
- var A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle;
5
- (function (A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle) {
6
- A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle["onAfterRequest"] = "onAfterHttpChannelRequest";
7
- A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle["onError"] = "onHttpChannelError";
8
- A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle["onBeforeRequest"] = "onBeforeHttpChannelRequest";
9
- })(A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle || (exports.A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle = A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle = {}));
10
- //# sourceMappingURL=A-Http.channel.constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Http.channel.constants.js","sourceRoot":"","sources":["../../../../src/channels/A-Http/A-Http.channel.constants.ts"],"names":[],"mappings":";;;AAGA,IAAY,2CAIX;AAJD,WAAY,2CAA2C;IACnD,2FAA4C,CAAA;IAC5C,6EAA8B,CAAA;IAC9B,6FAA8C,CAAA;AAClD,CAAC,EAJW,2CAA2C,2DAA3C,2CAA2C,QAItD"}
@@ -1,29 +0,0 @@
1
- import { A_HTTPChannel_RequestContext } from "../../context/A-HttpChannel/A-HttpChannel.context";
2
- import { A_Channel } from "@adaas/a-utils";
3
- import { A_SERVER_TYPES__HttpChannelRequestConfig, A_SERVER_TYPES__HttpChannelRequestParams, A_SERVER_TYPES__HttpChannelSendParams } from "./A-Http.channel.types";
4
- export declare class A_HTTPChannel extends A_Channel {
5
- protected baseUrl?: string;
6
- connect(): Promise<void>;
7
- /**
8
- * Allows to send an HTTP request without expecting a response
9
- *
10
- * @param params
11
- */
12
- send(params: A_SERVER_TYPES__HttpChannelSendParams): Promise<void>;
13
- /**
14
- * Makes an HTTP request
15
- *
16
- * @param params
17
- * @returns
18
- */
19
- request<T = any, M extends Record<string, any> = any>(
20
- /**
21
- * Provide request parameters
22
- */
23
- params: A_SERVER_TYPES__HttpChannelRequestParams<M>): Promise<A_HTTPChannel_RequestContext<T>>;
24
- post<T, M extends Record<string, any> = any>(url: string, body?: any, config?: Partial<A_SERVER_TYPES__HttpChannelRequestConfig>): Promise<A_HTTPChannel_RequestContext<T>>;
25
- get<T, M extends Record<string, any> = any>(url: string, params?: any, config?: Partial<A_SERVER_TYPES__HttpChannelRequestConfig>): Promise<A_HTTPChannel_RequestContext<T>>;
26
- put<T, M extends Record<string, any> = any>(url: string, body?: any, config?: Partial<A_SERVER_TYPES__HttpChannelRequestConfig>): Promise<A_HTTPChannel_RequestContext<T>>;
27
- delete<T, M extends Record<string, any> = any>(url: string, params?: any, config?: Partial<A_SERVER_TYPES__HttpChannelRequestConfig>): Promise<A_HTTPChannel_RequestContext<T>>;
28
- protected buildURL(path?: string, params?: Record<string, any>): string;
29
- }
@@ -1,4 +0,0 @@
1
- import { A_Error } from "@adaas/a-concept";
2
- export declare class A_HTTPChannelError extends A_Error {
3
- static readonly HttpRequestError = "HTTP Channel Request Error";
4
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_HTTPChannelError = void 0;
4
- const a_concept_1 = require("@adaas/a-concept");
5
- class A_HTTPChannelError extends a_concept_1.A_Error {
6
- }
7
- exports.A_HTTPChannelError = A_HTTPChannelError;
8
- A_HTTPChannelError.HttpRequestError = 'HTTP Channel Request Error';
9
- //# sourceMappingURL=A-Http.channel.error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Http.channel.error.js","sourceRoot":"","sources":["../../../../src/channels/A-Http/A-Http.channel.error.ts"],"names":[],"mappings":";;;AAAA,gDAA2C;AAG3C,MAAa,kBAAmB,SAAQ,mBAAO;;AAA/C,gDAIC;AAFmB,mCAAgB,GAAG,4BAA4B,CAAC"}
@@ -1,154 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.A_HTTPChannel = void 0;
13
- const a_concept_1 = require("@adaas/a-concept");
14
- const A_Service_container_types_1 = require("../../containers/A-Service/A-Service.container.types");
15
- const A_HttpChannel_context_1 = require("../../context/A-HttpChannel/A-HttpChannel.context");
16
- const A_Http_channel_constants_1 = require("./A-Http.channel.constants");
17
- const A_ServerError_class_1 = require("../../components/A-ServerError/A-ServerError.class");
18
- const a_utils_1 = require("@adaas/a-utils");
19
- const A_Http_channel_error_1 = require("./A-Http.channel.error");
20
- class A_HTTPChannel extends a_utils_1.A_Channel {
21
- connect() {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- // keep it empty since HTTP channel does not require persistent connection
24
- return;
25
- });
26
- }
27
- /**
28
- * Allows to send an HTTP request without expecting a response
29
- *
30
- * @param params
31
- */
32
- send(params) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- this.request(params);
35
- });
36
- }
37
- /**
38
- * Makes an HTTP request
39
- *
40
- * @param params
41
- * @returns
42
- */
43
- request(
44
- /**
45
- * Provide request parameters
46
- */
47
- params) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- var _a, _b;
50
- const { method, url, data, config } = params;
51
- yield this.initialize;
52
- this._processing = true;
53
- const fullUrl = this.buildURL(url, config === null || config === void 0 ? void 0 : config.params);
54
- const requestScope = new a_concept_1.A_Scope({ name: `a-http-channel-request-scope-${method}-${url}-${Date.now()}` });
55
- const context = new A_HttpChannel_context_1.A_HTTPChannel_RequestContext({
56
- method,
57
- url,
58
- data,
59
- config
60
- });
61
- requestScope.inherit(a_concept_1.A_Context.scope(this));
62
- requestScope.register(context);
63
- try {
64
- yield this.call(A_Http_channel_constants_1.A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle.onBeforeRequest, requestScope);
65
- const headers = Object.assign({ "Content-Type": "application/json" }, config === null || config === void 0 ? void 0 : config.headers);
66
- const options = {
67
- method,
68
- headers,
69
- };
70
- if (data && method !== A_Service_container_types_1.A_SERVER_TYPES__ServerMethod.GET) {
71
- options.body = JSON.stringify(data);
72
- }
73
- const response = yield fetch(fullUrl, options);
74
- if (!response.ok) {
75
- throw new A_ServerError_class_1.A_ServerError({
76
- status: response.status,
77
- title: response.statusText,
78
- description: `HTTP request to ${fullUrl} failed with status ${response.status}`,
79
- });
80
- }
81
- context.result =
82
- ((_a = config === null || config === void 0 ? void 0 : config.params) === null || _a === void 0 ? void 0 : _a.responseType) === "text"
83
- ? yield response.text()
84
- : ((_b = config === null || config === void 0 ? void 0 : config.params) === null || _b === void 0 ? void 0 : _b.responseType) === "blob"
85
- ? yield response.blob()
86
- : yield response.json();
87
- yield this.call(A_Http_channel_constants_1.A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle.onAfterRequest, requestScope);
88
- this._processing = false;
89
- return context;
90
- }
91
- catch (error) {
92
- this._processing = false;
93
- context.error = error;
94
- yield this.call(A_Http_channel_constants_1.A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle.onError, requestScope);
95
- if ((config === null || config === void 0 ? void 0 : config.throwOnError) === false)
96
- return context;
97
- else
98
- throw error;
99
- }
100
- });
101
- }
102
- post(url, body, config) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- return this.request({
105
- method: A_Service_container_types_1.A_SERVER_TYPES__ServerMethod.POST,
106
- url,
107
- data: body,
108
- config,
109
- });
110
- });
111
- }
112
- get(url, params, config) {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- return this.request({
115
- method: A_Service_container_types_1.A_SERVER_TYPES__ServerMethod.GET,
116
- url,
117
- config: Object.assign(Object.assign({}, config), { params })
118
- });
119
- });
120
- }
121
- put(url, body, config) {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- return this.request({
124
- method: A_Service_container_types_1.A_SERVER_TYPES__ServerMethod.PUT,
125
- url,
126
- data: body,
127
- config,
128
- });
129
- });
130
- }
131
- delete(url, params, config) {
132
- return __awaiter(this, void 0, void 0, function* () {
133
- return this.request({
134
- method: A_Service_container_types_1.A_SERVER_TYPES__ServerMethod.DELETE,
135
- url,
136
- data: params,
137
- config,
138
- });
139
- });
140
- }
141
- buildURL(path = '', params = {}) {
142
- if (!this.baseUrl)
143
- throw new A_Http_channel_error_1.A_HTTPChannelError(A_Http_channel_error_1.A_HTTPChannelError.HttpRequestError, "Base URL is not set for HTTP Channel");
144
- const url = new URL(`${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`);
145
- Object.keys(params).forEach(key => {
146
- if (params[key] !== undefined && params[key] !== null) {
147
- url.searchParams.append(key, params[key]);
148
- }
149
- });
150
- return url.toString();
151
- }
152
- }
153
- exports.A_HTTPChannel = A_HTTPChannel;
154
- //# sourceMappingURL=A-Http.channel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Http.channel.js","sourceRoot":"","sources":["../../../../src/channels/A-Http/A-Http.channel.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAAsD;AACtD,oGAAoG;AACpG,6FAAiG;AACjG,yEAAyF;AACzF,sGAA6F;AAC7F,4CAA2C;AAC3C,iEAA4D;AAK5D,MAAa,aAAc,SAAQ,mBAAS;IAKlC,OAAO;;YACT,0EAA0E;YAC1E,OAAO;QACX,CAAC;KAAA;IAED;;;;OAIG;IACG,IAAI,CAAC,MAA6C;;YACpD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;KAAA;IAED;;;;;OAKG;IACG,OAAO;IACT;;OAEG;IACH,MAAmD;;;YAEnD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;Y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CAAC;YAC9C,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAA;IACzB,CAAC;CACJ;AAtLD,sCAsLC"}
@@ -1,59 +0,0 @@
1
- import { A_SERVER_TYPES__ServerMethod } from "../../containers/A-Service/A-Service.container.types";
2
- export type A_SERVER_TYPES__HttpChannelSendParams<M extends Record<string, any> = any> = {
3
- /**
4
- * HTTP Method
5
- */
6
- method: A_SERVER_TYPES__ServerMethod;
7
- /**
8
- * Request URL
9
- */
10
- url: string;
11
- /**
12
- * Request Body or Query Parameters
13
- */
14
- data?: any;
15
- /**
16
- * Request Configuration
17
- */
18
- config?: Partial<A_SERVER_TYPES__HttpChannelRequestConfig<M>>;
19
- };
20
- export type A_SERVER_TYPES__HttpChannelRequestParams<M extends Record<string, any> = any> = {
21
- /**
22
- * HTTP Method
23
- */
24
- method: A_SERVER_TYPES__ServerMethod;
25
- /**
26
- * Request URL
27
- */
28
- url: string;
29
- /**
30
- * Request Body or Query Parameters
31
- */
32
- data?: any;
33
- /**
34
- * Request Configuration
35
- */
36
- config?: Partial<A_SERVER_TYPES__HttpChannelRequestConfig<M>>;
37
- };
38
- export type A_SERVER_TYPES__HttpChannelRequestConfig<M extends Record<string, any> = any> = {
39
- /**
40
- * Response Type
41
- */
42
- responseType: "json" | "text" | "blob";
43
- /**
44
- * Request Headers
45
- */
46
- headers: Record<string, string>;
47
- /**
48
- * Query Parameters
49
- */
50
- params: Record<string, any>;
51
- /**
52
- * Metadata
53
- */
54
- meta: M;
55
- /**
56
- * Throw on Error
57
- */
58
- throwOnError: boolean;
59
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=A-Http.channel.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Http.channel.types.js","sourceRoot":"","sources":["../../../../src/channels/A-Http/A-Http.channel.types.ts"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- import { A_Component, A_Container, A_Scope } from "@adaas/a-concept";
2
- import { A_Request } from "../../entities/A-Request/A-Request.entity";
3
- import { A_Response } from "../../entities/A-Response/A-Response.entity";
4
- export declare class A_CommandController extends A_Component {
5
- handleCommand(req: A_Request<any, any, {
6
- command: string;
7
- }>, res: A_Response, scope: A_Scope, container: A_Container): Promise<void>;
8
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __param = (this && this.__param) || function (paramIndex, decorator) {
9
- return function (target, key) { decorator(target, key, paramIndex); }
10
- };
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.A_CommandController = void 0;
22
- const a_concept_1 = require("@adaas/a-concept");
23
- const A_Router_component_1 = require("../A-Router/A-Router.component");
24
- const A_Request_entity_1 = require("../../entities/A-Request/A-Request.entity");
25
- const A_Response_entity_1 = require("../../entities/A-Response/A-Response.entity");
26
- class A_CommandController extends a_concept_1.A_Component {
27
- handleCommand(req, res, scope, container) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const commandName = req.params.command;
30
- const CommandConstructor = scope.resolveConstructor(commandName);
31
- if (!CommandConstructor) {
32
- res.status(404);
33
- throw new Error(`Command ${commandName} not found`);
34
- }
35
- const command = new CommandConstructor(req.body);
36
- container.scope.register(command);
37
- console.log(`1) Executing command: ${commandName}`);
38
- yield command.execute();
39
- const serialized = command.toJSON();
40
- return res.status(200).json(serialized);
41
- });
42
- }
43
- }
44
- exports.A_CommandController = A_CommandController;
45
- __decorate([
46
- A_Router_component_1.A_Router.Get({
47
- path: "/:command/execute",
48
- version: "v1",
49
- prefix: "a-command"
50
- }),
51
- __param(0, (0, a_concept_1.A_Inject)(A_Request_entity_1.A_Request)),
52
- __param(1, (0, a_concept_1.A_Inject)(A_Response_entity_1.A_Response)),
53
- __param(2, (0, a_concept_1.A_Inject)(a_concept_1.A_Scope)),
54
- __param(3, (0, a_concept_1.A_Inject)(a_concept_1.A_Container))
55
- ], A_CommandController.prototype, "handleCommand", null);
56
- //# sourceMappingURL=A-CommandController.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-CommandController.component.js","sourceRoot":"","sources":["../../../../src/components/A-CommandController/A-CommandController.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gDAA+E;AAC/E,uEAA0D;AAC1D,0FAAgF;AAChF,6FAAmF;AAInF,MAAa,mBAAoB,SAAQ,uBAAW;IAO1C,aAAa,CACM,GAA6C,EAC5C,GAAe,EAClB,KAAc,EACV,SAAsB;;YAG7C,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC;YAEvC,MAAM,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAY,WAAW,CAAC,CAAC;YAE5E,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACtB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAEhB,MAAM,IAAI,KAAK,CAAC,WAAW,WAAW,YAAY,CAAC,CAAC;YACxD,CAAC;YAED,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAEjD,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAElC,OAAO,CAAC,GAAG,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;YAEpD,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YAExB,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAEpC,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;KAAA;CAEJ;AArCD,kDAqCC;AA9BS;IALL,6BAAQ,CAAC,GAAG,CAAC;QACV,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,WAAW;KACtB,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,4BAAS,CAAC,CAAA;IACnB,WAAA,IAAA,oBAAQ,EAAC,8BAAU,CAAC,CAAA;IACpB,WAAA,IAAA,oBAAQ,EAAC,mBAAO,CAAC,CAAA;IACjB,WAAA,IAAA,oBAAQ,EAAC,uBAAW,CAAC,CAAA;wDAwBzB"}
@@ -1,9 +0,0 @@
1
- import { A_Component, A_Scope } from "@adaas/a-concept";
2
- import { A_Response } from "../../entities/A-Response/A-Response.entity";
3
- import { A_Request } from "../../entities/A-Request/A-Request.entity";
4
- export declare class A_Controller extends A_Component {
5
- callEntityMethod(request: A_Request<any, any, {
6
- component: string;
7
- operation: string;
8
- }>, response: A_Response, scope: A_Scope): Promise<void>;
9
- }
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __param = (this && this.__param) || function (paramIndex, decorator) {
9
- return function (target, key) { decorator(target, key, paramIndex); }
10
- };
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.A_Controller = void 0;
22
- const a_concept_1 = require("@adaas/a-concept");
23
- const A_Router_component_1 = require("../A-Router/A-Router.component");
24
- const A_Response_entity_1 = require("../../entities/A-Response/A-Response.entity");
25
- const A_Request_entity_1 = require("../../entities/A-Request/A-Request.entity");
26
- class A_Controller extends a_concept_1.A_Component {
27
- callEntityMethod(request, response, scope) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- // check step by step each parameter to ensure they are valid
30
- if (!scope.has(request.params.component))
31
- return;
32
- if (!request.params.operation || typeof request.params.operation !== 'string')
33
- return;
34
- const possibleComponent = scope.resolve(request.params.component);
35
- if (!possibleComponent
36
- ||
37
- ![a_concept_1.A_Component, a_concept_1.A_Container]
38
- .some(c => possibleComponent instanceof c))
39
- return;
40
- const component = possibleComponent;
41
- const meta = a_concept_1.A_Context.meta(component);
42
- const targetFeature = meta.features().find(f => f.name === `${component.constructor.name}.${request.params.operation}`);
43
- if (!targetFeature)
44
- return;
45
- yield component.call(request.params.operation, scope);
46
- });
47
- }
48
- }
49
- exports.A_Controller = A_Controller;
50
- __decorate([
51
- A_Router_component_1.A_Router.Post({
52
- path: '/:component/:operation',
53
- version: 'v1',
54
- prefix: 'a-component'
55
- }),
56
- __param(0, (0, a_concept_1.A_Inject)(A_Request_entity_1.A_Request)),
57
- __param(1, (0, a_concept_1.A_Inject)(A_Response_entity_1.A_Response)),
58
- __param(2, (0, a_concept_1.A_Inject)(a_concept_1.A_Scope))
59
- ], A_Controller.prototype, "callEntityMethod", null);
60
- //# sourceMappingURL=A-Controller.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Controller.component.js","sourceRoot":"","sources":["../../../../src/components/A-Controller/A-Controller.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gDAAqG;AACrG,uEAA0D;AAC1D,6FAAmF;AACnF,0FAAgF;AAIhF,MAAa,YAAa,SAAQ,uBAAW;IAQnC,gBAAgB,CACG,OAGnB,EACoB,QAAoB,EACvB,KAAc;;YAGjC,8DAA8D;YAE9D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;gBACpC,OAAM;YAEV,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,KAAK,QAAQ;gBACzE,OAAO;YAGX,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAElE,IACI,CAAC,iBAAiB;;oBAElB,CAAC,CAAC,uBAAW,EAAE,uBAAW,CAAC;yBACtB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,YAAY,CAAC,CAAC;gBAE9C,OAAO;YAEX,MAAM,SAAS,GAAG,iBAA8C,CAAC;YAEjE,MAAM,IAAI,GAAG,qBAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAEvC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,C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