@f3liz/rescript-misskey-api 0.4.2 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +36 -146
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,33 +1,32 @@
1
1
  # @f3liz/rescript-misskey-api
2
2
 
3
- **Pure ReScript** Misskey API client with a **clean, intuitive API**.
3
+ Type-safe Misskey API bindings for ReScript and TypeScript, generated from OpenAPI specs.
4
4
 
5
- > **Status**: Complete native ReScript implementation Zero dependencies • Type-safe • **Supports Misskey & Cherrypick**
5
+ Supports Misskey and Cherrypick instances. All endpoints are fully typed.
6
6
 
7
- ## Why @f3liz/rescript-misskey-api?
7
+ ## Usage
8
8
 
9
- **Discoverable**: Just type and let autocompletion guide you
10
- 🎯 **Simple**: Common operations are 1-2 lines
11
- 🔒 **Type-safe**: Full ReScript type checking
12
- ⚡ **Fast**: Native WebSocket implementation
13
- 🧩 **Complete**: Access 100% of the API via generated bindings
14
-
15
- ## Quick Start
9
+ ### ReScript
16
10
 
17
11
  ```rescript
18
- // Connect to Misskey
19
12
  let client = Misskey.connect("https://misskey.io", ~token="your-token")
20
13
 
21
14
  // Post a note
22
15
  await client->Misskey.Notes.create("Hello, Misskey!", ())
23
16
 
24
- // Stream timeline
25
- let sub = client->Misskey.Stream.timeline(#home, note => {
26
- Console.log2("New note!", note)
27
- })
17
+ // Read timeline
18
+ let notes = await client->Misskey.Notes.timeline(#home, ~limit=20, ())
19
+ ```
20
+
21
+ ### TypeScript
22
+
23
+ ```typescript
24
+ import Misskey from '@f3liz/rescript-misskey-api';
25
+
26
+ const client = new Misskey('https://misskey.io', 'your-token');
28
27
 
29
- // Cleanup
30
- sub.dispose()
28
+ await client.notes.create("Hello from TypeScript!");
29
+ const notes = await client.notes.timeline('home', { limit: 20 });
31
30
  ```
32
31
 
33
32
  ## Installation
@@ -36,169 +35,60 @@ sub.dispose()
36
35
  npm install @f3liz/rescript-misskey-api
37
36
  ```
38
37
 
39
- Add to your `rescript.json`:
38
+ If you are using ReScript, add to your `rescript.json`:
40
39
 
41
40
  ```json
42
41
  {
43
- "bs-dependencies": ["@f3liz/rescript-misskey-api"]
42
+ "dependencies": ["@f3liz/rescript-misskey-api"]
44
43
  }
45
44
  ```
46
45
 
47
46
  ## Architecture
48
47
 
49
- This library provides a **Dual-Layer Architecture**:
50
-
51
- 1. **High-Level Convenience API** (`Misskey`, `Cherrypick`):
52
- * Hand-crafted, simplified wrappers for common tasks (Notes, Streaming, Auth).
53
- * Recommended for most use cases.
54
- * Hides complexity (e.g., token injection, JSON handling).
55
-
56
- 2. **Full Generated API** (`MisskeyIoWrapper`, `KokonectLinkWrapper`):
57
- * Auto-generated from OpenAPI specs.
58
- * Provides **100% coverage** of every endpoint.
59
- * Strictly typed request/response objects.
60
-
61
- ### File Structure
62
-
63
- ```
64
- src/
65
- ├── Misskey.res # High-level Misskey wrapper
66
- ├── Cherrypick.res # High-level Cherrypick wrapper (fork support)
67
- └── generated/
68
- ├── misskey-io/ # Full generated bindings for Misskey.io
69
- └── kokonect-link/ # Full generated bindings for Cherrypick (Kokonect)
70
- ```
71
-
72
- ## TypeScript Support
73
-
74
- This library includes a **high-level TypeScript wrapper** and full generated definitions.
75
-
76
- ### 1. High-Level API (Recommended)
77
-
78
- The `Misskey` class provides a simple, "down-to-earth" API similar to the ReScript version.
79
-
80
- ```typescript
81
- import Misskey from '@f3liz/rescript-misskey-api';
82
-
83
- // 1. Initialize
84
- const misskey = new Misskey('https://misskey.io', 'your-token');
85
- // Or using static connect:
86
- // const misskey = Misskey.connect('https://misskey.io', 'your-token');
87
-
88
- // 2. Simple operations
89
- async function main() {
90
- // Create a note
91
- await misskey.notes.create("Hello from TypeScript!");
92
-
93
- // Create with options
94
- await misskey.notes.create("Private post", {
95
- visibility: 'followers'
96
- });
97
-
98
- // Read timeline
99
- const result = await misskey.notes.timeline('home', { limit: 10 });
100
- console.log(result);
101
- }
102
- ```
48
+ Two layers:
103
49
 
104
- ### 2. Full Generated API (Advanced)
50
+ 1. **High-level API** (`Misskey`, `Cherrypick`): Simplified wrappers for common operations (notes, timeline, streaming).
105
51
 
106
- For access to all 400+ endpoints, use the generated client directly.
52
+ 2. **Generated API** (`MisskeyIoWrapper`, `KokonectLinkWrapper`): Complete bindings for all 400+ endpoints, auto-generated from OpenAPI specs.
107
53
 
108
- ```typescript
109
- import { MisskeyClient, Notes } from '@f3liz/rescript-misskey-api';
54
+ ## Advanced Usage
110
55
 
111
- // Initialize generated client
112
- const client = new MisskeyClient('https://misskey.io', 'your-token');
56
+ ### Full Generated API (ReScript)
113
57
 
114
- // Use raw endpoint
115
- await Notes.postNotesCreate(client, {
116
- text: 'Raw API call',
117
- visibility: 'public'
118
- });
119
- ```
120
-
121
- ### For Cherrypick (Kokonect)
122
-
123
- ```typescript
124
- import { MisskeyClient, Chat } from '@f3liz/rescript-misskey-api/src/generated/kokonect-link/wrapper';
125
-
126
- const client = new MisskeyClient('https://kokonect.link', 'your-token');
127
- // ... use Chat or other Kokonect-specific APIs
128
- ```
129
-
130
- ## Examples
131
-
132
- ### 1. Standard Usage (High-Level)
133
-
134
- Use the `Misskey` module for standard interactions:
58
+ Access any endpoint not covered by the high-level wrapper:
135
59
 
136
60
  ```rescript
137
- // Post with options
138
- await client->Misskey.Notes.create(
139
- "Private post",
140
- ~visibility=#followers,
141
- ~cw="Content warning",
142
- ()
143
- )
144
-
145
- // Read timeline
146
- let result = await client->Misskey.Notes.timeline(#local, ~limit=20, ())
61
+ let wrapperClient = Misskey.connect("...")->Misskey.wrapperConnect
147
62
 
148
- // Stream notifications
149
- client->Misskey.Stream.notifications(notif => {
150
- Console.log2("Notification!", notif)
151
- })
63
+ open MisskeyIoWrapper
64
+ let result = await Admin.postAdminShowUser({userId: "..."}, ~client=wrapperClient)
152
65
  ```
153
66
 
154
- ### 2. Cherrypick / Fork Usage
155
-
156
- Use the `Cherrypick` module for [Cherrypick](https://github.com/kokonect-link/cherrypick) instances. It shares the same high-level API as `Misskey`.
67
+ ### Cherrypick
157
68
 
158
69
  ```rescript
159
70
  let client = Cherrypick.connect("https://kokonect.link", ~token="...")
160
-
161
71
  await client->Cherrypick.Notes.create("Hello Cherrypick!", ())
162
72
  ```
163
73
 
164
- ### 3. Advanced / Full API Access
74
+ ### Full Generated API (TypeScript)
165
75
 
166
- If you need an endpoint not covered by the high-level wrapper, drop down to the generated wrapper.
167
-
168
- **For Misskey:**
169
-
170
- ```rescript
171
- // Bridge to the generated client
172
- let wrapperClient = Misskey.connect("...")->Misskey.wrapperConnect
173
-
174
- // Use ANY endpoint (fully typed)
175
- open MisskeyIoWrapper
176
- let _ = await Admin.postAdminShowUser(
177
- {userId: "..."} /* Typed request object */,
178
- ~client=wrapperClient
179
- )
180
- ```
181
-
182
- **For Cherrypick (Fork-specific features):**
183
-
184
- ```rescript
185
- // Bridge to the generated client
186
- let wrapperClient = Cherrypick.connect("...")->Cherrypick.wrapperConnect
76
+ ```typescript
77
+ import { MisskeyClient, Notes } from '@f3liz/rescript-misskey-api';
187
78
 
188
- // Use a Cherrypick-specific endpoint
189
- open KokonectLinkWrapper
190
- let _ = await Chat.postChatRoomCreate(..., ~client=wrapperClient)
79
+ const client = new MisskeyClient('https://misskey.io', 'your-token');
80
+ await Notes.postNotesCreate(client, { text: 'Hello', visibility: 'public' });
191
81
  ```
192
82
 
193
- ## Developing & Regenerating
83
+ ## Regenerating Bindings
194
84
 
195
- To regenerate the bindings from the latest OpenAPI specs:
85
+ To update bindings from the latest OpenAPI specs:
196
86
 
197
87
  ```bash
198
88
  npm run generate
199
89
  ```
200
90
 
201
- This script fetches specs from `misskey.io` and `kokonect.link` and updates the `src/generated/` directories.
91
+ Fetches specs from `misskey.io` and `kokonect.link` and regenerates `src/generated/`.
202
92
 
203
93
  ## License
204
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@f3liz/rescript-misskey-api",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "ReScript bindings for Misskey API using OpenAPI code generation",
5
5
  "keywords": [
6
6
  "misskey",
@@ -48,10 +48,10 @@
48
48
  "prepublishOnly": "npm run build"
49
49
  },
50
50
  "dependencies": {
51
- "@f3liz/rescript-autogen-openapi": "^0.3.0",
52
51
  "sury": "11.0.0-alpha.4"
53
52
  },
54
53
  "devDependencies": {
54
+ "@f3liz/rescript-autogen-openapi": "^0.3.1",
55
55
  "rescript": "^12.1.0",
56
56
  "typescript": "^5.9.3"
57
57
  },