@fedify/mysql 2.3.0-dev.994 → 2.3.0-pr.809.37

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.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference lib="esnext.temporal" />
1
2
  import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions } from "@fedify/fedify";
2
3
 
3
4
  //#region src/kv.d.ts
package/dist/kv.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Temporal } from "@js-temporal/polyfill";
1
+ /// <reference lib="esnext.temporal" />
2
2
  import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions } from "@fedify/fedify";
3
3
 
4
4
  //#region src/kv.d.ts
package/dist/mod.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference lib="esnext.temporal" />
1
2
  import { MysqlKvStore, MysqlKvStoreOptions } from "./kv.cjs";
2
3
  import { MysqlMessageQueue, MysqlMessageQueueOptions } from "./mq.cjs";
3
4
  export { MysqlKvStore, type MysqlKvStoreOptions, MysqlMessageQueue, type MysqlMessageQueueOptions };
package/dist/mod.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Temporal } from "@js-temporal/polyfill";
1
+ /// <reference lib="esnext.temporal" />
2
2
  import { MysqlKvStore, MysqlKvStoreOptions } from "./kv.js";
3
3
  import { MysqlMessageQueue, MysqlMessageQueueOptions } from "./mq.js";
4
4
  export { MysqlKvStore, type MysqlKvStoreOptions, MysqlMessageQueue, type MysqlMessageQueueOptions };
package/dist/mod.js CHANGED
@@ -1,4 +1,4 @@
1
- import "@js-temporal/polyfill";
1
+ import { Temporal } from "@js-temporal/polyfill";
2
2
  import { MysqlKvStore } from "./kv.js";
3
3
  import { MysqlMessageQueue } from "./mq.js";
4
4
  export { MysqlKvStore, MysqlMessageQueue };
package/dist/mq.cjs CHANGED
@@ -170,6 +170,24 @@ var MysqlMessageQueue = class {
170
170
  });
171
171
  }
172
172
  /**
173
+ * {@inheritDoc MessageQueue.getDepth}
174
+ * @since 2.3.0
175
+ */
176
+ async getDepth() {
177
+ await this.initialize();
178
+ const [rows] = await this.#pool.query(`SELECT
179
+ COUNT(*) AS queued,
180
+ COALESCE(SUM(\`deliver_after\` <= NOW(6)), 0) AS ready
181
+ FROM \`${this.#tableName}\``);
182
+ const queued = Number(rows[0].queued);
183
+ const ready = Number(rows[0].ready);
184
+ return {
185
+ queued,
186
+ ready,
187
+ delayed: Math.max(0, queued - ready)
188
+ };
189
+ }
190
+ /**
173
191
  * {@inheritDoc MessageQueue.listen}
174
192
  * @since 2.1.0
175
193
  */
@@ -321,7 +339,7 @@ var MysqlMessageQueue = class {
321
339
  }
322
340
  /**
323
341
  * Initializes the message queue table if it does not already exist.
324
- * Concurrent calls are coalesced only one initialization runs at a time.
342
+ * Concurrent calls are coalesced—only one initialization runs at a time.
325
343
  *
326
344
  * @since 2.1.0
327
345
  */
package/dist/mq.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
2
3
 
3
4
  //#region src/mq.d.ts
4
5
  interface MysqlQueryable {
@@ -47,7 +48,7 @@ interface MysqlMessageQueueOptions {
47
48
  * The maximum time to wait for a message handler to complete before
48
49
  * the queue moves on. This is a *soft* timeout: when a handler exceeds
49
50
  * the limit, the queue stops waiting and logs a timeout error, but it
50
- * cannot cancel the handler itself the handler's promise continues
51
+ * cannot cancel the handler itself—the handler's promise continues
51
52
  * running in the background. In the ordered-key path the advisory lock
52
53
  * is always released in a `finally` block, so a timed-out handler will
53
54
  * not permanently block the same ordering key. However, concurrent
@@ -113,13 +114,18 @@ declare class MysqlMessageQueue implements MessageQueue {
113
114
  */
114
115
  enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
115
116
  /**
117
+ * {@inheritDoc MessageQueue.getDepth}
118
+ * @since 2.3.0
119
+ */
120
+ getDepth(): Promise<MessageQueueDepth>;
121
+ /**
116
122
  * {@inheritDoc MessageQueue.listen}
117
123
  * @since 2.1.0
118
124
  */
119
125
  listen(handler: (message: any) => void | Promise<void>, options?: MessageQueueListenOptions): Promise<void>;
120
126
  /**
121
127
  * Initializes the message queue table if it does not already exist.
122
- * Concurrent calls are coalesced only one initialization runs at a time.
128
+ * Concurrent calls are coalesced—only one initialization runs at a time.
123
129
  *
124
130
  * @since 2.1.0
125
131
  */
package/dist/mq.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
3
3
 
4
4
  //#region src/mq.d.ts
5
5
  interface MysqlQueryable {
@@ -48,7 +48,7 @@ interface MysqlMessageQueueOptions {
48
48
  * The maximum time to wait for a message handler to complete before
49
49
  * the queue moves on. This is a *soft* timeout: when a handler exceeds
50
50
  * the limit, the queue stops waiting and logs a timeout error, but it
51
- * cannot cancel the handler itself the handler's promise continues
51
+ * cannot cancel the handler itself—the handler's promise continues
52
52
  * running in the background. In the ordered-key path the advisory lock
53
53
  * is always released in a `finally` block, so a timed-out handler will
54
54
  * not permanently block the same ordering key. However, concurrent
@@ -114,13 +114,18 @@ declare class MysqlMessageQueue implements MessageQueue {
114
114
  */
115
115
  enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
116
116
  /**
117
+ * {@inheritDoc MessageQueue.getDepth}
118
+ * @since 2.3.0
119
+ */
120
+ getDepth(): Promise<MessageQueueDepth>;
121
+ /**
117
122
  * {@inheritDoc MessageQueue.listen}
118
123
  * @since 2.1.0
119
124
  */
120
125
  listen(handler: (message: any) => void | Promise<void>, options?: MessageQueueListenOptions): Promise<void>;
121
126
  /**
122
127
  * Initializes the message queue table if it does not already exist.
123
- * Concurrent calls are coalesced only one initialization runs at a time.
128
+ * Concurrent calls are coalesced—only one initialization runs at a time.
124
129
  *
125
130
  * @since 2.1.0
126
131
  */
package/dist/mq.js CHANGED
@@ -170,6 +170,24 @@ var MysqlMessageQueue = class {
170
170
  });
171
171
  }
172
172
  /**
173
+ * {@inheritDoc MessageQueue.getDepth}
174
+ * @since 2.3.0
175
+ */
176
+ async getDepth() {
177
+ await this.initialize();
178
+ const [rows] = await this.#pool.query(`SELECT
179
+ COUNT(*) AS queued,
180
+ COALESCE(SUM(\`deliver_after\` <= NOW(6)), 0) AS ready
181
+ FROM \`${this.#tableName}\``);
182
+ const queued = Number(rows[0].queued);
183
+ const ready = Number(rows[0].ready);
184
+ return {
185
+ queued,
186
+ ready,
187
+ delayed: Math.max(0, queued - ready)
188
+ };
189
+ }
190
+ /**
173
191
  * {@inheritDoc MessageQueue.listen}
174
192
  * @since 2.1.0
175
193
  */
@@ -321,7 +339,7 @@ var MysqlMessageQueue = class {
321
339
  }
322
340
  /**
323
341
  * Initializes the message queue table if it does not already exist.
324
- * Concurrent calls are coalesced only one initialization runs at a time.
342
+ * Concurrent calls are coalesced—only one initialization runs at a time.
325
343
  *
326
344
  * @since 2.1.0
327
345
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/mysql",
3
- "version": "2.3.0-dev.994+9071ca0a",
3
+ "version": "2.3.0-pr.809.37+0574ba5c",
4
4
  "description": "MySQL/MariaDB drivers for Fedify",
5
5
  "keywords": [
6
6
  "fedify",
@@ -70,17 +70,17 @@
70
70
  ],
71
71
  "dependencies": {
72
72
  "@js-temporal/polyfill": "^0.5.1",
73
- "@logtape/logtape": "^2.0.5",
74
- "es-toolkit": "1.43.0"
73
+ "@logtape/logtape": "^2.1.0",
74
+ "es-toolkit": "1.46.1"
75
75
  },
76
76
  "peerDependencies": {
77
- "mysql2": "^3.18.0",
78
- "@fedify/fedify": "^2.3.0-dev.994+9071ca0a"
77
+ "mysql2": "^3.22.3",
78
+ "@fedify/fedify": "^2.3.0-pr.809.37+0574ba5c"
79
79
  },
80
80
  "devDependencies": {
81
- "tsdown": "^0.21.6",
82
- "typescript": "^5.9.2",
83
- "@fedify/testing": "^2.3.0-dev.994+9071ca0a",
81
+ "tsdown": "^0.22.0",
82
+ "typescript": "^6.0.0",
83
+ "@fedify/testing": "^2.3.0-pr.809.37+0574ba5c",
84
84
  "@fedify/fixture": "^2.0.0"
85
85
  },
86
86
  "scripts": {