@tstdl/base 0.93.77 → 0.93.78
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/authentication/client/http-client.middleware.js +2 -2
- package/authentication/models/authentication-credentials.model.d.ts +2 -2
- package/authentication/models/authentication-credentials.model.js +5 -3
- package/authentication/models/authentication-session.model.d.ts +2 -2
- package/authentication/models/authentication-session.model.js +5 -3
- package/authentication/models/index.d.ts +4 -0
- package/authentication/models/index.js +4 -0
- package/authentication/models/service-account.model.d.ts +7 -0
- package/authentication/models/service-account.model.js +31 -0
- package/authentication/models/subject.model.d.ts +16 -0
- package/authentication/models/subject.model.js +59 -0
- package/authentication/models/system-account.model.d.ts +5 -0
- package/authentication/models/system-account.model.js +25 -0
- package/authentication/models/user.model.d.ts +15 -0
- package/authentication/models/user.model.js +47 -0
- package/authentication/server/drizzle/0001_condemned_pretty_boy.sql +70 -0
- package/authentication/server/drizzle/meta/0001_snapshot.json +651 -0
- package/authentication/server/drizzle/meta/_journal.json +7 -0
- package/authentication/server/index.d.ts +1 -0
- package/authentication/server/index.js +1 -0
- package/authentication/server/schemas.d.ts +16 -1
- package/authentication/server/schemas.js +7 -1
- package/authentication/server/subject.service.d.ts +6 -0
- package/authentication/server/subject.service.js +44 -0
- package/circuit-breaker/circuit-breaker.d.ts +32 -0
- package/circuit-breaker/circuit-breaker.js +9 -0
- package/circuit-breaker/index.d.ts +2 -0
- package/circuit-breaker/index.js +2 -0
- package/circuit-breaker/postgres/circuit-breaker.d.ts +7 -0
- package/circuit-breaker/postgres/circuit-breaker.js +78 -0
- package/circuit-breaker/postgres/drizzle/0000_hard_shocker.sql +9 -0
- package/circuit-breaker/postgres/drizzle/meta/0000_snapshot.json +82 -0
- package/circuit-breaker/postgres/drizzle/meta/_journal.json +13 -0
- package/circuit-breaker/postgres/drizzle.config.d.ts +2 -0
- package/circuit-breaker/postgres/drizzle.config.js +11 -0
- package/circuit-breaker/postgres/index.d.ts +5 -0
- package/circuit-breaker/postgres/index.js +5 -0
- package/circuit-breaker/postgres/model.d.ts +9 -0
- package/circuit-breaker/postgres/model.js +40 -0
- package/circuit-breaker/postgres/module.d.ts +6 -0
- package/circuit-breaker/postgres/module.js +25 -0
- package/circuit-breaker/postgres/provider.d.ts +6 -0
- package/circuit-breaker/postgres/provider.js +21 -0
- package/circuit-breaker/postgres/schemas.d.ts +8 -0
- package/circuit-breaker/postgres/schemas.js +6 -0
- package/circuit-breaker/provider.d.ts +4 -0
- package/circuit-breaker/provider.js +2 -0
- package/circuit-breaker/tests/circuit-breaker.test.js +113 -0
- package/document-management/models/document.model.d.ts +0 -1
- package/document-management/models/document.model.js +0 -5
- package/document-management/server/api/document-management.api.js +1 -2
- package/document-management/server/drizzle/0002_round_warbird.sql +1 -0
- package/document-management/server/drizzle/meta/0002_snapshot.json +2722 -0
- package/document-management/server/drizzle/meta/_journal.json +7 -0
- package/document-management/server/services/document-collection.service.js +3 -3
- package/document-management/server/services/document-management-ancillary.service.d.ts +1 -1
- package/document-management/server/services/document-management.service.js +1 -1
- package/document-management/server/services/document-workflow.service.js +5 -5
- package/document-management/server/services/document.service.d.ts +0 -2
- package/document-management/server/services/document.service.js +1 -2
- package/document-management/service-models/enriched/enriched-document.view.d.ts +1 -1
- package/examples/document-management/main.d.ts +1 -1
- package/examples/document-management/main.js +1 -1
- package/logger/transports/console.d.ts +1 -1
- package/logger/transports/console.js +4 -1
- package/message-bus/message-bus-base.js +1 -1
- package/package.json +6 -3
- package/queue/enqueue-batch.d.ts +11 -11
- package/queue/enqueue-batch.js +2 -3
- package/queue/index.d.ts +1 -0
- package/queue/index.js +1 -0
- package/queue/postgres/drizzle/0003_tricky_venom.sql +30 -0
- package/queue/postgres/drizzle/meta/0003_snapshot.json +288 -0
- package/queue/postgres/drizzle/meta/_journal.json +7 -0
- package/queue/postgres/drizzle.config.js +2 -2
- package/queue/postgres/index.d.ts +1 -1
- package/queue/postgres/index.js +1 -1
- package/queue/postgres/module.d.ts +1 -1
- package/queue/postgres/module.js +1 -1
- package/queue/postgres/queue.d.ts +52 -23
- package/queue/postgres/queue.js +582 -64
- package/queue/postgres/queue.provider.d.ts +1 -1
- package/queue/postgres/schemas.d.ts +13 -2
- package/queue/postgres/schemas.js +4 -2
- package/queue/postgres/task.model.d.ts +24 -0
- package/queue/postgres/task.model.js +115 -0
- package/queue/provider.d.ts +1 -1
- package/queue/queue.d.ts +158 -37
- package/queue/queue.js +97 -19
- package/queue/task-context.d.ts +38 -0
- package/queue/task-context.js +102 -0
- package/queue/tests/queue.test.d.ts +1 -0
- package/queue/tests/queue.test.js +623 -0
- package/test4.d.ts +1 -1
- package/test4.js +1 -1
- package/utils/format-error.d.ts +17 -20
- package/utils/format-error.js +105 -47
- package/queue/postgres/job.model.d.ts +0 -12
- package/queue/postgres/job.model.js +0 -53
- package/test6.js +0 -33
- /package/{test6.d.ts → circuit-breaker/tests/circuit-breaker.test.d.ts} +0 -0
|
@@ -26,13 +26,13 @@ let DocumentCollectionService = class DocumentCollectionService extends Transact
|
|
|
26
26
|
}
|
|
27
27
|
const loadIds = collectionsOrIds.filter((collection) => isString(collection));
|
|
28
28
|
if (loadIds.length == 0) {
|
|
29
|
-
return this.#ancillaryService.resolveMetadata(collectionsOrIds);
|
|
29
|
+
return this.#ancillaryService.resolveMetadata(tenantId, collectionsOrIds);
|
|
30
30
|
}
|
|
31
31
|
const loadedCollections = await this.repository.loadManyByQuery({ tenantId, id: { $in: loadIds } });
|
|
32
32
|
const collections = collectionsOrIds.map((collectionOrId) => isString(collectionOrId)
|
|
33
33
|
? assertDefinedPass(loadedCollections.find((collection) => collection.id == collectionOrId), `Could not load collection "${collectionOrId}".`)
|
|
34
34
|
: collectionOrId);
|
|
35
|
-
return this.#ancillaryService.resolveMetadata(collections);
|
|
35
|
+
return this.#ancillaryService.resolveMetadata(tenantId, collections);
|
|
36
36
|
}
|
|
37
37
|
async resolveMetadataMap(tenantId, collectionsOrIds) {
|
|
38
38
|
const names = await this.resolveMetadata(tenantId, collectionsOrIds);
|
|
@@ -63,7 +63,7 @@ let DocumentCollectionService = class DocumentCollectionService extends Transact
|
|
|
63
63
|
}
|
|
64
64
|
async assignDocument(document, collectionIds) {
|
|
65
65
|
const values = toArray(collectionIds).map((collectionId) => ({ tenantId: document.tenantId, collectionId, documentId: document.id, archiveTimestamp: null }));
|
|
66
|
-
await this.#documentCollectionAssignmentRepository.withSession(this.session).upsertMany(['collectionId', 'documentId'], values);
|
|
66
|
+
await this.#documentCollectionAssignmentRepository.withSession(this.session).upsertMany(['tenantId', 'collectionId', 'documentId'], values);
|
|
67
67
|
}
|
|
68
68
|
async archiveDocument(document, collectionIds) {
|
|
69
69
|
await this.#documentCollectionAssignmentRepository.withSession(this.session).updateManyByQuery({ tenantId: document.tenantId, collectionId: { $in: toArray(collectionIds) }, documentId: document.id, archiveTimestamp: null }, { archiveTimestamp: TRANSACTION_TIMESTAMP });
|
|
@@ -6,5 +6,5 @@ export declare abstract class DocumentManagementAncillaryService {
|
|
|
6
6
|
* @param collections An array of DocumentCollection entities.
|
|
7
7
|
* @returns A promise that resolves to an array of DocumentCollectionMetadata, corresponding to the input collections.
|
|
8
8
|
*/
|
|
9
|
-
abstract resolveMetadata(collections: DocumentCollection[]): DocumentCollectionMetadata[] | Promise<DocumentCollectionMetadata[]>;
|
|
9
|
+
abstract resolveMetadata(tenantId: string, collections: DocumentCollection[]): DocumentCollectionMetadata[] | Promise<DocumentCollectionMetadata[]>;
|
|
10
10
|
}
|
|
@@ -56,7 +56,7 @@ let DocumentManagementService = DocumentManagementService_1 = class DocumentMana
|
|
|
56
56
|
*/
|
|
57
57
|
async getRelevantDocumentCollectionIds(tenantId, documentId) {
|
|
58
58
|
const directAssignments = this.#documentCollectionService.session.$with('directAssignments').as((qb) => qb
|
|
59
|
-
.select({ collectionId: documentCollectionAssignment.
|
|
59
|
+
.select({ collectionId: documentCollectionAssignment.collectionId })
|
|
60
60
|
.from(documentCollectionAssignment)
|
|
61
61
|
.where(and(eq(documentCollectionAssignment.tenantId, tenantId), eq(documentCollectionAssignment.documentId, documentId))));
|
|
62
62
|
const requestAssignments = this.#documentRequestCollectionAssignmentRepository.session.$with('requestAssignments').as((qb) => qb
|
|
@@ -45,7 +45,7 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
|
|
|
45
45
|
if (this.isInTransaction) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
this.#queue.process({ concurrency: 5, cancellationSignal }, async (
|
|
48
|
+
this.#queue.process({ concurrency: 5, cancellationSignal }, async (taskContext) => await this.processWorkflowJob(taskContext), this.#logger);
|
|
49
49
|
}
|
|
50
50
|
async loadLatestWorkflow(tenantId, documentId) {
|
|
51
51
|
return await this.repository.loadByQuery({ tenantId, documentId }, { order: { 'metadata.createTimestamp': 'desc' } });
|
|
@@ -90,8 +90,8 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
|
|
|
90
90
|
await this.repository.update(id, { state, completeTimestamp: (state == DocumentWorkflowState.Completed) ? currentTimestamp() : undefined, failReason });
|
|
91
91
|
this.#observationService.workflowChange(id, this.session);
|
|
92
92
|
}
|
|
93
|
-
async processWorkflowJob(
|
|
94
|
-
const workflow = await this.repository.load(
|
|
93
|
+
async processWorkflowJob(task) {
|
|
94
|
+
const workflow = await this.repository.load(task.data.workflowId);
|
|
95
95
|
this.#logger.verbose(`Processing workflow "${workflow.step}" for document "${workflow.documentId}"`);
|
|
96
96
|
try {
|
|
97
97
|
await this.setWorkflowState(workflow.id, DocumentWorkflowState.Running);
|
|
@@ -109,10 +109,10 @@ let DocumentWorkflowService = DocumentWorkflowService_1 = class DocumentWorkflow
|
|
|
109
109
|
else {
|
|
110
110
|
await this.setWorkflowState(workflow.id, DocumentWorkflowState.Review);
|
|
111
111
|
}
|
|
112
|
+
await task.acknowledge();
|
|
112
113
|
}
|
|
113
114
|
catch (error) {
|
|
114
|
-
|
|
115
|
-
if (isLastTry) {
|
|
115
|
+
if (task.triesLeft == 0) {
|
|
116
116
|
await this.repository.update(workflow.id, { state: DocumentWorkflowState.Error });
|
|
117
117
|
this.#observationService.documentChange(workflow.id, this.session);
|
|
118
118
|
}
|
|
@@ -8,8 +8,6 @@ export declare class DocumentService extends Transactional {
|
|
|
8
8
|
create(tenantId: string, { typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }: TypedOmit<CreateDocumentParameters, 'uploadId'>, contentSource: Uint8Array<ArrayBuffer> | ReadableStream<Uint8Array<ArrayBuffer>> | {
|
|
9
9
|
uploadId: string;
|
|
10
10
|
uploadKey: string;
|
|
11
|
-
}, { createUserId }: {
|
|
12
|
-
createUserId?: string;
|
|
13
11
|
}): Promise<Document>;
|
|
14
12
|
update(tenantId: string, id: string, update: Partial<Pick<Document, UpdatableDocumentProperties>> & {
|
|
15
13
|
tags?: string[];
|
|
@@ -38,7 +38,7 @@ let DocumentService = DocumentService_1 = class DocumentService extends Transact
|
|
|
38
38
|
#observationService = inject(DocumentManagementObservationService);
|
|
39
39
|
#logger = inject(Logger, DocumentService_1.name);
|
|
40
40
|
repository = injectRepository(Document);
|
|
41
|
-
async create(tenantId, { typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }, contentSource
|
|
41
|
+
async create(tenantId, { typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }, contentSource) {
|
|
42
42
|
const document = await this.transaction(async (tx) => {
|
|
43
43
|
const isUpload = isNotUint8Array(contentSource) && isNotReadableStream(contentSource);
|
|
44
44
|
const document = await this.repository.withTransaction(tx).insert({
|
|
@@ -51,7 +51,6 @@ let DocumentService = DocumentService_1 = class DocumentService extends Transact
|
|
|
51
51
|
summary: summary ?? null,
|
|
52
52
|
approval: approval ?? DocumentApproval.Pending,
|
|
53
53
|
comment: comment ?? null,
|
|
54
|
-
createUserId: createUserId ?? null,
|
|
55
54
|
originalFileName: originalFileName ?? null,
|
|
56
55
|
mimeType: 'pending',
|
|
57
56
|
hash: 'pending',
|
|
@@ -6,7 +6,7 @@ import { EnrichedDocumentAssignment } from './enriched-document-assignment.view.
|
|
|
6
6
|
import type { EnrichedDocumentCategory } from './enriched-document-category.view.js';
|
|
7
7
|
import type { EnrichedDocumentManagementData } from './enriched-document-management-data.view.js';
|
|
8
8
|
import type { EnrichedDocumentType } from './enriched-document-type.view.js';
|
|
9
|
-
export declare class EnrichedDocument implements TypedOmit<DocumentView, 'typeId' | 'assignment' | 'tagIds'
|
|
9
|
+
export declare class EnrichedDocument implements TypedOmit<DocumentView, 'typeId' | 'assignment' | 'tagIds'> {
|
|
10
10
|
#private;
|
|
11
11
|
readonly id: string;
|
|
12
12
|
readonly tenantId: string;
|
|
@@ -2,7 +2,7 @@ import '../../polyfills.js';
|
|
|
2
2
|
import { DocumentManagementAuthorizationService, type DocumentCollection, type DocumentCollectionMetadata } from '../../document-management/index.js';
|
|
3
3
|
import { DocumentManagementAncillaryService } from '../../document-management/server/index.js';
|
|
4
4
|
export declare class ExampleDocumentManagementAncillaryService extends DocumentManagementAncillaryService {
|
|
5
|
-
resolveMetadata(collections: DocumentCollection[]): DocumentCollectionMetadata[];
|
|
5
|
+
resolveMetadata(_tenantId: string, collections: DocumentCollection[]): DocumentCollectionMetadata[];
|
|
6
6
|
}
|
|
7
7
|
export declare class AllowAllDocumentManagementAuthorizationService extends DocumentManagementAuthorizationService {
|
|
8
8
|
getTenantId(): string;
|
|
@@ -54,7 +54,7 @@ const config = {
|
|
|
54
54
|
},
|
|
55
55
|
};
|
|
56
56
|
let ExampleDocumentManagementAncillaryService = class ExampleDocumentManagementAncillaryService extends DocumentManagementAncillaryService {
|
|
57
|
-
resolveMetadata(collections) {
|
|
57
|
+
resolveMetadata(_tenantId, collections) {
|
|
58
58
|
return collections.map((collection) => ({ name: collection.metadata.attributes['name'] ?? collection.id.split('-')[0], group: null }));
|
|
59
59
|
}
|
|
60
60
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InjectionToken, type Resolvable, type resolveArgumentType } from '../../injector/index.js';
|
|
2
2
|
import type { ProvidersItem } from '../../injector/injector.js';
|
|
3
|
-
import
|
|
3
|
+
import { LogFormatter, type LogPayload } from '../formatter.js';
|
|
4
4
|
import { LogLevel } from '../level.js';
|
|
5
5
|
import { LogTransport, LogTransportOptions } from '../transport.js';
|
|
6
6
|
export declare class ConsoleLogTransportOptions extends LogTransportOptions {
|
|
@@ -6,6 +6,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Singleton } from '../../injector/decorators.js';
|
|
8
8
|
import { inject, injectArgument } from '../../injector/index.js';
|
|
9
|
+
import { isDefined } from '../../utils/type-guards.js';
|
|
10
|
+
import { LogFormatter } from '../formatter.js';
|
|
9
11
|
import { LogLevel } from '../level.js';
|
|
10
12
|
import { LogTransport, LogTransportOptions, provideLogTransport } from '../transport.js';
|
|
11
13
|
export class ConsoleLogTransportOptions extends LogTransportOptions {
|
|
@@ -20,7 +22,8 @@ const consoleLevelFuncMap = {
|
|
|
20
22
|
[LogLevel.Trace]: 'debug',
|
|
21
23
|
};
|
|
22
24
|
let ConsoleLogTransport = class ConsoleLogTransport extends LogTransport {
|
|
23
|
-
#
|
|
25
|
+
#argument = injectArgument(this, { optional: true });
|
|
26
|
+
#formatter = isDefined(this.#argument?.formatter) ? inject(this.#argument.formatter) : inject(LogFormatter);
|
|
24
27
|
log(payload) {
|
|
25
28
|
const message = this.#formatter.format(payload);
|
|
26
29
|
const consoleFunc = consoleLevelFuncMap[payload.level];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.93.
|
|
3
|
+
"version": "0.93.78",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"build:docs:watch": "typedoc --watch",
|
|
17
17
|
"lint": "eslint --cache source/",
|
|
18
18
|
"pub": "npm run build:production && npm run cleanup:dist && npm publish dist/",
|
|
19
|
+
"test": "vitest run",
|
|
19
20
|
"tsc:watch": "tsc --watch",
|
|
20
21
|
"tsc-alias:watch": "tsc-alias --watch",
|
|
21
22
|
"cleanup:dist": "rm -vrf dist/tools/",
|
|
@@ -161,7 +162,7 @@
|
|
|
161
162
|
"preact": "^10.28",
|
|
162
163
|
"preact-render-to-string": "^6.6",
|
|
163
164
|
"sharp": "^0.34",
|
|
164
|
-
"undici": "^7.
|
|
165
|
+
"undici": "^7.18",
|
|
165
166
|
"urlpattern-polyfill": "^10.1",
|
|
166
167
|
"zod": "^3.25"
|
|
167
168
|
},
|
|
@@ -187,7 +188,9 @@
|
|
|
187
188
|
"typedoc-plugin-markdown": "4.9",
|
|
188
189
|
"typedoc-plugin-missing-exports": "4.1",
|
|
189
190
|
"typescript": "5.9",
|
|
190
|
-
"typescript-eslint": "8.
|
|
191
|
+
"typescript-eslint": "8.52",
|
|
192
|
+
"vite-tsconfig-paths": "6.0",
|
|
193
|
+
"vitest": "4.0"
|
|
191
194
|
},
|
|
192
195
|
"overrides": {
|
|
193
196
|
"drizzle-kit": {
|
package/queue/enqueue-batch.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { EnqueueManyItem, EnqueueOptions,
|
|
2
|
-
export interface QueueEnqueueBatchMethods<
|
|
3
|
-
add(...args: Parameters<Queue<
|
|
4
|
-
enqueue(): ReturnType<Queue<
|
|
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
5
|
}
|
|
6
|
-
export declare class QueueEnqueueBatch<
|
|
6
|
+
export declare class QueueEnqueueBatch<Data, State, Result> implements QueueEnqueueBatchMethods<Data, State, Result> {
|
|
7
7
|
private readonly queue;
|
|
8
8
|
/** added items */
|
|
9
|
-
items: EnqueueManyItem<
|
|
10
|
-
constructor(queue: Queue<
|
|
9
|
+
items: EnqueueManyItem<Data>[];
|
|
10
|
+
constructor(queue: Queue<Data, State, Result>);
|
|
11
11
|
/** add data to items */
|
|
12
|
-
add(data:
|
|
12
|
+
add(data: Data, options?: EnqueueOptions): void;
|
|
13
13
|
/** enqueues all added items */
|
|
14
|
-
enqueue(
|
|
15
|
-
enqueue(
|
|
16
|
-
enqueue(
|
|
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
17
|
}
|
package/queue/enqueue-batch.js
CHANGED
|
@@ -10,10 +10,9 @@ export class QueueEnqueueBatch {
|
|
|
10
10
|
add(data, options) {
|
|
11
11
|
this.items.push({ data, ...options });
|
|
12
12
|
}
|
|
13
|
-
async enqueue(
|
|
13
|
+
async enqueue(returnTasks) {
|
|
14
14
|
const items = this.items;
|
|
15
15
|
this.items = [];
|
|
16
|
-
|
|
17
|
-
return result;
|
|
16
|
+
return await this.queue.enqueueMany(items, { returnTasks });
|
|
18
17
|
}
|
|
19
18
|
}
|
package/queue/index.d.ts
CHANGED
package/queue/index.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
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");
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "705393d9-616b-4a01-9553-3b5408f64180",
|
|
3
|
+
"prevId": "74e8909c-3a81-46a3-9fe7-176e263da2df",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"queue.task": {
|
|
8
|
+
"name": "task",
|
|
9
|
+
"schema": "queue",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "uuid",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true,
|
|
16
|
+
"default": "gen_random_uuid()"
|
|
17
|
+
},
|
|
18
|
+
"queue": {
|
|
19
|
+
"name": "queue",
|
|
20
|
+
"type": "text",
|
|
21
|
+
"primaryKey": false,
|
|
22
|
+
"notNull": true
|
|
23
|
+
},
|
|
24
|
+
"status": {
|
|
25
|
+
"name": "status",
|
|
26
|
+
"type": "task_state",
|
|
27
|
+
"typeSchema": "queue",
|
|
28
|
+
"primaryKey": false,
|
|
29
|
+
"notNull": true
|
|
30
|
+
},
|
|
31
|
+
"tag": {
|
|
32
|
+
"name": "tag",
|
|
33
|
+
"type": "text",
|
|
34
|
+
"primaryKey": false,
|
|
35
|
+
"notNull": false
|
|
36
|
+
},
|
|
37
|
+
"priority": {
|
|
38
|
+
"name": "priority",
|
|
39
|
+
"type": "integer",
|
|
40
|
+
"primaryKey": false,
|
|
41
|
+
"notNull": true
|
|
42
|
+
},
|
|
43
|
+
"parent_id": {
|
|
44
|
+
"name": "parent_id",
|
|
45
|
+
"type": "uuid",
|
|
46
|
+
"primaryKey": false,
|
|
47
|
+
"notNull": false
|
|
48
|
+
},
|
|
49
|
+
"lease": {
|
|
50
|
+
"name": "lease",
|
|
51
|
+
"type": "uuid",
|
|
52
|
+
"primaryKey": false,
|
|
53
|
+
"notNull": false
|
|
54
|
+
},
|
|
55
|
+
"enqueue_timestamp": {
|
|
56
|
+
"name": "enqueue_timestamp",
|
|
57
|
+
"type": "timestamp with time zone",
|
|
58
|
+
"primaryKey": false,
|
|
59
|
+
"notNull": true
|
|
60
|
+
},
|
|
61
|
+
"schedule_timestamp": {
|
|
62
|
+
"name": "schedule_timestamp",
|
|
63
|
+
"type": "timestamp with time zone",
|
|
64
|
+
"primaryKey": false,
|
|
65
|
+
"notNull": true
|
|
66
|
+
},
|
|
67
|
+
"start_timestamp": {
|
|
68
|
+
"name": "start_timestamp",
|
|
69
|
+
"type": "timestamp with time zone",
|
|
70
|
+
"primaryKey": false,
|
|
71
|
+
"notNull": false
|
|
72
|
+
},
|
|
73
|
+
"expiration_timestamp": {
|
|
74
|
+
"name": "expiration_timestamp",
|
|
75
|
+
"type": "timestamp with time zone",
|
|
76
|
+
"primaryKey": false,
|
|
77
|
+
"notNull": false
|
|
78
|
+
},
|
|
79
|
+
"lock_expiration_timestamp": {
|
|
80
|
+
"name": "lock_expiration_timestamp",
|
|
81
|
+
"type": "timestamp with time zone",
|
|
82
|
+
"primaryKey": false,
|
|
83
|
+
"notNull": false
|
|
84
|
+
},
|
|
85
|
+
"complete_timestamp": {
|
|
86
|
+
"name": "complete_timestamp",
|
|
87
|
+
"type": "timestamp with time zone",
|
|
88
|
+
"primaryKey": false,
|
|
89
|
+
"notNull": false
|
|
90
|
+
},
|
|
91
|
+
"tries": {
|
|
92
|
+
"name": "tries",
|
|
93
|
+
"type": "integer",
|
|
94
|
+
"primaryKey": false,
|
|
95
|
+
"notNull": true
|
|
96
|
+
},
|
|
97
|
+
"progress": {
|
|
98
|
+
"name": "progress",
|
|
99
|
+
"type": "double precision",
|
|
100
|
+
"primaryKey": false,
|
|
101
|
+
"notNull": true
|
|
102
|
+
},
|
|
103
|
+
"data": {
|
|
104
|
+
"name": "data",
|
|
105
|
+
"type": "jsonb",
|
|
106
|
+
"primaryKey": false,
|
|
107
|
+
"notNull": false
|
|
108
|
+
},
|
|
109
|
+
"state": {
|
|
110
|
+
"name": "state",
|
|
111
|
+
"type": "jsonb",
|
|
112
|
+
"primaryKey": false,
|
|
113
|
+
"notNull": false
|
|
114
|
+
},
|
|
115
|
+
"result": {
|
|
116
|
+
"name": "result",
|
|
117
|
+
"type": "jsonb",
|
|
118
|
+
"primaryKey": false,
|
|
119
|
+
"notNull": false
|
|
120
|
+
},
|
|
121
|
+
"error": {
|
|
122
|
+
"name": "error",
|
|
123
|
+
"type": "jsonb",
|
|
124
|
+
"primaryKey": false,
|
|
125
|
+
"notNull": false
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"indexes": {
|
|
129
|
+
"task_parent_id_status_idx": {
|
|
130
|
+
"name": "task_parent_id_status_idx",
|
|
131
|
+
"columns": [
|
|
132
|
+
{
|
|
133
|
+
"expression": "parent_id",
|
|
134
|
+
"isExpression": false,
|
|
135
|
+
"asc": true,
|
|
136
|
+
"nulls": "last"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"expression": "status",
|
|
140
|
+
"isExpression": false,
|
|
141
|
+
"asc": true,
|
|
142
|
+
"nulls": "last"
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"isUnique": false,
|
|
146
|
+
"concurrently": false,
|
|
147
|
+
"method": "btree",
|
|
148
|
+
"with": {}
|
|
149
|
+
},
|
|
150
|
+
"task_queue_complete_timestamp_idx": {
|
|
151
|
+
"name": "task_queue_complete_timestamp_idx",
|
|
152
|
+
"columns": [
|
|
153
|
+
{
|
|
154
|
+
"expression": "queue",
|
|
155
|
+
"isExpression": false,
|
|
156
|
+
"asc": true,
|
|
157
|
+
"nulls": "last"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"expression": "complete_timestamp",
|
|
161
|
+
"isExpression": false,
|
|
162
|
+
"asc": true,
|
|
163
|
+
"nulls": "last"
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"isUnique": false,
|
|
167
|
+
"concurrently": false,
|
|
168
|
+
"method": "btree",
|
|
169
|
+
"with": {}
|
|
170
|
+
},
|
|
171
|
+
"task_queue_status_lock_expiration_timestamp_idx": {
|
|
172
|
+
"name": "task_queue_status_lock_expiration_timestamp_idx",
|
|
173
|
+
"columns": [
|
|
174
|
+
{
|
|
175
|
+
"expression": "queue",
|
|
176
|
+
"isExpression": false,
|
|
177
|
+
"asc": true,
|
|
178
|
+
"nulls": "last"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"expression": "status",
|
|
182
|
+
"isExpression": false,
|
|
183
|
+
"asc": true,
|
|
184
|
+
"nulls": "last"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"expression": "lock_expiration_timestamp",
|
|
188
|
+
"isExpression": false,
|
|
189
|
+
"asc": true,
|
|
190
|
+
"nulls": "last"
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
"isUnique": false,
|
|
194
|
+
"concurrently": false,
|
|
195
|
+
"method": "btree",
|
|
196
|
+
"with": {}
|
|
197
|
+
},
|
|
198
|
+
"task_queue_status_priority_schedule_timestamp_idx": {
|
|
199
|
+
"name": "task_queue_status_priority_schedule_timestamp_idx",
|
|
200
|
+
"columns": [
|
|
201
|
+
{
|
|
202
|
+
"expression": "queue",
|
|
203
|
+
"isExpression": false,
|
|
204
|
+
"asc": true,
|
|
205
|
+
"nulls": "last"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"expression": "status",
|
|
209
|
+
"isExpression": false,
|
|
210
|
+
"asc": true,
|
|
211
|
+
"nulls": "last"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"expression": "priority",
|
|
215
|
+
"isExpression": false,
|
|
216
|
+
"asc": true,
|
|
217
|
+
"nulls": "last"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"expression": "schedule_timestamp",
|
|
221
|
+
"isExpression": false,
|
|
222
|
+
"asc": true,
|
|
223
|
+
"nulls": "last"
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"isUnique": false,
|
|
227
|
+
"concurrently": false,
|
|
228
|
+
"method": "btree",
|
|
229
|
+
"with": {}
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"foreignKeys": {
|
|
233
|
+
"task_parent_id_task_id_fk": {
|
|
234
|
+
"name": "task_parent_id_task_id_fk",
|
|
235
|
+
"tableFrom": "task",
|
|
236
|
+
"tableTo": "task",
|
|
237
|
+
"schemaTo": "queue",
|
|
238
|
+
"columnsFrom": [
|
|
239
|
+
"parent_id"
|
|
240
|
+
],
|
|
241
|
+
"columnsTo": [
|
|
242
|
+
"id"
|
|
243
|
+
],
|
|
244
|
+
"onDelete": "no action",
|
|
245
|
+
"onUpdate": "no action"
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
"compositePrimaryKeys": {},
|
|
249
|
+
"uniqueConstraints": {
|
|
250
|
+
"task_queue_tag_unique": {
|
|
251
|
+
"name": "task_queue_tag_unique",
|
|
252
|
+
"nullsNotDistinct": false,
|
|
253
|
+
"columns": [
|
|
254
|
+
"queue",
|
|
255
|
+
"tag"
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
"policies": {},
|
|
260
|
+
"checkConstraints": {},
|
|
261
|
+
"isRLSEnabled": false
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
"enums": {
|
|
265
|
+
"queue.task_state": {
|
|
266
|
+
"name": "task_state",
|
|
267
|
+
"schema": "queue",
|
|
268
|
+
"values": [
|
|
269
|
+
"pending",
|
|
270
|
+
"running",
|
|
271
|
+
"completed",
|
|
272
|
+
"cancelled",
|
|
273
|
+
"waiting",
|
|
274
|
+
"dead"
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"schemas": {},
|
|
279
|
+
"sequences": {},
|
|
280
|
+
"roles": {},
|
|
281
|
+
"policies": {},
|
|
282
|
+
"views": {},
|
|
283
|
+
"_meta": {
|
|
284
|
+
"columns": {},
|
|
285
|
+
"schemas": {},
|
|
286
|
+
"tables": {}
|
|
287
|
+
}
|
|
288
|
+
}
|
package/queue/postgres/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export declare class PostgresQueueModuleConfig {
|
|
|
3
3
|
database?: DatabaseConfig;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* configure
|
|
6
|
+
* configure queue module
|
|
7
7
|
*/
|
|
8
8
|
export declare function configurePostgresQueue(config?: PostgresQueueModuleConfig, register?: boolean): void;
|
|
9
9
|
export declare function migratePostgresQueueSchema(): Promise<void>;
|