@fedify/fedify 2.0.0-pr.458.1791 → 2.0.0-pr.467.1876
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/{actor-B1Ok0M4n.cjs → actor-9gjVpXgd.cjs} +185 -185
- package/dist/{actor-Cca09Hlc.js → actor-CsH6QBYT.js} +185 -185
- package/dist/{actor-BjOdI0ZL.js → actor-D1LkZWVU.js} +1 -1
- package/dist/{builder-G4Si9uyR.js → builder-DCBCGtfN.js} +3 -3
- package/dist/compat/mod.d.cts +2 -3
- package/dist/compat/mod.d.ts +2 -3
- package/dist/compat/transformers.test.js +14 -14
- package/dist/{context-DJ8aSy2Q.d.cts → context-PxGADCsD.d.cts} +140 -3
- package/dist/{context-DG0huGW-.d.ts → context-V-XS2_6O.d.ts} +140 -3
- package/dist/{docloader-7NmfEq4O.js → docloader-BaWIuRb2.js} +2 -2
- package/dist/{esm-CXBuq5BO.js → esm-uX3RtJS9.js} +1 -1
- package/dist/federation/builder.test.js +4 -4
- package/dist/federation/collection.test.js +2 -2
- package/dist/federation/handler.test.js +15 -15
- package/dist/federation/idempotency.test.js +15 -15
- package/dist/federation/inbox.test.js +3 -3
- package/dist/federation/keycache.test.js +3 -3
- package/dist/federation/kv.test.js +2 -2
- package/dist/federation/middleware.test.js +16 -16
- package/dist/federation/mod.cjs +7 -7
- package/dist/federation/mod.d.cts +2 -3
- package/dist/federation/mod.d.ts +2 -3
- package/dist/federation/mod.js +7 -7
- package/dist/federation/mq.test.js +6 -4
- package/dist/federation/negotiation.test.js +2 -2
- package/dist/federation/retry.test.js +2 -2
- package/dist/federation/router.test.js +2 -2
- package/dist/federation/send.test.js +9 -9
- package/dist/{http-CaEsjA2G.js → http-C5NpY8dE.js} +2 -2
- package/dist/{http-Cs287TmP.js → http-Cw6Nfbii.js} +2 -2
- package/dist/{http-DUTeGoKz.cjs → http-zanXjqHu.cjs} +2 -2
- package/dist/{inbox-CWHlU-4p.js → inbox-Bu3THMpw.js} +1 -1
- package/dist/{key-DEdR04Ab.js → key-KT2Sua_C.js} +2 -2
- package/dist/{keycache-BviIhg2b.js → keycache-CH77mwdO.js} +1 -1
- package/dist/{keys-CHylGW0O.js → keys-DM8I6W_Z.js} +1 -1
- package/dist/{kv-cache-BZnZAYno.js → kv-cache-DspkH6f2.js} +1 -1
- package/dist/{kv-cache-CZGTfHxH.cjs → kv-cache-DxziE8JZ.cjs} +1 -1
- package/dist/{ld-CImM10Xd.js → ld-RF_UxhNp.js} +2 -2
- package/dist/{lookup-BQkOrVtQ.js → lookup-D029Hgmr.js} +187 -192
- package/dist/{lookup-CxaofAPS.js → lookup-EXeITSkB.js} +3 -8
- package/dist/{lookup-CmWpZY_M.cjs → lookup-ZMUieFn0.cjs} +3 -8
- package/dist/middleware-BuhoXDtM.js +15 -0
- package/dist/middleware-C2X56NUR.cjs +15 -0
- package/dist/{middleware-CZBCqMIK.js → middleware-C32-qFyf.js} +7 -7
- package/dist/{middleware-CHrx6VCp.js → middleware-CI-4cLU9.js} +11 -11
- package/dist/{middleware-DehGSDBK.cjs → middleware-CMT8W2oG.cjs} +7 -7
- package/dist/middleware-DWijkoj4.js +26 -0
- package/dist/{mod-DJcZDvjA.d.cts → mod-BoRKfJPE.d.cts} +1 -1
- package/dist/{mod-BoHnwOCs.d.ts → mod-Cdo6SYlJ.d.ts} +1 -1
- package/dist/mod.cjs +7 -7
- package/dist/mod.d.cts +5 -6
- package/dist/mod.d.ts +5 -6
- package/dist/mod.js +7 -7
- package/dist/nodeinfo/client.test.js +3 -3
- package/dist/nodeinfo/handler.test.js +14 -14
- package/dist/nodeinfo/mod.d.cts +1 -1
- package/dist/nodeinfo/mod.d.ts +1 -1
- package/dist/nodeinfo/types.test.js +2 -2
- package/dist/{owner-C5k5U7z5.js → owner-6JbsaBQB.js} +2 -2
- package/dist/{proof-QPC0OByc.cjs → proof-CB7YKfl6.cjs} +3 -3
- package/dist/{proof-0QlPOspl.js → proof-D8SPvADT.js} +3 -3
- package/dist/{proof-DGsrnIEU.js → proof-gHlNO1tx.js} +2 -2
- package/dist/{send-BXuinmF1.js → send-CmpkYTnR.js} +2 -2
- package/dist/sig/http.test.js +7 -7
- package/dist/sig/key.test.js +5 -5
- package/dist/sig/ld.test.js +6 -6
- package/dist/sig/mod.cjs +4 -4
- package/dist/sig/mod.d.cts +1 -1
- package/dist/sig/mod.d.ts +1 -1
- package/dist/sig/mod.js +4 -4
- package/dist/sig/owner.test.js +6 -6
- package/dist/sig/proof.test.js +6 -6
- package/dist/testing/docloader.test.js +2 -2
- package/dist/testing/mod.js +2 -2
- package/dist/{testing-D4BaH0xH.js → testing-BJ493d9l.js} +1 -1
- package/dist/utils/docloader.test.js +8 -8
- package/dist/utils/kv-cache.test.js +2 -2
- package/dist/utils/mod.cjs +4 -4
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +4 -4
- package/dist/vocab/actor.test.js +4 -4
- package/dist/vocab/lookup.test.js +3 -3
- package/dist/vocab/mod.cjs +3 -3
- package/dist/vocab/mod.js +3 -3
- package/dist/vocab/type.test.js +2 -2
- package/dist/vocab/vocab.test.js +3 -3
- package/dist/{vocab-Bh3jSO8n.js → vocab-BY_op-IW.js} +2 -2
- package/dist/{vocab-lZ1-2A_O.cjs → vocab-I0FskT0s.cjs} +2 -2
- package/dist/webfinger/handler.test.js +14 -14
- package/dist/webfinger/lookup.test.js +3 -3
- package/dist/webfinger/mod.cjs +1 -1
- package/dist/webfinger/mod.js +1 -1
- package/package.json +5 -36
- package/dist/denokv-CCssOzMJ.js +0 -57
- package/dist/middleware-BXYjRNT8.js +0 -15
- package/dist/middleware-BiG0cANp.cjs +0 -15
- package/dist/middleware-DTljmOoB.js +0 -26
- package/dist/mq-CUKlBw08.d.ts +0 -143
- package/dist/mq-DcJPkXD5.d.cts +0 -140
- package/dist/vocab/schema.yaml +0 -247
- package/dist/x/cfworkers.cjs +0 -100
- package/dist/x/cfworkers.d.cts +0 -59
- package/dist/x/cfworkers.d.ts +0 -61
- package/dist/x/cfworkers.js +0 -98
- package/dist/x/cfworkers.test.d.ts +0 -3
- package/dist/x/cfworkers.test.js +0 -177
- package/dist/x/hono.cjs +0 -61
- package/dist/x/hono.d.cts +0 -53
- package/dist/x/hono.d.ts +0 -55
- package/dist/x/hono.js +0 -60
- package/dist/x/sveltekit.cjs +0 -69
- package/dist/x/sveltekit.d.cts +0 -45
- package/dist/x/sveltekit.d.ts +0 -47
- package/dist/x/sveltekit.js +0 -68
- /package/dist/{mod-C2tOeRkN.d.cts → mod-CcDPcLJW.d.cts} +0 -0
- /package/dist/{mod-B2iOw50L.d.ts → mod-D5Z2tISD.d.ts} +0 -0
- /package/dist/{mod-0noXw66R.d.cts → mod-DMpuiKXi.d.cts} +0 -0
- /package/dist/{mod-DgdBYYa0.d.cts → mod-DgxG-byT.d.cts} +0 -0
- /package/dist/{mod-B9M-8jm2.d.ts → mod-aAE2wOWV.d.ts} +0 -0
- /package/dist/{mod-xIj-IT58.d.ts → mod-bjzj5QIb.d.ts} +0 -0
package/dist/x/cfworkers.d.cts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { KvKey, KvStore, KvStoreSetOptions } from "../kv-Bxr0Q87_.cjs";
|
|
2
|
-
import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "../mq-DcJPkXD5.cjs";
|
|
3
|
-
import { KVNamespace, Queue } from "@cloudflare/workers-types/experimental";
|
|
4
|
-
|
|
5
|
-
//#region src/x/cfworkers.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Implementation of the {@link KvStore} interface for Cloudflare Workers KV
|
|
9
|
-
* binding. This class provides a wrapper around Cloudflare's KV namespace to
|
|
10
|
-
* store and retrieve JSON-serializable values using structured keys.
|
|
11
|
-
*
|
|
12
|
-
* Note that this implementation does not support the {@link KvStore.cas}
|
|
13
|
-
* operation, as Cloudflare Workers KV does not support atomic compare-and-swap
|
|
14
|
-
* operations. If you need this functionality, consider using a different
|
|
15
|
-
* key–value store that supports atomic operations.
|
|
16
|
-
*
|
|
17
|
-
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
|
18
|
-
* Import `WorkersKvStore` from `@fedify/cfworkers` instead.
|
|
19
|
-
* This class will be removed in Fedify v2.0.
|
|
20
|
-
* @since 1.6.0
|
|
21
|
-
*/
|
|
22
|
-
declare class WorkersKvStore implements KvStore {
|
|
23
|
-
#private;
|
|
24
|
-
constructor(namespace: KVNamespace<string>);
|
|
25
|
-
get<T = unknown>(key: KvKey): Promise<T | undefined>;
|
|
26
|
-
set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
|
|
27
|
-
delete(key: KvKey): Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Implementation of the {@link MessageQueue} interface for Cloudflare
|
|
31
|
-
* Workers Queues binding. This class provides a wrapper around Cloudflare's
|
|
32
|
-
* Queues to send messages to a queue.
|
|
33
|
-
*
|
|
34
|
-
* Note that this implementation does not support the `listen()` method,
|
|
35
|
-
* as Cloudflare Workers Queues do not support message consumption in the same
|
|
36
|
-
* way as other message queue systems. Instead, you should use
|
|
37
|
-
* the {@link Federation.processQueuedTask} method to process messages
|
|
38
|
-
* passed to the queue.
|
|
39
|
-
*
|
|
40
|
-
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
|
41
|
-
* Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
|
|
42
|
-
* This class will be removed in Fedify v2.0.
|
|
43
|
-
* @since 1.6.0
|
|
44
|
-
*/
|
|
45
|
-
declare class WorkersMessageQueue implements MessageQueue {
|
|
46
|
-
#private;
|
|
47
|
-
/**
|
|
48
|
-
* Cloudflare Queues provide automatic retry with exponential backoff
|
|
49
|
-
* and Dead Letter Queues.
|
|
50
|
-
* @since 1.7.0
|
|
51
|
-
*/
|
|
52
|
-
readonly nativeRetrial = true;
|
|
53
|
-
constructor(queue: Queue);
|
|
54
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
55
|
-
enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
56
|
-
listen(_handler: (message: any) => Promise<void> | void, _options?: MessageQueueListenOptions): Promise<void>;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { WorkersKvStore, WorkersMessageQueue };
|
package/dist/x/cfworkers.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
-
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { KvKey, KvStore, KvStoreSetOptions } from "../kv-BKNZ-Tb-.js";
|
|
4
|
-
import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "../mq-CUKlBw08.js";
|
|
5
|
-
import { KVNamespace, Queue } from "@cloudflare/workers-types/experimental";
|
|
6
|
-
|
|
7
|
-
//#region src/x/cfworkers.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Implementation of the {@link KvStore} interface for Cloudflare Workers KV
|
|
11
|
-
* binding. This class provides a wrapper around Cloudflare's KV namespace to
|
|
12
|
-
* store and retrieve JSON-serializable values using structured keys.
|
|
13
|
-
*
|
|
14
|
-
* Note that this implementation does not support the {@link KvStore.cas}
|
|
15
|
-
* operation, as Cloudflare Workers KV does not support atomic compare-and-swap
|
|
16
|
-
* operations. If you need this functionality, consider using a different
|
|
17
|
-
* key–value store that supports atomic operations.
|
|
18
|
-
*
|
|
19
|
-
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
|
20
|
-
* Import `WorkersKvStore` from `@fedify/cfworkers` instead.
|
|
21
|
-
* This class will be removed in Fedify v2.0.
|
|
22
|
-
* @since 1.6.0
|
|
23
|
-
*/
|
|
24
|
-
declare class WorkersKvStore implements KvStore {
|
|
25
|
-
#private;
|
|
26
|
-
constructor(namespace: KVNamespace<string>);
|
|
27
|
-
get<T = unknown>(key: KvKey): Promise<T | undefined>;
|
|
28
|
-
set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
|
|
29
|
-
delete(key: KvKey): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Implementation of the {@link MessageQueue} interface for Cloudflare
|
|
33
|
-
* Workers Queues binding. This class provides a wrapper around Cloudflare's
|
|
34
|
-
* Queues to send messages to a queue.
|
|
35
|
-
*
|
|
36
|
-
* Note that this implementation does not support the `listen()` method,
|
|
37
|
-
* as Cloudflare Workers Queues do not support message consumption in the same
|
|
38
|
-
* way as other message queue systems. Instead, you should use
|
|
39
|
-
* the {@link Federation.processQueuedTask} method to process messages
|
|
40
|
-
* passed to the queue.
|
|
41
|
-
*
|
|
42
|
-
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
|
43
|
-
* Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
|
|
44
|
-
* This class will be removed in Fedify v2.0.
|
|
45
|
-
* @since 1.6.0
|
|
46
|
-
*/
|
|
47
|
-
declare class WorkersMessageQueue implements MessageQueue {
|
|
48
|
-
#private;
|
|
49
|
-
/**
|
|
50
|
-
* Cloudflare Queues provide automatic retry with exponential backoff
|
|
51
|
-
* and Dead Letter Queues.
|
|
52
|
-
* @since 1.7.0
|
|
53
|
-
*/
|
|
54
|
-
readonly nativeRetrial = true;
|
|
55
|
-
constructor(queue: Queue);
|
|
56
|
-
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
57
|
-
enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
58
|
-
listen(_handler: (message: any) => Promise<void> | void, _options?: MessageQueueListenOptions): Promise<void>;
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
export { WorkersKvStore, WorkersMessageQueue };
|
package/dist/x/cfworkers.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
-
|
|
5
|
-
import { getLogger } from "@logtape/logtape";
|
|
6
|
-
|
|
7
|
-
//#region src/x/cfworkers.ts
|
|
8
|
-
/**
|
|
9
|
-
* Implementation of the {@link KvStore} interface for Cloudflare Workers KV
|
|
10
|
-
* binding. This class provides a wrapper around Cloudflare's KV namespace to
|
|
11
|
-
* store and retrieve JSON-serializable values using structured keys.
|
|
12
|
-
*
|
|
13
|
-
* Note that this implementation does not support the {@link KvStore.cas}
|
|
14
|
-
* operation, as Cloudflare Workers KV does not support atomic compare-and-swap
|
|
15
|
-
* operations. If you need this functionality, consider using a different
|
|
16
|
-
* key–value store that supports atomic operations.
|
|
17
|
-
*
|
|
18
|
-
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
|
19
|
-
* Import `WorkersKvStore` from `@fedify/cfworkers` instead.
|
|
20
|
-
* This class will be removed in Fedify v2.0.
|
|
21
|
-
* @since 1.6.0
|
|
22
|
-
*/
|
|
23
|
-
var WorkersKvStore = class {
|
|
24
|
-
#namespace;
|
|
25
|
-
constructor(namespace) {
|
|
26
|
-
const logger = getLogger(["fedify", "cfworkers"]);
|
|
27
|
-
logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersKvStore` from `@fedify/cfworkers` package instead.");
|
|
28
|
-
this.#namespace = namespace;
|
|
29
|
-
}
|
|
30
|
-
#encodeKey(key) {
|
|
31
|
-
return JSON.stringify(key);
|
|
32
|
-
}
|
|
33
|
-
async get(key) {
|
|
34
|
-
const encodedKey = this.#encodeKey(key);
|
|
35
|
-
const { value, metadata } = await this.#namespace.getWithMetadata(encodedKey, "json");
|
|
36
|
-
return metadata == null || metadata.expires < Date.now() ? void 0 : value;
|
|
37
|
-
}
|
|
38
|
-
async set(key, value, options) {
|
|
39
|
-
const encodedKey = this.#encodeKey(key);
|
|
40
|
-
const metadata = options?.ttl == null ? {} : { expires: Date.now() + options.ttl.total("milliseconds") };
|
|
41
|
-
await this.#namespace.put(encodedKey, JSON.stringify(value), options?.ttl == null ? { metadata } : {
|
|
42
|
-
expirationTtl: Math.max(options.ttl.total("seconds"), 60),
|
|
43
|
-
metadata
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
delete(key) {
|
|
47
|
-
return this.#namespace.delete(this.#encodeKey(key));
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Implementation of the {@link MessageQueue} interface for Cloudflare
|
|
52
|
-
* Workers Queues binding. This class provides a wrapper around Cloudflare's
|
|
53
|
-
* Queues to send messages to a queue.
|
|
54
|
-
*
|
|
55
|
-
* Note that this implementation does not support the `listen()` method,
|
|
56
|
-
* as Cloudflare Workers Queues do not support message consumption in the same
|
|
57
|
-
* way as other message queue systems. Instead, you should use
|
|
58
|
-
* the {@link Federation.processQueuedTask} method to process messages
|
|
59
|
-
* passed to the queue.
|
|
60
|
-
*
|
|
61
|
-
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
|
62
|
-
* Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
|
|
63
|
-
* This class will be removed in Fedify v2.0.
|
|
64
|
-
* @since 1.6.0
|
|
65
|
-
*/
|
|
66
|
-
var WorkersMessageQueue = class {
|
|
67
|
-
#queue;
|
|
68
|
-
/**
|
|
69
|
-
* Cloudflare Queues provide automatic retry with exponential backoff
|
|
70
|
-
* and Dead Letter Queues.
|
|
71
|
-
* @since 1.7.0
|
|
72
|
-
*/
|
|
73
|
-
nativeRetrial = true;
|
|
74
|
-
constructor(queue) {
|
|
75
|
-
const logger = getLogger(["fedify", "cfworkers"]);
|
|
76
|
-
logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersMessageQueue` from `@fedify/cfworkers` package instead.");
|
|
77
|
-
this.#queue = queue;
|
|
78
|
-
}
|
|
79
|
-
enqueue(message, options) {
|
|
80
|
-
return this.#queue.send(message, {
|
|
81
|
-
contentType: "json",
|
|
82
|
-
delaySeconds: options?.delay?.total("seconds") ?? 0
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
enqueueMany(messages, options) {
|
|
86
|
-
const requests = messages.map((msg) => ({
|
|
87
|
-
body: msg,
|
|
88
|
-
contentType: "json"
|
|
89
|
-
}));
|
|
90
|
-
return this.#queue.sendBatch(requests, { delaySeconds: options?.delay?.total("seconds") ?? 0 });
|
|
91
|
-
}
|
|
92
|
-
listen(_handler, _options) {
|
|
93
|
-
throw new TypeError("WorkersMessageQueue does not support listen(). Use Federation.processQueuedTask() method instead.");
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
//#endregion
|
|
98
|
-
export { WorkersKvStore, WorkersMessageQueue };
|
package/dist/x/cfworkers.test.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
-
globalThis.addEventListener = () => {};
|
|
5
|
-
|
|
6
|
-
import "../lookup-BQkOrVtQ.js";
|
|
7
|
-
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
|
8
|
-
import "../assert-MZs1qjMx.js";
|
|
9
|
-
import "../assert_instance_of-DHz7EHNU.js";
|
|
10
|
-
import { test } from "../testing-D4BaH0xH.js";
|
|
11
|
-
import "../std__assert-DWivtrGR.js";
|
|
12
|
-
import "../assert_rejects-Ce45JcFg.js";
|
|
13
|
-
import "../assert_throws-BNXdRGWP.js";
|
|
14
|
-
import "../assert_not_equals-C80BG-_5.js";
|
|
15
|
-
import { delay } from "es-toolkit";
|
|
16
|
-
import { getLogger } from "@logtape/logtape";
|
|
17
|
-
|
|
18
|
-
//#region src/x/cfworkers.ts
|
|
19
|
-
/**
|
|
20
|
-
* Implementation of the {@link KvStore} interface for Cloudflare Workers KV
|
|
21
|
-
* binding. This class provides a wrapper around Cloudflare's KV namespace to
|
|
22
|
-
* store and retrieve JSON-serializable values using structured keys.
|
|
23
|
-
*
|
|
24
|
-
* Note that this implementation does not support the {@link KvStore.cas}
|
|
25
|
-
* operation, as Cloudflare Workers KV does not support atomic compare-and-swap
|
|
26
|
-
* operations. If you need this functionality, consider using a different
|
|
27
|
-
* key–value store that supports atomic operations.
|
|
28
|
-
*
|
|
29
|
-
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
|
30
|
-
* Import `WorkersKvStore` from `@fedify/cfworkers` instead.
|
|
31
|
-
* This class will be removed in Fedify v2.0.
|
|
32
|
-
* @since 1.6.0
|
|
33
|
-
*/
|
|
34
|
-
var WorkersKvStore = class {
|
|
35
|
-
#namespace;
|
|
36
|
-
constructor(namespace) {
|
|
37
|
-
const logger = getLogger(["fedify", "cfworkers"]);
|
|
38
|
-
logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersKvStore` from `@fedify/cfworkers` package instead.");
|
|
39
|
-
this.#namespace = namespace;
|
|
40
|
-
}
|
|
41
|
-
#encodeKey(key) {
|
|
42
|
-
return JSON.stringify(key);
|
|
43
|
-
}
|
|
44
|
-
async get(key) {
|
|
45
|
-
const encodedKey = this.#encodeKey(key);
|
|
46
|
-
const { value, metadata } = await this.#namespace.getWithMetadata(encodedKey, "json");
|
|
47
|
-
return metadata == null || metadata.expires < Date.now() ? void 0 : value;
|
|
48
|
-
}
|
|
49
|
-
async set(key, value, options) {
|
|
50
|
-
const encodedKey = this.#encodeKey(key);
|
|
51
|
-
const metadata = options?.ttl == null ? {} : { expires: Date.now() + options.ttl.total("milliseconds") };
|
|
52
|
-
await this.#namespace.put(encodedKey, JSON.stringify(value), options?.ttl == null ? { metadata } : {
|
|
53
|
-
expirationTtl: Math.max(options.ttl.total("seconds"), 60),
|
|
54
|
-
metadata
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
delete(key) {
|
|
58
|
-
return this.#namespace.delete(this.#encodeKey(key));
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Implementation of the {@link MessageQueue} interface for Cloudflare
|
|
63
|
-
* Workers Queues binding. This class provides a wrapper around Cloudflare's
|
|
64
|
-
* Queues to send messages to a queue.
|
|
65
|
-
*
|
|
66
|
-
* Note that this implementation does not support the `listen()` method,
|
|
67
|
-
* as Cloudflare Workers Queues do not support message consumption in the same
|
|
68
|
-
* way as other message queue systems. Instead, you should use
|
|
69
|
-
* the {@link Federation.processQueuedTask} method to process messages
|
|
70
|
-
* passed to the queue.
|
|
71
|
-
*
|
|
72
|
-
* @deprecated This class has been moved to `@fedify/cfworkers` package.
|
|
73
|
-
* Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
|
|
74
|
-
* This class will be removed in Fedify v2.0.
|
|
75
|
-
* @since 1.6.0
|
|
76
|
-
*/
|
|
77
|
-
var WorkersMessageQueue = class {
|
|
78
|
-
#queue;
|
|
79
|
-
/**
|
|
80
|
-
* Cloudflare Queues provide automatic retry with exponential backoff
|
|
81
|
-
* and Dead Letter Queues.
|
|
82
|
-
* @since 1.7.0
|
|
83
|
-
*/
|
|
84
|
-
nativeRetrial = true;
|
|
85
|
-
constructor(queue) {
|
|
86
|
-
const logger = getLogger(["fedify", "cfworkers"]);
|
|
87
|
-
logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersMessageQueue` from `@fedify/cfworkers` package instead.");
|
|
88
|
-
this.#queue = queue;
|
|
89
|
-
}
|
|
90
|
-
enqueue(message, options) {
|
|
91
|
-
return this.#queue.send(message, {
|
|
92
|
-
contentType: "json",
|
|
93
|
-
delaySeconds: options?.delay?.total("seconds") ?? 0
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
enqueueMany(messages, options) {
|
|
97
|
-
const requests = messages.map((msg) => ({
|
|
98
|
-
body: msg,
|
|
99
|
-
contentType: "json"
|
|
100
|
-
}));
|
|
101
|
-
return this.#queue.sendBatch(requests, { delaySeconds: options?.delay?.total("seconds") ?? 0 });
|
|
102
|
-
}
|
|
103
|
-
listen(_handler, _options) {
|
|
104
|
-
throw new TypeError("WorkersMessageQueue does not support listen(). Use Federation.processQueuedTask() method instead.");
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/x/cfworkers.test.ts
|
|
110
|
-
test({
|
|
111
|
-
name: "WorkersKvStore",
|
|
112
|
-
ignore: !("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers"),
|
|
113
|
-
async fn(t) {
|
|
114
|
-
const { env } = t;
|
|
115
|
-
const store = new WorkersKvStore(env.KV1);
|
|
116
|
-
await t.step("set() & get()", async () => {
|
|
117
|
-
await store.set(["foo", "bar"], {
|
|
118
|
-
foo: 1,
|
|
119
|
-
bar: 2
|
|
120
|
-
});
|
|
121
|
-
assertEquals(await store.get(["foo", "bar"]), {
|
|
122
|
-
foo: 1,
|
|
123
|
-
bar: 2
|
|
124
|
-
});
|
|
125
|
-
assertEquals(await store.get(["foo"]), void 0);
|
|
126
|
-
await store.set(["foo", "baz"], "baz", { ttl: Temporal.Duration.from({ seconds: 0 }) });
|
|
127
|
-
assertEquals(await store.get(["foo", "baz"]), void 0);
|
|
128
|
-
});
|
|
129
|
-
await t.step("delete()", async () => {
|
|
130
|
-
await store.delete(["foo", "bar"]);
|
|
131
|
-
assertEquals(await store.get(["foo", "bar"]), void 0);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
test({
|
|
136
|
-
name: "WorkersMessageQueue",
|
|
137
|
-
ignore: !("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers"),
|
|
138
|
-
async fn(t) {
|
|
139
|
-
const { env, messageBatches } = t;
|
|
140
|
-
const queue = new WorkersMessageQueue(env.Q1);
|
|
141
|
-
await queue.enqueue({
|
|
142
|
-
foo: 1,
|
|
143
|
-
bar: 2
|
|
144
|
-
});
|
|
145
|
-
await waitFor(() => messageBatches.length > 0, 5e3);
|
|
146
|
-
assertEquals(messageBatches.length, 1);
|
|
147
|
-
assertEquals(messageBatches[0].queue, "Q1");
|
|
148
|
-
assertEquals(messageBatches[0].messages.length, 1);
|
|
149
|
-
assertEquals(messageBatches[0].messages[0].body, {
|
|
150
|
-
foo: 1,
|
|
151
|
-
bar: 2
|
|
152
|
-
});
|
|
153
|
-
await queue.enqueue({
|
|
154
|
-
baz: 3,
|
|
155
|
-
qux: 4
|
|
156
|
-
}, { delay: Temporal.Duration.from({ seconds: 3 }) });
|
|
157
|
-
await delay(2e3);
|
|
158
|
-
assertEquals(messageBatches.length, 1);
|
|
159
|
-
await waitFor(() => messageBatches.length > 1, 6e3);
|
|
160
|
-
assertEquals(messageBatches[1].queue, "Q1");
|
|
161
|
-
assertEquals(messageBatches[1].messages.length, 1);
|
|
162
|
-
assertEquals(messageBatches[1].messages[0].body, {
|
|
163
|
-
baz: 3,
|
|
164
|
-
qux: 4
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
async function waitFor(predicate, timeoutMs) {
|
|
169
|
-
let delayed = 0;
|
|
170
|
-
while (!predicate()) {
|
|
171
|
-
await delay(500);
|
|
172
|
-
delayed += 500;
|
|
173
|
-
if (delayed > timeoutMs) throw new Error("Timeout");
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
//#endregion
|
package/dist/x/hono.cjs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { Temporal } = require("@js-temporal/polyfill");
|
|
3
|
-
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
|
-
|
|
5
|
-
const require_chunk = require('../chunk-DqRYRqnO.cjs');
|
|
6
|
-
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
|
7
|
-
|
|
8
|
-
//#region src/x/hono.ts
|
|
9
|
-
/**
|
|
10
|
-
* Create a Hono middleware to integrate with the {@link Federation} object.
|
|
11
|
-
*
|
|
12
|
-
* @deprecated This function has been moved to `@fedify/hono` package.
|
|
13
|
-
* Import `federation` from `@fedify/hono` instead.
|
|
14
|
-
* This function will be removed in Fedify v2.0.
|
|
15
|
-
*
|
|
16
|
-
* @template TContextData A type of the context data for the {@link Federation}
|
|
17
|
-
* object.
|
|
18
|
-
* @template THonoContext A type of the Hono context.
|
|
19
|
-
* @param federation A {@link Federation} object to integrate with Hono.
|
|
20
|
-
* @param contextDataFactory A function to create a context data for the
|
|
21
|
-
* {@link Federation} object.
|
|
22
|
-
* @returns A Hono middleware.
|
|
23
|
-
*/
|
|
24
|
-
function federation(federation$1, contextDataFactory) {
|
|
25
|
-
const logger = (0, __logtape_logtape.getLogger)([
|
|
26
|
-
"fedify",
|
|
27
|
-
"federation",
|
|
28
|
-
"hono"
|
|
29
|
-
]);
|
|
30
|
-
logger.warn("The `@fedify/fedify/x/hono` module is deprecated; use `federation` from `@fedify/hono` package instead.");
|
|
31
|
-
return async (ctx, next) => {
|
|
32
|
-
let contextData = contextDataFactory(ctx);
|
|
33
|
-
if (contextData instanceof Promise) contextData = await contextData;
|
|
34
|
-
return await federation$1.fetch(ctx.req.raw, {
|
|
35
|
-
contextData,
|
|
36
|
-
...integrateFetchOptions(ctx, next)
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function integrateFetchOptions(ctx, next) {
|
|
41
|
-
return {
|
|
42
|
-
async onNotFound(_req) {
|
|
43
|
-
await next();
|
|
44
|
-
return ctx.res;
|
|
45
|
-
},
|
|
46
|
-
async onNotAcceptable(_req) {
|
|
47
|
-
await next();
|
|
48
|
-
if (ctx.res.status !== 404) return ctx.res;
|
|
49
|
-
return new Response("Not acceptable", {
|
|
50
|
-
status: 406,
|
|
51
|
-
headers: {
|
|
52
|
-
"Content-Type": "text/plain",
|
|
53
|
-
Vary: "Accept"
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
exports.federation = federation;
|
package/dist/x/hono.d.cts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import "../client-94iWEfQa.cjs";
|
|
2
|
-
import "../vocab-CeDBzu-f.cjs";
|
|
3
|
-
import "../actor-f2NtjyCg.cjs";
|
|
4
|
-
import "../http-M8k5mKc0.cjs";
|
|
5
|
-
import "../owner-B4HbyP8s.cjs";
|
|
6
|
-
import "../mod-BxRCHTz-.cjs";
|
|
7
|
-
import "../mod-C58MZ7Wx.cjs";
|
|
8
|
-
import { Federation } from "../context-DJ8aSy2Q.cjs";
|
|
9
|
-
import "../kv-Bxr0Q87_.cjs";
|
|
10
|
-
import "../mq-DcJPkXD5.cjs";
|
|
11
|
-
|
|
12
|
-
//#region src/x/hono.d.ts
|
|
13
|
-
interface HonoRequest {
|
|
14
|
-
raw: Request;
|
|
15
|
-
}
|
|
16
|
-
interface HonoContext {
|
|
17
|
-
req: HonoRequest;
|
|
18
|
-
res: Response;
|
|
19
|
-
}
|
|
20
|
-
type HonoMiddleware<THonoContext extends HonoContext> = (ctx: THonoContext, next: () => Promise<void>) => Promise<Response | void>;
|
|
21
|
-
/**
|
|
22
|
-
* A factory function to create a context data for the {@link Federation}
|
|
23
|
-
* object.
|
|
24
|
-
*
|
|
25
|
-
* @deprecated This type has been moved to `@fedify/hono` package.
|
|
26
|
-
* Import `ContextDataFactory` from `@fedify/hono` instead.
|
|
27
|
-
* This type will be removed in Fedify v2.0.
|
|
28
|
-
*
|
|
29
|
-
* @template TContextData A type of the context data for the {@link Federation}
|
|
30
|
-
* object.
|
|
31
|
-
* @template THonoContext A type of the Hono context.
|
|
32
|
-
* @param context A Hono context object.
|
|
33
|
-
* @returns A context data for the {@link Federation} object.
|
|
34
|
-
*/
|
|
35
|
-
type ContextDataFactory<TContextData, THonoContext> = (context: THonoContext) => TContextData | Promise<TContextData>;
|
|
36
|
-
/**
|
|
37
|
-
* Create a Hono middleware to integrate with the {@link Federation} object.
|
|
38
|
-
*
|
|
39
|
-
* @deprecated This function has been moved to `@fedify/hono` package.
|
|
40
|
-
* Import `federation` from `@fedify/hono` instead.
|
|
41
|
-
* This function will be removed in Fedify v2.0.
|
|
42
|
-
*
|
|
43
|
-
* @template TContextData A type of the context data for the {@link Federation}
|
|
44
|
-
* object.
|
|
45
|
-
* @template THonoContext A type of the Hono context.
|
|
46
|
-
* @param federation A {@link Federation} object to integrate with Hono.
|
|
47
|
-
* @param contextDataFactory A function to create a context data for the
|
|
48
|
-
* {@link Federation} object.
|
|
49
|
-
* @returns A Hono middleware.
|
|
50
|
-
*/
|
|
51
|
-
declare function federation<TContextData, THonoContext extends HonoContext>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData, THonoContext>): HonoMiddleware<THonoContext>;
|
|
52
|
-
//#endregion
|
|
53
|
-
export { ContextDataFactory, federation };
|
package/dist/x/hono.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
-
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import "../client-BsGzbnV-.js";
|
|
4
|
-
import "../vocab-BCWe1Ih5.js";
|
|
5
|
-
import "../actor-DqFajh9s.js";
|
|
6
|
-
import "../http-BbO0ejuk.js";
|
|
7
|
-
import "../owner-kQRGVXG1.js";
|
|
8
|
-
import "../mod-BlVovdcy.js";
|
|
9
|
-
import "../mod-Ds0mpFZU.js";
|
|
10
|
-
import { Federation } from "../context-DG0huGW-.js";
|
|
11
|
-
import "../kv-BKNZ-Tb-.js";
|
|
12
|
-
import "../mq-CUKlBw08.js";
|
|
13
|
-
|
|
14
|
-
//#region src/x/hono.d.ts
|
|
15
|
-
interface HonoRequest {
|
|
16
|
-
raw: Request;
|
|
17
|
-
}
|
|
18
|
-
interface HonoContext {
|
|
19
|
-
req: HonoRequest;
|
|
20
|
-
res: Response;
|
|
21
|
-
}
|
|
22
|
-
type HonoMiddleware<THonoContext extends HonoContext> = (ctx: THonoContext, next: () => Promise<void>) => Promise<Response | void>;
|
|
23
|
-
/**
|
|
24
|
-
* A factory function to create a context data for the {@link Federation}
|
|
25
|
-
* object.
|
|
26
|
-
*
|
|
27
|
-
* @deprecated This type has been moved to `@fedify/hono` package.
|
|
28
|
-
* Import `ContextDataFactory` from `@fedify/hono` instead.
|
|
29
|
-
* This type will be removed in Fedify v2.0.
|
|
30
|
-
*
|
|
31
|
-
* @template TContextData A type of the context data for the {@link Federation}
|
|
32
|
-
* object.
|
|
33
|
-
* @template THonoContext A type of the Hono context.
|
|
34
|
-
* @param context A Hono context object.
|
|
35
|
-
* @returns A context data for the {@link Federation} object.
|
|
36
|
-
*/
|
|
37
|
-
type ContextDataFactory<TContextData, THonoContext> = (context: THonoContext) => TContextData | Promise<TContextData>;
|
|
38
|
-
/**
|
|
39
|
-
* Create a Hono middleware to integrate with the {@link Federation} object.
|
|
40
|
-
*
|
|
41
|
-
* @deprecated This function has been moved to `@fedify/hono` package.
|
|
42
|
-
* Import `federation` from `@fedify/hono` instead.
|
|
43
|
-
* This function will be removed in Fedify v2.0.
|
|
44
|
-
*
|
|
45
|
-
* @template TContextData A type of the context data for the {@link Federation}
|
|
46
|
-
* object.
|
|
47
|
-
* @template THonoContext A type of the Hono context.
|
|
48
|
-
* @param federation A {@link Federation} object to integrate with Hono.
|
|
49
|
-
* @param contextDataFactory A function to create a context data for the
|
|
50
|
-
* {@link Federation} object.
|
|
51
|
-
* @returns A Hono middleware.
|
|
52
|
-
*/
|
|
53
|
-
declare function federation<TContextData, THonoContext extends HonoContext>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData, THonoContext>): HonoMiddleware<THonoContext>;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { ContextDataFactory, federation };
|
package/dist/x/hono.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
-
|
|
5
|
-
import { getLogger } from "@logtape/logtape";
|
|
6
|
-
|
|
7
|
-
//#region src/x/hono.ts
|
|
8
|
-
/**
|
|
9
|
-
* Create a Hono middleware to integrate with the {@link Federation} object.
|
|
10
|
-
*
|
|
11
|
-
* @deprecated This function has been moved to `@fedify/hono` package.
|
|
12
|
-
* Import `federation` from `@fedify/hono` instead.
|
|
13
|
-
* This function will be removed in Fedify v2.0.
|
|
14
|
-
*
|
|
15
|
-
* @template TContextData A type of the context data for the {@link Federation}
|
|
16
|
-
* object.
|
|
17
|
-
* @template THonoContext A type of the Hono context.
|
|
18
|
-
* @param federation A {@link Federation} object to integrate with Hono.
|
|
19
|
-
* @param contextDataFactory A function to create a context data for the
|
|
20
|
-
* {@link Federation} object.
|
|
21
|
-
* @returns A Hono middleware.
|
|
22
|
-
*/
|
|
23
|
-
function federation(federation$1, contextDataFactory) {
|
|
24
|
-
const logger = getLogger([
|
|
25
|
-
"fedify",
|
|
26
|
-
"federation",
|
|
27
|
-
"hono"
|
|
28
|
-
]);
|
|
29
|
-
logger.warn("The `@fedify/fedify/x/hono` module is deprecated; use `federation` from `@fedify/hono` package instead.");
|
|
30
|
-
return async (ctx, next) => {
|
|
31
|
-
let contextData = contextDataFactory(ctx);
|
|
32
|
-
if (contextData instanceof Promise) contextData = await contextData;
|
|
33
|
-
return await federation$1.fetch(ctx.req.raw, {
|
|
34
|
-
contextData,
|
|
35
|
-
...integrateFetchOptions(ctx, next)
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function integrateFetchOptions(ctx, next) {
|
|
40
|
-
return {
|
|
41
|
-
async onNotFound(_req) {
|
|
42
|
-
await next();
|
|
43
|
-
return ctx.res;
|
|
44
|
-
},
|
|
45
|
-
async onNotAcceptable(_req) {
|
|
46
|
-
await next();
|
|
47
|
-
if (ctx.res.status !== 404) return ctx.res;
|
|
48
|
-
return new Response("Not acceptable", {
|
|
49
|
-
status: 406,
|
|
50
|
-
headers: {
|
|
51
|
-
"Content-Type": "text/plain",
|
|
52
|
-
Vary: "Accept"
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
export { federation };
|