@vybit/api-sdk 1.0.1 → 1.1.1
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 +293 -38
- package/dist/__tests__/api-client.test.d.ts +8 -0
- package/dist/__tests__/api-client.test.d.ts.map +1 -0
- package/dist/__tests__/api-client.test.js +324 -0
- package/dist/__tests__/api-client.test.js.map +1 -0
- package/dist/__tests__/api-integration.test.d.ts +11 -0
- package/dist/__tests__/api-integration.test.d.ts.map +1 -0
- package/dist/__tests__/api-integration.test.js +267 -0
- package/dist/__tests__/api-integration.test.js.map +1 -0
- package/dist/api-client.d.ts +265 -9
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +428 -13
- package/dist/api-client.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +405 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +18 -7
package/dist/api-client.d.ts
CHANGED
|
@@ -1,18 +1,274 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VybitAPIConfig, PaginationParams, SearchParams, StatusResponse, Profile, Meter, Vybit, VybitCreateParams, VybitUpdateParams, VybitTriggerParams, VybitTriggerResponse, VybitFollow, VybitFollowUpdateParams, PublicVybit, SubscriberSendParams, SubscriberSendResponse, Sound, Log, Peep, DeleteResponse } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Vybit Developer API client
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* once the main Vybit application API is finalized.
|
|
5
|
+
* Provides programmatic access to manage vybits, subscriptions, sounds,
|
|
6
|
+
* and notification logs using the Vybit Developer API.
|
|
8
7
|
*
|
|
9
|
-
* @
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // With explicit API key
|
|
11
|
+
* const client = new VybitAPIClient({
|
|
12
|
+
* apiKey: 'your-api-key-from-developer-portal'
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Using VYBIT_API_KEY environment variable
|
|
16
|
+
* const client = new VybitAPIClient();
|
|
17
|
+
*
|
|
18
|
+
* // Get API status
|
|
19
|
+
* const status = await client.getStatus();
|
|
20
|
+
*
|
|
21
|
+
* // Create a vybit
|
|
22
|
+
* const vybit = await client.createVybit({
|
|
23
|
+
* name: 'Server Alert',
|
|
24
|
+
* soundKey: 'sound123abc',
|
|
25
|
+
* triggerType: 'webhook'
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // List vybits with pagination
|
|
29
|
+
* const vybits = await client.listVybits({ limit: 10, offset: 0 });
|
|
30
|
+
* ```
|
|
10
31
|
*/
|
|
11
32
|
export declare class VybitAPIClient {
|
|
12
|
-
|
|
33
|
+
private apiKey;
|
|
34
|
+
private baseUrl;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new Vybit Developer API client
|
|
37
|
+
* @param config - API configuration. If apiKey is not provided, falls back to VYBIT_API_KEY environment variable
|
|
38
|
+
* @throws {VybitValidationError} When API key is not provided and VYBIT_API_KEY environment variable is not set
|
|
39
|
+
*/
|
|
40
|
+
constructor(config?: VybitAPIConfig);
|
|
41
|
+
private request;
|
|
42
|
+
private buildQueryParams;
|
|
43
|
+
/**
|
|
44
|
+
* Check API health status
|
|
45
|
+
* @returns API status response
|
|
46
|
+
*/
|
|
47
|
+
getStatus(): Promise<StatusResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Get usage metrics and tier limits
|
|
50
|
+
* @returns Usage statistics and capacity limits
|
|
51
|
+
*/
|
|
52
|
+
getMeter(): Promise<Meter>;
|
|
53
|
+
/**
|
|
54
|
+
* Get user profile information
|
|
55
|
+
* @returns User profile data
|
|
56
|
+
*/
|
|
57
|
+
getProfile(): Promise<Profile>;
|
|
58
|
+
/**
|
|
59
|
+
* List vybits owned by the authenticated user
|
|
60
|
+
* @param params - Pagination and search parameters
|
|
61
|
+
* @returns Array of vybits
|
|
62
|
+
*/
|
|
63
|
+
listVybits(params?: SearchParams): Promise<Vybit[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Get a specific vybit by key
|
|
66
|
+
* @param key - Vybit key
|
|
67
|
+
* @returns Vybit details
|
|
68
|
+
*/
|
|
69
|
+
getVybit(key: string): Promise<Vybit>;
|
|
70
|
+
/**
|
|
71
|
+
* Create a new vybit
|
|
72
|
+
* @param params - Vybit creation parameters
|
|
73
|
+
* @returns Created vybit
|
|
74
|
+
*/
|
|
75
|
+
createVybit(params: VybitCreateParams): Promise<Vybit>;
|
|
76
|
+
/**
|
|
77
|
+
* Update a vybit (full update)
|
|
78
|
+
* @param key - Vybit key
|
|
79
|
+
* @param params - Vybit update parameters
|
|
80
|
+
* @returns Updated vybit
|
|
81
|
+
*/
|
|
82
|
+
updateVybit(key: string, params: VybitUpdateParams): Promise<Vybit>;
|
|
83
|
+
/**
|
|
84
|
+
* Update a vybit (partial update)
|
|
85
|
+
* @param key - Vybit key
|
|
86
|
+
* @param params - Vybit update parameters
|
|
87
|
+
* @returns Updated vybit
|
|
88
|
+
*/
|
|
89
|
+
patchVybit(key: string, params: VybitUpdateParams): Promise<Vybit>;
|
|
90
|
+
/**
|
|
91
|
+
* Delete a vybit
|
|
92
|
+
* @param key - Vybit key
|
|
93
|
+
* @returns Delete confirmation
|
|
94
|
+
*/
|
|
95
|
+
deleteVybit(key: string): Promise<DeleteResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* Trigger a vybit notification as the owner
|
|
98
|
+
* @param key - Vybit key
|
|
99
|
+
* @param params - Optional notification content to override defaults
|
|
100
|
+
* @returns Trigger response with log key
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const result = await client.triggerVybit('vybit123abc', {
|
|
105
|
+
* message: 'Server maintenance complete',
|
|
106
|
+
* imageUrl: 'https://example.com/status-ok.jpg'
|
|
107
|
+
* });
|
|
108
|
+
* console.log('Notification triggered, log key:', result.plk);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
triggerVybit(key: string, params?: VybitTriggerParams): Promise<VybitTriggerResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* List public vybits available for subscription
|
|
114
|
+
* @param params - Pagination and search parameters
|
|
115
|
+
* @returns Array of public vybits
|
|
116
|
+
*/
|
|
117
|
+
listPublicVybits(params?: SearchParams): Promise<PublicVybit[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Get a public vybit by subscription key
|
|
120
|
+
* @param key - Subscription key
|
|
121
|
+
* @returns Public vybit details
|
|
122
|
+
*/
|
|
123
|
+
getPublicVybit(key: string): Promise<PublicVybit>;
|
|
124
|
+
/**
|
|
125
|
+
* List vybit subscriptions (follows)
|
|
126
|
+
* @param params - Pagination and search parameters
|
|
127
|
+
* @returns Array of vybit follows
|
|
128
|
+
*/
|
|
129
|
+
listVybitFollows(params?: SearchParams): Promise<VybitFollow[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Get a specific vybit follow by key
|
|
132
|
+
* @param key - Vybit follow (following) key
|
|
133
|
+
* @returns Vybit follow details
|
|
134
|
+
*/
|
|
135
|
+
getVybitFollow(key: string): Promise<VybitFollow>;
|
|
136
|
+
/**
|
|
137
|
+
* Subscribe to a vybit using its subscription key
|
|
138
|
+
* @param subscriptionKey - The subscription key of the vybit to subscribe to
|
|
139
|
+
* @returns Created vybit follow
|
|
140
|
+
*/
|
|
141
|
+
createVybitFollow(subscriptionKey: string): Promise<any>;
|
|
142
|
+
/**
|
|
143
|
+
* Update a vybit subscription
|
|
144
|
+
* @param key - Vybit follow (following) key
|
|
145
|
+
* @param params - Update parameters
|
|
146
|
+
* @returns Updated vybit follow
|
|
147
|
+
*/
|
|
148
|
+
updateVybitFollow(key: string, params: VybitFollowUpdateParams): Promise<VybitFollow>;
|
|
149
|
+
/**
|
|
150
|
+
* Unsubscribe from a vybit (delete follow)
|
|
151
|
+
* @param key - Vybit follow (following) key
|
|
152
|
+
* @returns Delete confirmation
|
|
153
|
+
*/
|
|
154
|
+
deleteVybitFollow(key: string): Promise<DeleteResponse>;
|
|
155
|
+
/**
|
|
156
|
+
* Send a notification to the owner of a subscribed vybit
|
|
157
|
+
*
|
|
158
|
+
* Only available when the vybit's sendPermissions is set to 'subs_owner'.
|
|
159
|
+
* The subscription must be active (status='on') and granted access.
|
|
160
|
+
*
|
|
161
|
+
* @param followingKey - Vybit following key
|
|
162
|
+
* @param params - Notification content
|
|
163
|
+
* @returns Send response with log key
|
|
164
|
+
* @throws {VybitAPIError} 403 if vybit doesn't allow subscriber-to-owner sends
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const result = await client.sendToOwner('following123abc', {
|
|
169
|
+
* message: 'Server is back online',
|
|
170
|
+
* linkUrl: 'https://example.com/dashboard'
|
|
171
|
+
* });
|
|
172
|
+
* console.log('Notification sent, log key:', result.plk);
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
sendToOwner(followingKey: string, params?: SubscriberSendParams): Promise<SubscriberSendResponse>;
|
|
176
|
+
/**
|
|
177
|
+
* Send a notification to all subscribers of a vybit group
|
|
178
|
+
*
|
|
179
|
+
* Only available when the vybit's sendPermissions is set to 'subs_group'.
|
|
180
|
+
* The subscription must be active (status='on') and granted access.
|
|
181
|
+
*
|
|
182
|
+
* @param followingKey - Vybit following key
|
|
183
|
+
* @param params - Notification content
|
|
184
|
+
* @returns Send response with log key
|
|
185
|
+
* @throws {VybitAPIError} 403 if vybit doesn't allow subscriber-to-group sends
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const result = await client.sendToGroup('following123abc', {
|
|
190
|
+
* message: 'Emergency alert: Check the group chat',
|
|
191
|
+
* linkUrl: 'https://example.com/chat'
|
|
192
|
+
* });
|
|
193
|
+
* console.log('Notification sent to group, log key:', result.plk);
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
sendToGroup(followingKey: string, params?: SubscriberSendParams): Promise<SubscriberSendResponse>;
|
|
197
|
+
/**
|
|
198
|
+
* Search for sounds
|
|
199
|
+
* @param params - Pagination and search parameters
|
|
200
|
+
* @returns Array of sounds
|
|
201
|
+
*/
|
|
202
|
+
searchSounds(params?: SearchParams): Promise<Sound[]>;
|
|
203
|
+
/**
|
|
204
|
+
* Get a specific sound by key
|
|
205
|
+
* @param key - Sound key
|
|
206
|
+
* @returns Sound details
|
|
207
|
+
*/
|
|
208
|
+
getSound(key: string): Promise<Sound>;
|
|
209
|
+
/**
|
|
210
|
+
* Get the playback URL for a sound
|
|
211
|
+
* @param key - Sound key
|
|
212
|
+
* @returns Full URL to play/download the sound
|
|
213
|
+
*/
|
|
214
|
+
getSoundPlayUrl(key: string): string;
|
|
215
|
+
/**
|
|
216
|
+
* List all notification logs for the authenticated user
|
|
217
|
+
* @param params - Pagination and search parameters
|
|
218
|
+
* @returns Array of logs
|
|
219
|
+
*/
|
|
220
|
+
listLogs(params?: SearchParams): Promise<Log[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Get a specific log entry by key
|
|
223
|
+
* @param logKey - Log entry key
|
|
224
|
+
* @returns Log entry details
|
|
225
|
+
*/
|
|
226
|
+
getLog(logKey: string): Promise<Log>;
|
|
227
|
+
/**
|
|
228
|
+
* List logs for a specific owned vybit
|
|
229
|
+
* @param vybKey - Vybit key
|
|
230
|
+
* @param params - Pagination and search parameters
|
|
231
|
+
* @returns Array of logs for the vybit
|
|
232
|
+
*/
|
|
233
|
+
listVybitLogs(vybKey: string, params?: SearchParams): Promise<Log[]>;
|
|
234
|
+
/**
|
|
235
|
+
* List logs for a specific vybit subscription
|
|
236
|
+
* @param followingKey - Vybit following key
|
|
237
|
+
* @param params - Pagination and search parameters
|
|
238
|
+
* @returns Array of logs for the subscription
|
|
239
|
+
*/
|
|
240
|
+
listVybitFollowLogs(followingKey: string, params?: SearchParams): Promise<Log[]>;
|
|
241
|
+
/**
|
|
242
|
+
* List peeps (access invitations)
|
|
243
|
+
* @param params - Pagination parameters
|
|
244
|
+
* @returns Array of peeps
|
|
245
|
+
*/
|
|
246
|
+
listPeeps(params?: PaginationParams): Promise<Peep[]>;
|
|
247
|
+
/**
|
|
248
|
+
* Get a specific peep by key
|
|
249
|
+
* @param key - Peep key
|
|
250
|
+
* @returns Peep details
|
|
251
|
+
*/
|
|
252
|
+
getPeep(key: string): Promise<Peep>;
|
|
253
|
+
/**
|
|
254
|
+
* Create a peep invitation
|
|
255
|
+
* @param vybitKey - The vybit key to invite the user to
|
|
256
|
+
* @param email - Email address of the user to invite
|
|
257
|
+
* @returns Created peep response
|
|
258
|
+
*/
|
|
259
|
+
createPeep(vybitKey: string, email: string): Promise<any>;
|
|
260
|
+
/**
|
|
261
|
+
* Remove a peep invitation
|
|
262
|
+
* @param key - Peep key
|
|
263
|
+
* @returns Delete confirmation
|
|
264
|
+
*/
|
|
265
|
+
deletePeep(key: string): Promise<DeleteResponse>;
|
|
13
266
|
/**
|
|
14
|
-
*
|
|
267
|
+
* List peeps for a specific vybit
|
|
268
|
+
* @param vybitKey - Vybit key
|
|
269
|
+
* @param params - Pagination parameters
|
|
270
|
+
* @returns Array of peeps for the vybit
|
|
15
271
|
*/
|
|
16
|
-
|
|
272
|
+
listVybitPeeps(vybitKey: string, params?: PaginationParams): Promise<Peep[]>;
|
|
17
273
|
}
|
|
18
274
|
//# sourceMappingURL=api-client.d.ts.map
|
package/dist/api-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,OAAO,EACP,KAAK,EACL,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,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