@mrxsys/mrx-core 2.11.0-2-and-276-20251029 → 2.11.0-3-and-276-20251029

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 (146) hide show
  1. package/dist/chunk-0d0zd2yg.js +8 -0
  2. package/dist/chunk-12qzn7jw.js +7 -0
  3. package/dist/chunk-441xs5k1.js +53 -0
  4. package/dist/chunk-4v86f7gp.js +59 -0
  5. package/dist/chunk-6w9ja96e.js +9 -0
  6. package/dist/chunk-7t524zqh.js +26 -0
  7. package/dist/chunk-8tffnbpn.js +7 -0
  8. package/dist/chunk-9cgzhc50.js +15 -0
  9. package/dist/chunk-9d3zvgp6.js +9 -0
  10. package/dist/chunk-9dzsj7f2.js +23 -0
  11. package/dist/chunk-9r5anep5.js +11 -0
  12. package/dist/chunk-afd82epa.js +201 -0
  13. package/dist/chunk-afyz8rg5.js +209 -0
  14. package/dist/chunk-dre2fgj0.js +7 -0
  15. package/dist/chunk-e30paw8a.js +101 -0
  16. package/dist/chunk-eeb7yskp.js +61 -0
  17. package/dist/chunk-fs3wm3p4.js +32 -0
  18. package/dist/chunk-grfyngq0.js +39 -0
  19. package/dist/chunk-gtn1kn0z.js +79 -0
  20. package/dist/chunk-jksb9ers.js +7 -0
  21. package/dist/chunk-m3grz32t.js +27 -0
  22. package/dist/chunk-mvrxngm7.js +41 -0
  23. package/dist/chunk-n0n14mf8.js +7 -0
  24. package/dist/chunk-p14h6jfs.js +365 -0
  25. package/dist/chunk-pjv1ekwr.js +284 -0
  26. package/dist/chunk-rz5p4j3p.js +13 -0
  27. package/dist/chunk-spnh9dzk.js +10 -0
  28. package/dist/chunk-sqts8vyk.js +60 -0
  29. package/dist/chunk-w7h898m3.js +14 -0
  30. package/dist/chunk-xhhj1gvj.js +9 -0
  31. package/dist/chunk-z0ct35ft.js +8 -0
  32. package/dist/errors/enums/index.js +7 -0
  33. package/dist/errors/index.js +12 -0
  34. package/dist/errors/utils/index.js +16 -0
  35. package/dist/errors/utils/is-nowarajs-error.ts.d.ts +2 -2
  36. package/dist/modules/data/enums/index.js +7 -0
  37. package/dist/modules/data/index.js +17 -0
  38. package/dist/modules/data/transformers/camel-case.d.ts +2 -2
  39. package/dist/modules/data/transformers/index.js +32 -0
  40. package/dist/modules/data/transformers/kebab-case.d.ts +2 -2
  41. package/dist/modules/data/transformers/pascal-case.d.ts +2 -2
  42. package/dist/modules/data/transformers/snake-case.d.ts +2 -2
  43. package/dist/modules/data/types/index.js +1 -0
  44. package/dist/modules/data/types/transform-object-keys.d.ts +4 -4
  45. package/dist/modules/database/enums/index.js +9 -0
  46. package/dist/modules/database/events/index.js +1 -0
  47. package/dist/modules/database/events/mssql-event-map.d.ts +1 -1
  48. package/dist/modules/database/events/table-event-map.d.ts +1 -1
  49. package/dist/modules/database/index.js +16 -0
  50. package/dist/modules/database/mssql.d.ts +2 -2
  51. package/dist/modules/database/table.d.ts +2 -2
  52. package/dist/modules/database/types/index.js +1 -0
  53. package/dist/modules/elysia/cache/cache.d.ts +1 -1
  54. package/dist/modules/elysia/cache/index.js +90 -0
  55. package/dist/modules/elysia/cache/types/index.js +1 -0
  56. package/dist/modules/elysia/crud/crud.d.ts +2 -2
  57. package/dist/modules/elysia/crud/enums/index.js +7 -0
  58. package/dist/modules/elysia/crud/index.js +153 -0
  59. package/dist/modules/elysia/crud/operations/count.d.ts +3 -3
  60. package/dist/modules/elysia/crud/operations/delete.d.ts +3 -3
  61. package/dist/modules/elysia/crud/operations/deleteOne.d.ts +3 -3
  62. package/dist/modules/elysia/crud/operations/find.d.ts +3 -3
  63. package/dist/modules/elysia/crud/operations/findOne.d.ts +3 -3
  64. package/dist/modules/elysia/crud/operations/index.js +34 -0
  65. package/dist/modules/elysia/crud/operations/insert.d.ts +3 -3
  66. package/dist/modules/elysia/crud/operations/update.d.ts +3 -3
  67. package/dist/modules/elysia/crud/operations/updateOne.d.ts +3 -3
  68. package/dist/modules/elysia/crud/operations/utils/get-db-injection.d.ts +1 -1
  69. package/dist/modules/elysia/crud/types/crud-options.d.ts +1 -1
  70. package/dist/modules/elysia/crud/types/crud-schema-models-type.d.ts +9 -9
  71. package/dist/modules/elysia/crud/types/delete-schema.d.ts +2 -2
  72. package/dist/modules/elysia/crud/types/find-schema.d.ts +3 -3
  73. package/dist/modules/elysia/crud/types/index.js +1 -0
  74. package/dist/modules/elysia/crud/types/insert-schema.d.ts +1 -1
  75. package/dist/modules/elysia/crud/types/properties-schema.d.ts +1 -1
  76. package/dist/modules/elysia/crud/types/response-200-schema.d.ts +1 -1
  77. package/dist/modules/elysia/crud/types/update-schema.d.ts +2 -2
  78. package/dist/modules/elysia/crud/utils/create-adaptive-where-clause-schema.d.ts +1 -1
  79. package/dist/modules/elysia/crud/utils/create-count-response-200-schema.d.ts +1 -1
  80. package/dist/modules/elysia/crud/utils/create-count-schema.d.ts +1 -1
  81. package/dist/modules/elysia/crud/utils/create-delete-schema.d.ts +1 -1
  82. package/dist/modules/elysia/crud/utils/create-filters-schema.d.ts +1 -1
  83. package/dist/modules/elysia/crud/utils/create-find-schema.d.ts +1 -1
  84. package/dist/modules/elysia/crud/utils/create-id-param-schema.d.ts +1 -1
  85. package/dist/modules/elysia/crud/utils/create-insert-schema.d.ts +1 -1
  86. package/dist/modules/elysia/crud/utils/create-order-schema.d.ts +1 -1
  87. package/dist/modules/elysia/crud/utils/create-properties-schema.d.ts +1 -1
  88. package/dist/modules/elysia/crud/utils/create-q-schema.d.ts +1 -1
  89. package/dist/modules/elysia/crud/utils/create-response-200-schema.d.ts +1 -1
  90. package/dist/modules/elysia/crud/utils/create-selected-fields-schema.d.ts +1 -1
  91. package/dist/modules/elysia/crud/utils/create-update-one-schema.d.ts +1 -1
  92. package/dist/modules/elysia/crud/utils/create-update-schema.d.ts +1 -1
  93. package/dist/modules/elysia/crud/utils/index.js +41 -0
  94. package/dist/modules/elysia/db-resolver/db-resolver.d.ts +2 -2
  95. package/dist/modules/elysia/db-resolver/enums/index.js +7 -0
  96. package/dist/modules/elysia/db-resolver/index.js +18 -0
  97. package/dist/modules/elysia/error/enums/index.js +7 -0
  98. package/dist/modules/elysia/error/error.d.ts +51 -0
  99. package/dist/modules/elysia/error/index.js +76 -0
  100. package/dist/modules/elysia/microservice/enums/index.js +7 -0
  101. package/dist/modules/elysia/microservice/index.js +100 -0
  102. package/dist/modules/elysia/rate-limit/enums/index.js +7 -0
  103. package/dist/modules/elysia/rate-limit/index.js +81 -0
  104. package/dist/modules/elysia/rate-limit/rate-limit.d.ts +1 -1
  105. package/dist/modules/elysia/rate-limit/types/index.js +1 -0
  106. package/dist/modules/jwt/enums/index.js +11 -0
  107. package/dist/modules/jwt/index.js +51 -0
  108. package/dist/modules/jwt/utils/index.js +9 -0
  109. package/dist/modules/kv-store/bun-redis/bun-redis-store.d.ts +1 -1
  110. package/dist/modules/kv-store/bun-redis/index.js +84 -0
  111. package/dist/modules/kv-store/enums/index.js +7 -0
  112. package/dist/modules/kv-store/ioredis/index.js +86 -0
  113. package/dist/modules/kv-store/ioredis/ioredis-store.d.ts +1 -1
  114. package/dist/modules/kv-store/memory/index.js +9 -0
  115. package/dist/modules/kv-store/memory/memory-store.d.ts +1 -1
  116. package/dist/modules/kv-store/types/index.js +1 -0
  117. package/dist/modules/logger/enums/index.js +7 -0
  118. package/dist/modules/logger/events/index.js +1 -0
  119. package/dist/modules/logger/events/logger-events.d.ts +1 -1
  120. package/dist/modules/logger/index.js +208 -0
  121. package/dist/modules/logger/logger.d.ts +1 -1
  122. package/dist/modules/logger/sinks/console-logger.d.ts +2 -2
  123. package/dist/modules/logger/sinks/devnull-logger.d.ts +1 -1
  124. package/dist/modules/logger/sinks/file-logger/file-logger.d.ts +2 -2
  125. package/dist/modules/logger/sinks/index.js +66 -0
  126. package/dist/modules/logger/types/index.js +1 -0
  127. package/dist/modules/mailer/enums/index.js +7 -0
  128. package/dist/modules/mailer/index.js +55 -0
  129. package/dist/modules/mailer/types/index.js +1 -0
  130. package/dist/modules/repository/index.js +12 -0
  131. package/dist/modules/repository/repository.d.ts +2 -2
  132. package/dist/modules/repository/types/index.js +1 -0
  133. package/dist/modules/repository/types/query-options.d.ts +1 -1
  134. package/dist/modules/singleton-manager/enums/index.js +7 -0
  135. package/dist/modules/singleton-manager/index.js +9 -0
  136. package/dist/modules/totp/enums/index.js +7 -0
  137. package/dist/modules/totp/index.js +104 -0
  138. package/dist/modules/totp/types/index.js +1 -0
  139. package/dist/modules/totp/utils/index.js +76 -0
  140. package/dist/modules/typed-event-emitter/index.js +7 -0
  141. package/dist/modules/typed-event-emitter/types/index.js +1 -0
  142. package/dist/shared/enums/index.js +7 -0
  143. package/dist/shared/types/index.js +1 -0
  144. package/dist/shared/utils/flatten.d.ts +1 -1
  145. package/dist/shared/utils/index.js +30 -0
  146. package/package.json +1 -1
@@ -0,0 +1,208 @@
1
+ // @bun
2
+ import {
3
+ LOGGER_ERROR_KEYS
4
+ } from "../../chunk-rz5p4j3p.js";
5
+ import {
6
+ TypedEventEmitter
7
+ } from "../../chunk-mvrxngm7.js";
8
+ import {
9
+ BaseError
10
+ } from "../../chunk-9cgzhc50.js";
11
+
12
+ // source/modules/logger/logger.ts
13
+ class Logger extends TypedEventEmitter {
14
+ _sinks;
15
+ _sinkKeys = [];
16
+ _worker;
17
+ _maxPendingLogs;
18
+ _maxMessagesInFlight;
19
+ _batchSize;
20
+ _batchTimeout;
21
+ _autoEnd;
22
+ _flushOnBeforeExit;
23
+ _pendingLogs = [];
24
+ _messagesInFlight = 0;
25
+ _batchTimer = null;
26
+ _isWriting = false;
27
+ _flushResolvers = [];
28
+ _closeResolver = null;
29
+ _backpressureResolver = null;
30
+ _handleExit = () => {
31
+ this._worker.terminate();
32
+ };
33
+ _handleWorkerClose = () => {
34
+ process.off("beforeExit", this._handleBeforeExit);
35
+ process.off("exit", this._handleExit);
36
+ };
37
+ constructor(options) {
38
+ super();
39
+ const {
40
+ autoEnd = true,
41
+ batchSize = 50,
42
+ batchTimeout = 0.1,
43
+ flushOnBeforeExit = true,
44
+ maxMessagesInFlight = 100,
45
+ maxPendingLogs = 1e4
46
+ } = options ?? {};
47
+ this._sinks = {};
48
+ this._maxPendingLogs = maxPendingLogs;
49
+ this._maxMessagesInFlight = maxMessagesInFlight;
50
+ this._batchSize = batchSize;
51
+ this._batchTimeout = batchTimeout;
52
+ this._autoEnd = autoEnd;
53
+ this._flushOnBeforeExit = flushOnBeforeExit;
54
+ this._worker = new Worker(new URL("worker-logger.ts", import.meta.url).href, { type: "module" });
55
+ this._setupWorkerMessages();
56
+ if (this._autoEnd)
57
+ this._setupAutoEnd();
58
+ }
59
+ registerSink(sinkName, sinkConstructor, ...sinkArgs) {
60
+ if (this._sinks[sinkName])
61
+ throw new BaseError(LOGGER_ERROR_KEYS.SINK_ALREADY_ADDED);
62
+ this._worker.postMessage({
63
+ type: "REGISTER_SINK",
64
+ sinkName,
65
+ sinkClassName: sinkConstructor.name,
66
+ sinkClassString: sinkConstructor.toString(),
67
+ sinkArgs
68
+ });
69
+ this._sinks[sinkName] = sinkConstructor;
70
+ this._sinkKeys.push(sinkName);
71
+ return this;
72
+ }
73
+ error(object, sinkNames = this._sinkKeys) {
74
+ this._enqueue("ERROR", object, sinkNames);
75
+ }
76
+ warn(object, sinkNames = this._sinkKeys) {
77
+ this._enqueue("WARN", object, sinkNames);
78
+ }
79
+ info(object, sinkNames = this._sinkKeys) {
80
+ this._enqueue("INFO", object, sinkNames);
81
+ }
82
+ debug(object, sinkNames = this._sinkKeys) {
83
+ this._enqueue("DEBUG", object, sinkNames);
84
+ }
85
+ log(object, sinkNames = this._sinkKeys) {
86
+ this._enqueue("LOG", object, sinkNames);
87
+ }
88
+ async flush() {
89
+ if (this._pendingLogs.length === 0 && this._messagesInFlight === 0)
90
+ return;
91
+ return new Promise((resolve) => {
92
+ this._flushResolvers.push(resolve);
93
+ if (!this._isWriting && this._pendingLogs.length > 0) {
94
+ this._isWriting = true;
95
+ this._processPendingLogs();
96
+ }
97
+ });
98
+ }
99
+ async close() {
100
+ await this.flush();
101
+ return new Promise((resolve) => {
102
+ this._closeResolver = resolve;
103
+ this._worker.postMessage({ type: "CLOSE" });
104
+ });
105
+ }
106
+ _enqueue(level, object, sinkNames) {
107
+ if (this._sinkKeys.length === 0)
108
+ throw new BaseError(LOGGER_ERROR_KEYS.NO_SINKS_PROVIDED, { level, object });
109
+ if (this._pendingLogs.length >= this._maxPendingLogs)
110
+ return;
111
+ this._pendingLogs.push({
112
+ sinkNames: sinkNames ?? this._sinkKeys,
113
+ level,
114
+ timestamp: Date.now(),
115
+ object
116
+ });
117
+ if (this._pendingLogs.length >= this._batchSize) {
118
+ if (this._batchTimer !== null) {
119
+ clearTimeout(this._batchTimer);
120
+ this._batchTimer = null;
121
+ }
122
+ this._triggerProcessing();
123
+ } else if (this._batchTimeout > 0 && this._batchTimer === null) {
124
+ this._batchTimer = setTimeout(() => {
125
+ this._batchTimer = null;
126
+ this._triggerProcessing();
127
+ }, this._batchTimeout);
128
+ }
129
+ }
130
+ _triggerProcessing() {
131
+ if (this._isWriting)
132
+ return;
133
+ this._isWriting = true;
134
+ this._processPendingLogs();
135
+ }
136
+ async _processPendingLogs() {
137
+ while (this._pendingLogs.length > 0) {
138
+ if (this._messagesInFlight >= this._maxMessagesInFlight)
139
+ await new Promise((resolve) => {
140
+ this._backpressureResolver = resolve;
141
+ });
142
+ const batch = this._pendingLogs.splice(0, this._batchSize);
143
+ this._messagesInFlight++;
144
+ this._worker.postMessage({
145
+ type: "LOG_BATCH",
146
+ logs: batch
147
+ });
148
+ }
149
+ this._isWriting = false;
150
+ this.emit("drained");
151
+ }
152
+ _releaseBatch() {
153
+ this._messagesInFlight--;
154
+ if (this._backpressureResolver !== null) {
155
+ this._backpressureResolver();
156
+ this._backpressureResolver = null;
157
+ }
158
+ }
159
+ _setupWorkerMessages() {
160
+ this._worker.addEventListener("message", (event) => {
161
+ switch (event.data.type) {
162
+ case "BATCH_COMPLETE":
163
+ this._releaseBatch();
164
+ if (this._messagesInFlight === 0 && this._pendingLogs.length === 0 && this._flushResolvers.length > 0) {
165
+ for (const resolve of this._flushResolvers)
166
+ resolve();
167
+ this._flushResolvers.length = 0;
168
+ }
169
+ break;
170
+ case "SINK_LOG_ERROR":
171
+ this.emit("sinkError", new BaseError(LOGGER_ERROR_KEYS.SINK_LOG_ERROR, event.data));
172
+ this._releaseBatch();
173
+ break;
174
+ case "SINK_CLOSE_ERROR":
175
+ this.emit("sinkError", new BaseError(LOGGER_ERROR_KEYS.SINK_CLOSE_ERROR, event.data));
176
+ break;
177
+ case "REGISTER_SINK_ERROR":
178
+ this.emit("registerSinkError", new BaseError(LOGGER_ERROR_KEYS.REGISTER_SINK_ERROR, event.data));
179
+ break;
180
+ case "CLOSE_COMPLETE":
181
+ this._worker.terminate();
182
+ if (this._closeResolver) {
183
+ this._closeResolver();
184
+ this._closeResolver = null;
185
+ }
186
+ break;
187
+ }
188
+ });
189
+ }
190
+ _setupAutoEnd() {
191
+ process.on("beforeExit", this._handleBeforeExit);
192
+ process.on("exit", this._handleExit);
193
+ this._worker.addEventListener("close", this._handleWorkerClose);
194
+ }
195
+ _handleBeforeExit = () => {
196
+ if (this._flushOnBeforeExit)
197
+ this.flush().then(() => this.close()).catch((error) => {
198
+ this.emit("onBeforeExitError", new BaseError(LOGGER_ERROR_KEYS.BEFORE_EXIT_FLUSH_ERROR, { error }));
199
+ });
200
+ else
201
+ this.close().catch((error) => {
202
+ this.emit("onBeforeExitError", new BaseError(LOGGER_ERROR_KEYS.BEFORE_EXIT_CLOSE_ERROR, { error }));
203
+ });
204
+ };
205
+ }
206
+ export {
207
+ Logger
208
+ };
@@ -1,4 +1,4 @@
1
- import { TypedEventEmitter } from '#/modules/typed-event-emitter/typed-event-emitter';
1
+ import { TypedEventEmitter } from '../../modules/typed-event-emitter/typed-event-emitter';
2
2
  import type { LoggerEvent } from './events/logger-events';
3
3
  import type { LoggerOptions } from './types/logger-options';
4
4
  import type { LoggerSink } from './types/logger-sink';
@@ -1,5 +1,5 @@
1
- import type { LogLevels } from '#/modules/logger/types/log-levels';
2
- import type { LoggerSink } from '#/modules/logger/types/logger-sink';
1
+ import type { LogLevels } from '../../../modules/logger/types/log-levels';
2
+ import type { LoggerSink } from '../../../modules/logger/types/logger-sink';
3
3
  /**
4
4
  * ConsoleLoggerSink implements LoggerSink to provide logging functionality to the console.
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { LoggerSink } from '#/modules/logger/types/logger-sink';
1
+ import type { LoggerSink } from '../../../modules/logger/types/logger-sink';
2
2
  /**
3
3
  * DevNullLoggerSink implements LoggerSink to discard all logs (like /dev/null).
4
4
  * Useful for benchmarking the logger overhead without I/O.
@@ -1,5 +1,5 @@
1
- import type { LogLevels } from '#/modules/logger/types/log-levels';
2
- import type { LoggerSink } from '#/modules/logger/types/logger-sink';
1
+ import type { LogLevels } from '../../../../modules/logger/types/log-levels';
2
+ import type { LoggerSink } from '../../../../modules/logger/types/logger-sink';
3
3
  export interface FileLoggerConfig {
4
4
  /**
5
5
  * Path to the file to log to.
@@ -0,0 +1,66 @@
1
+ // @bun
2
+ import {
3
+ BaseError
4
+ } from "../../../chunk-9cgzhc50.js";
5
+
6
+ // source/modules/logger/sinks/console-logger.ts
7
+ class ConsoleLoggerSink {
8
+ async log(level, timestamp, object) {
9
+ const logEntry = { timestamp, level, content: object };
10
+ await Bun.write(Bun.stdout, JSON.stringify(logEntry) + `
11
+ `);
12
+ }
13
+ }
14
+ // source/modules/logger/sinks/devnull-logger.ts
15
+ class DevNullLoggerSink {
16
+ log() {}
17
+ }
18
+ // source/modules/logger/sinks/file-logger/enums/file-logger-error-keys.ts
19
+ var FILE_LOGGER_ERROR_KEYS = {
20
+ FAILED_TO_CLOSE_STREAM: "mrx-core.file_logger.error.failed_to_close_stream"
21
+ };
22
+ // source/modules/logger/sinks/file-logger/file-logger.ts
23
+ import { createWriteStream } from "fs";
24
+ class FileLoggerSink {
25
+ config;
26
+ _stream;
27
+ _isClosed = false;
28
+ constructor(config) {
29
+ this.config = config;
30
+ this._stream = createWriteStream(config.path, {
31
+ flags: "a",
32
+ encoding: "utf8",
33
+ highWaterMark: config.bufferSize ?? 16 * 1024
34
+ });
35
+ }
36
+ async log(level, timestamp, object) {
37
+ if (this._isClosed)
38
+ return;
39
+ const logEntry = JSON.stringify({ timestamp, level, content: object }) + `
40
+ `;
41
+ const canContinue = this._stream.write(logEntry);
42
+ if (!canContinue)
43
+ await new Promise((resolve) => {
44
+ this._stream.once("drain", resolve);
45
+ });
46
+ }
47
+ async close() {
48
+ if (this._isClosed)
49
+ return;
50
+ this._isClosed = true;
51
+ return new Promise((resolve, reject) => {
52
+ this._stream.end((err) => {
53
+ if (err)
54
+ reject(new BaseError(FILE_LOGGER_ERROR_KEYS.FAILED_TO_CLOSE_STREAM, err.message));
55
+ else
56
+ resolve();
57
+ });
58
+ });
59
+ }
60
+ }
61
+ export {
62
+ FileLoggerSink,
63
+ FILE_LOGGER_ERROR_KEYS,
64
+ DevNullLoggerSink,
65
+ ConsoleLoggerSink
66
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import {
3
+ MAILER_ERROR_KEYS
4
+ } from "../../../chunk-6w9ja96e.js";
5
+ export {
6
+ MAILER_ERROR_KEYS
7
+ };
@@ -0,0 +1,55 @@
1
+ // @bun
2
+ import {
3
+ MAILER_ERROR_KEYS
4
+ } from "../../chunk-6w9ja96e.js";
5
+ import {
6
+ BaseError
7
+ } from "../../chunk-9cgzhc50.js";
8
+
9
+ // source/modules/mailer/smtp.ts
10
+ import { createTransport } from "nodemailer";
11
+ class SMTP {
12
+ _config;
13
+ _transporter = null;
14
+ constructor(config) {
15
+ this._config = {
16
+ port: 587,
17
+ secure: false,
18
+ ...config
19
+ };
20
+ }
21
+ async connect() {
22
+ if (this._transporter)
23
+ throw new BaseError(MAILER_ERROR_KEYS.SMTP_ALREADY_CONNECTED);
24
+ this._transporter = createTransport({
25
+ host: this._config.host,
26
+ port: this._config.port,
27
+ secure: this._config.secure,
28
+ auth: {
29
+ user: this._config.credentials.user,
30
+ pass: this._config.credentials.pass
31
+ },
32
+ pool: true,
33
+ maxConnections: this._config.pool?.maxConnections ?? 5
34
+ });
35
+ try {
36
+ await this._transporter.verify();
37
+ } catch (error) {
38
+ throw new BaseError(MAILER_ERROR_KEYS.SMTP_CONNECTION_ERROR, error);
39
+ }
40
+ }
41
+ disconnect() {
42
+ if (this._transporter) {
43
+ this._transporter.close();
44
+ this._transporter = null;
45
+ }
46
+ }
47
+ async sendMail(options) {
48
+ if (!this._transporter)
49
+ throw new BaseError(MAILER_ERROR_KEYS.SMTP_NOT_CONNECTED);
50
+ return this._transporter.sendMail(options);
51
+ }
52
+ }
53
+ export {
54
+ SMTP
55
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,12 @@
1
+ // @bun
2
+ import {
3
+ Repository
4
+ } from "../../chunk-afyz8rg5.js";
5
+ import"../../chunk-grfyngq0.js";
6
+ import"../../chunk-4v86f7gp.js";
7
+ import"../../chunk-7t524zqh.js";
8
+ import"../../chunk-sqts8vyk.js";
9
+ import"../../chunk-9cgzhc50.js";
10
+ export {
11
+ Repository
12
+ };
@@ -1,6 +1,6 @@
1
1
  import type { Knex } from 'knex';
2
- import type { Table } from '#/modules/database/table';
3
- import type { StreamWithAsyncIterable } from '#/shared/types/stream-with-async-iterable';
2
+ import type { Table } from '../../modules/database/table';
3
+ import type { StreamWithAsyncIterable } from '../../shared/types/stream-with-async-iterable';
4
4
  import type { Filter } from './types/filter';
5
5
  import type { OrderByItem } from './types/order-by-item';
6
6
  import type { QueryOptions } from './types/query-options';
@@ -0,0 +1 @@
1
+ // @bun
@@ -1,4 +1,4 @@
1
- import type { HTTP_STATUS_CODES } from '#/errors/enums/http-status-codes';
1
+ import type { HTTP_STATUS_CODES } from '../../../errors/enums/http-status-codes';
2
2
  import type { Filter } from './filter';
3
3
  import type { OrderByItem } from './order-by-item';
4
4
  import type { SelectedFields } from './selected-fields';
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import {
3
+ SINGLETON_MANAGER_ERROR_KEYS
4
+ } from "../../../chunk-z0ct35ft.js";
5
+ export {
6
+ SINGLETON_MANAGER_ERROR_KEYS
7
+ };
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import {
3
+ SingletonManager
4
+ } from "../../chunk-fs3wm3p4.js";
5
+ import"../../chunk-z0ct35ft.js";
6
+ import"../../chunk-9cgzhc50.js";
7
+ export {
8
+ SingletonManager
9
+ };
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import {
3
+ TOTP_ERROR_KEYS
4
+ } from "../../../chunk-9r5anep5.js";
5
+ export {
6
+ TOTP_ERROR_KEYS
7
+ };
@@ -0,0 +1,104 @@
1
+ // @bun
2
+ import {
3
+ createCounterBuffer,
4
+ dynamicTruncation,
5
+ generateHmac
6
+ } from "../../chunk-m3grz32t.js";
7
+ import {
8
+ TOTP_ERROR_KEYS
9
+ } from "../../chunk-9r5anep5.js";
10
+ import {
11
+ BaseError
12
+ } from "../../chunk-9cgzhc50.js";
13
+
14
+ // source/modules/totp/hotp.ts
15
+ import { webcrypto } from "crypto";
16
+ var hotp = async (secret, counter, {
17
+ algorithm = "SHA-1",
18
+ digits = 6
19
+ } = {}) => {
20
+ const counterBuffer = createCounterBuffer(counter);
21
+ const key = await webcrypto.subtle.importKey("raw", secret, { name: "HMAC", hash: algorithm }, false, ["sign"]);
22
+ const hmacArray = await generateHmac(key, counterBuffer);
23
+ return dynamicTruncation(hmacArray, digits);
24
+ };
25
+ // source/modules/totp/otp-auth-uri.ts
26
+ var buildOtpAuthUri = ({
27
+ secretBase32,
28
+ label,
29
+ issuer,
30
+ algorithm = "SHA-1",
31
+ digits = 6,
32
+ period = 30
33
+ }) => {
34
+ const encodedLabel = encodeURIComponent(label);
35
+ const encodedIssuer = issuer ? encodeURIComponent(issuer) : undefined;
36
+ let uri = `otpauth://totp/${encodedLabel}?secret=${secretBase32}`;
37
+ if (encodedIssuer)
38
+ uri += `&issuer=${encodedIssuer}`;
39
+ if (algorithm !== "SHA-1")
40
+ uri += `&algorithm=${algorithm}`;
41
+ if (digits !== 6)
42
+ uri += `&digits=${digits}`;
43
+ if (period !== 30)
44
+ uri += `&period=${period}`;
45
+ return uri;
46
+ };
47
+ var parseOtpAuthUri = (uri) => {
48
+ const url = new URL(uri);
49
+ if (url.protocol !== "otpauth:")
50
+ throw new BaseError(TOTP_ERROR_KEYS.INVALID_OTP_AUTH_URI);
51
+ if (url.hostname !== "totp")
52
+ throw new BaseError(TOTP_ERROR_KEYS.INVALID_OTP_AUTH_URI);
53
+ const label = decodeURIComponent(url.pathname.slice(1));
54
+ const secretBase32 = url.searchParams.get("secret");
55
+ if (!secretBase32)
56
+ throw new BaseError(TOTP_ERROR_KEYS.MISSING_SECRET);
57
+ const issuerParam = url.searchParams.get("issuer");
58
+ const issuer = issuerParam ? decodeURIComponent(issuerParam) : undefined;
59
+ const algorithm = url.searchParams.get("algorithm") || "SHA-1";
60
+ const digits = parseInt(url.searchParams.get("digits") || "6", 10);
61
+ const period = parseInt(url.searchParams.get("period") || "30", 10);
62
+ const result = {
63
+ secretBase32,
64
+ label,
65
+ algorithm,
66
+ digits,
67
+ period,
68
+ ...issuer && { issuer }
69
+ };
70
+ return result;
71
+ };
72
+ // source/modules/totp/totp.ts
73
+ var totp = async (secret, {
74
+ algorithm = "SHA-1",
75
+ digits = 6,
76
+ period = 30,
77
+ now = Date.now()
78
+ } = {}) => {
79
+ const timeStep = Math.floor(now / 1000 / period);
80
+ return hotp(secret, timeStep, { algorithm, digits });
81
+ };
82
+ var verifyTotp = async (secret, code, {
83
+ algorithm = "SHA-1",
84
+ digits = 6,
85
+ period = 30,
86
+ window = 0,
87
+ now = Date.now()
88
+ } = {}) => {
89
+ const currentTimeStep = Math.floor(now / 1000 / period);
90
+ for (let i = -window;i <= window; ++i) {
91
+ const timeStep = currentTimeStep + i;
92
+ const expectedCode = await hotp(secret, timeStep, { algorithm, digits });
93
+ if (expectedCode === code)
94
+ return true;
95
+ }
96
+ return false;
97
+ };
98
+ export {
99
+ verifyTotp,
100
+ totp,
101
+ parseOtpAuthUri,
102
+ hotp,
103
+ buildOtpAuthUri
104
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,76 @@
1
+ // @bun
2
+ import {
3
+ createCounterBuffer,
4
+ dynamicTruncation,
5
+ generateHmac
6
+ } from "../../../chunk-m3grz32t.js";
7
+ import {
8
+ TOTP_ERROR_KEYS
9
+ } from "../../../chunk-9r5anep5.js";
10
+ import {
11
+ BaseError
12
+ } from "../../../chunk-9cgzhc50.js";
13
+
14
+ // source/modules/totp/utils/base32.ts
15
+ var BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
16
+ var base32Encode = (input, withPadding = true) => {
17
+ let result = "";
18
+ let bits = 0;
19
+ let value = 0;
20
+ const bytes = input instanceof Uint8Array ? input : new TextEncoder().encode(input);
21
+ for (const byte of bytes) {
22
+ value = value << 8 | byte;
23
+ bits += 8;
24
+ while (bits >= 5) {
25
+ result += BASE32_ALPHABET[value >>> bits - 5 & 31];
26
+ bits -= 5;
27
+ }
28
+ }
29
+ if (bits > 0)
30
+ result += BASE32_ALPHABET[value << 5 - bits & 31];
31
+ if (withPadding)
32
+ while (result.length % 8 !== 0)
33
+ result += "=";
34
+ return result;
35
+ };
36
+ var base32Decode = (base32) => {
37
+ const cleanBase32 = base32.replace(/=+$/, "");
38
+ if (cleanBase32.length === 0)
39
+ return new Uint8Array(0);
40
+ const result = [];
41
+ let bits = 0;
42
+ let value = 0;
43
+ for (const char of cleanBase32) {
44
+ const charValue = BASE32_ALPHABET.indexOf(char);
45
+ if (charValue === -1)
46
+ throw new BaseError(TOTP_ERROR_KEYS.INVALID_BASE32_CHARACTER, `Invalid Base32 character: ${char}`);
47
+ value = value << 5 | charValue;
48
+ bits += 5;
49
+ if (bits >= 8) {
50
+ result.push(value >>> bits - 8 & 255);
51
+ bits -= 8;
52
+ }
53
+ }
54
+ return new Uint8Array(result);
55
+ };
56
+ // source/modules/totp/utils/generate-secret-bytes.ts
57
+ import { getRandomValues } from "crypto";
58
+ var generateSecretBytes = (length = 20) => {
59
+ if (length <= 0)
60
+ throw new BaseError(TOTP_ERROR_KEYS.INVALID_SECRET_LENGTH);
61
+ return getRandomValues(new Uint8Array(length));
62
+ };
63
+ // source/modules/totp/utils/time-remaining.ts
64
+ var timeRemaining = (period = 30, now = Date.now()) => {
65
+ const elapsed = Math.floor(now / 1000) % period;
66
+ return period - elapsed;
67
+ };
68
+ export {
69
+ timeRemaining,
70
+ generateSecretBytes,
71
+ generateHmac,
72
+ dynamicTruncation,
73
+ createCounterBuffer,
74
+ base32Encode,
75
+ base32Decode
76
+ };
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import {
3
+ TypedEventEmitter
4
+ } from "../../chunk-mvrxngm7.js";
5
+ export {
6
+ TypedEventEmitter
7
+ };
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import {
3
+ UTILS_ERROR_KEYS
4
+ } from "../../chunk-n0n14mf8.js";
5
+ export {
6
+ UTILS_ERROR_KEYS
7
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -1,3 +1,3 @@
1
1
  import type { TSchema } from '@sinclair/typebox/type';
2
- import type { TFlatten } from '#/shared/types/tflatten';
2
+ import type { TFlatten } from '../../shared/types/tflatten';
3
3
  export declare const flatten: <Type extends TSchema>(type: Type) => TFlatten<Type>;
@@ -0,0 +1,30 @@
1
+ // @bun
2
+ import {
3
+ UTILS_ERROR_KEYS
4
+ } from "../../chunk-n0n14mf8.js";
5
+ import {
6
+ flatten
7
+ } from "../../chunk-9dzsj7f2.js";
8
+ import {
9
+ isDateString,
10
+ makeStreamAsyncIterable
11
+ } from "../../chunk-grfyngq0.js";
12
+ import {
13
+ BaseError
14
+ } from "../../chunk-9cgzhc50.js";
15
+
16
+ // source/shared/utils/env.ts
17
+ import { Value } from "@sinclair/typebox/value";
18
+ var validateEnv = (schema, env = process.env) => {
19
+ try {
20
+ Value.Assert(schema, Value.Parse(schema, env));
21
+ } catch (error) {
22
+ throw new BaseError(UTILS_ERROR_KEYS.INVALID_ENVIRONMENT, error);
23
+ }
24
+ };
25
+ export {
26
+ validateEnv,
27
+ makeStreamAsyncIterable,
28
+ isDateString,
29
+ flatten
30
+ };