@practicalworks/rc-client 0.1.0 → 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/LICENSE +21 -0
- package/README.md +30 -4
- package/package.json +29 -18
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Practical Works
|
|
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
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,33 +37,22 @@
|
|
|
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
|
},
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "tsc -p tsconfig.json",
|
|
29
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
30
|
-
"test": "vitest run"
|
|
31
|
-
},
|
|
32
43
|
"devDependencies": {
|
|
33
44
|
"@types/node": "^22.0.0",
|
|
34
45
|
"typescript": "^5.5.0",
|
|
35
46
|
"vitest": "^3.0.0"
|
|
36
47
|
},
|
|
37
|
-
"repository": {
|
|
38
|
-
"type": "git",
|
|
39
|
-
"url": "git+https://github.com/PracticalWorks/rc-bridge.git",
|
|
40
|
-
"directory": "packages/client"
|
|
41
|
-
},
|
|
42
48
|
"publishConfig": {
|
|
43
49
|
"registry": "https://registry.npmjs.org/",
|
|
44
50
|
"access": "public",
|
|
45
51
|
"provenance": true
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsc -p tsconfig.json",
|
|
55
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
56
|
+
"test": "vitest run"
|
|
46
57
|
}
|
|
47
|
-
}
|
|
58
|
+
}
|