@fedify/postgres 2.0.26-dev.1876 → 2.0.27-dev.1941

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/mq.cjs CHANGED
@@ -56,7 +56,8 @@ var PostgresMessageQueue = class {
56
56
  #channelName;
57
57
  #pollIntervalMs;
58
58
  #handlerTimeoutMs;
59
- #initialized;
59
+ #skipDdl;
60
+ #initialized = false;
60
61
  #initPromise;
61
62
  #driverSerializesJson = false;
62
63
  constructor(sql, options = {}) {
@@ -65,7 +66,7 @@ var PostgresMessageQueue = class {
65
66
  this.#channelName = options?.channelName ?? "fedify_channel";
66
67
  this.#pollIntervalMs = Temporal.Duration.from(options?.pollInterval ?? { seconds: 5 }).total("millisecond");
67
68
  this.#handlerTimeoutMs = Temporal.Duration.from(options?.handlerTimeout ?? { seconds: 60 }).total("millisecond");
68
- this.#initialized = options?.initialized ?? false;
69
+ this.#skipDdl = options?.initialized ?? false;
69
70
  }
70
71
  async enqueue(message, options) {
71
72
  await this.initialize();
@@ -278,6 +279,12 @@ var PostgresMessageQueue = class {
278
279
  }
279
280
  async #doInitialize() {
280
281
  logger.debug("Initializing the message queue table {tableName}...", { tableName: this.#tableName });
282
+ if (!this.#skipDdl) await this.#initializeTable();
283
+ this.#driverSerializesJson = await require_utils.driverSerializesJson(this.#sql);
284
+ this.#initialized = true;
285
+ logger.debug("Initialized the message queue table {tableName}.", { tableName: this.#tableName });
286
+ }
287
+ async #initializeTable() {
281
288
  for (let attempt = 1; attempt <= INITIALIZE_MAX_ATTEMPTS; attempt++) try {
282
289
  await this.#sql`
283
290
  CREATE TABLE IF NOT EXISTS ${this.#sql(this.#tableName)} (
@@ -312,9 +319,6 @@ var PostgresMessageQueue = class {
312
319
  });
313
320
  await sleep(backoffMs);
314
321
  }
315
- this.#driverSerializesJson = await require_utils.driverSerializesJson(this.#sql);
316
- this.#initialized = true;
317
- logger.debug("Initialized the message queue table {tableName}.", { tableName: this.#tableName });
318
322
  }
319
323
  /**
320
324
  * 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
@@ -53,7 +53,8 @@ var PostgresMessageQueue = class {
53
53
  #channelName;
54
54
  #pollIntervalMs;
55
55
  #handlerTimeoutMs;
56
- #initialized;
56
+ #skipDdl;
57
+ #initialized = false;
57
58
  #initPromise;
58
59
  #driverSerializesJson = false;
59
60
  constructor(sql, options = {}) {
@@ -62,7 +63,7 @@ var PostgresMessageQueue = class {
62
63
  this.#channelName = options?.channelName ?? "fedify_channel";
63
64
  this.#pollIntervalMs = Temporal.Duration.from(options?.pollInterval ?? { seconds: 5 }).total("millisecond");
64
65
  this.#handlerTimeoutMs = Temporal.Duration.from(options?.handlerTimeout ?? { seconds: 60 }).total("millisecond");
65
- this.#initialized = options?.initialized ?? false;
66
+ this.#skipDdl = options?.initialized ?? false;
66
67
  }
67
68
  async enqueue(message, options) {
68
69
  await this.initialize();
@@ -275,6 +276,12 @@ var PostgresMessageQueue = class {
275
276
  }
276
277
  async #doInitialize() {
277
278
  logger.debug("Initializing the message queue table {tableName}...", { tableName: this.#tableName });
279
+ if (!this.#skipDdl) await this.#initializeTable();
280
+ this.#driverSerializesJson = await driverSerializesJson(this.#sql);
281
+ this.#initialized = true;
282
+ logger.debug("Initialized the message queue table {tableName}.", { tableName: this.#tableName });
283
+ }
284
+ async #initializeTable() {
278
285
  for (let attempt = 1; attempt <= INITIALIZE_MAX_ATTEMPTS; attempt++) try {
279
286
  await this.#sql`
280
287
  CREATE TABLE IF NOT EXISTS ${this.#sql(this.#tableName)} (
@@ -309,9 +316,6 @@ var PostgresMessageQueue = class {
309
316
  });
310
317
  await sleep(backoffMs);
311
318
  }
312
- this.#driverSerializesJson = await driverSerializesJson(this.#sql);
313
- this.#initialized = true;
314
- logger.debug("Initialized the message queue table {tableName}.", { tableName: this.#tableName });
315
319
  }
316
320
  /**
317
321
  * 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.0.26-dev.1876+a95acb45",
3
+ "version": "2.0.27-dev.1941+9c8ec49c",
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.0.26-dev.1876+a95acb45"
77
+ "@fedify/fedify": "^2.0.27-dev.1941+9c8ec49c"
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
- "@fedify/fixture": "^2.0.0",
84
- "@fedify/testing": "^2.0.26-dev.1876+a95acb45"
83
+ "@fedify/testing": "^2.0.27-dev.1941+9c8ec49c",
84
+ "@fedify/fixture": "^2.0.0"
85
85
  },
86
86
  "scripts": {
87
87
  "build:self": "tsdown",