@tstdl/base 0.93.76 → 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.
Files changed (103) hide show
  1. package/ai/prompts/instructions-formatter.d.ts +68 -5
  2. package/ai/prompts/instructions-formatter.js +11 -3
  3. package/authentication/client/http-client.middleware.js +2 -2
  4. package/authentication/models/authentication-credentials.model.d.ts +2 -2
  5. package/authentication/models/authentication-credentials.model.js +5 -3
  6. package/authentication/models/authentication-session.model.d.ts +2 -2
  7. package/authentication/models/authentication-session.model.js +5 -3
  8. package/authentication/models/index.d.ts +4 -0
  9. package/authentication/models/index.js +4 -0
  10. package/authentication/models/service-account.model.d.ts +7 -0
  11. package/authentication/models/service-account.model.js +31 -0
  12. package/authentication/models/subject.model.d.ts +16 -0
  13. package/authentication/models/subject.model.js +59 -0
  14. package/authentication/models/system-account.model.d.ts +5 -0
  15. package/authentication/models/system-account.model.js +25 -0
  16. package/authentication/models/user.model.d.ts +15 -0
  17. package/authentication/models/user.model.js +47 -0
  18. package/authentication/server/drizzle/0001_condemned_pretty_boy.sql +70 -0
  19. package/authentication/server/drizzle/meta/0001_snapshot.json +651 -0
  20. package/authentication/server/drizzle/meta/_journal.json +7 -0
  21. package/authentication/server/index.d.ts +1 -0
  22. package/authentication/server/index.js +1 -0
  23. package/authentication/server/schemas.d.ts +16 -1
  24. package/authentication/server/schemas.js +7 -1
  25. package/authentication/server/subject.service.d.ts +6 -0
  26. package/authentication/server/subject.service.js +44 -0
  27. package/circuit-breaker/circuit-breaker.d.ts +32 -0
  28. package/circuit-breaker/circuit-breaker.js +9 -0
  29. package/circuit-breaker/index.d.ts +2 -0
  30. package/circuit-breaker/index.js +2 -0
  31. package/circuit-breaker/postgres/circuit-breaker.d.ts +7 -0
  32. package/circuit-breaker/postgres/circuit-breaker.js +78 -0
  33. package/circuit-breaker/postgres/drizzle/0000_hard_shocker.sql +9 -0
  34. package/circuit-breaker/postgres/drizzle/meta/0000_snapshot.json +82 -0
  35. package/circuit-breaker/postgres/drizzle/meta/_journal.json +13 -0
  36. package/circuit-breaker/postgres/drizzle.config.d.ts +2 -0
  37. package/circuit-breaker/postgres/drizzle.config.js +11 -0
  38. package/circuit-breaker/postgres/index.d.ts +5 -0
  39. package/circuit-breaker/postgres/index.js +5 -0
  40. package/circuit-breaker/postgres/model.d.ts +9 -0
  41. package/circuit-breaker/postgres/model.js +40 -0
  42. package/circuit-breaker/postgres/module.d.ts +6 -0
  43. package/circuit-breaker/postgres/module.js +25 -0
  44. package/circuit-breaker/postgres/provider.d.ts +6 -0
  45. package/circuit-breaker/postgres/provider.js +21 -0
  46. package/circuit-breaker/postgres/schemas.d.ts +8 -0
  47. package/circuit-breaker/postgres/schemas.js +6 -0
  48. package/circuit-breaker/provider.d.ts +4 -0
  49. package/circuit-breaker/provider.js +2 -0
  50. package/circuit-breaker/tests/circuit-breaker.test.js +113 -0
  51. package/document-management/models/document.model.d.ts +0 -1
  52. package/document-management/models/document.model.js +0 -5
  53. package/document-management/server/api/document-management.api.js +1 -2
  54. package/document-management/server/drizzle/0002_round_warbird.sql +1 -0
  55. package/document-management/server/drizzle/meta/0002_snapshot.json +2722 -0
  56. package/document-management/server/drizzle/meta/_journal.json +7 -0
  57. package/document-management/server/services/document-collection.service.js +3 -3
  58. package/document-management/server/services/document-management-ancillary.service.d.ts +1 -1
  59. package/document-management/server/services/document-management.service.js +1 -1
  60. package/document-management/server/services/document-workflow.service.js +5 -5
  61. package/document-management/server/services/document.service.d.ts +0 -2
  62. package/document-management/server/services/document.service.js +1 -2
  63. package/document-management/service-models/enriched/enriched-document.view.d.ts +1 -1
  64. package/examples/document-management/main.d.ts +1 -1
  65. package/examples/document-management/main.js +1 -1
  66. package/logger/transports/console.d.ts +1 -1
  67. package/logger/transports/console.js +4 -1
  68. package/message-bus/message-bus-base.js +1 -1
  69. package/package.json +8 -5
  70. package/queue/enqueue-batch.d.ts +11 -11
  71. package/queue/enqueue-batch.js +2 -3
  72. package/queue/index.d.ts +1 -0
  73. package/queue/index.js +1 -0
  74. package/queue/postgres/drizzle/0003_tricky_venom.sql +30 -0
  75. package/queue/postgres/drizzle/meta/0003_snapshot.json +288 -0
  76. package/queue/postgres/drizzle/meta/_journal.json +7 -0
  77. package/queue/postgres/drizzle.config.js +2 -2
  78. package/queue/postgres/index.d.ts +1 -1
  79. package/queue/postgres/index.js +1 -1
  80. package/queue/postgres/module.d.ts +1 -1
  81. package/queue/postgres/module.js +1 -1
  82. package/queue/postgres/queue.d.ts +52 -23
  83. package/queue/postgres/queue.js +582 -64
  84. package/queue/postgres/queue.provider.d.ts +1 -1
  85. package/queue/postgres/schemas.d.ts +13 -2
  86. package/queue/postgres/schemas.js +4 -2
  87. package/queue/postgres/task.model.d.ts +24 -0
  88. package/queue/postgres/task.model.js +115 -0
  89. package/queue/provider.d.ts +1 -1
  90. package/queue/queue.d.ts +158 -37
  91. package/queue/queue.js +97 -19
  92. package/queue/task-context.d.ts +38 -0
  93. package/queue/task-context.js +102 -0
  94. package/queue/tests/queue.test.d.ts +1 -0
  95. package/queue/tests/queue.test.js +623 -0
  96. package/test4.d.ts +1 -1
  97. package/test4.js +1 -1
  98. package/utils/format-error.d.ts +17 -20
  99. package/utils/format-error.js +105 -47
  100. package/queue/postgres/job.model.d.ts +0 -12
  101. package/queue/postgres/job.model.js +0 -53
  102. package/test6.js +0 -33
  103. /package/{test6.d.ts → circuit-breaker/tests/circuit-breaker.test.d.ts} +0 -0
@@ -15,6 +15,13 @@
15
15
  "when": 1764857079867,
16
16
  "tag": "0001_lyrical_wong",
17
17
  "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "7",
22
+ "when": 1767824153882,
23
+ "tag": "0002_round_warbird",
24
+ "breakpoints": true
18
25
  }
19
26
  ]
20
27
  }
@@ -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.id })
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 (job) => await this.processWorkflowJob(job), this.#logger);
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(job) {
94
- const workflow = await this.repository.load(job.data.workflowId);
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
- const isLastTry = job.tries >= this.#queue.maxTries;
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, { createUserId }) {
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' | 'createUserId'> {
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 type { LogFormatter, LogPayload } from '../formatter.js';
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
- #formatter = inject(injectArgument(this).formatter);
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];
@@ -28,7 +28,7 @@ export class MessageBusBase extends MessageBus {
28
28
  }
29
29
  async [Symbol.asyncDispose]() {
30
30
  if (this.disposeToken.isSet) {
31
- throw new Error('MessageBus is disposed.');
31
+ return;
32
32
  }
33
33
  this.disposeToken.set();
34
34
  this.publishSubject.complete();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.76",
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/",
@@ -150,7 +151,7 @@
150
151
  "@zxcvbn-ts/language-de": "^3.0",
151
152
  "@zxcvbn-ts/language-en": "^3.0",
152
153
  "drizzle-orm": "^0.45",
153
- "file-type": "^21.1",
154
+ "file-type": "^21.3",
154
155
  "genkit": "^1.27",
155
156
  "handlebars": "^4.7",
156
157
  "minio": "^8.0",
@@ -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.16",
165
+ "undici": "^7.18",
165
166
  "urlpattern-polyfill": "^10.1",
166
167
  "zod": "^3.25"
167
168
  },
@@ -181,13 +182,15 @@
181
182
  "concurrently": "9.2",
182
183
  "drizzle-kit": "0.31",
183
184
  "eslint": "9.39",
184
- "globals": "16.5",
185
+ "globals": "17.0",
185
186
  "tsc-alias": "1.8",
186
187
  "typedoc-github-wiki-theme": "2.1",
187
188
  "typedoc-plugin-markdown": "4.9",
188
189
  "typedoc-plugin-missing-exports": "4.1",
189
190
  "typescript": "5.9",
190
- "typescript-eslint": "8.50"
191
+ "typescript-eslint": "8.52",
192
+ "vite-tsconfig-paths": "6.0",
193
+ "vitest": "4.0"
191
194
  },
192
195
  "overrides": {
193
196
  "drizzle-kit": {
@@ -1,17 +1,17 @@
1
- import type { EnqueueManyItem, EnqueueOptions, Job, Queue } from './queue.js';
2
- export interface QueueEnqueueBatchMethods<T> {
3
- add(...args: Parameters<Queue<T>['enqueue']>): void;
4
- enqueue(): ReturnType<Queue<T>['enqueueMany']>;
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<T> implements QueueEnqueueBatchMethods<T> {
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<T>[];
10
- constructor(queue: Queue<T>);
9
+ items: EnqueueManyItem<Data>[];
10
+ constructor(queue: Queue<Data, State, Result>);
11
11
  /** add data to items */
12
- add(data: T, options?: EnqueueOptions): void;
12
+ add(data: Data, options?: EnqueueOptions): void;
13
13
  /** enqueues all added items */
14
- enqueue(returnJobs?: false): Promise<void>;
15
- enqueue(returnJobs: true): Promise<Job<T>[]>;
16
- enqueue(returnJobs?: boolean): Promise<Job<T>[] | undefined>;
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
  }
@@ -10,10 +10,9 @@ export class QueueEnqueueBatch {
10
10
  add(data, options) {
11
11
  this.items.push({ data, ...options });
12
12
  }
13
- async enqueue(returnJobs) {
13
+ async enqueue(returnTasks) {
14
14
  const items = this.items;
15
15
  this.items = [];
16
- const result = await this.queue.enqueueMany(items, { returnJobs });
17
- return result;
16
+ return await this.queue.enqueueMany(items, { returnTasks });
18
17
  }
19
18
  }
package/queue/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './enqueue-batch.js';
2
2
  export * from './provider.js';
3
3
  export * from './queue.js';
4
+ export * from './task-context.js';
package/queue/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './enqueue-batch.js';
2
2
  export * from './provider.js';
3
3
  export * from './queue.js';
4
+ export * from './task-context.js';
@@ -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
+ }
@@ -22,6 +22,13 @@
22
22
  "when": 1760974453539,
23
23
  "tag": "0002_dear_meggan",
24
24
  "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "7",
29
+ "when": 1767731213291,
30
+ "tag": "0003_tricky_venom",
31
+ "breakpoints": true
25
32
  }
26
33
  ]
27
34
  }
@@ -6,6 +6,6 @@ export default defineConfig({
6
6
  schema: resolve(__dirname, './schemas.js'),
7
7
  migrations: {
8
8
  schema: 'queue',
9
- table: '_migrations'
10
- }
9
+ table: '_migrations',
10
+ },
11
11
  });
@@ -1,4 +1,4 @@
1
- export * from './job.model.js';
1
+ export * from './task.model.js';
2
2
  export * from './module.js';
3
3
  export * from './queue.js';
4
4
  export * from './queue.provider.js';
@@ -1,4 +1,4 @@
1
- export * from './job.model.js';
1
+ export * from './task.model.js';
2
2
  export * from './module.js';
3
3
  export * from './queue.js';
4
4
  export * from './queue.provider.js';