@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/test1.js
CHANGED
|
@@ -9,7 +9,7 @@ import { configurePostgresKeyValueStore, migratePostgresKeyValueStoreSchema } fr
|
|
|
9
9
|
import { configurePostgresLock, migratePostgresLockSchema } from './lock/postgres/index.js';
|
|
10
10
|
import { PrettyPrintLogFormatter, provideConsoleLogTransport } from './logger/index.js';
|
|
11
11
|
import { configureOrm, injectRepository } from './orm/server/index.js';
|
|
12
|
-
import {
|
|
12
|
+
import { configurePostgresTaskQueue, migratePostgresTaskQueueSchema } from './task-queue/postgres/index.js';
|
|
13
13
|
import { migrateTestSchema } from './test/module.js';
|
|
14
14
|
import { Test, testData } from './test/test.model.js';
|
|
15
15
|
import { timedBenchmarkAsync } from './utils/benchmark.js';
|
package/test4.js
CHANGED
|
@@ -17,7 +17,7 @@ import { injectAsync } from './injector/inject.js';
|
|
|
17
17
|
import { configureLocalMessageBus } from './message-bus/index.js';
|
|
18
18
|
import { configureS3ObjectStorage } from './object-storage/index.js';
|
|
19
19
|
import { configureOrm } from './orm/server/index.js';
|
|
20
|
-
import {
|
|
20
|
+
import { configurePostgresTaskQueue } from './task-queue/postgres/module.js';
|
|
21
21
|
import { boolean, positiveInteger, string } from './utils/config-parser.js';
|
|
22
22
|
import { cancelableTimeout } from './utils/timing.js';
|
|
23
23
|
const config = {
|
|
@@ -100,7 +100,7 @@ async function bootstrap() {
|
|
|
100
100
|
fileUploadObjectStorageModule: 'document-uploads',
|
|
101
101
|
filePreviewObjectStorageModule: 'document-previews',
|
|
102
102
|
});
|
|
103
|
-
|
|
103
|
+
configurePostgresTaskQueue();
|
|
104
104
|
configureLocalMessageBus();
|
|
105
105
|
console.log('Configuring AI service');
|
|
106
106
|
configureAiService({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './integration-setup.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './integration-setup.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PoolConfig } from 'pg';
|
|
2
|
+
import { type AuthenticationAncillaryService } from '../authentication/server/index.js';
|
|
3
|
+
import { Injector } from '../injector/index.js';
|
|
4
|
+
import { LogLevel } from '../logger/index.js';
|
|
5
|
+
import { Database } from '../orm/server/index.js';
|
|
6
|
+
import type { Type } from '../types/index.js';
|
|
7
|
+
export type IntegrationTestOptions = {
|
|
8
|
+
dbConfig?: Partial<PoolConfig>;
|
|
9
|
+
orm?: {
|
|
10
|
+
schema?: string;
|
|
11
|
+
};
|
|
12
|
+
api?: {
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
port?: number;
|
|
15
|
+
};
|
|
16
|
+
logLevels?: Record<string, LogLevel>;
|
|
17
|
+
modules?: {
|
|
18
|
+
taskQueue?: boolean;
|
|
19
|
+
messageBus?: boolean;
|
|
20
|
+
circuitBreaker?: boolean;
|
|
21
|
+
rateLimiter?: boolean;
|
|
22
|
+
authentication?: boolean;
|
|
23
|
+
keyValueStore?: boolean;
|
|
24
|
+
audit?: boolean;
|
|
25
|
+
lock?: boolean;
|
|
26
|
+
signals?: boolean;
|
|
27
|
+
api?: boolean;
|
|
28
|
+
test?: boolean;
|
|
29
|
+
webServer?: boolean;
|
|
30
|
+
};
|
|
31
|
+
authenticationAncillaryService?: Type<AuthenticationAncillaryService>;
|
|
32
|
+
};
|
|
33
|
+
export type TestContext = {
|
|
34
|
+
injector: Injector;
|
|
35
|
+
database: Database;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Standard setup for integration tests.
|
|
39
|
+
*/
|
|
40
|
+
export declare function setupIntegrationTest(options?: IntegrationTestOptions): Promise<TestContext>;
|
|
41
|
+
/**
|
|
42
|
+
* Helper to truncate specific tables in a schema.
|
|
43
|
+
* Useful in beforeEach() to reset state.
|
|
44
|
+
*/
|
|
45
|
+
export declare function truncateTables(database: Database, schema: string, tables: string[]): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Helper to delete data for a specific tenant from specific tables.
|
|
48
|
+
* Useful for parallel tests to avoid interference.
|
|
49
|
+
*/
|
|
50
|
+
export declare function clearTenantData(database: Database, schema: string, tables: string[], tenantId: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Helper to drop specific tables.
|
|
53
|
+
* Useful in beforeAll() cleanups.
|
|
54
|
+
*/
|
|
55
|
+
export declare function dropTables(database: Database, schema: string, tables: string[]): Promise<void>;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { configureApiServer } from '../api/server/index.js';
|
|
3
|
+
import { configureAudit, migrateAuditSchema } from '../audit/index.js';
|
|
4
|
+
import { AuthenticationApiClient } from '../authentication/client/api.client.js';
|
|
5
|
+
import { configureAuthenticationClient } from '../authentication/client/index.js';
|
|
6
|
+
import { AuthenticationApiController, configureAuthenticationServer, migrateAuthenticationSchema } from '../authentication/server/index.js';
|
|
7
|
+
import { configurePostgresCircuitBreaker, migratePostgresCircuitBreaker } from '../circuit-breaker/postgres/module.js';
|
|
8
|
+
import { configureUndiciHttpClientAdapter } from '../http/client/adapters/undici.adapter.js';
|
|
9
|
+
import { configureHttpClient } from '../http/client/index.js';
|
|
10
|
+
import { HttpServer } from '../http/server/index.js';
|
|
11
|
+
import { configureNodeHttpServer } from '../http/server/node/module.js';
|
|
12
|
+
import { Injector, runInInjectionContext } from '../injector/index.js';
|
|
13
|
+
import { configurePostgresKeyValueStore, migratePostgresKeyValueStoreSchema } from '../key-value-store/postgres/module.js';
|
|
14
|
+
import { configurePostgresLock, migratePostgresLockSchema } from '../lock/postgres/module.js';
|
|
15
|
+
import { ConsoleLogTransport, DEFAULT_LOG_LEVEL, LogFormatter, LogLevel, LogManager, LogTransport, PrettyPrintLogFormatter } from '../logger/index.js';
|
|
16
|
+
import { configureLocalMessageBus } from '../message-bus/index.js';
|
|
17
|
+
import { configureWebServerModule, WebServerModule } from '../module/modules/web-server.module.js';
|
|
18
|
+
import { configureOrm, Database } from '../orm/server/index.js';
|
|
19
|
+
import { configurePostgresRateLimiter, migratePostgresRateLimiterSchema } from '../rate-limit/postgres/module.js';
|
|
20
|
+
import { configureDefaultSignalsImplementation } from '../signals/implementation/configure.js';
|
|
21
|
+
import { configurePostgresTaskQueue, migratePostgresTaskQueueSchema } from '../task-queue/postgres/index.js';
|
|
22
|
+
import * as configParser from '../utils/config-parser.js';
|
|
23
|
+
import { objectEntries } from '../utils/object/object.js';
|
|
24
|
+
import { isDefined } from '../utils/type-guards.js';
|
|
25
|
+
/**
|
|
26
|
+
* Standard setup for integration tests.
|
|
27
|
+
*/
|
|
28
|
+
export async function setupIntegrationTest(options = {}) {
|
|
29
|
+
const injector = new Injector('TestInjector');
|
|
30
|
+
// 1. Logger Setup
|
|
31
|
+
injector.register(LogFormatter, { useToken: PrettyPrintLogFormatter });
|
|
32
|
+
injector.register(LogTransport, { useToken: ConsoleLogTransport });
|
|
33
|
+
injector.register(DEFAULT_LOG_LEVEL, { useValue: LogLevel.Warn });
|
|
34
|
+
const logManager = injector.resolve(LogManager);
|
|
35
|
+
logManager.setModuleLevel('Audit', LogLevel.Error);
|
|
36
|
+
if (isDefined(options.logLevels)) {
|
|
37
|
+
for (const [module, level] of objectEntries(options.logLevels)) {
|
|
38
|
+
logManager.setModuleLevel(module, level);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// 2. Database Config
|
|
42
|
+
const dbConfig = {
|
|
43
|
+
host: configParser.string('DATABASE_HOST', '127.0.0.1'),
|
|
44
|
+
port: configParser.positiveInteger('DATABASE_PORT', 5432),
|
|
45
|
+
user: configParser.string('DATABASE_USER', 'tstdl'),
|
|
46
|
+
password: configParser.string('DATABASE_PASS', 'wf7rq6glrk5jykne'),
|
|
47
|
+
database: configParser.string('DATABASE_NAME', 'tstdl'),
|
|
48
|
+
...options.dbConfig,
|
|
49
|
+
};
|
|
50
|
+
// 4. Configure ORM
|
|
51
|
+
configureOrm({
|
|
52
|
+
repositoryConfig: { schema: options.orm?.schema ?? 'test' },
|
|
53
|
+
connection: dbConfig,
|
|
54
|
+
injector,
|
|
55
|
+
});
|
|
56
|
+
// 5. Database Resolution
|
|
57
|
+
// We resolve the DB here to allow for immediate schema operations below
|
|
58
|
+
const database = injector.resolve(Database);
|
|
59
|
+
await runMigrationSafely(database, async () => {
|
|
60
|
+
// 6. Schema Setup Helper
|
|
61
|
+
// Automatically create the schema if a specific one was requested
|
|
62
|
+
if (isDefined(options.orm?.schema)) {
|
|
63
|
+
await database.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(options.orm.schema)}`);
|
|
64
|
+
}
|
|
65
|
+
// 7. Optional Modules
|
|
66
|
+
if (options.modules?.messageBus ?? options.modules?.taskQueue ?? options.modules?.authentication ?? options.modules?.test) {
|
|
67
|
+
configureLocalMessageBus({ injector });
|
|
68
|
+
}
|
|
69
|
+
if (options.modules?.taskQueue) {
|
|
70
|
+
configurePostgresTaskQueue({ injector });
|
|
71
|
+
await runInInjectionContext(injector, migratePostgresTaskQueueSchema);
|
|
72
|
+
}
|
|
73
|
+
if (options.modules?.circuitBreaker ?? options.modules?.taskQueue) {
|
|
74
|
+
configurePostgresCircuitBreaker({ injector });
|
|
75
|
+
await runInInjectionContext(injector, migratePostgresCircuitBreaker);
|
|
76
|
+
}
|
|
77
|
+
if (options.modules?.rateLimiter ?? options.modules?.taskQueue) {
|
|
78
|
+
configurePostgresRateLimiter({ injector });
|
|
79
|
+
await runInInjectionContext(injector, migratePostgresRateLimiterSchema);
|
|
80
|
+
}
|
|
81
|
+
if (options.modules?.keyValueStore ?? options.modules?.authentication) {
|
|
82
|
+
configurePostgresKeyValueStore({ injector });
|
|
83
|
+
await runInInjectionContext(injector, migratePostgresKeyValueStoreSchema);
|
|
84
|
+
}
|
|
85
|
+
if (options.modules?.lock ?? options.modules?.authentication) {
|
|
86
|
+
configurePostgresLock({ injector });
|
|
87
|
+
await runInInjectionContext(injector, migratePostgresLockSchema);
|
|
88
|
+
}
|
|
89
|
+
if (options.modules?.signals ?? options.modules?.authentication ?? options.modules?.test) {
|
|
90
|
+
configureDefaultSignalsImplementation();
|
|
91
|
+
}
|
|
92
|
+
if (options.modules?.audit ?? options.modules?.authentication) {
|
|
93
|
+
configureAudit({ injector });
|
|
94
|
+
await runInInjectionContext(injector, migrateAuditSchema);
|
|
95
|
+
}
|
|
96
|
+
if (options.modules?.authentication) {
|
|
97
|
+
configureAuthenticationServer({
|
|
98
|
+
serviceOptions: { secret: 'test-secret' },
|
|
99
|
+
authenticationAncillaryService: options.authenticationAncillaryService,
|
|
100
|
+
injector,
|
|
101
|
+
});
|
|
102
|
+
await runInInjectionContext(injector, migrateAuthenticationSchema);
|
|
103
|
+
}
|
|
104
|
+
if (options.modules?.api ?? options.modules?.authentication) {
|
|
105
|
+
configureNodeHttpServer({ trustedProxiesCount: 0, injector });
|
|
106
|
+
configureApiServer({ controllers: [AuthenticationApiController], injector });
|
|
107
|
+
configureUndiciHttpClientAdapter({ injector });
|
|
108
|
+
configureAuthenticationClient({
|
|
109
|
+
authenticationApiClient: AuthenticationApiClient,
|
|
110
|
+
registerMiddleware: true,
|
|
111
|
+
}, injector);
|
|
112
|
+
if (options.modules?.webServer ?? options.modules?.api ?? options.modules?.authentication) {
|
|
113
|
+
const port = options.api?.port ?? 0;
|
|
114
|
+
configureWebServerModule({ port, injector });
|
|
115
|
+
const webServerModule = await injector.resolveAsync(WebServerModule);
|
|
116
|
+
const httpServer = await injector.resolveAsync(HttpServer);
|
|
117
|
+
void webServerModule.run();
|
|
118
|
+
// Wait for server to be listening
|
|
119
|
+
while (true) {
|
|
120
|
+
try {
|
|
121
|
+
if (isDefined(httpServer.port)) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// ignore
|
|
127
|
+
}
|
|
128
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
129
|
+
}
|
|
130
|
+
configureHttpClient({ baseUrl: options.api?.baseUrl ?? `http://localhost:${httpServer.port}`, injector });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return { injector, database };
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Helper to run a migration safely with a database advisory lock to prevent race conditions.
|
|
138
|
+
*/
|
|
139
|
+
async function runMigrationSafely(database, migration) {
|
|
140
|
+
const lockId = 123456789; // Fixed lock ID for migrations
|
|
141
|
+
await database.execute(sql `SELECT pg_advisory_lock(${lockId})`);
|
|
142
|
+
try {
|
|
143
|
+
await migration();
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
await database.execute(sql `SELECT pg_advisory_unlock(${lockId})`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Helper to truncate specific tables in a schema.
|
|
151
|
+
* Useful in beforeEach() to reset state.
|
|
152
|
+
*/
|
|
153
|
+
export async function truncateTables(database, schema, tables) {
|
|
154
|
+
if (tables.length == 0) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
// Using CASCADE to handle foreign keys automatically
|
|
158
|
+
for (const table of tables) {
|
|
159
|
+
await database.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier(table)} CASCADE`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Helper to delete data for a specific tenant from specific tables.
|
|
164
|
+
* Useful for parallel tests to avoid interference.
|
|
165
|
+
*/
|
|
166
|
+
export async function clearTenantData(database, schema, tables, tenantId) {
|
|
167
|
+
if (tables.length == 0) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
for (const table of tables) {
|
|
171
|
+
await database.execute(sql `DELETE FROM ${sql.identifier(schema)}.${sql.identifier(table)} WHERE tenant_id = ${tenantId}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Helper to drop specific tables.
|
|
176
|
+
* Useful in beforeAll() cleanups.
|
|
177
|
+
*/
|
|
178
|
+
export async function dropTables(database, schema, tables) {
|
|
179
|
+
for (const table of tables) {
|
|
180
|
+
await database.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier(table)} CASCADE`);
|
|
181
|
+
}
|
|
182
|
+
}
|
package/utils/patterns.d.ts
CHANGED
|
@@ -2,4 +2,7 @@
|
|
|
2
2
|
export declare const numberPattern: RegExp;
|
|
3
3
|
/** Pattern matching valid email addresses */
|
|
4
4
|
export declare const mailPattern: RegExp;
|
|
5
|
+
/** Pattern matching valid UUIDs */
|
|
6
|
+
export declare const uuidPattern: RegExp;
|
|
5
7
|
export declare function isEmail(value: string): boolean;
|
|
8
|
+
export declare function isUuid(value: string): boolean;
|
package/utils/patterns.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/** Pattern matching valid JavaScript number literals including binary, octal and hexadecimal format but *not* Infinity and NaN */
|
|
2
2
|
export const numberPattern = /^[+-]?(?:\d*\.?\d+|\d+\.?\d*|0[bB][01]+|0[xX][\da-fA-F]+|0[oO][0-7]+)$/u;
|
|
3
3
|
/** Pattern matching valid email addresses */
|
|
4
|
-
// eslint-disable-next-line
|
|
4
|
+
// eslint-disable-next-line prefer-named-capture-group
|
|
5
5
|
export const mailPattern = /^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/u;
|
|
6
|
+
/** Pattern matching valid UUIDs */
|
|
7
|
+
export const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
|
|
6
8
|
export function isEmail(value) {
|
|
7
9
|
return mailPattern.test(value);
|
|
8
10
|
}
|
|
11
|
+
export function isUuid(value) {
|
|
12
|
+
return uuidPattern.test(value);
|
|
13
|
+
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "12d8d2c6-0f8e-4958-a036-cd42c36f2b1f",
|
|
3
|
-
"prevId": "8f6c87f8-1692-49bd-9bd4-09dc9d0bdcd4",
|
|
4
|
-
"version": "7",
|
|
5
|
-
"dialect": "postgresql",
|
|
6
|
-
"tables": {
|
|
7
|
-
"audit.event": {
|
|
8
|
-
"name": "event",
|
|
9
|
-
"schema": "audit",
|
|
10
|
-
"columns": {
|
|
11
|
-
"id": {
|
|
12
|
-
"name": "id",
|
|
13
|
-
"type": "uuid",
|
|
14
|
-
"primaryKey": true,
|
|
15
|
-
"notNull": true,
|
|
16
|
-
"default": "gen_random_uuid()"
|
|
17
|
-
},
|
|
18
|
-
"timestamp": {
|
|
19
|
-
"name": "timestamp",
|
|
20
|
-
"type": "timestamp with time zone",
|
|
21
|
-
"primaryKey": false,
|
|
22
|
-
"notNull": true
|
|
23
|
-
},
|
|
24
|
-
"tenant_id": {
|
|
25
|
-
"name": "tenant_id",
|
|
26
|
-
"type": "uuid",
|
|
27
|
-
"primaryKey": false,
|
|
28
|
-
"notNull": false
|
|
29
|
-
},
|
|
30
|
-
"correlation_id": {
|
|
31
|
-
"name": "correlation_id",
|
|
32
|
-
"type": "uuid",
|
|
33
|
-
"primaryKey": false,
|
|
34
|
-
"notNull": false
|
|
35
|
-
},
|
|
36
|
-
"module": {
|
|
37
|
-
"name": "module",
|
|
38
|
-
"type": "text",
|
|
39
|
-
"primaryKey": false,
|
|
40
|
-
"notNull": true
|
|
41
|
-
},
|
|
42
|
-
"action": {
|
|
43
|
-
"name": "action",
|
|
44
|
-
"type": "text",
|
|
45
|
-
"primaryKey": false,
|
|
46
|
-
"notNull": true
|
|
47
|
-
},
|
|
48
|
-
"outcome": {
|
|
49
|
-
"name": "outcome",
|
|
50
|
-
"type": "audit_outcome",
|
|
51
|
-
"typeSchema": "audit",
|
|
52
|
-
"primaryKey": false,
|
|
53
|
-
"notNull": true
|
|
54
|
-
},
|
|
55
|
-
"severity": {
|
|
56
|
-
"name": "severity",
|
|
57
|
-
"type": "audit_severity",
|
|
58
|
-
"typeSchema": "audit",
|
|
59
|
-
"primaryKey": false,
|
|
60
|
-
"notNull": true
|
|
61
|
-
},
|
|
62
|
-
"actor_type": {
|
|
63
|
-
"name": "actor_type",
|
|
64
|
-
"type": "actor_type",
|
|
65
|
-
"typeSchema": "audit",
|
|
66
|
-
"primaryKey": false,
|
|
67
|
-
"notNull": true
|
|
68
|
-
},
|
|
69
|
-
"actor": {
|
|
70
|
-
"name": "actor",
|
|
71
|
-
"type": "text",
|
|
72
|
-
"primaryKey": false,
|
|
73
|
-
"notNull": false
|
|
74
|
-
},
|
|
75
|
-
"impersonator_type": {
|
|
76
|
-
"name": "impersonator_type",
|
|
77
|
-
"type": "actor_type",
|
|
78
|
-
"typeSchema": "audit",
|
|
79
|
-
"primaryKey": false,
|
|
80
|
-
"notNull": false
|
|
81
|
-
},
|
|
82
|
-
"impersonator": {
|
|
83
|
-
"name": "impersonator",
|
|
84
|
-
"type": "text",
|
|
85
|
-
"primaryKey": false,
|
|
86
|
-
"notNull": false
|
|
87
|
-
},
|
|
88
|
-
"target_type": {
|
|
89
|
-
"name": "target_type",
|
|
90
|
-
"type": "text",
|
|
91
|
-
"primaryKey": false,
|
|
92
|
-
"notNull": true
|
|
93
|
-
},
|
|
94
|
-
"target_id": {
|
|
95
|
-
"name": "target_id",
|
|
96
|
-
"type": "uuid",
|
|
97
|
-
"primaryKey": false,
|
|
98
|
-
"notNull": true
|
|
99
|
-
},
|
|
100
|
-
"network_path": {
|
|
101
|
-
"name": "network_path",
|
|
102
|
-
"type": "text",
|
|
103
|
-
"primaryKey": false,
|
|
104
|
-
"notNull": false
|
|
105
|
-
},
|
|
106
|
-
"network_ip_address": {
|
|
107
|
-
"name": "network_ip_address",
|
|
108
|
-
"type": "text",
|
|
109
|
-
"primaryKey": false,
|
|
110
|
-
"notNull": false
|
|
111
|
-
},
|
|
112
|
-
"network_user_agent": {
|
|
113
|
-
"name": "network_user_agent",
|
|
114
|
-
"type": "text",
|
|
115
|
-
"primaryKey": false,
|
|
116
|
-
"notNull": false
|
|
117
|
-
},
|
|
118
|
-
"network_session_id": {
|
|
119
|
-
"name": "network_session_id",
|
|
120
|
-
"type": "uuid",
|
|
121
|
-
"primaryKey": false,
|
|
122
|
-
"notNull": false
|
|
123
|
-
},
|
|
124
|
-
"changes_before": {
|
|
125
|
-
"name": "changes_before",
|
|
126
|
-
"type": "jsonb",
|
|
127
|
-
"primaryKey": false,
|
|
128
|
-
"notNull": false
|
|
129
|
-
},
|
|
130
|
-
"changes_after": {
|
|
131
|
-
"name": "changes_after",
|
|
132
|
-
"type": "jsonb",
|
|
133
|
-
"primaryKey": false,
|
|
134
|
-
"notNull": false
|
|
135
|
-
},
|
|
136
|
-
"details": {
|
|
137
|
-
"name": "details",
|
|
138
|
-
"type": "jsonb",
|
|
139
|
-
"primaryKey": false,
|
|
140
|
-
"notNull": false
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
"indexes": {},
|
|
144
|
-
"foreignKeys": {},
|
|
145
|
-
"compositePrimaryKeys": {},
|
|
146
|
-
"uniqueConstraints": {},
|
|
147
|
-
"policies": {},
|
|
148
|
-
"checkConstraints": {},
|
|
149
|
-
"isRLSEnabled": false
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
"enums": {
|
|
153
|
-
"audit.actor_type": {
|
|
154
|
-
"name": "actor_type",
|
|
155
|
-
"schema": "audit",
|
|
156
|
-
"values": [
|
|
157
|
-
"anonymous",
|
|
158
|
-
"system",
|
|
159
|
-
"api-key",
|
|
160
|
-
"user"
|
|
161
|
-
]
|
|
162
|
-
},
|
|
163
|
-
"audit.audit_outcome": {
|
|
164
|
-
"name": "audit_outcome",
|
|
165
|
-
"schema": "audit",
|
|
166
|
-
"values": [
|
|
167
|
-
"pending",
|
|
168
|
-
"success",
|
|
169
|
-
"cancelled",
|
|
170
|
-
"failure",
|
|
171
|
-
"denied"
|
|
172
|
-
]
|
|
173
|
-
},
|
|
174
|
-
"audit.audit_severity": {
|
|
175
|
-
"name": "audit_severity",
|
|
176
|
-
"schema": "audit",
|
|
177
|
-
"values": [
|
|
178
|
-
"info",
|
|
179
|
-
"warn",
|
|
180
|
-
"error",
|
|
181
|
-
"critical"
|
|
182
|
-
]
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
"schemas": {},
|
|
186
|
-
"sequences": {},
|
|
187
|
-
"roles": {},
|
|
188
|
-
"policies": {},
|
|
189
|
-
"views": {},
|
|
190
|
-
"_meta": {
|
|
191
|
-
"columns": {},
|
|
192
|
-
"schemas": {},
|
|
193
|
-
"tables": {}
|
|
194
|
-
}
|
|
195
|
-
}
|
package/queue/enqueue-batch.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { EnqueueManyItem, EnqueueOptions, Task, Queue } from './queue.js';
|
|
2
|
-
export interface QueueEnqueueBatchMethods<Data, State, Result> {
|
|
3
|
-
add(...args: Parameters<Queue<Data, State, Result>['enqueue']>): void;
|
|
4
|
-
enqueue(): ReturnType<Queue<Data, State, Result>['enqueueMany']>;
|
|
5
|
-
}
|
|
6
|
-
export declare class QueueEnqueueBatch<Data, State, Result> implements QueueEnqueueBatchMethods<Data, State, Result> {
|
|
7
|
-
private readonly queue;
|
|
8
|
-
/** added items */
|
|
9
|
-
items: EnqueueManyItem<Data>[];
|
|
10
|
-
constructor(queue: Queue<Data, State, Result>);
|
|
11
|
-
/** add data to items */
|
|
12
|
-
add(data: Data, options?: EnqueueOptions): void;
|
|
13
|
-
/** enqueues all added items */
|
|
14
|
-
enqueue(returnTasks?: false): Promise<void>;
|
|
15
|
-
enqueue(returnTasks: true): Promise<Task<Data, State, Result>[]>;
|
|
16
|
-
enqueue(returnTasks?: boolean): Promise<Task<Data, State, Result>[] | undefined>;
|
|
17
|
-
}
|
package/queue/enqueue-batch.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export class QueueEnqueueBatch {
|
|
2
|
-
queue;
|
|
3
|
-
/** added items */
|
|
4
|
-
items;
|
|
5
|
-
constructor(queue) {
|
|
6
|
-
this.queue = queue;
|
|
7
|
-
this.items = [];
|
|
8
|
-
}
|
|
9
|
-
/** add data to items */
|
|
10
|
-
add(data, options) {
|
|
11
|
-
this.items.push({ data, ...options });
|
|
12
|
-
}
|
|
13
|
-
async enqueue(returnTasks) {
|
|
14
|
-
const items = this.items;
|
|
15
|
-
this.items = [];
|
|
16
|
-
return await this.queue.enqueueMany(items, { returnTasks });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
CREATE TABLE "queue"."job" (
|
|
2
|
-
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
3
|
-
"queue" text NOT NULL,
|
|
4
|
-
"tag" text,
|
|
5
|
-
"priority" integer NOT NULL,
|
|
6
|
-
"enqueue_timestamp" timestamp with time zone NOT NULL,
|
|
7
|
-
"tries" integer NOT NULL,
|
|
8
|
-
"last_dequeue_timestamp" timestamp with time zone,
|
|
9
|
-
"data" jsonb NOT NULL,
|
|
10
|
-
CONSTRAINT "job_queue_tag_unique" UNIQUE("queue","tag")
|
|
11
|
-
);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
CREATE TYPE "queue"."task_state" AS ENUM('pending', 'running', 'completed', 'cancelled', 'waiting', 'dead');--> statement-breakpoint
|
|
2
|
-
CREATE TABLE "queue"."task" (
|
|
3
|
-
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
4
|
-
"queue" text NOT NULL,
|
|
5
|
-
"status" "queue"."task_state" NOT NULL,
|
|
6
|
-
"tag" text,
|
|
7
|
-
"priority" integer NOT NULL,
|
|
8
|
-
"parent_id" uuid,
|
|
9
|
-
"lease" uuid,
|
|
10
|
-
"enqueue_timestamp" timestamp with time zone NOT NULL,
|
|
11
|
-
"schedule_timestamp" timestamp with time zone NOT NULL,
|
|
12
|
-
"start_timestamp" timestamp with time zone,
|
|
13
|
-
"expiration_timestamp" timestamp with time zone,
|
|
14
|
-
"lock_expiration_timestamp" timestamp with time zone,
|
|
15
|
-
"complete_timestamp" timestamp with time zone,
|
|
16
|
-
"tries" integer NOT NULL,
|
|
17
|
-
"progress" double precision NOT NULL,
|
|
18
|
-
"data" jsonb,
|
|
19
|
-
"state" jsonb,
|
|
20
|
-
"result" jsonb,
|
|
21
|
-
"error" jsonb,
|
|
22
|
-
CONSTRAINT "task_queue_tag_unique" UNIQUE("queue","tag")
|
|
23
|
-
);
|
|
24
|
-
--> statement-breakpoint
|
|
25
|
-
DROP TABLE "queue"."job" CASCADE;--> statement-breakpoint
|
|
26
|
-
ALTER TABLE "queue"."task" ADD CONSTRAINT "task_parent_id_task_id_fk" FOREIGN KEY ("parent_id") REFERENCES "queue"."task"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
27
|
-
CREATE INDEX "task_parent_id_status_idx" ON "queue"."task" USING btree ("parent_id","status");--> statement-breakpoint
|
|
28
|
-
CREATE INDEX "task_queue_complete_timestamp_idx" ON "queue"."task" USING btree ("queue","complete_timestamp");--> statement-breakpoint
|
|
29
|
-
CREATE INDEX "task_queue_status_lock_expiration_timestamp_idx" ON "queue"."task" USING btree ("queue","status","lock_expiration_timestamp");--> statement-breakpoint
|
|
30
|
-
CREATE INDEX "task_queue_status_priority_schedule_timestamp_idx" ON "queue"."task" USING btree ("queue","status","priority","schedule_timestamp");
|