@fedify/sqlite 2.1.0-dev.405 → 2.1.0-dev.408

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/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/sqlite",
3
- "version": "2.1.0-dev.405+f4e278ae",
3
+ "version": "2.1.0-dev.408+5c3c9d78",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts",
@@ -1,44 +1,44 @@
1
1
  //#region src/adapter.d.ts
2
2
  /**
3
- * SQLite database adapter.
4
- *
5
- * An abstract interface for SQLite database for different runtime environments.
6
- */
3
+ * SQLite database adapter.
4
+ *
5
+ * An abstract interface for SQLite database for different runtime environments.
6
+ */
7
7
  interface SqliteDatabaseAdapter {
8
8
  /**
9
- * Prepares a SQL statement.
10
- * @param sql - The SQL statement to prepare.
11
- */
9
+ * Prepares a SQL statement.
10
+ * @param sql - The SQL statement to prepare.
11
+ */
12
12
  prepare(sql: string): SqliteStatementAdapter;
13
13
  /**
14
- * Executes a SQL statement.
15
- * @param sql - The SQL statement to execute.
16
- */
14
+ * Executes a SQL statement.
15
+ * @param sql - The SQL statement to execute.
16
+ */
17
17
  exec(sql: string): void;
18
18
  /**
19
- * Closes the database connection.
20
- */
19
+ * Closes the database connection.
20
+ */
21
21
  close(): void;
22
22
  }
23
23
  interface SqliteStatementAdapter {
24
24
  /**
25
- * Executes a SQL statement and returns the number of changes made to the database.
26
- * @param params - The parameters to bind to the SQL statement.
27
- */
25
+ * Executes a SQL statement and returns the number of changes made to the database.
26
+ * @param params - The parameters to bind to the SQL statement.
27
+ */
28
28
  run(...params: unknown[]): {
29
29
  changes: number;
30
30
  lastInsertRowid: number;
31
31
  };
32
32
  /**
33
- * Executes a SQL statement and returns the first row of the result set.
34
- * @param params - The parameters to bind to the SQL statement.
35
- * @returns The first row of the result set, or `undefined` if the result set is empty.
36
- */
33
+ * Executes a SQL statement and returns the first row of the result set.
34
+ * @param params - The parameters to bind to the SQL statement.
35
+ * @returns The first row of the result set, or `undefined` if the result set is empty.
36
+ */
37
37
  get(...params: unknown[]): unknown | undefined;
38
38
  /**
39
- * Executes a SQL statement and returns all rows of the result set.
40
- * @param params - The parameters to bind to the SQL statement.
41
- */
39
+ * Executes a SQL statement and returns all rows of the result set.
40
+ * @param params - The parameters to bind to the SQL statement.
41
+ */
42
42
  all(...params: unknown[]): unknown[];
43
43
  }
44
44
  //#endregion
package/dist/adapter.d.ts CHANGED
@@ -3,45 +3,45 @@ import { Temporal } from "@js-temporal/polyfill";
3
3
  //#region src/adapter.d.ts
4
4
 
5
5
  /**
6
- * SQLite database adapter.
7
- *
8
- * An abstract interface for SQLite database for different runtime environments.
9
- */
6
+ * SQLite database adapter.
7
+ *
8
+ * An abstract interface for SQLite database for different runtime environments.
9
+ */
10
10
  interface SqliteDatabaseAdapter {
11
11
  /**
12
- * Prepares a SQL statement.
13
- * @param sql - The SQL statement to prepare.
14
- */
12
+ * Prepares a SQL statement.
13
+ * @param sql - The SQL statement to prepare.
14
+ */
15
15
  prepare(sql: string): SqliteStatementAdapter;
16
16
  /**
17
- * Executes a SQL statement.
18
- * @param sql - The SQL statement to execute.
19
- */
17
+ * Executes a SQL statement.
18
+ * @param sql - The SQL statement to execute.
19
+ */
20
20
  exec(sql: string): void;
21
21
  /**
22
- * Closes the database connection.
23
- */
22
+ * Closes the database connection.
23
+ */
24
24
  close(): void;
25
25
  }
26
26
  interface SqliteStatementAdapter {
27
27
  /**
28
- * Executes a SQL statement and returns the number of changes made to the database.
29
- * @param params - The parameters to bind to the SQL statement.
30
- */
28
+ * Executes a SQL statement and returns the number of changes made to the database.
29
+ * @param params - The parameters to bind to the SQL statement.
30
+ */
31
31
  run(...params: unknown[]): {
32
32
  changes: number;
33
33
  lastInsertRowid: number;
34
34
  };
35
35
  /**
36
- * Executes a SQL statement and returns the first row of the result set.
37
- * @param params - The parameters to bind to the SQL statement.
38
- * @returns The first row of the result set, or `undefined` if the result set is empty.
39
- */
36
+ * Executes a SQL statement and returns the first row of the result set.
37
+ * @param params - The parameters to bind to the SQL statement.
38
+ * @returns The first row of the result set, or `undefined` if the result set is empty.
39
+ */
40
40
  get(...params: unknown[]): unknown | undefined;
41
41
  /**
42
- * Executes a SQL statement and returns all rows of the result set.
43
- * @param params - The parameters to bind to the SQL statement.
44
- */
42
+ * Executes a SQL statement and returns all rows of the result set.
43
+ * @param params - The parameters to bind to the SQL statement.
44
+ */
45
45
  all(...params: unknown[]): unknown[];
46
46
  }
47
47
  //#endregion
@@ -0,0 +1,2 @@
1
+ import { DatabaseSync } from "node:sqlite";
2
+ export { DatabaseSync };
package/dist/kv.d.cts CHANGED
@@ -1,80 +1,84 @@
1
- import { PlatformDatabase } from "#sqlite";
1
+ import { DatabaseSync } from "./dist/sqlite.node.cjs";
2
2
  import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions } from "@fedify/fedify";
3
3
 
4
4
  //#region src/kv.d.ts
5
5
  /**
6
- * Options for the SQLite key–value store.
7
- */
6
+ * Options for the SQLite key–value store.
7
+ */
8
8
  interface SqliteKvStoreOptions {
9
9
  /**
10
- * The table name to use for the key–value store.
11
- * Only letters, digits, and underscores are allowed.
12
- * `"fedify_kv"` by default.
13
- * @default `"fedify_kv"`
14
- */
10
+ * The table name to use for the key–value store.
11
+ * Only letters, digits, and underscores are allowed.
12
+ * `"fedify_kv"` by default.
13
+ * @default `"fedify_kv"`
14
+ */
15
15
  readonly tableName?: string;
16
16
  /**
17
- * Whether the table has been initialized. `false` by default.
18
- * @default `false`
19
- */
17
+ * Whether the table has been initialized. `false` by default.
18
+ * @default `false`
19
+ */
20
20
  readonly initialized?: boolean;
21
21
  }
22
22
  /**
23
- * A key–value store that uses SQLite as the underlying storage.
24
- *
25
- * @example
26
- * ```ts
27
- * import { createFederation } from "@fedify/fedify";
28
- * import { SqliteKvStore } from "@fedify/sqlite";
29
- * import { DatabaseSync } from "node:sqlite";
30
- *
31
- * const db = new DatabaseSync(":memory:");
32
- * const federation = createFederation({
33
- * // ...
34
- * kv: new SqliteKvStore(db),
35
- * });
36
- * ```
37
- */
23
+ * A key–value store that uses SQLite as the underlying storage.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { createFederation } from "@fedify/fedify";
28
+ * import { SqliteKvStore } from "@fedify/sqlite";
29
+ * import { DatabaseSync } from "node:sqlite";
30
+ *
31
+ * const db = new DatabaseSync(":memory:");
32
+ * const federation = createFederation({
33
+ * // ...
34
+ * kv: new SqliteKvStore(db),
35
+ * });
36
+ * ```
37
+ */
38
38
  declare class SqliteKvStore implements KvStore {
39
39
  #private;
40
- readonly db: PlatformDatabase;
40
+ readonly db: DatabaseSync;
41
41
  readonly options: SqliteKvStoreOptions;
42
42
  /**
43
- * Creates a new SQLite key–value store.
44
- * @param db The SQLite database to use. Supports `node:sqlite` and `bun:sqlite`.
45
- * @param options The options for the key–value store.
46
- */
47
- constructor(db: PlatformDatabase, options?: SqliteKvStoreOptions);
43
+ * Creates a new SQLite key–value store.
44
+ * @param db The SQLite database to use. Supports `node:sqlite` and `bun:sqlite`.
45
+ * @param options The options for the key–value store.
46
+ */
47
+ constructor(db: DatabaseSync, options?: SqliteKvStoreOptions);
48
48
  /**
49
- * {@inheritDoc KvStore.get}
50
- */
49
+ * {@inheritDoc KvStore.get}
50
+ */
51
+ // deno-lint-ignore require-await
51
52
  get<T = unknown>(key: KvKey): Promise<T | undefined>;
52
53
  /**
53
- * {@inheritDoc KvStore.set}
54
- */
54
+ * {@inheritDoc KvStore.set}
55
+ */
56
+ // deno-lint-ignore require-await
55
57
  set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
56
58
  /**
57
- * {@inheritDoc KvStore.delete}
58
- */
59
+ * {@inheritDoc KvStore.delete}
60
+ */
61
+ // deno-lint-ignore require-await
59
62
  delete(key: KvKey): Promise<void>;
60
63
  /**
61
- * {@inheritDoc KvStore.cas}
62
- */
64
+ * {@inheritDoc KvStore.cas}
65
+ */
66
+ // deno-lint-ignore require-await
63
67
  cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
64
68
  /**
65
- * {@inheritDoc KvStore.list}
66
- * @since 1.10.0
67
- */
69
+ * {@inheritDoc KvStore.list}
70
+ * @since 1.10.0
71
+ */
68
72
  list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
69
73
  /**
70
- * Creates the table used by the key–value store if it does not already exist.
71
- * Does nothing if the table already exists.
72
- */
74
+ * Creates the table used by the key–value store if it does not already exist.
75
+ * Does nothing if the table already exists.
76
+ */
73
77
  initialize(): void;
74
78
  /**
75
- * Drops the table used by the key–value store. Does nothing if the table
76
- * does not exist.
77
- */
79
+ * Drops the table used by the key–value store. Does nothing if the table
80
+ * does not exist.
81
+ */
78
82
  drop(): void;
79
83
  }
80
84
  //#endregion
package/dist/kv.d.ts CHANGED
@@ -4,78 +4,82 @@ import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions } from "@fedify/fed
4
4
 
5
5
  //#region src/kv.d.ts
6
6
  /**
7
- * Options for the SQLite key–value store.
8
- */
7
+ * Options for the SQLite key–value store.
8
+ */
9
9
  interface SqliteKvStoreOptions {
10
10
  /**
11
- * The table name to use for the key–value store.
12
- * Only letters, digits, and underscores are allowed.
13
- * `"fedify_kv"` by default.
14
- * @default `"fedify_kv"`
15
- */
11
+ * The table name to use for the key–value store.
12
+ * Only letters, digits, and underscores are allowed.
13
+ * `"fedify_kv"` by default.
14
+ * @default `"fedify_kv"`
15
+ */
16
16
  readonly tableName?: string;
17
17
  /**
18
- * Whether the table has been initialized. `false` by default.
19
- * @default `false`
20
- */
18
+ * Whether the table has been initialized. `false` by default.
19
+ * @default `false`
20
+ */
21
21
  readonly initialized?: boolean;
22
22
  }
23
23
  /**
24
- * A key–value store that uses SQLite as the underlying storage.
25
- *
26
- * @example
27
- * ```ts
28
- * import { createFederation } from "@fedify/fedify";
29
- * import { SqliteKvStore } from "@fedify/sqlite";
30
- * import { DatabaseSync } from "node:sqlite";
31
- *
32
- * const db = new DatabaseSync(":memory:");
33
- * const federation = createFederation({
34
- * // ...
35
- * kv: new SqliteKvStore(db),
36
- * });
37
- * ```
38
- */
24
+ * A key–value store that uses SQLite as the underlying storage.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { createFederation } from "@fedify/fedify";
29
+ * import { SqliteKvStore } from "@fedify/sqlite";
30
+ * import { DatabaseSync } from "node:sqlite";
31
+ *
32
+ * const db = new DatabaseSync(":memory:");
33
+ * const federation = createFederation({
34
+ * // ...
35
+ * kv: new SqliteKvStore(db),
36
+ * });
37
+ * ```
38
+ */
39
39
  declare class SqliteKvStore implements KvStore {
40
40
  #private;
41
41
  readonly db: PlatformDatabase;
42
42
  readonly options: SqliteKvStoreOptions;
43
43
  /**
44
- * Creates a new SQLite key–value store.
45
- * @param db The SQLite database to use. Supports `node:sqlite` and `bun:sqlite`.
46
- * @param options The options for the key–value store.
47
- */
44
+ * Creates a new SQLite key–value store.
45
+ * @param db The SQLite database to use. Supports `node:sqlite` and `bun:sqlite`.
46
+ * @param options The options for the key–value store.
47
+ */
48
48
  constructor(db: PlatformDatabase, options?: SqliteKvStoreOptions);
49
49
  /**
50
- * {@inheritDoc KvStore.get}
51
- */
50
+ * {@inheritDoc KvStore.get}
51
+ */
52
+ // deno-lint-ignore require-await
52
53
  get<T = unknown>(key: KvKey): Promise<T | undefined>;
53
54
  /**
54
- * {@inheritDoc KvStore.set}
55
- */
55
+ * {@inheritDoc KvStore.set}
56
+ */
57
+ // deno-lint-ignore require-await
56
58
  set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
57
59
  /**
58
- * {@inheritDoc KvStore.delete}
59
- */
60
+ * {@inheritDoc KvStore.delete}
61
+ */
62
+ // deno-lint-ignore require-await
60
63
  delete(key: KvKey): Promise<void>;
61
64
  /**
62
- * {@inheritDoc KvStore.cas}
63
- */
65
+ * {@inheritDoc KvStore.cas}
66
+ */
67
+ // deno-lint-ignore require-await
64
68
  cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
65
69
  /**
66
- * {@inheritDoc KvStore.list}
67
- * @since 1.10.0
68
- */
70
+ * {@inheritDoc KvStore.list}
71
+ * @since 1.10.0
72
+ */
69
73
  list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
70
74
  /**
71
- * Creates the table used by the key–value store if it does not already exist.
72
- * Does nothing if the table already exists.
73
- */
75
+ * Creates the table used by the key–value store if it does not already exist.
76
+ * Does nothing if the table already exists.
77
+ */
74
78
  initialize(): void;
75
79
  /**
76
- * Drops the table used by the key–value store. Does nothing if the table
77
- * does not exist.
78
- */
80
+ * Drops the table used by the key–value store. Does nothing if the table
81
+ * does not exist.
82
+ */
79
83
  drop(): void;
80
84
  }
81
85
  //#endregion
package/dist/mq.d.cts CHANGED
@@ -1,111 +1,111 @@
1
- import { PlatformDatabase } from "#sqlite";
1
+ import { DatabaseSync } from "./dist/sqlite.node.cjs";
2
2
  import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
3
3
 
4
4
  //#region src/mq.d.ts
5
5
  /**
6
- * Options for the SQLite message queue.
7
- */
6
+ * Options for the SQLite message queue.
7
+ */
8
8
  interface SqliteMessageQueueOptions {
9
9
  /**
10
- * The table name to use for the message queue.
11
- * Only letters, digits, and underscores are allowed.
12
- * `"fedify_message"` by default.
13
- * @default `"fedify_message"`
14
- */
10
+ * The table name to use for the message queue.
11
+ * Only letters, digits, and underscores are allowed.
12
+ * `"fedify_message"` by default.
13
+ * @default `"fedify_message"`
14
+ */
15
15
  tableName?: string;
16
16
  /**
17
- * Whether the table has been initialized. `false` by default.
18
- * @default `false`
19
- */
17
+ * Whether the table has been initialized. `false` by default.
18
+ * @default `false`
19
+ */
20
20
  initialized?: boolean;
21
21
  /**
22
- * The poll interval for the message queue.
23
- * @default `{ seconds: 5 }`
24
- */
22
+ * The poll interval for the message queue.
23
+ * @default `{ seconds: 5 }`
24
+ */
25
25
  pollInterval?: Temporal.Duration | Temporal.DurationLike;
26
26
  /**
27
- * Maximum number of retries for SQLITE_BUSY errors.
28
- * @default `5`
29
- */
27
+ * Maximum number of retries for SQLITE_BUSY errors.
28
+ * @default `5`
29
+ */
30
30
  maxRetries?: number;
31
31
  /**
32
- * Initial retry delay in milliseconds for SQLITE_BUSY errors.
33
- * Uses exponential backoff.
34
- * @default `100`
35
- */
32
+ * Initial retry delay in milliseconds for SQLITE_BUSY errors.
33
+ * Uses exponential backoff.
34
+ * @default `100`
35
+ */
36
36
  retryDelayMs?: number;
37
37
  /**
38
- * SQLite journal mode to use.
39
- * WAL (Write-Ahead Logging) mode is recommended for better concurrency
40
- * in multi-process environments.
41
- * Note: WAL mode is persistent per database file, not per connection.
42
- * @default `"WAL"`
43
- */
38
+ * SQLite journal mode to use.
39
+ * WAL (Write-Ahead Logging) mode is recommended for better concurrency
40
+ * in multi-process environments.
41
+ * Note: WAL mode is persistent per database file, not per connection.
42
+ * @default `"WAL"`
43
+ */
44
44
  journalMode?: "WAL" | "DELETE" | "TRUNCATE" | "PERSIST" | "MEMORY";
45
45
  }
46
46
  /**
47
- * A message queue that uses SQLite as the underlying storage.
48
- *
49
- * This implementation is designed for single-node deployments and uses
50
- * polling to check for new messages. It is not suitable for high-throughput
51
- * scenarios or distributed environments.
52
- *
53
- * @example
54
- * ```ts ignore
55
- * import { createFederation } from "@fedify/fedify";
56
- * import { SqliteMessageQueue } from "@fedify/sqlite";
57
- * import { DatabaseSync } from "node:sqlite";
58
- *
59
- * const db = new DatabaseSync(":memory:");
60
- * const federation = createFederation({
61
- * // ...
62
- * queue: new SqliteMessageQueue(db),
63
- * });
64
- * ```
65
- */
47
+ * A message queue that uses SQLite as the underlying storage.
48
+ *
49
+ * This implementation is designed for single-node deployments and uses
50
+ * polling to check for new messages. It is not suitable for high-throughput
51
+ * scenarios or distributed environments.
52
+ *
53
+ * @example
54
+ * ```ts ignore
55
+ * import { createFederation } from "@fedify/fedify";
56
+ * import { SqliteMessageQueue } from "@fedify/sqlite";
57
+ * import { DatabaseSync } from "node:sqlite";
58
+ *
59
+ * const db = new DatabaseSync(":memory:");
60
+ * const federation = createFederation({
61
+ * // ...
62
+ * queue: new SqliteMessageQueue(db),
63
+ * });
64
+ * ```
65
+ */
66
66
  declare class SqliteMessageQueue implements MessageQueue, Disposable {
67
67
  #private;
68
- readonly db: PlatformDatabase;
68
+ readonly db: DatabaseSync;
69
69
  readonly options: SqliteMessageQueueOptions;
70
70
  /**
71
- * SQLite message queue does not provide native retry mechanisms.
72
- */
73
- readonly nativeRetrial = false;
71
+ * SQLite message queue does not provide native retry mechanisms.
72
+ */
73
+ readonly nativeRetrial: false;
74
74
  /**
75
- * Creates a new SQLite message queue.
76
- * @param db The SQLite database to use. Supports `node:sqlite`, `bun:sqlite`.
77
- * @param options The options for the message queue.
78
- */
79
- constructor(db: PlatformDatabase, options?: SqliteMessageQueueOptions);
75
+ * Creates a new SQLite message queue.
76
+ * @param db The SQLite database to use. Supports `node:sqlite`, `bun:sqlite`.
77
+ * @param options The options for the message queue.
78
+ */
79
+ constructor(db: DatabaseSync, options?: SqliteMessageQueueOptions);
80
80
  /**
81
- * {@inheritDoc MessageQueue.enqueue}
82
- */
81
+ * {@inheritDoc MessageQueue.enqueue}
82
+ */
83
83
  enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
84
84
  /**
85
- * {@inheritDoc MessageQueue.enqueueMany}
86
- */
85
+ * {@inheritDoc MessageQueue.enqueueMany}
86
+ */
87
87
  enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
88
88
  /**
89
- * {@inheritDoc MessageQueue.listen}
90
- */
89
+ * {@inheritDoc MessageQueue.listen}
90
+ */
91
91
  listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
92
92
  /**
93
- * Creates the message queue table if it does not already exist.
94
- * Does nothing if the table already exists.
95
- *
96
- * This method also configures the SQLite journal mode for better concurrency.
97
- * WAL (Write-Ahead Logging) mode is enabled by default to improve
98
- * concurrent access in multi-process environments.
99
- */
93
+ * Creates the message queue table if it does not already exist.
94
+ * Does nothing if the table already exists.
95
+ *
96
+ * This method also configures the SQLite journal mode for better concurrency.
97
+ * WAL (Write-Ahead Logging) mode is enabled by default to improve
98
+ * concurrent access in multi-process environments.
99
+ */
100
100
  initialize(): void;
101
101
  /**
102
- * Drops the tables used by the message queue. Does nothing if the tables
103
- * do not exist.
104
- */
102
+ * Drops the tables used by the message queue. Does nothing if the tables
103
+ * do not exist.
104
+ */
105
105
  drop(): void;
106
106
  /**
107
- * Closes the database connection.
108
- */
107
+ * Closes the database connection.
108
+ */
109
109
  [Symbol.dispose](): void;
110
110
  }
111
111
  //#endregion
package/dist/mq.d.ts CHANGED
@@ -4,109 +4,109 @@ import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } f
4
4
 
5
5
  //#region src/mq.d.ts
6
6
  /**
7
- * Options for the SQLite message queue.
8
- */
7
+ * Options for the SQLite message queue.
8
+ */
9
9
  interface SqliteMessageQueueOptions {
10
10
  /**
11
- * The table name to use for the message queue.
12
- * Only letters, digits, and underscores are allowed.
13
- * `"fedify_message"` by default.
14
- * @default `"fedify_message"`
15
- */
11
+ * The table name to use for the message queue.
12
+ * Only letters, digits, and underscores are allowed.
13
+ * `"fedify_message"` by default.
14
+ * @default `"fedify_message"`
15
+ */
16
16
  tableName?: string;
17
17
  /**
18
- * Whether the table has been initialized. `false` by default.
19
- * @default `false`
20
- */
18
+ * Whether the table has been initialized. `false` by default.
19
+ * @default `false`
20
+ */
21
21
  initialized?: boolean;
22
22
  /**
23
- * The poll interval for the message queue.
24
- * @default `{ seconds: 5 }`
25
- */
23
+ * The poll interval for the message queue.
24
+ * @default `{ seconds: 5 }`
25
+ */
26
26
  pollInterval?: Temporal.Duration | Temporal.DurationLike;
27
27
  /**
28
- * Maximum number of retries for SQLITE_BUSY errors.
29
- * @default `5`
30
- */
28
+ * Maximum number of retries for SQLITE_BUSY errors.
29
+ * @default `5`
30
+ */
31
31
  maxRetries?: number;
32
32
  /**
33
- * Initial retry delay in milliseconds for SQLITE_BUSY errors.
34
- * Uses exponential backoff.
35
- * @default `100`
36
- */
33
+ * Initial retry delay in milliseconds for SQLITE_BUSY errors.
34
+ * Uses exponential backoff.
35
+ * @default `100`
36
+ */
37
37
  retryDelayMs?: number;
38
38
  /**
39
- * SQLite journal mode to use.
40
- * WAL (Write-Ahead Logging) mode is recommended for better concurrency
41
- * in multi-process environments.
42
- * Note: WAL mode is persistent per database file, not per connection.
43
- * @default `"WAL"`
44
- */
39
+ * SQLite journal mode to use.
40
+ * WAL (Write-Ahead Logging) mode is recommended for better concurrency
41
+ * in multi-process environments.
42
+ * Note: WAL mode is persistent per database file, not per connection.
43
+ * @default `"WAL"`
44
+ */
45
45
  journalMode?: "WAL" | "DELETE" | "TRUNCATE" | "PERSIST" | "MEMORY";
46
46
  }
47
47
  /**
48
- * A message queue that uses SQLite as the underlying storage.
49
- *
50
- * This implementation is designed for single-node deployments and uses
51
- * polling to check for new messages. It is not suitable for high-throughput
52
- * scenarios or distributed environments.
53
- *
54
- * @example
55
- * ```ts ignore
56
- * import { createFederation } from "@fedify/fedify";
57
- * import { SqliteMessageQueue } from "@fedify/sqlite";
58
- * import { DatabaseSync } from "node:sqlite";
59
- *
60
- * const db = new DatabaseSync(":memory:");
61
- * const federation = createFederation({
62
- * // ...
63
- * queue: new SqliteMessageQueue(db),
64
- * });
65
- * ```
66
- */
48
+ * A message queue that uses SQLite as the underlying storage.
49
+ *
50
+ * This implementation is designed for single-node deployments and uses
51
+ * polling to check for new messages. It is not suitable for high-throughput
52
+ * scenarios or distributed environments.
53
+ *
54
+ * @example
55
+ * ```ts ignore
56
+ * import { createFederation } from "@fedify/fedify";
57
+ * import { SqliteMessageQueue } from "@fedify/sqlite";
58
+ * import { DatabaseSync } from "node:sqlite";
59
+ *
60
+ * const db = new DatabaseSync(":memory:");
61
+ * const federation = createFederation({
62
+ * // ...
63
+ * queue: new SqliteMessageQueue(db),
64
+ * });
65
+ * ```
66
+ */
67
67
  declare class SqliteMessageQueue implements MessageQueue, Disposable {
68
68
  #private;
69
69
  readonly db: PlatformDatabase;
70
70
  readonly options: SqliteMessageQueueOptions;
71
71
  /**
72
- * SQLite message queue does not provide native retry mechanisms.
73
- */
74
- readonly nativeRetrial = false;
72
+ * SQLite message queue does not provide native retry mechanisms.
73
+ */
74
+ readonly nativeRetrial: false;
75
75
  /**
76
- * Creates a new SQLite message queue.
77
- * @param db The SQLite database to use. Supports `node:sqlite`, `bun:sqlite`.
78
- * @param options The options for the message queue.
79
- */
76
+ * Creates a new SQLite message queue.
77
+ * @param db The SQLite database to use. Supports `node:sqlite`, `bun:sqlite`.
78
+ * @param options The options for the message queue.
79
+ */
80
80
  constructor(db: PlatformDatabase, options?: SqliteMessageQueueOptions);
81
81
  /**
82
- * {@inheritDoc MessageQueue.enqueue}
83
- */
82
+ * {@inheritDoc MessageQueue.enqueue}
83
+ */
84
84
  enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
85
85
  /**
86
- * {@inheritDoc MessageQueue.enqueueMany}
87
- */
86
+ * {@inheritDoc MessageQueue.enqueueMany}
87
+ */
88
88
  enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
89
89
  /**
90
- * {@inheritDoc MessageQueue.listen}
91
- */
90
+ * {@inheritDoc MessageQueue.listen}
91
+ */
92
92
  listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
93
93
  /**
94
- * Creates the message queue table if it does not already exist.
95
- * Does nothing if the table already exists.
96
- *
97
- * This method also configures the SQLite journal mode for better concurrency.
98
- * WAL (Write-Ahead Logging) mode is enabled by default to improve
99
- * concurrent access in multi-process environments.
100
- */
94
+ * Creates the message queue table if it does not already exist.
95
+ * Does nothing if the table already exists.
96
+ *
97
+ * This method also configures the SQLite journal mode for better concurrency.
98
+ * WAL (Write-Ahead Logging) mode is enabled by default to improve
99
+ * concurrent access in multi-process environments.
100
+ */
101
101
  initialize(): void;
102
102
  /**
103
- * Drops the tables used by the message queue. Does nothing if the tables
104
- * do not exist.
105
- */
103
+ * Drops the tables used by the message queue. Does nothing if the tables
104
+ * do not exist.
105
+ */
106
106
  drop(): void;
107
107
  /**
108
- * Closes the database connection.
109
- */
108
+ * Closes the database connection.
109
+ */
110
110
  [Symbol.dispose](): void;
111
111
  }
112
112
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/sqlite",
3
- "version": "2.1.0-dev.405+f4e278ae",
3
+ "version": "2.1.0-dev.408+5c3c9d78",
4
4
  "description": "SQLite drivers for Fedify",
5
5
  "keywords": [
6
6
  "fedify",
@@ -72,13 +72,13 @@
72
72
  "es-toolkit": "^1.31.0"
73
73
  },
74
74
  "peerDependencies": {
75
- "@fedify/fedify": "^2.1.0-dev.405+f4e278ae"
75
+ "@fedify/fedify": "^2.1.0-dev.408+5c3c9d78"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@std/async": "npm:@jsr/std__async@^1.0.13",
79
79
  "tsdown": "^0.12.9",
80
80
  "typescript": "^5.9.3",
81
- "@fedify/testing": "^2.1.0-dev.405+f4e278ae"
81
+ "@fedify/testing": "^2.1.0-dev.408+5c3c9d78"
82
82
  },
83
83
  "scripts": {
84
84
  "build:self": "tsdown",
package/src/kv.ts CHANGED
@@ -266,7 +266,7 @@ export class SqliteKvStore implements KvStore {
266
266
  * Creates the table used by the key–value store if it does not already exist.
267
267
  * Does nothing if the table already exists.
268
268
  */
269
- initialize() {
269
+ initialize(): void {
270
270
  if (this.#initialized) {
271
271
  return;
272
272
  }
@@ -309,7 +309,7 @@ export class SqliteKvStore implements KvStore {
309
309
  * Drops the table used by the key–value store. Does nothing if the table
310
310
  * does not exist.
311
311
  */
312
- drop() {
312
+ drop(): void {
313
313
  this.#db.exec(`DROP TABLE IF EXISTS "${this.#tableName}"`);
314
314
  this.#initialized = false;
315
315
  }
package/tsdown.config.ts CHANGED
@@ -8,7 +8,7 @@ export default defineConfig({
8
8
  "src/sqlite.node.ts",
9
9
  "src/sqlite.bun.ts",
10
10
  ],
11
- dts: true,
11
+ dts: { compilerOptions: { isolatedDeclarations: true, declaration: true } },
12
12
  unbundle: true,
13
13
  format: ["esm", "cjs"],
14
14
  platform: "node",