@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.
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendatalabs/vana-sdk",
3
- "version": "3.18.1",
3
+ "version": "3.19.0",
4
4
  "description": "A TypeScript library for interacting with Vana Network smart contracts.",
5
5
  "publishConfig": {
6
6
  "access": "public"