@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
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PostgresTask } from './task.model.js';
|
|
2
|
-
export declare const queueSchema: import("../../orm/server/index.js").DatabaseSchema<"queue">;
|
|
3
|
-
export declare const taskState: import("../../orm/enums.js").PgEnumFromEnumeration<{
|
|
4
|
-
readonly Pending: "pending";
|
|
5
|
-
readonly Running: "running";
|
|
6
|
-
readonly Completed: "completed";
|
|
7
|
-
readonly Cancelled: "cancelled";
|
|
8
|
-
readonly Waiting: "waiting";
|
|
9
|
-
readonly Dead: "dead";
|
|
10
|
-
}>;
|
|
11
|
-
export declare const task: import("../../orm/server/types.js").PgTableFromType<{
|
|
12
|
-
new (): PostgresTask<any, any, any>;
|
|
13
|
-
readonly entityName: "Task";
|
|
14
|
-
}, "queue">;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { databaseSchema } from '../../orm/server/index.js';
|
|
2
|
-
import { TaskState } from '../queue.js';
|
|
3
|
-
import { PostgresTask } from './task.model.js';
|
|
4
|
-
export const queueSchema = databaseSchema('queue');
|
|
5
|
-
export const taskState = queueSchema.getEnum(TaskState);
|
|
6
|
-
export const task = queueSchema.getTable((PostgresTask));
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BaseEntity, type Json, type Timestamp } from '../../orm/index.js';
|
|
2
|
-
import type { ObjectLiteral } from '../../types/types.js';
|
|
3
|
-
import { type Task, TaskState } from '../queue.js';
|
|
4
|
-
export declare class PostgresTask<Data extends ObjectLiteral = ObjectLiteral, State extends ObjectLiteral = ObjectLiteral, Result extends ObjectLiteral = ObjectLiteral> extends BaseEntity implements Task<Data, State, Result> {
|
|
5
|
-
static readonly entityName = "Task";
|
|
6
|
-
queue: string;
|
|
7
|
-
status: TaskState;
|
|
8
|
-
tag: string | null;
|
|
9
|
-
priority: number;
|
|
10
|
-
parentId: string | null;
|
|
11
|
-
lease: string | null;
|
|
12
|
-
enqueueTimestamp: Timestamp;
|
|
13
|
-
scheduleTimestamp: Timestamp;
|
|
14
|
-
startTimestamp: Timestamp | null;
|
|
15
|
-
expirationTimestamp: Timestamp | null;
|
|
16
|
-
lockExpirationTimestamp: Timestamp | null;
|
|
17
|
-
completeTimestamp: Timestamp | null;
|
|
18
|
-
tries: number;
|
|
19
|
-
progress: number;
|
|
20
|
-
data: Json<Data>;
|
|
21
|
-
state: Json<State> | null;
|
|
22
|
-
result: Json<Result> | null;
|
|
23
|
-
error: Json<ObjectLiteral> | null;
|
|
24
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { BaseEntity, Index, JsonProperty, Reference, Table, TimestampProperty, Unique, UuidProperty } from '../../orm/index.js';
|
|
11
|
-
import { Enumeration, Integer, NumberProperty, StringProperty } from '../../schema/index.js';
|
|
12
|
-
import { TaskState } from '../queue.js';
|
|
13
|
-
let PostgresTask = class PostgresTask extends BaseEntity {
|
|
14
|
-
static entityName = 'Task';
|
|
15
|
-
queue;
|
|
16
|
-
status;
|
|
17
|
-
tag;
|
|
18
|
-
priority;
|
|
19
|
-
parentId;
|
|
20
|
-
lease;
|
|
21
|
-
enqueueTimestamp;
|
|
22
|
-
scheduleTimestamp;
|
|
23
|
-
startTimestamp;
|
|
24
|
-
expirationTimestamp;
|
|
25
|
-
lockExpirationTimestamp;
|
|
26
|
-
completeTimestamp;
|
|
27
|
-
tries;
|
|
28
|
-
progress;
|
|
29
|
-
data;
|
|
30
|
-
state;
|
|
31
|
-
result;
|
|
32
|
-
error;
|
|
33
|
-
};
|
|
34
|
-
__decorate([
|
|
35
|
-
StringProperty(),
|
|
36
|
-
__metadata("design:type", String)
|
|
37
|
-
], PostgresTask.prototype, "queue", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
Enumeration(TaskState),
|
|
40
|
-
__metadata("design:type", String)
|
|
41
|
-
], PostgresTask.prototype, "status", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
StringProperty({ nullable: true }),
|
|
44
|
-
__metadata("design:type", Object)
|
|
45
|
-
], PostgresTask.prototype, "tag", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
Integer(),
|
|
48
|
-
__metadata("design:type", Number)
|
|
49
|
-
], PostgresTask.prototype, "priority", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
Reference(() => PostgresTask),
|
|
52
|
-
UuidProperty({ nullable: true }),
|
|
53
|
-
__metadata("design:type", Object)
|
|
54
|
-
], PostgresTask.prototype, "parentId", void 0);
|
|
55
|
-
__decorate([
|
|
56
|
-
UuidProperty({ nullable: true }),
|
|
57
|
-
__metadata("design:type", Object)
|
|
58
|
-
], PostgresTask.prototype, "lease", void 0);
|
|
59
|
-
__decorate([
|
|
60
|
-
TimestampProperty(),
|
|
61
|
-
__metadata("design:type", Number)
|
|
62
|
-
], PostgresTask.prototype, "enqueueTimestamp", void 0);
|
|
63
|
-
__decorate([
|
|
64
|
-
TimestampProperty(),
|
|
65
|
-
__metadata("design:type", Number)
|
|
66
|
-
], PostgresTask.prototype, "scheduleTimestamp", void 0);
|
|
67
|
-
__decorate([
|
|
68
|
-
TimestampProperty({ nullable: true }),
|
|
69
|
-
__metadata("design:type", Object)
|
|
70
|
-
], PostgresTask.prototype, "startTimestamp", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
TimestampProperty({ nullable: true }),
|
|
73
|
-
__metadata("design:type", Object)
|
|
74
|
-
], PostgresTask.prototype, "expirationTimestamp", void 0);
|
|
75
|
-
__decorate([
|
|
76
|
-
TimestampProperty({ nullable: true }),
|
|
77
|
-
__metadata("design:type", Object)
|
|
78
|
-
], PostgresTask.prototype, "lockExpirationTimestamp", void 0);
|
|
79
|
-
__decorate([
|
|
80
|
-
TimestampProperty({ nullable: true }),
|
|
81
|
-
__metadata("design:type", Object)
|
|
82
|
-
], PostgresTask.prototype, "completeTimestamp", void 0);
|
|
83
|
-
__decorate([
|
|
84
|
-
Integer(),
|
|
85
|
-
__metadata("design:type", Number)
|
|
86
|
-
], PostgresTask.prototype, "tries", void 0);
|
|
87
|
-
__decorate([
|
|
88
|
-
NumberProperty(),
|
|
89
|
-
__metadata("design:type", Number)
|
|
90
|
-
], PostgresTask.prototype, "progress", void 0);
|
|
91
|
-
__decorate([
|
|
92
|
-
JsonProperty({ nullable: true }),
|
|
93
|
-
__metadata("design:type", Object)
|
|
94
|
-
], PostgresTask.prototype, "data", void 0);
|
|
95
|
-
__decorate([
|
|
96
|
-
JsonProperty({ nullable: true }),
|
|
97
|
-
__metadata("design:type", Object)
|
|
98
|
-
], PostgresTask.prototype, "state", void 0);
|
|
99
|
-
__decorate([
|
|
100
|
-
JsonProperty({ nullable: true }),
|
|
101
|
-
__metadata("design:type", Object)
|
|
102
|
-
], PostgresTask.prototype, "result", void 0);
|
|
103
|
-
__decorate([
|
|
104
|
-
JsonProperty({ nullable: true }),
|
|
105
|
-
__metadata("design:type", Object)
|
|
106
|
-
], PostgresTask.prototype, "error", void 0);
|
|
107
|
-
PostgresTask = __decorate([
|
|
108
|
-
Table('task', { schema: 'queue' }),
|
|
109
|
-
Unique(['queue', 'tag']),
|
|
110
|
-
Index(['queue', 'status', 'priority', 'scheduleTimestamp']),
|
|
111
|
-
Index(['queue', 'status', 'lockExpirationTimestamp']),
|
|
112
|
-
Index(['queue', 'completeTimestamp']),
|
|
113
|
-
Index(['parentId', 'status'])
|
|
114
|
-
], PostgresTask);
|
|
115
|
-
export { PostgresTask };
|
package/queue/provider.js
DELETED
package/queue/queue.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { defineEnum } from '../enumeration/enumeration.js';
|
|
2
|
-
import { createArray } from '../utils/array/array.js';
|
|
3
|
-
import { cancelableTimeout } from '../utils/timing.js';
|
|
4
|
-
import { isDefined } from '../utils/type-guards.js';
|
|
5
|
-
import { millisecondsPerDay, millisecondsPerMinute, millisecondsPerSecond } from '../utils/units.js';
|
|
6
|
-
import { QueueEnqueueBatch } from './enqueue-batch.js';
|
|
7
|
-
import { BatchTaskContext } from './task-context.js';
|
|
8
|
-
export const TaskState = defineEnum('TaskState', {
|
|
9
|
-
/**
|
|
10
|
-
* The task is waiting to be processed.
|
|
11
|
-
*/
|
|
12
|
-
Pending: 'pending',
|
|
13
|
-
/**
|
|
14
|
-
* The task is currently being processed.
|
|
15
|
-
*/
|
|
16
|
-
Running: 'running',
|
|
17
|
-
/**
|
|
18
|
-
* The task has been completed successfully.
|
|
19
|
-
*/
|
|
20
|
-
Completed: 'completed',
|
|
21
|
-
/**
|
|
22
|
-
* The task has been cancelled and will not be processed.
|
|
23
|
-
*/
|
|
24
|
-
Cancelled: 'cancelled',
|
|
25
|
-
/**
|
|
26
|
-
* The task is scheduled to be processed in the future when all children have completed.
|
|
27
|
-
*/
|
|
28
|
-
Waiting: 'waiting',
|
|
29
|
-
/**
|
|
30
|
-
* The task has failed and will not be retried.
|
|
31
|
-
*/
|
|
32
|
-
Dead: 'dead',
|
|
33
|
-
});
|
|
34
|
-
export const defaultTaskPriority = 1000;
|
|
35
|
-
export const UniqueTagStrategy = defineEnum('UniqueTagStrategy', {
|
|
36
|
-
KeepOld: 0,
|
|
37
|
-
TakeNew: 1,
|
|
38
|
-
});
|
|
39
|
-
export const defaultQueueConfig = {
|
|
40
|
-
processTimeout: millisecondsPerMinute * 5,
|
|
41
|
-
executionTimeout: millisecondsPerMinute * 60,
|
|
42
|
-
maxTries: 3,
|
|
43
|
-
retentionPeriod: 30 * millisecondsPerDay,
|
|
44
|
-
globalConcurrency: null,
|
|
45
|
-
circuitBreakerThreshold: 5,
|
|
46
|
-
circuitBreakerResetTimeout: 30 * millisecondsPerSecond,
|
|
47
|
-
retryDelayMinimum: 5 * millisecondsPerSecond,
|
|
48
|
-
retryDelayMaximum: 5 * millisecondsPerMinute,
|
|
49
|
-
retryDelayGrowth: 2,
|
|
50
|
-
};
|
|
51
|
-
export class Queue {
|
|
52
|
-
batch() {
|
|
53
|
-
return new QueueEnqueueBatch(this);
|
|
54
|
-
}
|
|
55
|
-
process({ concurrency = 1, cancellationSignal }, handler, logger) {
|
|
56
|
-
for (let i = 0; i < concurrency; i++) {
|
|
57
|
-
void this.processWorker(cancellationSignal, handler, logger);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
processBatch({ batchSize = 10, concurrency = 1, cancellationSignal }, handler, logger) {
|
|
61
|
-
for (let i = 0; i < concurrency; i++) {
|
|
62
|
-
void this.processBatchWorker(batchSize, cancellationSignal, handler, logger);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async processWorker(cancellationSignal, handler, logger) {
|
|
66
|
-
await this.processBatchWorker(1, cancellationSignal, async (batchContext) => {
|
|
67
|
-
const task = batchContext.tasks[0];
|
|
68
|
-
const context = batchContext.for(task);
|
|
69
|
-
const result = await handler(context);
|
|
70
|
-
if (isDefined(result)) {
|
|
71
|
-
return [result];
|
|
72
|
-
}
|
|
73
|
-
return undefined;
|
|
74
|
-
}, logger);
|
|
75
|
-
}
|
|
76
|
-
async processBatchWorker(size, cancellationSignal, handler, logger) {
|
|
77
|
-
for await (const tasks of this.getBatchConsumer(size, cancellationSignal)) {
|
|
78
|
-
const batchToken = cancellationSignal.createChild();
|
|
79
|
-
const context = new BatchTaskContext(this, tasks, batchToken, logger);
|
|
80
|
-
let activeTaskIds = new Set(tasks.map((t) => t.id));
|
|
81
|
-
context.logger.verbose(`Processing batch of ${tasks.length}`);
|
|
82
|
-
void (async () => {
|
|
83
|
-
while (batchToken.isUnset) {
|
|
84
|
-
await cancelableTimeout(Math.min(this.processTimeout / 2, 5000), batchToken);
|
|
85
|
-
if (batchToken.isSet) {
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
const tasksToTouch = tasks.filter((t) => activeTaskIds.has(t.id));
|
|
90
|
-
if (tasksToTouch.length > 0) {
|
|
91
|
-
const touchedIds = await this.touchMany(tasksToTouch);
|
|
92
|
-
if (touchedIds.length != tasksToTouch.length) {
|
|
93
|
-
const lostCount = tasksToTouch.length - touchedIds.length;
|
|
94
|
-
context.logger.warn(`Batch integrity compromised: ${lostCount} tasks lost lease. Aborting batch.`);
|
|
95
|
-
activeTaskIds = new Set(touchedIds);
|
|
96
|
-
batchToken.set();
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
activeTaskIds = new Set(touchedIds);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (activeTaskIds.size == 0 && batchToken.isUnset) {
|
|
103
|
-
context.logger.warn(`All tasks in batch lost lease. Stopping worker.`);
|
|
104
|
-
batchToken.set();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
context.logger.error(error);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
})();
|
|
112
|
-
try {
|
|
113
|
-
if (batchToken.isSet) {
|
|
114
|
-
throw new Error('Tasks cancelled before start');
|
|
115
|
-
}
|
|
116
|
-
const results = await handler(context);
|
|
117
|
-
if (isDefined(results)) {
|
|
118
|
-
context.logger.verbose(`Acknowledging batch`);
|
|
119
|
-
await this.acknowledgeMany(tasks, results);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
context.logger.error(error);
|
|
124
|
-
await this.failMany(tasks, createArray(tasks.length, () => error));
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
batchToken.set();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|