@fedify/cfworkers 2.1.1 → 2.1.3
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/mod.d.ts +2 -5
- package/dist/mod.js +5 -5
- package/package.json +4 -4
package/dist/mod.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { KVNamespace, Queue } from "@cloudflare/workers-types/experimental";
|
|
1
|
+
import { KVNamespace, Queue } from "@cloudflare/workers-types/experimental/index.ts";
|
|
2
2
|
import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify/federation";
|
|
3
3
|
|
|
4
4
|
//#region src/mod.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Result from {@link WorkersMessageQueue.processMessage}.
|
|
8
7
|
* @since 2.0.0
|
|
@@ -19,7 +18,6 @@ interface ProcessMessageResult {
|
|
|
19
18
|
* The unwrapped message payload to process.
|
|
20
19
|
* Only present when `shouldProcess` is `true`.
|
|
21
20
|
*/
|
|
22
|
-
// deno-lint-ignore no-explicit-any
|
|
23
21
|
readonly message?: any;
|
|
24
22
|
/**
|
|
25
23
|
* A cleanup function that must be called after processing the message.
|
|
@@ -97,7 +95,7 @@ declare class WorkersMessageQueue implements MessageQueue {
|
|
|
97
95
|
* and Dead Letter Queues.
|
|
98
96
|
* @since 1.7.0
|
|
99
97
|
*/
|
|
100
|
-
readonly nativeRetrial
|
|
98
|
+
readonly nativeRetrial = true;
|
|
101
99
|
/**
|
|
102
100
|
* Constructs a new {@link WorkersMessageQueue} with the given queue and
|
|
103
101
|
* optional ordering key configuration.
|
|
@@ -143,7 +141,6 @@ declare class WorkersMessageQueue implements MessageQueue {
|
|
|
143
141
|
* @returns A result object indicating whether to process the message.
|
|
144
142
|
* @since 2.0.0
|
|
145
143
|
*/
|
|
146
|
-
// deno-lint-ignore no-explicit-any
|
|
147
144
|
processMessage(rawMessage: any): Promise<ProcessMessageResult>;
|
|
148
145
|
listen(_handler: (message: any) => Promise<void> | void, _options?: MessageQueueListenOptions): Promise<void>;
|
|
149
146
|
}
|
package/dist/mod.js
CHANGED
|
@@ -21,7 +21,9 @@ var WorkersKvStore = class {
|
|
|
21
21
|
async get(key) {
|
|
22
22
|
const encodedKey = this.#encodeKey(key);
|
|
23
23
|
const { value, metadata } = await this.#namespace.getWithMetadata(encodedKey, "json");
|
|
24
|
-
|
|
24
|
+
if (value == null) return void 0;
|
|
25
|
+
if (metadata?.expires != null && metadata.expires < Date.now()) return;
|
|
26
|
+
return value;
|
|
25
27
|
}
|
|
26
28
|
async set(key, value, options) {
|
|
27
29
|
const encodedKey = this.#encodeKey(key);
|
|
@@ -176,8 +178,7 @@ var WorkersMessageQueue = class {
|
|
|
176
178
|
message
|
|
177
179
|
};
|
|
178
180
|
const lockKey = this.#getOrderingLockKey(orderingKey);
|
|
179
|
-
|
|
180
|
-
if (existing != null) return { shouldProcess: false };
|
|
181
|
+
if (await this.#orderingKv.get(lockKey) != null) return { shouldProcess: false };
|
|
181
182
|
await this.#orderingKv.put(lockKey, Date.now().toString(), { expirationTtl: this.#orderingLockTtl });
|
|
182
183
|
const release = async () => {
|
|
183
184
|
await this.#orderingKv.delete(lockKey);
|
|
@@ -192,6 +193,5 @@ var WorkersMessageQueue = class {
|
|
|
192
193
|
throw new TypeError("WorkersMessageQueue does not support listen(). Use Federation.processQueuedTask() method instead.");
|
|
193
194
|
}
|
|
194
195
|
};
|
|
195
|
-
|
|
196
196
|
//#endregion
|
|
197
|
-
export { WorkersKvStore, WorkersMessageQueue };
|
|
197
|
+
export { WorkersKvStore, WorkersMessageQueue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/cfworkers",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Adapt Fedify with Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
],
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@cloudflare/workers-types": "^4.20250906.0",
|
|
55
|
-
"@fedify/fedify": "^2.1.
|
|
55
|
+
"@fedify/fedify": "^2.1.3"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@cloudflare/vitest-pool-workers": "^0.8.31",
|
|
59
|
-
"tsdown": "^0.
|
|
60
|
-
"typescript": "^5.9.
|
|
59
|
+
"tsdown": "^0.21.6",
|
|
60
|
+
"typescript": "^5.9.2",
|
|
61
61
|
"vitest": "~3.2.0",
|
|
62
62
|
"wrangler": "^4.21.1"
|
|
63
63
|
},
|