@tstdl/base 0.93.140 → 0.93.141
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/application/application.d.ts +1 -1
- package/application/application.js +1 -1
- package/application/providers.d.ts +20 -2
- package/application/providers.js +34 -7
- package/audit/module.d.ts +5 -0
- package/audit/module.js +9 -1
- package/authentication/server/module.d.ts +5 -0
- package/authentication/server/module.js +9 -1
- package/authentication/tests/authentication.api-controller.test.js +1 -1
- package/authentication/tests/authentication.api-request-token.provider.test.js +1 -1
- package/authentication/tests/authentication.client-service.test.js +1 -1
- package/circuit-breaker/postgres/module.d.ts +1 -0
- package/circuit-breaker/postgres/module.js +5 -1
- package/document-management/server/configure.js +5 -1
- package/document-management/server/module.d.ts +1 -1
- package/document-management/server/module.js +1 -1
- package/document-management/server/services/document-management-ancillary.service.js +1 -1
- package/document-management/tests/ai-config-hierarchy.test.js +0 -5
- package/document-management/tests/document-management-ai-overrides.test.js +0 -1
- package/document-management/tests/document-validation-ai-overrides.test.js +0 -1
- package/examples/document-management/main.d.ts +1 -0
- package/examples/document-management/main.js +14 -11
- package/key-value-store/postgres/module.d.ts +1 -0
- package/key-value-store/postgres/module.js +5 -1
- package/lock/postgres/module.d.ts +1 -0
- package/lock/postgres/module.js +5 -1
- package/mail/module.d.ts +5 -1
- package/mail/module.js +11 -6
- package/module/modules/web-server.module.js +2 -3
- package/notification/server/module.d.ts +1 -0
- package/notification/server/module.js +5 -1
- package/notification/tests/notification-flow.test.js +2 -2
- package/orm/decorators.d.ts +5 -1
- package/orm/decorators.js +1 -1
- package/orm/server/drizzle/schema-converter.js +17 -30
- package/orm/server/encryption.d.ts +0 -1
- package/orm/server/encryption.js +1 -4
- package/orm/server/index.d.ts +1 -6
- package/orm/server/index.js +1 -6
- package/orm/server/migration.d.ts +19 -0
- package/orm/server/migration.js +72 -0
- package/orm/server/repository.d.ts +1 -1
- package/orm/server/transaction.d.ts +5 -10
- package/orm/server/transaction.js +22 -26
- package/orm/server/transactional.js +3 -3
- package/orm/tests/database-migration.test.d.ts +1 -0
- package/orm/tests/database-migration.test.js +82 -0
- package/orm/tests/encryption.test.js +3 -4
- package/orm/utils.d.ts +17 -2
- package/orm/utils.js +49 -1
- package/package.json +4 -3
- package/rate-limit/postgres/module.d.ts +1 -0
- package/rate-limit/postgres/module.js +5 -1
- package/reflection/decorator-data.js +11 -12
- package/task-queue/README.md +2 -9
- package/task-queue/postgres/drizzle/{0000_simple_invisible_woman.sql → 0000_wakeful_sunspot.sql} +22 -14
- package/task-queue/postgres/drizzle/meta/0000_snapshot.json +160 -82
- package/task-queue/postgres/drizzle/meta/_journal.json +2 -2
- package/task-queue/postgres/module.d.ts +1 -0
- package/task-queue/postgres/module.js +5 -1
- package/task-queue/postgres/schemas.d.ts +9 -6
- package/task-queue/postgres/schemas.js +4 -3
- package/task-queue/postgres/task-queue.d.ts +2 -12
- package/task-queue/postgres/task-queue.js +431 -354
- package/task-queue/postgres/task.model.d.ts +12 -5
- package/task-queue/postgres/task.model.js +51 -25
- package/task-queue/task-context.d.ts +2 -2
- package/task-queue/task-context.js +7 -7
- package/task-queue/task-queue.d.ts +36 -19
- package/task-queue/task-queue.js +18 -10
- package/task-queue/tests/cascading-cancellations.test.d.ts +1 -0
- package/task-queue/tests/cascading-cancellations.test.js +38 -0
- package/task-queue/tests/complex.test.js +44 -228
- package/task-queue/tests/coverage-branch.test.d.ts +1 -0
- package/task-queue/tests/coverage-branch.test.js +407 -0
- package/task-queue/tests/coverage-enhancement.test.d.ts +1 -0
- package/task-queue/tests/coverage-enhancement.test.js +144 -0
- package/task-queue/tests/dag-dependencies.test.d.ts +1 -0
- package/task-queue/tests/dag-dependencies.test.js +41 -0
- package/task-queue/tests/dependencies.test.js +26 -26
- package/task-queue/tests/extensive-dependencies.test.js +64 -139
- package/task-queue/tests/fan-out-spawning.test.d.ts +1 -0
- package/task-queue/tests/fan-out-spawning.test.js +53 -0
- package/task-queue/tests/idempotent-replacement.test.d.ts +1 -0
- package/task-queue/tests/idempotent-replacement.test.js +61 -0
- package/task-queue/tests/missing-idempotent-tasks.test.d.ts +1 -0
- package/task-queue/tests/missing-idempotent-tasks.test.js +38 -0
- package/task-queue/tests/queue.test.js +33 -24
- package/task-queue/tests/worker.test.js +20 -5
- package/task-queue/tests/zombie-parent.test.d.ts +1 -0
- package/task-queue/tests/zombie-parent.test.js +45 -0
- package/task-queue/tests/zombie-recovery.test.d.ts +1 -0
- package/task-queue/tests/zombie-recovery.test.js +51 -0
- package/test5.js +5 -5
- package/testing/integration-setup.d.ts +4 -4
- package/testing/integration-setup.js +54 -29
- package/text/localization.service.js +2 -2
- package/utils/file-reader.js +1 -2
package/orm/utils.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Provides utility functions for working with ORM entities.
|
|
4
4
|
*/
|
|
5
5
|
import { reflectionRegistry } from '../reflection/registry.js';
|
|
6
|
-
import {
|
|
6
|
+
import { toSnakeCase } from '../utils/string/index.js';
|
|
7
|
+
import { assertDefined, isDefined, isNotNullOrUndefined, isString, isUndefined } from '../utils/type-guards.js';
|
|
7
8
|
export function getEntityMap(entities, selector = (entity) => entity.id) {
|
|
8
9
|
const entries = entities.map((entity) => [selector(entity), entity]);
|
|
9
10
|
return new Map(entries);
|
|
@@ -36,3 +37,50 @@ export function getOwnProperties(type) {
|
|
|
36
37
|
}
|
|
37
38
|
return [...metadata.properties.values()].filter((property) => !property.inherited || (property.key == 'id'));
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets the database schema name for a given entity type, traversing the inheritance hierarchy.
|
|
42
|
+
* @param type The entity class.
|
|
43
|
+
* @param fallback Optional fallback schema name if none is defined in metadata.
|
|
44
|
+
* @returns The resolved schema name.
|
|
45
|
+
*/
|
|
46
|
+
export function getEntitySchema(type, fallback) {
|
|
47
|
+
for (let currentMetadata = reflectionRegistry.getMetadata(type); isNotNullOrUndefined(currentMetadata); currentMetadata = isNotNullOrUndefined(currentMetadata.parent) ? reflectionRegistry.getMetadata(currentMetadata.parent) : undefined) {
|
|
48
|
+
const schema = currentMetadata.data.tryGet('orm')?.schema;
|
|
49
|
+
if (isDefined(schema)) {
|
|
50
|
+
return schema;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (isDefined(fallback)) {
|
|
54
|
+
return fallback;
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Schema not found for entity ${type.name} and no fallback provided.`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets the database table name for a given entity type, traversing the inheritance hierarchy.
|
|
60
|
+
* @param type The entity class.
|
|
61
|
+
* @returns The resolved table name.
|
|
62
|
+
*/
|
|
63
|
+
export function getEntityTableName(type) {
|
|
64
|
+
for (let currentMetadata = reflectionRegistry.getMetadata(type); isNotNullOrUndefined(currentMetadata); currentMetadata = isNotNullOrUndefined(currentMetadata.parent) ? reflectionRegistry.getMetadata(currentMetadata.parent) : undefined) {
|
|
65
|
+
const name = currentMetadata.data.tryGet('orm')?.name;
|
|
66
|
+
if (isDefined(name)) {
|
|
67
|
+
return name;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return getDefaultTableName(type);
|
|
71
|
+
}
|
|
72
|
+
export function getDefaultTableName(type) {
|
|
73
|
+
return toSnakeCase(isString(type.entityName) ? type.entityName : type.name.replace(/\d+$/u, ''));
|
|
74
|
+
}
|
|
75
|
+
export function getTableReflectionDatas(type) {
|
|
76
|
+
const metadata = reflectionRegistry.getMetadata(type);
|
|
77
|
+
assertDefined(metadata, `Type ${type.name} does not have reflection metadata.`);
|
|
78
|
+
const tableReflectionDatas = [];
|
|
79
|
+
for (let currentMetadata = metadata; isNotNullOrUndefined(currentMetadata?.parent); currentMetadata = reflectionRegistry.getMetadata(currentMetadata.parent)) {
|
|
80
|
+
const tableReflectionData = currentMetadata.data.tryGet('orm');
|
|
81
|
+
if (isDefined(tableReflectionData)) {
|
|
82
|
+
tableReflectionDatas.push(tableReflectionData);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return tableReflectionDatas;
|
|
86
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.93.
|
|
3
|
+
"version": "0.93.141",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"lint": "eslint --cache source/",
|
|
18
18
|
"pub": "npm run build:production && npm run cleanup:dist && npm publish dist/",
|
|
19
19
|
"test": "vitest run",
|
|
20
|
+
"test:coverage": "f() { vitest run --coverage --coverage.include=\"source/$1/**/*.ts\" source/$1; }; f",
|
|
20
21
|
"tsc:watch": "tsc --watch",
|
|
21
22
|
"tsc-alias:watch": "tsc-alias --watch",
|
|
22
23
|
"cleanup:dist": "rm -vrf dist/tools/",
|
|
@@ -151,8 +152,8 @@
|
|
|
151
152
|
"type-fest": "^5.4"
|
|
152
153
|
},
|
|
153
154
|
"peerDependencies": {
|
|
154
|
-
"@aws-sdk/client-s3": "^3.
|
|
155
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
155
|
+
"@aws-sdk/client-s3": "^3.996",
|
|
156
|
+
"@aws-sdk/s3-request-presigner": "^3.996",
|
|
156
157
|
"@genkit-ai/google-genai": "^1.29",
|
|
157
158
|
"@google-cloud/storage": "^7.19",
|
|
158
159
|
"@toon-format/toon": "^2.1.0",
|
|
@@ -2,6 +2,7 @@ import { Injector } from '../../injector/injector.js';
|
|
|
2
2
|
import { type DatabaseConfig } from '../../orm/server/index.js';
|
|
3
3
|
export declare class PostgresRateLimiterModuleConfig {
|
|
4
4
|
database?: DatabaseConfig;
|
|
5
|
+
autoMigrate?: boolean;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* configure rate limit module
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { inject } from '../../injector/index.js';
|
|
2
2
|
import { Injector } from '../../injector/injector.js';
|
|
3
|
-
import { Database, migrate } from '../../orm/server/index.js';
|
|
3
|
+
import { Database, migrate, registerDatabaseMigration } from '../../orm/server/index.js';
|
|
4
4
|
import { RateLimiterProvider } from '../provider.js';
|
|
5
5
|
import { RateLimiter } from '../rate-limiter.js';
|
|
6
6
|
import { PostgresRateLimiter } from './postgres-rate-limiter.js';
|
|
7
7
|
import { PostgresRateLimiterProvider } from './rate-limiter.provider.js';
|
|
8
8
|
export class PostgresRateLimiterModuleConfig {
|
|
9
9
|
database;
|
|
10
|
+
autoMigrate;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* configure rate limit module
|
|
@@ -16,6 +17,9 @@ export function configurePostgresRateLimiter({ injector, ...config } = {}) {
|
|
|
16
17
|
targetInjector.register(PostgresRateLimiterModuleConfig, { useValue: config });
|
|
17
18
|
targetInjector.registerSingleton(RateLimiterProvider, { useToken: PostgresRateLimiterProvider });
|
|
18
19
|
targetInjector.registerSingleton(RateLimiter, { useToken: PostgresRateLimiter });
|
|
20
|
+
if (config.autoMigrate != false) {
|
|
21
|
+
registerDatabaseMigration('PostgresRateLimiter', migratePostgresRateLimiterSchema, { injector });
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
export async function migratePostgresRateLimiterSchema() {
|
|
21
25
|
const connection = inject(PostgresRateLimiterModuleConfig, undefined, { optional: true })?.database?.connection;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DetailsError } from '../errors/details.error.js';
|
|
2
2
|
import { isDefined, isFunction, isNumber, isObject, isUndefined } from '../utils/type-guards.js';
|
|
3
3
|
import { getConstructor } from './utils.js';
|
|
4
|
-
// eslint-disable-next-line max-lines-per-function
|
|
5
4
|
export function getDecoratorData(target, propertyKey, descriptorOrParameterIndex) {
|
|
6
5
|
const constructor = getConstructor(target);
|
|
7
6
|
const prototype = constructor.prototype;
|
|
@@ -10,54 +9,54 @@ export function getDecoratorData(target, propertyKey, descriptorOrParameterIndex
|
|
|
10
9
|
return {
|
|
11
10
|
type: 'class',
|
|
12
11
|
constructor,
|
|
13
|
-
prototype
|
|
12
|
+
prototype,
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
if (isDefined(propertyKey) && isUndefined(descriptorOrParameterIndex)) {
|
|
17
16
|
return {
|
|
18
17
|
type: 'property',
|
|
19
18
|
constructor,
|
|
20
19
|
prototype,
|
|
21
20
|
static: isStatic,
|
|
22
|
-
propertyKey
|
|
21
|
+
propertyKey,
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
if (isDefined(propertyKey) && isObject(descriptorOrParameterIndex) && (isFunction(descriptorOrParameterIndex.get ?? descriptorOrParameterIndex.set))) { // eslint-disable-line @typescript-eslint/unbound-method
|
|
26
25
|
return {
|
|
27
26
|
type: 'accessor',
|
|
28
27
|
constructor,
|
|
29
28
|
prototype,
|
|
30
29
|
static: isStatic,
|
|
31
30
|
propertyKey,
|
|
32
|
-
descriptor: descriptorOrParameterIndex
|
|
31
|
+
descriptor: descriptorOrParameterIndex,
|
|
33
32
|
};
|
|
34
33
|
}
|
|
35
|
-
|
|
34
|
+
if (isDefined(propertyKey) && isObject(descriptorOrParameterIndex) && isFunction(descriptorOrParameterIndex.value)) {
|
|
36
35
|
return {
|
|
37
36
|
type: 'method',
|
|
38
37
|
constructor,
|
|
39
38
|
prototype,
|
|
40
39
|
static: isStatic,
|
|
41
40
|
methodKey: propertyKey,
|
|
42
|
-
descriptor: descriptorOrParameterIndex
|
|
41
|
+
descriptor: descriptorOrParameterIndex,
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
|
-
|
|
44
|
+
if (isDefined(propertyKey) && isNumber(descriptorOrParameterIndex)) {
|
|
46
45
|
return {
|
|
47
46
|
type: 'method-parameter',
|
|
48
47
|
constructor,
|
|
49
48
|
prototype,
|
|
50
49
|
static: isStatic,
|
|
51
50
|
methodKey: propertyKey,
|
|
52
|
-
index: descriptorOrParameterIndex
|
|
51
|
+
index: descriptorOrParameterIndex,
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
if (isNumber(descriptorOrParameterIndex)) {
|
|
56
55
|
return {
|
|
57
56
|
type: 'constructor-parameter',
|
|
58
57
|
constructor,
|
|
59
58
|
prototype,
|
|
60
|
-
index: descriptorOrParameterIndex
|
|
59
|
+
index: descriptorOrParameterIndex,
|
|
61
60
|
};
|
|
62
61
|
}
|
|
63
62
|
throw new DetailsError('unknown type', { type: constructor, isStatic, propertyKey, descriptorOrParameterIndex });
|
package/task-queue/README.md
CHANGED
|
@@ -60,18 +60,11 @@ A function that processes tasks. The `TaskQueue` provides a managed loop (`proce
|
|
|
60
60
|
Register the PostgreSQL backend in your application bootstrap.
|
|
61
61
|
|
|
62
62
|
```typescript
|
|
63
|
-
import { configurePostgresTaskQueue
|
|
64
|
-
import { runInInjectionContext, inject } from '@tstdl/base/injector';
|
|
65
|
-
import { Injector } from '@tstdl/base/injector';
|
|
63
|
+
import { configurePostgresTaskQueue } from '@tstdl/base/task-queue/postgres';
|
|
66
64
|
|
|
67
65
|
export async function bootstrap() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// Configure the module (uses default DatabaseConfig from context)
|
|
66
|
+
// Configure the module
|
|
71
67
|
configurePostgresTaskQueue();
|
|
72
|
-
|
|
73
|
-
// Run migrations to create the 'task_queue.task' table
|
|
74
|
-
await runInInjectionContext(injector, migratePostgresTaskQueueSchema);
|
|
75
68
|
}
|
|
76
69
|
```
|
|
77
70
|
|
package/task-queue/postgres/drizzle/{0000_simple_invisible_woman.sql → 0000_wakeful_sunspot.sql}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
CREATE TYPE "task_queue"."
|
|
2
|
-
CREATE TYPE "task_queue"."task_status" AS ENUM('pending', 'running', 'completed', 'cancelled', 'waiting', '
|
|
1
|
+
CREATE TYPE "task_queue"."task_dependency_type" AS ENUM('schedule', 'complete');--> statement-breakpoint
|
|
2
|
+
CREATE TYPE "task_queue"."task_status" AS ENUM('pending', 'running', 'completed', 'cancelled', 'dead', 'waiting', 'waiting-children', 'paused');--> statement-breakpoint
|
|
3
3
|
CREATE TABLE "task_queue"."task" (
|
|
4
4
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
5
5
|
"namespace" text NOT NULL,
|
|
@@ -8,12 +8,10 @@ CREATE TABLE "task_queue"."task" (
|
|
|
8
8
|
"idempotency_key" text,
|
|
9
9
|
"trace_id" text,
|
|
10
10
|
"tags" text[] NOT NULL,
|
|
11
|
-
"complete_after_tags" text[] NOT NULL,
|
|
12
|
-
"schedule_after_tags" text[] NOT NULL,
|
|
13
11
|
"fail_fast" boolean NOT NULL,
|
|
14
|
-
"dependency_join_mode" "task_queue"."dependency_join_mode" NOT NULL,
|
|
15
|
-
"dependency_trigger_statuses" "task_queue"."task_status"[] NOT NULL,
|
|
16
12
|
"priority" integer NOT NULL,
|
|
13
|
+
"unresolved_schedule_dependencies" integer NOT NULL,
|
|
14
|
+
"unresolved_complete_dependencies" integer NOT NULL,
|
|
17
15
|
"token" uuid,
|
|
18
16
|
"creation_timestamp" timestamp with time zone NOT NULL,
|
|
19
17
|
"priority_age_timestamp" timestamp with time zone NOT NULL,
|
|
@@ -29,6 +27,7 @@ CREATE TABLE "task_queue"."task" (
|
|
|
29
27
|
"result" jsonb,
|
|
30
28
|
"error" jsonb,
|
|
31
29
|
"parent_id" uuid,
|
|
30
|
+
CONSTRAINT "task_namespace_id_unique" UNIQUE("namespace","id"),
|
|
32
31
|
CONSTRAINT "task_namespace_idempotency_key_unique" UNIQUE("namespace","idempotency_key")
|
|
33
32
|
);
|
|
34
33
|
--> statement-breakpoint
|
|
@@ -40,12 +39,10 @@ CREATE TABLE "task_queue"."task_archive" (
|
|
|
40
39
|
"idempotency_key" text,
|
|
41
40
|
"trace_id" text,
|
|
42
41
|
"tags" text[] NOT NULL,
|
|
43
|
-
"complete_after_tags" text[] NOT NULL,
|
|
44
|
-
"schedule_after_tags" text[] NOT NULL,
|
|
45
42
|
"fail_fast" boolean NOT NULL,
|
|
46
|
-
"dependency_join_mode" "task_queue"."dependency_join_mode" NOT NULL,
|
|
47
|
-
"dependency_trigger_statuses" "task_queue"."task_status"[] NOT NULL,
|
|
48
43
|
"priority" integer NOT NULL,
|
|
44
|
+
"unresolved_schedule_dependencies" integer NOT NULL,
|
|
45
|
+
"unresolved_complete_dependencies" integer NOT NULL,
|
|
49
46
|
"token" uuid,
|
|
50
47
|
"creation_timestamp" timestamp with time zone NOT NULL,
|
|
51
48
|
"priority_age_timestamp" timestamp with time zone NOT NULL,
|
|
@@ -63,12 +60,23 @@ CREATE TABLE "task_queue"."task_archive" (
|
|
|
63
60
|
"parent_id" uuid
|
|
64
61
|
);
|
|
65
62
|
--> statement-breakpoint
|
|
66
|
-
|
|
63
|
+
CREATE TABLE "task_queue"."task_dependency" (
|
|
64
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
65
|
+
"namespace" text NOT NULL,
|
|
66
|
+
"task_id" uuid NOT NULL,
|
|
67
|
+
"dependency_task_id" uuid NOT NULL,
|
|
68
|
+
"type" "task_queue"."task_dependency_type" NOT NULL,
|
|
69
|
+
"required_statuses" "task_queue"."task_status"[] NOT NULL,
|
|
70
|
+
CONSTRAINT "td_namespace_task_id_dependency_task_id_type_unique" UNIQUE("namespace","task_id","dependency_task_id","type")
|
|
71
|
+
);
|
|
72
|
+
--> statement-breakpoint
|
|
73
|
+
ALTER TABLE "task_queue"."task" ADD CONSTRAINT "task_namespace_parentId_task_fkey" FOREIGN KEY ("namespace","parent_id") REFERENCES "task_queue"."task"("namespace","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
74
|
+
ALTER TABLE "task_queue"."task_dependency" ADD CONSTRAINT "task_dependency_namespace_dependencyTaskId_task_fkey" FOREIGN KEY ("namespace","dependency_task_id") REFERENCES "task_queue"."task"("namespace","id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
75
|
+
ALTER TABLE "task_queue"."task_dependency" ADD CONSTRAINT "task_dependency_namespace_taskId_task_fkey" FOREIGN KEY ("namespace","task_id") REFERENCES "task_queue"."task"("namespace","id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
67
76
|
CREATE INDEX "task_parent_id_idx" ON "task_queue"."task" USING btree ("parent_id");--> statement-breakpoint
|
|
68
77
|
CREATE INDEX "task_status_visibility_deadline_idx" ON "task_queue"."task" USING btree ("status","visibility_deadline");--> statement-breakpoint
|
|
69
78
|
CREATE INDEX "task_status_complete_timestamp_idx" ON "task_queue"."task" USING btree ("status","complete_timestamp");--> statement-breakpoint
|
|
70
|
-
CREATE INDEX "task_schedule_after_tags_idx" ON "task_queue"."task" USING gin ("schedule_after_tags");--> statement-breakpoint
|
|
71
|
-
CREATE INDEX "task_complete_after_tags_idx" ON "task_queue"."task" USING gin ("complete_after_tags");--> statement-breakpoint
|
|
72
79
|
CREATE INDEX "task_tags_idx" ON "task_queue"."task" USING gin ("tags");--> statement-breakpoint
|
|
73
80
|
CREATE INDEX "task_namespace_status_schedule_timestamp_priority_idx" ON "task_queue"."task" USING btree ("namespace","status","schedule_timestamp","priority");--> statement-breakpoint
|
|
74
|
-
CREATE INDEX "task_archive_namespace_complete_timestamp_idx" ON "task_queue"."task_archive" USING btree ("namespace","complete_timestamp")
|
|
81
|
+
CREATE INDEX "task_archive_namespace_complete_timestamp_idx" ON "task_queue"."task_archive" USING btree ("namespace","complete_timestamp");--> statement-breakpoint
|
|
82
|
+
CREATE INDEX "task_dependency_namespace_dependency_task_id_type_idx" ON "task_queue"."task_dependency" USING btree ("namespace","dependency_task_id","type");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "748b4480-a37e-43bb-a9fc-6920c03c3ed3",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
@@ -52,40 +52,26 @@
|
|
|
52
52
|
"primaryKey": false,
|
|
53
53
|
"notNull": true
|
|
54
54
|
},
|
|
55
|
-
"complete_after_tags": {
|
|
56
|
-
"name": "complete_after_tags",
|
|
57
|
-
"type": "text[]",
|
|
58
|
-
"primaryKey": false,
|
|
59
|
-
"notNull": true
|
|
60
|
-
},
|
|
61
|
-
"schedule_after_tags": {
|
|
62
|
-
"name": "schedule_after_tags",
|
|
63
|
-
"type": "text[]",
|
|
64
|
-
"primaryKey": false,
|
|
65
|
-
"notNull": true
|
|
66
|
-
},
|
|
67
55
|
"fail_fast": {
|
|
68
56
|
"name": "fail_fast",
|
|
69
57
|
"type": "boolean",
|
|
70
58
|
"primaryKey": false,
|
|
71
59
|
"notNull": true
|
|
72
60
|
},
|
|
73
|
-
"
|
|
74
|
-
"name": "
|
|
75
|
-
"type": "
|
|
76
|
-
"typeSchema": "task_queue",
|
|
61
|
+
"priority": {
|
|
62
|
+
"name": "priority",
|
|
63
|
+
"type": "integer",
|
|
77
64
|
"primaryKey": false,
|
|
78
65
|
"notNull": true
|
|
79
66
|
},
|
|
80
|
-
"
|
|
81
|
-
"name": "
|
|
82
|
-
"type": "
|
|
83
|
-
"typeSchema": "task_queue",
|
|
67
|
+
"unresolved_schedule_dependencies": {
|
|
68
|
+
"name": "unresolved_schedule_dependencies",
|
|
69
|
+
"type": "integer",
|
|
84
70
|
"primaryKey": false,
|
|
85
71
|
"notNull": true
|
|
86
72
|
},
|
|
87
|
-
"
|
|
88
|
-
"name": "
|
|
73
|
+
"unresolved_complete_dependencies": {
|
|
74
|
+
"name": "unresolved_complete_dependencies",
|
|
89
75
|
"type": "integer",
|
|
90
76
|
"primaryKey": false,
|
|
91
77
|
"notNull": true
|
|
@@ -239,36 +225,6 @@
|
|
|
239
225
|
"method": "btree",
|
|
240
226
|
"with": {}
|
|
241
227
|
},
|
|
242
|
-
"task_schedule_after_tags_idx": {
|
|
243
|
-
"name": "task_schedule_after_tags_idx",
|
|
244
|
-
"columns": [
|
|
245
|
-
{
|
|
246
|
-
"expression": "schedule_after_tags",
|
|
247
|
-
"isExpression": false,
|
|
248
|
-
"asc": true,
|
|
249
|
-
"nulls": "last"
|
|
250
|
-
}
|
|
251
|
-
],
|
|
252
|
-
"isUnique": false,
|
|
253
|
-
"concurrently": false,
|
|
254
|
-
"method": "gin",
|
|
255
|
-
"with": {}
|
|
256
|
-
},
|
|
257
|
-
"task_complete_after_tags_idx": {
|
|
258
|
-
"name": "task_complete_after_tags_idx",
|
|
259
|
-
"columns": [
|
|
260
|
-
{
|
|
261
|
-
"expression": "complete_after_tags",
|
|
262
|
-
"isExpression": false,
|
|
263
|
-
"asc": true,
|
|
264
|
-
"nulls": "last"
|
|
265
|
-
}
|
|
266
|
-
],
|
|
267
|
-
"isUnique": false,
|
|
268
|
-
"concurrently": false,
|
|
269
|
-
"method": "gin",
|
|
270
|
-
"with": {}
|
|
271
|
-
},
|
|
272
228
|
"task_tags_idx": {
|
|
273
229
|
"name": "task_tags_idx",
|
|
274
230
|
"columns": [
|
|
@@ -319,15 +275,17 @@
|
|
|
319
275
|
}
|
|
320
276
|
},
|
|
321
277
|
"foreignKeys": {
|
|
322
|
-
"
|
|
323
|
-
"name": "
|
|
278
|
+
"task_namespace_parentId_task_fkey": {
|
|
279
|
+
"name": "task_namespace_parentId_task_fkey",
|
|
324
280
|
"tableFrom": "task",
|
|
325
281
|
"tableTo": "task",
|
|
326
282
|
"schemaTo": "task_queue",
|
|
327
283
|
"columnsFrom": [
|
|
284
|
+
"namespace",
|
|
328
285
|
"parent_id"
|
|
329
286
|
],
|
|
330
287
|
"columnsTo": [
|
|
288
|
+
"namespace",
|
|
331
289
|
"id"
|
|
332
290
|
],
|
|
333
291
|
"onDelete": "no action",
|
|
@@ -336,6 +294,14 @@
|
|
|
336
294
|
},
|
|
337
295
|
"compositePrimaryKeys": {},
|
|
338
296
|
"uniqueConstraints": {
|
|
297
|
+
"task_namespace_id_unique": {
|
|
298
|
+
"name": "task_namespace_id_unique",
|
|
299
|
+
"nullsNotDistinct": false,
|
|
300
|
+
"columns": [
|
|
301
|
+
"namespace",
|
|
302
|
+
"id"
|
|
303
|
+
]
|
|
304
|
+
},
|
|
339
305
|
"task_namespace_idempotency_key_unique": {
|
|
340
306
|
"name": "task_namespace_idempotency_key_unique",
|
|
341
307
|
"nullsNotDistinct": false,
|
|
@@ -397,40 +363,26 @@
|
|
|
397
363
|
"primaryKey": false,
|
|
398
364
|
"notNull": true
|
|
399
365
|
},
|
|
400
|
-
"complete_after_tags": {
|
|
401
|
-
"name": "complete_after_tags",
|
|
402
|
-
"type": "text[]",
|
|
403
|
-
"primaryKey": false,
|
|
404
|
-
"notNull": true
|
|
405
|
-
},
|
|
406
|
-
"schedule_after_tags": {
|
|
407
|
-
"name": "schedule_after_tags",
|
|
408
|
-
"type": "text[]",
|
|
409
|
-
"primaryKey": false,
|
|
410
|
-
"notNull": true
|
|
411
|
-
},
|
|
412
366
|
"fail_fast": {
|
|
413
367
|
"name": "fail_fast",
|
|
414
368
|
"type": "boolean",
|
|
415
369
|
"primaryKey": false,
|
|
416
370
|
"notNull": true
|
|
417
371
|
},
|
|
418
|
-
"
|
|
419
|
-
"name": "
|
|
420
|
-
"type": "
|
|
421
|
-
"typeSchema": "task_queue",
|
|
372
|
+
"priority": {
|
|
373
|
+
"name": "priority",
|
|
374
|
+
"type": "integer",
|
|
422
375
|
"primaryKey": false,
|
|
423
376
|
"notNull": true
|
|
424
377
|
},
|
|
425
|
-
"
|
|
426
|
-
"name": "
|
|
427
|
-
"type": "
|
|
428
|
-
"typeSchema": "task_queue",
|
|
378
|
+
"unresolved_schedule_dependencies": {
|
|
379
|
+
"name": "unresolved_schedule_dependencies",
|
|
380
|
+
"type": "integer",
|
|
429
381
|
"primaryKey": false,
|
|
430
382
|
"notNull": true
|
|
431
383
|
},
|
|
432
|
-
"
|
|
433
|
-
"name": "
|
|
384
|
+
"unresolved_complete_dependencies": {
|
|
385
|
+
"name": "unresolved_complete_dependencies",
|
|
434
386
|
"type": "integer",
|
|
435
387
|
"primaryKey": false,
|
|
436
388
|
"notNull": true
|
|
@@ -555,15 +507,139 @@
|
|
|
555
507
|
"policies": {},
|
|
556
508
|
"checkConstraints": {},
|
|
557
509
|
"isRLSEnabled": false
|
|
510
|
+
},
|
|
511
|
+
"task_queue.task_dependency": {
|
|
512
|
+
"name": "task_dependency",
|
|
513
|
+
"schema": "task_queue",
|
|
514
|
+
"columns": {
|
|
515
|
+
"id": {
|
|
516
|
+
"name": "id",
|
|
517
|
+
"type": "uuid",
|
|
518
|
+
"primaryKey": true,
|
|
519
|
+
"notNull": true,
|
|
520
|
+
"default": "gen_random_uuid()"
|
|
521
|
+
},
|
|
522
|
+
"namespace": {
|
|
523
|
+
"name": "namespace",
|
|
524
|
+
"type": "text",
|
|
525
|
+
"primaryKey": false,
|
|
526
|
+
"notNull": true
|
|
527
|
+
},
|
|
528
|
+
"task_id": {
|
|
529
|
+
"name": "task_id",
|
|
530
|
+
"type": "uuid",
|
|
531
|
+
"primaryKey": false,
|
|
532
|
+
"notNull": true
|
|
533
|
+
},
|
|
534
|
+
"dependency_task_id": {
|
|
535
|
+
"name": "dependency_task_id",
|
|
536
|
+
"type": "uuid",
|
|
537
|
+
"primaryKey": false,
|
|
538
|
+
"notNull": true
|
|
539
|
+
},
|
|
540
|
+
"type": {
|
|
541
|
+
"name": "type",
|
|
542
|
+
"type": "task_dependency_type",
|
|
543
|
+
"typeSchema": "task_queue",
|
|
544
|
+
"primaryKey": false,
|
|
545
|
+
"notNull": true
|
|
546
|
+
},
|
|
547
|
+
"required_statuses": {
|
|
548
|
+
"name": "required_statuses",
|
|
549
|
+
"type": "task_status[]",
|
|
550
|
+
"typeSchema": "task_queue",
|
|
551
|
+
"primaryKey": false,
|
|
552
|
+
"notNull": true
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
"indexes": {
|
|
556
|
+
"task_dependency_namespace_dependency_task_id_type_idx": {
|
|
557
|
+
"name": "task_dependency_namespace_dependency_task_id_type_idx",
|
|
558
|
+
"columns": [
|
|
559
|
+
{
|
|
560
|
+
"expression": "namespace",
|
|
561
|
+
"isExpression": false,
|
|
562
|
+
"asc": true,
|
|
563
|
+
"nulls": "last"
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
"expression": "dependency_task_id",
|
|
567
|
+
"isExpression": false,
|
|
568
|
+
"asc": true,
|
|
569
|
+
"nulls": "last"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"expression": "type",
|
|
573
|
+
"isExpression": false,
|
|
574
|
+
"asc": true,
|
|
575
|
+
"nulls": "last"
|
|
576
|
+
}
|
|
577
|
+
],
|
|
578
|
+
"isUnique": false,
|
|
579
|
+
"concurrently": false,
|
|
580
|
+
"method": "btree",
|
|
581
|
+
"with": {}
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
"foreignKeys": {
|
|
585
|
+
"task_dependency_namespace_dependencyTaskId_task_fkey": {
|
|
586
|
+
"name": "task_dependency_namespace_dependencyTaskId_task_fkey",
|
|
587
|
+
"tableFrom": "task_dependency",
|
|
588
|
+
"tableTo": "task",
|
|
589
|
+
"schemaTo": "task_queue",
|
|
590
|
+
"columnsFrom": [
|
|
591
|
+
"namespace",
|
|
592
|
+
"dependency_task_id"
|
|
593
|
+
],
|
|
594
|
+
"columnsTo": [
|
|
595
|
+
"namespace",
|
|
596
|
+
"id"
|
|
597
|
+
],
|
|
598
|
+
"onDelete": "cascade",
|
|
599
|
+
"onUpdate": "no action"
|
|
600
|
+
},
|
|
601
|
+
"task_dependency_namespace_taskId_task_fkey": {
|
|
602
|
+
"name": "task_dependency_namespace_taskId_task_fkey",
|
|
603
|
+
"tableFrom": "task_dependency",
|
|
604
|
+
"tableTo": "task",
|
|
605
|
+
"schemaTo": "task_queue",
|
|
606
|
+
"columnsFrom": [
|
|
607
|
+
"namespace",
|
|
608
|
+
"task_id"
|
|
609
|
+
],
|
|
610
|
+
"columnsTo": [
|
|
611
|
+
"namespace",
|
|
612
|
+
"id"
|
|
613
|
+
],
|
|
614
|
+
"onDelete": "cascade",
|
|
615
|
+
"onUpdate": "no action"
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
"compositePrimaryKeys": {},
|
|
619
|
+
"uniqueConstraints": {
|
|
620
|
+
"td_namespace_task_id_dependency_task_id_type_unique": {
|
|
621
|
+
"name": "td_namespace_task_id_dependency_task_id_type_unique",
|
|
622
|
+
"nullsNotDistinct": false,
|
|
623
|
+
"columns": [
|
|
624
|
+
"namespace",
|
|
625
|
+
"task_id",
|
|
626
|
+
"dependency_task_id",
|
|
627
|
+
"type"
|
|
628
|
+
]
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
"policies": {},
|
|
632
|
+
"checkConstraints": {},
|
|
633
|
+
"isRLSEnabled": false
|
|
558
634
|
}
|
|
559
635
|
},
|
|
560
636
|
"enums": {
|
|
561
|
-
"task_queue.
|
|
562
|
-
"name": "
|
|
637
|
+
"task_queue.task_dependency_type": {
|
|
638
|
+
"name": "task_dependency_type",
|
|
563
639
|
"schema": "task_queue",
|
|
564
640
|
"values": [
|
|
565
|
-
"
|
|
566
|
-
"
|
|
641
|
+
"schedule",
|
|
642
|
+
"complete"
|
|
567
643
|
]
|
|
568
644
|
},
|
|
569
645
|
"task_queue.task_status": {
|
|
@@ -574,8 +650,10 @@
|
|
|
574
650
|
"running",
|
|
575
651
|
"completed",
|
|
576
652
|
"cancelled",
|
|
653
|
+
"dead",
|
|
577
654
|
"waiting",
|
|
578
|
-
"
|
|
655
|
+
"waiting-children",
|
|
656
|
+
"paused"
|
|
579
657
|
]
|
|
580
658
|
}
|
|
581
659
|
},
|