@fedify/postgres 2.2.11 → 2.2.13
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/kv.cjs +9 -5
- package/dist/kv.d.cts +4 -0
- package/dist/kv.d.ts +4 -0
- package/dist/kv.js +9 -5
- package/dist/mq.cjs +9 -5
- package/dist/mq.d.cts +4 -0
- package/dist/mq.d.ts +4 -0
- package/dist/mq.js +9 -5
- package/package.json +3 -3
package/dist/kv.cjs
CHANGED
|
@@ -26,7 +26,8 @@ const logger = (0, require("@logtape/logtape").getLogger)([
|
|
|
26
26
|
var PostgresKvStore = class {
|
|
27
27
|
#sql;
|
|
28
28
|
#tableName;
|
|
29
|
-
#
|
|
29
|
+
#skipDdl;
|
|
30
|
+
#initialized = false;
|
|
30
31
|
#driverSerializesJson = false;
|
|
31
32
|
/**
|
|
32
33
|
* Creates a new PostgreSQL key–value store.
|
|
@@ -36,7 +37,7 @@ var PostgresKvStore = class {
|
|
|
36
37
|
constructor(sql, options = {}) {
|
|
37
38
|
this.#sql = sql;
|
|
38
39
|
this.#tableName = options.tableName ?? "fedify_kv_v2";
|
|
39
|
-
this.#
|
|
40
|
+
this.#skipDdl = options.initialized ?? false;
|
|
40
41
|
}
|
|
41
42
|
async #expire() {
|
|
42
43
|
await this.#sql`
|
|
@@ -113,6 +114,12 @@ var PostgresKvStore = class {
|
|
|
113
114
|
async initialize() {
|
|
114
115
|
if (this.#initialized) return;
|
|
115
116
|
logger.debug("Initializing the key–value store table {tableName}...", { tableName: this.#tableName });
|
|
117
|
+
if (!this.#skipDdl) await this.#initializeTable();
|
|
118
|
+
this.#driverSerializesJson = await require_utils.driverSerializesJson(this.#sql);
|
|
119
|
+
this.#initialized = true;
|
|
120
|
+
logger.debug("Initialized the key–value store table {tableName}.", { tableName: this.#tableName });
|
|
121
|
+
}
|
|
122
|
+
async #initializeTable() {
|
|
116
123
|
await this.#sql`
|
|
117
124
|
CREATE UNLOGGED TABLE IF NOT EXISTS ${this.#sql(this.#tableName)} (
|
|
118
125
|
key text[] PRIMARY KEY,
|
|
@@ -121,9 +128,6 @@ var PostgresKvStore = class {
|
|
|
121
128
|
ttl interval
|
|
122
129
|
);
|
|
123
130
|
`;
|
|
124
|
-
this.#driverSerializesJson = await require_utils.driverSerializesJson(this.#sql);
|
|
125
|
-
this.#initialized = true;
|
|
126
|
-
logger.debug("Initialized the key–value store table {tableName}.", { tableName: this.#tableName });
|
|
127
131
|
}
|
|
128
132
|
/**
|
|
129
133
|
* Drops the table used by the key–value store. Does nothing if the table
|
package/dist/kv.d.cts
CHANGED
|
@@ -15,6 +15,10 @@ interface PostgresKvStoreOptions {
|
|
|
15
15
|
readonly tableName?: string;
|
|
16
16
|
/**
|
|
17
17
|
* Whether the table has been initialized. `false` by default.
|
|
18
|
+
*
|
|
19
|
+
* This skips only the table's schema DDL. Driver-specific runtime setup,
|
|
20
|
+
* such as detecting whether the driver serializes JSON parameters on its
|
|
21
|
+
* own, still runs before the first key is read or written.
|
|
18
22
|
* @default `false`
|
|
19
23
|
*/
|
|
20
24
|
readonly initialized?: boolean;
|
package/dist/kv.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ interface PostgresKvStoreOptions {
|
|
|
15
15
|
readonly tableName?: string;
|
|
16
16
|
/**
|
|
17
17
|
* Whether the table has been initialized. `false` by default.
|
|
18
|
+
*
|
|
19
|
+
* This skips only the table's schema DDL. Driver-specific runtime setup,
|
|
20
|
+
* such as detecting whether the driver serializes JSON parameters on its
|
|
21
|
+
* own, still runs before the first key is read or written.
|
|
18
22
|
* @default `false`
|
|
19
23
|
*/
|
|
20
24
|
readonly initialized?: boolean;
|
package/dist/kv.js
CHANGED
|
@@ -25,7 +25,8 @@ const logger = getLogger([
|
|
|
25
25
|
var PostgresKvStore = class {
|
|
26
26
|
#sql;
|
|
27
27
|
#tableName;
|
|
28
|
-
#
|
|
28
|
+
#skipDdl;
|
|
29
|
+
#initialized = false;
|
|
29
30
|
#driverSerializesJson = false;
|
|
30
31
|
/**
|
|
31
32
|
* Creates a new PostgreSQL key–value store.
|
|
@@ -35,7 +36,7 @@ var PostgresKvStore = class {
|
|
|
35
36
|
constructor(sql, options = {}) {
|
|
36
37
|
this.#sql = sql;
|
|
37
38
|
this.#tableName = options.tableName ?? "fedify_kv_v2";
|
|
38
|
-
this.#
|
|
39
|
+
this.#skipDdl = options.initialized ?? false;
|
|
39
40
|
}
|
|
40
41
|
async #expire() {
|
|
41
42
|
await this.#sql`
|
|
@@ -112,6 +113,12 @@ var PostgresKvStore = class {
|
|
|
112
113
|
async initialize() {
|
|
113
114
|
if (this.#initialized) return;
|
|
114
115
|
logger.debug("Initializing the key–value store table {tableName}...", { tableName: this.#tableName });
|
|
116
|
+
if (!this.#skipDdl) await this.#initializeTable();
|
|
117
|
+
this.#driverSerializesJson = await driverSerializesJson(this.#sql);
|
|
118
|
+
this.#initialized = true;
|
|
119
|
+
logger.debug("Initialized the key–value store table {tableName}.", { tableName: this.#tableName });
|
|
120
|
+
}
|
|
121
|
+
async #initializeTable() {
|
|
115
122
|
await this.#sql`
|
|
116
123
|
CREATE UNLOGGED TABLE IF NOT EXISTS ${this.#sql(this.#tableName)} (
|
|
117
124
|
key text[] PRIMARY KEY,
|
|
@@ -120,9 +127,6 @@ var PostgresKvStore = class {
|
|
|
120
127
|
ttl interval
|
|
121
128
|
);
|
|
122
129
|
`;
|
|
123
|
-
this.#driverSerializesJson = await driverSerializesJson(this.#sql);
|
|
124
|
-
this.#initialized = true;
|
|
125
|
-
logger.debug("Initialized the key–value store table {tableName}.", { tableName: this.#tableName });
|
|
126
130
|
}
|
|
127
131
|
/**
|
|
128
132
|
* Drops the table used by the key–value store. Does nothing if the table
|
package/dist/mq.cjs
CHANGED
|
@@ -60,7 +60,8 @@ var PostgresMessageQueue = class {
|
|
|
60
60
|
#channelName;
|
|
61
61
|
#pollIntervalMs;
|
|
62
62
|
#handlerTimeoutMs;
|
|
63
|
-
#
|
|
63
|
+
#skipDdl;
|
|
64
|
+
#initialized = false;
|
|
64
65
|
#initPromise;
|
|
65
66
|
#driverSerializesJson = false;
|
|
66
67
|
constructor(sql, options = {}) {
|
|
@@ -69,7 +70,7 @@ var PostgresMessageQueue = class {
|
|
|
69
70
|
this.#channelName = options?.channelName ?? "fedify_channel";
|
|
70
71
|
this.#pollIntervalMs = Temporal.Duration.from(options?.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
71
72
|
this.#handlerTimeoutMs = Temporal.Duration.from(options?.handlerTimeout ?? { seconds: 60 }).total("millisecond");
|
|
72
|
-
this.#
|
|
73
|
+
this.#skipDdl = options?.initialized ?? false;
|
|
73
74
|
}
|
|
74
75
|
async enqueue(message, options) {
|
|
75
76
|
await this.initialize();
|
|
@@ -290,6 +291,12 @@ var PostgresMessageQueue = class {
|
|
|
290
291
|
}
|
|
291
292
|
async #doInitialize() {
|
|
292
293
|
logger.debug("Initializing the message queue table {tableName}...", { tableName: this.#tableName });
|
|
294
|
+
if (!this.#skipDdl) await this.#initializeTable();
|
|
295
|
+
this.#driverSerializesJson = await require_utils.driverSerializesJson(this.#sql);
|
|
296
|
+
this.#initialized = true;
|
|
297
|
+
logger.debug("Initialized the message queue table {tableName}.", { tableName: this.#tableName });
|
|
298
|
+
}
|
|
299
|
+
async #initializeTable() {
|
|
293
300
|
for (let attempt = 1; attempt <= INITIALIZE_MAX_ATTEMPTS; attempt++) try {
|
|
294
301
|
await this.#sql`
|
|
295
302
|
CREATE TABLE IF NOT EXISTS ${this.#sql(this.#tableName)} (
|
|
@@ -324,9 +331,6 @@ var PostgresMessageQueue = class {
|
|
|
324
331
|
});
|
|
325
332
|
await sleep(backoffMs);
|
|
326
333
|
}
|
|
327
|
-
this.#driverSerializesJson = await require_utils.driverSerializesJson(this.#sql);
|
|
328
|
-
this.#initialized = true;
|
|
329
|
-
logger.debug("Initialized the message queue table {tableName}.", { tableName: this.#tableName });
|
|
330
334
|
}
|
|
331
335
|
/**
|
|
332
336
|
* Drops the message queue table if it exists.
|
package/dist/mq.d.cts
CHANGED
|
@@ -21,6 +21,10 @@ interface PostgresMessageQueueOptions {
|
|
|
21
21
|
readonly channelName?: string;
|
|
22
22
|
/**
|
|
23
23
|
* Whether the table has been initialized. `false` by default.
|
|
24
|
+
*
|
|
25
|
+
* This skips only the table's schema DDL. Driver-specific runtime setup,
|
|
26
|
+
* such as detecting whether the driver serializes JSON parameters on its
|
|
27
|
+
* own, still runs before the first message is enqueued.
|
|
24
28
|
* @default `false`
|
|
25
29
|
*/
|
|
26
30
|
readonly initialized?: boolean;
|
package/dist/mq.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ interface PostgresMessageQueueOptions {
|
|
|
21
21
|
readonly channelName?: string;
|
|
22
22
|
/**
|
|
23
23
|
* Whether the table has been initialized. `false` by default.
|
|
24
|
+
*
|
|
25
|
+
* This skips only the table's schema DDL. Driver-specific runtime setup,
|
|
26
|
+
* such as detecting whether the driver serializes JSON parameters on its
|
|
27
|
+
* own, still runs before the first message is enqueued.
|
|
24
28
|
* @default `false`
|
|
25
29
|
*/
|
|
26
30
|
readonly initialized?: boolean;
|
package/dist/mq.js
CHANGED
|
@@ -57,7 +57,8 @@ var PostgresMessageQueue = class {
|
|
|
57
57
|
#channelName;
|
|
58
58
|
#pollIntervalMs;
|
|
59
59
|
#handlerTimeoutMs;
|
|
60
|
-
#
|
|
60
|
+
#skipDdl;
|
|
61
|
+
#initialized = false;
|
|
61
62
|
#initPromise;
|
|
62
63
|
#driverSerializesJson = false;
|
|
63
64
|
constructor(sql, options = {}) {
|
|
@@ -66,7 +67,7 @@ var PostgresMessageQueue = class {
|
|
|
66
67
|
this.#channelName = options?.channelName ?? "fedify_channel";
|
|
67
68
|
this.#pollIntervalMs = Temporal.Duration.from(options?.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
68
69
|
this.#handlerTimeoutMs = Temporal.Duration.from(options?.handlerTimeout ?? { seconds: 60 }).total("millisecond");
|
|
69
|
-
this.#
|
|
70
|
+
this.#skipDdl = options?.initialized ?? false;
|
|
70
71
|
}
|
|
71
72
|
async enqueue(message, options) {
|
|
72
73
|
await this.initialize();
|
|
@@ -287,6 +288,12 @@ var PostgresMessageQueue = class {
|
|
|
287
288
|
}
|
|
288
289
|
async #doInitialize() {
|
|
289
290
|
logger.debug("Initializing the message queue table {tableName}...", { tableName: this.#tableName });
|
|
291
|
+
if (!this.#skipDdl) await this.#initializeTable();
|
|
292
|
+
this.#driverSerializesJson = await driverSerializesJson(this.#sql);
|
|
293
|
+
this.#initialized = true;
|
|
294
|
+
logger.debug("Initialized the message queue table {tableName}.", { tableName: this.#tableName });
|
|
295
|
+
}
|
|
296
|
+
async #initializeTable() {
|
|
290
297
|
for (let attempt = 1; attempt <= INITIALIZE_MAX_ATTEMPTS; attempt++) try {
|
|
291
298
|
await this.#sql`
|
|
292
299
|
CREATE TABLE IF NOT EXISTS ${this.#sql(this.#tableName)} (
|
|
@@ -321,9 +328,6 @@ var PostgresMessageQueue = class {
|
|
|
321
328
|
});
|
|
322
329
|
await sleep(backoffMs);
|
|
323
330
|
}
|
|
324
|
-
this.#driverSerializesJson = await driverSerializesJson(this.#sql);
|
|
325
|
-
this.#initialized = true;
|
|
326
|
-
logger.debug("Initialized the message queue table {tableName}.", { tableName: this.#tableName });
|
|
327
331
|
}
|
|
328
332
|
/**
|
|
329
333
|
* Drops the message queue table if it exists.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/postgres",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.13",
|
|
4
4
|
"description": "PostgreSQL drivers for Fedify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -74,14 +74,14 @@
|
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"postgres": "^3.4.7",
|
|
77
|
-
"@fedify/fedify": "^2.2.
|
|
77
|
+
"@fedify/fedify": "^2.2.13"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@std/async": "npm:@jsr/std__async@^1.0.13",
|
|
81
81
|
"tsdown": "^0.21.6",
|
|
82
82
|
"typescript": "^6.0.0",
|
|
83
83
|
"@fedify/fixture": "^2.0.0",
|
|
84
|
-
"@fedify/testing": "^2.2.
|
|
84
|
+
"@fedify/testing": "^2.2.13"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build:self": "tsdown",
|