duron 0.1.0 → 0.2.0
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/README.md +4 -4
- package/dist/adapters/postgres/base.d.ts +52 -0
- package/dist/adapters/postgres/base.d.ts.map +1 -0
- package/dist/adapters/postgres/base.js +832 -0
- package/dist/adapters/postgres/pglite.d.ts +10 -5
- package/dist/adapters/postgres/pglite.d.ts.map +1 -1
- package/dist/adapters/postgres/pglite.js +19 -7
- package/dist/adapters/postgres/postgres.d.ts +6 -39
- package/dist/adapters/postgres/postgres.d.ts.map +1 -1
- package/dist/adapters/postgres/postgres.js +9 -822
- package/dist/adapters/postgres/schema.d.ts +89 -135
- package/dist/adapters/postgres/schema.d.ts.map +1 -1
- package/dist/adapters/postgres/schema.default.d.ts +89 -135
- package/dist/adapters/postgres/schema.default.d.ts.map +1 -1
- package/dist/step-manager.js +1 -0
- package/migrations/postgres/20251203223656_conscious_johnny_blaze/migration.sql +64 -0
- package/migrations/postgres/20251203223656_conscious_johnny_blaze/snapshot.json +954 -0
- package/package.json +3 -3
- package/src/adapters/postgres/base.ts +1297 -0
- package/src/adapters/postgres/pglite.ts +36 -18
- package/src/adapters/postgres/postgres.ts +19 -1244
- package/src/step-manager.ts +1 -0
- package/migrations/postgres/0000_lethal_speed_demon.sql +0 -64
- package/migrations/postgres/meta/0000_snapshot.json +0 -606
- package/migrations/postgres/meta/_journal.json +0 -13
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { drizzle } from 'drizzle-orm/pglite';
|
|
2
|
+
import { type AdapterOptions, PostgresBaseAdapter } from './base.js';
|
|
3
|
+
import type createSchema from './schema.js';
|
|
4
|
+
type Schema = ReturnType<typeof createSchema>;
|
|
5
|
+
export type DB = ReturnType<typeof drizzle<Schema>>;
|
|
6
|
+
export declare class PGLiteAdapter extends PostgresBaseAdapter<DB, string | undefined> {
|
|
7
|
+
protected _start(): Promise<void>;
|
|
8
|
+
protected _stop(): Promise<void>;
|
|
5
9
|
protected _map(result: any): any;
|
|
6
10
|
protected _initDb(): void;
|
|
7
11
|
protected _notify(event: string, data: any): Promise<void>;
|
|
@@ -9,5 +13,6 @@ export declare class PGLiteAdapter extends PostgresAdapter {
|
|
|
9
13
|
unlisten: () => void;
|
|
10
14
|
}>;
|
|
11
15
|
}
|
|
12
|
-
export declare const pgliteAdapter: (options:
|
|
16
|
+
export declare const pgliteAdapter: (options: AdapterOptions<string | undefined>) => PGLiteAdapter;
|
|
17
|
+
export {};
|
|
13
18
|
//# sourceMappingURL=pglite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pglite.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/pglite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"pglite.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/pglite.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAG5C,OAAO,EAAE,KAAK,cAAc,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,KAAK,YAAY,MAAM,aAAa,CAAA;AAE3C,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AAE7C,MAAM,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AAQnD,qBAAa,aAAc,SAAQ,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;cAOnD,MAAM;cAYN,KAAK;cAWX,IAAI,CAAC,MAAM,EAAE,GAAG;cAQhB,OAAO;cAoBD,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;cAWhD,OAAO,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAClC,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CASrC;AAED,eAAO,MAAM,aAAa,GAAI,SAAS,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,kBAExE,CAAA"}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
1
2
|
import { drizzle } from 'drizzle-orm/pglite';
|
|
2
|
-
import {
|
|
3
|
-
|
|
3
|
+
import { migrate } from 'drizzle-orm/pglite/migrator';
|
|
4
|
+
import { PostgresBaseAdapter } from './base.js';
|
|
5
|
+
export class PGLiteAdapter extends PostgresBaseAdapter {
|
|
6
|
+
async _start() {
|
|
7
|
+
if (this.migrateOnStart) {
|
|
8
|
+
await migrate(this.db, {
|
|
9
|
+
migrationsFolder: join(import.meta.dirname, '..', '..', '..', 'migrations', 'postgres'),
|
|
10
|
+
migrationsTable: 'migrations',
|
|
11
|
+
migrationsSchema: 'duron',
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
await super._start();
|
|
15
|
+
}
|
|
4
16
|
async _stop() {
|
|
5
|
-
await this.db
|
|
17
|
+
await this.db?.$client.close();
|
|
6
18
|
}
|
|
7
19
|
_map(result) {
|
|
8
20
|
return result.rows;
|
|
9
21
|
}
|
|
10
22
|
_initDb() {
|
|
11
23
|
let connection = ':memory:';
|
|
12
|
-
if (typeof this.
|
|
13
|
-
connection = this.
|
|
24
|
+
if (typeof this.connection === 'string' && !this.connection.startsWith('postgres://')) {
|
|
25
|
+
connection = this.connection;
|
|
14
26
|
}
|
|
15
27
|
if (connection === ':memory:') {
|
|
16
28
|
this.db = drizzle();
|
|
@@ -20,10 +32,10 @@ export class PGLiteAdapter extends PostgresAdapter {
|
|
|
20
32
|
}
|
|
21
33
|
}
|
|
22
34
|
async _notify(event, data) {
|
|
23
|
-
await this.db
|
|
35
|
+
await this.db?.$client.query(`NOTIFY "${this.schema}.${event}", '${JSON.stringify(data)}'`);
|
|
24
36
|
}
|
|
25
37
|
async _listen(event, callback) {
|
|
26
|
-
const unlisten = await this.db
|
|
38
|
+
const unlisten = await this.db?.$client.listen(`"${this.schema}.${event}"`, (payload) => {
|
|
27
39
|
callback(payload);
|
|
28
40
|
});
|
|
29
41
|
return {
|
|
@@ -1,51 +1,18 @@
|
|
|
1
1
|
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
2
2
|
import type { Options as PostgresOptions } from 'postgres';
|
|
3
|
-
import {
|
|
4
|
-
import createSchema from './schema.js';
|
|
3
|
+
import { type AdapterOptions, PostgresBaseAdapter } from './base.js';
|
|
4
|
+
import type createSchema from './schema.js';
|
|
5
5
|
type Schema = ReturnType<typeof createSchema>;
|
|
6
6
|
export type { Job, JobStep } from '../adapter.js';
|
|
7
|
-
export interface PostgresAdapterOptions {
|
|
8
|
-
connection: PostgresOptions<any> | string;
|
|
9
|
-
schema?: string;
|
|
10
|
-
migrateOnStart?: boolean;
|
|
11
|
-
}
|
|
12
7
|
export type DB = ReturnType<typeof drizzle<Schema>>;
|
|
13
|
-
export declare class PostgresAdapter extends
|
|
14
|
-
#private;
|
|
15
|
-
protected options: Required<PostgresAdapterOptions>;
|
|
16
|
-
protected db: DB;
|
|
17
|
-
protected tables: Schema;
|
|
18
|
-
constructor(options: PostgresAdapterOptions);
|
|
8
|
+
export declare class PostgresAdapter extends PostgresBaseAdapter<DB, PostgresOptions<any> | string> {
|
|
19
9
|
protected _initDb(): void;
|
|
20
|
-
_start(): Promise<void>;
|
|
21
|
-
_stop(): Promise<void>;
|
|
22
|
-
protected _createJob({ queue, groupKey, input, timeoutMs, checksum, concurrencyLimit }: CreateJobOptions): Promise<string | null>;
|
|
23
|
-
protected _completeJob({ jobId, output }: CompleteJobOptions): Promise<boolean>;
|
|
24
|
-
protected _failJob({ jobId, error }: FailJobOptions): Promise<boolean>;
|
|
25
|
-
protected _cancelJob({ jobId }: CancelJobOptions): Promise<boolean>;
|
|
26
|
-
protected _retryJob({ jobId }: RetryJobOptions): Promise<string | null>;
|
|
27
|
-
protected _deleteJob({ jobId }: DeleteJobOptions): Promise<boolean>;
|
|
28
|
-
protected _deleteJobs(options?: DeleteJobsOptions): Promise<number>;
|
|
29
|
-
protected _fetch({ batch }: FetchOptions): Promise<any>;
|
|
30
|
-
protected _recoverJobs(options: RecoverJobsOptions): Promise<number>;
|
|
31
|
-
protected _createOrRecoverJobStep({ jobId, name, timeoutMs, retriesLimit, }: CreateOrRecoverJobStepOptions): Promise<CreateOrRecoverJobStepResult | null>;
|
|
32
|
-
protected _completeJobStep({ stepId, output }: CompleteJobStepOptions): Promise<boolean>;
|
|
33
|
-
protected _failJobStep({ stepId, error }: FailJobStepOptions): Promise<boolean>;
|
|
34
|
-
protected _delayJobStep({ stepId, delayMs, error }: DelayJobStepOptions): Promise<boolean>;
|
|
35
|
-
protected _cancelJobStep({ stepId }: CancelJobStepOptions): Promise<boolean>;
|
|
36
|
-
protected _getJobById(jobId: string): Promise<Job | null>;
|
|
37
|
-
protected _getJobSteps(options: GetJobStepsOptions): Promise<GetJobStepsResult>;
|
|
38
|
-
protected _buildJobsWhereClause(filters: GetJobsOptions['filters']): import("drizzle-orm").SQL<unknown> | undefined;
|
|
39
|
-
protected _getJobs(options?: GetJobsOptions): Promise<GetJobsResult>;
|
|
40
|
-
protected _getJobStepById(stepId: string): Promise<JobStep | null>;
|
|
41
|
-
protected _getJobStatus(jobId: string): Promise<JobStatusResult | null>;
|
|
42
|
-
protected _getJobStepStatus(stepId: string): Promise<JobStepStatusResult | null>;
|
|
43
|
-
protected _getActions(): Promise<GetActionsResult>;
|
|
10
|
+
protected _start(): Promise<void>;
|
|
11
|
+
protected _stop(): Promise<void>;
|
|
44
12
|
protected _notify(event: string, data: any): Promise<void>;
|
|
45
13
|
protected _listen(event: string, callback: (payload: string) => void): Promise<{
|
|
46
14
|
unlisten: () => void;
|
|
47
15
|
}>;
|
|
48
|
-
protected _map(result: any): any;
|
|
49
16
|
}
|
|
50
|
-
export declare const postgresAdapter: (options:
|
|
17
|
+
export declare const postgresAdapter: (options: AdapterOptions<PostgresOptions<any> | string>) => PostgresAdapter;
|
|
51
18
|
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/postgres.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../src/adapters/postgres/postgres.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1D,OAAO,EAAE,KAAK,cAAc,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,KAAK,YAAY,MAAM,aAAa,CAAA;AAE3C,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AAG7C,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAMjD,MAAM,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AAQnD,qBAAa,eAAgB,SAAQ,mBAAmB,CAAC,EAAE,EAAE,eAAe,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;cAItE,OAAO;cA8BD,MAAM;cAiBN,KAAK;cAiBL,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;cAchD,OAAO,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAClC,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CAKrC;AAED,eAAO,MAAM,eAAe,GAAI,SAAS,cAAc,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,oBAErF,CAAA"}
|