@usearete/sdk 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arete
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # Arete TypeScript SDK
2
+
3
+ Pure TypeScript SDK for the Arete Solana streaming platform. Framework-agnostic core with AsyncIterable-based streaming.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @usearete/sdk
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Setup
14
+
15
+ ```typescript
16
+ import { Arete } from '@usearete/sdk';
17
+ import { SETTLEMENT_GAME_STACK } from './generated/settlement-game-stack';
18
+
19
+ const a4 = await Arete.connect('wss://mainnet.arete.xyz', {
20
+ stack: SETTLEMENT_GAME_STACK,
21
+ });
22
+ ```
23
+
24
+ ### Streaming with AsyncIterable
25
+
26
+ ```typescript
27
+ for await (const update of a4.views.settlementGame.list.watch()) {
28
+ if (update.type === 'upsert') {
29
+ console.log('Game updated:', update.key, update.data);
30
+ } else if (update.type === 'delete') {
31
+ console.log('Game deleted:', update.key);
32
+ }
33
+ }
34
+
35
+ for await (const update of a4.views.settlementGame.state.watch('game-123')) {
36
+ console.log('Game 123 updated:', update.data);
37
+ }
38
+
39
+ for await (const update of a4.views.settlementGame.list.watchRich()) {
40
+ if (update.type === 'updated') {
41
+ console.log('Changed from:', update.before);
42
+ console.log('Changed to:', update.after);
43
+ }
44
+ }
45
+ ```
46
+
47
+ ### One-Shot Queries
48
+
49
+ ```typescript
50
+ const games = await a4.views.settlementGame.list.get();
51
+
52
+ const game = await a4.views.settlementGame.state.get('game-123');
53
+ ```
54
+
55
+ ### Connection Management
56
+
57
+ ```typescript
58
+ console.log(a4.connectionState);
59
+
60
+ const unsubscribe = a4.onConnectionStateChange((state) => {
61
+ console.log('Connection state:', state);
62
+ });
63
+
64
+ await a4.disconnect();
65
+ ```
66
+
67
+ ## API
68
+
69
+ ### Arete
70
+
71
+ Main client class with typed view accessors.
72
+
73
+ - `Arete.connect(url, options)` - Connect to a Arete server
74
+ - `views` - Typed view accessors based on your stack definition
75
+ - `connectionState` - Current connection state
76
+ - `onConnectionStateChange(callback)` - Listen for connection changes
77
+ - `disconnect()` - Disconnect from the server
78
+
79
+ ### Views
80
+
81
+ Each view provides:
82
+
83
+ **StateView (keyed entities)**
84
+ - `watch(key)` - AsyncIterable of updates for a specific key
85
+ - `watchRich(key)` - AsyncIterable with before/after diffs
86
+ - `get(key)` - Get entity by key
87
+ - `getSync(key)` - Get entity synchronously (if available)
88
+
89
+ **ListView (collections)**
90
+ - `watch()` - AsyncIterable of all updates
91
+ - `watchRich()` - AsyncIterable with before/after diffs
92
+ - `get()` - Get all entities
93
+ - `getSync()` - Get all entities synchronously (if available)
94
+
95
+ ### Update Types
96
+
97
+ ```typescript
98
+ type Update<T> =
99
+ | { type: 'upsert'; key: string; data: T }
100
+ | { type: 'patch'; key: string; data: Partial<T> }
101
+ | { type: 'delete'; key: string };
102
+
103
+ type RichUpdate<T> =
104
+ | { type: 'created'; key: string; data: T }
105
+ | { type: 'updated'; key: string; before: T; after: T; patch?: unknown }
106
+ | { type: 'deleted'; key: string; lastKnown?: T };
107
+ ```
108
+
109
+ ## License
110
+
111
+ MIT