@tstdl/base 0.93.87 → 0.93.90
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 +20 -5
- package/authentication/models/subject.model.js +34 -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 +17 -11
- 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/query/base.d.ts +17 -17
- package/orm/query/base.js +1 -1
- package/orm/repository.types.d.ts +45 -1
- 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 +32 -20
- 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 +757 -253
- 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 +3 -3
- package/orm/sqls/case-when.js +2 -2
- package/orm/sqls/sqls.d.ts +31 -5
- package/orm/sqls/sqls.js +69 -6
- 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
|
@@ -14,7 +14,7 @@ import { injectionToken } from '../../../injector/token.js';
|
|
|
14
14
|
import { Logger } from '../../../logger/logger.js';
|
|
15
15
|
import { getEntityIds } from '../../../orm/index.js';
|
|
16
16
|
import { injectRepository } from '../../../orm/server/index.js';
|
|
17
|
-
import {
|
|
17
|
+
import { TaskQueue, TaskResult } from '../../../task-queue/task-queue.js';
|
|
18
18
|
import { currentTimestamp } from '../../../utils/date-time.js';
|
|
19
19
|
import { isNull, isUndefined } from '../../../utils/type-guards.js';
|
|
20
20
|
import { millisecondsPerMinute } from '../../../utils/units.js';
|
|
@@ -37,7 +37,7 @@ let DocumentValidationService = DocumentValidationService_1 = class DocumentVali
|
|
|
37
37
|
#validationExecutionService = injectRepository(DocumentValidationExecution);
|
|
38
38
|
#validationExecutionRelatedDocumentService = injectRepository(DocumentValidationExecutionRelatedDocument);
|
|
39
39
|
#documentTypeValidationService = injectRepository(DocumentTypeValidation);
|
|
40
|
-
#
|
|
40
|
+
#taskQueue = inject((TaskQueue), { namespace: 'DocumentManagement:validation', visibilityTimeout: 5 * millisecondsPerMinute, maxTries: 3 });
|
|
41
41
|
#executors = injectAll(DOCUMENT_VALIDATION_EXECUTORS);
|
|
42
42
|
#logger = inject(Logger, DocumentValidationService_1.name);
|
|
43
43
|
#executorMap = new Map(this.#executors.map((executor) => [executor.identifier, executor]));
|
|
@@ -45,10 +45,11 @@ let DocumentValidationService = DocumentValidationService_1 = class DocumentVali
|
|
|
45
45
|
this.processQueue(cancellationSignal);
|
|
46
46
|
}
|
|
47
47
|
processQueue(cancellationSignal) {
|
|
48
|
-
this.#
|
|
48
|
+
this.#taskQueue.process({ concurrency: 5, cancellationSignal }, async (job) => {
|
|
49
49
|
this.#logger.verbose(`Processing validation execution "${job.data.executionId}"`);
|
|
50
50
|
await this.processValidationExecution(job.data.tenantId, job.data.executionId);
|
|
51
|
-
|
|
51
|
+
return TaskResult.Complete();
|
|
52
|
+
});
|
|
52
53
|
}
|
|
53
54
|
async startValidationWorkflow(tenantId, documentId) {
|
|
54
55
|
const document = await this.#documentService.loadByQuery({ tenantId, id: documentId });
|
|
@@ -69,7 +70,7 @@ let DocumentValidationService = DocumentValidationService_1 = class DocumentVali
|
|
|
69
70
|
startedAt: null,
|
|
70
71
|
completedAt: null,
|
|
71
72
|
});
|
|
72
|
-
await this.#
|
|
73
|
+
await this.#taskQueue.enqueue('validate', { tenantId, executionId: execution.id });
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
async setExecutionRunning(tenantId, executionId) {
|
|
@@ -13,7 +13,7 @@ import { inject } from '../../../injector/inject.js';
|
|
|
13
13
|
import { afterResolve } from '../../../injector/interfaces.js';
|
|
14
14
|
import { Logger } from '../../../logger/index.js';
|
|
15
15
|
import { injectRepository, injectTransactional, Transactional } from '../../../orm/server/index.js';
|
|
16
|
-
import {
|
|
16
|
+
import { TaskQueue, TaskResult } from '../../../task-queue/task-queue.js';
|
|
17
17
|
import { toArray } from '../../../utils/array/array.js';
|
|
18
18
|
import { currentTimestamp } from '../../../utils/date-time.js';
|
|
19
19
|
import { _throw } from '../../../utils/throw.js';
|
|
@@ -37,7 +37,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
|
|
|
37
37
|
#documentAssignmentTaskRepository = injectRepository(DocumentAssignmentTask);
|
|
38
38
|
#documentAssignmentScopeRepository = injectRepository(DocumentAssignmentScope);
|
|
39
39
|
#observationService = inject(DocumentManagementObservationService);
|
|
40
|
-
#
|
|
40
|
+
#taskQueue = inject((TaskQueue), { namespace: 'DocumentManagement:DocumentWorkflow', visibilityTimeout: 5 * 60 * 1000, maxTries: 3 });
|
|
41
41
|
#logger = inject(Logger, DocumentWorkflowService_1.name);
|
|
42
42
|
documentService = inject(DocumentService, undefined, { forwardRef: true });
|
|
43
43
|
repository = injectRepository(DocumentWorkflow);
|
|
@@ -45,7 +45,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
|
|
|
45
45
|
if (this.isInTransaction) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
this.#
|
|
48
|
+
this.#taskQueue.process({ concurrency: 5, cancellationSignal }, async (taskContext) => await this.processWorkflowJob(taskContext));
|
|
49
49
|
}
|
|
50
50
|
async loadLatestWorkflow(tenantId, documentId) {
|
|
51
51
|
return await this.repository.loadByQuery({ tenantId, documentId }, { order: { 'metadata.createTimestamp': 'desc' } });
|
|
@@ -82,7 +82,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
|
|
|
82
82
|
}
|
|
83
83
|
async initiateWorkflow(tenantId, documentId, step) {
|
|
84
84
|
const workflow = await this.repository.insert({ tenantId, documentId, step, state: 'pending', failReason: null, completeTimestamp: null, completeUserId: null });
|
|
85
|
-
await this.#
|
|
85
|
+
await this.#taskQueue.enqueue('workflow', { workflowId: workflow.id });
|
|
86
86
|
this.#observationService.documentChange(workflow.id, this.session);
|
|
87
87
|
return workflow;
|
|
88
88
|
}
|
|
@@ -109,7 +109,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
|
|
|
109
109
|
else {
|
|
110
110
|
await this.setWorkflowState(workflow.id, DocumentWorkflowState.Review);
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
return TaskResult.Complete();
|
|
113
113
|
}
|
|
114
114
|
catch (error) {
|
|
115
115
|
if (task.triesLeft == 0) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { EnrichedDocumentManagementData } from './enriched/enriched-document-management-data.view.js';
|
|
2
2
|
export type DocumentManagementFolder = {
|
|
3
3
|
id: string;
|
|
4
|
-
type: 'collection' | 'category' | '
|
|
4
|
+
type: 'collection' | 'category' | 'collection-group';
|
|
5
5
|
label: string;
|
|
6
6
|
subFolders: DocumentManagementFolder[];
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type GetDocumentManagementFoldersOptions = {
|
|
9
|
+
wrapCollections?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function getDocumentManagementFolders(data: EnrichedDocumentManagementData, options?: GetDocumentManagementFoldersOptions): DocumentManagementFolder[];
|
|
9
12
|
export declare function getFlatFolders(folders: DocumentManagementFolder[]): DocumentManagementFolder[];
|
|
@@ -1,19 +1,52 @@
|
|
|
1
1
|
import { isNotNull } from '../../utils/type-guards.js';
|
|
2
|
-
export function getDocumentManagementFolders(data) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
2
|
+
export function getDocumentManagementFolders(data, options = {}) {
|
|
3
|
+
const { wrapCollections = (data.collections.length > 1) } = options;
|
|
4
|
+
function getCategoryFolder(category, collectionId) {
|
|
5
|
+
const subFolders = category.children.map((child) => getCategoryFolder(child, collectionId)).filter(isNotNull);
|
|
6
|
+
const documents = (collectionId == null)
|
|
7
|
+
? category.documents
|
|
8
|
+
: category.documents.filter((document) => document.assignments.collections.some((assignment) => assignment.collection.id == collectionId));
|
|
9
|
+
if ((documents.length + subFolders.length) == 0) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
6
13
|
id: category.id,
|
|
7
14
|
type: 'category',
|
|
8
15
|
label: category.label,
|
|
9
16
|
subFolders,
|
|
10
17
|
};
|
|
11
|
-
if ((category.documents.length + categoryFolder.subFolders.length) == 0) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
return categoryFolder;
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
if (wrapCollections) {
|
|
20
|
+
return data.collectionGroups.flatMap((group) => {
|
|
21
|
+
const collectionFolders = group.collections.map((collection) => {
|
|
22
|
+
const subFolders = data.rootCategories.map((category) => getCategoryFolder(category, collection.id)).filter(isNotNull);
|
|
23
|
+
if (subFolders.length == 0) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
id: collection.id,
|
|
28
|
+
type: 'collection',
|
|
29
|
+
label: collection.name,
|
|
30
|
+
subFolders,
|
|
31
|
+
};
|
|
32
|
+
}).filter(isNotNull);
|
|
33
|
+
if (collectionFolders.length == 0) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
if (group.group == null) {
|
|
37
|
+
return collectionFolders;
|
|
38
|
+
}
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
id: `group:${group.group}`,
|
|
42
|
+
type: 'collection-group',
|
|
43
|
+
label: group.group,
|
|
44
|
+
subFolders: collectionFolders,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return data.rootCategories.map((category) => getCategoryFolder(category)).filter(isNotNull);
|
|
17
50
|
}
|
|
18
51
|
export function getFlatFolders(folders) {
|
|
19
52
|
return [...folders, ...folders.flatMap((folder) => getFlatFolders(folder.subFolders))];
|
package/document-management/service-models/enriched/enriched-document-management-data.view.js
CHANGED
|
@@ -56,7 +56,7 @@ export class EnrichedDocumentManagementData {
|
|
|
56
56
|
return this.rawData.collections.map((collection) => collection.id);
|
|
57
57
|
}
|
|
58
58
|
get rootCollections() {
|
|
59
|
-
return this.
|
|
59
|
+
return this.collections.filter((collection) => isNull(collection.parentId));
|
|
60
60
|
}
|
|
61
61
|
get collections() {
|
|
62
62
|
return this.rawData.collections.map((collection) => new EnrichedDocumentCollection(this, collection));
|
|
@@ -11,6 +11,7 @@ import { MockApiRequestTokenProvider } from '../../api/server/api-request-token.
|
|
|
11
11
|
import { configureApiServer } from '../../api/server/module.js';
|
|
12
12
|
import { Application } from '../../application/application.js';
|
|
13
13
|
import { provideInitializer, provideModule, provideSignalHandler } from '../../application/index.js';
|
|
14
|
+
import { configurePostgresCircuitBreaker, migratePostgresCircuitBreaker } from '../../circuit-breaker/postgres/module.js';
|
|
14
15
|
import { DocumentManagementAuthorizationService } from '../../document-management/index.js';
|
|
15
16
|
import { configureDocumentManagement } from '../../document-management/server/configure.js';
|
|
16
17
|
import { DocumentCategoryTypeService, DocumentCollectionService, DocumentManagementAncillaryService, DocumentManagementApiController, DocumentRequestService } from '../../document-management/server/index.js';
|
|
@@ -24,11 +25,10 @@ import { configureLocalMessageBus } from '../../message-bus/index.js';
|
|
|
24
25
|
import { WebServerModule } from '../../module/index.js';
|
|
25
26
|
import { configureS3ObjectStorage } from '../../object-storage/index.js';
|
|
26
27
|
import { configureOrm } from '../../orm/server/index.js';
|
|
27
|
-
import { configurePostgresQueue, migratePostgresQueueSchema } from '../../queue/postgres/index.js';
|
|
28
28
|
import { configureDefaultSignalsImplementation } from '../../signals/implementation/configure.js';
|
|
29
|
+
import { configurePostgresTaskQueue, migratePostgresTaskQueueSchema } from '../../task-queue/postgres/index.js';
|
|
29
30
|
import { boolean, positiveInteger, string } from '../../utils/config-parser.js';
|
|
30
31
|
import { TstdlCategoryParents, TstdlDocumentCategoryLabels, TstdlDocumentPropertyConfiguration, TstdlDocumentTypeCategories, TstdlDocumentTypeLabels, TstdlDocumentTypeProperties } from './categories-and-types.js';
|
|
31
|
-
import { configurePostgresCircuitBreaker, migratePostgresCircuitBreaker } from '../../circuit-breaker/postgres/module.js';
|
|
32
32
|
const config = {
|
|
33
33
|
database: {
|
|
34
34
|
host: string('DATABASE_HOST', '127.0.0.1'),
|
|
@@ -87,7 +87,7 @@ export { AllowAllDocumentManagementAuthorizationService };
|
|
|
87
87
|
async function bootstrap() {
|
|
88
88
|
const injector = inject(Injector);
|
|
89
89
|
configureNodeHttpServer();
|
|
90
|
-
|
|
90
|
+
configurePostgresTaskQueue();
|
|
91
91
|
configurePostgresCircuitBreaker();
|
|
92
92
|
configureLocalMessageBus();
|
|
93
93
|
configureDefaultSignalsImplementation();
|
|
@@ -138,7 +138,7 @@ async function bootstrap() {
|
|
|
138
138
|
});
|
|
139
139
|
await runInInjectionContext(injector, migrateDocumentManagementSchema);
|
|
140
140
|
await runInInjectionContext(injector, migratePostgresCircuitBreaker);
|
|
141
|
-
await runInInjectionContext(injector,
|
|
141
|
+
await runInInjectionContext(injector, migratePostgresTaskQueueSchema);
|
|
142
142
|
}
|
|
143
143
|
async function main() {
|
|
144
144
|
const tenantId = '00000000-0000-0000-0000-000000000000';
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import type { Dispatcher } from 'undici';
|
|
2
2
|
import type { Resolvable } from '../../../injector/index.js';
|
|
3
3
|
import { resolveArgumentType } from '../../../injector/index.js';
|
|
4
|
+
import { Injector } from '../../../injector/injector.js';
|
|
4
5
|
import type { HttpClientRequest } from '../http-client-request.js';
|
|
5
6
|
import { HttpClientResponse } from '../http-client-response.js';
|
|
6
7
|
import { HttpClientAdapter } from '../http-client.adapter.js';
|
|
7
|
-
export
|
|
8
|
+
export declare class UndiciHttpClientAdapterOptions {
|
|
8
9
|
dispatcher?: Dispatcher;
|
|
9
|
-
}
|
|
10
|
+
}
|
|
10
11
|
export declare class UndiciHttpClientAdapter extends HttpClientAdapter implements Resolvable<UndiciHttpClientAdapterOptions> {
|
|
11
12
|
private readonly options;
|
|
12
13
|
readonly [resolveArgumentType]: UndiciHttpClientAdapterOptions;
|
|
13
14
|
call(httpClientRequest: HttpClientRequest): Promise<HttpClientResponse>;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* configure undici http client adapter module
|
|
18
|
+
* @param options adapter configuration
|
|
17
19
|
*/
|
|
18
|
-
export declare function configureUndiciHttpClientAdapter(options?: UndiciHttpClientAdapterOptions & {
|
|
19
|
-
|
|
20
|
+
export declare function configureUndiciHttpClientAdapter({ injector, ...options }?: UndiciHttpClientAdapterOptions & {
|
|
21
|
+
injector?: Injector;
|
|
20
22
|
}): void;
|
|
@@ -8,15 +8,18 @@ import { Readable } from 'node:stream';
|
|
|
8
8
|
import { request, errors as undiciErrors } from 'undici';
|
|
9
9
|
import { HttpHeaders } from '../../../http/http-headers.js';
|
|
10
10
|
import { HttpError, HttpErrorReason } from '../../../http/http.error.js';
|
|
11
|
-
import { Singleton,
|
|
11
|
+
import { Singleton, inject, resolveArgumentType } from '../../../injector/index.js';
|
|
12
12
|
import { Injector } from '../../../injector/injector.js';
|
|
13
13
|
import { toArray } from '../../../utils/array/array.js';
|
|
14
14
|
import { isBlob, isDefined, isUint8Array } from '../../../utils/type-guards.js';
|
|
15
15
|
import { HttpClientResponse } from '../http-client-response.js';
|
|
16
16
|
import { HttpClientAdapter } from '../http-client.adapter.js';
|
|
17
|
-
|
|
17
|
+
export class UndiciHttpClientAdapterOptions {
|
|
18
|
+
dispatcher;
|
|
19
|
+
}
|
|
20
|
+
;
|
|
18
21
|
let UndiciHttpClientAdapter = class UndiciHttpClientAdapter extends HttpClientAdapter {
|
|
19
|
-
options =
|
|
22
|
+
options = inject(UndiciHttpClientAdapterOptions, undefined, { optional: true }) ?? {};
|
|
20
23
|
// eslint-disable-next-line max-lines-per-function, max-statements
|
|
21
24
|
async call(httpClientRequest) {
|
|
22
25
|
let body;
|
|
@@ -78,17 +81,17 @@ let UndiciHttpClientAdapter = class UndiciHttpClientAdapter extends HttpClientAd
|
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
83
|
UndiciHttpClientAdapter = __decorate([
|
|
81
|
-
Singleton(
|
|
84
|
+
Singleton()
|
|
82
85
|
], UndiciHttpClientAdapter);
|
|
83
86
|
export { UndiciHttpClientAdapter };
|
|
84
87
|
/**
|
|
85
|
-
*
|
|
88
|
+
* configure undici http client adapter module
|
|
89
|
+
* @param options adapter configuration
|
|
86
90
|
*/
|
|
87
|
-
export function configureUndiciHttpClientAdapter(options = {}) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
91
|
+
export function configureUndiciHttpClientAdapter({ injector, ...options } = {}) {
|
|
92
|
+
const targetInjector = injector ?? Injector;
|
|
93
|
+
targetInjector.register(UndiciHttpClientAdapterOptions, { useValue: options });
|
|
94
|
+
targetInjector.register(HttpClientAdapter, { useToken: UndiciHttpClientAdapter });
|
|
92
95
|
}
|
|
93
96
|
function getHttpErrorReason(error) {
|
|
94
97
|
switch (error.code) {
|
package/http/client/module.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Injector } from '../../injector/injector.js';
|
|
1
2
|
import type { OneOrMany, Type } from '../../types/index.js';
|
|
2
3
|
import { HttpClientOptions } from './http-client-options.js';
|
|
3
4
|
import { HttpClientAdapter } from './http-client.adapter.js';
|
|
@@ -8,5 +9,6 @@ export type HttpClientModuleConfig = HttpClientOptions & {
|
|
|
8
9
|
* Middlewares to add
|
|
9
10
|
*/
|
|
10
11
|
middleware?: OneOrMany<HttpClientMiddleware>;
|
|
12
|
+
injector?: Injector;
|
|
11
13
|
};
|
|
12
|
-
export declare function configureHttpClient({ adapter, middleware, ...rest }
|
|
14
|
+
export declare function configureHttpClient({ adapter, middleware, injector, ...rest }?: HttpClientModuleConfig): void;
|
package/http/client/module.js
CHANGED
|
@@ -4,20 +4,19 @@ import { isDefined } from '../../utils/type-guards.js';
|
|
|
4
4
|
import { HttpClientOptions } from './http-client-options.js';
|
|
5
5
|
import { HttpClientAdapter } from './http-client.adapter.js';
|
|
6
6
|
import { HTTP_CLIENT_MIDDLEWARE } from './tokens.js';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export function configureHttpClient({ adapter, middleware, injector, ...rest } = {}) {
|
|
8
|
+
const targetInjector = injector ?? Injector;
|
|
9
9
|
if (isDefined(adapter)) {
|
|
10
|
-
|
|
10
|
+
targetInjector.register(HttpClientAdapter, { useToken: adapter });
|
|
11
11
|
}
|
|
12
|
-
options = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
enableErrorHandling: rest.enableErrorHandling ?? options.enableErrorHandling
|
|
12
|
+
const options = {
|
|
13
|
+
baseUrl: rest.baseUrl,
|
|
14
|
+
enableErrorHandling: rest.enableErrorHandling,
|
|
16
15
|
};
|
|
17
16
|
if (isDefined(middleware)) {
|
|
18
17
|
for (const m of toArray(middleware)) {
|
|
19
|
-
|
|
18
|
+
targetInjector.register(HTTP_CLIENT_MIDDLEWARE, { useValue: m }, { multi: true });
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
targetInjector.register(HttpClientOptions, { useValue: options });
|
|
23
22
|
}
|
|
@@ -7,6 +7,8 @@ export type HttpServerRequestContext<Context = unknown> = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare abstract class HttpServer<Context = unknown> implements AsyncIterable<HttpServerRequestContext<Context>>, AsyncDisposable {
|
|
9
9
|
abstract readonly connectedSocketsCount: number;
|
|
10
|
+
abstract readonly port: number;
|
|
11
|
+
abstract readonly address: string;
|
|
10
12
|
abstract listen(port: number): Promise<void>;
|
|
11
13
|
abstract close(timeout: number): Promise<void>;
|
|
12
14
|
abstract [Symbol.asyncIterator](): AsyncIterator<HttpServerRequestContext<Context>>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { Injector } from '../../../injector/injector.js';
|
|
1
2
|
export declare class NodeHttpServerConfiguration {
|
|
2
3
|
trustedProxiesCount: number;
|
|
3
4
|
}
|
|
4
5
|
/**
|
|
5
|
-
* registers {@link HttpServer} in
|
|
6
|
+
* registers {@link HttpServer} in container
|
|
7
|
+
* @param configuration server configuration
|
|
6
8
|
*/
|
|
7
|
-
export declare function configureNodeHttpServer(configuration?: Partial<NodeHttpServerConfiguration>
|
|
9
|
+
export declare function configureNodeHttpServer({ injector, ...configuration }?: Partial<NodeHttpServerConfiguration> & {
|
|
10
|
+
injector?: Injector;
|
|
11
|
+
}): void;
|
|
@@ -6,13 +6,15 @@ export class NodeHttpServerConfiguration {
|
|
|
6
6
|
}
|
|
7
7
|
;
|
|
8
8
|
/**
|
|
9
|
-
* registers {@link HttpServer} in
|
|
9
|
+
* registers {@link HttpServer} in container
|
|
10
|
+
* @param configuration server configuration
|
|
10
11
|
*/
|
|
11
|
-
export function configureNodeHttpServer(configuration = {}) {
|
|
12
|
-
Injector
|
|
12
|
+
export function configureNodeHttpServer({ injector, ...configuration } = {}) {
|
|
13
|
+
const targetInjector = injector ?? Injector;
|
|
14
|
+
targetInjector.register(NodeHttpServerConfiguration, {
|
|
13
15
|
useValue: {
|
|
14
16
|
trustedProxiesCount: configuration.trustedProxiesCount ?? 0,
|
|
15
17
|
},
|
|
16
18
|
});
|
|
17
|
-
|
|
19
|
+
targetInjector.registerSingleton(HttpServer, { useToken: NodeHttpServer });
|
|
18
20
|
}
|
|
@@ -9,6 +9,8 @@ export declare class NodeHttpServer extends HttpServer<NodeHttpServerContext> im
|
|
|
9
9
|
#private;
|
|
10
10
|
private untrackConnectedSockets?;
|
|
11
11
|
get connectedSocketsCount(): number;
|
|
12
|
+
get port(): number;
|
|
13
|
+
get address(): string;
|
|
12
14
|
[afterResolve](): void;
|
|
13
15
|
[Symbol.asyncDispose](): Promise<void>;
|
|
14
16
|
listen(port: number): Promise<void>;
|
|
@@ -34,6 +34,12 @@ let NodeHttpServer = NodeHttpServer_1 = class NodeHttpServer extends HttpServer
|
|
|
34
34
|
get connectedSocketsCount() {
|
|
35
35
|
return this.#sockets.size;
|
|
36
36
|
}
|
|
37
|
+
get port() {
|
|
38
|
+
return this.#httpServer.address().port;
|
|
39
|
+
}
|
|
40
|
+
get address() {
|
|
41
|
+
return this.#httpServer.address().address;
|
|
42
|
+
}
|
|
37
43
|
[afterResolve]() {
|
|
38
44
|
this.#httpServer.on('request', (request, response) => this.#requestIterable.feed({ request, response }));
|
|
39
45
|
}
|
|
@@ -85,6 +91,7 @@ let NodeHttpServer = NodeHttpServer_1 = class NodeHttpServer extends HttpServer
|
|
|
85
91
|
await cancelableTimeout(250, CancellationToken.from(close$));
|
|
86
92
|
}
|
|
87
93
|
}
|
|
94
|
+
this.#requestIterable.end();
|
|
88
95
|
this.untrackConnectedSockets?.();
|
|
89
96
|
this.untrackConnectedSockets = undefined;
|
|
90
97
|
}
|
package/http/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type HttpValue = string | number | boolean | null;
|
|
|
3
3
|
export type NormalizedHttpValue = string;
|
|
4
4
|
export type HttpValueObject = Record<string, OneOrMany<HttpValue>>;
|
|
5
5
|
export type NormalizedHttpValueObject = Record<string, WritableOneOrMany<string>>;
|
|
6
|
-
export type HttpMethod = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
|
6
|
+
export type HttpMethod = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'TRACE';
|
|
7
7
|
export declare function normalizeHttpValue(value: OneOrMany<HttpValue>): WritableOneOrMany<string>;
|
|
8
8
|
export declare function normalizeSingleHttpValue(value: HttpValue): string;
|
|
9
9
|
export declare function denormalizeHttpValue(value: OneOrMany<HttpValue>): OneOrMany<HttpValue>;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { Injector } from '../../injector/index.js';
|
|
1
2
|
import { type DatabaseConfig } from '../../orm/server/index.js';
|
|
2
3
|
export declare class PostgresKeyValueStoreModuleConfig {
|
|
3
4
|
database?: DatabaseConfig;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* configure key-value store module
|
|
8
|
+
*/
|
|
9
|
+
export declare function configurePostgresKeyValueStore({ injector, ...config }?: PostgresKeyValueStoreModuleConfig & {
|
|
10
|
+
injector?: Injector;
|
|
11
|
+
}): void;
|
|
6
12
|
export declare function migratePostgresKeyValueStoreSchema(): Promise<void>;
|
|
@@ -6,11 +6,15 @@ import { PostgresKeyValueStore } from './key-value-store.service.js';
|
|
|
6
6
|
export class PostgresKeyValueStoreModuleConfig {
|
|
7
7
|
database;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* configure key-value store module
|
|
11
|
+
*/
|
|
12
|
+
export function configurePostgresKeyValueStore({ injector, ...config } = {}) {
|
|
13
|
+
const targetInjector = injector ?? Injector;
|
|
10
14
|
if (isDefined(config)) {
|
|
11
|
-
|
|
15
|
+
targetInjector.register(PostgresKeyValueStoreModuleConfig, { useValue: config });
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
targetInjector.registerSingleton(KeyValueStore, { useToken: PostgresKeyValueStore });
|
|
14
18
|
}
|
|
15
19
|
export async function migratePostgresKeyValueStoreSchema() {
|
|
16
20
|
const connection = inject(PostgresKeyValueStoreModuleConfig, undefined, { optional: true })?.database?.connection;
|
package/lock/postgres/lock.js
CHANGED
|
@@ -84,7 +84,6 @@ let PostgresLockAdapter = class PostgresLockAdapter extends Lock {
|
|
|
84
84
|
setWhere: lte(lock.expiration, TRANSACTION_TIMESTAMP),
|
|
85
85
|
})
|
|
86
86
|
.returning({ expiration: lock.expiration });
|
|
87
|
-
console.log(upsertQuery.toSQL());
|
|
88
87
|
const [result] = await upsertQuery;
|
|
89
88
|
if (isUndefined(result)) {
|
|
90
89
|
return false;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { Injector } from '../../injector/index.js';
|
|
1
2
|
import { type DatabaseConfig } from '../../orm/server/index.js';
|
|
2
3
|
export declare class PostgresLockModuleConfig {
|
|
3
4
|
database?: DatabaseConfig;
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* configure lock module
|
|
8
|
+
*/
|
|
9
|
+
export declare function configurePostgresLock({ injector, ...config }?: PostgresLockModuleConfig & {
|
|
10
|
+
injector?: Injector;
|
|
11
|
+
}): void;
|
|
6
12
|
export declare function migratePostgresLockSchema(): Promise<void>;
|
package/lock/postgres/module.js
CHANGED
|
@@ -3,17 +3,21 @@ import { Database, migrate } from '../../orm/server/index.js';
|
|
|
3
3
|
import { isDefined } from '../../utils/type-guards.js';
|
|
4
4
|
import { Lock } from '../lock.js';
|
|
5
5
|
import { LockProvider } from '../provider.js';
|
|
6
|
-
import { PostgresLockProvider } from './provider.js';
|
|
7
6
|
import { PostgresLockAdapter } from './lock.js';
|
|
7
|
+
import { PostgresLockProvider } from './provider.js';
|
|
8
8
|
export class PostgresLockModuleConfig {
|
|
9
9
|
database;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* configure lock module
|
|
13
|
+
*/
|
|
14
|
+
export function configurePostgresLock({ injector, ...config } = {}) {
|
|
15
|
+
const targetInjector = injector ?? Injector;
|
|
12
16
|
if (isDefined(config)) {
|
|
13
|
-
|
|
17
|
+
targetInjector.register(PostgresLockModuleConfig, { useValue: config });
|
|
14
18
|
}
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
targetInjector.registerSingleton(LockProvider, { useToken: PostgresLockProvider });
|
|
20
|
+
targetInjector.registerSingleton(Lock, { useToken: PostgresLockAdapter });
|
|
17
21
|
}
|
|
18
22
|
export async function migratePostgresLockSchema() {
|
|
19
23
|
const connection = inject(PostgresLockModuleConfig, undefined, { optional: true })?.database?.connection;
|
package/logger/formatter.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export type LogPayload = {
|
|
|
5
5
|
level: LogLevel;
|
|
6
6
|
module: string[];
|
|
7
7
|
message: string;
|
|
8
|
+
interpolationKeys: string[];
|
|
8
9
|
context: Record<string>;
|
|
10
|
+
error?: unknown;
|
|
9
11
|
};
|
|
10
12
|
/** Formats a log payload for a transport. */
|
|
11
13
|
export declare abstract class LogFormatter {
|
|
@@ -21,8 +21,8 @@ let JsonLogFormatter = class JsonLogFormatter extends LogFormatter {
|
|
|
21
21
|
...payload.context,
|
|
22
22
|
};
|
|
23
23
|
// Special handling for error objects to make them serializable
|
|
24
|
-
if (isNotNullOrUndefined(
|
|
25
|
-
logObject['error'] = formatError(
|
|
24
|
+
if (isNotNullOrUndefined(payload.error)) {
|
|
25
|
+
logObject['error'] = formatError(payload.error, { includeStack: true });
|
|
26
26
|
}
|
|
27
27
|
return JSON.stringify(logObject);
|
|
28
28
|
}
|
|
@@ -8,6 +8,7 @@ import { Singleton } from '../../injector/decorators.js';
|
|
|
8
8
|
import { supportsColoredStdout } from '../../supports.js';
|
|
9
9
|
import { enumValueName } from '../../utils/enum.js';
|
|
10
10
|
import { formatError } from '../../utils/format-error.js';
|
|
11
|
+
import { objectKeys } from '../../utils/object/object.js';
|
|
11
12
|
import { isNotNullOrUndefined } from '../../utils/type-guards.js';
|
|
12
13
|
import { LogFormatter } from '../formatter.js';
|
|
13
14
|
import { LogLevel } from '../level.js';
|
|
@@ -28,23 +29,20 @@ let PrettyPrintLogFormatter = class PrettyPrintLogFormatter extends LogFormatter
|
|
|
28
29
|
const levelName = enumValueName(LogLevel, payload.level).toUpperCase();
|
|
29
30
|
const levelString = `${levelName}:`.padEnd(8);
|
|
30
31
|
const moduleString = payload.module.map((m) => `[${m}]`).join(' ');
|
|
31
|
-
const metadata = { ...payload.context };
|
|
32
32
|
let metadataString = '';
|
|
33
33
|
let errorString = '';
|
|
34
|
-
if (
|
|
34
|
+
if (objectKeys(payload.context).length > 0) {
|
|
35
35
|
const displayMeta = {};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!interpolationKeys.includes(key)) {
|
|
40
|
-
displayMeta[key] = metadata[key];
|
|
36
|
+
for (const key in payload.context) {
|
|
37
|
+
if (!payload.interpolationKeys.includes(key)) {
|
|
38
|
+
displayMeta[key] = payload.context[key];
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
|
-
if (
|
|
41
|
+
if (objectKeys(displayMeta).length > 0) {
|
|
44
42
|
metadataString = ` ${dimColor}${JSON.stringify(displayMeta)}${resetColor}`;
|
|
45
43
|
}
|
|
46
|
-
if (isNotNullOrUndefined(
|
|
47
|
-
errorString += `\n${formatError(
|
|
44
|
+
if (isNotNullOrUndefined(payload.error)) {
|
|
45
|
+
errorString += `\n${formatError(payload.error, { includeStack: true })}`;
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
return `${dimColor}${payload.timestamp.toISOString()}${resetColor} ${color}${levelString}${resetColor} ${moduleString}${moduleString.length > 0 ? ' ' : ''}${payload.message}${metadataString}${errorString}`;
|
package/logger/logger.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class Logger implements Resolvable<LoggerArgument> {
|
|
|
18
18
|
readonly context: Record<string>;
|
|
19
19
|
readonly level: LogLevel | undefined;
|
|
20
20
|
readonly [resolveArgumentType]: LoggerArgument;
|
|
21
|
-
error(message: string, context?: Record<string>): void;
|
|
21
|
+
error(message: string, error: unknown, context?: Record<string>): void;
|
|
22
22
|
error(error: unknown, context?: Record<string>): void;
|
|
23
23
|
warn(message: string, context?: Record<string>): void;
|
|
24
24
|
info(message: string, context?: Record<string>): void;
|