@riseonly/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 Riseonly
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,163 @@
1
+ # @riseonly/sdk
2
+
3
+ Official Riseonly Bot API SDK for Node.js.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @riseonly/sdk
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```js
14
+ import { RiseonlyBot } from '@riseonly/sdk';
15
+
16
+ const bot = new RiseonlyBot(process.env.BOT_TOKEN, { polling: true });
17
+
18
+ bot.on('message', async (message) => {
19
+ if (message.text === '/start') {
20
+ await bot.sendMessage({
21
+ chat_id: message.chat.id,
22
+ text: 'welcome to riseonly',
23
+ });
24
+ }
25
+ });
26
+ ```
27
+
28
+ ## Bot API client
29
+
30
+ Use `ApiClient` when you only need HTTP methods without event loop helpers:
31
+
32
+ ```js
33
+ import { ApiClient } from '@riseonly/sdk';
34
+
35
+ const api = new ApiClient(process.env.BOT_TOKEN, {
36
+ baseUrl: 'http://localhost:8080',
37
+ });
38
+
39
+ const me = await api.getMe();
40
+ await api.sendMessage({ chat_id: me.id, text: 'hello' });
41
+ ```
42
+
43
+ ## Webhooks
44
+
45
+ ### Built-in server
46
+
47
+ ```js
48
+ import { RiseonlyBot } from '@riseonly/sdk';
49
+
50
+ const bot = new RiseonlyBot(process.env.BOT_TOKEN);
51
+
52
+ bot.on('message', async (message) => {
53
+ await bot.reply(message, 'got it');
54
+ });
55
+
56
+ await bot.setWebhook({
57
+ url: 'https://example.com/hook',
58
+ secret_token: 'my-secret',
59
+ });
60
+
61
+ await bot.startWebhook({
62
+ path: '/hook',
63
+ port: 3000,
64
+ secretToken: 'my-secret',
65
+ });
66
+ ```
67
+
68
+ ### Express / Fastify adapter
69
+
70
+ ```js
71
+ import express from 'express';
72
+ import { createWebhookHandler } from '@riseonly/sdk';
73
+
74
+ const app = express();
75
+ app.use(express.json());
76
+
77
+ const handleWebhook = createWebhookHandler({
78
+ secretToken: process.env.WEBHOOK_SECRET,
79
+ onUpdate: (update) => bot.processUpdate(update),
80
+ });
81
+
82
+ app.post('/hook', async (req, res) => {
83
+ const result = await handleWebhook({ headers: req.headers, body: req.body });
84
+ res.status(result.status).json(result.body);
85
+ });
86
+ ```
87
+
88
+ ## Mini app init data
89
+
90
+ ```js
91
+ import { verifyInitData, extractInitDataFromLaunchUrl } from '@riseonly/sdk';
92
+
93
+ const initData = extractInitDataFromLaunchUrl(launchUrl);
94
+ const fields = verifyInitData(process.env.BOT_TOKEN, initData);
95
+ const user = JSON.parse(fields.user);
96
+ ```
97
+
98
+ ## Supported methods
99
+
100
+ - `getMe`
101
+ - `sendMessage`
102
+ - `sendPhoto`, `sendVideo`, `sendDocument`, `sendAudio`, `sendVoice`, `sendAnimation`
103
+ - `editMessageText`
104
+ - `deleteMessage`
105
+ - `sendChatAction`
106
+ - `getUpdates`
107
+ - `setWebhook`, `deleteWebhook`, `getWebhookInfo`
108
+ - `setMyCommands`, `getMyCommands`, `deleteMyCommands`
109
+ - `answerCallbackQuery`
110
+ - `getChat`
111
+
112
+ ## Idempotency
113
+
114
+ Pass `requestId` to any method that supports retries:
115
+
116
+ ```js
117
+ import { createRequestId } from '@riseonly/sdk';
118
+
119
+ const requestId = createRequestId();
120
+ await bot.sendMessage({
121
+ chat_id: 'chat-id',
122
+ text: 'safe retry',
123
+ requestId,
124
+ });
125
+ ```
126
+
127
+ ## TypeScript
128
+
129
+ The package ships with full type definitions. Import types directly:
130
+
131
+ ```ts
132
+ import type { Message, Update, InlineKeyboardMarkup } from '@riseonly/sdk';
133
+ ```
134
+
135
+ ## Local development
136
+
137
+ ```bash
138
+ npm install
139
+ npm test
140
+ npm run build
141
+ ```
142
+
143
+ Point the SDK to a local api-gateway:
144
+
145
+ ```js
146
+ const bot = new RiseonlyBot(token, {
147
+ baseUrl: 'http://localhost:8080',
148
+ polling: true,
149
+ });
150
+ ```
151
+
152
+ ## Release channels
153
+
154
+ - `latest` — production releases from `main` after merge with `deploy` label
155
+ - `next` — staging prereleases from `staging` branch
156
+
157
+ ```bash
158
+ npm install @riseonly/sdk@next
159
+ ```
160
+
161
+ ## License
162
+
163
+ MIT