@funcd-dev/shim 0.26.0 → 0.27.0

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.ts CHANGED
@@ -9,27 +9,31 @@ export interface PutOptions {
9
9
  * lease from before the call never counts past the key's expiry. Renew it with a compareAndSet and a new ttl. */
10
10
  ttl?: number;
11
11
  }
12
- /** A function's view of its namespace-scoped KV (ADR-0069): get/put/del a binding's key, or list keys.
13
- * putIfAbsent, compareAndSet and delIf write only while their condition holds and say who won: of racing writers
14
- * exactly one gets the new version, the others null (false for a delete). */
12
+ /** The key-value tables that a function binds, each by its alias in spec.bindings.kv. putIfAbsent, compareAndSet and
13
+ * delIf write only while their condition holds and say who won: of racing writers, exactly one gets the new version,
14
+ * and the others get null (false for delIf). */
15
15
  export interface KVClient {
16
+ /** The key's value as bytes, or null when the key does not exist. */
16
17
  get(binding: string, key: string): Promise<Uint8Array | null>;
17
- /** get() with the key's version (a missing key is null). */
18
+ /** The key's value with its version, or null when the key does not exist. */
18
19
  getEntry(binding: string, key: string): Promise<KVEntry | null>;
19
- /** get() decoded as UTF-8 text — the common case (a missing key is null). Saves the caller a
20
- * TextDecoder dance; put() already accepts a string. */
20
+ /** The key's value decoded as UTF-8 text, or null when the key does not exist. */
21
21
  getText(binding: string, key: string): Promise<string | null>;
22
- /** get() decoded as UTF-8 text then JSON-parsed (a missing key is null). The structured-value
23
- * counterpart of getText; write with put(binding, key, JSON.stringify(value)). */
22
+ /** The key's value parsed as JSON, or null when the key does not exist. Write it with
23
+ * put(binding, key, JSON.stringify(value)). */
24
24
  getJSON<T = unknown>(binding: string, key: string): Promise<T | null>;
25
+ /** Writes the value. opts.ttl, in whole seconds, sets the key's expiry; a put without it leaves the key with none.
26
+ * Only the table's owner can write. */
25
27
  put(binding: string, key: string, value: Uint8Array | string, opts?: PutOptions): Promise<void>;
26
- /** Create the key: its new version, or null when it exists (an expired key does not). */
28
+ /** Creates the key: its new version, or null when it exists (an expired key does not). */
27
29
  putIfAbsent(binding: string, key: string, value: Uint8Array | string, opts?: PutOptions): Promise<string | null>;
28
- /** Replace the key while it is at version: its new version, or null when it is not. */
30
+ /** Replaces the key while it is at version: its new version, or null when it is not. */
29
31
  compareAndSet(binding: string, key: string, value: Uint8Array | string, version: string, opts?: PutOptions): Promise<string | null>;
32
+ /** Deletes the key. */
30
33
  del(binding: string, key: string): Promise<void>;
31
- /** Delete the key while it is at version, as a lease holder releases what it holds. */
34
+ /** Deletes the key while it is at version, as a lease holder releases what it holds: true when it did. */
32
35
  delIf(binding: string, key: string, version: string): Promise<boolean>;
36
+ /** The keys that start with prefix; without a prefix, every key of the table. */
33
37
  list(binding: string, prefix?: string): Promise<string[]>;
34
38
  }
35
39
  /** Build the context.kv client. In a pool, `member` names the calling function on every request
package/dist/types.d.ts CHANGED
@@ -41,7 +41,7 @@ export interface FunctionContext {
41
41
  * its status and headers; funcd answers an error status, and calls nothing, for an undeclared link or a target
42
42
  * that does not serve HTTP (call it with invoke). */
43
43
  fetch(alias: string, path: string, init?: RequestInit): Promise<Response>;
44
- /** Namespace-scoped key-value storage (ADR-0069): get/put/del a binding's key, or list keys. */
44
+ /** The key-value tables that the function binds, by alias: read, write and list their keys. */
45
45
  kv: KVClient;
46
46
  /** Binding-scoped blob storage (ADR-0127): get/put/del/list a bound prefix's objects, or mint a
47
47
  * presigned URL — the blob twin of kv. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funcd-dev/shim",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "type": "module",
5
5
  "description": "Types and the contract build for writing funcd functions in TypeScript",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,8 @@
32
32
  "scripts": {
33
33
  "typecheck": "tsc --noEmit",
34
34
  "test": "node --test --experimental-strip-types test/*.test.ts",
35
- "build": "yarn build:shim && yarn build:pool && yarn build:lib",
35
+ "build": "yarn build:shim && yarn build:pool && yarn build:lib && yarn build:api",
36
+ "build:api": "node --experimental-strip-types scripts/api.ts",
36
37
  "build:shim": "esbuild src/shim.ts --bundle --platform=node --format=esm --target=node22 --outfile=shim.mjs --banner:js=\"// GENERATED from shim/src/shim.ts by 'yarn build' (esbuild). Do not edit by hand.\"",
37
38
  "build:pool": "esbuild src/pool.ts --bundle --platform=node --format=esm --target=node22 --outfile=pool.mjs --banner:js=\"// GENERATED from shim/src/pool.ts by 'yarn build' (esbuild). Do not edit by hand.\"",
38
39
  "build:lib": "tsc -p tsconfig.lib.json"