@practicalworks/rc-client 0.1.1 → 0.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.
- package/README.md +30 -4
- package/package.json +23 -12
package/README.md
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
# @practicalworks/rc-client
|
|
2
2
|
|
|
3
|
-
A typed
|
|
3
|
+
**A typed [Rocket.Chat](https://www.rocket.chat) REST client for Node, with no runtime dependencies.**
|
|
4
|
+
Post to a channel, a DM, a room or a thread; react; upload files; check auth. Every message is
|
|
5
|
+
split to fit Rocket.Chat's size limit, so long output never gets refused.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@practicalworks/rc-client)
|
|
8
|
+
[](https://github.com/PracticalWorks/rc-bridge/actions/workflows/ci.yml)
|
|
9
|
+
[](https://github.com/PracticalWorks/rc-bridge/blob/main/LICENSE)
|
|
10
|
+
|
|
11
|
+
Use it for the jobs that tell people things: a deploy notice, a nightly report, an alert, a tool
|
|
12
|
+
your AI agent calls to message the team. It is the client inside
|
|
13
|
+
[`@practicalworks/rc-bridge`](https://www.npmjs.com/package/@practicalworks/rc-bridge).
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @practicalworks/rc-client
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Node 20 or later (it uses the global `fetch`, `FormData` and `Blob`).
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
Create a bot user in Rocket.Chat and a personal access token for it (*My Account → Personal
|
|
26
|
+
Access Tokens*); the token page shows the user id too.
|
|
4
27
|
|
|
5
28
|
```ts
|
|
6
29
|
import { RocketChatClient } from "@practicalworks/rc-client";
|
|
@@ -11,11 +34,14 @@ const rc = new RocketChatClient({
|
|
|
11
34
|
authToken: process.env.RC_AUTH_TOKEN!,
|
|
12
35
|
});
|
|
13
36
|
|
|
14
|
-
await rc.postToChannel("#
|
|
15
|
-
await rc.postToChannel("@sam", "Your report is ready.");
|
|
37
|
+
await rc.postToChannel("#deploys", "v2.3.0 is live."); // a channel
|
|
38
|
+
await rc.postToChannel("@sam", "Your report is ready."); // a DM, opened if needed
|
|
39
|
+
|
|
40
|
+
const status = await rc.authStatus(); // { ok, status, error? }, never throws
|
|
16
41
|
```
|
|
17
42
|
|
|
18
|
-
The base URL and
|
|
43
|
+
The base URL and credentials come from the caller and are never stored or logged. Pass your
|
|
44
|
+
own `fetch` as the second constructor argument to test or proxy.
|
|
19
45
|
|
|
20
46
|
## Two registers
|
|
21
47
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@practicalworks/rc-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A typed Rocket.Chat REST client: posts by name, room or thread, replies with a fallback, reactions, room type, uploads, auth status, and splitting a message Rocket.Chat would refuse.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rocket.chat",
|
|
7
|
+
"rocketchat",
|
|
8
|
+
"chat",
|
|
9
|
+
"client",
|
|
10
|
+
"rocket-chat",
|
|
11
|
+
"rest",
|
|
12
|
+
"api",
|
|
13
|
+
"bot",
|
|
14
|
+
"notifications",
|
|
15
|
+
"typescript"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/PracticalWorks/rc-bridge/tree/main/packages/client#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/PracticalWorks/rc-bridge/issues"
|
|
20
|
+
},
|
|
5
21
|
"license": "MIT",
|
|
22
|
+
"author": "Practical Works <hello@practical.works> (https://practical.works)",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/PracticalWorks/rc-bridge.git",
|
|
26
|
+
"directory": "packages/client"
|
|
27
|
+
},
|
|
6
28
|
"type": "module",
|
|
7
29
|
"main": "dist/index.js",
|
|
8
30
|
"types": "dist/index.d.ts",
|
|
@@ -15,12 +37,6 @@
|
|
|
15
37
|
"files": [
|
|
16
38
|
"dist"
|
|
17
39
|
],
|
|
18
|
-
"keywords": [
|
|
19
|
-
"rocket.chat",
|
|
20
|
-
"rocketchat",
|
|
21
|
-
"chat",
|
|
22
|
-
"client"
|
|
23
|
-
],
|
|
24
40
|
"engines": {
|
|
25
41
|
"node": ">=20"
|
|
26
42
|
},
|
|
@@ -29,11 +45,6 @@
|
|
|
29
45
|
"typescript": "^5.5.0",
|
|
30
46
|
"vitest": "^3.0.0"
|
|
31
47
|
},
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "git+https://github.com/PracticalWorks/rc-bridge.git",
|
|
35
|
-
"directory": "packages/client"
|
|
36
|
-
},
|
|
37
48
|
"publishConfig": {
|
|
38
49
|
"registry": "https://registry.npmjs.org/",
|
|
39
50
|
"access": "public",
|