@junejs/server 0.1.0 → 0.1.1
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/agent-durable.d.ts +4 -3
- package/package.json +1 -1
- package/src/agent-durable.ts +13 -2
package/dist/agent-durable.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { Channel, ChannelFactory } from "@junejs/core/agent-config";
|
|
|
2
2
|
import { Model, Msg, SessionStore, Tool } from "@junejs/core/agent-runtime";
|
|
3
3
|
import { Resources } from "@junejs/core/resources";
|
|
4
4
|
//#region src/agent-durable.d.ts
|
|
5
|
-
|
|
5
|
+
type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
6
|
+
interface SqlStorageCursor<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>> {
|
|
6
7
|
toArray(): T[];
|
|
7
8
|
one(): T;
|
|
8
9
|
}
|
|
9
10
|
interface SqlStorage {
|
|
10
|
-
exec<T = Record<string,
|
|
11
|
+
exec<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>>(query: string, ...bindings: unknown[]): SqlStorageCursor<T>;
|
|
11
12
|
}
|
|
12
13
|
interface DurableStorage {
|
|
13
14
|
sql: SqlStorage;
|
|
@@ -69,4 +70,4 @@ declare function durableChannelSurface(getNamespace: () => DurableObjectNamespac
|
|
|
69
70
|
waitUntil?: (p: Promise<unknown>) => void;
|
|
70
71
|
}): (req: Request) => Promise<Response | null>;
|
|
71
72
|
//#endregion
|
|
72
|
-
export { AgentDurableObject, DoAgentDef, DoSessionStore, DurableObjectNamespace, DurableObjectState, DurableObjectStub, DurableStorage, SqlStorage, SqlStorageCursor, durableAgentSurface, durableChannelSurface, durableFetch };
|
|
73
|
+
export { AgentDurableObject, DoAgentDef, DoSessionStore, DurableObjectNamespace, DurableObjectState, DurableObjectStub, DurableStorage, SqlStorage, SqlStorageCursor, SqlStorageValue, durableAgentSurface, durableChannelSurface, durableFetch };
|
package/package.json
CHANGED
package/src/agent-durable.ts
CHANGED
|
@@ -37,12 +37,23 @@ import {
|
|
|
37
37
|
import { ensureScope, runInScope } from "@junejs/db";
|
|
38
38
|
|
|
39
39
|
// ── minimal structural Cloudflare surface (no @cloudflare/workers-types dep) ──
|
|
40
|
-
|
|
40
|
+
// SqlStorage row values are exactly what workerd's SQLite returns. Mirroring
|
|
41
|
+
// @cloudflare/workers-types' `T extends Record<string, SqlStorageValue>` constraint
|
|
42
|
+
// STRUCTURALLY (not importing it) makes `this.ctx.storage` directly assignable to
|
|
43
|
+
// these interfaces, so a DO shell needs no `as unknown as JuneDoState` cast. The
|
|
44
|
+
// constraint (not just a default) is what lets the two `exec` signatures unify:
|
|
45
|
+
// an unconstrained `T` promises `toArray(): T[]` for arbitrary T, which workerd's
|
|
46
|
+
// cursor — only ever `Record<string, SqlStorageValue>` rows — cannot satisfy.
|
|
47
|
+
export type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
48
|
+
export interface SqlStorageCursor<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>> {
|
|
41
49
|
toArray(): T[];
|
|
42
50
|
one(): T;
|
|
43
51
|
}
|
|
44
52
|
export interface SqlStorage {
|
|
45
|
-
exec<T
|
|
53
|
+
exec<T extends Record<string, SqlStorageValue> = Record<string, SqlStorageValue>>(
|
|
54
|
+
query: string,
|
|
55
|
+
...bindings: unknown[]
|
|
56
|
+
): SqlStorageCursor<T>;
|
|
46
57
|
}
|
|
47
58
|
export interface DurableStorage {
|
|
48
59
|
sql: SqlStorage;
|