@mrxsys/mrx-core 2.11.1-1-and-275-20251023 → 2.12.0-1-and-289-20251215
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.
- package/CHANGELOG.md +0 -0
- package/dist/{chunk-0d0zd2yg.js → chunk-037vwvd4.js} +2 -2
- package/dist/{chunk-jksb9ers.js → chunk-10w8mg8e.js} +1 -1
- package/dist/{chunk-dre2fgj0.js → chunk-2z8amjqt.js} +1 -1
- package/dist/{chunk-afyz8rg5.js → chunk-47yta3gd.js} +34 -22
- package/dist/chunk-4t7sy5qt.js +10 -0
- package/dist/chunk-642xajvx.js +59 -0
- package/dist/chunk-6hs00zfd.js +13 -0
- package/dist/chunk-8pw0syzf.js +9 -0
- package/dist/{chunk-eeb7yskp.js → chunk-awphtyzp.js} +4 -4
- package/dist/{chunk-8tffnbpn.js → chunk-ayyrgqyv.js} +1 -1
- package/dist/{chunk-12qzn7jw.js → chunk-dmsev7vs.js} +1 -1
- package/dist/{chunk-afd82epa.js → chunk-hnds0krm.js} +13 -13
- package/dist/{chunk-gtn1kn0z.js → chunk-hv6g22kf.js} +4 -4
- package/dist/chunk-hwfebx4x.js +11 -0
- package/dist/chunk-j7dyc5ks.js +101 -0
- package/dist/chunk-jz3wd472.js +23 -0
- package/dist/{chunk-fs3wm3p4.js → chunk-r7yr9p57.js} +6 -6
- package/dist/chunk-txazb0xn.js +27 -0
- package/dist/chunk-y5dtkmnp.js +8 -0
- package/dist/chunk-yrt0ffvf.js +9 -0
- package/dist/chunk-zn2nm5gg.js +9 -0
- package/dist/{chunk-7t524zqh.js → chunk-zv4ta4fb.js} +3 -3
- package/dist/errors/{base-error.d.ts → app-error.d.ts} +2 -1
- package/dist/errors/http-error.d.ts +2 -2
- package/dist/errors/index.d.ts +2 -1
- package/dist/errors/index.js +6 -4
- package/dist/errors/internal-error.d.ts +4 -0
- package/dist/modules/data/data.d.ts +5 -5
- package/dist/modules/data/enums/data-error-keys.d.ts +1 -1
- package/dist/modules/data/enums/index.js +1 -1
- package/dist/modules/data/index.js +3 -3
- package/dist/modules/database/enums/database-error-keys.d.ts +26 -26
- package/dist/modules/database/enums/index.js +1 -1
- package/dist/modules/database/enums/mssql-error-code.d.ts +23 -23
- package/dist/modules/database/index.js +5 -5
- package/dist/modules/database/mssql.d.ts +9 -9
- package/dist/modules/elysia/cache/cache.d.ts +1 -1
- package/dist/modules/elysia/cache/index.js +3 -3
- package/dist/modules/elysia/db-resolver/enums/db-resolver-error-keys.d.ts +1 -1
- package/dist/modules/elysia/db-resolver/enums/index.js +1 -1
- package/dist/modules/elysia/db-resolver/index.js +53 -10
- package/dist/modules/elysia/error/enums/error.keys.d.ts +4 -4
- package/dist/modules/elysia/error/enums/index.js +1 -1
- package/dist/modules/elysia/error/error.d.ts +5 -5
- package/dist/modules/elysia/error/index.js +14 -14
- package/dist/modules/elysia/microservice/enums/index.js +1 -1
- package/dist/modules/elysia/microservice/enums/microservice-success-keys.d.ts +2 -2
- package/dist/modules/elysia/microservice/index.js +1 -1
- package/dist/modules/elysia/rate-limit/enums/index.js +1 -1
- package/dist/modules/elysia/rate-limit/enums/rate-limit-error-keys.d.ts +1 -1
- package/dist/modules/elysia/rate-limit/index.js +7 -6
- package/dist/modules/elysia/rate-limit/rate-limit.d.ts +1 -1
- package/dist/modules/jwt/enums/index.js +2 -2
- package/dist/modules/jwt/enums/jwt-error-keys.d.ts +3 -3
- package/dist/modules/jwt/enums/parse-human-time-to-seconds-error-keys.d.ts +1 -1
- package/dist/modules/jwt/index.js +10 -12
- package/dist/modules/jwt/utils/index.js +3 -3
- package/dist/modules/jwt/utils/parse-human-time-to-seconds.d.ts +1 -1
- package/dist/modules/kv-store/bun-redis/index.js +25 -17
- package/dist/modules/kv-store/enums/index.js +1 -1
- package/dist/modules/kv-store/enums/kv-store-error-keys.d.ts +3 -3
- package/dist/modules/kv-store/ioredis/index.js +17 -17
- package/dist/modules/kv-store/memory/index.js +4 -98
- package/dist/modules/logger/enums/index.js +1 -1
- package/dist/modules/logger/enums/logger-error-keys.d.ts +7 -7
- package/dist/modules/logger/events/logger-events.d.ts +4 -4
- package/dist/modules/logger/index.js +91 -20
- package/dist/modules/logger/logger.d.ts +2 -2
- package/dist/modules/logger/sinks/console-logger.d.ts +1 -1
- package/dist/modules/logger/sinks/file-logger/enums/file-logger-error-keys.d.ts +1 -1
- package/dist/modules/logger/sinks/file-logger/file-logger.d.ts +3 -3
- package/dist/modules/logger/sinks/index.js +10 -11
- package/dist/modules/logger/types/logger-options.d.ts +1 -1
- package/dist/modules/logger/types/logger-sink.d.ts +1 -1
- package/dist/modules/logger/worker-logger.d.ts +1 -0
- package/dist/modules/mailer/enums/index.js +1 -1
- package/dist/modules/mailer/enums/mailer-error-keys.d.ts +3 -3
- package/dist/modules/mailer/index.js +6 -6
- package/dist/modules/mailer/smtp.d.ts +4 -4
- package/dist/modules/repository/index.js +4 -4
- package/dist/modules/repository/repository.d.ts +29 -13
- package/dist/modules/repository/types/filter.d.ts +2 -5
- package/dist/modules/repository/types/global-search.d.ts +12 -0
- package/dist/modules/repository/types/index.d.ts +2 -1
- package/dist/modules/repository/types/{order-by-item.d.ts → order-by.d.ts} +3 -3
- package/dist/modules/repository/types/query-options.d.ts +4 -5
- package/dist/modules/schema-builder/build-adaptive-where-clause-schema.d.ts +17 -0
- package/dist/modules/schema-builder/build-count-schema.d.ts +12 -0
- package/dist/modules/{elysia/crud/utils/create-delete-schema.d.ts → schema-builder/build-delete-schema.d.ts} +3 -3
- package/dist/modules/schema-builder/build-filters-schema.d.ts +12 -0
- package/dist/modules/schema-builder/build-find-schema.d.ts +12 -0
- package/dist/modules/schema-builder/build-global-search-schema.d.ts +12 -0
- package/dist/modules/schema-builder/build-insert-schema.d.ts +3 -0
- package/dist/modules/schema-builder/build-order-by-schema.d.ts +12 -0
- package/dist/modules/schema-builder/build-selected-fields.d.ts +12 -0
- package/dist/modules/schema-builder/build-update-one-schema.d.ts +12 -0
- package/dist/modules/schema-builder/build-update-schema.d.ts +12 -0
- package/dist/modules/schema-builder/clean-schema.d.ts +2 -0
- package/dist/modules/schema-builder/index.d.ts +12 -0
- package/dist/modules/schema-builder/index.js +232 -0
- package/dist/modules/schema-builder/types/adaptive-where-clause-schema.d.ts +34 -0
- package/dist/modules/{elysia/crud → schema-builder}/types/count-schema.d.ts +3 -3
- package/dist/modules/schema-builder/types/delete-schema.d.ts +12 -0
- package/dist/modules/schema-builder/types/filter-schema.d.ts +12 -0
- package/dist/modules/schema-builder/types/find-schema.d.ts +16 -0
- package/dist/modules/{elysia/crud/types/q-schema.d.ts → schema-builder/types/global-search-schema.d.ts} +1 -1
- package/dist/modules/schema-builder/types/index.d.ts +12 -0
- package/dist/modules/{elysia/crud → schema-builder}/types/insert-schema.d.ts +1 -1
- package/dist/modules/schema-builder/types/order-by-schema.d.ts +5 -0
- package/dist/modules/{elysia/crud → schema-builder}/types/update-schema.d.ts +4 -4
- package/dist/{shared → modules/schema-builder}/utils/flatten.d.ts +1 -1
- package/dist/modules/schema-builder/utils/index.d.ts +2 -0
- package/dist/modules/schema-builder/utils/index.js +9 -0
- package/dist/modules/singleton-manager/enums/index.js +1 -1
- package/dist/modules/singleton-manager/enums/singleton-manager-error-keys.d.ts +2 -2
- package/dist/modules/singleton-manager/index.js +3 -3
- package/dist/modules/singleton-manager/singleton-manager.d.ts +3 -3
- package/dist/modules/totp/enums/index.js +1 -1
- package/dist/modules/totp/enums/totp-error-keys.d.ts +5 -5
- package/dist/modules/totp/index.js +6 -6
- package/dist/modules/totp/otp-auth-uri.d.ts +1 -1
- package/dist/modules/totp/utils/base32.d.ts +1 -1
- package/dist/modules/totp/utils/generate-secret-bytes.d.ts +1 -1
- package/dist/modules/totp/utils/index.js +5 -5
- package/dist/shared/types/index.d.ts +0 -1
- package/dist/shared/utils/env.d.ts +1 -1
- package/dist/shared/utils/index.d.ts +0 -1
- package/dist/shared/utils/index.js +4 -8
- package/package.json +19 -22
- package/dist/chunk-441xs5k1.js +0 -53
- package/dist/chunk-4v86f7gp.js +0 -59
- package/dist/chunk-6w9ja96e.js +0 -9
- package/dist/chunk-9cgzhc50.js +0 -15
- package/dist/chunk-9d3zvgp6.js +0 -9
- package/dist/chunk-9dzsj7f2.js +0 -23
- package/dist/chunk-9r5anep5.js +0 -11
- package/dist/chunk-p14h6jfs.js +0 -365
- package/dist/chunk-pjv1ekwr.js +0 -284
- package/dist/chunk-rz5p4j3p.js +0 -13
- package/dist/chunk-spnh9dzk.js +0 -10
- package/dist/chunk-w7h898m3.js +0 -14
- package/dist/chunk-xhhj1gvj.js +0 -9
- package/dist/chunk-z0ct35ft.js +0 -8
- package/dist/errors/utils/index.d.ts +0 -1
- package/dist/errors/utils/index.js +0 -16
- package/dist/errors/utils/is-nowarajs-error.ts.d.ts +0 -4
- package/dist/modules/elysia/crud/crud-schema.d.ts +0 -18
- package/dist/modules/elysia/crud/crud.d.ts +0 -38
- package/dist/modules/elysia/crud/enums/crud-success-keys.d.ts +0 -10
- package/dist/modules/elysia/crud/enums/index.d.ts +0 -1
- package/dist/modules/elysia/crud/enums/index.js +0 -7
- package/dist/modules/elysia/crud/index.d.ts +0 -2
- package/dist/modules/elysia/crud/index.js +0 -153
- package/dist/modules/elysia/crud/operations/count.d.ts +0 -258
- package/dist/modules/elysia/crud/operations/delete.d.ts +0 -258
- package/dist/modules/elysia/crud/operations/deleteOne.d.ts +0 -258
- package/dist/modules/elysia/crud/operations/find.d.ts +0 -258
- package/dist/modules/elysia/crud/operations/findOne.d.ts +0 -258
- package/dist/modules/elysia/crud/operations/index.d.ts +0 -8
- package/dist/modules/elysia/crud/operations/index.js +0 -34
- package/dist/modules/elysia/crud/operations/insert.d.ts +0 -258
- package/dist/modules/elysia/crud/operations/update.d.ts +0 -268
- package/dist/modules/elysia/crud/operations/updateOne.d.ts +0 -268
- package/dist/modules/elysia/crud/operations/utils/get-db-injection.d.ts +0 -8
- package/dist/modules/elysia/crud/types/adaptive-where-clause-schema.d.ts +0 -31
- package/dist/modules/elysia/crud/types/count-response-200-schema.d.ts +0 -5
- package/dist/modules/elysia/crud/types/crud-operation-base.d.ts +0 -4
- package/dist/modules/elysia/crud/types/crud-operation-count.d.ts +0 -14
- package/dist/modules/elysia/crud/types/crud-operation-delete-one.d.ts +0 -14
- package/dist/modules/elysia/crud/types/crud-operation-delete.d.ts +0 -14
- package/dist/modules/elysia/crud/types/crud-operation-find-one.d.ts +0 -14
- package/dist/modules/elysia/crud/types/crud-operation-find.d.ts +0 -14
- package/dist/modules/elysia/crud/types/crud-operation-insert.d.ts +0 -14
- package/dist/modules/elysia/crud/types/crud-operation-update-one.d.ts +0 -16
- package/dist/modules/elysia/crud/types/crud-operation-update.d.ts +0 -14
- package/dist/modules/elysia/crud/types/crud-operations.d.ts +0 -19
- package/dist/modules/elysia/crud/types/crud-options.d.ts +0 -44
- package/dist/modules/elysia/crud/types/crud-schema-models-type.d.ts +0 -12
- package/dist/modules/elysia/crud/types/crud-schema-operations.d.ts +0 -10
- package/dist/modules/elysia/crud/types/crud-schema-options.d.ts +0 -13
- package/dist/modules/elysia/crud/types/delete-schema.d.ts +0 -12
- package/dist/modules/elysia/crud/types/filter-schema.d.ts +0 -9
- package/dist/modules/elysia/crud/types/find-schema.d.ts +0 -16
- package/dist/modules/elysia/crud/types/id-param-schema.d.ts +0 -4
- package/dist/modules/elysia/crud/types/index.d.ts +0 -29
- package/dist/modules/elysia/crud/types/order-schema.d.ts +0 -11
- package/dist/modules/elysia/crud/types/properties-schema.d.ts +0 -9
- package/dist/modules/elysia/crud/types/response-200-schema.d.ts +0 -11
- package/dist/modules/elysia/crud/utils/create-adaptive-where-clause-schema.d.ts +0 -17
- package/dist/modules/elysia/crud/utils/create-count-response-200-schema.d.ts +0 -8
- package/dist/modules/elysia/crud/utils/create-count-schema.d.ts +0 -12
- package/dist/modules/elysia/crud/utils/create-filters-schema.d.ts +0 -14
- package/dist/modules/elysia/crud/utils/create-find-schema.d.ts +0 -12
- package/dist/modules/elysia/crud/utils/create-id-param-schema.d.ts +0 -2
- package/dist/modules/elysia/crud/utils/create-insert-schema.d.ts +0 -8
- package/dist/modules/elysia/crud/utils/create-order-schema.d.ts +0 -12
- package/dist/modules/elysia/crud/utils/create-properties-schema.d.ts +0 -12
- package/dist/modules/elysia/crud/utils/create-q-schema.d.ts +0 -12
- package/dist/modules/elysia/crud/utils/create-response-200-schema.d.ts +0 -3
- package/dist/modules/elysia/crud/utils/create-selected-fields-schema.d.ts +0 -12
- package/dist/modules/elysia/crud/utils/create-update-one-schema.d.ts +0 -3
- package/dist/modules/elysia/crud/utils/create-update-schema.d.ts +0 -3
- package/dist/modules/elysia/crud/utils/index.d.ts +0 -16
- package/dist/modules/elysia/crud/utils/index.js +0 -41
- /package/dist/modules/{elysia/crud → schema-builder}/types/index.js +0 -0
- /package/dist/modules/{elysia/crud/types/selected-field-schema.d.ts → schema-builder/types/selected-fields-schema.d.ts} +0 -0
- /package/dist/{shared → modules/schema-builder}/types/tflatten.d.ts +0 -0
- /package/dist/modules/{elysia/crud → schema-builder}/types/update-one-schema.d.ts +0 -0
- /package/dist/modules/{elysia/crud → schema-builder}/utils/is-date-from-elysia-typebox.d.ts +0 -0
package/CHANGELOG.md
ADDED
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// source/modules/elysia/microservice/enums/microservice-success-keys.ts
|
|
3
3
|
var MICROSERVICE_SUCCESS_KEYS = {
|
|
4
|
-
PING_RESPONSE: "mrx-core.microservice.success.ping_response",
|
|
5
|
-
INFO_RETRIEVED: "mrx-core.microservice.success.info_retrieved"
|
|
4
|
+
PING_RESPONSE: "mrx.mrx-core.microservice.success.ping_response",
|
|
5
|
+
INFO_RETRIEVED: "mrx.mrx-core.microservice.success.info_retrieved"
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export { MICROSERVICE_SUCCESS_KEYS };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// source/modules/elysia/rate-limit/enums/rate-limit-error-keys.ts
|
|
3
3
|
var RATE_LIMIT_ERROR_KEYS = {
|
|
4
|
-
RATE_LIMIT_EXCEEDED: "mrx-core.elysia.rate-limit.error.exceeded"
|
|
4
|
+
RATE_LIMIT_EXCEEDED: "mrx.mrx-core.elysia.rate-limit.error.exceeded"
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export { RATE_LIMIT_ERROR_KEYS };
|
|
@@ -3,13 +3,16 @@ import {
|
|
|
3
3
|
isDateString,
|
|
4
4
|
makeStreamAsyncIterable
|
|
5
5
|
} from "./chunk-grfyngq0.js";
|
|
6
|
+
import {
|
|
7
|
+
HttpError
|
|
8
|
+
} from "./chunk-zv4ta4fb.js";
|
|
9
|
+
import {
|
|
10
|
+
InternalError
|
|
11
|
+
} from "./chunk-jz3wd472.js";
|
|
6
12
|
import {
|
|
7
13
|
DATABASE_ERROR_KEYS,
|
|
8
14
|
MSSQL_ERROR_CODE
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
HttpError
|
|
12
|
-
} from "./chunk-7t524zqh.js";
|
|
15
|
+
} from "./chunk-642xajvx.js";
|
|
13
16
|
|
|
14
17
|
// source/modules/repository/repository.ts
|
|
15
18
|
import { PassThrough } from "stream";
|
|
@@ -79,7 +82,7 @@ class Repository {
|
|
|
79
82
|
};
|
|
80
83
|
kStream.on("error", (error) => {
|
|
81
84
|
const code = error?.number || 0;
|
|
82
|
-
passThrough.emit("error", new
|
|
85
|
+
passThrough.emit("error", new InternalError(MSSQL_ERROR_CODE[code] ?? DATABASE_ERROR_KEYS.MSSQL_QUERY_ERROR, {
|
|
83
86
|
query: query.toSQL().sql,
|
|
84
87
|
error
|
|
85
88
|
}));
|
|
@@ -99,7 +102,8 @@ class Repository {
|
|
|
99
102
|
}
|
|
100
103
|
async count(options) {
|
|
101
104
|
const query = this._knex(this._table.name).count({ count: "*" });
|
|
102
|
-
|
|
105
|
+
if (options?.filters)
|
|
106
|
+
this._applyFilter(query, options?.filters);
|
|
103
107
|
if (options?.transaction)
|
|
104
108
|
query.transacting(options.transaction);
|
|
105
109
|
return this._executeQuery(query, options?.throwIfNoResult).then((result) => result[0].count);
|
|
@@ -113,6 +117,10 @@ class Repository {
|
|
|
113
117
|
async update(data, options) {
|
|
114
118
|
const query = this._knex(this._table.name).update(data);
|
|
115
119
|
this._applyQueryOptions(query, options);
|
|
120
|
+
if (options.limit)
|
|
121
|
+
query.limit(options.limit);
|
|
122
|
+
if (options.offset)
|
|
123
|
+
query.offset(options.offset);
|
|
116
124
|
return this._executeQuery(query, options?.throwIfNoResult);
|
|
117
125
|
}
|
|
118
126
|
async delete(options) {
|
|
@@ -132,21 +140,20 @@ class Repository {
|
|
|
132
140
|
const processing = (query2, search2) => {
|
|
133
141
|
for (const key in search2) {
|
|
134
142
|
const prop = search2[key];
|
|
135
|
-
if (this.
|
|
143
|
+
if (this._isAdaptiveWhereClause(prop)) {
|
|
136
144
|
for (const operator in prop)
|
|
137
145
|
if (operator in _operators && prop[operator] !== undefined)
|
|
138
146
|
_operators[operator](query2, key, prop[operator]);
|
|
139
|
-
} else if (key === "$q" &&
|
|
147
|
+
} else if (key === "$q" && this._isGlobalSearchPrimitive(prop)) {
|
|
140
148
|
for (const field of this._table.fields)
|
|
141
149
|
if (prop)
|
|
142
150
|
query2.orWhere(field, "like", `%${prop}%`);
|
|
143
|
-
} else if (key === "$q" && prop
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
query2.orWhere(field, "like", `%${value}%`);
|
|
151
|
+
} else if (key === "$q" && this._isGlobalSearchObject(prop)) {
|
|
152
|
+
if (Array.isArray(prop.selectedFields))
|
|
153
|
+
for (const field of prop.selectedFields)
|
|
154
|
+
query2.orWhere(field, "like", `%${prop.value}%`);
|
|
148
155
|
else
|
|
149
|
-
query2.orWhere(selectedFields, "like", `%${value}%`);
|
|
156
|
+
query2.orWhere(prop.selectedFields, "like", `%${prop.value}%`);
|
|
150
157
|
} else {
|
|
151
158
|
if (prop !== null && typeof prop === "object" && Object.keys(prop).length === 0)
|
|
152
159
|
continue;
|
|
@@ -155,9 +162,9 @@ class Repository {
|
|
|
155
162
|
}
|
|
156
163
|
}
|
|
157
164
|
};
|
|
158
|
-
if (
|
|
165
|
+
if (Array.isArray(search))
|
|
159
166
|
search.reduce((acc, item) => acc.orWhere((q) => this._applyFilter(q, item)), query);
|
|
160
|
-
else
|
|
167
|
+
else
|
|
161
168
|
processing(query, search);
|
|
162
169
|
}
|
|
163
170
|
_applyOrderBy(query, orderBy) {
|
|
@@ -174,7 +181,8 @@ class Repository {
|
|
|
174
181
|
query.orderBy(`[${this._table.name}].${orderBy.selectedField}`, orderBy.direction);
|
|
175
182
|
}
|
|
176
183
|
_applyQueryOptions(query, options) {
|
|
177
|
-
|
|
184
|
+
if (options?.filters)
|
|
185
|
+
this._applyFilter(query, options.filters);
|
|
178
186
|
this._applyOrderBy(query, options?.orderBy);
|
|
179
187
|
this._applySelectedFields(query, options?.selectedFields);
|
|
180
188
|
if (options?.transaction)
|
|
@@ -184,21 +192,25 @@ class Repository {
|
|
|
184
192
|
if (error instanceof HttpError)
|
|
185
193
|
throw error;
|
|
186
194
|
const code = error?.number || 0;
|
|
187
|
-
throw new
|
|
195
|
+
throw new InternalError(MSSQL_ERROR_CODE[code] ?? DATABASE_ERROR_KEYS.MSSQL_QUERY_ERROR, {
|
|
188
196
|
query: query.toSQL().sql,
|
|
189
197
|
error
|
|
190
198
|
});
|
|
191
199
|
}
|
|
192
|
-
|
|
200
|
+
_isAdaptiveWhereClause(data) {
|
|
193
201
|
return Boolean(data && typeof data === "object" && !Array.isArray(data) && Object.keys(data).some((key) => _validOperatorKeys.has(key)));
|
|
194
202
|
}
|
|
203
|
+
_isGlobalSearchObject(data) {
|
|
204
|
+
return Boolean(data && typeof data === "object" && "selectedFields" in data && "value" in data);
|
|
205
|
+
}
|
|
206
|
+
_isGlobalSearchPrimitive(data) {
|
|
207
|
+
return data !== null && (typeof data === "string" || typeof data === "number");
|
|
208
|
+
}
|
|
195
209
|
async _executeQuery(query, throwIfNoResult = false) {
|
|
196
210
|
try {
|
|
197
211
|
const result = await query;
|
|
198
212
|
if (throwIfNoResult && result.length === 0)
|
|
199
|
-
throw new HttpError(typeof throwIfNoResult === "object" && throwIfNoResult.message ? throwIfNoResult.message : DATABASE_ERROR_KEYS.MSSQL_NO_RESULT, typeof throwIfNoResult === "object" && throwIfNoResult.httpStatusCode ? throwIfNoResult.httpStatusCode : 404
|
|
200
|
-
query: query.toSQL().sql
|
|
201
|
-
});
|
|
213
|
+
throw new HttpError(typeof throwIfNoResult === "object" && throwIfNoResult.message ? throwIfNoResult.message : DATABASE_ERROR_KEYS.MSSQL_NO_RESULT, typeof throwIfNoResult === "object" && throwIfNoResult.httpStatusCode ? throwIfNoResult.httpStatusCode : 404);
|
|
202
214
|
return result;
|
|
203
215
|
} catch (error) {
|
|
204
216
|
return this._handleError(error, query);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/elysia/error/enums/error.keys.ts
|
|
3
|
+
var ERROR_KEYS = {
|
|
4
|
+
VALIDATION: "mrx.mrx-core.error.validation",
|
|
5
|
+
NOT_FOUND: "mrx.mrx-core.error.not_found",
|
|
6
|
+
PARSE: "mrx.mrx-core.error.parse",
|
|
7
|
+
INTERNAL_SERVER_ERROR: "mrx.mrx-core.error.internal_server_error"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { ERROR_KEYS };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/database/enums/database-error-keys.ts
|
|
3
|
+
var DATABASE_ERROR_KEYS = {
|
|
4
|
+
MSSQL_CONNECTION_ERROR: "mrx.mrx-core.mssql.error.database.connection_error",
|
|
5
|
+
MSSQL_DATABASE_ACCESS_DENIED: "mrx.mrx-core.mssql.error.database.access_denied",
|
|
6
|
+
MSSQL_DATABASE_AMBIGUOUS_COLUMN: "mrx.mrx-core.mssql.error.database.ambiguous_column",
|
|
7
|
+
MSSQL_DATABASE_AUTHORIZATION_FAILED: "mrx.mrx-core.mssql.error.database.authorization_failed",
|
|
8
|
+
MSSQL_DATABASE_COLUMN_NOT_FOUND: "mrx.mrx-core.mssql.error.database.column_not_found",
|
|
9
|
+
MSSQL_DATABASE_CONVERSION_FAILED: "mrx.mrx-core.mssql.error.database.conversion_failed",
|
|
10
|
+
MSSQL_DATABASE_DATA_TOO_LARGE: "mrx.mrx-core.mssql.error.database.data_too_large",
|
|
11
|
+
MSSQL_DATABASE_DEADLOCK_DETECTED: "mrx.mrx-core.mssql.error.database.deadlock_detected",
|
|
12
|
+
MSSQL_DATABASE_DUPLICATE_KEY: "mrx.mrx-core.mssql.error.database.duplicate_key",
|
|
13
|
+
MSSQL_DATABASE_FOREIGN_KEY_VIOLATION: "mrx.mrx-core.mssql.error.database.foreign_key_violation",
|
|
14
|
+
MSSQL_DATABASE_IDENTITY_INSERT_NOT_ALLOWED: "mrx.mrx-core.mssql.error.database.identity_insert_not_allowed",
|
|
15
|
+
MSSQL_DATABASE_INSUFFICIENT_MEMORY: "mrx.mrx-core.mssql.error.database.insufficient_memory",
|
|
16
|
+
MSSQL_DATABASE_INSUFFICIENT_STORAGE: "mrx.mrx-core.mssql.error.database.insufficient_storage",
|
|
17
|
+
MSSQL_DATABASE_PERMISSION_DENIED: "mrx.mrx-core.mssql.error.database.permission_denied",
|
|
18
|
+
MSSQL_DATABASE_QUERY_TIMEOUT: "mrx.mrx-core.mssql.error.database.query_timeout",
|
|
19
|
+
MSSQL_DATABASE_RESOURCE_LOCKED: "mrx.mrx-core.mssql.error.database.resource_locked",
|
|
20
|
+
MSSQL_DATABASE_SYNTAX_ERROR: "mrx.mrx-core.mssql.error.database.syntax_error",
|
|
21
|
+
MSSQL_DATABASE_TRANSACTION_ABORTED: "mrx.mrx-core.mssql.error.database.transaction_aborted",
|
|
22
|
+
MSSQL_DATABASE_TRANSACTION_LOG_FULL: "mrx.mrx-core.mssql.error.database.transaction_log_full",
|
|
23
|
+
MSSQL_DATABASE_UNIQUE_CONSTRAINT_VIOLATION: "mrx.mrx-core.mssql.error.database.unique_constraint_violation",
|
|
24
|
+
MSSQL_DATABASE_CANNOT_UPDATE_IDENTITY_COLUMN: "mrx.mrx-core.mssql.error.database.cannot_update_identity_column",
|
|
25
|
+
MSSQL_DISCONNECT_ERROR: "mrx.mrx-core.mssql.error.database.disconnect_error",
|
|
26
|
+
MSSQL_NO_RESULT: "mrx.mrx-core.mssql.error.database.no_result",
|
|
27
|
+
MSSQL_NOT_CONNECTED: "mrx.mrx-core.mssql.error.database.not_connected",
|
|
28
|
+
MSSQL_QUERY_ERROR: "mrx.mrx-core.mssql.error.database.query_error",
|
|
29
|
+
MSSQL_TABLE_NOT_FOUND: "mrx.mrx-core.mssql.error.database.table_not_found"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// source/modules/database/enums/mssql-error-code.ts
|
|
33
|
+
var MSSQL_ERROR_CODE = {
|
|
34
|
+
0: DATABASE_ERROR_KEYS.MSSQL_QUERY_ERROR,
|
|
35
|
+
102: DATABASE_ERROR_KEYS.MSSQL_DATABASE_SYNTAX_ERROR,
|
|
36
|
+
1105: DATABASE_ERROR_KEYS.MSSQL_DATABASE_INSUFFICIENT_STORAGE,
|
|
37
|
+
1205: DATABASE_ERROR_KEYS.MSSQL_DATABASE_DEADLOCK_DETECTED,
|
|
38
|
+
1222: DATABASE_ERROR_KEYS.MSSQL_DATABASE_RESOURCE_LOCKED,
|
|
39
|
+
18452: DATABASE_ERROR_KEYS.MSSQL_DATABASE_AUTHORIZATION_FAILED,
|
|
40
|
+
18456: DATABASE_ERROR_KEYS.MSSQL_DATABASE_AUTHORIZATION_FAILED,
|
|
41
|
+
207: DATABASE_ERROR_KEYS.MSSQL_DATABASE_COLUMN_NOT_FOUND,
|
|
42
|
+
208: DATABASE_ERROR_KEYS.MSSQL_TABLE_NOT_FOUND,
|
|
43
|
+
209: DATABASE_ERROR_KEYS.MSSQL_DATABASE_AMBIGUOUS_COLUMN,
|
|
44
|
+
229: DATABASE_ERROR_KEYS.MSSQL_DATABASE_PERMISSION_DENIED,
|
|
45
|
+
2601: DATABASE_ERROR_KEYS.MSSQL_DATABASE_UNIQUE_CONSTRAINT_VIOLATION,
|
|
46
|
+
2627: DATABASE_ERROR_KEYS.MSSQL_DATABASE_DUPLICATE_KEY,
|
|
47
|
+
3928: DATABASE_ERROR_KEYS.MSSQL_DATABASE_TRANSACTION_ABORTED,
|
|
48
|
+
4060: DATABASE_ERROR_KEYS.MSSQL_DATABASE_ACCESS_DENIED,
|
|
49
|
+
544: DATABASE_ERROR_KEYS.MSSQL_DATABASE_IDENTITY_INSERT_NOT_ALLOWED,
|
|
50
|
+
547: DATABASE_ERROR_KEYS.MSSQL_DATABASE_FOREIGN_KEY_VIOLATION,
|
|
51
|
+
701: DATABASE_ERROR_KEYS.MSSQL_DATABASE_INSUFFICIENT_MEMORY,
|
|
52
|
+
8102: DATABASE_ERROR_KEYS.MSSQL_DATABASE_CANNOT_UPDATE_IDENTITY_COLUMN,
|
|
53
|
+
8152: DATABASE_ERROR_KEYS.MSSQL_DATABASE_DATA_TOO_LARGE,
|
|
54
|
+
8169: DATABASE_ERROR_KEYS.MSSQL_DATABASE_CONVERSION_FAILED,
|
|
55
|
+
8645: DATABASE_ERROR_KEYS.MSSQL_DATABASE_QUERY_TIMEOUT,
|
|
56
|
+
9002: DATABASE_ERROR_KEYS.MSSQL_DATABASE_TRANSACTION_LOG_FULL
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { DATABASE_ERROR_KEYS, MSSQL_ERROR_CODE };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/logger/enums/logger-error-keys.ts
|
|
3
|
+
var LOGGER_ERROR_KEYS = {
|
|
4
|
+
BEFORE_EXIT_CLOSE_ERROR: "mrx.mrx-core.logger.error.before_exit_close_error",
|
|
5
|
+
BEFORE_EXIT_FLUSH_ERROR: "mrx.mrx-core.logger.error.before_exit_flush_error",
|
|
6
|
+
NO_SINKS_PROVIDED: "mrx.mrx-core.logger.error.no_sinks_provided",
|
|
7
|
+
REGISTER_SINK_ERROR: "mrx.mrx-core.logger.error.register_sink_error",
|
|
8
|
+
SINK_ALREADY_ADDED: "mrx.mrx-core.logger.error.sink_already_added",
|
|
9
|
+
SINK_CLOSE_ERROR: "mrx.mrx-core.logger.error.sink_close_error",
|
|
10
|
+
SINK_LOG_ERROR: "mrx.mrx-core.logger.error.sink_log_error"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { LOGGER_ERROR_KEYS };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/kv-store/enums/kv-store-error-keys.ts
|
|
3
|
+
var KV_STORE_ERROR_KEYS = {
|
|
4
|
+
CLOSING_CONNECTION_FAILED: "mrx.mrx-core.kv-store.error.closing_connection_failed",
|
|
5
|
+
CONNECTION_FAILED: "mrx.mrx-core.kv-store.error.connection_failed",
|
|
6
|
+
NOT_INTEGER: "mrx.mrx-core.kv-store.error.not_integer"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { KV_STORE_ERROR_KEYS };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-dmsev7vs.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
InternalError
|
|
7
|
+
} from "./chunk-jz3wd472.js";
|
|
8
8
|
|
|
9
9
|
// source/modules/jwt/utils/parse-human-time-to-seconds.ts
|
|
10
10
|
var TIME_UNITS = {
|
|
@@ -47,7 +47,7 @@ var UNIT_MAPPINGS = {
|
|
|
47
47
|
var parseHumanTimeToSeconds = (timeExpression) => {
|
|
48
48
|
const match = TIME_EXPRESSION_REGEX.exec(timeExpression);
|
|
49
49
|
if (!match || match[4] && match[1])
|
|
50
|
-
throw new
|
|
50
|
+
throw new InternalError(PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS.INVALID_TIME_EXPRESSION);
|
|
51
51
|
const [, sign, valueStr, unitStr, direction] = match;
|
|
52
52
|
const value = parseFloat(valueStr);
|
|
53
53
|
const unit = unitStr.toLowerCase();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// source/modules/elysia/db-resolver/enums/db-resolver-error-keys.ts
|
|
3
3
|
var DB_RESOLVER_ERROR_KEYS = {
|
|
4
|
-
DB_RESOLVER_STATIC_DB_NOT_FOUND: "mrx-core.db-resolver.error.static_db_not_found"
|
|
4
|
+
DB_RESOLVER_STATIC_DB_NOT_FOUND: "mrx.mrx-core.db-resolver.error.static_db_not_found"
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export { DB_RESOLVER_ERROR_KEYS };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// source/modules/jwt/enums/parse-human-time-to-seconds-error-keys.ts
|
|
3
3
|
var PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS = {
|
|
4
|
-
INVALID_TIME_EXPRESSION: "mrx-core.parse_human_time_to_seconds.error.invalid_time_expression"
|
|
4
|
+
INVALID_TIME_EXPRESSION: "mrx.mrx-core.jwt.parse_human_time_to_seconds.error.invalid_time_expression"
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export { PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
Repository
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-47yta3gd.js";
|
|
5
5
|
import {
|
|
6
6
|
TypedEventEmitter
|
|
7
7
|
} from "./chunk-mvrxngm7.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
InternalError
|
|
10
|
+
} from "./chunk-jz3wd472.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
12
|
+
DATABASE_ERROR_KEYS
|
|
13
|
+
} from "./chunk-642xajvx.js";
|
|
14
14
|
|
|
15
15
|
// source/modules/database/table.ts
|
|
16
16
|
class Table extends TypedEventEmitter {
|
|
@@ -80,7 +80,7 @@ class MSSQL extends TypedEventEmitter {
|
|
|
80
80
|
if (this._isEventEnabled)
|
|
81
81
|
this._addEventKnex();
|
|
82
82
|
} catch (error) {
|
|
83
|
-
throw new
|
|
83
|
+
throw new InternalError(DATABASE_ERROR_KEYS.MSSQL_CONNECTION_ERROR, {
|
|
84
84
|
databaseName: this._databaseName,
|
|
85
85
|
error
|
|
86
86
|
});
|
|
@@ -88,14 +88,14 @@ class MSSQL extends TypedEventEmitter {
|
|
|
88
88
|
}
|
|
89
89
|
async disconnect() {
|
|
90
90
|
if (!this._isConnected)
|
|
91
|
-
throw new
|
|
91
|
+
throw new InternalError(DATABASE_ERROR_KEYS.MSSQL_NOT_CONNECTED, {
|
|
92
92
|
databaseName: this._databaseName
|
|
93
93
|
});
|
|
94
94
|
try {
|
|
95
95
|
await this._db.destroy();
|
|
96
96
|
this._isConnected = false;
|
|
97
97
|
} catch (error) {
|
|
98
|
-
throw new
|
|
98
|
+
throw new InternalError(DATABASE_ERROR_KEYS.MSSQL_DISCONNECT_ERROR, {
|
|
99
99
|
databaseName: this._databaseName,
|
|
100
100
|
error
|
|
101
101
|
});
|
|
@@ -103,9 +103,9 @@ class MSSQL extends TypedEventEmitter {
|
|
|
103
103
|
}
|
|
104
104
|
getRepository(tableName, customRepository) {
|
|
105
105
|
if (!this._isConnected)
|
|
106
|
-
throw new
|
|
106
|
+
throw new InternalError(DATABASE_ERROR_KEYS.MSSQL_NOT_CONNECTED, { databaseName: this._databaseName });
|
|
107
107
|
if (!this._tables.has(tableName))
|
|
108
|
-
throw new
|
|
108
|
+
throw new InternalError(DATABASE_ERROR_KEYS.MSSQL_TABLE_NOT_FOUND, { table: tableName });
|
|
109
109
|
let repo = this._repositories.get(tableName);
|
|
110
110
|
if (customRepository) {
|
|
111
111
|
const table = this._tables.get(tableName);
|
|
@@ -119,9 +119,9 @@ class MSSQL extends TypedEventEmitter {
|
|
|
119
119
|
}
|
|
120
120
|
getTable(tableName) {
|
|
121
121
|
if (!this._isConnected)
|
|
122
|
-
throw new
|
|
122
|
+
throw new InternalError(DATABASE_ERROR_KEYS.MSSQL_NOT_CONNECTED, { databaseName: this._databaseName });
|
|
123
123
|
if (!this._tables.has(tableName))
|
|
124
|
-
throw new
|
|
124
|
+
throw new InternalError(DATABASE_ERROR_KEYS.MSSQL_TABLE_NOT_FOUND, { table: tableName });
|
|
125
125
|
return this._tables.get(tableName);
|
|
126
126
|
}
|
|
127
127
|
get databaseName() {
|
|
@@ -138,7 +138,7 @@ class MSSQL extends TypedEventEmitter {
|
|
|
138
138
|
}
|
|
139
139
|
get db() {
|
|
140
140
|
if (!this._isConnected)
|
|
141
|
-
throw new
|
|
141
|
+
throw new InternalError(DATABASE_ERROR_KEYS.MSSQL_NOT_CONNECTED, { databaseName: this._databaseName });
|
|
142
142
|
return this._db;
|
|
143
143
|
}
|
|
144
144
|
async _introspectDatabase() {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
DATA_ERROR_KEYS
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-10w8mg8e.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
InternalError
|
|
7
|
+
} from "./chunk-jz3wd472.js";
|
|
8
8
|
|
|
9
9
|
// source/modules/data/data.ts
|
|
10
10
|
var _validateDataNull = (data) => {
|
|
11
11
|
if (data === null || data === undefined)
|
|
12
|
-
throw new
|
|
12
|
+
throw new InternalError(DATA_ERROR_KEYS.DATA_IS_NULL);
|
|
13
13
|
};
|
|
14
14
|
var filterByKeyExclusion = (data, keys, excludeNullUndefined) => {
|
|
15
15
|
_validateDataNull(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/totp/enums/totp-error-keys.ts
|
|
3
|
+
var TOTP_ERROR_KEYS = {
|
|
4
|
+
INVALID_ALGORITHM: "mrx.mrx-core.totp.error.invalid_algorithm",
|
|
5
|
+
INVALID_BASE32_CHARACTER: "mrx.mrx-core.totp.error.invalid_base32_character",
|
|
6
|
+
INVALID_OTP_AUTH_URI: "mrx.mrx-core.totp.error.invalid_otp_auth_uri",
|
|
7
|
+
INVALID_SECRET_LENGTH: "mrx.mrx-core.totp.error.invalid_secret_length",
|
|
8
|
+
MISSING_SECRET: "mrx.mrx-core.totp.error.missing_secret"
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { TOTP_ERROR_KEYS };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
KV_STORE_ERROR_KEYS
|
|
4
|
+
} from "./chunk-8pw0syzf.js";
|
|
5
|
+
import {
|
|
6
|
+
InternalError
|
|
7
|
+
} from "./chunk-jz3wd472.js";
|
|
8
|
+
|
|
9
|
+
// source/modules/kv-store/memory/memory-store.ts
|
|
10
|
+
class MemoryStore {
|
|
11
|
+
_store = new Map;
|
|
12
|
+
_cleanupInterval;
|
|
13
|
+
_cleanupTimer = null;
|
|
14
|
+
constructor(cleanupIntervalMs) {
|
|
15
|
+
this._cleanupInterval = cleanupIntervalMs ?? 300000;
|
|
16
|
+
this._startCleanup();
|
|
17
|
+
}
|
|
18
|
+
get(key) {
|
|
19
|
+
const entry = this._store.get(key);
|
|
20
|
+
if (!entry)
|
|
21
|
+
return null;
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
if (now > entry.expiresAt && entry.expiresAt !== -1) {
|
|
24
|
+
this._store.delete(key);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return entry.value;
|
|
28
|
+
}
|
|
29
|
+
set(key, value, ttlSec) {
|
|
30
|
+
const expiresAt = ttlSec ? Date.now() + ttlSec * 1000 : -1;
|
|
31
|
+
this._store.set(key, { value, expiresAt });
|
|
32
|
+
}
|
|
33
|
+
increment(key, amount = 1) {
|
|
34
|
+
const current = this.get(key);
|
|
35
|
+
const entry = this._store.get(key);
|
|
36
|
+
if (current !== null && typeof current !== "number")
|
|
37
|
+
throw new InternalError(KV_STORE_ERROR_KEYS.NOT_INTEGER);
|
|
38
|
+
const currentValue = current ?? 0;
|
|
39
|
+
const newValue = currentValue + amount;
|
|
40
|
+
const expiresAt = entry ? entry.expiresAt : -1;
|
|
41
|
+
this._store.set(key, { value: newValue, expiresAt });
|
|
42
|
+
return newValue;
|
|
43
|
+
}
|
|
44
|
+
decrement(key, amount = 1) {
|
|
45
|
+
const current = this.get(key);
|
|
46
|
+
const entry = this._store.get(key);
|
|
47
|
+
if (current !== null && typeof current !== "number")
|
|
48
|
+
throw new InternalError(KV_STORE_ERROR_KEYS.NOT_INTEGER);
|
|
49
|
+
const currentValue = current ?? 0;
|
|
50
|
+
const newValue = currentValue - amount;
|
|
51
|
+
const expiresAt = entry ? entry.expiresAt : -1;
|
|
52
|
+
this._store.set(key, { value: newValue, expiresAt });
|
|
53
|
+
return newValue;
|
|
54
|
+
}
|
|
55
|
+
del(key) {
|
|
56
|
+
return this._store.delete(key);
|
|
57
|
+
}
|
|
58
|
+
expire(key, ttlSec) {
|
|
59
|
+
const entry = this._store.get(key);
|
|
60
|
+
if (!entry)
|
|
61
|
+
return false;
|
|
62
|
+
entry.expiresAt = Date.now() + ttlSec * 1000;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
ttl(key) {
|
|
66
|
+
const entry = this._store.get(key);
|
|
67
|
+
if (!entry)
|
|
68
|
+
return -1;
|
|
69
|
+
if (entry.expiresAt === -1)
|
|
70
|
+
return -1;
|
|
71
|
+
const remaining = entry.expiresAt - Date.now();
|
|
72
|
+
return remaining > 0 ? Math.ceil(remaining / 1000) : -1;
|
|
73
|
+
}
|
|
74
|
+
clean() {
|
|
75
|
+
const sizeBefore = this._store.size;
|
|
76
|
+
this._store.clear();
|
|
77
|
+
return sizeBefore;
|
|
78
|
+
}
|
|
79
|
+
_startCleanup() {
|
|
80
|
+
if (this._cleanupTimer)
|
|
81
|
+
return;
|
|
82
|
+
this._cleanupTimer = setInterval(() => {
|
|
83
|
+
this._removeExpiredEntries();
|
|
84
|
+
}, this._cleanupInterval);
|
|
85
|
+
}
|
|
86
|
+
_removeExpiredEntries() {
|
|
87
|
+
const now = Date.now();
|
|
88
|
+
for (const [key, entry] of this._store.entries())
|
|
89
|
+
if (entry.expiresAt !== -1 && now > entry.expiresAt)
|
|
90
|
+
this._store.delete(key);
|
|
91
|
+
}
|
|
92
|
+
destroy() {
|
|
93
|
+
if (this._cleanupTimer) {
|
|
94
|
+
clearInterval(this._cleanupTimer);
|
|
95
|
+
this._cleanupTimer = null;
|
|
96
|
+
}
|
|
97
|
+
this._store.clear();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { MemoryStore };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/errors/app-error.ts
|
|
3
|
+
class AppError extends Error {
|
|
4
|
+
cause;
|
|
5
|
+
date = new Date;
|
|
6
|
+
uuid = Bun.randomUUIDv7();
|
|
7
|
+
constructor(message, cause) {
|
|
8
|
+
super(message, { cause });
|
|
9
|
+
this.cause = cause;
|
|
10
|
+
this.name = new.target.name;
|
|
11
|
+
if (Error.captureStackTrace)
|
|
12
|
+
Error.captureStackTrace(this, new.target);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// source/errors/internal-error.ts
|
|
17
|
+
class InternalError extends AppError {
|
|
18
|
+
constructor(message, cause) {
|
|
19
|
+
super(message, cause);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { AppError, InternalError };
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
SINGLETON_MANAGER_ERROR_KEYS
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-y5dtkmnp.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
InternalError
|
|
7
|
+
} from "./chunk-jz3wd472.js";
|
|
8
8
|
|
|
9
9
|
// source/modules/singleton-manager/singleton-manager.ts
|
|
10
10
|
class SingletonManager {
|
|
11
11
|
static _registry = new Map;
|
|
12
12
|
static register(name, instance) {
|
|
13
13
|
if (this._registry.has(name))
|
|
14
|
-
throw new
|
|
14
|
+
throw new InternalError(SINGLETON_MANAGER_ERROR_KEYS.CLASS_INSTANCE_ALREADY_REGISTERED, { name });
|
|
15
15
|
this._registry.set(name, instance);
|
|
16
16
|
}
|
|
17
17
|
static unregister(name) {
|
|
18
18
|
if (!this._registry.has(name))
|
|
19
|
-
throw new
|
|
19
|
+
throw new InternalError(SINGLETON_MANAGER_ERROR_KEYS.CLASS_INSTANCE_NOT_REGISTERED, { name });
|
|
20
20
|
this._registry.delete(name);
|
|
21
21
|
}
|
|
22
22
|
static get(name) {
|
|
23
23
|
if (!this._registry.has(name))
|
|
24
|
-
throw new
|
|
24
|
+
throw new InternalError(SINGLETON_MANAGER_ERROR_KEYS.CLASS_INSTANCE_NOT_REGISTERED, { name });
|
|
25
25
|
return this._registry.get(name);
|
|
26
26
|
}
|
|
27
27
|
static has(name) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/schema-builder/utils/is-date-from-elysia-typebox.ts
|
|
3
|
+
import { KindGuard } from "@sinclair/typebox";
|
|
4
|
+
var isDateFromElysiaTypeBox = (schema) => KindGuard.IsUnion(schema) && schema.anyOf.length === 4 && schema.anyOf.some((item) => KindGuard.IsDate(item)) && schema.anyOf.some((item) => KindGuard.IsString(item) && item.format === "date-time") && schema.anyOf.some((item) => KindGuard.IsString(item) && item.format === "date") && schema.anyOf.some((item) => KindGuard.IsNumber(item));
|
|
5
|
+
|
|
6
|
+
// source/modules/schema-builder/utils/flatten.ts
|
|
7
|
+
import { KindGuard as KindGuard2 } from "@sinclair/typebox";
|
|
8
|
+
import { t } from "elysia";
|
|
9
|
+
var _flattenInto = (type, result) => {
|
|
10
|
+
if (KindGuard2.IsUnion(type))
|
|
11
|
+
for (const subType of type.anyOf)
|
|
12
|
+
_flattenInto(subType, result);
|
|
13
|
+
else
|
|
14
|
+
result.push(type);
|
|
15
|
+
};
|
|
16
|
+
var flatten = (type) => {
|
|
17
|
+
if (!KindGuard2.IsUnion(type))
|
|
18
|
+
return type;
|
|
19
|
+
const isAlreadyFlat = type.anyOf.every((subType) => !KindGuard2.IsUnion(subType));
|
|
20
|
+
if (isAlreadyFlat)
|
|
21
|
+
return type;
|
|
22
|
+
const result = [];
|
|
23
|
+
_flattenInto(type, result);
|
|
24
|
+
return t.Union(result);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { isDateFromElysiaTypeBox, flatten };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/singleton-manager/enums/singleton-manager-error-keys.ts
|
|
3
|
+
var SINGLETON_MANAGER_ERROR_KEYS = {
|
|
4
|
+
CLASS_INSTANCE_ALREADY_REGISTERED: "mrx.mrx-core.singleton-manager.error.class_instance_already_registered",
|
|
5
|
+
CLASS_INSTANCE_NOT_REGISTERED: "mrx.mrx-core.singleton-manager.error.class_instance_not_registered"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { SINGLETON_MANAGER_ERROR_KEYS };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/mailer/enums/mailer-error-keys.ts
|
|
3
|
+
var MAILER_ERROR_KEYS = {
|
|
4
|
+
SMTP_ALREADY_CONNECTED: "mrx.mrx-core.mailer.error.smtp.already_connected",
|
|
5
|
+
SMTP_CONNECTION_ERROR: "mrx.mrx-core.mailer.error.smtp.connection_error",
|
|
6
|
+
SMTP_NOT_CONNECTED: "mrx.mrx-core.mailer.error.smtp.not_connected"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { MAILER_ERROR_KEYS };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/jwt/enums/jwt-error-keys.ts
|
|
3
|
+
var JWT_ERROR_KEYS = {
|
|
4
|
+
JWT_EXPIRATION_PASSED: "mrx.mrx-core.jwt.error.expiration_passed",
|
|
5
|
+
JWT_SECRET_NOT_FOUND: "mrx.mrx-core.jwt.error.secret_not_found",
|
|
6
|
+
JWT_SIGN_ERROR: "mrx.mrx-core.jwt.error.sign_error"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { JWT_ERROR_KEYS };
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
HTTP_STATUS_CODES
|
|
4
4
|
} from "./chunk-sqts8vyk.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
AppError
|
|
7
|
+
} from "./chunk-jz3wd472.js";
|
|
8
8
|
|
|
9
9
|
// source/errors/http-error.ts
|
|
10
|
-
class HttpError extends
|
|
10
|
+
class HttpError extends AppError {
|
|
11
11
|
httpStatusCode;
|
|
12
12
|
constructor(message, a, b) {
|
|
13
13
|
const isStatus = typeof a === "number" || typeof a === "string" && a in HTTP_STATUS_CODES;
|