@tstdl/base 0.93.86 → 0.93.89
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/ai/genkit/helpers.d.ts +3 -1
- package/ai/genkit/helpers.js +3 -3
- package/api/server/gateway.d.ts +3 -0
- package/api/server/gateway.js +15 -4
- package/api/server/middlewares/catch-error.middleware.js +2 -4
- package/api/server/middlewares/cors.middleware.js +2 -3
- package/api/server/middlewares/csrf.middleware.d.ts +41 -0
- package/api/server/middlewares/csrf.middleware.js +108 -0
- package/api/server/middlewares/index.d.ts +1 -0
- package/api/server/middlewares/index.js +1 -0
- package/api/server/module.d.ts +8 -2
- package/api/server/module.js +14 -8
- package/api/server/tests/csrf.middleware.test.js +91 -0
- package/audit/drizzle/{0000_bored_stick.sql → 0000_lumpy_thunderball.sql} +3 -3
- package/audit/drizzle/meta/0000_snapshot.json +4 -4
- package/audit/drizzle/meta/_journal.json +2 -9
- package/audit/module.d.ts +4 -1
- package/audit/module.js +3 -2
- package/audit/schemas.d.ts +1 -1
- package/audit/types.d.ts +1 -1
- package/audit/types.js +1 -1
- package/authentication/client/authentication.service.d.ts +14 -1
- package/authentication/client/authentication.service.js +82 -23
- package/authentication/client/http-client.middleware.d.ts +6 -0
- package/authentication/client/http-client.middleware.js +36 -0
- package/authentication/client/module.js +8 -2
- package/authentication/models/service-account.model.d.ts +2 -2
- package/authentication/models/service-account.model.js +10 -5
- package/authentication/models/subject.model.d.ts +19 -5
- package/authentication/models/subject.model.js +25 -29
- package/authentication/models/system-account.model.d.ts +3 -2
- package/authentication/models/system-account.model.js +11 -5
- package/authentication/models/user.model.d.ts +2 -11
- package/authentication/models/user.model.js +5 -16
- package/authentication/server/authentication-api-request-token.provider.d.ts +0 -2
- package/authentication/server/authentication-api-request-token.provider.js +3 -11
- package/authentication/server/authentication.api-controller.d.ts +1 -2
- package/authentication/server/authentication.api-controller.js +8 -9
- package/authentication/server/authentication.audit.d.ts +3 -2
- package/authentication/server/authentication.service.d.ts +27 -1
- package/authentication/server/authentication.service.js +67 -18
- package/authentication/server/drizzle/{0000_normal_paper_doll.sql → 0000_soft_tag.sql} +25 -32
- package/authentication/server/drizzle/meta/0000_snapshot.json +180 -205
- package/authentication/server/drizzle/meta/_journal.json +2 -2
- package/authentication/server/helper.js +9 -2
- package/authentication/server/module.d.ts +4 -1
- package/authentication/server/module.js +9 -5
- package/authentication/server/schemas.d.ts +2 -1
- package/authentication/server/schemas.js +2 -2
- package/authentication/server/subject.service.d.ts +14 -8
- package/authentication/server/subject.service.js +86 -84
- package/authentication/tests/authentication-ancillary.service.test.d.ts +1 -0
- package/authentication/tests/authentication-ancillary.service.test.js +13 -0
- package/authentication/tests/authentication-secret-requirements.validator.test.d.ts +1 -0
- package/authentication/tests/authentication-secret-requirements.validator.test.js +29 -0
- package/authentication/tests/authentication.api-controller.test.d.ts +1 -0
- package/authentication/tests/authentication.api-controller.test.js +88 -0
- package/authentication/tests/authentication.api-request-token.provider.test.d.ts +1 -0
- package/authentication/tests/authentication.api-request-token.provider.test.js +48 -0
- package/authentication/tests/authentication.client-middleware.test.d.ts +1 -0
- package/authentication/tests/authentication.client-middleware.test.js +23 -0
- package/authentication/tests/authentication.client-service.test.d.ts +1 -0
- package/authentication/tests/authentication.client-service.test.js +70 -0
- package/authentication/tests/authentication.service.test.d.ts +1 -0
- package/authentication/tests/authentication.service.test.js +186 -0
- package/authentication/tests/authentication.test-ancillary-service.d.ts +9 -0
- package/authentication/tests/authentication.test-ancillary-service.js +27 -0
- package/authentication/tests/helper.test.d.ts +1 -0
- package/authentication/tests/helper.test.js +107 -0
- package/authentication/tests/secret-requirements.error.test.d.ts +1 -0
- package/authentication/tests/secret-requirements.error.test.js +14 -0
- package/authentication/tests/subject.service.test.d.ts +1 -0
- package/authentication/tests/subject.service.test.js +140 -0
- package/circuit-breaker/postgres/drizzle/meta/0000_snapshot.json +1 -1
- package/circuit-breaker/postgres/drizzle/meta/_journal.json +2 -2
- package/circuit-breaker/postgres/module.d.ts +7 -1
- package/circuit-breaker/postgres/module.js +8 -6
- package/circuit-breaker/tests/circuit-breaker.test.js +2 -22
- package/document-management/api/document-management.api.js +2 -6
- package/document-management/server/services/document-validation.service.js +6 -5
- package/document-management/server/services/document-workflow.service.js +5 -5
- package/document-management/service-models/document-folders.view-model.d.ts +5 -2
- package/document-management/service-models/document-folders.view-model.js +42 -9
- package/document-management/service-models/enriched/enriched-document-management-data.view.js +1 -1
- package/examples/document-management/main.js +4 -4
- package/http/client/adapters/undici.adapter.d.ts +7 -5
- package/http/client/adapters/undici.adapter.js +13 -10
- package/http/client/module.d.ts +3 -1
- package/http/client/module.js +8 -9
- package/http/server/http-server.d.ts +2 -0
- package/http/server/node/module.d.ts +6 -2
- package/http/server/node/module.js +6 -4
- package/http/server/node/node-http-server.d.ts +2 -0
- package/http/server/node/node-http-server.js +7 -0
- package/http/types.d.ts +1 -1
- package/key-value-store/postgres/module.d.ts +7 -1
- package/key-value-store/postgres/module.js +7 -3
- package/lock/postgres/lock.js +0 -1
- package/lock/postgres/module.d.ts +7 -1
- package/lock/postgres/module.js +9 -5
- package/logger/formatter.d.ts +2 -0
- package/logger/formatters/json.js +2 -2
- package/logger/formatters/pretty-print.js +8 -10
- package/logger/logger.d.ts +1 -1
- package/logger/logger.js +15 -12
- package/message-bus/local/module.d.ts +5 -2
- package/message-bus/local/module.js +5 -4
- package/module/module.d.ts +2 -1
- package/module/module.js +3 -0
- package/module/modules/web-server.module.d.ts +11 -6
- package/module/modules/web-server.module.js +15 -10
- package/orm/decorators.d.ts +24 -1
- package/orm/decorators.js +40 -4
- package/orm/index.d.ts +1 -1
- package/orm/index.js +1 -1
- package/orm/query/base.d.ts +17 -17
- package/orm/query/base.js +1 -1
- package/orm/repository.types.d.ts +46 -2
- package/orm/schemas/tsvector.js +1 -1
- package/orm/server/drizzle/schema-converter.d.ts +3 -1
- package/orm/server/drizzle/schema-converter.js +120 -14
- package/orm/server/index.d.ts +1 -0
- package/orm/server/index.js +1 -0
- package/orm/server/module.d.ts +4 -2
- package/orm/server/module.js +6 -5
- package/orm/server/query-converter.d.ts +6 -3
- package/orm/server/query-converter.js +33 -21
- package/orm/server/repository-config.d.ts +8 -0
- package/orm/server/repository-config.js +8 -0
- package/orm/server/repository.d.ts +117 -43
- package/orm/server/repository.js +758 -254
- package/orm/server/transaction.d.ts +4 -2
- package/orm/server/transaction.js +14 -5
- package/orm/server/transactional.d.ts +6 -2
- package/orm/server/transactional.js +39 -9
- package/orm/server/types.d.ts +2 -0
- package/orm/sqls/case-when.d.ts +25 -0
- package/orm/sqls/case-when.js +54 -0
- package/orm/sqls/index.d.ts +2 -0
- package/orm/sqls/index.js +2 -0
- package/orm/{sqls.d.ts → sqls/sqls.d.ts} +67 -19
- package/orm/{sqls.js → sqls/sqls.js} +116 -22
- package/orm/tests/data-types.test.d.ts +1 -0
- package/orm/tests/data-types.test.js +39 -0
- package/orm/tests/decorators.test.d.ts +1 -0
- package/orm/tests/decorators.test.js +77 -0
- package/orm/tests/encryption.test.d.ts +1 -0
- package/orm/tests/encryption.test.js +34 -0
- package/orm/tests/query-complex.test.d.ts +1 -0
- package/orm/tests/query-complex.test.js +203 -0
- package/orm/tests/query-converter-complex.test.d.ts +1 -0
- package/orm/tests/query-converter-complex.test.js +126 -0
- package/orm/tests/query-converter.test.d.ts +1 -0
- package/orm/tests/query-converter.test.js +123 -0
- package/orm/tests/repository-advanced.test.d.ts +1 -0
- package/orm/tests/repository-advanced.test.js +232 -0
- package/orm/tests/repository-attributes.test.d.ts +1 -0
- package/orm/tests/repository-attributes.test.js +99 -0
- package/orm/tests/repository-comprehensive.test.d.ts +1 -0
- package/orm/tests/repository-comprehensive.test.js +187 -0
- package/orm/tests/repository-coverage.test.d.ts +1 -0
- package/orm/tests/repository-coverage.test.js +303 -0
- package/orm/tests/repository-cti-complex.test.d.ts +1 -0
- package/orm/tests/repository-cti-complex.test.js +170 -0
- package/orm/tests/repository-cti-embedded.test.d.ts +1 -0
- package/orm/tests/repository-cti-embedded.test.js +188 -0
- package/orm/tests/repository-cti-extensive.test.d.ts +1 -0
- package/orm/tests/repository-cti-extensive.test.js +308 -0
- package/orm/tests/repository-cti-mapping.test.d.ts +1 -0
- package/orm/tests/repository-cti-mapping.test.js +121 -0
- package/orm/tests/repository-cti-search.test.d.ts +1 -0
- package/orm/tests/repository-cti-search.test.js +152 -0
- package/orm/tests/repository-cti-soft-delete.test.d.ts +1 -0
- package/orm/tests/repository-cti-soft-delete.test.js +115 -0
- package/orm/tests/repository-cti-transactions.test.d.ts +1 -0
- package/orm/tests/repository-cti-transactions.test.js +126 -0
- package/orm/tests/repository-cti-upsert-many.test.d.ts +1 -0
- package/orm/tests/repository-cti-upsert-many.test.js +127 -0
- package/orm/tests/repository-cti.test.d.ts +1 -0
- package/orm/tests/repository-cti.test.js +456 -0
- package/orm/tests/repository-edge-cases.test.d.ts +1 -0
- package/orm/tests/repository-edge-cases.test.js +216 -0
- package/orm/tests/repository-expiration.test.d.ts +1 -0
- package/orm/tests/repository-expiration.test.js +153 -0
- package/orm/tests/repository-extra-coverage.test.d.ts +1 -0
- package/orm/tests/repository-extra-coverage.test.js +546 -0
- package/orm/tests/repository-mapping.test.d.ts +1 -0
- package/orm/tests/repository-mapping.test.js +71 -0
- package/orm/tests/repository-regression.test.d.ts +1 -0
- package/orm/tests/repository-regression.test.js +330 -0
- package/orm/tests/repository-search-coverage.test.d.ts +1 -0
- package/orm/tests/repository-search-coverage.test.js +129 -0
- package/orm/tests/repository-search.test.d.ts +1 -0
- package/orm/tests/repository-search.test.js +116 -0
- package/orm/tests/repository-soft-delete.test.d.ts +1 -0
- package/orm/tests/repository-soft-delete.test.js +143 -0
- package/orm/tests/repository-transactions-nested.test.d.ts +1 -0
- package/orm/tests/repository-transactions-nested.test.js +202 -0
- package/orm/tests/repository-types.test.d.ts +1 -0
- package/orm/tests/repository-types.test.js +218 -0
- package/orm/tests/schema-converter.test.d.ts +1 -0
- package/orm/tests/schema-converter.test.js +81 -0
- package/orm/tests/schema-generation.test.d.ts +1 -0
- package/orm/tests/schema-generation.test.js +127 -0
- package/orm/tests/sql-helpers.test.d.ts +1 -0
- package/orm/tests/sql-helpers.test.js +67 -0
- package/orm/tests/transaction-safety.test.d.ts +1 -0
- package/orm/tests/transaction-safety.test.js +81 -0
- package/orm/tests/transactional.test.d.ts +1 -0
- package/orm/tests/transactional.test.js +224 -0
- package/orm/tests/utils.test.d.ts +1 -0
- package/orm/tests/utils.test.js +70 -0
- package/orm/utils.d.ts +7 -0
- package/orm/utils.js +26 -6
- package/package.json +12 -7
- package/pool/pool.js +1 -1
- package/rate-limit/index.d.ts +2 -0
- package/rate-limit/index.js +2 -0
- package/rate-limit/postgres/drizzle/0000_watery_rage.sql +7 -0
- package/{queue → rate-limit}/postgres/drizzle/meta/0000_snapshot.json +14 -39
- package/rate-limit/postgres/drizzle/meta/_journal.json +13 -0
- package/{queue → rate-limit}/postgres/drizzle.config.js +1 -1
- package/rate-limit/postgres/index.d.ts +4 -0
- package/rate-limit/postgres/index.js +4 -0
- package/rate-limit/postgres/module.d.ts +12 -0
- package/rate-limit/postgres/module.js +28 -0
- package/rate-limit/postgres/postgres-rate-limiter.d.ts +9 -0
- package/rate-limit/postgres/postgres-rate-limiter.js +56 -0
- package/rate-limit/postgres/rate-limit.model.d.ts +8 -0
- package/rate-limit/postgres/rate-limit.model.js +35 -0
- package/rate-limit/postgres/rate-limiter.provider.d.ts +6 -0
- package/rate-limit/postgres/rate-limiter.provider.js +21 -0
- package/rate-limit/postgres/schemas.d.ts +3 -0
- package/rate-limit/postgres/schemas.js +4 -0
- package/rate-limit/provider.d.ts +9 -0
- package/rate-limit/provider.js +2 -0
- package/rate-limit/rate-limiter.d.ts +35 -0
- package/rate-limit/rate-limiter.js +3 -0
- package/rate-limit/tests/postgres-rate-limiter.test.d.ts +1 -0
- package/rate-limit/tests/postgres-rate-limiter.test.js +92 -0
- package/signals/implementation/configure.d.ts +3 -0
- package/signals/implementation/configure.js +3 -0
- package/sse/data-stream-source.d.ts +1 -1
- package/sse/data-stream-source.js +6 -6
- package/task-queue/enqueue-batch.d.ts +17 -0
- package/task-queue/enqueue-batch.js +24 -0
- package/{queue → task-queue}/index.d.ts +1 -1
- package/{queue → task-queue}/index.js +1 -1
- package/task-queue/postgres/drizzle/0000_thin_black_panther.sql +74 -0
- package/task-queue/postgres/drizzle/meta/0000_snapshot.json +592 -0
- package/task-queue/postgres/drizzle/meta/_journal.json +13 -0
- package/task-queue/postgres/drizzle.config.d.ts +2 -0
- package/task-queue/postgres/drizzle.config.js +11 -0
- package/task-queue/postgres/index.d.ts +4 -0
- package/task-queue/postgres/index.js +4 -0
- package/task-queue/postgres/module.d.ts +12 -0
- package/task-queue/postgres/module.js +28 -0
- package/task-queue/postgres/schemas.d.ts +16 -0
- package/task-queue/postgres/schemas.js +8 -0
- package/task-queue/postgres/task-queue.d.ts +83 -0
- package/task-queue/postgres/task-queue.js +1054 -0
- package/task-queue/postgres/task-queue.provider.d.ts +7 -0
- package/{queue/postgres/queue.provider.js → task-queue/postgres/task-queue.provider.js} +8 -8
- package/task-queue/postgres/task.model.d.ts +39 -0
- package/task-queue/postgres/task.model.js +178 -0
- package/{queue → task-queue}/provider.d.ts +3 -3
- package/task-queue/provider.js +2 -0
- package/{queue → task-queue}/task-context.d.ts +7 -7
- package/{queue → task-queue}/task-context.js +8 -8
- package/{queue/queue.d.ts → task-queue/task-queue.d.ts} +128 -59
- package/task-queue/task-queue.js +200 -0
- package/task-queue/tests/complex.test.d.ts +1 -0
- package/task-queue/tests/complex.test.js +299 -0
- package/task-queue/tests/dependencies.test.d.ts +1 -0
- package/task-queue/tests/dependencies.test.js +174 -0
- package/task-queue/tests/queue.test.d.ts +1 -0
- package/task-queue/tests/queue.test.js +334 -0
- package/task-queue/tests/worker.test.d.ts +1 -0
- package/task-queue/tests/worker.test.js +163 -0
- package/test1.js +1 -1
- package/test4.js +2 -2
- package/unit-test/index.d.ts +1 -0
- package/unit-test/index.js +1 -0
- package/unit-test/integration-setup.d.ts +55 -0
- package/unit-test/integration-setup.js +182 -0
- package/utils/patterns.d.ts +3 -0
- package/utils/patterns.js +6 -1
- package/audit/drizzle/0001_previous_network.sql +0 -2
- package/audit/drizzle/meta/0001_snapshot.json +0 -195
- package/queue/enqueue-batch.d.ts +0 -17
- package/queue/enqueue-batch.js +0 -18
- package/queue/postgres/drizzle/0000_zippy_moondragon.sql +0 -11
- package/queue/postgres/drizzle/0001_certain_wild_pack.sql +0 -2
- package/queue/postgres/drizzle/0002_dear_meggan.sql +0 -2
- package/queue/postgres/drizzle/0003_tricky_venom.sql +0 -30
- package/queue/postgres/drizzle/meta/0001_snapshot.json +0 -103
- package/queue/postgres/drizzle/meta/0002_snapshot.json +0 -90
- package/queue/postgres/drizzle/meta/0003_snapshot.json +0 -288
- package/queue/postgres/drizzle/meta/_journal.json +0 -34
- package/queue/postgres/index.d.ts +0 -4
- package/queue/postgres/index.js +0 -4
- package/queue/postgres/module.d.ts +0 -9
- package/queue/postgres/module.js +0 -29
- package/queue/postgres/queue.d.ts +0 -60
- package/queue/postgres/queue.js +0 -681
- package/queue/postgres/queue.provider.d.ts +0 -7
- package/queue/postgres/schemas.d.ts +0 -14
- package/queue/postgres/schemas.js +0 -6
- package/queue/postgres/task.model.d.ts +0 -24
- package/queue/postgres/task.model.js +0 -115
- package/queue/provider.js +0 -2
- package/queue/queue.js +0 -131
- package/queue/tests/queue.test.js +0 -623
- package/test3.d.ts +0 -1
- package/test3.js +0 -47
- /package/{queue/tests/queue.test.d.ts → api/server/tests/csrf.middleware.test.d.ts} +0 -0
- /package/circuit-breaker/postgres/drizzle/{0000_hard_shocker.sql → 0000_cooing_korath.sql} +0 -0
- /package/{queue → rate-limit}/postgres/drizzle.config.d.ts +0 -0
package/logger/logger.js
CHANGED
|
@@ -11,7 +11,7 @@ import { toArray } from '../utils/array/array.js';
|
|
|
11
11
|
import { now } from '../utils/date-time.js';
|
|
12
12
|
import { getCachedDereference } from '../utils/object/dereference.js';
|
|
13
13
|
import { hasOwnProperty } from '../utils/object/object.js';
|
|
14
|
-
import { isArray, isNotArray, isObject, isString } from '../utils/type-guards.js';
|
|
14
|
+
import { isArray, isError, isNotArray, isObject, isString } from '../utils/type-guards.js';
|
|
15
15
|
import { LogLevel } from './level.js';
|
|
16
16
|
import { LogManager } from './manager.js';
|
|
17
17
|
const { getCurrentLoggerCreationContext, runInLoggerCreationContext, isInLoggerCreationContext } = createContextProvider('LoggerCreation');
|
|
@@ -21,14 +21,12 @@ let Logger = Logger_1 = class Logger {
|
|
|
21
21
|
module = getCurrentLoggerCreationContext()?.module ?? moduleFromArgument(this.#argument);
|
|
22
22
|
context = getCurrentLoggerCreationContext()?.context ?? ((isObject(this.#argument) && isNotArray(this.#argument)) ? (this.#argument.context ?? {}) : {});
|
|
23
23
|
level = isInLoggerCreationContext() ? getCurrentLoggerCreationContext().level : (isObject(this.#argument) && isNotArray(this.#argument)) ? this.#argument.level : undefined;
|
|
24
|
-
error(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this._log(LogLevel.Error, message, { ...context, error: errorOrMessage });
|
|
31
|
-
}
|
|
24
|
+
error(messageOrError, errorOrContext, contextOrNothing) {
|
|
25
|
+
const messageOrErrorIsString = isString(messageOrError);
|
|
26
|
+
const message = messageOrErrorIsString ? messageOrError : isError(messageOrError) ? messageOrError.message : 'Error';
|
|
27
|
+
const error = messageOrErrorIsString ? errorOrContext : messageOrError;
|
|
28
|
+
const context = messageOrErrorIsString ? contextOrNothing : errorOrContext;
|
|
29
|
+
this._log(LogLevel.Error, message, context, error);
|
|
32
30
|
}
|
|
33
31
|
warn(message, context) {
|
|
34
32
|
this._log(LogLevel.Warn, message, context);
|
|
@@ -66,19 +64,21 @@ let Logger = Logger_1 = class Logger {
|
|
|
66
64
|
};
|
|
67
65
|
return runInLoggerCreationContext(creationContext, () => new Logger_1());
|
|
68
66
|
}
|
|
69
|
-
_log(level, message, context = {}) {
|
|
67
|
+
_log(level, message, context = {}, error) {
|
|
70
68
|
const moduleLevel = this.level ?? this.#manager.getModuleLevel(this.module);
|
|
71
69
|
if (level > moduleLevel) {
|
|
72
70
|
return;
|
|
73
71
|
}
|
|
74
72
|
const effectiveContext = { ...this.context, ...context };
|
|
75
|
-
const finalMessage = interpolateMessage(message, effectiveContext);
|
|
73
|
+
const { keys, interpolated: finalMessage } = interpolateMessage(message, effectiveContext);
|
|
76
74
|
const payload = {
|
|
77
75
|
timestamp: now(),
|
|
78
76
|
level,
|
|
79
77
|
module: this.module,
|
|
80
78
|
message: finalMessage,
|
|
79
|
+
interpolationKeys: keys,
|
|
81
80
|
context: effectiveContext,
|
|
81
|
+
error,
|
|
82
82
|
};
|
|
83
83
|
this.#manager.log(payload);
|
|
84
84
|
}
|
|
@@ -101,11 +101,14 @@ function moduleFromArgument(argument) {
|
|
|
101
101
|
}
|
|
102
102
|
const cachedDereference = getCachedDereference({ optional: true });
|
|
103
103
|
function interpolateMessage(message, context) {
|
|
104
|
-
|
|
104
|
+
const keys = [];
|
|
105
|
+
const interpolated = message.replace(/{([^{}]+)}/g, (match, key) => {
|
|
106
|
+
keys.push(key);
|
|
105
107
|
if (hasOwnProperty(context, key)) {
|
|
106
108
|
const value = cachedDereference(context, key);
|
|
107
109
|
return String(value);
|
|
108
110
|
}
|
|
109
111
|
return match;
|
|
110
112
|
});
|
|
113
|
+
return { keys, interpolated };
|
|
111
114
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { Injector } from '../../injector/injector.js';
|
|
1
2
|
/**
|
|
2
|
-
* registers {@link LocalMessageBus} and {@link LocalMessageBusProvider} in
|
|
3
|
+
* registers {@link LocalMessageBus} and {@link LocalMessageBusProvider} in container
|
|
3
4
|
*/
|
|
4
|
-
export declare function configureLocalMessageBus(
|
|
5
|
+
export declare function configureLocalMessageBus({ injector }?: {
|
|
6
|
+
injector?: Injector;
|
|
7
|
+
}): void;
|
|
@@ -4,9 +4,10 @@ import { MessageBus } from '../message-bus.js';
|
|
|
4
4
|
import { LocalMessageBusProvider } from './local-message-bus-provider.js';
|
|
5
5
|
import { LocalMessageBus } from './local-message-bus.js';
|
|
6
6
|
/**
|
|
7
|
-
* registers {@link LocalMessageBus} and {@link LocalMessageBusProvider} in
|
|
7
|
+
* registers {@link LocalMessageBus} and {@link LocalMessageBusProvider} in container
|
|
8
8
|
*/
|
|
9
|
-
export function configureLocalMessageBus() {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export function configureLocalMessageBus({ injector } = {}) {
|
|
10
|
+
const targetInjector = injector ?? Injector;
|
|
11
|
+
targetInjector.register(MessageBus, { useToken: LocalMessageBus });
|
|
12
|
+
targetInjector.registerSingleton(MessageBusProvider, { useToken: LocalMessageBusProvider });
|
|
12
13
|
}
|
package/module/module.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const ModuleState: {
|
|
|
8
8
|
readonly Erroneous: 3;
|
|
9
9
|
};
|
|
10
10
|
export type ModuleState = EnumType<typeof ModuleState>;
|
|
11
|
-
export declare abstract class Module {
|
|
11
|
+
export declare abstract class Module implements AsyncDisposable {
|
|
12
12
|
private runPromise;
|
|
13
13
|
private _state;
|
|
14
14
|
protected readonly cancellationToken: CancellationToken;
|
|
@@ -16,6 +16,7 @@ export declare abstract class Module {
|
|
|
16
16
|
get state(): ModuleState;
|
|
17
17
|
private get stateString();
|
|
18
18
|
constructor(name: string);
|
|
19
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
19
20
|
run(): Promise<void>;
|
|
20
21
|
stop(): Promise<void>;
|
|
21
22
|
protected abstract _run(cancellationSignal: CancellationSignal): Promise<void>;
|
package/module/module.js
CHANGED
|
@@ -24,6 +24,9 @@ export class Module {
|
|
|
24
24
|
this._state = ModuleState.Stopped;
|
|
25
25
|
this.cancellationToken = new CancellationToken();
|
|
26
26
|
}
|
|
27
|
+
async [Symbol.asyncDispose]() {
|
|
28
|
+
await this.stop();
|
|
29
|
+
}
|
|
27
30
|
async run() {
|
|
28
31
|
if (this._state != ModuleState.Stopped) {
|
|
29
32
|
throw new Error(`cannot start module, it is ${this.stateString}`);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { CancellationSignal } from '../../cancellation/index.js';
|
|
2
|
-
import
|
|
2
|
+
import { Injector } from '../../injector/injector.js';
|
|
3
|
+
import type { resolveArgumentType } from '../../injector/interfaces.js';
|
|
3
4
|
import { Module } from '../module.js';
|
|
4
|
-
export
|
|
5
|
+
export declare class WebServerModuleConfiguration {
|
|
5
6
|
port: number;
|
|
6
|
-
}
|
|
7
|
-
export declare
|
|
8
|
-
export declare class WebServerModule extends Module implements Resolvable<WebServerModuleConfiguration> {
|
|
7
|
+
}
|
|
8
|
+
export declare class WebServerModule extends Module {
|
|
9
9
|
private readonly config;
|
|
10
10
|
private readonly httpServer;
|
|
11
11
|
private readonly apiGateway;
|
|
@@ -16,4 +16,9 @@ export declare class WebServerModule extends Module implements Resolvable<WebSer
|
|
|
16
16
|
initialize(): void;
|
|
17
17
|
protected _run(cancellationSignal: CancellationSignal): Promise<void>;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* registers {@link WebServerModule} in container
|
|
21
|
+
*/
|
|
22
|
+
export declare function configureWebServerModule({ injector, ...config }?: Partial<WebServerModuleConfiguration> & {
|
|
23
|
+
injector?: Injector;
|
|
24
|
+
}): void;
|
|
@@ -10,13 +10,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { API_CONTROLLERS, ApiGateway, getApiControllerDefinition } from '../../api/server/index.js';
|
|
11
11
|
import { HttpServer } from '../../http/server/http-server.js';
|
|
12
12
|
import { Singleton } from '../../injector/decorators.js';
|
|
13
|
-
import { inject
|
|
13
|
+
import { inject } from '../../injector/inject.js';
|
|
14
|
+
import { Injector } from '../../injector/injector.js';
|
|
14
15
|
import { Module } from '../module.js';
|
|
15
|
-
export
|
|
16
|
-
port
|
|
17
|
-
}
|
|
16
|
+
export class WebServerModuleConfiguration {
|
|
17
|
+
port;
|
|
18
|
+
}
|
|
19
|
+
;
|
|
18
20
|
let WebServerModule = class WebServerModule extends Module {
|
|
19
|
-
config =
|
|
21
|
+
config = inject(WebServerModuleConfiguration);
|
|
20
22
|
httpServer = inject(HttpServer);
|
|
21
23
|
apiGateway = inject(ApiGateway);
|
|
22
24
|
apiControllers = inject(API_CONTROLLERS);
|
|
@@ -46,12 +48,15 @@ let WebServerModule = class WebServerModule extends Module {
|
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
WebServerModule = __decorate([
|
|
49
|
-
Singleton(
|
|
50
|
-
defaultArgumentProvider: () => webServerModuleConfiguration,
|
|
51
|
-
}),
|
|
51
|
+
Singleton(),
|
|
52
52
|
__metadata("design:paramtypes", [])
|
|
53
53
|
], WebServerModule);
|
|
54
54
|
export { WebServerModule };
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
/**
|
|
56
|
+
* registers {@link WebServerModule} in container
|
|
57
|
+
*/
|
|
58
|
+
export function configureWebServerModule({ injector, ...config } = {}) {
|
|
59
|
+
const targetInjector = injector ?? Injector;
|
|
60
|
+
targetInjector.register(WebServerModuleConfiguration, { useValue: config });
|
|
61
|
+
targetInjector.registerSingleton(WebServerModule, { useClass: WebServerModule });
|
|
57
62
|
}
|
package/orm/decorators.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { AbstractConstructor, Record, TypedOmit } from '../types/index.js';
|
|
|
10
10
|
import type { ValueOrProvider } from '../utils/value-or-provider.js';
|
|
11
11
|
import type { AnyEntity, BaseEntity, Entity, EntityType } from './entity.js';
|
|
12
12
|
import type { Query } from './query/index.js';
|
|
13
|
-
import type { TargetColumnPath } from './repository.types.js';
|
|
13
|
+
import type { TargetColumn, TargetColumnPath } from './repository.types.js';
|
|
14
14
|
import type { ExtraConfigColumnsFromType } from './server/types.js';
|
|
15
15
|
type IndexMethod = LiteralUnion<'hash' | 'btree' | 'gist' | 'spgist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat' | 'bm25', string>;
|
|
16
16
|
type NamingStrategy = 'abbreviated-table';
|
|
@@ -45,8 +45,18 @@ export type OrmTableReflectionData<T extends BaseEntity = BaseEntity> = {
|
|
|
45
45
|
unique?: UniqueReflectionData[];
|
|
46
46
|
index?: IndexReflectionData[];
|
|
47
47
|
paradeIndex?: ParadeIndexReflectionData<T>;
|
|
48
|
+
propertyOverrides?: Record<string, OrmColumnReflectionData>;
|
|
48
49
|
checks?: CheckReflectionData[];
|
|
49
50
|
foreignKeys?: ForeignKeyReflectionData[];
|
|
51
|
+
inheritance?: InheritanceMetadata<T>;
|
|
52
|
+
childEntity?: ChildEntityMetadata;
|
|
53
|
+
};
|
|
54
|
+
export type InheritanceMetadata<T extends BaseEntity = BaseEntity> = {
|
|
55
|
+
discriminatorColumn: TargetColumn<T>;
|
|
56
|
+
subclasses: EntityType[];
|
|
57
|
+
};
|
|
58
|
+
export type ChildEntityMetadata = {
|
|
59
|
+
discriminatorValue: string;
|
|
50
60
|
};
|
|
51
61
|
/**
|
|
52
62
|
* Reflection data stored for ORM column decorators.
|
|
@@ -387,3 +397,16 @@ export declare function ParadeIndex<T extends BaseEntity>(options: ParadeIndexRe
|
|
|
387
397
|
export declare function ParadeIndex(options?: ParadeFieldOptions): PropertyDecorator;
|
|
388
398
|
export declare function ParadeCompoundIndex<T extends BaseEntity>(alias: string, compoundColumns: ParadeIndexCompoundColumnColumnsProvider<T>, options?: TypedOmit<ParadeFieldOptions, 'alias'>): ClassDecorator;
|
|
389
399
|
export declare function ParadeExpressionIndex<T extends BaseEntity>(alias: string, expression: ParadeIndexExpressionProvider<T>, options?: TypedOmit<ParadeFieldOptions, 'alias'>): ClassDecorator;
|
|
400
|
+
/**
|
|
401
|
+
* Configures inheritance for the entity.
|
|
402
|
+
* @param options Inheritance configuration.
|
|
403
|
+
*/
|
|
404
|
+
export declare function Inheritance<T extends BaseEntity>(options: {
|
|
405
|
+
strategy: 'joined';
|
|
406
|
+
discriminatorColumn?: TargetColumn<T>;
|
|
407
|
+
}): ClassDecorator;
|
|
408
|
+
/**
|
|
409
|
+
* Marks the entity as a child entity in an inheritance hierarchy.
|
|
410
|
+
* @param discriminatorValue The value identifying this subclass.
|
|
411
|
+
*/
|
|
412
|
+
export declare function ChildEntity(discriminatorValue: string): ClassDecorator;
|
package/orm/decorators.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { match } from 'ts-pattern';
|
|
2
|
-
import { createClassDecorator, createDecorator, createPropertyDecorator } from '../reflection/index.js';
|
|
2
|
+
import { createClassDecorator, createDecorator, createPropertyDecorator, reflectionRegistry } from '../reflection/index.js';
|
|
3
3
|
import { Property } from '../schema/index.js';
|
|
4
4
|
import { merge } from '../utils/merge.js';
|
|
5
5
|
import { filterUndefinedObjectProperties, objectEntries, propertyNameOf } from '../utils/object/index.js';
|
|
6
|
-
import { isArray, isFunction, isString, isUndefined } from '../utils/type-guards.js';
|
|
6
|
+
import { isArray, isDefined, isFunction, isNotNullOrUndefined, isString, isUndefined } from '../utils/type-guards.js';
|
|
7
7
|
/**
|
|
8
8
|
* Merges ORM reflection data into the target's metadata.
|
|
9
9
|
* @param metadata The metadata object for the class or property.
|
|
@@ -143,8 +143,10 @@ export function Index(columnsOrOptions, options) {
|
|
|
143
143
|
* @param mode Whether to delete soft or hard.
|
|
144
144
|
*/
|
|
145
145
|
export function TimeToLive(ttl, mode) {
|
|
146
|
-
return
|
|
147
|
-
|
|
146
|
+
return createTableDecorator({
|
|
147
|
+
propertyOverrides: {
|
|
148
|
+
[propertyNameOf((entity) => entity.metadata.createTimestamp)]: { expirationField: { after: ttl, mode } },
|
|
149
|
+
},
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
152
|
/**
|
|
@@ -199,3 +201,37 @@ export function ParadeCompoundIndex(alias, compoundColumns, options) {
|
|
|
199
201
|
export function ParadeExpressionIndex(alias, expression, options) {
|
|
200
202
|
return ParadeIndex({ expressions: [[expression, { alias, tokenizer: 'simple', ...options }]] });
|
|
201
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Configures inheritance for the entity.
|
|
206
|
+
* @param options Inheritance configuration.
|
|
207
|
+
*/
|
|
208
|
+
export function Inheritance(options) {
|
|
209
|
+
return createTableDecorator({
|
|
210
|
+
inheritance: {
|
|
211
|
+
discriminatorColumn: options.discriminatorColumn ?? 'type',
|
|
212
|
+
subclasses: [],
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Marks the entity as a child entity in an inheritance hierarchy.
|
|
218
|
+
* @param discriminatorValue The value identifying this subclass.
|
|
219
|
+
*/
|
|
220
|
+
export function ChildEntity(discriminatorValue) {
|
|
221
|
+
return createClassDecorator({
|
|
222
|
+
handler: (data, metadata) => {
|
|
223
|
+
let currentMetadata = metadata;
|
|
224
|
+
while (isNotNullOrUndefined(currentMetadata?.parent)) {
|
|
225
|
+
const parentMetadata = reflectionRegistry.getMetadata(currentMetadata.parent);
|
|
226
|
+
const parentOrmData = parentMetadata?.data.tryGet('orm');
|
|
227
|
+
if (isDefined(parentOrmData?.inheritance) && !parentOrmData.inheritance.subclasses.includes(data.constructor)) {
|
|
228
|
+
parentOrmData.inheritance.subclasses.push(data.constructor);
|
|
229
|
+
}
|
|
230
|
+
currentMetadata = parentMetadata;
|
|
231
|
+
}
|
|
232
|
+
const ormData = metadata.data.tryGet('orm') ?? {};
|
|
233
|
+
ormData.childEntity = { discriminatorValue };
|
|
234
|
+
metadata.data.set('orm', ormData, true);
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
}
|
package/orm/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export * from './entity.js';
|
|
|
8
8
|
export * from './query/index.js';
|
|
9
9
|
export * from './repository.types.js';
|
|
10
10
|
export * from './schemas/index.js';
|
|
11
|
-
export * from './sqls.js';
|
|
11
|
+
export * from './sqls/index.js';
|
|
12
12
|
export * from './types.js';
|
|
13
13
|
export * from './utils.js';
|
package/orm/index.js
CHANGED
|
@@ -8,6 +8,6 @@ export * from './entity.js';
|
|
|
8
8
|
export * from './query/index.js';
|
|
9
9
|
export * from './repository.types.js';
|
|
10
10
|
export * from './schemas/index.js';
|
|
11
|
-
export * from './sqls.js';
|
|
11
|
+
export * from './sqls/index.js';
|
|
12
12
|
export * from './types.js';
|
|
13
13
|
export * from './utils.js';
|
package/orm/query/base.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export type QueryObject<T extends BaseEntity> = LogicalQuery<T> | Partial<Specia
|
|
|
45
45
|
/** Union of all possible query operator keys (logical, comparison, special). */
|
|
46
46
|
export type QueryTypes = LogicalQueryTypes | ComparisonQueryTypes | SpecialQueryTypes;
|
|
47
47
|
/** Array containing all valid query operator keys. */
|
|
48
|
-
export declare const allQueryTypes: ("$parade" | "$and" | "$or" | "$nor" | "$not" | "$eq" | "$neq" | "$exists" | "$item" | "$in" | "$nin" | "$
|
|
48
|
+
export declare const allQueryTypes: ("$parade" | "$and" | "$or" | "$nor" | "$not" | "$eq" | "$neq" | "$exists" | "$item" | "$in" | "$nin" | "$contains" | "$gt" | "$gte" | "$lt" | "$lte" | "$regex" | "$tsvector" | "$trigram" | "$geoShape" | "$geoDistance")[];
|
|
49
49
|
/** Represents an AND logical query. All sub-queries must be true. */
|
|
50
50
|
export type LogicalAndQuery<T = any> = {
|
|
51
51
|
$and: readonly Query<T>[];
|
|
@@ -61,7 +61,7 @@ export type LogicalNorQuery<T = any> = {
|
|
|
61
61
|
/** Represents a value used in comparisons, can be a direct value, a flattened value, or a Drizzle SQLWrapper. */
|
|
62
62
|
export type ComparisonValue<T> = T | Flatten<T> | SQLWrapper;
|
|
63
63
|
/** Represents a comparison value that can also include a RegExp for string comparisons. */
|
|
64
|
-
export type ComparisonValueWithRegex<T> = T extends string ? ComparisonValue<T | RegExp> : T extends readonly string[] ? ComparisonValue<readonly (Flatten<T> | RegExp)[]> :
|
|
64
|
+
export type ComparisonValueWithRegex<T> = T extends string ? ComparisonValue<T | RegExp> : T extends readonly string[] ? ComparisonValue<readonly (Flatten<T> | RegExp)[]> : ComparisonValue<T>;
|
|
65
65
|
/** Represents a logical AND query. All sub-queries must be true. */
|
|
66
66
|
export type ComparisonAndQuery<T = any> = {
|
|
67
67
|
$and: readonly ComparisonQueryOrValue<T>[];
|
|
@@ -74,51 +74,51 @@ export type ComparisonOrQuery<T = any> = {
|
|
|
74
74
|
export type ComparisonNotQuery<T = any> = {
|
|
75
75
|
$not: ComparisonQueryOrValue<T>;
|
|
76
76
|
};
|
|
77
|
-
/** Represents an equality comparison query
|
|
77
|
+
/** Represents an equality comparison query. */
|
|
78
78
|
export type ComparisonEqualsQuery<T = any> = {
|
|
79
79
|
$eq: ComparisonValueWithRegex<T>;
|
|
80
80
|
};
|
|
81
|
-
/** Represents a non-equality comparison query
|
|
81
|
+
/** Represents a non-equality comparison query. */
|
|
82
82
|
export type ComparisonNotEqualsQuery<T = any> = {
|
|
83
83
|
$neq: ComparisonValueWithRegex<T>;
|
|
84
84
|
};
|
|
85
|
-
/** Represents an existence check query
|
|
85
|
+
/** Represents an existence check query. Checks if a field exists (or not). */
|
|
86
86
|
export type ComparisonExistsQuery = {
|
|
87
87
|
$exists: ComparisonValue<boolean>;
|
|
88
88
|
};
|
|
89
|
-
/** Represents a query targeting elements within an array field
|
|
89
|
+
/** Represents a query targeting elements within an array field. */
|
|
90
90
|
export type ComparisonItemQuery<T = any> = {
|
|
91
91
|
$item: T extends readonly (infer U)[] ? U extends Record ? Query<U> : ComparisonQuery<U> : never;
|
|
92
92
|
};
|
|
93
|
-
/** Represents an "in list" comparison query
|
|
93
|
+
/** Represents an "in list" comparison query. Checks if a field value is within a specified array. */
|
|
94
94
|
export type ComparisonInQuery<T = any> = {
|
|
95
95
|
$in: readonly ComparisonValueWithRegex<T>[];
|
|
96
96
|
};
|
|
97
|
-
/** Represents a "not in list" comparison query
|
|
97
|
+
/** Represents a "not in list" comparison query. Checks if a field value is not within a specified array. */
|
|
98
98
|
export type ComparisonNotInQuery<T = any> = {
|
|
99
99
|
$nin: readonly ComparisonValueWithRegex<T>[];
|
|
100
100
|
};
|
|
101
|
-
/** Represents an "all elements match" query
|
|
101
|
+
/** Represents an "all elements match" query. Checks if an array field contains all specified values. */
|
|
102
102
|
export type ComparisonAllQuery<T = any> = {
|
|
103
|
-
$
|
|
103
|
+
$contains: readonly ComparisonValueWithRegex<T>[];
|
|
104
104
|
};
|
|
105
|
-
/** Represents a "greater than" comparison query
|
|
105
|
+
/** Represents a "greater than" comparison query. */
|
|
106
106
|
export type ComparisonGreaterThanQuery<T = any> = {
|
|
107
107
|
$gt: ComparisonValue<T>;
|
|
108
108
|
};
|
|
109
|
-
/** Represents a "greater than or equals" comparison query
|
|
109
|
+
/** Represents a "greater than or equals" comparison query. */
|
|
110
110
|
export type ComparisonGreaterThanOrEqualsQuery<T = any> = {
|
|
111
111
|
$gte: ComparisonValue<T>;
|
|
112
112
|
};
|
|
113
|
-
/** Represents a "less than" comparison query
|
|
113
|
+
/** Represents a "less than" comparison query. */
|
|
114
114
|
export type ComparisonLessThanQuery<T = any> = {
|
|
115
115
|
$lt: ComparisonValue<T>;
|
|
116
116
|
};
|
|
117
|
-
/** Represents a "less than or equals" comparison query
|
|
117
|
+
/** Represents a "less than or equals" comparison query. */
|
|
118
118
|
export type ComparisonLessThanOrEqualsQuery<T = any> = {
|
|
119
119
|
$lte: ComparisonValue<T>;
|
|
120
120
|
};
|
|
121
|
-
/** Represents a regular expression comparison query
|
|
121
|
+
/** Represents a regular expression comparison query. */
|
|
122
122
|
export type ComparisonRegexQuery = {
|
|
123
123
|
$regex: string | RegExp | {
|
|
124
124
|
pattern: string;
|
|
@@ -151,14 +151,14 @@ export type ComparisonTrigramQuery = {
|
|
|
151
151
|
};
|
|
152
152
|
/** Defines the possible spatial relationships for geospatial shape queries. */
|
|
153
153
|
export type GeoShapeRelation = 'intersects' | 'within' | 'disjoint' | 'contains';
|
|
154
|
-
/** Represents a geospatial query based on shape relationships
|
|
154
|
+
/** Represents a geospatial query based on shape relationships. */
|
|
155
155
|
export type ComparisonGeoShapeQuery = {
|
|
156
156
|
$geoShape: {
|
|
157
157
|
geometry: Geometry;
|
|
158
158
|
relation: GeoShapeRelation;
|
|
159
159
|
};
|
|
160
160
|
};
|
|
161
|
-
/** Represents a geospatial query based on distance from a point
|
|
161
|
+
/** Represents a geospatial query based on distance from a point. */
|
|
162
162
|
export type ComparisonGeoDistanceQuery = {
|
|
163
163
|
$geoDistance: {
|
|
164
164
|
longitude: number;
|
package/orm/query/base.js
CHANGED
|
@@ -2,7 +2,7 @@ import { paradeComparisonQueryTypes, paradeSpecialQueryTypes } from './parade.js
|
|
|
2
2
|
/** Array containing all valid logical query operator keys. */
|
|
3
3
|
export const allLogicalQueryTypes = ['$and', '$or', '$nor'];
|
|
4
4
|
/** Array containing all valid comparison query operator keys. */
|
|
5
|
-
export const allComparisonQueryTypes = ['$
|
|
5
|
+
export const allComparisonQueryTypes = ['$contains', '$not', '$eq', '$exists', '$gt', '$gte', '$in', '$item', '$lt', '$lte', '$neq', '$nin', '$regex', '$tsvector', '$trigram', '$geoDistance', '$geoShape', ...paradeComparisonQueryTypes];
|
|
6
6
|
/** Array containing all valid special query operator keys. */
|
|
7
7
|
export const allSpecialQueryTypes = ['$tsvector', '$trigram', ...paradeSpecialQueryTypes];
|
|
8
8
|
/** Array containing all valid query operator keys. */
|
|
@@ -7,9 +7,9 @@ import type { Path, Record, SimplifyObject, TypedOmit } from '../types/index.js'
|
|
|
7
7
|
import type { UntaggedDeep } from '../types/tagged.js';
|
|
8
8
|
import type { AnyColumn, SQL, SQLWrapper } from 'drizzle-orm';
|
|
9
9
|
import type { PartialDeep } from 'type-fest';
|
|
10
|
-
import type { BaseEntity, Entity, EntityMetadata } from './entity.js';
|
|
10
|
+
import type { BaseEntity, Entity, EntityMetadata, EntityType } from './entity.js';
|
|
11
11
|
import type { FullTextSearchQuery, Query } from './query/index.js';
|
|
12
|
-
import type { TsHeadlineOptions } from './sqls.js';
|
|
12
|
+
import type { TsHeadlineOptions } from './sqls/index.js';
|
|
13
13
|
type WithSql<T> = {
|
|
14
14
|
[P in keyof T]: T[P] extends Record ? WithSql<T[P]> : (T[P] | SQL);
|
|
15
15
|
};
|
|
@@ -40,12 +40,40 @@ export type Order<T extends BaseEntity> = TargetColumn<T> | (TargetColumn<T> | [
|
|
|
40
40
|
export type OrderOptions<T extends BaseEntity> = {
|
|
41
41
|
order?: Order<T>;
|
|
42
42
|
};
|
|
43
|
+
export type CountOptions<_T extends BaseEntity> = {
|
|
44
|
+
/**
|
|
45
|
+
* Whether to include soft-deleted entities in the count.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
withDeleted?: boolean;
|
|
49
|
+
for?: LockMode | LockOptions;
|
|
50
|
+
};
|
|
51
|
+
export type HasOptions<_T extends BaseEntity> = {
|
|
52
|
+
/**
|
|
53
|
+
* Whether to include soft-deleted entities in the check.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
withDeleted?: boolean;
|
|
57
|
+
};
|
|
58
|
+
export type LockMode = 'update' | 'no key update' | 'share' | 'key share';
|
|
59
|
+
export type LockOptions = {
|
|
60
|
+
mode: LockMode;
|
|
61
|
+
skipLocked?: boolean;
|
|
62
|
+
noWait?: boolean;
|
|
63
|
+
};
|
|
43
64
|
/**
|
|
44
65
|
* Options for loading a single entity, including ordering and offset.
|
|
45
66
|
* @template T - The entity type.
|
|
46
67
|
*/
|
|
47
68
|
export type LoadOptions<T extends BaseEntity> = OrderOptions<T> & {
|
|
48
69
|
offset?: number;
|
|
70
|
+
includeSubclasses?: boolean | EntityType[];
|
|
71
|
+
/**
|
|
72
|
+
* Whether to include soft-deleted entities in the results.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
withDeleted?: boolean;
|
|
76
|
+
for?: LockMode | LockOptions;
|
|
49
77
|
};
|
|
50
78
|
/**
|
|
51
79
|
* Options for loading multiple entities, including ordering, offset, and limit.
|
|
@@ -55,6 +83,22 @@ export type LoadManyOptions<T extends BaseEntity> = LoadOptions<T> & {
|
|
|
55
83
|
limit?: number;
|
|
56
84
|
distinct?: boolean | TargetColumn<T>[];
|
|
57
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Options for delete operations.
|
|
88
|
+
* @template T - The entity type.
|
|
89
|
+
*/
|
|
90
|
+
export type DeleteOptions<_T extends BaseEntity> = {
|
|
91
|
+
/**
|
|
92
|
+
* Whether to include soft-deleted entities (e.g. for hard delete).
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
withDeleted?: boolean;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Options for delete many operations.
|
|
99
|
+
* @template T - The entity type.
|
|
100
|
+
*/
|
|
101
|
+
export type DeleteManyOptions<T extends BaseEntity> = DeleteOptions<T>;
|
|
58
102
|
/**
|
|
59
103
|
* Options for ranking search results.
|
|
60
104
|
*/
|
package/orm/schemas/tsvector.js
CHANGED
|
@@ -4,7 +4,7 @@ export class TsVectorSchema extends Schema {
|
|
|
4
4
|
_test(_value, _path, _options) {
|
|
5
5
|
return {
|
|
6
6
|
valid: false,
|
|
7
|
-
error: SchemaError.expectedButGot('nothing', 'value', _path, { customMessage: `TSVectorSchema does not support validation as tsvector columns are not directly mapped to application data.` })
|
|
7
|
+
error: SchemaError.expectedButGot('nothing', 'value', _path, { customMessage: `TSVectorSchema does not support validation as tsvector columns are not directly mapped to application data.` }),
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PgEnum, type PgSchema, type PgTableWithColumns } from 'drizzle-orm/pg-core';
|
|
2
|
-
import type { Enumeration } from '../../../types/index.js';
|
|
2
|
+
import type { AbstractConstructor, Enumeration } from '../../../types/index.js';
|
|
3
3
|
import { type EntityType } from '../../entity.js';
|
|
4
4
|
import type { ColumnDefinition, ColumnDefinitionsMap, PgTableFromType } from '../types.js';
|
|
5
5
|
type ConverterContext = {
|
|
@@ -8,7 +8,9 @@ type ConverterContext = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare const getDrizzleTableFromType: typeof _getDrizzleTableFromType;
|
|
10
10
|
export declare function getColumnDefinitions(table: PgTableWithColumns<any>): ColumnDefinition[];
|
|
11
|
+
export declare function getTableColumnDefinitions(table: PgTableWithColumns<any>): ColumnDefinition[];
|
|
11
12
|
export declare function getColumnDefinitionsMap(table: PgTableWithColumns<any>): ColumnDefinitionsMap;
|
|
12
13
|
export declare function _getDrizzleTableFromType<T extends EntityType, S extends string>(type: T, fallbackSchemaName?: S): PgTableFromType<T, S>;
|
|
14
|
+
export declare function isTableOwning(type: AbstractConstructor): boolean;
|
|
13
15
|
export declare function getPgEnum(schema: string | PgSchema, enumeration: Enumeration, context?: ConverterContext): PgEnum<[string, ...string[]]>;
|
|
14
16
|
export {};
|