@absurd-sqlite/sdk 0.2.1-alpha.2 → 0.3.0-alpha.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/dist/cjs/index.js CHANGED
@@ -1,21 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Absurd = exports.resolveExtensionPath = exports.downloadExtension = void 0;
4
- const absurd_sdk_1 = require("absurd-sdk");
5
- const sqlite_1 = require("./sqlite");
3
+ exports.Absurd = exports.SQLiteConnection = exports.resolveExtensionPath = exports.downloadExtension = exports.TaskContext = exports.TimeoutError = exports.SuspendTask = exports.CancelledTask = void 0;
4
+ const absurd_1 = require("./absurd");
5
+ var absurd_2 = require("./absurd");
6
+ Object.defineProperty(exports, "CancelledTask", { enumerable: true, get: function () { return absurd_2.CancelledTask; } });
7
+ Object.defineProperty(exports, "SuspendTask", { enumerable: true, get: function () { return absurd_2.SuspendTask; } });
8
+ Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return absurd_2.TimeoutError; } });
9
+ Object.defineProperty(exports, "TaskContext", { enumerable: true, get: function () { return absurd_2.TaskContext; } });
6
10
  var extension_downloader_1 = require("./extension-downloader");
7
11
  Object.defineProperty(exports, "downloadExtension", { enumerable: true, get: function () { return extension_downloader_1.downloadExtension; } });
8
12
  Object.defineProperty(exports, "resolveExtensionPath", { enumerable: true, get: function () { return extension_downloader_1.resolveExtensionPath; } });
9
- class Absurd extends absurd_sdk_1.Absurd {
10
- db;
11
- constructor(db, extensionPath) {
12
- db.loadExtension(extensionPath);
13
- const queryable = new sqlite_1.SqliteConnection(db);
14
- super(queryable);
15
- this.db = db;
16
- }
17
- async close() {
18
- this.db.close();
13
+ var sqlite_connection_1 = require("./sqlite-connection");
14
+ Object.defineProperty(exports, "SQLiteConnection", { enumerable: true, get: function () { return sqlite_connection_1.SQLiteConnection; } });
15
+ class Absurd extends absurd_1.AbsurdImpl {
16
+ constructor(connection, options) {
17
+ super({
18
+ db: connection,
19
+ queueName: options?.queueName,
20
+ defaultMaxAttempts: options?.defaultMaxAttempts,
21
+ log: options?.log,
22
+ hooks: options?.hooks,
23
+ ownedConnection: false,
24
+ });
19
25
  }
20
26
  }
21
27
  exports.Absurd = Absurd;
@@ -1,34 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SqliteConnection = void 0;
4
- class SqliteConnection {
3
+ exports.SQLiteConnection = void 0;
4
+ /**
5
+ * SQLite adapter that rewrites Absurd's SQL to SQLite syntax and handles retries.
6
+ */
7
+ class SQLiteConnection {
5
8
  db;
6
9
  maxRetries = 5;
7
10
  baseRetryDelayMs = 50;
8
- constructor(db) {
11
+ codec;
12
+ verbose;
13
+ constructor(db, options = {}) {
9
14
  this.db = db;
10
- // TODO: verbose logging
15
+ this.codec = {
16
+ encodeParam: options.valueCodec?.encodeParam ?? encodeColumnValue,
17
+ decodeColumn: options.valueCodec?.decodeColumn ?? decodeColumnValue,
18
+ decodeRow: options.valueCodec?.decodeRow,
19
+ };
20
+ this.verbose = options.verbose;
11
21
  }
12
22
  async query(sql, params) {
13
23
  const sqliteQuery = rewritePostgresQuery(sql);
14
- const sqliteParams = rewritePostgresParams(params);
24
+ const sqliteParams = rewritePostgresParams(params, this.codec.encodeParam);
15
25
  const statement = this.db.prepare(sqliteQuery);
16
26
  if (!statement.readonly) {
17
27
  // this indicates `return_data` is false
18
28
  // https://github.com/WiseLibs/better-sqlite3/blob/6209be238d6a1b181f516e4e636986604b0f62e1/src/objects/statement.cpp#L134C83-L134C95
19
29
  throw new Error("The query() method is only statements that return data");
20
30
  }
21
- const rowsDecoded = await this.runWithRetry(() => statement
22
- .all(sqliteParams)
23
- .map((row) => decodeRowValues(statement, row)));
31
+ const rowsDecoded = await this.runWithRetry(() => {
32
+ const rows = statement.all(sqliteParams);
33
+ return rows.map((row) => decodeRowValues(statement, row, this.codec, this.verbose));
34
+ });
24
35
  return { rows: rowsDecoded };
25
36
  }
26
37
  async exec(sql, params) {
27
38
  const sqliteQuery = rewritePostgresQuery(sql);
28
- const sqliteParams = rewritePostgresParams(params);
39
+ const sqliteParams = rewritePostgresParams(params, this.codec.encodeParam);
29
40
  const statement = this.db.prepare(sqliteQuery);
30
41
  await this.runWithRetry(() => statement.run(sqliteParams));
31
42
  }
43
+ close() {
44
+ this.db.close();
45
+ }
32
46
  async runWithRetry(operation) {
33
47
  let attempt = 0;
34
48
  while (true) {
@@ -45,38 +59,59 @@ class SqliteConnection {
45
59
  }
46
60
  }
47
61
  }
48
- exports.SqliteConnection = SqliteConnection;
62
+ exports.SQLiteConnection = SQLiteConnection;
49
63
  const namedParamPrefix = "p";
50
64
  function rewritePostgresQuery(text) {
51
65
  return text
52
66
  .replace(/\$(\d+)/g, `:${namedParamPrefix}$1`)
53
67
  .replace(/absurd\.(\w+)/g, "absurd_$1");
54
68
  }
55
- function rewritePostgresParams(params) {
69
+ function rewritePostgresParams(params, encodeParam) {
56
70
  if (!params) {
57
71
  return {};
58
72
  }
59
73
  const rewrittenParams = {};
60
- params.forEach((value, index) => {
61
- const paramKey = `${namedParamPrefix}${index + 1}`;
62
- const encodedParamValue = encodeColumnValue(value);
63
- rewrittenParams[paramKey] = encodedParamValue;
64
- });
74
+ if (Array.isArray(params)) {
75
+ params.forEach((value, index) => {
76
+ const paramKey = `${namedParamPrefix}${index + 1}`;
77
+ const encodedParamValue = encodeParam(value);
78
+ rewrittenParams[paramKey] = encodedParamValue;
79
+ });
80
+ return rewrittenParams;
81
+ }
82
+ for (const [key, value] of Object.entries(params)) {
83
+ rewrittenParams[key] = encodeParam(value);
84
+ }
65
85
  return rewrittenParams;
66
86
  }
67
- function decodeRowValues(statement, row, verbose) {
87
+ function decodeRowValues(statement, row, codec, verbose) {
68
88
  const columns = statement.columns();
89
+ const rowRecord = row;
90
+ if (codec.decodeRow) {
91
+ return codec.decodeRow({
92
+ row: rowRecord,
93
+ columns,
94
+ decodeColumn: codec.decodeColumn,
95
+ verbose,
96
+ });
97
+ }
69
98
  const decodedRow = {};
70
99
  for (const column of columns) {
71
100
  const columnName = column.name;
72
101
  const columnType = column.type;
73
- const rawValue = row[columnName];
74
- const decodedValue = decodeColumnValue(rawValue, columnName, columnType, verbose);
102
+ const rawValue = rowRecord[columnName];
103
+ const decodedValue = codec.decodeColumn({
104
+ value: rawValue,
105
+ columnName,
106
+ columnType,
107
+ verbose,
108
+ });
75
109
  decodedRow[columnName] = decodedValue;
76
110
  }
77
111
  return decodedRow;
78
112
  }
79
- function decodeColumnValue(value, columnName, columnType, verbose) {
113
+ function decodeColumnValue(args) {
114
+ const { value, columnName, columnType, verbose } = args;
80
115
  if (value === null || value === undefined) {
81
116
  return null;
82
117
  }
package/dist/index.d.ts CHANGED
@@ -1,13 +1,104 @@
1
- import { Absurd as AbsurdBase } from "absurd-sdk";
2
- import type { AbsurdClient } from "./absurd-types";
3
- import type { SQLiteDatabase } from "./sqlite-types";
4
- export type { AbsurdClient, Queryable, Worker } from "./absurd-types";
1
+ import { AbsurdImpl, type AbsurdOptions as AbsurdImplOptions, type ClaimedTask, type JsonValue, type SpawnOptions, type SpawnResult, type TaskHandler, type TaskRegistrationOptions, type WorkerOptions } from "./absurd";
2
+ import { SQLiteConnection } from "./sqlite-connection";
3
+ export type { Queryable } from "./absurd";
4
+ export { CancelledTask, SuspendTask, TimeoutError, TaskContext, type AbsurdHooks, type CancellationPolicy, type ClaimedTask, type JsonObject, type JsonValue, type RetryStrategy, type SpawnOptions, type SpawnResult, type TaskHandler, type TaskRegistrationOptions, type WorkerOptions, } from "./absurd";
5
5
  export { downloadExtension, resolveExtensionPath, type DownloadExtensionOptions, } from "./extension-downloader";
6
- export type { AbsurdHooks, AbsurdOptions, CancellationPolicy, ClaimedTask, JsonObject, JsonValue, RetryStrategy, SpawnOptions, SpawnResult, TaskContext, TaskHandler, TaskRegistrationOptions, WorkerOptions, } from "absurd-sdk";
7
6
  export type { SQLiteBindParams, SQLiteBindValue, SQLiteColumnDefinition, SQLiteDatabase, SQLiteRestBindParams, SQLiteStatement, SQLiteVerboseLog, } from "./sqlite-types";
8
- export declare class Absurd extends AbsurdBase implements AbsurdClient {
9
- private db;
10
- constructor(db: SQLiteDatabase, extensionPath: string);
7
+ export { SQLiteConnection } from "./sqlite-connection";
8
+ export type { SQLiteConnectionOptions, SQLiteValueCodec } from "./sqlite-connection";
9
+ /**
10
+ * SQLite-specific Absurd client that loads the extension and owns the database handle.
11
+ */
12
+ export type AbsurdOptions = Omit<AbsurdImplOptions, "db" | "ownedConnection">;
13
+ /**
14
+ * Background worker handle returned by startWorker().
15
+ */
16
+ export interface Worker {
17
+ /**
18
+ * Stop the worker loop and wait for in-flight tasks to settle.
19
+ */
11
20
  close(): Promise<void>;
12
21
  }
22
+ /**
23
+ * Absurd client interface.
24
+ */
25
+ export interface AbsurdClient {
26
+ /**
27
+ * Register a task handler.
28
+ * @param options Task registration options.
29
+ * @param handler Async task handler.
30
+ */
31
+ registerTask<P = any, R = any>(options: TaskRegistrationOptions, handler: TaskHandler<P, R>): void;
32
+ /**
33
+ * Create a queue.
34
+ * @param queueName Optional queue name (defaults to client queue).
35
+ */
36
+ createQueue(queueName?: string): Promise<void>;
37
+ /**
38
+ * Drop a queue.
39
+ * @param queueName Optional queue name (defaults to client queue).
40
+ */
41
+ dropQueue(queueName?: string): Promise<void>;
42
+ /**
43
+ * List available queues.
44
+ */
45
+ listQueues(): Promise<Array<string>>;
46
+ /**
47
+ * Spawn a task execution.
48
+ * @param taskName Task name.
49
+ * @param params Task parameters.
50
+ * @param options Spawn options including queue and retry behavior.
51
+ */
52
+ spawn<P = any>(taskName: string, params: P, options?: SpawnOptions): Promise<SpawnResult>;
53
+ /**
54
+ * Emit an event on a queue.
55
+ * @param eventName Non-empty event name.
56
+ * @param payload Optional JSON payload.
57
+ * @param queueName Optional queue name (defaults to client queue).
58
+ */
59
+ emitEvent(eventName: string, payload?: JsonValue, queueName?: string): Promise<void>;
60
+ /**
61
+ * Cancel a task by ID.
62
+ * @param taskID Task identifier.
63
+ * @param queueName Optional queue name (defaults to client queue).
64
+ */
65
+ cancelTask(taskID: string, queueName?: string): Promise<void>;
66
+ /**
67
+ * Claim tasks for processing.
68
+ * @param options Claiming options.
69
+ */
70
+ claimTasks(options?: {
71
+ batchSize?: number;
72
+ claimTimeout?: number;
73
+ workerId?: string;
74
+ }): Promise<ClaimedTask[]>;
75
+ /**
76
+ * Claim and process a batch of tasks sequentially.
77
+ * @param workerId Worker identifier.
78
+ * @param claimTimeout Lease duration in seconds.
79
+ * @param batchSize Max tasks to process.
80
+ */
81
+ workBatch(workerId?: string, claimTimeout?: number, batchSize?: number): Promise<void>;
82
+ /**
83
+ * Start a background worker that polls and executes tasks.
84
+ * @param options Worker behavior options.
85
+ */
86
+ startWorker(options?: WorkerOptions): Promise<Worker>;
87
+ /**
88
+ * Close the client and any owned resources.
89
+ */
90
+ close(): Promise<void>;
91
+ /**
92
+ * Execute a claimed task (used by workers).
93
+ * @param task Claimed task record.
94
+ * @param claimTimeout Lease duration in seconds.
95
+ * @param options Execution options.
96
+ */
97
+ executeTask(task: ClaimedTask, claimTimeout: number, options?: {
98
+ fatalOnLeaseTimeout?: boolean;
99
+ }): Promise<void>;
100
+ }
101
+ export declare class Absurd extends AbsurdImpl implements AbsurdClient {
102
+ constructor(connection: SQLiteConnection, options?: AbsurdOptions);
103
+ }
13
104
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,wBAAwB,GAC9B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,WAAW,EACX,WAAW,EACX,WAAW,EACX,uBAAuB,EACvB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,qBAAa,MAAO,SAAQ,UAAW,YAAW,YAAY;IAC5D,OAAO,CAAC,EAAE,CAAiB;gBAEf,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM;IAO/C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAClB,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O,CAAC,EAAE,SAAS,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;;OAGG;IACH,UAAU,CAAC,OAAO,CAAC,EAAE;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAE3B;;;;;OAKG;IACH,SAAS,CACP,QAAQ,CAAC,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;OAGG;IACH,WAAW,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtD;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,WAAW,CACT,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;QAAE,mBAAmB,CAAC,EAAE,OAAO,CAAA;KAAE,GAC1C,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED,qBAAa,MAAO,SAAQ,UAAW,YAAW,YAAY;gBAChD,UAAU,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,aAAa;CAUlE"}
package/dist/index.js CHANGED
@@ -1,16 +1,17 @@
1
- import { Absurd as AbsurdBase } from "absurd-sdk";
2
- import { SqliteConnection } from "./sqlite";
1
+ import { AbsurdImpl, } from "./absurd";
2
+ export { CancelledTask, SuspendTask, TimeoutError, TaskContext, } from "./absurd";
3
3
  export { downloadExtension, resolveExtensionPath, } from "./extension-downloader";
4
- export class Absurd extends AbsurdBase {
5
- db;
6
- constructor(db, extensionPath) {
7
- db.loadExtension(extensionPath);
8
- const queryable = new SqliteConnection(db);
9
- super(queryable);
10
- this.db = db;
11
- }
12
- async close() {
13
- this.db.close();
4
+ export { SQLiteConnection } from "./sqlite-connection";
5
+ export class Absurd extends AbsurdImpl {
6
+ constructor(connection, options) {
7
+ super({
8
+ db: connection,
9
+ queueName: options?.queueName,
10
+ defaultMaxAttempts: options?.defaultMaxAttempts,
11
+ log: options?.log,
12
+ hooks: options?.hooks,
13
+ ownedConnection: false,
14
+ });
14
15
  }
15
16
  }
16
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EACL,iBAAiB,EACjB,oBAAoB,GAErB,MAAM,wBAAwB,CAAC;AA0BhC,MAAM,OAAO,MAAO,SAAQ,UAAU;IAC5B,EAAE,CAAiB;IAE3B,YAAY,EAAkB,EAAE,aAAqB;QACnD,EAAE,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAChC,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC3C,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACF"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GASX,MAAM,UAAU,CAAC;AAIlB,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,WAAW,GAYZ,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,GAErB,MAAM,wBAAwB,CAAC;AAUhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA4HvD,MAAM,OAAO,MAAO,SAAQ,UAAU;IACpC,YAAY,UAA4B,EAAE,OAAuB;QAC/D,KAAK,CAAC;YACJ,EAAE,EAAE,UAAU;YACd,SAAS,EAAE,OAAO,EAAE,SAAS;YAC7B,kBAAkB,EAAE,OAAO,EAAE,kBAAkB;YAC/C,GAAG,EAAE,OAAO,EAAE,GAAG;YACjB,KAAK,EAAE,OAAO,EAAE,KAAK;YACrB,eAAe,EAAE,KAAK;SACvB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ import type { Queryable } from "./absurd";
2
+ import type { SQLiteColumnDefinition, SQLiteDatabase, SQLiteVerboseLog, SQLiteBindValue } from "./sqlite-types";
3
+ /**
4
+ * Hooks for encoding parameters and decoding query results.
5
+ * Useful when SQLite drivers expose different value representations.
6
+ */
7
+ export interface SQLiteValueCodec {
8
+ encodeParam?: (value: SQLiteBindValue) => SQLiteBindValue;
9
+ decodeColumn?: (args: {
10
+ value: unknown;
11
+ columnName: string;
12
+ columnType: string | null;
13
+ verbose?: SQLiteVerboseLog;
14
+ }) => unknown;
15
+ decodeRow?: (args: {
16
+ row: Record<string, unknown>;
17
+ columns: SQLiteColumnDefinition[];
18
+ decodeColumn: NonNullable<SQLiteValueCodec["decodeColumn"]>;
19
+ verbose?: SQLiteVerboseLog;
20
+ }) => Record<string, unknown>;
21
+ }
22
+ /**
23
+ * Configuration options for SQLiteConnection.
24
+ */
25
+ export interface SQLiteConnectionOptions {
26
+ valueCodec?: SQLiteValueCodec;
27
+ verbose?: SQLiteVerboseLog;
28
+ }
29
+ /**
30
+ * SQLite adapter that rewrites Absurd's SQL to SQLite syntax and handles retries.
31
+ */
32
+ export declare class SQLiteConnection implements Queryable {
33
+ private readonly db;
34
+ private readonly maxRetries;
35
+ private readonly baseRetryDelayMs;
36
+ private readonly codec;
37
+ private readonly verbose?;
38
+ constructor(db: SQLiteDatabase, options?: SQLiteConnectionOptions);
39
+ query<R extends object = Record<string, any>>(sql: string, params?: unknown[] | Record<string, unknown>): Promise<{
40
+ rows: R[];
41
+ }>;
42
+ exec(sql: string, params?: unknown[] | Record<string, unknown>): Promise<void>;
43
+ close(): void;
44
+ private runWithRetry;
45
+ }
46
+ //# sourceMappingURL=sqlite-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-connection.d.ts","sourceRoot":"","sources":["../src/sqlite-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EAEd,gBAAgB,EAChB,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,eAAe,CAAC;IAC1D,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,KAAK,EAAE,OAAO,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,OAAO,CAAC,EAAE,gBAAgB,CAAC;KAC5B,KAAK,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QACjB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,EAAE,sBAAsB,EAAE,CAAC;QAClC,YAAY,EAAE,WAAW,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;QAC5D,OAAO,CAAC,EAAE,gBAAgB,CAAC;KAC5B,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAChD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAiB;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAK;IAChC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAM;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CACgB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAmB;gBAEhC,EAAE,EAAE,cAAc,EAAE,OAAO,GAAE,uBAA4B;IAU/D,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChD,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3C,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,EAAE,CAAA;KAAE,CAAC;IAqBnB,IAAI,CACR,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3C,OAAO,CAAC,IAAI,CAAC;IAQhB,KAAK,IAAI,IAAI;YAIC,YAAY;CAc3B"}
@@ -1,31 +1,45 @@
1
- export class SqliteConnection {
1
+ /**
2
+ * SQLite adapter that rewrites Absurd's SQL to SQLite syntax and handles retries.
3
+ */
4
+ export class SQLiteConnection {
2
5
  db;
3
6
  maxRetries = 5;
4
7
  baseRetryDelayMs = 50;
5
- constructor(db) {
8
+ codec;
9
+ verbose;
10
+ constructor(db, options = {}) {
6
11
  this.db = db;
7
- // TODO: verbose logging
12
+ this.codec = {
13
+ encodeParam: options.valueCodec?.encodeParam ?? encodeColumnValue,
14
+ decodeColumn: options.valueCodec?.decodeColumn ?? decodeColumnValue,
15
+ decodeRow: options.valueCodec?.decodeRow,
16
+ };
17
+ this.verbose = options.verbose;
8
18
  }
9
19
  async query(sql, params) {
10
20
  const sqliteQuery = rewritePostgresQuery(sql);
11
- const sqliteParams = rewritePostgresParams(params);
21
+ const sqliteParams = rewritePostgresParams(params, this.codec.encodeParam);
12
22
  const statement = this.db.prepare(sqliteQuery);
13
23
  if (!statement.readonly) {
14
24
  // this indicates `return_data` is false
15
25
  // https://github.com/WiseLibs/better-sqlite3/blob/6209be238d6a1b181f516e4e636986604b0f62e1/src/objects/statement.cpp#L134C83-L134C95
16
26
  throw new Error("The query() method is only statements that return data");
17
27
  }
18
- const rowsDecoded = await this.runWithRetry(() => statement
19
- .all(sqliteParams)
20
- .map((row) => decodeRowValues(statement, row)));
28
+ const rowsDecoded = await this.runWithRetry(() => {
29
+ const rows = statement.all(sqliteParams);
30
+ return rows.map((row) => decodeRowValues(statement, row, this.codec, this.verbose));
31
+ });
21
32
  return { rows: rowsDecoded };
22
33
  }
23
34
  async exec(sql, params) {
24
35
  const sqliteQuery = rewritePostgresQuery(sql);
25
- const sqliteParams = rewritePostgresParams(params);
36
+ const sqliteParams = rewritePostgresParams(params, this.codec.encodeParam);
26
37
  const statement = this.db.prepare(sqliteQuery);
27
38
  await this.runWithRetry(() => statement.run(sqliteParams));
28
39
  }
40
+ close() {
41
+ this.db.close();
42
+ }
29
43
  async runWithRetry(operation) {
30
44
  let attempt = 0;
31
45
  while (true) {
@@ -48,31 +62,52 @@ function rewritePostgresQuery(text) {
48
62
  .replace(/\$(\d+)/g, `:${namedParamPrefix}$1`)
49
63
  .replace(/absurd\.(\w+)/g, "absurd_$1");
50
64
  }
51
- function rewritePostgresParams(params) {
65
+ function rewritePostgresParams(params, encodeParam) {
52
66
  if (!params) {
53
67
  return {};
54
68
  }
55
69
  const rewrittenParams = {};
56
- params.forEach((value, index) => {
57
- const paramKey = `${namedParamPrefix}${index + 1}`;
58
- const encodedParamValue = encodeColumnValue(value);
59
- rewrittenParams[paramKey] = encodedParamValue;
60
- });
70
+ if (Array.isArray(params)) {
71
+ params.forEach((value, index) => {
72
+ const paramKey = `${namedParamPrefix}${index + 1}`;
73
+ const encodedParamValue = encodeParam(value);
74
+ rewrittenParams[paramKey] = encodedParamValue;
75
+ });
76
+ return rewrittenParams;
77
+ }
78
+ for (const [key, value] of Object.entries(params)) {
79
+ rewrittenParams[key] = encodeParam(value);
80
+ }
61
81
  return rewrittenParams;
62
82
  }
63
- function decodeRowValues(statement, row, verbose) {
83
+ function decodeRowValues(statement, row, codec, verbose) {
64
84
  const columns = statement.columns();
85
+ const rowRecord = row;
86
+ if (codec.decodeRow) {
87
+ return codec.decodeRow({
88
+ row: rowRecord,
89
+ columns,
90
+ decodeColumn: codec.decodeColumn,
91
+ verbose,
92
+ });
93
+ }
65
94
  const decodedRow = {};
66
95
  for (const column of columns) {
67
96
  const columnName = column.name;
68
97
  const columnType = column.type;
69
- const rawValue = row[columnName];
70
- const decodedValue = decodeColumnValue(rawValue, columnName, columnType, verbose);
98
+ const rawValue = rowRecord[columnName];
99
+ const decodedValue = codec.decodeColumn({
100
+ value: rawValue,
101
+ columnName,
102
+ columnType,
103
+ verbose,
104
+ });
71
105
  decodedRow[columnName] = decodedValue;
72
106
  }
73
107
  return decodedRow;
74
108
  }
75
- function decodeColumnValue(value, columnName, columnType, verbose) {
109
+ function decodeColumnValue(args) {
110
+ const { value, columnName, columnType, verbose } = args;
76
111
  if (value === null || value === undefined) {
77
112
  return null;
78
113
  }
@@ -152,4 +187,4 @@ function isRetryableSQLiteError(err) {
152
187
  function delay(ms) {
153
188
  return new Promise((resolve) => setTimeout(resolve, ms));
154
189
  }
155
- //# sourceMappingURL=sqlite.js.map
190
+ //# sourceMappingURL=sqlite-connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-connection.js","sourceRoot":"","sources":["../src/sqlite-connection.ts"],"names":[],"mappings":"AAqCA;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACV,EAAE,CAAiB;IACnB,UAAU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AC,IAAI,CAAC;IAC/B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,KAAK,MAAM,aAAa,IAAI,yBAAyB,EAAE,CAAC;YACtD,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;gBACnC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAI,GAAW,CAAC,KAAK,CAAC;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -12,7 +12,7 @@ export interface SQLiteStatement<Result extends object = Record<string, any>> {
12
12
  readonly: boolean;
13
13
  columns(): SQLiteColumnDefinition[];
14
14
  all(...args: SQLiteRestBindParams): Result[];
15
- run(...args: SQLiteRestBindParams): number;
15
+ run(...args: SQLiteRestBindParams): unknown;
16
16
  }
17
17
  export interface SQLiteDatabase {
18
18
  prepare<Result extends object = Record<string, any>>(sql: string): SQLiteStatement<Result>;
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-types.d.ts","sourceRoot":"","sources":["../src/sqlite-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GACxB,eAAe,EAAE,GACjB,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG,eAAe,EAAE,GAAG,CAAC,gBAAgB,CAAC,CA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AC,gBAAgB,CAAC,CAAC;AAE1E,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,eAAe,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACpC,GAAG,CAAC,GAAG,IAAI,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAAC;IAC7C,GAAG,CAAC,GAAG,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC;CAC7C;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjD,GAAG,EAAE,MAAM,GACV,eAAe,CAAC,MAAM,CAAC,CAAC;IAC3B,KAAK,IAAI,IAAI,CAAC;IACd,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,CAAC,EAAE,GAAG,EACb,GAAG,cAAc,EAAE,GAAG,EAAE,KACrB,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absurd-sqlite/sdk",
3
- "version": "0.2.1-alpha.2",
3
+ "version": "0.3.0-alpha.0",
4
4
  "description": "TypeScript SDK for Absurd-SQLite - SQLite-based durable task execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,8 @@
12
12
  "test": "npm run test:prepare && vitest --silent --run",
13
13
  "test:watch": "npm run test:prepare && vitest",
14
14
  "test:ui": "npm run test:prepare && vitest --ui",
15
- "docs": "typedoc"
15
+ "docs": "typedoc",
16
+ "docs:serve": "typedoc --watch --out docs/api & python3 -m http.server 8080 -d docs/api"
16
17
  },
17
18
  "repository": {
18
19
  "type": "git",
@@ -35,9 +36,6 @@
35
36
  "peerDependencies": {
36
37
  "better-sqlite3": "^12.5.0"
37
38
  },
38
- "dependencies": {
39
- "absurd-sdk": "https://github.com/bcho/absurd/releases/download/sdks%2Ftypescript%2Fv0.0.7/typescript-sdk-v0.0.7.tgz"
40
- },
41
39
  "devDependencies": {
42
40
  "@types/better-sqlite3": "^7.6.13",
43
41
  "@types/node": "^22.18.0",
@@ -48,4 +46,4 @@
48
46
  "engines": {
49
47
  "node": ">=18.0.0"
50
48
  }
51
- }
49
+ }