@fedify/fedify 1.6.1-pr.239.855 → 1.6.1-pr.242.858

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.
@@ -0,0 +1,28 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+ import { KvKey, KvStore, KvStoreSetOptions } from "../federation/kv.js";
4
+ import { KVNamespace } from "@cloudflare/workers-types/experimental";
5
+
6
+ //#region x/cfworkers.d.ts
7
+ /**
8
+ * Implementation of the KvStore interface for Cloudflare Workers KV binding.
9
+ * This class provides a wrapper around Cloudflare's KV namespace to store and
10
+ * retrieve JSON-serializable values using structured keys.
11
+ * @since 1.6.0
12
+ */
13
+ /**
14
+ * Implementation of the KvStore interface for Cloudflare Workers KV binding.
15
+ * This class provides a wrapper around Cloudflare's KV namespace to store and
16
+ * retrieve JSON-serializable values using structured keys.
17
+ * @since 1.6.0
18
+ */
19
+ declare class WorkersKvStore implements KvStore {
20
+ #private;
21
+ constructor(namespace: KVNamespace<string>);
22
+ get<T = unknown>(key: KvKey): Promise<T | undefined>;
23
+ set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
24
+ delete(key: KvKey): Promise<void>;
25
+ }
26
+
27
+ //#endregion
28
+ export { WorkersKvStore };
@@ -0,0 +1,35 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ //#region x/cfworkers.ts
6
+ /**
7
+ * Implementation of the KvStore interface for Cloudflare Workers KV binding.
8
+ * This class provides a wrapper around Cloudflare's KV namespace to store and
9
+ * retrieve JSON-serializable values using structured keys.
10
+ * @since 1.6.0
11
+ */
12
+ var WorkersKvStore = class {
13
+ #namespace;
14
+ constructor(namespace) {
15
+ this.#namespace = namespace;
16
+ }
17
+ #encodeKey(key) {
18
+ return JSON.stringify(key);
19
+ }
20
+ async get(key) {
21
+ const encodedKey = this.#encodeKey(key);
22
+ const value = await this.#namespace.get(encodedKey);
23
+ return value == null ? void 0 : JSON.parse(value);
24
+ }
25
+ async set(key, value, options) {
26
+ const encodedKey = this.#encodeKey(key);
27
+ await this.#namespace.put(encodedKey, JSON.stringify(value), options?.ttl == null ? {} : { expirationTtl: Math.max(options.ttl.total("seconds"), 60) });
28
+ }
29
+ delete(key) {
30
+ return this.#namespace.delete(this.#encodeKey(key));
31
+ }
32
+ };
33
+
34
+ //#endregion
35
+ export { WorkersKvStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "1.6.1-pr.239.855+05827ff9",
3
+ "version": "1.6.1-pr.242.858+ae33fee0",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -68,6 +68,10 @@
68
68
  "types": "./dist/webfinger/mod.d.ts",
69
69
  "import": "./dist/webfinger/mod.js"
70
70
  },
71
+ "./x/cfworkers": {
72
+ "types": "./dist/x/cfworkers.d.ts",
73
+ "import": "./dist/x/cfworkers.js"
74
+ },
71
75
  "./x/hono": {
72
76
  "types": "./dist/x/hono.d.ts",
73
77
  "import": "./dist/x/hono.js"
@@ -99,6 +103,7 @@
99
103
  "urlpattern-polyfill": "^10.1.0"
100
104
  },
101
105
  "devDependencies": {
106
+ "@cloudflare/workers-types": "^4.20250529.0",
102
107
  "@hongminhee/deno-mock-fetch": "npm:@jsr/hongminhee__deno-mock-fetch@^0.3.2",
103
108
  "@std/assert": "npm:@jsr/std__assert@^0.226.0",
104
109
  "@std/path": "npm:@jsr/std__path@^1.0.9",