@theophilusdev/conduit 1.0.1 → 1.1.2

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 (3) hide show
  1. package/README.md +59 -38
  2. package/docs/DOCS.md +153 -94
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -5,10 +5,12 @@
5
5
  > A lightweight TypeScript wrapper around [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial) with a clean, middleware-based event system.
6
6
 
7
7
  ```ts
8
- const conduit = new ConduitClient({ listenEvents: true });
9
- await conduit.login({ appstate });
8
+ import { ConduitClient } from "@theophilusdev/conduit";
10
9
 
11
- conduit.on("message:create", async (ctx) => {
10
+ const client = new ConduitClient({ listenEvents: true });
11
+ await client.login({ appstate });
12
+
13
+ client.on("message:create", async (ctx) => {
12
14
  await ctx.reply(`hey, you said: ${ctx.body}`);
13
15
  });
14
16
  ```
@@ -22,18 +24,19 @@ npm install @theophilusdev/conduit
22
24
  ## Quick Start
23
25
 
24
26
  ```ts
25
- import { ConduitClient } from "conduit";
27
+ import { ConduitClient } from "@theophilusdev/conduit";
26
28
  import appstate from "./appstate.json" assert { type: "json" };
27
29
 
28
- const conduit = new ConduitClient({ listenEvents: true });
30
+ const client = new ConduitClient({ listenEvents: true });
29
31
 
30
- await conduit.login({ appstate });
32
+ await client.login({ appstate });
31
33
 
32
- conduit.on("message:create", async (ctx, next) => {
34
+ client.on("message:create", async (ctx, next) => {
33
35
  if (ctx.body === "ping") {
34
36
  await ctx.reply("pong");
35
37
  return;
36
38
  }
39
+
37
40
  await next();
38
41
  });
39
42
  ```
@@ -50,56 +53,69 @@ Pass **one** of the following to `.login()`:
50
53
 
51
54
  ```ts
52
55
  // appstate (recommended)
53
- await conduit.login({ appstate: [...] });
56
+ await client.login({ appstate: [...] });
54
57
 
55
58
  // raw cookies
56
- await conduit.login({ cookies: "c_user=...; xs=..." });
59
+ await client.login({ cookies: "c_user=...; xs=..." });
57
60
 
58
61
  // email/password (not recommended)
59
- await conduit.login({ account: { email: "...", password: "..." } });
62
+ await client.login({
63
+ account: { email: "...", password: "..." },
64
+ });
60
65
  ```
61
66
 
62
67
  ## Events
63
68
 
64
- Register handlers with `.on(event, ...middlewares)`. Handlers receive an enriched context object and an optional `next` function to pass control down the stack.
69
+ Register handlers with `.on(event, ...middlewares)`.
70
+
71
+ Handlers receive a context object and an optional `next()` function for middleware chaining.
72
+
73
+ All events include:
65
74
 
66
- All events include a `send(body)` helper. Events in the `message:*` namespace additionally include `reply(body)` and `react(emoji)`.
75
+ - `send(body)` send a message to the same thread
76
+
77
+ Message events additionally include:
78
+
79
+ - `reply(body)` — quoted reply to the triggering message
80
+ - `react(emoji)` — react to the triggering message
81
+
82
+ Both `send()` and `reply()` accept a plain string or a `ConduitMessageBody` object for rich messages with attachments and mentions.
67
83
 
68
84
  ### Message Events
69
85
 
70
- | Event | Trigger |
71
- | ----------------- | -------------------------------------------------------------- |
72
- | `message:create` | New message received |
73
- | `message:respond` | Reply to an existing message |
74
- | `message:remove` | Message unsent by sender |
75
- | `message:react` | Reaction added or removed |
76
- | `message:writing` | User started or stopped typing (requires `listenTyping: true`) |
77
- | `message:read` | Thread or message marked as read |
86
+ | Event | Description |
87
+ | ----------------- | ------------------------------------------------ |
88
+ | `message:create` | New message received |
89
+ | `message:respond` | Reply to an existing message |
90
+ | `message:remove` | Message unsent by sender |
91
+ | `message:react` | Reaction added or removed |
92
+ | `message:writing` | Typing indicator (requires `listenTyping: true`) |
93
+ | `message:read` | Thread or message marked as read |
78
94
 
79
95
  ### User Events
80
96
 
81
- | Event | Trigger |
97
+ | Event | Description |
82
98
  | ------------- | -------------------------------------------- |
83
99
  | `user:create` | User added to a group thread |
84
100
  | `user:remove` | User left or was removed from a group thread |
85
101
 
86
102
  ### Thread Events
87
103
 
88
- | Event | Trigger |
89
- | ------------------------- | ------------------------------------------ |
90
- | `thread:update` | Any thread metadata change (catch-all) |
91
- | `thread:title_change` | Group title updated |
92
- | `thread:photo_replaced` | Group photo changed |
93
- | `thread:theme_changed` | Chat theme or color changed |
94
- | `thread:nickname_changed` | A participant's nickname changed |
95
- | `thread:admin_changed` | A participant promoted or demoted as admin |
104
+ | Event | Description |
105
+ | ------------------------- | ---------------------------- |
106
+ | `thread:update` | Catch-all for thread updates |
107
+ | `thread:title_change` | Group title updated |
108
+ | `thread:photo_replaced` | Group photo changed |
109
+ | `thread:theme_changed` | Chat theme changed |
110
+ | `thread:nickname_changed` | Participant nickname updated |
111
+ | `thread:admin_changed` | Admin role changed |
96
112
 
97
113
  ## Middleware
98
114
 
99
- `.on()` accepts multiple handlers. Each must call `next()` to pass control to the next one.
115
+ `.on()` accepts multiple handlers. Each must call `next()` to continue the chain.
100
116
 
101
117
  ```ts
102
- conduit.on(
118
+ client.on(
103
119
  "message:create",
104
120
  async (ctx, next) => {
105
121
  console.log("middleware 1");
@@ -114,26 +130,31 @@ conduit.on(
114
130
 
115
131
  ## Raw FCA Access
116
132
 
117
- For events or methods not yet covered by conduit, you can drop down to the raw FCA layer:
133
+ Drop down to FCA when needed:
118
134
 
119
135
  ```ts
120
136
  // raw FCA event
121
- conduit.onFca("presence", async (data) => {
137
+ client.onFca("presence", async (data) => {
122
138
  console.log(data);
123
139
  });
124
140
 
125
- // raw FCA api (no type safety)
126
- conduit.api.getThreadList(10, null, ["INBOX"]);
141
+ // raw FCA API (no type safety)
142
+ client.api.getThreadList(10, null, ["INBOX"]);
127
143
  ```
128
144
 
129
145
  ## API Reference
130
146
 
131
- See [docs/DOCS.md](docs/DOCS.md) for the full API reference covering `client.messages`, `client.threads`, `client.users`, and `client.account`.
147
+ See [docs/DOCS.md](docs/DOCS.md) for full API details:
148
+
149
+ - `client.messages`
150
+ - `client.threads`
151
+ - `client.users`
152
+ - `client.account`
132
153
 
133
154
  ## License
134
155
 
135
- GNU GPL v3 © [theophilusdev](https://github.com/TheophilusWorks)
156
+ GNU GPL v3 © theophilusdev
136
157
 
137
158
  ---
138
159
 
139
- Built on top of [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial). Credit to dongp06 and all contributors to the fca-unofficial project.
160
+ Built on top of [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial).
package/docs/DOCS.md CHANGED
@@ -1,6 +1,6 @@
1
- # conduit — API Reference
1
+ # Conduit — API Reference
2
2
 
3
- Full reference for all namespaced APIs exposed by `ConduitClient`.
3
+ Full reference for all APIs exposed by `ConduitClient`.
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -16,28 +16,33 @@ Full reference for all namespaced APIs exposed by `ConduitClient`.
16
16
  ## ConduitClient
17
17
 
18
18
  ```ts
19
- import { ConduitClient } from "conduit";
19
+ import { ConduitClient } from "@theophilusdev/conduit";
20
20
 
21
- const conduit = new ConduitClient(config);
22
- await conduit.login(credentials);
21
+ const client = new ConduitClient(config);
22
+ await client.login(credentials);
23
23
  ```
24
24
 
25
+ ---
26
+
25
27
  ### Constructor
26
28
 
27
29
  ```ts
28
30
  new ConduitClient(config: ConduitClientConfig)
29
31
  ```
30
32
 
31
- `ConduitClientConfig` extends `MessengerBotOptions` from `@dongdev/fca-unofficial`. The `logLevel` defaults to `"silent"` if not provided.
33
+ Creates a new Conduit client instance.
34
+
35
+ - Extends `MessengerBotOptions` from `@dongdev/fca-unofficial`
36
+ - `logLevel` defaults to `"silent"`
32
37
 
33
38
  ---
34
39
 
35
40
  ### `.login(credentials)`
36
41
 
37
- Authenticates with Messenger and initialises the underlying FCA bot. Must be called before any events can be received.
42
+ Authenticates with Messenger and initializes the client.
38
43
 
39
44
  ```ts
40
- await conduit.login(credentials: ConduitCredentials): Promise<ConduitClient>
45
+ await client.login(credentials: ConduitCredentials): Promise<ConduitClient>
41
46
  ```
42
47
 
43
48
  Returns the client instance for chaining.
@@ -46,14 +51,14 @@ Returns the client instance for chaining.
46
51
 
47
52
  ### `.on(event, ...middlewares)`
48
53
 
49
- Registers one or more middleware handlers for a Conduit event. The first call for a given event also binds the corresponding FCA listener internally.
54
+ Registers one or more middleware handlers for a Conduit event.
50
55
 
51
56
  ```ts
52
- conduit.on(event: keyof ConduitEvents, ...middlewares: Middleware[]): this
57
+ client.on(event: keyof ConduitEvents, ...middlewares: Middleware[]): this
53
58
  ```
54
59
 
55
60
  ```ts
56
- conduit.on("message:create", async (ctx, next) => {
61
+ client.on("message:create", async (ctx, next) => {
57
62
  await ctx.reply("hello!");
58
63
  await next();
59
64
  });
@@ -63,56 +68,80 @@ conduit.on("message:create", async (ctx, next) => {
63
68
 
64
69
  ### `.onFca(event, ...middlewares)`
65
70
 
66
- Registers middleware directly against a raw FCA event, bypassing the Conduit abstraction. Useful for events not yet mapped by conduit.
71
+ Registers middleware directly on raw FCA events.
67
72
 
68
73
  ```ts
69
- conduit.onFca(event: string, ...middlewares): this
74
+ client.onFca(event: string, ...middlewares): this
70
75
  ```
71
76
 
72
77
  ---
73
78
 
74
79
  ### `.api`
75
80
 
76
- Direct access to the raw FCA api context. No type safety or autocompletion — use as a last resort.
81
+ Direct access to the raw FCA API. No type safety — use as a last resort.
77
82
 
78
83
  ```ts
79
- conduit.api.getThreadList(10, null, ["INBOX"]);
84
+ client.api.getThreadList(10, null, ["INBOX"]);
80
85
  ```
81
86
 
82
87
  ---
83
88
 
84
89
  ## client.messages
85
90
 
86
- Accessible via `conduit.messages`. Handles all message-level operations.
91
+ Accessible via:
92
+
93
+ ```ts
94
+ client.messages;
95
+ ```
96
+
97
+ Handles message-level operations.
87
98
 
88
99
  ---
89
100
 
90
101
  ### `.send(body, threadID)`
91
102
 
92
- Sends a plain text message to a thread.
103
+ Sends a message to a thread. Accepts a plain string or a `ConduitMessageBody` for rich messages.
93
104
 
94
105
  ```ts
95
- await conduit.messages.send("hello", threadID);
106
+ await client.messages.send("hello", threadID);
107
+
108
+ await client.messages.send(
109
+ {
110
+ body: "hey @user",
111
+ mentions: [{ tag: "@user", id: "uid", fromIndex: 4 }],
112
+ attachment: [stream],
113
+ },
114
+ threadID,
115
+ );
96
116
  ```
97
117
 
98
118
  ---
99
119
 
100
120
  ### `.reply(body, threadID, messageID)`
101
121
 
102
- Sends a quoted reply to a specific message.
122
+ Sends a quoted reply to a specific message. Accepts a plain string or a `ConduitMessageBody`.
103
123
 
104
124
  ```ts
105
- await conduit.messages.reply("got it", threadID, messageID);
125
+ await client.messages.reply("got it", threadID, messageID);
126
+
127
+ await client.messages.reply(
128
+ {
129
+ body: "got it",
130
+ attachment: [stream],
131
+ },
132
+ threadID,
133
+ messageID,
134
+ );
106
135
  ```
107
136
 
108
137
  ---
109
138
 
110
139
  ### `.edit(messageID, body)`
111
140
 
112
- Edits an existing message sent by the bot.
141
+ Edits an existing message.
113
142
 
114
143
  ```ts
115
- await conduit.messages.edit(messageID, "updated text");
144
+ await client.messages.edit(messageID, "updated text");
116
145
  ```
117
146
 
118
147
  ---
@@ -122,7 +151,7 @@ await conduit.messages.edit(messageID, "updated text");
122
151
  Retracts a message sent by the bot.
123
152
 
124
153
  ```ts
125
- await conduit.messages.unsend(messageID);
154
+ await client.messages.unsend(messageID);
126
155
  ```
127
156
 
128
157
  ---
@@ -132,7 +161,7 @@ await conduit.messages.unsend(messageID);
132
161
  Deletes a message.
133
162
 
134
163
  ```ts
135
- await conduit.messages.delete(messageID);
164
+ await client.messages.delete(messageID);
136
165
  ```
137
166
 
138
167
  ---
@@ -142,17 +171,17 @@ await conduit.messages.delete(messageID);
142
171
  Adds or removes a reaction on a message.
143
172
 
144
173
  ```ts
145
- await conduit.messages.react("👍", messageID, threadID);
174
+ await client.messages.react("👍", messageID, threadID);
146
175
  ```
147
176
 
148
177
  ---
149
178
 
150
179
  ### `.sendTypingIndicator(threadID)`
151
180
 
152
- Sends a typing indicator to a thread.
181
+ Sends a typing indicator.
153
182
 
154
183
  ```ts
155
- await conduit.messages.sendTypingIndicator(threadID);
184
+ await client.messages.sendTypingIndicator(threadID);
156
185
  ```
157
186
 
158
187
  ---
@@ -162,205 +191,209 @@ await conduit.messages.sendTypingIndicator(threadID);
162
191
  Marks a message as read.
163
192
 
164
193
  ```ts
165
- await conduit.messages.markAsRead(messageID);
194
+ await client.messages.markAsRead(messageID);
166
195
  ```
167
196
 
168
197
  ---
169
198
 
170
199
  ### `.uploadAttachment(file)`
171
200
 
172
- Uploads a file attachment and returns an attachment object that can be used in subsequent sends.
201
+ Uploads a file attachment.
173
202
 
174
203
  ```ts
175
- const attachment = await conduit.messages.uploadAttachment(stream);
204
+ const attachment = await client.messages.uploadAttachment(stream);
176
205
  ```
177
206
 
178
207
  ---
179
208
 
180
209
  ### `.forwardAttachment(attachmentID, threadID)`
181
210
 
182
- Forwards an existing attachment to another thread.
211
+ Forwards an attachment to another thread.
183
212
 
184
213
  ```ts
185
- await conduit.messages.forwardAttachment(attachmentID, threadID);
214
+ await client.messages.forwardAttachment(attachmentID, threadID);
186
215
  ```
187
216
 
188
217
  ---
189
218
 
190
219
  ### `.shareContact(userID, threadID)`
191
220
 
192
- Shares a contact card to a thread.
221
+ Shares a contact card.
193
222
 
194
223
  ```ts
195
- await conduit.messages.shareContact(userID, threadID);
224
+ await client.messages.shareContact(userID, threadID);
196
225
  ```
197
226
 
198
227
  ---
199
228
 
200
229
  ### `.changeThreadColor(color, threadID)`
201
230
 
202
- Changes the color theme of a thread.
231
+ Changes thread color.
203
232
 
204
233
  ```ts
205
- await conduit.messages.changeThreadColor("#FF0000", threadID);
234
+ await client.messages.changeThreadColor("#FF0000", threadID);
206
235
  ```
207
236
 
208
237
  ---
209
238
 
210
239
  ### `.changeThreadEmoji(emoji, threadID)`
211
240
 
212
- Changes the quick-reaction emoji of a thread.
241
+ Changes thread emoji.
213
242
 
214
243
  ```ts
215
- await conduit.messages.changeThreadEmoji("🔥", threadID);
244
+ await client.messages.changeThreadEmoji("🔥", threadID);
216
245
  ```
217
246
 
218
247
  ---
219
248
 
220
249
  ### `.getMessage(messageID)`
221
250
 
222
- Fetches a specific message by ID.
251
+ Fetches a message by ID.
223
252
 
224
253
  ```ts
225
- const message = await conduit.messages.getMessage(messageID);
254
+ const message = await client.messages.getMessage(messageID);
226
255
  ```
227
256
 
228
257
  ---
229
258
 
230
259
  ### `.getThreadColors()`
231
260
 
232
- Returns all available thread color themes.
261
+ Returns available thread colors.
233
262
 
234
263
  ```ts
235
- const colors = await conduit.messages.getThreadColors();
264
+ const colors = await client.messages.getThreadColors();
236
265
  ```
237
266
 
238
267
  ---
239
268
 
240
269
  ## client.threads
241
270
 
242
- Accessible via `conduit.threads`. Handles thread-level operations.
271
+ Accessible via:
272
+
273
+ ```ts
274
+ client.threads;
275
+ ```
276
+
277
+ Handles thread-level operations.
243
278
 
244
279
  ---
245
280
 
246
281
  ### `.getInfo(threadID)`
247
282
 
248
- Fetches detailed info about a thread including participants, name, and settings.
283
+ Fetches thread information.
249
284
 
250
285
  ```ts
251
- const info = await conduit.threads.getInfo(threadID);
286
+ const info = await client.threads.getInfo(threadID);
252
287
  ```
253
288
 
254
289
  ---
255
290
 
256
291
  ### `.getList(limit, cursor, folders)`
257
292
 
258
- Fetches a paginated list of threads.
293
+ Fetches a list of threads.
259
294
 
260
295
  ```ts
261
- const threads = await conduit.threads.getList(10, null, ["INBOX"]);
296
+ const threads = await client.threads.getList(10, null, ["INBOX"]);
262
297
  ```
263
298
 
264
299
  ---
265
300
 
266
301
  ### `.getHistory(threadID, limit)`
267
302
 
268
- Fetches message history for a thread.
303
+ Fetches message history.
269
304
 
270
305
  ```ts
271
- const history = await conduit.threads.getHistory(threadID, 20);
306
+ const history = await client.threads.getHistory(threadID, 20);
272
307
  ```
273
308
 
274
309
  ---
275
310
 
276
311
  ### `.search(query)`
277
312
 
278
- Searches for threads by name or keyword.
313
+ Searches threads.
279
314
 
280
315
  ```ts
281
- const results = await conduit.threads.search("dev chat");
316
+ const results = await client.threads.search("dev chat");
282
317
  ```
283
318
 
284
319
  ---
285
320
 
286
321
  ### `.createGroup(userIDs, name?)`
287
322
 
288
- Creates a new group conversation.
323
+ Creates a group conversation.
289
324
 
290
325
  ```ts
291
- const thread = await conduit.threads.createGroup(["uid1", "uid2"], "my group");
326
+ const thread = await client.threads.createGroup(["uid1", "uid2"], "my group");
292
327
  ```
293
328
 
294
329
  ---
295
330
 
296
331
  ### `.addUser(userID, threadID)`
297
332
 
298
- Adds a user to an existing group thread.
333
+ Adds a user to a thread.
299
334
 
300
335
  ```ts
301
- await conduit.threads.addUser(userID, threadID);
336
+ await client.threads.addUser(userID, threadID);
302
337
  ```
303
338
 
304
339
  ---
305
340
 
306
341
  ### `.removeUser(userID, threadID)`
307
342
 
308
- Removes a user from a group thread.
343
+ Removes a user from a thread.
309
344
 
310
345
  ```ts
311
- await conduit.threads.removeUser(userID, threadID);
346
+ await client.threads.removeUser(userID, threadID);
312
347
  ```
313
348
 
314
349
  ---
315
350
 
316
351
  ### `.changeAdminStatus(userID, threadID, admin)`
317
352
 
318
- Promotes or demotes a user's admin status in a group.
353
+ Changes admin status.
319
354
 
320
355
  ```ts
321
- await conduit.threads.changeAdminStatus(userID, threadID, true); // promote
322
- await conduit.threads.changeAdminStatus(userID, threadID, false); // demote
356
+ await client.threads.changeAdminStatus(userID, threadID, true);
323
357
  ```
324
358
 
325
359
  ---
326
360
 
327
361
  ### `.changeGroupImage(image, threadID)`
328
362
 
329
- Updates the group's profile image.
363
+ Updates group image.
330
364
 
331
365
  ```ts
332
- await conduit.threads.changeGroupImage(stream, threadID);
366
+ await client.threads.changeGroupImage(stream, threadID);
333
367
  ```
334
368
 
335
369
  ---
336
370
 
337
371
  ### `.changeNickname(nickname, threadID, userID)`
338
372
 
339
- Sets a participant's nickname. Pass an empty string to clear.
373
+ Sets nickname.
340
374
 
341
375
  ```ts
342
- await conduit.threads.changeNickname("nick", threadID, userID);
343
- await conduit.threads.changeNickname("", threadID, userID); // clear
376
+ await client.threads.changeNickname("nick", threadID, userID);
344
377
  ```
345
378
 
346
379
  ---
347
380
 
348
381
  ### `.setTitle(title, threadID)`
349
382
 
350
- Changes the title of a group thread.
383
+ Changes thread title.
351
384
 
352
385
  ```ts
353
- await conduit.threads.setTitle("new title", threadID);
386
+ await client.threads.setTitle("new title", threadID);
354
387
  ```
355
388
 
356
389
  ---
357
390
 
358
391
  ### `.createPoll(title, threadID, options)`
359
392
 
360
- Creates a poll in a thread.
393
+ Creates a poll.
361
394
 
362
395
  ```ts
363
- await conduit.threads.createPoll("Favourite language?", threadID, [
396
+ await client.threads.createPoll("Favourite language?", threadID, [
364
397
  "TypeScript",
365
398
  "Python",
366
399
  ]);
@@ -373,55 +406,59 @@ await conduit.threads.createPoll("Favourite language?", threadID, [
373
406
  Deletes a thread.
374
407
 
375
408
  ```ts
376
- await conduit.threads.delete(threadID);
409
+ await client.threads.delete(threadID);
377
410
  ```
378
411
 
379
412
  ---
380
413
 
381
414
  ### `.mute(threadID, muteUntil)`
382
415
 
383
- Mutes or unmutes notifications for a thread.
416
+ Mutes or unmutes a thread. Pass `-1` to mute indefinitely, `0` to unmute.
384
417
 
385
418
  ```ts
386
- await conduit.threads.mute(threadID, -1); // mute indefinitely
387
- await conduit.threads.mute(threadID, 0); // unmute
419
+ await client.threads.mute(threadID, -1); // mute forever
420
+ await client.threads.mute(threadID, 0); // unmute
388
421
  ```
389
422
 
390
423
  ---
391
424
 
392
425
  ### `.handleMessageRequest(threadID, accept)`
393
426
 
394
- Accepts or declines a message request.
427
+ Handles message requests.
395
428
 
396
429
  ```ts
397
- await conduit.threads.handleMessageRequest(threadID, true);
430
+ await client.threads.handleMessageRequest(threadID, true);
398
431
  ```
399
432
 
400
433
  ---
401
434
 
402
435
  ## client.users
403
436
 
404
- Accessible via `conduit.users`. Handles user-related operations.
437
+ Accessible via:
438
+
439
+ ```ts
440
+ client.users;
441
+ ```
405
442
 
406
443
  ---
407
444
 
408
445
  ### `.getInfo(userID)`
409
446
 
410
- Fetches info for one or more users by ID.
447
+ Fetches user info. Accepts a single ID or an array.
411
448
 
412
449
  ```ts
413
- const user = await conduit.users.getInfo("uid");
414
- const users = await conduit.users.getInfo(["uid1", "uid2"]);
450
+ const user = await client.users.getInfo("uid");
451
+ const users = await client.users.getInfo(["uid1", "uid2"]);
415
452
  ```
416
453
 
417
454
  ---
418
455
 
419
456
  ### `.getID(vanity)`
420
457
 
421
- Resolves a vanity URL or username to a Facebook user ID.
458
+ Resolves a vanity username to a Facebook user ID.
422
459
 
423
460
  ```ts
424
- const id = await conduit.users.getID("zuck");
461
+ const id = await client.users.getID("zuck");
425
462
  ```
426
463
 
427
464
  ---
@@ -431,23 +468,27 @@ const id = await conduit.users.getID("zuck");
431
468
  Returns the authenticated user's friends list.
432
469
 
433
470
  ```ts
434
- const friends = await conduit.users.getFriendsList();
471
+ const friends = await client.users.getFriendsList();
435
472
  ```
436
473
 
437
474
  ---
438
475
 
439
476
  ## client.account
440
477
 
441
- Accessible via `conduit.account`. Handles account-level operations for the authenticated user.
478
+ Accessible via:
479
+
480
+ ```ts
481
+ client.account;
482
+ ```
442
483
 
443
484
  ---
444
485
 
445
486
  ### `.getCurrentUserID()`
446
487
 
447
- Returns the logged-in user's Facebook ID synchronously.
488
+ Returns current user ID. Synchronous.
448
489
 
449
490
  ```ts
450
- const myID = conduit.account.getCurrentUserID();
491
+ const myID = client.account.getCurrentUserID();
451
492
  ```
452
493
 
453
494
  ---
@@ -457,8 +498,8 @@ const myID = conduit.account.getCurrentUserID();
457
498
  Blocks or unblocks a user.
458
499
 
459
500
  ```ts
460
- await conduit.account.blockUser(userID, true); // block
461
- await conduit.account.blockUser(userID, false); // unblock
501
+ await client.account.blockUser(userID, true); // block
502
+ await client.account.blockUser(userID, false); // unblock
462
503
  ```
463
504
 
464
505
  ---
@@ -468,7 +509,7 @@ await conduit.account.blockUser(userID, false); // unblock
468
509
  Accepts or declines a friend request.
469
510
 
470
511
  ```ts
471
- await conduit.account.handleFriendRequest(userID, true);
512
+ await client.account.handleFriendRequest(userID, true);
472
513
  ```
473
514
 
474
515
  ---
@@ -478,25 +519,23 @@ await conduit.account.handleFriendRequest(userID, true);
478
519
  Removes a user from the friends list.
479
520
 
480
521
  ```ts
481
- await conduit.account.unfriend(userID);
522
+ await client.account.unfriend(userID);
482
523
  ```
483
524
 
484
525
  ---
485
526
 
486
527
  ### `.logout()`
487
528
 
488
- Ends the current session and invalidates cookies.
529
+ Ends the session and invalidates cookies.
489
530
 
490
531
  ```ts
491
- await conduit.account.logout();
532
+ await client.account.logout();
492
533
  ```
493
534
 
494
535
  ---
495
536
 
496
537
  ## Types
497
538
 
498
- Key types exported from conduit. See `src/types.ts` for the full source.
499
-
500
539
  ### `ConduitCredentials`
501
540
 
502
541
  ```ts
@@ -510,6 +549,22 @@ interface ConduitCredentials {
510
549
  }
511
550
  ```
512
551
 
552
+ ---
553
+
554
+ ### `ConduitMessageBody`
555
+
556
+ Used by `send()` and `reply()` for rich messages with attachments and mentions.
557
+
558
+ ```ts
559
+ interface ConduitMessageBody {
560
+ body?: string;
561
+ mentions?: { tag: string; id: string; fromIndex: number }[];
562
+ attachment?: any[];
563
+ }
564
+ ```
565
+
566
+ ---
567
+
513
568
  ### `Message`
514
569
 
515
570
  ```ts
@@ -525,6 +580,8 @@ interface Message {
525
580
  }
526
581
  ```
527
582
 
583
+ ---
584
+
528
585
  ### `Middleware<K>`
529
586
 
530
587
  ```ts
@@ -534,6 +591,8 @@ type Middleware<K extends keyof ConduitEvents> = (
534
591
  ) => Promise<void>;
535
592
  ```
536
593
 
594
+ ---
595
+
537
596
  ### `ConduitEvents`
538
597
 
539
- The full map of event names to their payload types. See `src/types.ts` for all payload shapes (`MessageCreatePayload`, `ThreadTitleChangePayload`, etc.).
598
+ Full event map is defined in `src/types.ts`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@theophilusdev/conduit",
3
3
  "description": "A simple FCA wrapper library with typescript support",
4
- "version": "1.0.1",
4
+ "version": "1.1.2",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.mjs",