@xrystal/core 3.32.1 → 3.37.4

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 (264) hide show
  1. package/README.md +676 -136
  2. package/package.json +27 -24
  3. package/tsconfig.base.json +15 -0
  4. package/x/bin/commands/create.mjs +34 -5
  5. package/x/bin/commands/doctor.mjs +115 -25
  6. package/x/bin/commands/hooks.mjs +55 -0
  7. package/x/bin/commands/project.mjs +75 -42
  8. package/x/bin/commands/release.mjs +8 -3
  9. package/x/bin/commands/sync-toolchain.mjs +43 -0
  10. package/x/bin/commands/tmp.mjs +13 -4
  11. package/x/bin/helpers/.generated/.generated-from +1 -0
  12. package/x/bin/helpers/.generated/tmp-schema.mjs +192 -0
  13. package/x/bin/helpers/banner.mjs +66 -12
  14. package/x/bin/helpers/build-config.mjs +342 -0
  15. package/x/bin/helpers/cli-help.mjs +164 -0
  16. package/x/bin/helpers/create-target.mjs +18 -2
  17. package/x/bin/helpers/project-artifacts.mjs +142 -0
  18. package/x/bin/helpers/runtime-info.mjs +172 -0
  19. package/x/bin/helpers/tmp-config.mjs +11 -10
  20. package/x/bin/helpers/tmp-layout.mjs +10 -16
  21. package/x/bin/helpers/tmp-schema.mjs +9 -0
  22. package/x/bin/helpers/toolchain-config.mjs +233 -0
  23. package/x/bin/main-cli.js +31 -3
  24. package/x/bin/scripts/clean-source-types.mjs +19 -0
  25. package/x/bin/scripts/fix-dist-imports.mjs +80 -0
  26. package/x/bin/scripts/install-git-hooks.mjs +86 -0
  27. package/x/bin/scripts/minify-dist.mjs +50 -0
  28. package/x/bin/scripts/prepare-npm-publish.mjs +39 -0
  29. package/x/bin/scripts/publish-guard.mjs +113 -0
  30. package/x/bin/scripts/verify-npm-pack.mjs +12 -0
  31. package/x/bin/scripts/verify-publish-config.mjs +10 -0
  32. package/x/bin/scripts/verify-version-bump.mjs +27 -0
  33. package/x/bin/scripts/version-check.mjs +173 -0
  34. package/x/dist/index.js +1 -0
  35. package/x/dist/loader/clients/index.js +1 -0
  36. package/x/dist/loader/configs/index.js +1 -0
  37. package/{source → x/dist}/loader/controller/index.d.ts +20 -17
  38. package/x/dist/loader/controller/index.js +1 -0
  39. package/x/dist/loader/dto/index.js +1 -0
  40. package/x/dist/loader/events/index.js +1 -0
  41. package/x/dist/loader/index.d.ts +11 -0
  42. package/x/dist/loader/index.js +1 -0
  43. package/{source → x/dist}/loader/kafka/index.d.ts +1 -0
  44. package/x/dist/loader/kafka/index.js +1 -0
  45. package/x/dist/loader/localizations/index.js +1 -0
  46. package/{source → x/dist}/loader/logger/index.d.ts +1 -0
  47. package/x/dist/loader/logger/index.js +2 -0
  48. package/x/dist/loader/service/index.js +1 -0
  49. package/x/dist/loader/system/index.js +1 -0
  50. package/x/dist/project/index.d.ts +12 -0
  51. package/x/dist/project/index.js +1 -0
  52. package/x/dist/utils/constants/defaults.json +44 -0
  53. package/x/dist/utils/constants/index.js +1 -0
  54. package/x/dist/utils/helpers/configs/index.js +1 -0
  55. package/x/dist/utils/helpers/context/controller-store.js +1 -0
  56. package/x/dist/utils/helpers/context/index.js +1 -0
  57. package/{source → x/dist}/utils/helpers/core/index.d.ts +1 -1
  58. package/x/dist/utils/helpers/core/index.js +1 -0
  59. package/x/dist/utils/helpers/core/paths.js +1 -0
  60. package/x/dist/utils/helpers/core/tmp-layout.js +1 -0
  61. package/x/dist/utils/helpers/date/index.js +1 -0
  62. package/x/dist/utils/helpers/dispatch/index.js +1 -0
  63. package/x/dist/utils/helpers/dto/index.js +1 -0
  64. package/x/dist/utils/helpers/filters/index.js +1 -0
  65. package/x/dist/utils/helpers/framework/index.js +1 -0
  66. package/x/dist/utils/helpers/handlers/adapters.js +1 -0
  67. package/x/dist/utils/helpers/handlers/execute.js +1 -0
  68. package/x/dist/utils/helpers/handlers/index.js +1 -0
  69. package/x/dist/utils/helpers/hash/crypto.js +1 -0
  70. package/x/dist/utils/helpers/id/index.js +1 -0
  71. package/x/dist/utils/helpers/index.js +1 -0
  72. package/x/dist/utils/helpers/ip/index.js +1 -0
  73. package/x/dist/utils/helpers/is/index.js +1 -0
  74. package/x/dist/utils/helpers/locales/index.js +1 -0
  75. package/x/dist/utils/helpers/math/index.js +1 -0
  76. package/{source → x/dist}/utils/helpers/middleware/index.d.ts +2 -2
  77. package/x/dist/utils/helpers/middleware/index.js +1 -0
  78. package/x/dist/utils/helpers/objects/index.js +1 -0
  79. package/x/dist/utils/helpers/path/index.js +1 -0
  80. package/{source → x/dist}/utils/helpers/protocol/index.d.ts +2 -10
  81. package/x/dist/utils/helpers/protocol/index.js +1 -0
  82. package/x/dist/utils/helpers/protocol/options.js +1 -0
  83. package/x/dist/utils/helpers/regex/checkSpecialRegexControl.js +1 -0
  84. package/x/dist/utils/helpers/runtime/dto-access.js +1 -0
  85. package/x/dist/utils/helpers/runtime/dto-types.js +1 -0
  86. package/{source → x/dist}/utils/helpers/runtime/index.d.ts +1 -0
  87. package/x/dist/utils/helpers/runtime/index.js +1 -0
  88. package/x/dist/utils/helpers/runtime/shutdown.d.ts +3 -0
  89. package/x/dist/utils/helpers/runtime/shutdown.js +1 -0
  90. package/x/dist/utils/helpers/state/index.js +1 -0
  91. package/x/dist/utils/helpers/state/props-from-tmp.js +1 -0
  92. package/x/dist/utils/helpers/state/request-key-guard.js +1 -0
  93. package/x/dist/utils/helpers/state/scopes.js +1 -0
  94. package/x/dist/utils/helpers/string/index.js +1 -0
  95. package/x/dist/utils/helpers/tests/tmp-schema.test.js +1 -0
  96. package/x/dist/utils/helpers/tests/tmp-watch.test.d.ts +1 -0
  97. package/x/dist/utils/helpers/tests/tmp-watch.test.js +1 -0
  98. package/x/dist/utils/helpers/timer/index.js +1 -0
  99. package/x/dist/utils/helpers/tmp/index.d.ts +5 -0
  100. package/x/dist/utils/helpers/tmp/index.js +1 -0
  101. package/x/dist/utils/helpers/tmp/loader-tmp-sync.js +1 -0
  102. package/{source → x/dist}/utils/helpers/tmp/runtime-tmp.d.ts +2 -6
  103. package/x/dist/utils/helpers/tmp/runtime-tmp.js +1 -0
  104. package/{source → x/dist}/utils/helpers/tmp/tmp-loader.d.ts +1 -0
  105. package/x/dist/utils/helpers/tmp/tmp-loader.js +1 -0
  106. package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +47 -0
  107. package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -0
  108. package/x/dist/utils/helpers/tmp/tmp-watch.d.ts +1 -0
  109. package/x/dist/utils/helpers/tmp/tmp-watch.js +1 -0
  110. package/x/dist/utils/helpers/validates/index.js +1 -0
  111. package/x/dist/utils/index.js +1 -0
  112. package/x/dist/utils/models/classes/class.clients.js +1 -0
  113. package/x/dist/utils/models/classes/class.interfaces.js +1 -0
  114. package/x/dist/utils/models/classes/class.service-locator.js +1 -0
  115. package/{source → x/dist}/utils/models/classes/class.tmp-file-loader.d.ts +3 -2
  116. package/x/dist/utils/models/classes/class.tmp-file-loader.js +1 -0
  117. package/x/dist/utils/models/classes/class.x.js +1 -0
  118. package/x/dist/utils/models/enums/index.js +1 -0
  119. package/x/dist/utils/models/index.js +1 -0
  120. package/x/dist/utils/models/types/index.js +1 -0
  121. package/x/dist/utils/package-root.js +1 -0
  122. package/x/tmp.yml +51 -42
  123. package/source/index.js +0 -11
  124. package/source/loader/clients/index.js +0 -22
  125. package/source/loader/configs/index.js +0 -88
  126. package/source/loader/controller/index.js +0 -236
  127. package/source/loader/dto/index.js +0 -92
  128. package/source/loader/events/index.js +0 -44
  129. package/source/loader/index.d.ts +0 -11
  130. package/source/loader/index.js +0 -11
  131. package/source/loader/kafka/index.js +0 -137
  132. package/source/loader/localizations/index.js +0 -46
  133. package/source/loader/logger/index.js +0 -217
  134. package/source/loader/service/index.js +0 -7
  135. package/source/loader/system/index.js +0 -25
  136. package/source/project/index.d.ts +0 -8
  137. package/source/project/index.js +0 -70
  138. package/source/utils/constants/defaults.json +0 -15
  139. package/source/utils/constants/defaults.mjs +0 -10
  140. package/source/utils/constants/index.js +0 -22
  141. package/source/utils/helpers/configs/index.js +0 -1
  142. package/source/utils/helpers/context/controller-store.js +0 -12
  143. package/source/utils/helpers/context/index.js +0 -24
  144. package/source/utils/helpers/core/index.js +0 -58
  145. package/source/utils/helpers/core/paths.js +0 -78
  146. package/source/utils/helpers/core/tmp-layout.js +0 -241
  147. package/source/utils/helpers/date/index.js +0 -48
  148. package/source/utils/helpers/dispatch/index.js +0 -53
  149. package/source/utils/helpers/dto/index.js +0 -10
  150. package/source/utils/helpers/filters/index.js +0 -44
  151. package/source/utils/helpers/framework/index.js +0 -17
  152. package/source/utils/helpers/handlers/adapters.js +0 -40
  153. package/source/utils/helpers/handlers/execute.js +0 -82
  154. package/source/utils/helpers/handlers/index.js +0 -31
  155. package/source/utils/helpers/hash/crypto.js +0 -22
  156. package/source/utils/helpers/id/index.js +0 -24
  157. package/source/utils/helpers/index.js +0 -26
  158. package/source/utils/helpers/ip/index.js +0 -21
  159. package/source/utils/helpers/is/index.js +0 -35
  160. package/source/utils/helpers/locales/index.js +0 -82
  161. package/source/utils/helpers/math/index.js +0 -14
  162. package/source/utils/helpers/middleware/index.js +0 -36
  163. package/source/utils/helpers/objects/index.js +0 -55
  164. package/source/utils/helpers/path/index.js +0 -4
  165. package/source/utils/helpers/protocol/index.js +0 -99
  166. package/source/utils/helpers/protocol/options.js +0 -13
  167. package/source/utils/helpers/regex/checkSpecialRegexControl.js +0 -3
  168. package/source/utils/helpers/runtime/dto-access.js +0 -5
  169. package/source/utils/helpers/runtime/index.js +0 -1
  170. package/source/utils/helpers/state/index.js +0 -185
  171. package/source/utils/helpers/state/props-from-tmp.js +0 -44
  172. package/source/utils/helpers/state/request-key-guard.js +0 -42
  173. package/source/utils/helpers/state/scopes.js +0 -69
  174. package/source/utils/helpers/string/index.js +0 -9
  175. package/source/utils/helpers/timer/index.js +0 -5
  176. package/source/utils/helpers/tmp/index.d.ts +0 -3
  177. package/source/utils/helpers/tmp/index.js +0 -3
  178. package/source/utils/helpers/tmp/loader-tmp-sync.js +0 -13
  179. package/source/utils/helpers/tmp/runtime-tmp.js +0 -30
  180. package/source/utils/helpers/tmp/tmp-loader.js +0 -48
  181. package/source/utils/helpers/validates/index.js +0 -20
  182. package/source/utils/index.js +0 -3
  183. package/source/utils/models/classes/class.clients.js +0 -142
  184. package/source/utils/models/classes/class.interfaces.js +0 -10
  185. package/source/utils/models/classes/class.service-locator.js +0 -16
  186. package/source/utils/models/classes/class.tmp-file-loader.js +0 -38
  187. package/source/utils/models/classes/class.x.js +0 -180
  188. package/source/utils/models/enums/index.js +0 -148
  189. package/source/utils/models/index.js +0 -9
  190. package/source/utils/models/types/index.js +0 -2
  191. package/source/utils/models/types/shims.d.ts +0 -123
  192. package/source/utils/package-root.js +0 -5
  193. package/x/tests/cli.test.ts +0 -85
  194. package/x/tests/context.test.ts +0 -25
  195. package/x/tests/dispatch.test.ts +0 -84
  196. package/x/tests/fixtures/locales/en/translation.json +0 -8
  197. package/x/tests/fixtures/locales/tr/translation.json +0 -8
  198. package/x/tests/frameworks.integration.test.ts +0 -185
  199. package/x/tests/helpers/i18n-setup.ts +0 -52
  200. package/x/tests/helpers/middleware.ts +0 -23
  201. package/x/tests/helpers/register-test-dto.ts +0 -52
  202. package/x/tests/i18n.integration.test.ts +0 -77
  203. package/x/tests/i18n.test.ts +0 -96
  204. package/x/tests/middleware.test.ts +0 -83
  205. package/x/tests/project-layout.test.ts +0 -65
  206. package/x/tests/protocol.test.ts +0 -75
  207. package/x/tests/realtime.examples.test.ts +0 -198
  208. package/x/tests/runtime-tmp.test.ts +0 -49
  209. package/x/tests/socket.integration.test.ts +0 -174
  210. package/x/tests/state.test.ts +0 -183
  211. package/x/tests/tmp-layout-guard.test.ts +0 -40
  212. /package/{source → x/dist}/index.d.ts +0 -0
  213. /package/{source → x/dist}/loader/clients/index.d.ts +0 -0
  214. /package/{source → x/dist}/loader/configs/index.d.ts +0 -0
  215. /package/{source → x/dist}/loader/dto/index.d.ts +0 -0
  216. /package/{source → x/dist}/loader/events/index.d.ts +0 -0
  217. /package/{source → x/dist}/loader/localizations/index.d.ts +0 -0
  218. /package/{source → x/dist}/loader/service/index.d.ts +0 -0
  219. /package/{source → x/dist}/loader/system/index.d.ts +0 -0
  220. /package/{source → x/dist}/utils/constants/index.d.ts +0 -0
  221. /package/{source → x/dist}/utils/helpers/configs/index.d.ts +0 -0
  222. /package/{source → x/dist}/utils/helpers/context/controller-store.d.ts +0 -0
  223. /package/{source → x/dist}/utils/helpers/context/index.d.ts +0 -0
  224. /package/{source → x/dist}/utils/helpers/core/paths.d.ts +0 -0
  225. /package/{source → x/dist}/utils/helpers/core/tmp-layout.d.ts +0 -0
  226. /package/{source → x/dist}/utils/helpers/date/index.d.ts +0 -0
  227. /package/{source → x/dist}/utils/helpers/dispatch/index.d.ts +0 -0
  228. /package/{source → x/dist}/utils/helpers/dto/index.d.ts +0 -0
  229. /package/{source → x/dist}/utils/helpers/filters/index.d.ts +0 -0
  230. /package/{source → x/dist}/utils/helpers/framework/index.d.ts +0 -0
  231. /package/{source → x/dist}/utils/helpers/handlers/adapters.d.ts +0 -0
  232. /package/{source → x/dist}/utils/helpers/handlers/execute.d.ts +0 -0
  233. /package/{source → x/dist}/utils/helpers/handlers/index.d.ts +0 -0
  234. /package/{source → x/dist}/utils/helpers/hash/crypto.d.ts +0 -0
  235. /package/{source → x/dist}/utils/helpers/id/index.d.ts +0 -0
  236. /package/{source → x/dist}/utils/helpers/index.d.ts +0 -0
  237. /package/{source → x/dist}/utils/helpers/ip/index.d.ts +0 -0
  238. /package/{source → x/dist}/utils/helpers/is/index.d.ts +0 -0
  239. /package/{source → x/dist}/utils/helpers/locales/index.d.ts +0 -0
  240. /package/{source → x/dist}/utils/helpers/math/index.d.ts +0 -0
  241. /package/{source → x/dist}/utils/helpers/objects/index.d.ts +0 -0
  242. /package/{source → x/dist}/utils/helpers/path/index.d.ts +0 -0
  243. /package/{source → x/dist}/utils/helpers/protocol/options.d.ts +0 -0
  244. /package/{source → x/dist}/utils/helpers/regex/checkSpecialRegexControl.d.ts +0 -0
  245. /package/{source → x/dist}/utils/helpers/runtime/dto-access.d.ts +0 -0
  246. /package/{source → x/dist}/utils/helpers/runtime/dto-types.d.ts +0 -0
  247. /package/{source → x/dist}/utils/helpers/state/index.d.ts +0 -0
  248. /package/{source → x/dist}/utils/helpers/state/props-from-tmp.d.ts +0 -0
  249. /package/{source → x/dist}/utils/helpers/state/request-key-guard.d.ts +0 -0
  250. /package/{source → x/dist}/utils/helpers/state/scopes.d.ts +0 -0
  251. /package/{source → x/dist}/utils/helpers/string/index.d.ts +0 -0
  252. /package/{source/utils/helpers/runtime/dto-types.js → x/dist/utils/helpers/tests/tmp-schema.test.d.ts} +0 -0
  253. /package/{source → x/dist}/utils/helpers/timer/index.d.ts +0 -0
  254. /package/{source → x/dist}/utils/helpers/tmp/loader-tmp-sync.d.ts +0 -0
  255. /package/{source → x/dist}/utils/helpers/validates/index.d.ts +0 -0
  256. /package/{source → x/dist}/utils/index.d.ts +0 -0
  257. /package/{source → x/dist}/utils/models/classes/class.clients.d.ts +0 -0
  258. /package/{source → x/dist}/utils/models/classes/class.interfaces.d.ts +0 -0
  259. /package/{source → x/dist}/utils/models/classes/class.service-locator.d.ts +0 -0
  260. /package/{source → x/dist}/utils/models/classes/class.x.d.ts +0 -0
  261. /package/{source → x/dist}/utils/models/enums/index.d.ts +0 -0
  262. /package/{source → x/dist}/utils/models/index.d.ts +0 -0
  263. /package/{source → x/dist}/utils/models/types/index.d.ts +0 -0
  264. /package/{source → x/dist}/utils/package-root.d.ts +0 -0
@@ -1,180 +0,0 @@
1
- import { createContainer, asClass, asValue, InjectionMode, listModules, Lifetime } from 'awilix';
2
- import path from 'node:path';
3
- import { pathToFileURL } from 'node:url';
4
- export const xSymbol = Symbol.for('@xrystal/core/di-container');
5
- class X {
6
- checkRegistration(container, name) {
7
- return !!container.registrations[name];
8
- }
9
- }
10
- class DIM extends X {
11
- container;
12
- initializedNames = new Set();
13
- loadedPaths = new Set();
14
- registeredClasses = new Set();
15
- isInitializing = false;
16
- constructor() {
17
- super();
18
- this.container = createContainer({
19
- injectionMode: InjectionMode.PROXY,
20
- strict: true
21
- });
22
- }
23
- getName(target) {
24
- if (typeof target === 'string')
25
- return target.charAt(0).toLowerCase() + target.slice(1);
26
- if (typeof target === 'function' && target.name)
27
- return target.name.charAt(0).toLowerCase() + target.name.slice(1);
28
- return '';
29
- }
30
- async load(patterns, options = {}) {
31
- const { verbose = false, exclude = [], lifetime = Lifetime.SINGLETON } = options;
32
- const cwd = process.cwd();
33
- const resolvedPatterns = (Array.isArray(patterns) ? patterns : [patterns]).map(p => {
34
- const resolved = path.isAbsolute(p) ? p : path.resolve(cwd, p);
35
- return resolved.replace(/\\/g, '/').toLowerCase();
36
- });
37
- let modules = [];
38
- try {
39
- modules = listModules(resolvedPatterns);
40
- }
41
- catch (err) {
42
- return this;
43
- }
44
- for (const m of modules) {
45
- const normalizedMPath = m.path.replace(/\\/g, '/').toLowerCase();
46
- if (this.loadedPaths.has(normalizedMPath))
47
- continue;
48
- if (normalizedMPath === __filename.replace(/\\/g, '/').toLowerCase() || normalizedMPath.endsWith('.d.ts'))
49
- continue;
50
- try {
51
- const fileUrl = pathToFileURL(m.path).href;
52
- const loaded = await import(fileUrl);
53
- let dependency = loaded.default;
54
- if (!dependency) {
55
- dependency = Object.values(loaded).find(val => typeof val === 'function' && !!val.prototype && !!val.name);
56
- }
57
- if (typeof dependency === 'function' && !!dependency.prototype && !!dependency.name) {
58
- if (this.registeredClasses.has(dependency))
59
- continue;
60
- const name = this.getName(dependency);
61
- if (name && !this.checkRegistration(this.container, name)) {
62
- this.container.register({
63
- [name]: asClass(dependency).setLifetime(lifetime)
64
- });
65
- this.loadedPaths.add(normalizedMPath);
66
- this.registeredClasses.add(dependency);
67
- }
68
- }
69
- }
70
- catch (err) {
71
- if (verbose)
72
- console.error(`[DI] Load Error:`, err.message);
73
- }
74
- }
75
- return this;
76
- }
77
- register(Dependency, lifetime = Lifetime.SINGLETON) {
78
- const name = this.getName(Dependency);
79
- if (!name || this.registeredClasses.has(Dependency))
80
- return this;
81
- if (this.checkRegistration(this.container, name))
82
- return this;
83
- this.container.register({ [name]: asClass(Dependency).setLifetime(lifetime) });
84
- this.registeredClasses.add(Dependency);
85
- return this;
86
- }
87
- registerInstance(name, instance) {
88
- if (!name)
89
- return this;
90
- const formattedName = this.getName(name);
91
- this.container.register({ [formattedName]: asValue(instance) });
92
- return this;
93
- }
94
- async initialize(input, verbose = false) {
95
- if (this.isInitializing)
96
- return this;
97
- this.isInitializing = true;
98
- try {
99
- const inputList = input ? (Array.isArray(input) ? input : [input]) : [];
100
- for (const item of inputList) {
101
- const name = this.getName(item.service);
102
- if (!name || this.initializedNames.has(name))
103
- continue;
104
- const reg = this.container.registrations[name];
105
- if (!reg || reg.lifetime !== Lifetime.SINGLETON)
106
- continue;
107
- try {
108
- const instance = this.container.cradle[name];
109
- if (instance && typeof instance.onInit === 'function') {
110
- await instance.onInit(item.props || {});
111
- }
112
- this.initializedNames.add(name);
113
- }
114
- catch (err) {
115
- if (verbose)
116
- console.error(`[DI] Priority onInit Failed (${name}):`, err.message);
117
- }
118
- }
119
- const allKeys = Object.keys(this.container.registrations);
120
- for (const key of allKeys) {
121
- if (this.initializedNames.has(key))
122
- continue;
123
- const reg = this.container.registrations[key];
124
- if (reg.lifetime !== Lifetime.SINGLETON)
125
- continue;
126
- try {
127
- const instance = this.container.cradle[key];
128
- if (instance && typeof instance.onInit === 'function') {
129
- await instance.onInit({});
130
- }
131
- this.initializedNames.add(key);
132
- }
133
- catch (err) {
134
- if (verbose)
135
- console.error(`[DI] Auto onInit Failed (${key}):`, err.message);
136
- }
137
- }
138
- for (const name of this.initializedNames) {
139
- try {
140
- const instance = this.container.cradle[name];
141
- if (instance && typeof instance.onAfterInit === 'function') {
142
- await instance.onAfterInit();
143
- }
144
- }
145
- catch (err) {
146
- if (verbose)
147
- console.error(`[DI] onAfterInit Failed (${name}):`, err.message);
148
- }
149
- }
150
- }
151
- finally {
152
- this.isInitializing = false;
153
- }
154
- return this;
155
- }
156
- get(target) {
157
- const resolveName = this.getName(target);
158
- return this.container.resolve(resolveName);
159
- }
160
- async shutdown() {
161
- for (const name of this.initializedNames) {
162
- try {
163
- const instance = this.container.cradle[name];
164
- if (instance && typeof instance.onDispose === 'function') {
165
- await instance.onDispose();
166
- }
167
- }
168
- catch (err) {
169
- console.error(`[DI] onDispose Failed (${name})`);
170
- }
171
- }
172
- await this.container.dispose();
173
- }
174
- get cradle() { return this.container.cradle; }
175
- }
176
- const globalStore = globalThis;
177
- if (!globalStore[xSymbol]) {
178
- globalStore[xSymbol] = new DIM();
179
- }
180
- export default globalStore[xSymbol];
@@ -1,148 +0,0 @@
1
- export var NodeEnvEnum;
2
- (function (NodeEnvEnum) {
3
- NodeEnvEnum["DEV"] = "dev";
4
- NodeEnvEnum["TEST"] = "test";
5
- NodeEnvEnum["PROD"] = "prod";
6
- })(NodeEnvEnum || (NodeEnvEnum = {}));
7
- export var ProtocolEnum;
8
- (function (ProtocolEnum) {
9
- ProtocolEnum["HTTP"] = "http";
10
- ProtocolEnum["HTTPS"] = "https";
11
- ProtocolEnum["WEBSOCKET"] = "ws";
12
- ProtocolEnum["SOCKETIO"] = "socketio";
13
- ProtocolEnum["NONE"] = "none";
14
- })(ProtocolEnum || (ProtocolEnum = {}));
15
- export var FrameworkEnum;
16
- (function (FrameworkEnum) {
17
- FrameworkEnum["EXPRESS"] = "express";
18
- FrameworkEnum["ELYSIA"] = "elysia";
19
- FrameworkEnum["NODE"] = "node";
20
- FrameworkEnum["FETCH"] = "fetch";
21
- FrameworkEnum["WEBSOCKET"] = "websocket";
22
- FrameworkEnum["SOCKETIO"] = "socketio";
23
- })(FrameworkEnum || (FrameworkEnum = {}));
24
- export var PolarityTypeEnum;
25
- (function (PolarityTypeEnum) {
26
- PolarityTypeEnum[PolarityTypeEnum["NOTR"] = 0] = "NOTR";
27
- PolarityTypeEnum[PolarityTypeEnum["POSITIVE"] = 1] = "POSITIVE";
28
- PolarityTypeEnum[PolarityTypeEnum["NEGATIVE"] = -1] = "NEGATIVE";
29
- })(PolarityTypeEnum || (PolarityTypeEnum = {}));
30
- export var LoggerLayerEnum;
31
- (function (LoggerLayerEnum) {
32
- LoggerLayerEnum[LoggerLayerEnum["CRITICAL"] = 0] = "CRITICAL";
33
- LoggerLayerEnum[LoggerLayerEnum["ERROR"] = 1] = "ERROR";
34
- LoggerLayerEnum[LoggerLayerEnum["WARN"] = 2] = "WARN";
35
- LoggerLayerEnum[LoggerLayerEnum["INFO"] = 3] = "INFO";
36
- LoggerLayerEnum[LoggerLayerEnum["HTTP"] = 4] = "HTTP";
37
- LoggerLayerEnum[LoggerLayerEnum["DEBUG"] = 5] = "DEBUG";
38
- })(LoggerLayerEnum || (LoggerLayerEnum = {}));
39
- export var CountryCodeEnum;
40
- (function (CountryCodeEnum) {
41
- CountryCodeEnum["EN"] = "en";
42
- CountryCodeEnum["TR"] = "tr";
43
- })(CountryCodeEnum || (CountryCodeEnum = {}));
44
- export var CurrencyCodeEnum;
45
- (function (CurrencyCodeEnum) {
46
- CurrencyCodeEnum["USD"] = "usd";
47
- CurrencyCodeEnum["EUR"] = "eur";
48
- CurrencyCodeEnum["TRY"] = "try";
49
- })(CurrencyCodeEnum || (CurrencyCodeEnum = {}));
50
- export var HttpMethodEnum;
51
- (function (HttpMethodEnum) {
52
- HttpMethodEnum["POST"] = "post";
53
- HttpMethodEnum["GET"] = "get";
54
- HttpMethodEnum["PUT"] = "put";
55
- HttpMethodEnum["DELETE"] = "delete";
56
- })(HttpMethodEnum || (HttpMethodEnum = {}));
57
- export var ContentTypeEnum;
58
- (function (ContentTypeEnum) {
59
- ContentTypeEnum["applicationJson"] = "application/json";
60
- ContentTypeEnum["applicationXWwwFormUrlencoded"] = "application/x-www-form-urlencoded";
61
- })(ContentTypeEnum || (ContentTypeEnum = {}));
62
- export var DeviceStatusEnum;
63
- (function (DeviceStatusEnum) {
64
- DeviceStatusEnum[DeviceStatusEnum["PENDING"] = 0] = "PENDING";
65
- DeviceStatusEnum[DeviceStatusEnum["OFFLINE"] = 1] = "OFFLINE";
66
- DeviceStatusEnum[DeviceStatusEnum["ONLINE"] = 2] = "ONLINE";
67
- DeviceStatusEnum[DeviceStatusEnum["CONNECTING"] = 3] = "CONNECTING";
68
- DeviceStatusEnum[DeviceStatusEnum["CONNECTED"] = 4] = "CONNECTED";
69
- })(DeviceStatusEnum || (DeviceStatusEnum = {}));
70
- export var DevicePlatformEnum;
71
- (function (DevicePlatformEnum) {
72
- DevicePlatformEnum["WEB"] = "web";
73
- DevicePlatformEnum["NATIVE"] = "native";
74
- DevicePlatformEnum["OTHER"] = "other";
75
- })(DevicePlatformEnum || (DevicePlatformEnum = {}));
76
- export var DeviceOSEnum;
77
- (function (DeviceOSEnum) {
78
- DeviceOSEnum["ANDROID"] = "android";
79
- DeviceOSEnum["IOS"] = "ios";
80
- DeviceOSEnum["WINDOWS"] = "windows";
81
- DeviceOSEnum["MACOS"] = "macos";
82
- DeviceOSEnum["MACOSX"] = "macosx";
83
- DeviceOSEnum["OTHER"] = "other";
84
- })(DeviceOSEnum || (DeviceOSEnum = {}));
85
- export var PriorityEnum;
86
- (function (PriorityEnum) {
87
- PriorityEnum[PriorityEnum["HIGH"] = 0] = "HIGH";
88
- PriorityEnum[PriorityEnum["MEDIUM"] = 1] = "MEDIUM";
89
- PriorityEnum[PriorityEnum["LOW"] = 2] = "LOW";
90
- })(PriorityEnum || (PriorityEnum = {}));
91
- export var PrivacyEnum;
92
- (function (PrivacyEnum) {
93
- PrivacyEnum[PrivacyEnum["PRIVATE"] = 0] = "PRIVATE";
94
- PrivacyEnum[PrivacyEnum["PUBLIC"] = 1] = "PUBLIC";
95
- PrivacyEnum[PrivacyEnum["ONLY_FRIENDS"] = 2] = "ONLY_FRIENDS";
96
- })(PrivacyEnum || (PrivacyEnum = {}));
97
- export var TimezoneEnum;
98
- (function (TimezoneEnum) {
99
- TimezoneEnum["UTC"] = "UTC";
100
- TimezoneEnum["EtcUTC"] = "Etc/UTC";
101
- TimezoneEnum["EtcGMT"] = "Etc/GMT";
102
- })(TimezoneEnum || (TimezoneEnum = {}));
103
- export var ModeEnum;
104
- (function (ModeEnum) {
105
- ModeEnum["MONOLITIC"] = "monolitic";
106
- ModeEnum["MICRO_SERVICE"] = "micro_service";
107
- })(ModeEnum || (ModeEnum = {}));
108
- export var TokensEnum;
109
- (function (TokensEnum) {
110
- TokensEnum["INTERNAL_API_TOKEN"] = "internal_api_key";
111
- TokensEnum["CSRF_TOKEN"] = "csrf_token";
112
- TokensEnum["ACCESS_TOKEN"] = "access_token";
113
- TokensEnum["REFRESH_TOKEN"] = "refresh_token";
114
- TokensEnum["REFERENCE_TOKEN"] = "reference_token";
115
- TokensEnum["PERSONAL_ACCESS_TOKEN"] = "personal_access_token";
116
- })(TokensEnum || (TokensEnum = {}));
117
- export var CoreClientsEnum;
118
- (function (CoreClientsEnum) {
119
- CoreClientsEnum["BASE_API_CLIENT"] = "base_client_name";
120
- CoreClientsEnum["SOAP_API_CLIENT"] = "soap_api_client";
121
- })(CoreClientsEnum || (CoreClientsEnum = {}));
122
- export var GStoreScopeEnum;
123
- (function (GStoreScopeEnum) {
124
- GStoreScopeEnum["GLOBAL"] = "global";
125
- GStoreScopeEnum["RUN"] = "run";
126
- GStoreScopeEnum["CONTROLLER"] = "controller";
127
- })(GStoreScopeEnum || (GStoreScopeEnum = {}));
128
- export var EndpointResourceEnum;
129
- (function (EndpointResourceEnum) {
130
- EndpointResourceEnum["EXAMPLE"] = "example";
131
- EndpointResourceEnum["FULL"] = "full";
132
- EndpointResourceEnum["SYSTEM"] = "system";
133
- EndpointResourceEnum["CLIENTS"] = "clients";
134
- EndpointResourceEnum["AUTH"] = "auth";
135
- EndpointResourceEnum["ACCOUNTS"] = "accounts";
136
- EndpointResourceEnum["USERS"] = "users";
137
- EndpointResourceEnum["TRANSACTIONS"] = "transactions";
138
- EndpointResourceEnum["NOTIFICATIONS"] = "notifications";
139
- EndpointResourceEnum["ADDRESSES"] = "addresses";
140
- EndpointResourceEnum["PAYMENTS"] = "payments";
141
- EndpointResourceEnum["COMMISSIONS_AND_TAXES"] = "commissions-and-taxes";
142
- EndpointResourceEnum["SUPPORTS"] = "supports";
143
- EndpointResourceEnum["INVOICES"] = "invoices";
144
- EndpointResourceEnum["FILES"] = "files";
145
- EndpointResourceEnum["TOKENS"] = "tokens";
146
- EndpointResourceEnum["WEBHOOKS"] = "webhooks";
147
- EndpointResourceEnum["OTHERS"] = "others";
148
- })(EndpointResourceEnum || (EndpointResourceEnum = {}));
@@ -1,9 +0,0 @@
1
- import _ from 'lodash';
2
- import x from '../../utils/models/classes/class.x';
3
- import locator from '../../utils/models/classes/class.service-locator';
4
- export * from '../../utils/models/classes/class.tmp-file-loader';
5
- export * from '../../utils/models/classes/class.interfaces';
6
- export * from '../../utils/models/classes/class.clients';
7
- export * from '../../utils/models/types';
8
- export * from '../../utils/models/enums';
9
- export { x, locator, _ };
@@ -1,2 +0,0 @@
1
- export {};
2
- /** Ambient module shims: `@xrystal/dto/*`, `qs` — see `./shims.d.ts` */
@@ -1,123 +0,0 @@
1
- declare module '@xrystal/dto/dto' {
2
- export class DTO {
3
- constructor(config?: DTOConfig)
4
- express(): HttpMiddleware
5
- elysia(): ElysiaPlugin
6
- node(): HttpMiddleware
7
- websocket(): SocketMiddleware
8
- socketIo(): SocketMiddleware
9
- fetch(): unknown
10
- forRequest(request: Request): Record<string, unknown>
11
- attachWebSocket(socket: unknown, requestId?: string): unknown
12
- attachSocketIo(socket: unknown): unknown
13
- configure(config?: Partial<DTOConfig>): this
14
- use(...plugins: unknown[]): this
15
- }
16
- export function createDTO(config?: DTOConfig): DTO
17
- export type DTOConfig = {
18
- withDefaultHeaders?: boolean
19
- codes?: Record<string, unknown>
20
- defaultHeaders?: Record<string, unknown>
21
- socket?: { event?: string }
22
- hooks?: unknown
23
- plugins?: unknown[]
24
- }
25
- export type RuntimeOptions = Record<string, unknown>
26
- export type HttpMiddleware = (req: unknown, res: unknown, next: (err?: unknown) => void) => void | Promise<void>
27
- export type SocketMiddleware = (socket: unknown, next?: (err?: unknown) => void) => void | Promise<void>
28
- export type ElysiaPlugin = object
29
- }
30
-
31
- declare module '@xrystal/dto/response' {
32
- export type FinalResult = { body: unknown; statusCode: number }
33
- export type PayloadExtras = { data?: unknown; extraData?: unknown }
34
- export type SchemaInput = Record<string, unknown>
35
- export type Payload = unknown
36
- export type ResponseBody = Record<string, unknown>
37
- export class ResponseDTO {}
38
- export class Builder {
39
- as: {
40
- ok: (...args: unknown[]) => { build(): FinalResult }
41
- fail: (...args: unknown[]) => { build(): FinalResult }
42
- internalServerError: (message: string) => { build(): FinalResult }
43
- }
44
- httpStatus: (code: number) => unknown
45
- code: (code: number) => unknown
46
- }
47
- export function createBuilderProxy(...args: unknown[]): Builder
48
- export const ResponsePresets: Record<string, unknown>
49
- export type PresetTerminal = Record<string, unknown>
50
- export function assembleResponseBody(...args: unknown[]): unknown
51
- export function dispatchExpressResponse(...args: unknown[]): unknown
52
- export function dispatchNodeResponse(...args: unknown[]): unknown
53
- export function toFetchResponse(...args: unknown[]): unknown
54
- export function applyElysiaTransport(...args: unknown[]): unknown
55
- export function dispatchWebSocketMessage(...args: unknown[]): unknown
56
- export function dispatchSocketIoMessage(...args: unknown[]): unknown
57
- }
58
-
59
- declare module '@xrystal/dto/express' {
60
- export function expressSink(res: unknown): { dispatch(result: unknown): void }
61
- export function expressMiddleware(...args: unknown[]): unknown
62
- export class ExpressAdapter {}
63
- }
64
-
65
- declare module '@xrystal/dto/node' {
66
- export function nodeSink(res: unknown): { dispatch(result: unknown): void }
67
- export function nodeMiddleware(...args: unknown[]): unknown
68
- export class NodeAdapter {}
69
- }
70
-
71
- declare module '@xrystal/dto/fetch' {
72
- export const fetchSink: { dispatch(result: unknown): Response }
73
- export function fetchDerive(...args: unknown[]): unknown
74
- export class FetchAdapter {}
75
- }
76
-
77
- declare module '@xrystal/dto/elysia' {
78
- export function elysiaSink(ctx: unknown): { dispatch(result: unknown): unknown }
79
- export class ElysiaAdapter {}
80
- }
81
-
82
- declare module '@xrystal/dto/websocket' {
83
- export function websocketSink(socket: unknown): { dispatch(result: unknown): void }
84
- export class WebSocketAdapter {}
85
- }
86
-
87
- declare module '@xrystal/dto/socketio' {
88
- export function socketIoSink(socket: unknown, event?: string): { dispatch(result: unknown): void }
89
- export class SocketIoAdapter {}
90
- }
91
-
92
- declare module '@xrystal/dto/log' {
93
- export class LogDTO {
94
- static schema(input?: Record<string, unknown>): { build(): LogBody }
95
- }
96
- export type LogBody = {
97
- level: string
98
- message: string
99
- payload?: unknown
100
- code?: string | number
101
- id?: string
102
- service?: string
103
- timestamp?: string
104
- env?: string
105
- }
106
- export type ILogDTO = LogBody
107
- export function assembleLogBody(...args: unknown[]): LogBody
108
- }
109
-
110
- declare module '@xrystal/dto/queue' {
111
- export class QueueDTO {}
112
- export type IMetadata = Record<string, unknown>
113
- export type IMessageInput = Record<string, unknown>
114
- export function assembleQueueMessage(...args: unknown[]): unknown
115
- }
116
-
117
- declare module 'qs' {
118
- const qs: {
119
- parse(str: string, options?: Record<string, unknown>): Record<string, unknown>
120
- stringify(obj: Record<string, unknown>, options?: Record<string, unknown>): string
121
- }
122
- export default qs
123
- }
@@ -1,5 +0,0 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- const utilsDir = path.dirname(fileURLToPath(import.meta.url));
4
- export const sourceDir = path.resolve(utilsDir, '..');
5
- export const packageRootDir = path.resolve(utilsDir, '..', '..');
@@ -1,85 +0,0 @@
1
- import { describe, expect, test } from 'bun:test'
2
- import { ProtocolEnum } from '@/utils/models'
3
- import { resolveProtocolsFromConfig } from '@/utils/helpers/protocol'
4
- import { summarizeLoaders, resolveProtocolsFromConfig as resolveCliProtocols } from '../bin/helpers/tmp-config.mjs'
5
-
6
- describe('resolveProtocolsFromConfig (core)', () => {
7
- test('configs.protocols — tmp.yml location', () => {
8
- const protocols = resolveProtocolsFromConfig({
9
- protocols: ['http', 'ws'],
10
- })
11
- expect(protocols).toEqual([ProtocolEnum.HTTP, ProtocolEnum.WEBSOCKET])
12
- })
13
-
14
- test('defaults to http when protocols omitted', () => {
15
- const protocols = resolveProtocolsFromConfig({})
16
- expect(protocols).toEqual([ProtocolEnum.HTTP])
17
- })
18
- })
19
-
20
- describe('CLI tmp-config helper', () => {
21
- test('summarizeLoaders matches x/tmp.yml shape', () => {
22
- const summary = summarizeLoaders({
23
- configs: {
24
- framework: 'elysia',
25
- service: 'my-api',
26
- protocols: ['http', 'ws'],
27
- loaders: {
28
- dto: { withDefaultHeaders: true },
29
- loggers: { loadPath: 'logs', logLevel: 'debug' },
30
- localization: { fallbackLang: 'en', preloadLangs: ['en', 'tr'] },
31
- controller: {},
32
- },
33
- },
34
- })
35
-
36
- expect(summary.framework).toBe('elysia')
37
- expect(summary.protocols).toEqual(['http', 'ws'])
38
- expect(summary.items.some((i) => i.key === 'dto')).toBe(true)
39
- expect(summary.items.some((i) => i.key === 'localization')).toBe(true)
40
- })
41
-
42
- test('CLI resolveProtocols matches core aliases', () => {
43
- expect(resolveCliProtocols({ protocols: ['http', 'socketio'] })).toEqual(['http', 'socketio'])
44
- })
45
- })
46
-
47
- describe('CLI bin identity', () => {
48
- test('xcore, xrystal, tmp resolve to invoked bin name', async () => {
49
- const { resolveInvokedAs, CLI_BIN_NAMES, CLI_PRIMARY_NAME } = await import('../bin/helpers/cli-identity.mjs')
50
-
51
- for (const name of CLI_BIN_NAMES) {
52
- expect(resolveInvokedAs(['node', name, 'doctor'])).toBe(name)
53
- }
54
-
55
- expect(resolveInvokedAs(['node', 'main-cli.js', 'doctor'])).toBe(CLI_PRIMARY_NAME)
56
- expect(resolveInvokedAs(['node', 'unknown-bin', 'doctor'])).toBe(CLI_PRIMARY_NAME)
57
- })
58
-
59
- test('shouldShowBanner works for all bin names', async () => {
60
- const { shouldShowBanner } = await import('../bin/helpers/banner.mjs')
61
- for (const name of ['xcore', 'xrystal', 'tmp']) {
62
- expect(shouldShowBanner(['node', name, '--version'])).toBe(false)
63
- expect(shouldShowBanner(['node', name, 'doctor'])).toBe(true)
64
- }
65
- })
66
- })
67
-
68
- describe('CLI banner', () => {
69
- test('shouldShowBanner skips version flag', async () => {
70
- const { shouldShowBanner } = await import('../bin/helpers/banner.mjs')
71
- expect(shouldShowBanner(['node', 'xcore', '--version'])).toBe(false)
72
- expect(shouldShowBanner(['node', 'xcore', 'doctor'])).toBe(true)
73
- })
74
- })
75
-
76
- describe('project root resolver', () => {
77
- test('finds @xrystal/core repo from subdirectory', async () => {
78
- const { resolveProjectRoot, getInstalledCoreVersion } = await import('../bin/helpers/project-root.mjs')
79
- const root = resolveProjectRoot(process.cwd())
80
- expect(root.endsWith('-xrystal-core') || root.includes('xrystal-core')).toBe(true)
81
-
82
- const core = getInstalledCoreVersion(root)
83
- expect(core.installed).toBeTruthy()
84
- })
85
- })
@@ -1,25 +0,0 @@
1
- import { describe, expect, test } from 'bun:test'
2
- import { getRequestId, getRunContext, runWithContext, runWithRequestId, runWithTrace } from '@/utils/helpers/context'
3
-
4
- describe('run context (scoped)', () => {
5
- test('clears after callback', () => {
6
- runWithRequestId('req-1', () => {
7
- expect(getRequestId()).toBe('req-1')
8
- expect(getRunContext()?.kind).toBe('http')
9
- })
10
- expect(getRequestId()).toBeUndefined()
11
- })
12
-
13
- test('runWithTrace for jobs', () => {
14
- runWithTrace('job-1', () => {
15
- expect(getRunContext()?.kind).toBe('job')
16
- expect(getRunContext()?.label).toBe('nightly')
17
- }, 'nightly')
18
- })
19
-
20
- test('custom meta via runWithContext', () => {
21
- runWithContext({ requestId: 'x', kind: 'job', meta: { q: 'billing' } }, () => {
22
- expect(getRunContext()?.meta?.q).toBe('billing')
23
- })
24
- })
25
- })
@@ -1,84 +0,0 @@
1
- import { beforeEach, describe, expect, test } from 'bun:test'
2
- import type { FinalResult } from '@xrystal/dto/response'
3
- import { DTO } from '@xrystal/dto'
4
- import { dispatchResult } from '@/utils/helpers/dispatch'
5
- import { FrameworkEnum, ProtocolEnum } from '@/utils/models'
6
- import { registerTestDto } from './helpers/register-test-dto'
7
-
8
- const sampleResult = (): FinalResult => ({
9
- statusCode: 200,
10
- headers: { 'content-type': 'application/json' },
11
- cookies: [],
12
- body: { status: true, message: 'OK', code: 0 },
13
- })
14
-
15
- describe('dispatchResult', () => {
16
- test('express sink writes json to res', () => {
17
- const headers: Record<string, string> = {}
18
- const res = {
19
- headersSent: false,
20
- statusCode: 0,
21
- setHeader(name: string, value: string) { headers[name.toLowerCase()] = value },
22
- status(code: number) { this.statusCode = code; return this },
23
- json(body: unknown) { this.body = body; return this },
24
- body: undefined as unknown,
25
- }
26
-
27
- dispatchResult(sampleResult(), { framework: FrameworkEnum.EXPRESS }, res)
28
-
29
- expect(res.statusCode).toBe(200)
30
- expect(res.body).toEqual({ status: true, message: 'OK', code: 0 })
31
- })
32
-
33
- test('fetch sink returns Response', async () => {
34
- const out = dispatchResult(sampleResult(), { framework: FrameworkEnum.FETCH }) as Response
35
- expect(out).toBeInstanceOf(Response)
36
- expect(out.status).toBe(200)
37
- expect(await out.json()).toEqual({ status: true, message: 'OK', code: 0 })
38
- })
39
-
40
- test('default sink is elysia when framework omitted', () => {
41
- const set: Record<string, unknown> = {}
42
- const out = dispatchResult(sampleResult(), { ctx: { set } }) as Response
43
- expect(out).toBeDefined()
44
- })
45
-
46
- test('skips when headers already sent', () => {
47
- const res = {
48
- headersSent: true,
49
- status() { throw new Error('should not call status') },
50
- }
51
- expect(dispatchResult(sampleResult(), { framework: FrameworkEnum.EXPRESS }, res)).toBeUndefined()
52
- })
53
-
54
- describe('realtime sinks', () => {
55
- beforeEach(() => registerTestDto())
56
-
57
- test('websocket sink sends JSON string', () => {
58
- const runtime = new DTO({ withDefaultHeaders: false })
59
- const sent: string[] = []
60
- const socket: any = { send: (d: string) => sent.push(d) }
61
- runtime.attachWebSocket(socket)
62
-
63
- dispatchResult(sampleResult(), { protocol: ProtocolEnum.WEBSOCKET, socket })
64
-
65
- expect(JSON.parse(sent[0]).body.message).toBe('OK')
66
- })
67
-
68
- test('socketio sink emits configured event', () => {
69
- registerTestDto({ socketEvent: 'api:response' })
70
- const runtime = new DTO({ withDefaultHeaders: false })
71
- const emitted: Array<{ event: string; data: unknown }> = []
72
- const socket: any = { emit: (event: string, data: unknown) => emitted.push({ event, data }) }
73
- runtime.attachSocketIo(socket)
74
-
75
- dispatchResult(sampleResult(), {
76
- protocol: ProtocolEnum.SOCKETIO,
77
- socket,
78
- })
79
-
80
- expect(emitted[0].event).toBe('api:response')
81
- expect((emitted[0].data as any).body.message).toBe('OK')
82
- })
83
- })
84
- })
@@ -1,8 +0,0 @@
1
- {
2
- "responseMessage": {
3
- "successfully": "Operation completed successfully",
4
- "unsuccessful": "Operation failed",
5
- "notFound": "Not found",
6
- "process": "Process completed"
7
- }
8
- }