@usearete/sdk 0.2.0 → 0.3.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 +60 -0
- package/dist/{index.js → index.cjs} +2725 -509
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +597 -118
- package/dist/index.esm.js +2666 -472
- package/dist/index.esm.js.map +1 -1
- package/dist/ssr/handlers.cjs +794 -0
- package/dist/ssr/handlers.cjs.map +1 -0
- package/dist/ssr/handlers.esm.js +523 -4
- package/dist/ssr/handlers.esm.js.map +1 -1
- package/dist/ssr/index.cjs +795 -0
- package/dist/ssr/index.cjs.map +1 -0
- package/dist/ssr/index.esm.js +523 -4
- package/dist/ssr/index.esm.js.map +1 -1
- package/dist/ssr/nextjs-app.cjs +859 -0
- package/dist/ssr/nextjs-app.cjs.map +1 -0
- package/dist/ssr/nextjs-app.esm.js +523 -4
- package/dist/ssr/nextjs-app.esm.js.map +1 -1
- package/dist/ssr/tanstack-start.cjs +881 -0
- package/dist/ssr/tanstack-start.cjs.map +1 -0
- package/dist/ssr/tanstack-start.esm.js +523 -4
- package/dist/ssr/tanstack-start.esm.js.map +1 -1
- package/dist/ssr/vite.cjs +887 -0
- package/dist/ssr/vite.cjs.map +1 -0
- package/dist/ssr/vite.esm.js +523 -4
- package/dist/ssr/vite.esm.js.map +1 -1
- package/package.json +10 -8
- package/dist/index.js.map +0 -1
- package/dist/ssr/handlers.js +0 -294
- package/dist/ssr/handlers.js.map +0 -1
- package/dist/ssr/index.js +0 -295
- package/dist/ssr/index.js.map +0 -1
- package/dist/ssr/nextjs-app.js +0 -359
- package/dist/ssr/nextjs-app.js.map +0 -1
- package/dist/ssr/tanstack-start.js +0 -381
- package/dist/ssr/tanstack-start.js.map +0 -1
- package/dist/ssr/vite.js +0 -387
- package/dist/ssr/vite.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Pure TypeScript SDK for generated stack definitions, program SDKs, prepared operation execution, and chain reads.
|
|
4
4
|
|
|
5
|
+
Connected clients expose the typed six-route transaction relay as `client.transactions`. Wallet adapters receive it per invocation from `client.transaction` and `client.inspectOperation`, so a shared wallet can safely serve multiple clients. Sessions expose `session.transactions` and accept a `transactions` override. HTTP `u64` fields are decimal strings on the wire and `bigint` in the SDK; sends are never automatically retried.
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -307,20 +309,78 @@ for await (const update of session.stacks.myStack.views.settlementGame.list.watc
|
|
|
307
309
|
const game = await session.stacks.myStack.views.settlementGame.state.get('game-123');
|
|
308
310
|
```
|
|
309
311
|
|
|
312
|
+
Every options object is a protocol v2 query with independent ordered membership. Different windows and filters on the same view can run concurrently, while equivalent normalized queries share one reference-counted wire subscription:
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
const rounds = session.stacks.ore.views.OreRound.latest;
|
|
316
|
+
|
|
317
|
+
const firstPage = rounds.watch({ take: 10 });
|
|
318
|
+
const secondPage = rounds.watch({ take: 10, skip: 10 });
|
|
319
|
+
|
|
320
|
+
for await (const update of firstPage) {
|
|
321
|
+
if (update.type === 'remove') {
|
|
322
|
+
console.log(`${update.key} left the first-page window`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Completed authoritative snapshots replace membership for their exact query after reconnect. Cursor queries created with `after` receive incremental snapshots and merge without pruning.
|
|
328
|
+
|
|
329
|
+
Low-level `QueryLease.refresh()` returns a `Promise<void>` that resolves after the refreshed subscription's next complete snapshot is committed. Registration, send, and subscription failures reject and are published on the lease's `QuerySnapshot.error`, with `isRefreshing` cleared. Subscriptions created with snapshots disabled resolve after the refresh request is sent.
|
|
330
|
+
|
|
331
|
+
### Connection recovery
|
|
332
|
+
|
|
333
|
+
`autoConnect` and `autoReconnect` default to `true` and control separate lifecycle phases. Set `autoConnect: false` to create a disconnected client that the application connects later. Set `autoReconnect: false` when the application wants to handle post-disconnect recovery itself:
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
const client = await Arete.connect(MY_STACK, {
|
|
337
|
+
autoConnect: false,
|
|
338
|
+
autoReconnect: false,
|
|
339
|
+
});
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
The same independent options are available per stack member in `createSession(...)` and on React's `AreteProvider`.
|
|
343
|
+
|
|
344
|
+
### Caller-supplied schema diagnostics
|
|
345
|
+
|
|
346
|
+
Core view schemas continue to filter rejected entities. React view hooks additionally accept `onSchemaValidationError`, which reports `{ view, key?, entity, error }` without changing accepted data.
|
|
347
|
+
|
|
348
|
+
## Safe amount parsing
|
|
349
|
+
|
|
350
|
+
`toRawAmount(input, decimals)` throws when user input is invalid. Form and API boundaries can use `safeToRawAmount(input, decimals)` instead:
|
|
351
|
+
|
|
352
|
+
```ts
|
|
353
|
+
import { safeToRawAmount } from '@usearete/sdk';
|
|
354
|
+
|
|
355
|
+
const result = safeToRawAmount({ ui: amountText }, 9);
|
|
356
|
+
if (!result.success) {
|
|
357
|
+
console.error(result.error);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
console.log(result.data); // bigint in raw base units
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
It returns `{ success: true, data } | { success: false, error }` and never throws for an invalid amount input.
|
|
365
|
+
|
|
310
366
|
## Update Types
|
|
311
367
|
|
|
312
368
|
```ts
|
|
313
369
|
type Update<T> =
|
|
314
370
|
| { type: 'upsert'; key: string; data: T }
|
|
315
371
|
| { type: 'patch'; key: string; data: Partial<T> }
|
|
372
|
+
| { type: 'remove'; key: string }
|
|
316
373
|
| { type: 'delete'; key: string };
|
|
317
374
|
|
|
318
375
|
type RichUpdate<T> =
|
|
319
376
|
| { type: 'created'; key: string; data: T }
|
|
320
377
|
| { type: 'updated'; key: string; before: T; after: T; patch?: unknown }
|
|
378
|
+
| { type: 'removed'; key: string; lastKnown?: T }
|
|
321
379
|
| { type: 'deleted'; key: string; lastKnown?: T };
|
|
322
380
|
```
|
|
323
381
|
|
|
382
|
+
`remove` means an entity left only this query's filter or window. `delete` means the source entity was deleted and is removed from every query for that view.
|
|
383
|
+
|
|
324
384
|
## License
|
|
325
385
|
|
|
326
386
|
MIT
|