@opendatalabs/vana-sdk 3.18.1 → 3.19.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.
Files changed (37) hide show
  1. package/README.md +141 -0
  2. package/dist/auth/web3-signed-builder.cjs +3 -0
  3. package/dist/auth/web3-signed-builder.cjs.map +1 -1
  4. package/dist/auth/web3-signed-builder.d.ts +14 -0
  5. package/dist/auth/web3-signed-builder.js +3 -0
  6. package/dist/auth/web3-signed-builder.js.map +1 -1
  7. package/dist/errors.cjs +69 -0
  8. package/dist/errors.cjs.map +1 -1
  9. package/dist/errors.d.ts +117 -2
  10. package/dist/errors.js +60 -0
  11. package/dist/errors.js.map +1 -1
  12. package/dist/index.browser.d.ts +1 -0
  13. package/dist/index.browser.js +577 -29
  14. package/dist/index.browser.js.map +4 -4
  15. package/dist/index.node.cjs +605 -29
  16. package/dist/index.node.cjs.map +4 -4
  17. package/dist/index.node.d.ts +1 -0
  18. package/dist/index.node.js +577 -29
  19. package/dist/index.node.js.map +4 -4
  20. package/dist/protocol/derivative-questions.cjs +518 -0
  21. package/dist/protocol/derivative-questions.cjs.map +1 -0
  22. package/dist/protocol/derivative-questions.d.ts +396 -0
  23. package/dist/protocol/derivative-questions.js +507 -0
  24. package/dist/protocol/derivative-questions.js.map +1 -0
  25. package/dist/protocol/derivative-questions.test.d.ts +1 -0
  26. package/dist/protocol/personal-server-write.cjs +12 -108
  27. package/dist/protocol/personal-server-write.cjs.map +1 -1
  28. package/dist/protocol/personal-server-write.d.ts +2 -17
  29. package/dist/protocol/personal-server-write.js +7 -98
  30. package/dist/protocol/personal-server-write.js.map +1 -1
  31. package/dist/protocol/write-request.cjs +156 -0
  32. package/dist/protocol/write-request.cjs.map +1 -0
  33. package/dist/protocol/write-request.d.ts +75 -0
  34. package/dist/protocol/write-request.js +124 -0
  35. package/dist/protocol/write-request.js.map +1 -0
  36. package/dist/tests/mock-personal-server.d.ts +54 -0
  37. package/package.json +1 -1
@@ -14,6 +14,16 @@
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 whole
19
+ * request TARGET, query string INCLUDED and compared in canonical form),
20
+ * the optional `nonce` claim as the replay key when present, authorized
21
+ * against `write:<derivedScope>`, compact JSON bodies, the consent rule
22
+ * (every source scope read-granted to the builder), the cycle guard, the
23
+ * 404 for a question this builder did not register AND for an unknown id
24
+ * presented with a live write session, and the 400
25
+ * `DERIVATIVE_DERIVED_SCOPE_REQUIRED` for a builder list with no
26
+ * `?derivedScope=`
17
27
  * - lineage reads on both the Personal Server and the gateway: Web3Signed
18
28
  * over the bare path (`/lineage[/:version]`, the version is a path
19
29
  * segment, any query is 400), grant view from the signed `grantId` claim
@@ -55,6 +65,30 @@ export interface MockPersonalServerOptions {
55
65
  status?: "stored" | "syncing";
56
66
  sessionTtlSeconds?: number;
57
67
  now?: () => number;
68
+ /** Answer every `/v1/derivatives` route 503, as a server with no compute. */
69
+ computeUnavailable?: boolean;
70
+ }
71
+ /** A question registration the mock server holds. */
72
+ export interface MockQuestion {
73
+ questionId: string;
74
+ derivedScope: string;
75
+ sourceScopes: string[];
76
+ question: string;
77
+ model: string | null;
78
+ registeredBy: {
79
+ kind: "owner";
80
+ } | {
81
+ kind: "builder";
82
+ builder: Address;
83
+ grantId: string;
84
+ };
85
+ status: "pending" | "ready" | "failed" | "stale";
86
+ error: string | null;
87
+ createdAt: string;
88
+ updatedAt: string;
89
+ lastComputedAt: string | null;
90
+ derivedVersion: number | null;
91
+ derivedCollectedAt: string | null;
58
92
  }
59
93
  export interface MockRequestLog {
60
94
  method: string;
@@ -75,6 +109,26 @@ export interface MockPersonalServer {
75
109
  respondNextWith(status: number, body: unknown): void;
76
110
  /** Sessions minted (token -> record). */
77
111
  sessions: Map<string, MockSession>;
112
+ /** Question registrations (id -> row), in registration order. */
113
+ questions: Map<string, MockQuestion>;
114
+ /**
115
+ * Forget every minted session, the way a restarted Personal Server does:
116
+ * the next call with an old bearer answers 401.
117
+ */
118
+ dropSessions(): void;
119
+ /**
120
+ * Settle a question the way a compute would: set its status and, for a
121
+ * `ready` one, store the derived record the builder then reads.
122
+ */
123
+ settleQuestion(questionId: string, outcome: {
124
+ status: "ready";
125
+ data?: Record<string, unknown>;
126
+ } | {
127
+ status: "failed";
128
+ error: string;
129
+ } | {
130
+ status: "stale" | "pending";
131
+ }): void;
78
132
  }
79
133
  export interface MockSession {
80
134
  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.1",
4
4
  "description": "A TypeScript library for interacting with Vana Network smart contracts.",
5
5
  "publishConfig": {
6
6
  "access": "public"