@xrystal/core 3.28.3 → 3.37.3

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 (233) hide show
  1. package/README.md +2331 -21
  2. package/package.json +66 -24
  3. package/tsconfig.base.json +15 -0
  4. package/x/bin/commands/create.mjs +136 -0
  5. package/x/bin/commands/doctor.mjs +149 -0
  6. package/x/bin/commands/hooks.mjs +55 -0
  7. package/x/bin/commands/project.mjs +126 -0
  8. package/x/bin/commands/release.mjs +66 -0
  9. package/x/bin/commands/sync-toolchain.mjs +43 -0
  10. package/x/bin/commands/tmp.mjs +57 -0
  11. package/x/bin/constants/index.mjs +6 -0
  12. package/x/bin/helpers/.generated/.generated-from +1 -0
  13. package/x/bin/helpers/.generated/tmp-schema.mjs +192 -0
  14. package/x/bin/helpers/banner.mjs +80 -0
  15. package/x/bin/helpers/build-config.mjs +342 -0
  16. package/x/bin/helpers/cli-help.mjs +164 -0
  17. package/x/bin/helpers/cli-identity.mjs +17 -0
  18. package/x/bin/helpers/create-target.mjs +35 -0
  19. package/{bin → x/bin}/helpers/index.mjs +44 -1
  20. package/x/bin/helpers/project-artifacts.mjs +140 -0
  21. package/x/bin/helpers/project-root.mjs +70 -0
  22. package/x/bin/helpers/runtime-info.mjs +172 -0
  23. package/x/bin/helpers/tmp-config.mjs +67 -0
  24. package/x/bin/helpers/tmp-layout.mjs +281 -0
  25. package/x/bin/helpers/tmp-schema.mjs +9 -0
  26. package/x/bin/helpers/toolchain-config.mjs +233 -0
  27. package/x/bin/main-cli.js +80 -0
  28. package/x/bin/paths.mjs +14 -0
  29. package/x/bin/scripts/clean-source-types.mjs +19 -0
  30. package/x/bin/scripts/fix-dist-imports.mjs +80 -0
  31. package/x/bin/scripts/install-git-hooks.mjs +86 -0
  32. package/x/bin/scripts/minify-dist.mjs +50 -0
  33. package/x/bin/scripts/prepare-npm-publish.mjs +49 -0
  34. package/x/bin/scripts/release-prepare.mjs +56 -0
  35. package/x/bin/scripts/tag.mjs +17 -0
  36. package/x/bin/scripts/unpublish-leaked-versions.mjs +62 -0
  37. package/x/bin/scripts/verify-npm-pack.mjs +45 -0
  38. package/x/bin/scripts/verify-version-bump.mjs +27 -0
  39. package/x/bin/scripts/version-check.mjs +370 -0
  40. package/x/dist/index.d.ts +3 -0
  41. package/x/dist/index.js +1 -0
  42. package/{source → x/dist}/loader/clients/index.d.ts +2 -1
  43. package/x/dist/loader/clients/index.js +1 -0
  44. package/{source → x/dist}/loader/configs/index.d.ts +3 -2
  45. package/x/dist/loader/configs/index.js +1 -0
  46. package/x/dist/loader/controller/index.d.ts +69 -0
  47. package/x/dist/loader/controller/index.js +1 -0
  48. package/x/dist/loader/dto/index.d.ts +39 -0
  49. package/x/dist/loader/dto/index.js +1 -0
  50. package/{source → x/dist}/loader/events/index.d.ts +1 -1
  51. package/x/dist/loader/events/index.js +1 -0
  52. package/{source → x/dist}/loader/index.d.ts +2 -1
  53. package/x/dist/loader/index.js +1 -0
  54. package/{source → x/dist}/loader/kafka/index.d.ts +6 -3
  55. package/x/dist/loader/kafka/index.js +1 -0
  56. package/{source → x/dist}/loader/localizations/index.d.ts +4 -3
  57. package/x/dist/loader/localizations/index.js +1 -0
  58. package/{source → x/dist}/loader/logger/index.d.ts +10 -7
  59. package/x/dist/loader/logger/index.js +2 -0
  60. package/x/dist/loader/service/index.js +1 -0
  61. package/{source → x/dist}/loader/system/index.d.ts +4 -3
  62. package/x/dist/loader/system/index.js +1 -0
  63. package/{source → x/dist}/project/index.d.ts +2 -2
  64. package/x/dist/project/index.js +1 -0
  65. package/x/dist/utils/constants/defaults.json +44 -0
  66. package/x/dist/utils/constants/index.d.ts +27 -0
  67. package/x/dist/utils/constants/index.js +1 -0
  68. package/x/dist/utils/helpers/configs/index.js +1 -0
  69. package/x/dist/utils/helpers/context/controller-store.d.ts +51 -0
  70. package/x/dist/utils/helpers/context/controller-store.js +1 -0
  71. package/x/dist/utils/helpers/context/index.d.ts +18 -0
  72. package/x/dist/utils/helpers/context/index.js +1 -0
  73. package/{source → x/dist}/utils/helpers/core/index.d.ts +8 -6
  74. package/x/dist/utils/helpers/core/index.js +1 -0
  75. package/x/dist/utils/helpers/core/paths.d.ts +2 -0
  76. package/x/dist/utils/helpers/core/paths.js +1 -0
  77. package/x/dist/utils/helpers/core/tmp-layout.d.ts +45 -0
  78. package/x/dist/utils/helpers/core/tmp-layout.js +1 -0
  79. package/{source → x/dist}/utils/helpers/date/index.d.ts +1 -1
  80. package/x/dist/utils/helpers/date/index.js +1 -0
  81. package/x/dist/utils/helpers/dispatch/index.d.ts +9 -0
  82. package/x/dist/utils/helpers/dispatch/index.js +1 -0
  83. package/x/dist/utils/helpers/dto/index.d.ts +10 -0
  84. package/x/dist/utils/helpers/dto/index.js +1 -0
  85. package/x/dist/utils/helpers/filters/index.js +1 -0
  86. package/x/dist/utils/helpers/framework/index.d.ts +3 -0
  87. package/x/dist/utils/helpers/framework/index.js +1 -0
  88. package/x/dist/utils/helpers/handlers/adapters.d.ts +10 -0
  89. package/x/dist/utils/helpers/handlers/adapters.js +1 -0
  90. package/x/dist/utils/helpers/handlers/execute.d.ts +5 -0
  91. package/x/dist/utils/helpers/handlers/execute.js +1 -0
  92. package/x/dist/utils/helpers/handlers/index.d.ts +18 -0
  93. package/x/dist/utils/helpers/handlers/index.js +1 -0
  94. package/x/dist/utils/helpers/hash/crypto.js +1 -0
  95. package/x/dist/utils/helpers/id/index.js +1 -0
  96. package/x/dist/utils/helpers/index.d.ts +26 -0
  97. package/x/dist/utils/helpers/index.js +1 -0
  98. package/x/dist/utils/helpers/ip/index.js +1 -0
  99. package/x/dist/utils/helpers/is/index.js +1 -0
  100. package/{source → x/dist}/utils/helpers/locales/index.d.ts +1 -0
  101. package/x/dist/utils/helpers/locales/index.js +1 -0
  102. package/x/dist/utils/helpers/math/index.js +1 -0
  103. package/x/dist/utils/helpers/middleware/index.d.ts +19 -0
  104. package/x/dist/utils/helpers/middleware/index.js +1 -0
  105. package/x/dist/utils/helpers/objects/index.js +1 -0
  106. package/x/dist/utils/helpers/path/index.js +1 -0
  107. package/x/dist/utils/helpers/protocol/index.d.ts +20 -0
  108. package/x/dist/utils/helpers/protocol/index.js +1 -0
  109. package/x/dist/utils/helpers/protocol/options.d.ts +6 -0
  110. package/x/dist/utils/helpers/protocol/options.js +1 -0
  111. package/x/dist/utils/helpers/regex/checkSpecialRegexControl.js +1 -0
  112. package/x/dist/utils/helpers/runtime/dto-access.d.ts +3 -0
  113. package/x/dist/utils/helpers/runtime/dto-access.js +1 -0
  114. package/x/dist/utils/helpers/runtime/dto-types.d.ts +19 -0
  115. package/x/dist/utils/helpers/runtime/dto-types.js +1 -0
  116. package/x/dist/utils/helpers/runtime/index.d.ts +3 -0
  117. package/x/dist/utils/helpers/runtime/index.js +1 -0
  118. package/x/dist/utils/helpers/runtime/shutdown.d.ts +3 -0
  119. package/x/dist/utils/helpers/runtime/shutdown.js +1 -0
  120. package/x/dist/utils/helpers/state/index.d.ts +59 -0
  121. package/x/dist/utils/helpers/state/index.js +1 -0
  122. package/x/dist/utils/helpers/state/props-from-tmp.d.ts +9 -0
  123. package/x/dist/utils/helpers/state/props-from-tmp.js +1 -0
  124. package/x/dist/utils/helpers/state/request-key-guard.d.ts +3 -0
  125. package/x/dist/utils/helpers/state/request-key-guard.js +1 -0
  126. package/x/dist/utils/helpers/state/scopes.d.ts +21 -0
  127. package/x/dist/utils/helpers/state/scopes.js +1 -0
  128. package/x/dist/utils/helpers/string/index.js +1 -0
  129. package/x/dist/utils/helpers/tests/tmp-schema.test.js +1 -0
  130. package/{source/utils/models/types/index.js → x/dist/utils/helpers/tests/tmp-watch.test.d.ts} +0 -1
  131. package/x/dist/utils/helpers/tests/tmp-watch.test.js +1 -0
  132. package/x/dist/utils/helpers/timer/index.js +1 -0
  133. package/x/dist/utils/helpers/tmp/index.d.ts +5 -0
  134. package/x/dist/utils/helpers/tmp/index.js +1 -0
  135. package/x/dist/utils/helpers/tmp/loader-tmp-sync.d.ts +4 -0
  136. package/x/dist/utils/helpers/tmp/loader-tmp-sync.js +1 -0
  137. package/x/dist/utils/helpers/tmp/runtime-tmp.d.ts +9 -0
  138. package/x/dist/utils/helpers/tmp/runtime-tmp.js +1 -0
  139. package/x/dist/utils/helpers/tmp/tmp-loader.d.ts +7 -0
  140. package/x/dist/utils/helpers/tmp/tmp-loader.js +1 -0
  141. package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +47 -0
  142. package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -0
  143. package/x/dist/utils/helpers/tmp/tmp-watch.d.ts +1 -0
  144. package/x/dist/utils/helpers/tmp/tmp-watch.js +1 -0
  145. package/x/dist/utils/helpers/validates/index.js +1 -0
  146. package/x/dist/utils/index.d.ts +3 -0
  147. package/x/dist/utils/index.js +1 -0
  148. package/x/dist/utils/models/classes/class.clients.js +1 -0
  149. package/x/dist/utils/models/classes/class.interfaces.js +1 -0
  150. package/x/dist/utils/models/classes/class.service-locator.js +1 -0
  151. package/{source → x/dist}/utils/models/classes/class.tmp-file-loader.d.ts +3 -2
  152. package/x/dist/utils/models/classes/class.tmp-file-loader.js +1 -0
  153. package/x/dist/utils/models/classes/class.x.js +1 -0
  154. package/{source → x/dist}/utils/models/enums/index.d.ts +14 -1
  155. package/x/dist/utils/models/enums/index.js +1 -0
  156. package/x/dist/utils/models/index.d.ts +9 -0
  157. package/x/dist/utils/models/index.js +1 -0
  158. package/x/dist/utils/models/types/index.d.ts +5 -0
  159. package/x/dist/utils/models/types/index.js +1 -0
  160. package/x/dist/utils/package-root.d.ts +2 -0
  161. package/x/dist/utils/package-root.js +1 -0
  162. package/x/tmp.yml +48 -17
  163. package/bin/constants/index.mjs +0 -17
  164. package/bin/main-cli.js +0 -131
  165. package/source/index.js +0 -6
  166. package/source/loader/clients/index.js +0 -18
  167. package/source/loader/configs/index.js +0 -81
  168. package/source/loader/controller/index.d.ts +0 -129
  169. package/source/loader/controller/index.js +0 -327
  170. package/source/loader/events/index.js +0 -44
  171. package/source/loader/index.js +0 -10
  172. package/source/loader/kafka/index.js +0 -122
  173. package/source/loader/localizations/index.js +0 -40
  174. package/source/loader/logger/index.js +0 -183
  175. package/source/loader/service/index.js +0 -7
  176. package/source/loader/system/index.js +0 -19
  177. package/source/project/index.js +0 -66
  178. package/source/utils/constants/index.d.ts +0 -10
  179. package/source/utils/constants/index.js +0 -11
  180. package/source/utils/helpers/configs/index.js +0 -1
  181. package/source/utils/helpers/core/index.js +0 -105
  182. package/source/utils/helpers/date/index.js +0 -48
  183. package/source/utils/helpers/filters/index.js +0 -44
  184. package/source/utils/helpers/hash/crypto.js +0 -22
  185. package/source/utils/helpers/id/index.js +0 -24
  186. package/source/utils/helpers/index.d.ts +0 -17
  187. package/source/utils/helpers/index.js +0 -17
  188. package/source/utils/helpers/ip/index.js +0 -21
  189. package/source/utils/helpers/is/index.js +0 -35
  190. package/source/utils/helpers/locales/index.js +0 -63
  191. package/source/utils/helpers/math/index.js +0 -14
  192. package/source/utils/helpers/middlewares/index.d.ts +0 -1
  193. package/source/utils/helpers/middlewares/index.js +0 -26
  194. package/source/utils/helpers/objects/index.js +0 -55
  195. package/source/utils/helpers/path/index.js +0 -4
  196. package/source/utils/helpers/regex/checkSpecialRegexControl.js +0 -3
  197. package/source/utils/helpers/string/index.js +0 -9
  198. package/source/utils/helpers/timer/index.js +0 -5
  199. package/source/utils/helpers/validates/index.js +0 -20
  200. package/source/utils/index.d.ts +0 -3
  201. package/source/utils/index.js +0 -3
  202. package/source/utils/models/classes/class.clients.js +0 -142
  203. package/source/utils/models/classes/class.dtos.d.ts +0 -47
  204. package/source/utils/models/classes/class.dtos.js +0 -36
  205. package/source/utils/models/classes/class.interfaces.js +0 -10
  206. package/source/utils/models/classes/class.response.d.ts +0 -17
  207. package/source/utils/models/classes/class.response.js +0 -35
  208. package/source/utils/models/classes/class.service-locator.js +0 -16
  209. package/source/utils/models/classes/class.tmp-file-loader.js +0 -38
  210. package/source/utils/models/classes/class.x.js +0 -179
  211. package/source/utils/models/enums/index.js +0 -133
  212. package/source/utils/models/index.d.ts +0 -11
  213. package/source/utils/models/index.js +0 -11
  214. package/source/utils/models/types/index.d.ts +0 -3
  215. /package/{source → x/dist}/loader/service/index.d.ts +0 -0
  216. /package/{source → x/dist}/utils/helpers/configs/index.d.ts +0 -0
  217. /package/{source → x/dist}/utils/helpers/filters/index.d.ts +0 -0
  218. /package/{source → x/dist}/utils/helpers/hash/crypto.d.ts +0 -0
  219. /package/{source → x/dist}/utils/helpers/id/index.d.ts +0 -0
  220. /package/{source → x/dist}/utils/helpers/ip/index.d.ts +0 -0
  221. /package/{source → x/dist}/utils/helpers/is/index.d.ts +0 -0
  222. /package/{source → x/dist}/utils/helpers/math/index.d.ts +0 -0
  223. /package/{source → x/dist}/utils/helpers/objects/index.d.ts +0 -0
  224. /package/{source → x/dist}/utils/helpers/path/index.d.ts +0 -0
  225. /package/{source → x/dist}/utils/helpers/regex/checkSpecialRegexControl.d.ts +0 -0
  226. /package/{source → x/dist}/utils/helpers/string/index.d.ts +0 -0
  227. /package/{source/index.d.ts → x/dist/utils/helpers/tests/tmp-schema.test.d.ts} +0 -0
  228. /package/{source → x/dist}/utils/helpers/timer/index.d.ts +0 -0
  229. /package/{source → x/dist}/utils/helpers/validates/index.d.ts +0 -0
  230. /package/{source → x/dist}/utils/models/classes/class.clients.d.ts +0 -0
  231. /package/{source → x/dist}/utils/models/classes/class.interfaces.d.ts +0 -0
  232. /package/{source → x/dist}/utils/models/classes/class.service-locator.d.ts +0 -0
  233. /package/{source → x/dist}/utils/models/classes/class.x.d.ts +0 -0
@@ -1,63 +0,0 @@
1
- const f = (...args) => args.filter(item => item && typeof item === 'string' && item.trim() !== '').join(' ').trim();
2
- export const coreMessages = {
3
- 'successfully': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.successfully')}.`.trim(),
4
- 'unsuccessful': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.unsuccessful')}.`.trim(),
5
- 'notFound': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.notFound')}.`.trim(),
6
- 'notMatch': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.notMatch')}.`.trim(),
7
- 'notUse': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.notUse')}.`.trim(),
8
- 'invalid': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.invalid')}.`.trim(),
9
- 'checked': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.checked')}.`.trim(),
10
- 'process': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.process')}.`.trim(),
11
- 'missingData': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.missingData')}.`.trim(),
12
- 'allreadyHave': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.allreadyHave')}.`.trim(),
13
- 'wrongFormat': (p = '', e = '', t) => `${f(p, e)} ${t && t('responseMessage.wrongFormat')}.`.trim(),
14
- 'externalApiError': (p = '', e = '', t) => `${f(p, e)}, ${t && t('responseMessage.externalApiError')}.`.trim(),
15
- 'unauthorizedUrl': (p = '', e = '', t) => `${f(p, e)}, ${t && t('responseMessage.unauthorizedUrl')}.`.trim(),
16
- 'endpointNotWorking': (endpoint = '', t) => `${endpoint}, ${t && t('responseMessage.endpointNotWorking')}.`.trim(),
17
- 'schemaMissingDataChecks': (t) => `${t && t('responseMessage.schemaMissingDataChecks')}.`.trim(),
18
- 'schemaInvalidDataChecks': (t) => `${t && t('responseMessage.schemaInvalidDataChecks')}.`.trim(),
19
- 'schemaUnknowErrorChecks': (a, b, t) => `${t && t('responseMessage.schemaUnknowErrorChecks')}. ${a}. ${t('responseMessage.schemaErrorExtraExplanation')}: ${b}`.trim(),
20
- 'schemaUnknowErrorLogic': (a, b, t) => `${t && t('responseMessage.schemaUnknowErrorLogic')}. ${a}. ${t('responseMessage.schemaErrorExtraExplanation')}: ${b}`.trim(),
21
- 'schemaUnknowErrorResponse': (a, b, t) => `${t && t('responseMessage.schemaUnknowErrorLogic')}. ${a}. ${t('responseMessage.schemaErrorExtraExplanation')}: ${b}`.trim(),
22
- 'schemaUnknowErrorMain': (a, b, t) => `${t && t('responseMessage.schemaUnknowErrorMain')}. ${a}. ${t('responseMessage.schemaErrorExtraExplanation')}: ${b}`.trim(),
23
- 'dbQueryError': (p = '', e = '', t) => `${t && t('responseMessage.dbQueryError')}. ${f(p, e)}`.trim(),
24
- 'unknowError': (p = '', e = '', t) => `${t && t('responseMessage.unknowError')}. ${f(p, e)}`.trim(),
25
- 'serverError': (p = '', e = '', t) => `${t && t('responseMessage.serverError')}. ${f(p, e)}`.trim(),
26
- 'emailWelcomeTemplateTitle': (t) => `${t && t('responseMessage.emailWelcomeTemplateTitle')}`.trim(),
27
- 'emailWelcomeTemplateExplanation': (t) => `${t && t('responseMessage.emailWelcomeTemplateExplanation')}.`.trim(),
28
- 'emailForgotPasswordTemplateTitle': (t) => `${t && t('responseMessage.emailForgotPasswordTemplateTitle')}`.trim(),
29
- 'emailForgotPasswordTemplateExplanation': (t) => `${t && t('responseMessage.emailForgotPasswordTemplateExplanation')}.`.trim(),
30
- 'allRightsReserved': (e1 = '', e2 = '', t) => `${f(e1, e2)}, ${t && t('responseMessage.allRightsReserved')}.`.trim(),
31
- 'emailButtonText': (t) => `${t && t('responseMessage.emailButtonText')}.`.trim(),
32
- 'emailIgnoreText': (t) => `${t && t('responseMessage.emailIgnoreText')}.`.trim(),
33
- 'welcomeMessage': (username = '', t) => `@${username} - ${t && t('responseMessage.welcome')}.`.trim(),
34
- 'userIsBlocked': (extra1 = '', t) => `${extra1}, ${t && t('responseMessage.userIsBlocked')}.`.trim(),
35
- 'passwordChangeCode': (username = '', t) => `@${username} - ${t && t('responseMessage.passwordChangeCode')}.`.trim(),
36
- 'notEnoughWalletBalance': (m = '', c = '', t) => `${f(m, c)}, ${t && t('responseMessage.notEnoughWalletBalance')}.`.trim(),
37
- 'openAuthConsumerOverhang': (p1 = '', p2 = '', t) => `${f(p1, p2)}, ${t && t('responseMessage.openAuthConsumerOverhang')}.`.trim(),
38
- 'thirdPartySystemOverhang': (p1 = '', p2 = '', t) => `${f(p1, p2)}, ${t && t('responseMessage.thirdPartySystems')}.`.trim(),
39
- 'deviceOverhang': (p1 = '', p2 = '', t) => `${f(p1, p2)}, ${t && t('responseMessage.deviceOverhang')}.`.trim(),
40
- 'provisionOverhang': (m = '', c = '', t) => `${f(m, c)}, ${t && t('responseMessage.provisionOverhang')}.`.trim(),
41
- 'balanceOverhang': (m = '', c = '', t) => `${f(m, c)}, ${t && t('responseMessage.balanceOverhang')}.`.trim(),
42
- 'debtOverhang': (m = '', c = '', t) => `${f(m, c)}, ${t && t('responseMessage.debtOverhang')}.`.trim(),
43
- 'shipmentNotAccepted': (v1 = '', v2 = '', t) => `${t && t('responseMessage.shipmentNotAccepted')}. ${f(v1, v2)}`.trim(),
44
- 'optionsMethod': (m = '', t) => `${t && t('responseMessage.optionsMethod')}. ${m}`.trim(),
45
- 'notAllowedCORS': (m = '', t) => `${t && t('responseMessage.notAllowedCORS')}. ${m}`.trim(),
46
- 'missingCRSFToken': (t) => `${t && t('responseMessage.missingCSRFToken')}.`.trim(),
47
- 'invalidCRSFToken': (t) => `${t && t('responseMessage.invalidCSRFToken')}.`.trim(),
48
- 'tooManyRequest': (t) => `${t && t('responseMessage.tooManyRequest')}.`.trim(),
49
- 'endpointNotFound': (t) => `${t && t('responseMessage.endpointNotFound')}.`.trim(),
50
- 'roleAccess': (error = '', t) => `${t && t('responseMessage.roleAccess')}. ${error}`.trim(),
51
- 'authenticationRequiredTokenExpired': (t) => `${t && t('responseMessage.authenticationRequiredTokenExpired')}.`.trim(),
52
- 'authenticationRequired': (t) => `${t && t('responseMessage.authenticationRequired')}.`.trim(),
53
- };
54
- export const responseMessageHelper = new Proxy(coreMessages, {
55
- get(target, prop) {
56
- if (prop in target)
57
- return target[prop];
58
- const local = globalThis.__LOCAL_MESSAGES__;
59
- if (local && prop in local)
60
- return local[prop];
61
- return (p = '', e = '', t) => `${f(p, e)} ${prop}.`.trim();
62
- }
63
- });
@@ -1,14 +0,0 @@
1
- export function calcPercentace(value, percentage) {
2
- if (typeof value !== "number" || typeof percentage !== "number") {
3
- throw new Error("Değerler sayısal olmalıdır.");
4
- }
5
- return (value * percentage) / 100;
6
- }
7
- export function bankersRounding(value, decimals = 2) {
8
- const factor = Math.pow(10, decimals);
9
- const rounded = Math.round(value * factor);
10
- const isHalf = (value * factor) % 1 === 0.5;
11
- return isHalf && rounded % 2 !== 0
12
- ? (rounded - 1) / factor
13
- : rounded / factor;
14
- }
@@ -1 +0,0 @@
1
- export declare const toExpress: (action: () => Promise<any>) => (req: any, res: any, next: any) => Promise<any>;
@@ -1,26 +0,0 @@
1
- import { controllerContextStorage } from "source/loader/controller";
2
- import { ProtocolEnum } from "source/utils/models";
3
- // => Use case - app.post('/example', toExpress(() => exampleCtrl.example()))
4
- export const toExpress = (action) => async (req, res, next) => {
5
- try {
6
- const result = await controllerContextStorage.run({
7
- req,
8
- res,
9
- protocol: ProtocolEnum.HTTP,
10
- metadata: { locals: res.locals || {} }
11
- }, action);
12
- if (result instanceof Response) {
13
- res.status(result.status);
14
- result.headers.forEach((v, k) => res.setHeader(k, v));
15
- const contentType = result.headers.get('content-type') || '';
16
- if (contentType.includes('application/json') || contentType.includes('text/')) {
17
- return res.send(await result.text());
18
- }
19
- return res.send(Buffer.from(await result.arrayBuffer()));
20
- }
21
- return res.send(result);
22
- }
23
- catch (e) {
24
- next(e);
25
- }
26
- };
@@ -1,55 +0,0 @@
1
- export function pickProps(obj, props) {
2
- if (!obj) {
3
- return {};
4
- }
5
- const negativeProps = new Set();
6
- const positiveProps = new Set();
7
- for (const p of props) {
8
- if (typeof p === 'string' && p.startsWith('-')) {
9
- negativeProps.add(p.substring(1));
10
- }
11
- else {
12
- positiveProps.add(p);
13
- }
14
- }
15
- function getNestedValue(o, path) {
16
- return path.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), o);
17
- }
18
- function setNestedValue(o, path, value) {
19
- let current = o;
20
- for (let i = 0; i < path.length - 1; i++) {
21
- if (!(path[i] in current))
22
- current[path[i]] = {};
23
- current = current[path[i]];
24
- }
25
- current[path[path.length - 1]] = value;
26
- }
27
- if (negativeProps.size > 0) {
28
- const result = {};
29
- function recurse(currentObj, currentPath = [], resObj) {
30
- for (const key in currentObj) {
31
- const fullPath = [...currentPath, key].join('.');
32
- if (!Array.from(negativeProps).some(neg => fullPath === neg || fullPath.startsWith(neg + '.'))) {
33
- if (typeof currentObj[key] === 'object' && currentObj[key] !== null && !Array.isArray(currentObj[key])) {
34
- resObj[key] = {};
35
- recurse(currentObj[key], [...currentPath, key], resObj[key]);
36
- }
37
- else {
38
- resObj[key] = currentObj[key];
39
- }
40
- }
41
- }
42
- }
43
- recurse(obj, [], result);
44
- return result;
45
- }
46
- const result = {};
47
- for (const p of positiveProps) {
48
- const path = p.split('.');
49
- const value = getNestedValue(obj, path);
50
- if (value !== undefined) {
51
- setNestedValue(result, path, value);
52
- }
53
- }
54
- return result;
55
- }
@@ -1,4 +0,0 @@
1
- import path from "path";
2
- import { fileURLToPath } from "url";
3
- export const __filename = (metaUrl) => fileURLToPath(metaUrl);
4
- export const __dirname = (metaUrl) => path.dirname(fileURLToPath(metaUrl));
@@ -1,3 +0,0 @@
1
- export function checkSpecialRegexControl(str, regex) {
2
- return regex.test(str);
3
- }
@@ -1,9 +0,0 @@
1
- export function cleanStringForNormalize(input) {
2
- if (typeof input !== 'string')
3
- return '';
4
- const cleaned = input
5
- .normalize('NFD')
6
- .replace(/\u0307/g, '')
7
- .normalize('NFC');
8
- return cleaned;
9
- }
@@ -1,5 +0,0 @@
1
- export async function delay({ duration, }) {
2
- return new Promise((resolve, reject) => {
3
- setTimeout(() => resolve(delay), duration);
4
- });
5
- }
@@ -1,20 +0,0 @@
1
- export const validateScopes = ({ scopes, permissions, resources }) => {
2
- const parsedScopes = scopes.split(' ');
3
- function dublicateControl(parsedScopes) {
4
- const uniqueScopes = new Set(parsedScopes);
5
- if (uniqueScopes.size !== parsedScopes.length) {
6
- return true;
7
- }
8
- return false;
9
- }
10
- if (dublicateControl(parsedScopes)) {
11
- return false;
12
- }
13
- const isInvalid = parsedScopes.some((scope) => {
14
- const [resource, permission] = scope.split(':');
15
- const isValidResource = resources.includes(resource);
16
- const isValidPermission = permissions.includes(permission);
17
- return !isValidResource || !isValidPermission;
18
- });
19
- return !isInvalid;
20
- };
@@ -1,3 +0,0 @@
1
- export * from './constants';
2
- export * from './helpers';
3
- export * from './models';
@@ -1,3 +0,0 @@
1
- export * from './constants';
2
- export * from './helpers';
3
- export * from './models';
@@ -1,142 +0,0 @@
1
- import { createHash, createHmac } from 'node:crypto';
2
- import { Configs, Logger } from '../../../loader';
3
- import { LoggerLayerEnum, x } from '../../index';
4
- export class ClientStore {
5
- static _store = {};
6
- static get(clientName) { return this._store[clientName] || {}; }
7
- static set(clientName, data) {
8
- this._store[clientName] = { ...this._store[clientName], ...data };
9
- }
10
- }
11
- export class Client {
12
- logger = x.get(Logger);
13
- configs = x.get(Configs);
14
- clientName;
15
- baseURL;
16
- version = null;
17
- timeout = 15000;
18
- debug;
19
- authConfigs;
20
- breaker = {
21
- failures: 0,
22
- lastFailure: 0,
23
- state: 'CLOSED',
24
- threshold: 5,
25
- cooldown: 30000
26
- };
27
- constructor({ clientName, baseURL, version, timeout, auth, debug }) {
28
- this.clientName = clientName;
29
- this.baseURL = baseURL;
30
- this.version = version || null;
31
- this.authConfigs = auth;
32
- this.timeout = timeout || 15000;
33
- const configDebug = Number(this.configs.all.debug) >= LoggerLayerEnum.DEBUG;
34
- this.debug = debug ?? configDebug;
35
- if (auth?.token)
36
- ClientStore.set(clientName, { accessToken: auth.token });
37
- }
38
- resolvePath(obj, path) {
39
- return path.split('.').reduce((prev, curr) => prev ? prev[curr] : undefined, obj);
40
- }
41
- static cryptoHashGenerate = ({ algorithm, input, digest = 'hex' }) => {
42
- return createHash(algorithm).update(input).digest(digest);
43
- };
44
- }
45
- export class BaseApiClient extends Client {
46
- constructor(config) { super(config); }
47
- async request(path, options = {}) {
48
- if (this.breaker.state === 'OPEN') {
49
- if (Date.now() - this.breaker.lastFailure > this.breaker.cooldown) {
50
- this.breaker.state = 'HALF_OPEN';
51
- }
52
- else {
53
- throw new Error(`[CircuitBreaker] ${this.clientName} is OPEN`);
54
- }
55
- }
56
- const maxRetries = options.retries ?? 3;
57
- let attempt = 0;
58
- while (attempt < maxRetries) {
59
- try {
60
- const response = await this._execute(path, { ...options });
61
- if (response.ok || response.status === 401) {
62
- this.breaker.failures = 0;
63
- this.breaker.state = 'CLOSED';
64
- return response;
65
- }
66
- if ([502, 503, 504].includes(response.status)) {
67
- throw new Error(`Server Error: ${response.status}`);
68
- }
69
- return response;
70
- }
71
- catch (error) {
72
- attempt++;
73
- this.breaker.failures++;
74
- this.breaker.lastFailure = Date.now();
75
- if (this.breaker.failures >= this.breaker.threshold)
76
- this.breaker.state = 'OPEN';
77
- if (attempt >= maxRetries)
78
- throw error;
79
- const backoff = Math.pow(2, attempt) * 500;
80
- await new Promise(res => setTimeout(res, backoff));
81
- }
82
- }
83
- throw new Error(`${this.clientName} failed after ${maxRetries} attempts`);
84
- }
85
- async _execute(path, options) {
86
- const base = this.baseURL.replace(/\/$/, '');
87
- const activeVersion = options.version !== undefined ? options.version : this.version;
88
- const ver = activeVersion ? `/${activeVersion.replace(/^\//, '')}` : '';
89
- const url = `${base}${ver}${path}`;
90
- const store = Logger.storage.getStore();
91
- const correlationId = store?.get('correlationId');
92
- const headers = new Headers(options.headers || {});
93
- const isUrlEncoded = options.body instanceof URLSearchParams;
94
- const isFormData = options.body instanceof FormData;
95
- if (!isUrlEncoded && !isFormData) {
96
- headers.set('Content-Type', 'application/json');
97
- }
98
- if (correlationId)
99
- headers.set('x-correlation-id', correlationId);
100
- const systemSecret = this.configs.all.internalSecret || process.env.INTERNAL_SECRET;
101
- if (systemSecret) {
102
- const timestamp = Date.now().toString();
103
- const signature = createHmac('sha256', systemSecret)
104
- .update(timestamp + this.clientName)
105
- .digest('hex');
106
- headers.set('x-internal-signature', signature);
107
- headers.set('x-internal-timestamp', timestamp);
108
- headers.set('x-internal-client', this.clientName);
109
- }
110
- const isDebugMode = options.debug ?? this.debug;
111
- const { version, retries, debug, ...fetchOptions } = options;
112
- let processedBody = fetchOptions.body;
113
- if (processedBody && typeof processedBody === 'object' && !isUrlEncoded && !isFormData) {
114
- processedBody = JSON.stringify(processedBody);
115
- }
116
- if (isDebugMode) {
117
- const logData = {
118
- method: fetchOptions.method || 'GET',
119
- url,
120
- body: processedBody && typeof processedBody === 'string' ? JSON.parse(processedBody) : processedBody
121
- };
122
- console.log(`[DEBUG] ${this.clientName}`, logData);
123
- this.logger.winston.info(`${this.clientName} Request`, logData);
124
- }
125
- const controller = new AbortController();
126
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
127
- try {
128
- const response = await fetch(url, {
129
- ...fetchOptions,
130
- body: processedBody,
131
- headers,
132
- signal: controller.signal
133
- });
134
- clearTimeout(timeoutId);
135
- return response;
136
- }
137
- catch (error) {
138
- clearTimeout(timeoutId);
139
- throw error;
140
- }
141
- }
142
- }
@@ -1,47 +0,0 @@
1
- import { NodeEnvEnum } from "../enums";
2
- export interface ILogDTO {
3
- level: string;
4
- service: string;
5
- message: string;
6
- payload?: Record<string, any>;
7
- code: string | number;
8
- timestamp: string;
9
- id?: string | number;
10
- env: NodeEnvEnum;
11
- }
12
- export declare class LogDTO {
13
- static getSchema({ level, service, message, payload, code, timestamp, id, env }: ILogDTO): {
14
- level: string;
15
- service: string;
16
- message: string;
17
- payload: Record<string, any>;
18
- code: string | number;
19
- timestamp: string;
20
- id: string | number;
21
- env: NodeEnvEnum;
22
- };
23
- }
24
- export interface IMetadata<E = any> {
25
- source: string;
26
- eventType: string;
27
- timestamp: number;
28
- correlationId: string;
29
- userId?: string;
30
- extraData?: E;
31
- }
32
- export interface IMessageInput<P = any, E = any> {
33
- metadata: {
34
- source: string;
35
- eventType: string;
36
- userId?: string;
37
- correlationId?: string;
38
- extraData?: E;
39
- };
40
- payload: P;
41
- }
42
- export declare class QueueDTO {
43
- static getSchema<P, E>(input: IMessageInput<P, E>): {
44
- metadata: IMetadata<E>;
45
- payload: P;
46
- };
47
- }
@@ -1,36 +0,0 @@
1
- export class LogDTO {
2
- static getSchema({ level, service, message, payload, code, timestamp, id, env }) {
3
- if (!level || !service || !message || !timestamp || !env) {
4
- throw new Error("Missing data other data required!");
5
- }
6
- return {
7
- level,
8
- service,
9
- message,
10
- payload,
11
- code,
12
- timestamp,
13
- id,
14
- env
15
- };
16
- }
17
- }
18
- export class QueueDTO {
19
- static getSchema(input) {
20
- if (!input.metadata.source || !input.metadata.eventType) {
21
- throw new Error("Source and eventType are required inside metadata");
22
- }
23
- const finalMetadata = {
24
- source: input.metadata.source,
25
- eventType: input.metadata.eventType,
26
- timestamp: Date.now(),
27
- correlationId: input.metadata.correlationId || Math.random().toString(36).substring(7),
28
- userId: input.metadata.userId,
29
- extraData: input.metadata.extraData
30
- };
31
- return {
32
- metadata: finalMetadata,
33
- payload: input.payload
34
- };
35
- }
36
- }
@@ -1,10 +0,0 @@
1
- export class ILifeCycle {
2
- async onInit(props = {}) {
3
- }
4
- onAfterInit(_context) {
5
- }
6
- onDispose(_context) {
7
- }
8
- }
9
- export class IProvide extends ILifeCycle {
10
- }
@@ -1,17 +0,0 @@
1
- export interface PayloadSchemaInterface {
2
- status: boolean;
3
- message: string;
4
- payload?: any;
5
- code?: number;
6
- [key: string]: any;
7
- }
8
- export declare class ResponseSchema {
9
- status: boolean;
10
- message: string;
11
- payload: any;
12
- code: number;
13
- constructor({ status, message, payload, code }: PayloadSchemaInterface);
14
- validData(): any;
15
- statusCodeGenerator(): number;
16
- get getResponse(): any;
17
- }
@@ -1,35 +0,0 @@
1
- export class ResponseSchema {
2
- status;
3
- message;
4
- payload;
5
- code;
6
- constructor({ status = false, message = '', payload = null, code = 0 }) {
7
- this.status = status;
8
- this.message = message;
9
- this.payload = payload;
10
- this.code = code;
11
- }
12
- validData() {
13
- return this.payload;
14
- }
15
- statusCodeGenerator() {
16
- if (this.status === false) {
17
- if (this.code !== 0 && this.code !== 1) {
18
- return Number(this.code);
19
- }
20
- return 1;
21
- }
22
- return 0;
23
- }
24
- get getResponse() {
25
- const response = {
26
- status: this.status,
27
- message: this.message
28
- };
29
- if (this.payload !== null && this.payload !== undefined) {
30
- response.payload = this.validData();
31
- }
32
- response.code = this.statusCodeGenerator();
33
- return response;
34
- }
35
- }
@@ -1,16 +0,0 @@
1
- // => // X Service Locator
2
- export class Locator {
3
- _context = new Map();
4
- constructor({}) {
5
- }
6
- set = ({ service, reference, args }) => {
7
- this._context.set(service, new reference(...(args || [])));
8
- };
9
- get = (service) => {
10
- if (!this._context.has(service)) {
11
- throw new Error(`${service} not found in context.`);
12
- }
13
- return this._context.get(service);
14
- };
15
- }
16
- export default new Locator({});
@@ -1,38 +0,0 @@
1
- import { EventEmitter } from "node:events";
2
- import { resolve } from "node:path";
3
- import { readFileSync, watchFile } from "node:fs";
4
- import { parse } from "yaml";
5
- import { resolveObjWithHandlebars } from "../../helpers";
6
- export class TmpFileLoader extends EventEmitter {
7
- #tmpFileJson = {};
8
- #filePath;
9
- constructor({ filePath }) {
10
- super();
11
- this.#filePath = resolve(filePath);
12
- this.#loadSync();
13
- this.#initWatcher();
14
- }
15
- #loadSync() {
16
- try {
17
- const content = readFileSync(this.#filePath, "utf8");
18
- this.#tmpFileJson = parse(content);
19
- this.emit("reload", this.#tmpFileJson);
20
- }
21
- catch (err) {
22
- console.error(`[TmpFileLoader] Error: ${err}`);
23
- }
24
- }
25
- #initWatcher() {
26
- watchFile(this.#filePath, { interval: 500 }, (curr, prev) => {
27
- if (curr.mtimeMs !== prev.mtimeMs) {
28
- this.#loadSync();
29
- }
30
- });
31
- }
32
- getResolvedTmpFile() {
33
- const data = Object.keys(this.#tmpFileJson).length > 0
34
- ? this.#tmpFileJson
35
- : (this.#loadSync(), this.#tmpFileJson);
36
- return resolveObjWithHandlebars(data, data);
37
- }
38
- }