@opendatalabs/vana-sdk 3.18.1 → 3.19.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/README.md +123 -0
- package/dist/errors.cjs +56 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +98 -2
- package/dist/errors.js +48 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +533 -29
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +560 -29
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +1 -0
- package/dist/index.node.js +533 -29
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/derivative-questions.cjs +501 -0
- package/dist/protocol/derivative-questions.cjs.map +1 -0
- package/dist/protocol/derivative-questions.d.ts +355 -0
- package/dist/protocol/derivative-questions.js +486 -0
- package/dist/protocol/derivative-questions.js.map +1 -0
- package/dist/protocol/derivative-questions.test.d.ts +1 -0
- package/dist/protocol/personal-server-write.cjs +12 -108
- package/dist/protocol/personal-server-write.cjs.map +1 -1
- package/dist/protocol/personal-server-write.d.ts +2 -17
- package/dist/protocol/personal-server-write.js +7 -98
- package/dist/protocol/personal-server-write.js.map +1 -1
- package/dist/protocol/write-request.cjs +142 -0
- package/dist/protocol/write-request.cjs.map +1 -0
- package/dist/protocol/write-request.d.ts +63 -0
- package/dist/protocol/write-request.js +111 -0
- package/dist/protocol/write-request.js.map +1 -0
- package/dist/tests/mock-personal-server.d.ts +51 -0
- package/package.json +1 -1
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* proof single-use; `lineage` is the body's top-level field (JSON) or
|
|
15
15
|
* the metadata object's field (binary), validated per
|
|
16
16
|
* docs/derivative-data-api.md and mirrored to `$lineage`
|
|
17
|
+
* - derivative questions (`/v1/derivatives/questions`): the same builder
|
|
18
|
+
* credential as a write (bearer + X-Vana-Write-Signature over the
|
|
19
|
+
* request PATH, query string excluded, as the server verifies it),
|
|
20
|
+
* authorized against `write:<derivedScope>`, compact JSON bodies, the
|
|
21
|
+
* consent rule (every source scope read-granted to the builder), the
|
|
22
|
+
* cycle guard, and the 404 a builder gets for a question it did not
|
|
23
|
+
* register
|
|
17
24
|
* - lineage reads on both the Personal Server and the gateway: Web3Signed
|
|
18
25
|
* over the bare path (`/lineage[/:version]`, the version is a path
|
|
19
26
|
* segment, any query is 400), grant view from the signed `grantId` claim
|
|
@@ -55,6 +62,30 @@ export interface MockPersonalServerOptions {
|
|
|
55
62
|
status?: "stored" | "syncing";
|
|
56
63
|
sessionTtlSeconds?: number;
|
|
57
64
|
now?: () => number;
|
|
65
|
+
/** Answer every `/v1/derivatives` route 503, as a server with no compute. */
|
|
66
|
+
computeUnavailable?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** A question registration the mock server holds. */
|
|
69
|
+
export interface MockQuestion {
|
|
70
|
+
questionId: string;
|
|
71
|
+
derivedScope: string;
|
|
72
|
+
sourceScopes: string[];
|
|
73
|
+
question: string;
|
|
74
|
+
model: string | null;
|
|
75
|
+
registeredBy: {
|
|
76
|
+
kind: "owner";
|
|
77
|
+
} | {
|
|
78
|
+
kind: "builder";
|
|
79
|
+
builder: Address;
|
|
80
|
+
grantId: string;
|
|
81
|
+
};
|
|
82
|
+
status: "pending" | "ready" | "failed" | "stale";
|
|
83
|
+
error: string | null;
|
|
84
|
+
createdAt: string;
|
|
85
|
+
updatedAt: string;
|
|
86
|
+
lastComputedAt: string | null;
|
|
87
|
+
derivedVersion: number | null;
|
|
88
|
+
derivedCollectedAt: string | null;
|
|
58
89
|
}
|
|
59
90
|
export interface MockRequestLog {
|
|
60
91
|
method: string;
|
|
@@ -75,6 +106,26 @@ export interface MockPersonalServer {
|
|
|
75
106
|
respondNextWith(status: number, body: unknown): void;
|
|
76
107
|
/** Sessions minted (token -> record). */
|
|
77
108
|
sessions: Map<string, MockSession>;
|
|
109
|
+
/** Question registrations (id -> row), in registration order. */
|
|
110
|
+
questions: Map<string, MockQuestion>;
|
|
111
|
+
/**
|
|
112
|
+
* Forget every minted session, the way a restarted Personal Server does:
|
|
113
|
+
* the next call with an old bearer answers 401.
|
|
114
|
+
*/
|
|
115
|
+
dropSessions(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Settle a question the way a compute would: set its status and, for a
|
|
118
|
+
* `ready` one, store the derived record the builder then reads.
|
|
119
|
+
*/
|
|
120
|
+
settleQuestion(questionId: string, outcome: {
|
|
121
|
+
status: "ready";
|
|
122
|
+
data?: Record<string, unknown>;
|
|
123
|
+
} | {
|
|
124
|
+
status: "failed";
|
|
125
|
+
error: string;
|
|
126
|
+
} | {
|
|
127
|
+
status: "stale" | "pending";
|
|
128
|
+
}): void;
|
|
78
129
|
}
|
|
79
130
|
export interface MockSession {
|
|
80
131
|
token: string;
|