@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
@@ -0,0 +1 @@
1
+ export var NodeEnvEnum;(function(N){N.DEV="dev";N.TEST="test";N.PROD="prod"})(NodeEnvEnum||(NodeEnvEnum={}));export var ProtocolEnum;(function(N){N.HTTP="http";N.HTTPS="https";N.WEBSOCKET="ws";N.SOCKETIO="socketio";N.NONE="none"})(ProtocolEnum||(ProtocolEnum={}));export var FrameworkEnum;(function(N){N.EXPRESS="express";N.ELYSIA="elysia";N.NODE="node";N.FETCH="fetch";N.WEBSOCKET="websocket";N.SOCKETIO="socketio"})(FrameworkEnum||(FrameworkEnum={}));export var PolarityTypeEnum;(function(N){N[N.NOTR=0]="NOTR";N[N.POSITIVE=1]="POSITIVE";N[N.NEGATIVE=-1]="NEGATIVE"})(PolarityTypeEnum||(PolarityTypeEnum={}));export var LoggerLayerEnum;(function(N){N[N.CRITICAL=0]="CRITICAL";N[N.ERROR=1]="ERROR";N[N.WARN=2]="WARN";N[N.INFO=3]="INFO";N[N.HTTP=4]="HTTP";N[N.DEBUG=5]="DEBUG"})(LoggerLayerEnum||(LoggerLayerEnum={}));export var CountryCodeEnum;(function(N){N.EN="en";N.TR="tr"})(CountryCodeEnum||(CountryCodeEnum={}));export var CurrencyCodeEnum;(function(N){N.USD="usd";N.EUR="eur";N.TRY="try"})(CurrencyCodeEnum||(CurrencyCodeEnum={}));export var HttpMethodEnum;(function(N){N.POST="post";N.GET="get";N.PUT="put";N.DELETE="delete"})(HttpMethodEnum||(HttpMethodEnum={}));export var ContentTypeEnum;(function(N){N.applicationJson="application/json";N.applicationXWwwFormUrlencoded="application/x-www-form-urlencoded"})(ContentTypeEnum||(ContentTypeEnum={}));export var DeviceStatusEnum;(function(N){N[N.PENDING=0]="PENDING";N[N.OFFLINE=1]="OFFLINE";N[N.ONLINE=2]="ONLINE";N[N.CONNECTING=3]="CONNECTING";N[N.CONNECTED=4]="CONNECTED"})(DeviceStatusEnum||(DeviceStatusEnum={}));export var DevicePlatformEnum;(function(N){N.WEB="web";N.NATIVE="native";N.OTHER="other"})(DevicePlatformEnum||(DevicePlatformEnum={}));export var DeviceOSEnum;(function(N){N.ANDROID="android";N.IOS="ios";N.WINDOWS="windows";N.MACOS="macos";N.MACOSX="macosx";N.OTHER="other"})(DeviceOSEnum||(DeviceOSEnum={}));export var PriorityEnum;(function(N){N[N.HIGH=0]="HIGH";N[N.MEDIUM=1]="MEDIUM";N[N.LOW=2]="LOW"})(PriorityEnum||(PriorityEnum={}));export var PrivacyEnum;(function(N){N[N.PRIVATE=0]="PRIVATE";N[N.PUBLIC=1]="PUBLIC";N[N.ONLY_FRIENDS=2]="ONLY_FRIENDS"})(PrivacyEnum||(PrivacyEnum={}));export var TimezoneEnum;(function(N){N.UTC="UTC";N.EtcUTC="Etc/UTC";N.EtcGMT="Etc/GMT"})(TimezoneEnum||(TimezoneEnum={}));export var ModeEnum;(function(N){N.MONOLITIC="monolitic";N.MICRO_SERVICE="micro_service"})(ModeEnum||(ModeEnum={}));export var TokensEnum;(function(N){N.INTERNAL_API_TOKEN="internal_api_key";N.CSRF_TOKEN="csrf_token";N.ACCESS_TOKEN="access_token";N.REFRESH_TOKEN="refresh_token";N.REFERENCE_TOKEN="reference_token";N.PERSONAL_ACCESS_TOKEN="personal_access_token"})(TokensEnum||(TokensEnum={}));export var CoreClientsEnum;(function(N){N.BASE_API_CLIENT="base_client_name";N.SOAP_API_CLIENT="soap_api_client"})(CoreClientsEnum||(CoreClientsEnum={}));export var GStoreScopeEnum;(function(N){N.GLOBAL="global";N.RUN="run";N.CONTROLLER="controller"})(GStoreScopeEnum||(GStoreScopeEnum={}));export var EndpointResourceEnum;(function(N){N.EXAMPLE="example";N.FULL="full";N.SYSTEM="system";N.CLIENTS="clients";N.AUTH="auth";N.ACCOUNTS="accounts";N.USERS="users";N.TRANSACTIONS="transactions";N.NOTIFICATIONS="notifications";N.ADDRESSES="addresses";N.PAYMENTS="payments";N.COMMISSIONS_AND_TAXES="commissions-and-taxes";N.SUPPORTS="supports";N.INVOICES="invoices";N.FILES="files";N.TOKENS="tokens";N.WEBHOOKS="webhooks";N.OTHERS="others"})(EndpointResourceEnum||(EndpointResourceEnum={}));
@@ -0,0 +1 @@
1
+ import _ from"lodash";import x from"../../utils/models/classes/class.x.js";import locator from"../../utils/models/classes/class.service-locator.js";export*from"../../utils/models/classes/class.tmp-file-loader.js";export*from"../../utils/models/classes/class.interfaces.js";export*from"../../utils/models/classes/class.clients.js";export*from"../../utils/models/types/index.js";export*from"../../utils/models/enums/index.js";export{x,locator,_};
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1 @@
1
+ import o from"node:path";import{fileURLToPath as t}from"node:url";const r=o.dirname(t(import.meta.url));export const sourceDir=o.resolve(r,".."),packageRootDir=o.resolve(r,"..","..");
package/x/tmp.yml CHANGED
@@ -1,49 +1,58 @@
1
- # configs = proje ayarları (servis tmp.yml — tek kaynak)
2
- # @xrystal/core paketinde default rootFolderPath: x (servislerde değiştir)
3
1
  project:
4
2
  name: x
5
3
 
6
4
  configs:
7
- framework: elysia
8
- rootFolderPath: x
9
- mainFolderPath: ./source
10
- paths:
11
- tests: tests
12
- environments: environments
13
- dist: dist
14
- service: service-name
15
-
16
- loaders:
17
- configs:
18
- loadPath: '@/source/utils/helpers/configs/index'
19
-
20
- system:
21
- gStore:
22
- options:
23
- bootstrap: true
24
- autoCreateProps: true
25
- vars:
26
- test: false
27
-
28
- loggers:
29
- loadPath: logs
30
- logLevel: debug
31
-
32
- localization:
33
- loadPath: assets/langs
34
- fallbackLang: en
35
- preloadLangs:
36
- - en
37
- - tr
38
-
39
- dto:
40
- withDefaultHeaders: true
41
-
42
- controller:
43
-
44
- protocols:
45
- - http
46
- - ws
5
+ service:
6
+ name: example-service
7
+ framework: elysia
8
+
9
+ paths:
10
+ root: ./x
11
+ source: ./source
12
+ special:
13
+ tests: tests
14
+ environments: environments
15
+ dist: dist
16
+
17
+ protocols:
18
+ - http
19
+ - ws
20
+
21
+ loaders:
22
+ configs:
23
+ loadPath: '@/source/utils/helpers/configs/index'
24
+
25
+ system:
26
+ gStore:
27
+ options:
28
+ bootstrap: true
29
+ autoCreateProps: true
30
+ vars:
31
+ test: false
32
+
33
+ loggers:
34
+ loadPath: logs
35
+ logLevel: debug
36
+
37
+ localization:
38
+ loadPath: assets/langs
39
+ fallbackLang: en
40
+ preloadLangs:
41
+ - en
42
+ - tr
43
+
44
+ dto:
45
+ withDefaultHeaders: true
46
+
47
+ controller:
48
+
49
+ build:
50
+ typecheck: true
51
+ minify: true
52
+
53
+ core:
54
+ tmp:
55
+ fileWatchIntervalMs: 500
47
56
 
48
57
  end:
49
58
  version: 1
package/source/index.js DELETED
@@ -1,11 +0,0 @@
1
- import coreLoader from './project/index.js';
2
- import { ensureCoreTmpEntry, isCorePackageRoot } from './utils/helpers/core/tmp-layout';
3
- import { getTmpSnapshot } from './utils/helpers/tmp/tmp-loader';
4
- await (async () => {
5
- const root = process.cwd();
6
- if (isCorePackageRoot(root)) {
7
- ensureCoreTmpEntry(root);
8
- }
9
- getTmpSnapshot();
10
- await coreLoader({});
11
- })();
@@ -1,22 +0,0 @@
1
- import { BaseApiClient, CoreClientsEnum } from "../../utils";
2
- import { bindLoaderTmpSync } from '../../utils';
3
- export default class Clients {
4
- _instances = {};
5
- #configs;
6
- constructor({ configs }) {
7
- this.#configs = configs;
8
- }
9
- async onInit() {
10
- await this.syncFromTmp();
11
- bindLoaderTmpSync(this);
12
- }
13
- syncFromTmp = async () => {
14
- this._instances[CoreClientsEnum.BASE_API_CLIENT] = new BaseApiClient({
15
- clientName: CoreClientsEnum.BASE_API_CLIENT,
16
- baseURL: this.#configs.all.baseApiUri || '',
17
- });
18
- };
19
- get instances() {
20
- return this._instances;
21
- }
22
- }
@@ -1,88 +0,0 @@
1
- import path from 'node:path';
2
- import { isArray, mergeWith } from 'lodash';
3
- import { pathToFileURL } from 'node:url';
4
- import { bindLoaderTmpSync } from '../../utils';
5
- import { Constants } from '../../utils';
6
- export default class Configs {
7
- publicFolderName = Constants.publicFolderName;
8
- kafkaLogsTopic = Constants.kafkaLogsTopic;
9
- #system;
10
- #config;
11
- constructor({ system }) {
12
- this.#system = system;
13
- const proxy = new Proxy(this, {
14
- get: (target, prop) => {
15
- return target[prop] || target.config?.[prop];
16
- }
17
- });
18
- return proxy;
19
- }
20
- onInit = async () => {
21
- await this.syncFromTmp();
22
- bindLoaderTmpSync(this);
23
- };
24
- syncFromTmp = async () => {
25
- const cwd = process.cwd();
26
- const tmp = this.#system.tmp;
27
- const extendConfigs = tmp.configs.loaders.configs.loadPath;
28
- const fullPath = extendConfigs.startsWith('@/')
29
- ? path.join(process.cwd(), extendConfigs.slice(2))
30
- : path.resolve(tmp.configs.rootFolderPath, extendConfigs);
31
- const fileUrl = pathToFileURL(fullPath).href;
32
- const modulePromise = import(fileUrl);
33
- this.#config = {
34
- worker: process.env.WORKER === 'true' ? true : false || false,
35
- mode: process.env.MODE,
36
- nodeEnv: process.env.NODE_ENV ?? 'development',
37
- debug: process.env.SYSTEM_LOGGER_LAYER ?? '',
38
- https: process.env.HTTPS ?? 'false',
39
- httpsfileEncoding: process.env.ENCODING || 'utf8',
40
- httpsCertfile: process.env.HTTPS_CERT_FILE ?? '',
41
- httpsKeyfile: process.env.HTTPS_KEY_FILE ?? '',
42
- rootFolderPath: tmp.configs.rootFolderPath || 'x',
43
- projectName: tmp.project.name,
44
- serviceName: tmp.configs.service,
45
- projectNamePrefixEnv: process.env.PROJECT_NAME_PREFIX || '',
46
- projectNameEnv: process.env.PROJECT_NAME || '',
47
- projectNameSuffixEnv: process.env.PROJECT_NAME_SUFFIX || '',
48
- systemStaticFolderPath: path.resolve(tmp.configs.rootFolderPath, this.publicFolderName),
49
- systemLoggerLayer: process.env.SYSTEM_LOGGER_LAYER ?? 'info',
50
- isKafkaPassive: process.env.IS_KAFKA_PASSIVE === 'true' ? true : false,
51
- kafkaClientId: tmp.configs.service,
52
- kafkaBrokers: process.env.KAFKA_BROKERS ?? '',
53
- kafkaUsername: process.env.KAFKA_USERNAME ?? '',
54
- kafkaPassword: process.env.KAFKA_PASSWORD ?? '',
55
- kafkaTopics: [],
56
- kafkaLogsTopic: this.kafkaLogsTopic,
57
- baseApiUri: process.env.HTTPS === 'true' ? (process.env.SYSTEM_HTTPS_BASE_API_URI ?? '') : (process.env.SYSTEM_BASE_API_URI ?? ''),
58
- port: Number(process.env.PORT),
59
- internalSecret: process.env.INTERNAL_SECRET ?? '',
60
- secret: process.env.SECRET ?? '',
61
- cwd,
62
- env: process.env.NODE_ENV ?? 'development',
63
- };
64
- try {
65
- const moduleData = await modulePromise;
66
- const importedConfigs = moduleData?.default || moduleData?.configs || moduleData || {};
67
- const merged = mergeWith({}, this.#config, importedConfigs, (objValue, srcValue) => {
68
- if (isArray(objValue)) {
69
- return objValue.concat(srcValue);
70
- }
71
- });
72
- this.#config = Object.freeze(merged);
73
- }
74
- catch {
75
- this.#config = Object.freeze(this.#config);
76
- }
77
- };
78
- setConfig(newConfigs) {
79
- const mergedDObj = Object.assign(this.#config, newConfigs);
80
- this.#config = Object.freeze(mergedDObj);
81
- }
82
- _(key) {
83
- return this.#config[key];
84
- }
85
- get all() {
86
- return this.#config;
87
- }
88
- }
@@ -1,236 +0,0 @@
1
- import qs from 'qs';
2
- import Logger from '../../loader/logger';
3
- import System from '../../loader/system';
4
- import { bindLoaderTmpSync, getClientIp, getConfiguredProtocols, isRealtimeProtocol, LoggerLayerEnum, parseResponseMessage, ProtocolEnum, x, controllerContextStorage, getControllerCtx, runControllerStore, adapterBagFromRequest, isFetchRequest, toHandler, toRealtimeHandler, resolveCtrOptions, } from '../../utils';
5
- export { controllerContextStorage, getControllerCtx };
6
- export const runController = runControllerStore;
7
- function isRawResponse(value) {
8
- return value instanceof Response || value instanceof Blob || value instanceof Uint8Array || value instanceof ArrayBuffer;
9
- }
10
- function applyResultMeta(builder, obj) {
11
- if (!obj || typeof obj !== 'object')
12
- return;
13
- if (obj.statusCode !== undefined)
14
- return void builder.httpStatus(Number(obj.statusCode));
15
- if (obj.code !== undefined) {
16
- const code = Number(obj.code);
17
- if (code >= 100)
18
- builder.httpStatus(code);
19
- else
20
- builder.code(code);
21
- }
22
- }
23
- function extractPayload(obj) {
24
- if (!obj || typeof obj !== 'object')
25
- return { data: undefined, extraData: undefined, message: undefined };
26
- if (obj.payload && typeof obj.payload === 'object') {
27
- return { data: obj.payload.data !== undefined ? obj.payload.data : obj.payload, extraData: obj.payload.extraData, message: obj.message };
28
- }
29
- if (obj.data !== undefined || obj.extraData !== undefined)
30
- return { data: obj.data, extraData: obj.extraData, message: obj.message };
31
- const hasMeta = obj.status !== undefined || obj.message !== undefined || obj.code !== undefined || obj.statusCode !== undefined;
32
- if (!hasMeta && Object.keys(obj).length > 0)
33
- return { data: obj, extraData: undefined, message: obj.message };
34
- return { data: undefined, extraData: undefined, message: obj.message };
35
- }
36
- export function resolveBuilder(store) {
37
- const attached = store.ctx?.builder ?? store.res?.builder ?? store.socket?.builder;
38
- if (attached)
39
- return attached;
40
- throw new Error('[xrystal] use dtoMiddleware() — builder attaches at request start via @xrystal/dto adapter');
41
- }
42
- export class BaseController {
43
- system = x.get(System);
44
- logger = x.get(Logger);
45
- supportedProtocols = [ProtocolEnum.HTTP, ProtocolEnum.WEBSOCKET];
46
- get store() {
47
- return getControllerCtx();
48
- }
49
- get protocol() {
50
- return this.store?.protocol || ProtocolEnum.HTTP;
51
- }
52
- get req() {
53
- const store = this.store;
54
- const ctx = store?.ctx || {};
55
- const req = store?.req || {};
56
- const fetchRequest = isFetchRequest(ctx.request) ? ctx.request : undefined;
57
- const ctxReq = adapterBagFromRequest(ctx.request);
58
- const headerSource = ctx.headers ?? req.headers ?? fetchRequest?.headers ?? ctxReq?.headers;
59
- const headers = headerSource instanceof Headers
60
- ? Object.fromEntries(headerSource.entries())
61
- : (headerSource ?? {});
62
- const url = fetchRequest?.url ?? ctxReq?.url ?? req.url ?? ctx.url ?? "";
63
- let query = (store?.metadata?.parsedQuery || ctx.query || req.query || ctxReq?.query || {});
64
- if (!Object.keys(query).length && url.includes('?'))
65
- query = qs.parse(url.split('?')[1]);
66
- let cookies = (ctx.cookies || req.cookies || ctxReq?.cookies || {});
67
- if (!Object.keys(cookies).length && headers.cookie) {
68
- cookies = Object.fromEntries(headers.cookie.split(';').map((part) => {
69
- const [k, v] = part.trim().split('=');
70
- return [decodeURIComponent(k), decodeURIComponent(v || '')];
71
- }));
72
- }
73
- return {
74
- url,
75
- method: (ctx.method || req.method || fetchRequest?.method || ctxReq?.method || '').toUpperCase(),
76
- headers,
77
- body: store?.metadata?.parsedBody || ctx.body || req.body || ctxReq?.body || {},
78
- query,
79
- params: { ...req.params, ...ctx.params, ...ctxReq?.params, ...ctxReq?.routeParams },
80
- cookies,
81
- ip: getClientIp(req, ctx),
82
- lang: ctx.lang || req.lang || 'en',
83
- requestId: store?.requestId ?? ctx.requestId ?? req.ctx?.requestId ?? String(headers['x-request-id'] ?? headers['x-correlation-id'] ?? ''),
84
- startTime: (ctx.startTime ?? req.ctx?.startTime ?? Date.now()),
85
- t: ctx.t || req.t || ((k) => k),
86
- accounts: ctx.accounts || req.accounts || ctx.user,
87
- };
88
- }
89
- get res() {
90
- const store = this.store;
91
- if (!store)
92
- throw new Error('[xrystal] controller context missing');
93
- const locals = store.metadata?.locals ?? {};
94
- return { builder: resolveBuilder(store), locals: locals };
95
- }
96
- async parseRequestBody() {
97
- const store = this.store;
98
- if (!store)
99
- return;
100
- const ctxRequest = store.ctx?.request;
101
- const raw = store.req || ctxRequest || store.ctx?.req;
102
- const base = this.req;
103
- const type = (base.headers['content-type'] || '').toLowerCase();
104
- const length = parseInt(base.headers['content-length'] || '-1', 10);
105
- let body = base.body;
106
- const parse = (text) => {
107
- if (!text)
108
- return {};
109
- if (type.includes('application/json'))
110
- try {
111
- return JSON.parse(text);
112
- }
113
- catch {
114
- return text;
115
- }
116
- if (type.includes('application/x-www-form-urlencoded'))
117
- return qs.parse(text);
118
- try {
119
- return JSON.parse(text);
120
- }
121
- catch {
122
- try {
123
- return qs.parse(text);
124
- }
125
- catch {
126
- return text;
127
- }
128
- }
129
- };
130
- const isStream = (v) => v instanceof ReadableStream || typeof v?.getReader === 'function';
131
- const ready = body && typeof body === 'object' && !isStream(body) && Object.keys(body).length > 0;
132
- if (!isRealtimeProtocol(this.protocol) && !['GET', 'HEAD', 'OPTIONS'].includes(base.method) && !ready) {
133
- if (raw instanceof Request && (isStream(body) || length > 0)) {
134
- try {
135
- body = parse(await raw.clone().text());
136
- }
137
- catch {
138
- if (typeof body === 'string')
139
- body = parse(body);
140
- }
141
- }
142
- else if (raw && typeof raw === 'object' && 'on' in raw && typeof raw.on === 'function' && length !== 0) {
143
- const stream = raw;
144
- body = await new Promise((resolve) => {
145
- let text = '';
146
- const timer = setTimeout(() => resolve({}), 200);
147
- stream.on('data', (chunk) => { text += String(chunk); });
148
- stream.on('end', () => { clearTimeout(timer); resolve(parse(text)); });
149
- stream.on('error', () => { clearTimeout(timer); resolve({}); });
150
- });
151
- }
152
- else if (typeof body === 'string' && body.length) {
153
- body = parse(body);
154
- }
155
- }
156
- if (body?.constructor?.name === 'FormData')
157
- body = Object.fromEntries(body.entries());
158
- if (!store.metadata)
159
- store.metadata = { locals: {} };
160
- store.metadata.parsedBody = body || {};
161
- store.metadata.parsedQuery = base.query;
162
- }
163
- }
164
- export default class Controller extends BaseController {
165
- async onInit() {
166
- await this.syncFromTmp();
167
- bindLoaderTmpSync(this);
168
- }
169
- syncFromTmp = () => {
170
- this.supportedProtocols = getConfiguredProtocols();
171
- };
172
- parseMessage(msg, t, isError = false) {
173
- return parseResponseMessage(msg, t, isError);
174
- }
175
- args(builder) {
176
- const req = this.req;
177
- const locals = this.store.metadata?.locals ?? {};
178
- return { req, res: { builder, locals }, builder, body: req.body, query: req.query, queries: req.query, params: req.params, cookies: req.cookies, locals, t: req.t };
179
- }
180
- fail(builder, source, t) {
181
- applyResultMeta(builder, source);
182
- const { data, extraData } = extractPayload(source);
183
- const message = this.parseMessage(source?.message ?? source, t, true);
184
- const extras = data !== undefined || extraData !== undefined ? { data, extraData } : undefined;
185
- const terminal = data !== undefined ? builder.as.fail(data, message, extras) : builder.as.fail(message, extras);
186
- return terminal.build();
187
- }
188
- ok(builder, resResult, logicResult, t) {
189
- let message = 'success_process';
190
- let source = resResult !== undefined ? resResult : logicResult;
191
- if (typeof resResult === 'string') {
192
- message = resResult;
193
- source = logicResult;
194
- }
195
- const { data, extraData, message: custom } = extractPayload(source);
196
- if (custom)
197
- message = custom;
198
- applyResultMeta(builder, source);
199
- return builder.as.ok(data, this.parseMessage(message, t, false), extraData !== undefined ? { extraData } : undefined).build();
200
- }
201
- async schema({ checks, logic, response }) {
202
- const builder = resolveBuilder(this.store);
203
- try {
204
- await this.parseRequestBody();
205
- const args = this.args(builder);
206
- if (checks) {
207
- const check = await checks(args);
208
- if (check !== true)
209
- return this.fail(builder, check, args.req.t);
210
- }
211
- let result = logic ? await logic(args) : {};
212
- if (result?.response)
213
- result = await result.response();
214
- if (isRawResponse(result))
215
- return result;
216
- if (result?.status === false)
217
- return this.fail(builder, result, args.req.t);
218
- const out = response ? await response({ ...args, logicResult: result }) : result;
219
- if (isRawResponse(out))
220
- return out;
221
- return this.ok(builder, out, result, args.req.t);
222
- }
223
- catch (error) {
224
- this.logger?.log(LoggerLayerEnum.ERROR, `Controller Error: ${error.message}`);
225
- return builder.as.internalServerError(this.parseMessage(error.message, this.req.t, true)).build();
226
- }
227
- }
228
- ctr(definition, opts) {
229
- const { framework, protocol } = resolveCtrOptions(opts);
230
- const action = () => this.schema(definition);
231
- if (isRealtimeProtocol(protocol)) {
232
- return toRealtimeHandler(action, protocol);
233
- }
234
- return toHandler(action, framework);
235
- }
236
- }
@@ -1,92 +0,0 @@
1
- import { DTO } from '@xrystal/dto/dto';
2
- import { bindLoaderTmpSync } from '../../utils';
3
- import { FrameworkEnum, parseFramework } from '../../utils';
4
- export const DEFAULT_DTO_CONFIG = {
5
- withDefaultHeaders: true,
6
- };
7
- function mergeDtoConfig(base, patch) {
8
- return {
9
- ...base,
10
- ...patch,
11
- codes: patch.codes ? { ...base.codes, ...patch.codes } : base.codes,
12
- defaultHeaders: patch.defaultHeaders
13
- ? { ...base.defaultHeaders, ...patch.defaultHeaders }
14
- : base.defaultHeaders,
15
- socket: patch.socket ? { ...base.socket, ...patch.socket } : base.socket,
16
- hooks: patch.hooks ?? base.hooks,
17
- plugins: patch.plugins ? [...(base.plugins ?? []), ...patch.plugins] : base.plugins,
18
- };
19
- }
20
- export default class DtoRuntime {
21
- _runtime;
22
- _system;
23
- _config = { ...DEFAULT_DTO_CONFIG };
24
- _framework = FrameworkEnum.ELYSIA;
25
- _bootConfig = {};
26
- constructor({ system }) {
27
- this._system = system;
28
- }
29
- async onInit(props = {}) {
30
- this._bootConfig = props.config ?? {};
31
- await this.syncFromTmp();
32
- bindLoaderTmpSync(this);
33
- }
34
- syncFromTmp = async () => {
35
- this._framework = parseFramework(this._system?.tmp?.configs?.framework);
36
- this.applyConfig(DEFAULT_DTO_CONFIG, this._system?.tmp?.configs?.loaders?.dto ?? {}, this._bootConfig, { rebuild: true });
37
- };
38
- get instance() {
39
- return this._runtime;
40
- }
41
- get config() {
42
- return this._config;
43
- }
44
- get framework() {
45
- return this._framework;
46
- }
47
- configure(config = {}, options = {}) {
48
- this.applyConfig(this._config, config, options);
49
- return this;
50
- }
51
- use(...plugins) {
52
- this._runtime.use(...plugins);
53
- this._config = mergeDtoConfig(this._config, { plugins });
54
- return this;
55
- }
56
- express() {
57
- return this._runtime.express();
58
- }
59
- elysia() {
60
- return this._runtime.elysia();
61
- }
62
- node() {
63
- return this._runtime.node();
64
- }
65
- websocket() {
66
- return this._runtime.websocket();
67
- }
68
- socketIo() {
69
- return this._runtime.socketIo();
70
- }
71
- attachWebSocket(socket, requestId) {
72
- return this._runtime.attachWebSocket(socket, requestId);
73
- }
74
- attachSocketIo(socket) {
75
- return this._runtime.attachSocketIo(socket);
76
- }
77
- fetch() {
78
- return this._runtime.fetch();
79
- }
80
- forRequest(request) {
81
- return this._runtime.forRequest(request);
82
- }
83
- applyConfig(...sources) {
84
- const last = sources[sources.length - 1];
85
- const options = last && 'rebuild' in last ? sources.pop() : {};
86
- const merged = sources.reduce((acc, part) => mergeDtoConfig(acc, part), { ...DEFAULT_DTO_CONFIG });
87
- this._config = merged;
88
- if (!this._runtime || options.rebuild !== false) {
89
- this._runtime = new DTO(this._config);
90
- }
91
- }
92
- }
@@ -1,44 +0,0 @@
1
- import { LoggerLayerEnum, x } from '../../utils';
2
- export default class Events {
3
- #logger;
4
- constructor({ logger }) {
5
- this.#logger = logger;
6
- }
7
- onInit = ({}) => {
8
- this._globalLoader();
9
- this._DILoader();
10
- };
11
- _globalLoader = () => {
12
- process.on("uncaughtException", (error, origin) => {
13
- this.#logger.log({
14
- level: LoggerLayerEnum.CRITICAL,
15
- message: `Uncaught Exception: ${error.message}`,
16
- payload: {
17
- stack: error.stack,
18
- origin: origin
19
- }
20
- });
21
- });
22
- process.on("unhandledRejection", (reason, promise) => {
23
- const error = reason instanceof Error ? reason : new Error(String(reason));
24
- this.#logger.log({
25
- level: LoggerLayerEnum.CRITICAL,
26
- message: `Unhandled Rejection: ${error.message}`,
27
- payload: {
28
- stack: error.stack,
29
- }
30
- });
31
- });
32
- };
33
- _DILoader = () => {
34
- process.on('SIGTERM', () => {
35
- x.shutdown();
36
- });
37
- process.on('SIGINT', () => {
38
- x.shutdown();
39
- });
40
- };
41
- get global() {
42
- return this._globalLoader();
43
- }
44
- }
@@ -1,11 +0,0 @@
1
- import System from "../loader/system";
2
- import Configs from "../loader/configs";
3
- import KafkaForCore from "../loader/kafka";
4
- import Logger from "../loader/logger";
5
- import Events from "../loader/events";
6
- import Localizations from "../loader/localizations";
7
- import DtoRuntime from "../loader/dto";
8
- import Controller from "../loader/controller";
9
- import Service from "../loader/service";
10
- import Clients from "../loader/clients";
11
- export { System, Configs, Logger, Events, Localizations, DtoRuntime, Controller, Service, Clients, KafkaForCore };
@@ -1,11 +0,0 @@
1
- import System from "../loader/system";
2
- import Configs from "../loader/configs";
3
- import KafkaForCore from "../loader/kafka";
4
- import Logger from "../loader/logger";
5
- import Events from "../loader/events";
6
- import Localizations from "../loader/localizations";
7
- import DtoRuntime from "../loader/dto";
8
- import Controller from "../loader/controller";
9
- import Service from "../loader/service";
10
- import Clients from "../loader/clients";
11
- export { System, Configs, Logger, Events, Localizations, DtoRuntime, Controller, Service, Clients, KafkaForCore };