@mrxsys/mrx-core 2.11.0-2-and-276-20251029 → 2.11.0-4-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.
- package/dist/chunk-0d0zd2yg.js +8 -0
- package/dist/chunk-12qzn7jw.js +7 -0
- package/dist/chunk-441xs5k1.js +53 -0
- package/dist/chunk-4v86f7gp.js +59 -0
- package/dist/chunk-6w9ja96e.js +9 -0
- package/dist/chunk-7t524zqh.js +26 -0
- package/dist/chunk-8tffnbpn.js +7 -0
- package/dist/chunk-9cgzhc50.js +15 -0
- package/dist/chunk-9d3zvgp6.js +9 -0
- package/dist/chunk-9dzsj7f2.js +23 -0
- package/dist/chunk-9r5anep5.js +11 -0
- package/dist/chunk-afd82epa.js +201 -0
- package/dist/chunk-afyz8rg5.js +209 -0
- package/dist/chunk-dre2fgj0.js +7 -0
- package/dist/chunk-e30paw8a.js +101 -0
- package/dist/chunk-eeb7yskp.js +61 -0
- package/dist/chunk-fs3wm3p4.js +32 -0
- package/dist/chunk-grfyngq0.js +39 -0
- package/dist/chunk-gtn1kn0z.js +79 -0
- package/dist/chunk-jksb9ers.js +7 -0
- package/dist/chunk-m3grz32t.js +27 -0
- package/dist/chunk-mvrxngm7.js +41 -0
- package/dist/chunk-n0n14mf8.js +7 -0
- package/dist/chunk-p14h6jfs.js +365 -0
- package/dist/chunk-pjv1ekwr.js +284 -0
- package/dist/chunk-rz5p4j3p.js +13 -0
- package/dist/chunk-spnh9dzk.js +10 -0
- package/dist/chunk-sqts8vyk.js +60 -0
- package/dist/chunk-w7h898m3.js +14 -0
- package/dist/chunk-xhhj1gvj.js +9 -0
- package/dist/chunk-z0ct35ft.js +8 -0
- package/dist/errors/enums/index.js +7 -0
- package/dist/errors/index.js +12 -0
- package/dist/errors/utils/index.js +16 -0
- package/dist/errors/utils/is-nowarajs-error.ts.d.ts +2 -2
- package/dist/modules/data/enums/index.js +7 -0
- package/dist/modules/data/index.js +17 -0
- package/dist/modules/data/transformers/camel-case.d.ts +2 -2
- package/dist/modules/data/transformers/index.js +32 -0
- package/dist/modules/data/transformers/kebab-case.d.ts +2 -2
- package/dist/modules/data/transformers/pascal-case.d.ts +2 -2
- package/dist/modules/data/transformers/snake-case.d.ts +2 -2
- package/dist/modules/data/types/index.js +1 -0
- package/dist/modules/data/types/transform-object-keys.d.ts +4 -4
- package/dist/modules/database/enums/index.js +9 -0
- package/dist/modules/database/events/index.js +1 -0
- package/dist/modules/database/events/mssql-event-map.d.ts +1 -1
- package/dist/modules/database/events/table-event-map.d.ts +1 -1
- package/dist/modules/database/index.js +16 -0
- package/dist/modules/database/mssql.d.ts +2 -2
- package/dist/modules/database/table.d.ts +2 -2
- package/dist/modules/database/types/index.js +1 -0
- package/dist/modules/elysia/cache/cache.d.ts +1 -1
- package/dist/modules/elysia/cache/index.js +90 -0
- package/dist/modules/elysia/cache/types/index.js +1 -0
- package/dist/modules/elysia/crud/crud.d.ts +2 -2
- package/dist/modules/elysia/crud/enums/index.js +7 -0
- package/dist/modules/elysia/crud/index.js +153 -0
- package/dist/modules/elysia/crud/operations/count.d.ts +3 -3
- package/dist/modules/elysia/crud/operations/delete.d.ts +3 -3
- package/dist/modules/elysia/crud/operations/deleteOne.d.ts +3 -3
- package/dist/modules/elysia/crud/operations/find.d.ts +3 -3
- package/dist/modules/elysia/crud/operations/findOne.d.ts +3 -3
- package/dist/modules/elysia/crud/operations/index.js +34 -0
- package/dist/modules/elysia/crud/operations/insert.d.ts +3 -3
- package/dist/modules/elysia/crud/operations/update.d.ts +3 -3
- package/dist/modules/elysia/crud/operations/updateOne.d.ts +3 -3
- package/dist/modules/elysia/crud/operations/utils/get-db-injection.d.ts +1 -1
- package/dist/modules/elysia/crud/types/crud-options.d.ts +1 -1
- package/dist/modules/elysia/crud/types/crud-schema-models-type.d.ts +9 -9
- package/dist/modules/elysia/crud/types/delete-schema.d.ts +2 -2
- package/dist/modules/elysia/crud/types/find-schema.d.ts +3 -3
- package/dist/modules/elysia/crud/types/index.js +1 -0
- package/dist/modules/elysia/crud/types/insert-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/types/properties-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/types/response-200-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/types/update-schema.d.ts +2 -2
- package/dist/modules/elysia/crud/utils/create-adaptive-where-clause-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-count-response-200-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-count-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-delete-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-filters-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-find-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-id-param-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-insert-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-order-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-properties-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-q-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-response-200-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-selected-fields-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-update-one-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/create-update-schema.d.ts +1 -1
- package/dist/modules/elysia/crud/utils/index.js +41 -0
- package/dist/modules/elysia/db-resolver/db-resolver.d.ts +2 -2
- package/dist/modules/elysia/db-resolver/enums/index.js +7 -0
- package/dist/modules/elysia/db-resolver/index.js +18 -0
- package/dist/modules/elysia/error/enums/index.js +7 -0
- package/dist/modules/elysia/error/error.d.ts +5 -0
- package/dist/modules/elysia/error/index.d.ts +1 -1
- package/dist/modules/elysia/error/index.js +67 -0
- package/dist/modules/elysia/microservice/enums/index.js +7 -0
- package/dist/modules/elysia/microservice/index.js +100 -0
- package/dist/modules/elysia/rate-limit/enums/index.js +7 -0
- package/dist/modules/elysia/rate-limit/index.js +81 -0
- package/dist/modules/elysia/rate-limit/rate-limit.d.ts +1 -1
- package/dist/modules/elysia/rate-limit/types/index.js +1 -0
- package/dist/modules/jwt/enums/index.js +11 -0
- package/dist/modules/jwt/index.js +51 -0
- package/dist/modules/jwt/utils/index.js +9 -0
- package/dist/modules/kv-store/bun-redis/bun-redis-store.d.ts +1 -1
- package/dist/modules/kv-store/bun-redis/index.js +84 -0
- package/dist/modules/kv-store/enums/index.js +7 -0
- package/dist/modules/kv-store/ioredis/index.js +86 -0
- package/dist/modules/kv-store/ioredis/ioredis-store.d.ts +1 -1
- package/dist/modules/kv-store/memory/index.js +9 -0
- package/dist/modules/kv-store/memory/memory-store.d.ts +1 -1
- package/dist/modules/kv-store/types/index.js +1 -0
- package/dist/modules/logger/enums/index.js +7 -0
- package/dist/modules/logger/events/index.js +1 -0
- package/dist/modules/logger/events/logger-events.d.ts +1 -1
- package/dist/modules/logger/index.js +208 -0
- package/dist/modules/logger/logger.d.ts +1 -1
- package/dist/modules/logger/sinks/console-logger.d.ts +2 -2
- package/dist/modules/logger/sinks/devnull-logger.d.ts +1 -1
- package/dist/modules/logger/sinks/file-logger/file-logger.d.ts +2 -2
- package/dist/modules/logger/sinks/index.js +66 -0
- package/dist/modules/logger/types/index.js +1 -0
- package/dist/modules/mailer/enums/index.js +7 -0
- package/dist/modules/mailer/index.js +55 -0
- package/dist/modules/mailer/types/index.js +1 -0
- package/dist/modules/repository/index.js +12 -0
- package/dist/modules/repository/repository.d.ts +2 -2
- package/dist/modules/repository/types/index.js +1 -0
- package/dist/modules/repository/types/query-options.d.ts +1 -1
- package/dist/modules/singleton-manager/enums/index.js +7 -0
- package/dist/modules/singleton-manager/index.js +9 -0
- package/dist/modules/totp/enums/index.js +7 -0
- package/dist/modules/totp/index.js +104 -0
- package/dist/modules/totp/types/index.js +1 -0
- package/dist/modules/totp/utils/index.js +76 -0
- package/dist/modules/typed-event-emitter/index.js +7 -0
- package/dist/modules/typed-event-emitter/types/index.js +1 -0
- package/dist/shared/enums/index.js +7 -0
- package/dist/shared/types/index.js +1 -0
- package/dist/shared/utils/flatten.d.ts +1 -1
- package/dist/shared/utils/index.js +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/errors/enums/http-status-codes.ts
|
|
3
|
+
var HTTP_STATUS_CODES = {
|
|
4
|
+
CONTINUE: 100,
|
|
5
|
+
SWITCHING_PROTOCOLS: 101,
|
|
6
|
+
PROCESSING: 102,
|
|
7
|
+
EARLY_HINTS: 103,
|
|
8
|
+
OK: 200,
|
|
9
|
+
CREATED: 201,
|
|
10
|
+
ACCEPTED: 202,
|
|
11
|
+
NON_AUTHORITATIVE_INFORMATION: 203,
|
|
12
|
+
NO_CONTENT: 204,
|
|
13
|
+
RESET_CONTENT: 205,
|
|
14
|
+
PARTIAL_CONTENT: 206,
|
|
15
|
+
MULTI_STATUS: 207,
|
|
16
|
+
ALREADY_REPORTED: 208,
|
|
17
|
+
IM_USED: 226,
|
|
18
|
+
BAD_REQUEST: 400,
|
|
19
|
+
UNAUTHORIZED: 401,
|
|
20
|
+
PAYMENT_REQUIRED: 402,
|
|
21
|
+
FORBIDDEN: 403,
|
|
22
|
+
NOT_FOUND: 404,
|
|
23
|
+
METHOD_NOT_ALLOWED: 405,
|
|
24
|
+
NOT_ACCEPTABLE: 406,
|
|
25
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
26
|
+
REQUEST_TIMEOUT: 408,
|
|
27
|
+
CONFLICT: 409,
|
|
28
|
+
GONE: 410,
|
|
29
|
+
LENGTH_REQUIRED: 411,
|
|
30
|
+
PRECONDITION_FAILED: 412,
|
|
31
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
32
|
+
URI_TOO_LONG: 414,
|
|
33
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
34
|
+
RANGE_NOT_SATISFIABLE: 416,
|
|
35
|
+
EXPECTATION_FAILED: 417,
|
|
36
|
+
IM_A_TEAPOT: 418,
|
|
37
|
+
MISDIRECTED_REQUEST: 421,
|
|
38
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
39
|
+
LOCKED: 423,
|
|
40
|
+
FAILED_DEPENDENCY: 424,
|
|
41
|
+
TOO_EARLY: 425,
|
|
42
|
+
UPGRADE_REQUIRED: 426,
|
|
43
|
+
PRECONDITION_REQUIRED: 428,
|
|
44
|
+
TOO_MANY_REQUESTS: 429,
|
|
45
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
|
|
46
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
|
|
47
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
48
|
+
NOT_IMPLEMENTED: 501,
|
|
49
|
+
BAD_GATEWAY: 502,
|
|
50
|
+
SERVICE_UNAVAILABLE: 503,
|
|
51
|
+
GATEWAY_TIMEOUT: 504,
|
|
52
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
53
|
+
VARIANT_ALSO_NEGOTIATES: 506,
|
|
54
|
+
INSUFFICIENT_STORAGE: 507,
|
|
55
|
+
LOOP_DETECTED: 508,
|
|
56
|
+
NOT_EXTENDED: 510,
|
|
57
|
+
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { HTTP_STATUS_CODES };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/elysia/crud/enums/crud-success-keys.ts
|
|
3
|
+
var CRUD_SUCCESS_KEYS = {
|
|
4
|
+
COUNT_RESPONSE: "mrx-core.crud.success.count_response",
|
|
5
|
+
DELETE_RESPONSE: "mrx-core.crud.success.delete_response",
|
|
6
|
+
DELETE_ONE_RESPONSE: "mrx-core.crud.success.delete_one_response",
|
|
7
|
+
FIND_RESPONSE: "mrx-core.crud.success.find_response",
|
|
8
|
+
FIND_ONE_RESPONSE: "mrx-core.crud.success.find_one_response",
|
|
9
|
+
INSERT_RESPONSE: "mrx-core.crud.success.insert_response",
|
|
10
|
+
UPDATE_RESPONSE: "mrx-core.crud.success.update_response",
|
|
11
|
+
UPDATE_ONE_RESPONSE: "mrx-core.crud.success.update_one_response"
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { CRUD_SUCCESS_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-core.kv-store.error.closing_connection_failed",
|
|
5
|
+
CONNECTION_FAILED: "mrx-core.kv-store.error.connection_failed",
|
|
6
|
+
NOT_INTEGER: "mrx-core.kv-store.error.not_integer"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { KV_STORE_ERROR_KEYS };
|
|
@@ -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-core.singleton-manager.error.class_instance_already_registered",
|
|
5
|
+
CLASS_INSTANCE_NOT_REGISTERED: "mrx-core.singleton-manager.error.class_instance_not_registered"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { SINGLETON_MANAGER_ERROR_KEYS };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
HttpError
|
|
4
|
+
} from "../../chunk-7t524zqh.js";
|
|
5
|
+
import"../../chunk-sqts8vyk.js";
|
|
6
|
+
import {
|
|
7
|
+
BaseError
|
|
8
|
+
} from "../../chunk-9cgzhc50.js";
|
|
9
|
+
|
|
10
|
+
// source/errors/utils/is-nowarajs-error.ts.ts
|
|
11
|
+
var isBaseError = (e) => e instanceof BaseError;
|
|
12
|
+
var isHttpError = (e) => e instanceof HttpError;
|
|
13
|
+
export {
|
|
14
|
+
isHttpError,
|
|
15
|
+
isBaseError
|
|
16
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseError } from '
|
|
2
|
-
import { HttpError } from '
|
|
1
|
+
import { BaseError } from '../../errors/base-error';
|
|
2
|
+
import { HttpError } from '../../errors/http-error';
|
|
3
3
|
export declare const isBaseError: (e: unknown) => e is BaseError;
|
|
4
4
|
export declare const isHttpError: (e: unknown) => e is HttpError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
filterByKeyExclusion,
|
|
4
|
+
filterByKeyExclusionRecursive,
|
|
5
|
+
filterByKeyInclusion,
|
|
6
|
+
filterByValue,
|
|
7
|
+
transformKeys
|
|
8
|
+
} from "../../chunk-gtn1kn0z.js";
|
|
9
|
+
import"../../chunk-jksb9ers.js";
|
|
10
|
+
import"../../chunk-9cgzhc50.js";
|
|
11
|
+
export {
|
|
12
|
+
transformKeys,
|
|
13
|
+
filterByValue,
|
|
14
|
+
filterByKeyInclusion,
|
|
15
|
+
filterByKeyExclusionRecursive,
|
|
16
|
+
filterByKeyExclusion
|
|
17
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CamelCase } from '
|
|
2
|
-
import type { CaseTransformer } from '
|
|
1
|
+
import type { CamelCase } from '../../../modules/data/types/camel-case';
|
|
2
|
+
import type { CaseTransformer } from '../../../modules/data/types/case-transformer';
|
|
3
3
|
/**
|
|
4
4
|
* Transforms string into `camelCase` format.
|
|
5
5
|
* Implements ({@link CaseTransformer}).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// source/modules/data/transformers/camel-case.ts
|
|
3
|
+
class CamelCaseTransformer {
|
|
4
|
+
convertCase(str) {
|
|
5
|
+
return str.replace(/(?:[-_][a-z])/giu, (group) => group[1].toUpperCase()).replace(/^[A-Z]/u, (firstLetter) => firstLetter.toLowerCase());
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
// source/modules/data/transformers/kebab-case.ts
|
|
9
|
+
class KebabCaseTransformer {
|
|
10
|
+
convertCase(str) {
|
|
11
|
+
return str.replace(/_/gu, "-").replace(/(?<=[a-z])(?=[A-Z])/gu, "-").replace(/(?<=[A-Z]+)(?=[A-Z][a-z])/gu, "-").toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// source/modules/data/transformers/pascal-case.ts
|
|
15
|
+
class PascalCaseTransformer {
|
|
16
|
+
convertCase(str) {
|
|
17
|
+
const camelCaseKey = str.replace(/(?:[-_][a-z])/giu, (group) => group[1].toUpperCase());
|
|
18
|
+
return camelCaseKey.charAt(0).toUpperCase() + camelCaseKey.slice(1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// source/modules/data/transformers/snake-case.ts
|
|
22
|
+
class SnakeCaseTransformer {
|
|
23
|
+
convertCase(str) {
|
|
24
|
+
return str.replace(/(?<lower>[a-z])(?<upper>[A-Z])/gu, "$<lower>_$<upper>").replace(/[-\s]/gu, "_").toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
SnakeCaseTransformer,
|
|
29
|
+
PascalCaseTransformer,
|
|
30
|
+
KebabCaseTransformer,
|
|
31
|
+
CamelCaseTransformer
|
|
32
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CaseTransformer } from '
|
|
2
|
-
import type { KebabCase } from '
|
|
1
|
+
import type { CaseTransformer } from '../../../modules/data/types/case-transformer';
|
|
2
|
+
import type { KebabCase } from '../../../modules/data/types/kebab-case';
|
|
3
3
|
/**
|
|
4
4
|
* Transforms string into `kebab-case` format.
|
|
5
5
|
* Implements ({@link CaseTransformer}).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CaseTransformer } from '
|
|
2
|
-
import type { PascalCase } from '
|
|
1
|
+
import type { CaseTransformer } from '../../../modules/data/types/case-transformer';
|
|
2
|
+
import type { PascalCase } from '../../../modules/data/types/pascal-case';
|
|
3
3
|
/**
|
|
4
4
|
* Transforms string into `PascalCase` format.
|
|
5
5
|
* Implements ({@link CaseTransformer}).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CaseTransformer } from '
|
|
2
|
-
import type { SnakeCase } from '
|
|
1
|
+
import type { CaseTransformer } from '../../../modules/data/types/case-transformer';
|
|
2
|
+
import type { SnakeCase } from '../../../modules/data/types/snake-case';
|
|
3
3
|
/**
|
|
4
4
|
* Transforms string into `snake_case` format.
|
|
5
5
|
* Implements ({@link CaseTransformer}).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CamelCaseTransformer } from '
|
|
2
|
-
import type { KebabCaseTransformer } from '
|
|
3
|
-
import type { PascalCaseTransformer } from '
|
|
4
|
-
import type { SnakeCaseTransformer } from '
|
|
1
|
+
import type { CamelCaseTransformer } from '../../../modules/data/transformers/camel-case';
|
|
2
|
+
import type { KebabCaseTransformer } from '../../../modules/data/transformers/kebab-case';
|
|
3
|
+
import type { PascalCaseTransformer } from '../../../modules/data/transformers/pascal-case';
|
|
4
|
+
import type { SnakeCaseTransformer } from '../../../modules/data/transformers/snake-case';
|
|
5
5
|
import type { TransformKeysCamelCase } from './transform-keys-camel-case';
|
|
6
6
|
import type { TransformKeysKebabCase } from './transform-keys-kebab-case';
|
|
7
7
|
import type { TransformKeysPascalCase } from './transform-keys-pascal-case';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryContext } from '
|
|
1
|
+
import type { QueryContext } from '../../../modules/database/types/query-context';
|
|
2
2
|
export interface MssqlEventMap {
|
|
3
3
|
readonly query: [QueryContext];
|
|
4
4
|
readonly 'query:response': [unknown[], QueryContext];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryContext } from '
|
|
1
|
+
import type { QueryContext } from '../../../modules/database/types/query-context';
|
|
2
2
|
export interface TableEventMap {
|
|
3
3
|
readonly selected: [unknown, QueryContext];
|
|
4
4
|
readonly inserted: [unknown, QueryContext];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
MSSQL,
|
|
4
|
+
Table
|
|
5
|
+
} from "../../chunk-afd82epa.js";
|
|
6
|
+
import"../../chunk-afyz8rg5.js";
|
|
7
|
+
import"../../chunk-grfyngq0.js";
|
|
8
|
+
import"../../chunk-mvrxngm7.js";
|
|
9
|
+
import"../../chunk-4v86f7gp.js";
|
|
10
|
+
import"../../chunk-7t524zqh.js";
|
|
11
|
+
import"../../chunk-sqts8vyk.js";
|
|
12
|
+
import"../../chunk-9cgzhc50.js";
|
|
13
|
+
export {
|
|
14
|
+
Table,
|
|
15
|
+
MSSQL
|
|
16
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Knex } from 'knex';
|
|
2
|
-
import { Repository } from '
|
|
3
|
-
import { TypedEventEmitter } from '
|
|
2
|
+
import { Repository } from '../../modules/repository/repository';
|
|
3
|
+
import { TypedEventEmitter } from '../../modules/typed-event-emitter/typed-event-emitter';
|
|
4
4
|
import type { MssqlEventMap } from './events/mssql-event-map';
|
|
5
5
|
import { Table } from './table';
|
|
6
6
|
import type { MSSQLDatabaseOptions } from './types/mssql-database-option';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TableEventMap } from '
|
|
2
|
-
import { TypedEventEmitter } from '
|
|
1
|
+
import type { TableEventMap } from '../../modules/database/events/table-event-map';
|
|
2
|
+
import { TypedEventEmitter } from '../../modules/typed-event-emitter/typed-event-emitter';
|
|
3
3
|
/**
|
|
4
4
|
* Represents a database table and provides access to its metadata (name, fields, primary key).
|
|
5
5
|
* The class extends `TypedEventEmitter`<{@link TableEventMap}> to allow for event-driven programming.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
|
-
import type { KvStore } from '
|
|
2
|
+
import type { KvStore } from '../../../modules/kv-store/types/kv-store';
|
|
3
3
|
import type { CacheOptions } from './types/cache-options';
|
|
4
4
|
export declare const cache: (store?: KvStore) => Elysia<"", {
|
|
5
5
|
decorator: {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
MemoryStore
|
|
4
|
+
} from "../../../chunk-e30paw8a.js";
|
|
5
|
+
import"../../../chunk-xhhj1gvj.js";
|
|
6
|
+
import"../../../chunk-9cgzhc50.js";
|
|
7
|
+
|
|
8
|
+
// source/modules/elysia/cache/cache.ts
|
|
9
|
+
import { Elysia } from "elysia";
|
|
10
|
+
|
|
11
|
+
// source/modules/elysia/cache/utils/generate-cache-key.ts
|
|
12
|
+
var _calculateBodyHash = async (body, hasher) => {
|
|
13
|
+
if (!body)
|
|
14
|
+
return;
|
|
15
|
+
const reader = body.getReader();
|
|
16
|
+
try {
|
|
17
|
+
while (true) {
|
|
18
|
+
const { done, value } = await reader.read();
|
|
19
|
+
if (done)
|
|
20
|
+
break;
|
|
21
|
+
if (value)
|
|
22
|
+
hasher.update(new Uint8Array(value));
|
|
23
|
+
}
|
|
24
|
+
} finally {
|
|
25
|
+
reader.releaseLock();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var generateCacheKey = async (request) => {
|
|
29
|
+
const { method, url, headers } = request;
|
|
30
|
+
const hasher = new Bun.CryptoHasher("sha256");
|
|
31
|
+
hasher.update(method);
|
|
32
|
+
hasher.update(url);
|
|
33
|
+
hasher.update(JSON.stringify(headers));
|
|
34
|
+
await _calculateBodyHash(request.body, hasher);
|
|
35
|
+
return hasher.digest("hex");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// source/modules/elysia/cache/cache.ts
|
|
39
|
+
var cache = (store = new MemoryStore) => {
|
|
40
|
+
const cachedRoutes = new Map;
|
|
41
|
+
return new Elysia().onRequest(async ({ request, set }) => {
|
|
42
|
+
const route = `${request.method}:${new URL(request.url).pathname}`;
|
|
43
|
+
if (cachedRoutes.has(route)) {
|
|
44
|
+
const { ttl, prefix } = cachedRoutes.get(route);
|
|
45
|
+
const cacheKey = await generateCacheKey(request.clone());
|
|
46
|
+
const cacheItem = await store.get(`${prefix}${cacheKey}`);
|
|
47
|
+
if (cacheItem && typeof cacheItem === "object" && "response" in cacheItem && "metadata" in cacheItem) {
|
|
48
|
+
const createdAt = new Date(cacheItem.metadata.createdAt);
|
|
49
|
+
const expiresAt = new Date(createdAt.getTime() + ttl * 1000);
|
|
50
|
+
const now = Date.now();
|
|
51
|
+
const remaining = Math.max(0, Math.ceil((expiresAt.getTime() - now) / 1000));
|
|
52
|
+
set.headers["cache-control"] = `max-age=${remaining}, public`;
|
|
53
|
+
set.headers["etag"] = `"${prefix}${cacheKey}"`;
|
|
54
|
+
set.headers["last-modified"] = cacheItem.metadata.createdAt;
|
|
55
|
+
set.headers["expires"] = expiresAt.toUTCString();
|
|
56
|
+
set.headers["x-cache"] = "HIT";
|
|
57
|
+
if (cacheItem.response instanceof Response)
|
|
58
|
+
return cacheItem.response.clone();
|
|
59
|
+
return cacheItem.response;
|
|
60
|
+
}
|
|
61
|
+
set.headers["x-cache"] = "MISS";
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}).macro({
|
|
65
|
+
isCached: ({ ttl, prefix = "" }) => ({
|
|
66
|
+
async afterHandle({ set, responseValue, request }) {
|
|
67
|
+
const route = `${request.method}:${new URL(request.url).pathname}`;
|
|
68
|
+
if (!cachedRoutes.has(route))
|
|
69
|
+
cachedRoutes.set(route, { ttl, prefix });
|
|
70
|
+
const cacheKey = await generateCacheKey(request.clone());
|
|
71
|
+
const now = new Date;
|
|
72
|
+
set.headers["cache-control"] = `max-age=${ttl}, public`;
|
|
73
|
+
set.headers["etag"] = `"${prefix}${cacheKey}"`;
|
|
74
|
+
set.headers["last-modified"] = now.toUTCString();
|
|
75
|
+
set.headers["expires"] = new Date(now.getTime() + ttl * 1000).toUTCString();
|
|
76
|
+
set.headers["x-cache"] = "MISS";
|
|
77
|
+
const cacheItem = {
|
|
78
|
+
response: responseValue instanceof Response ? responseValue.clone() : responseValue,
|
|
79
|
+
metadata: {
|
|
80
|
+
createdAt: now.toUTCString()
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
await store.set(`${prefix}${cacheKey}`, cacheItem, ttl);
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
cache
|
|
90
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TObject, TString } from '@sinclair/typebox';
|
|
2
2
|
import { Elysia, type SingletonBase } from 'elysia';
|
|
3
|
-
import type { MSSQLDatabaseOptions } from '
|
|
4
|
-
import type { CrudSchemaModelsType } from '
|
|
3
|
+
import type { MSSQLDatabaseOptions } from '../../../modules/database/types/mssql-database-option';
|
|
4
|
+
import type { CrudSchemaModelsType } from '../../../modules/elysia/crud/types/crud-schema-models-type';
|
|
5
5
|
import type { CrudOperationCount } from './types/crud-operation-count';
|
|
6
6
|
import type { CrudOperationDelete } from './types/crud-operation-delete';
|
|
7
7
|
import type { CrudOperationDeleteOne } from './types/crud-operation-delete-one';
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
createCountResponse200Schema,
|
|
4
|
+
createCountSchema,
|
|
5
|
+
createDeleteSchema,
|
|
6
|
+
createFindSchema,
|
|
7
|
+
createIdParamSchema,
|
|
8
|
+
createInsertSchema,
|
|
9
|
+
createResponse200Schema,
|
|
10
|
+
createUpdateOneSchema,
|
|
11
|
+
createUpdateSchema
|
|
12
|
+
} from "../../../chunk-p14h6jfs.js";
|
|
13
|
+
import"../../../chunk-9dzsj7f2.js";
|
|
14
|
+
import {
|
|
15
|
+
batchDelete,
|
|
16
|
+
count,
|
|
17
|
+
deleteOne,
|
|
18
|
+
find,
|
|
19
|
+
findOne,
|
|
20
|
+
insert,
|
|
21
|
+
update,
|
|
22
|
+
updateOne
|
|
23
|
+
} from "../../../chunk-pjv1ekwr.js";
|
|
24
|
+
import"../../../chunk-441xs5k1.js";
|
|
25
|
+
import"../../../chunk-fs3wm3p4.js";
|
|
26
|
+
import"../../../chunk-z0ct35ft.js";
|
|
27
|
+
import"../../../chunk-8tffnbpn.js";
|
|
28
|
+
import"../../../chunk-w7h898m3.js";
|
|
29
|
+
import"../../../chunk-gtn1kn0z.js";
|
|
30
|
+
import"../../../chunk-jksb9ers.js";
|
|
31
|
+
import"../../../chunk-afd82epa.js";
|
|
32
|
+
import"../../../chunk-afyz8rg5.js";
|
|
33
|
+
import"../../../chunk-grfyngq0.js";
|
|
34
|
+
import"../../../chunk-mvrxngm7.js";
|
|
35
|
+
import"../../../chunk-4v86f7gp.js";
|
|
36
|
+
import"../../../chunk-7t524zqh.js";
|
|
37
|
+
import"../../../chunk-sqts8vyk.js";
|
|
38
|
+
import"../../../chunk-9cgzhc50.js";
|
|
39
|
+
|
|
40
|
+
// source/modules/elysia/crud/crud.ts
|
|
41
|
+
import { Elysia as Elysia2 } from "elysia";
|
|
42
|
+
|
|
43
|
+
// source/modules/elysia/crud/crud-schema.ts
|
|
44
|
+
import { Elysia } from "elysia";
|
|
45
|
+
var crudSchema = ({
|
|
46
|
+
sourceSchemaName,
|
|
47
|
+
sourceSchema,
|
|
48
|
+
sourceInsertSchema = sourceSchema,
|
|
49
|
+
sourceFindSchema = sourceSchema,
|
|
50
|
+
sourceCountSchema = sourceSchema,
|
|
51
|
+
sourceUpdateSchema = sourceSchema,
|
|
52
|
+
sourceDeleteSchema = sourceSchema,
|
|
53
|
+
sourceResponseSchema = sourceSchema,
|
|
54
|
+
operations = {
|
|
55
|
+
count: true,
|
|
56
|
+
find: true,
|
|
57
|
+
findOne: true,
|
|
58
|
+
insert: true,
|
|
59
|
+
update: true,
|
|
60
|
+
updateOne: true,
|
|
61
|
+
delete: true,
|
|
62
|
+
deleteOne: true
|
|
63
|
+
}
|
|
64
|
+
}) => {
|
|
65
|
+
const models = {};
|
|
66
|
+
if (operations.insert)
|
|
67
|
+
models[`${sourceSchemaName}Insert`] = createInsertSchema(sourceInsertSchema);
|
|
68
|
+
if (operations.find)
|
|
69
|
+
models[`${sourceSchemaName}Find`] = createFindSchema(sourceFindSchema);
|
|
70
|
+
if (operations.count)
|
|
71
|
+
models[`${sourceSchemaName}Count`] = createCountSchema(sourceCountSchema);
|
|
72
|
+
if (operations.update)
|
|
73
|
+
models[`${sourceSchemaName}Update`] = createUpdateSchema(sourceUpdateSchema);
|
|
74
|
+
if (operations.updateOne)
|
|
75
|
+
models[`${sourceSchemaName}UpdateOne`] = createUpdateOneSchema(sourceUpdateSchema);
|
|
76
|
+
if (operations.delete)
|
|
77
|
+
models[`${sourceSchemaName}Delete`] = createDeleteSchema(sourceDeleteSchema);
|
|
78
|
+
if (operations.findOne || operations.updateOne || operations.deleteOne)
|
|
79
|
+
models[`${sourceSchemaName}IdParam`] = createIdParamSchema();
|
|
80
|
+
if (operations.find || operations.findOne || operations.insert || operations.update || operations.updateOne || operations.delete || operations.deleteOne)
|
|
81
|
+
models[`${sourceSchemaName}Response200`] = createResponse200Schema(sourceResponseSchema);
|
|
82
|
+
if (operations.count)
|
|
83
|
+
models[`${sourceSchemaName}CountResponse200`] = createCountResponse200Schema();
|
|
84
|
+
const app = new Elysia({
|
|
85
|
+
name: `crudSchemaPlugin-${sourceSchemaName}`
|
|
86
|
+
}).model(models);
|
|
87
|
+
return app;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// source/modules/elysia/crud/crud.ts
|
|
91
|
+
var crud = ({
|
|
92
|
+
database,
|
|
93
|
+
tableName,
|
|
94
|
+
schema,
|
|
95
|
+
operations = {
|
|
96
|
+
find: true,
|
|
97
|
+
findOne: true,
|
|
98
|
+
insert: true,
|
|
99
|
+
update: true,
|
|
100
|
+
updateOne: true,
|
|
101
|
+
delete: true,
|
|
102
|
+
deleteOne: true,
|
|
103
|
+
count: true
|
|
104
|
+
},
|
|
105
|
+
tags = [tableName],
|
|
106
|
+
prefix = ""
|
|
107
|
+
}) => {
|
|
108
|
+
const app = new Elysia2({
|
|
109
|
+
name: `crudPlugin[${tableName}]`,
|
|
110
|
+
tags,
|
|
111
|
+
prefix
|
|
112
|
+
}).use(crudSchema({
|
|
113
|
+
sourceSchemaName: tableName,
|
|
114
|
+
sourceSchema: schema.sourceSchema,
|
|
115
|
+
sourceInsertSchema: schema.sourceInsertSchema || schema.sourceSchema,
|
|
116
|
+
sourceFindSchema: schema.sourceFindSchema || schema.sourceSchema,
|
|
117
|
+
sourceCountSchema: schema.sourceCountSchema || schema.sourceSchema,
|
|
118
|
+
sourceUpdateSchema: schema.sourceUpdateSchema || schema.sourceSchema,
|
|
119
|
+
sourceDeleteSchema: schema.sourceDeleteSchema || schema.sourceSchema,
|
|
120
|
+
sourceResponseSchema: schema.sourceResponseSchema || schema.sourceSchema,
|
|
121
|
+
operations: {
|
|
122
|
+
find: operations.find ? true : false,
|
|
123
|
+
findOne: operations.findOne ? true : false,
|
|
124
|
+
insert: operations.insert ? true : false,
|
|
125
|
+
update: operations.update ? true : false,
|
|
126
|
+
updateOne: operations.updateOne ? true : false,
|
|
127
|
+
delete: operations.delete ? true : false,
|
|
128
|
+
deleteOne: operations.deleteOne ? true : false,
|
|
129
|
+
count: operations.count ? true : false
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
if (operations.insert)
|
|
133
|
+
app.use(insert(database, tableName, operations.insert && typeof operations.insert === "object" ? operations.insert : {}));
|
|
134
|
+
if (operations.find)
|
|
135
|
+
app.use(find(database, tableName, operations.find && typeof operations.find === "object" ? operations.find : {}));
|
|
136
|
+
if (operations.findOne)
|
|
137
|
+
app.use(findOne(database, tableName, operations.findOne && typeof operations.findOne === "object" ? operations.findOne : {}));
|
|
138
|
+
if (operations.update)
|
|
139
|
+
app.use(update(database, tableName, operations.update && typeof operations.update === "object" ? operations.update : {}));
|
|
140
|
+
if (operations.updateOne)
|
|
141
|
+
app.use(updateOne(database, tableName, operations.updateOne && typeof operations.updateOne === "object" ? operations.updateOne : {}));
|
|
142
|
+
if (operations.delete)
|
|
143
|
+
app.use(batchDelete(database, tableName, operations.delete && typeof operations.delete === "object" ? operations.delete : {}));
|
|
144
|
+
if (operations.deleteOne)
|
|
145
|
+
app.use(deleteOne(database, tableName, operations.deleteOne && typeof operations.deleteOne === "object" ? operations.deleteOne : {}));
|
|
146
|
+
if (operations.count)
|
|
147
|
+
app.use(count(database, tableName, operations.count && typeof operations.count === "object" ? operations.count : {}));
|
|
148
|
+
return app;
|
|
149
|
+
};
|
|
150
|
+
export {
|
|
151
|
+
crudSchema,
|
|
152
|
+
crud
|
|
153
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TObject } from '@sinclair/typebox/type';
|
|
2
2
|
import { Elysia } from 'elysia';
|
|
3
|
-
import type { MSSQL } from '
|
|
4
|
-
import type { MSSQLDatabaseOptions } from '
|
|
5
|
-
import type { CrudOperationCount } from '
|
|
3
|
+
import type { MSSQL } from '../../../../modules/database/mssql';
|
|
4
|
+
import type { MSSQLDatabaseOptions } from '../../../../modules/database/types/mssql-database-option';
|
|
5
|
+
import type { CrudOperationCount } from '../../../../modules/elysia/crud/types/crud-operation-count';
|
|
6
6
|
export declare const count: <const TDatabase extends Omit<MSSQLDatabaseOptions, "databaseName"> | string, const TTableName extends string, const THeaderSchema extends TObject, const TSourceCountSchema extends TObject>(database: TDatabase, tableName: TTableName, { hook, method, path }: CrudOperationCount<THeaderSchema, TSourceCountSchema>) => Elysia<"", {
|
|
7
7
|
decorator: {};
|
|
8
8
|
store: {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TObject } from '@sinclair/typebox/type';
|
|
2
2
|
import { Elysia } from 'elysia';
|
|
3
|
-
import type { MSSQL } from '
|
|
4
|
-
import type { MSSQLDatabaseOptions } from '
|
|
5
|
-
import type { CrudOperationDelete } from '
|
|
3
|
+
import type { MSSQL } from '../../../../modules/database/mssql';
|
|
4
|
+
import type { MSSQLDatabaseOptions } from '../../../../modules/database/types/mssql-database-option';
|
|
5
|
+
import type { CrudOperationDelete } from '../../../../modules/elysia/crud/types/crud-operation-delete';
|
|
6
6
|
export declare const batchDelete: <const TDatabase extends Omit<MSSQLDatabaseOptions, "databaseName"> | string, const TTableName extends string, const THeaderSchema extends TObject, const TSourceDeleteSchema extends TObject, const TSourceResponseSchema extends TObject>(database: TDatabase, tableName: TTableName, { hook, method, path }: CrudOperationDelete<THeaderSchema, TSourceDeleteSchema, TSourceResponseSchema>) => Elysia<"", {
|
|
7
7
|
decorator: {};
|
|
8
8
|
store: {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TObject } from '@sinclair/typebox/type';
|
|
2
2
|
import { Elysia } from 'elysia';
|
|
3
|
-
import type { MSSQL } from '
|
|
4
|
-
import type { MSSQLDatabaseOptions } from '
|
|
5
|
-
import type { CrudOperationDeleteOne } from '
|
|
3
|
+
import type { MSSQL } from '../../../../modules/database/mssql';
|
|
4
|
+
import type { MSSQLDatabaseOptions } from '../../../../modules/database/types/mssql-database-option';
|
|
5
|
+
import type { CrudOperationDeleteOne } from '../../../../modules/elysia/crud/types/crud-operation-delete-one';
|
|
6
6
|
export declare const deleteOne: <const TDatabase extends Omit<MSSQLDatabaseOptions, "databaseName"> | string, const TTableName extends string, const THeaderSchema extends TObject, const TSourceResponseSchema extends TObject>(database: TDatabase, tableName: TTableName, { hook, method, path }: CrudOperationDeleteOne<THeaderSchema, TSourceResponseSchema>) => Elysia<"", {
|
|
7
7
|
decorator: {};
|
|
8
8
|
store: {};
|