@vybit/n8n-nodes-vybit 2.0.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.
|
@@ -0,0 +1,1789 @@
|
|
|
1
|
+
var dist$1 = {};
|
|
2
|
+
|
|
3
|
+
var apiClient = {};
|
|
4
|
+
|
|
5
|
+
var dist = {};
|
|
6
|
+
|
|
7
|
+
var types$1 = {};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(types$1, "__esModule", { value: true });
|
|
10
|
+
|
|
11
|
+
var utils = {};
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(utils, "__esModule", { value: true });
|
|
14
|
+
utils.isValidUrl = isValidUrl;
|
|
15
|
+
utils.generateRandomState = generateRandomState;
|
|
16
|
+
utils.buildQueryString = buildQueryString;
|
|
17
|
+
utils.getDefaultBaseUrl = getDefaultBaseUrl;
|
|
18
|
+
utils.getAuthDomain = getAuthDomain;
|
|
19
|
+
utils.getApiBaseUrl = getApiBaseUrl;
|
|
20
|
+
function isValidUrl(url) {
|
|
21
|
+
try {
|
|
22
|
+
const parsed = new URL(url);
|
|
23
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function generateRandomState(length = 12) {
|
|
29
|
+
let result = "";
|
|
30
|
+
while (result.length < length) {
|
|
31
|
+
result += Math.random().toString(36).substring(2);
|
|
32
|
+
}
|
|
33
|
+
return result.substring(0, length);
|
|
34
|
+
}
|
|
35
|
+
function buildQueryString(params) {
|
|
36
|
+
return new URLSearchParams(params).toString();
|
|
37
|
+
}
|
|
38
|
+
function getDefaultBaseUrl() {
|
|
39
|
+
return "https://vybit.net";
|
|
40
|
+
}
|
|
41
|
+
function getAuthDomain() {
|
|
42
|
+
return "https://app.vybit.net";
|
|
43
|
+
}
|
|
44
|
+
function getApiBaseUrl() {
|
|
45
|
+
return "https://api.vybit.net/v1";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var errors = {};
|
|
49
|
+
|
|
50
|
+
Object.defineProperty(errors, "__esModule", { value: true });
|
|
51
|
+
errors.VybitValidationError = errors.VybitAPIError = errors.VybitAuthError = errors.VybitSDKError = void 0;
|
|
52
|
+
class VybitSDKError extends Error {
|
|
53
|
+
constructor(message, code = "UNKNOWN_ERROR", details) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.name = "VybitSDKError";
|
|
56
|
+
this.code = code;
|
|
57
|
+
this.details = details;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
errors.VybitSDKError = VybitSDKError;
|
|
61
|
+
class VybitAuthError extends VybitSDKError {
|
|
62
|
+
constructor(message, statusCode, details) {
|
|
63
|
+
super(message, "AUTH_ERROR", details);
|
|
64
|
+
this.name = "VybitAuthError";
|
|
65
|
+
this.statusCode = statusCode;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
errors.VybitAuthError = VybitAuthError;
|
|
69
|
+
class VybitAPIError extends VybitSDKError {
|
|
70
|
+
constructor(message, statusCode, details) {
|
|
71
|
+
super(message, "API_ERROR", details);
|
|
72
|
+
this.name = "VybitAPIError";
|
|
73
|
+
this.statusCode = statusCode;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
errors.VybitAPIError = VybitAPIError;
|
|
77
|
+
class VybitValidationError extends VybitSDKError {
|
|
78
|
+
constructor(message, details) {
|
|
79
|
+
super(message, "VALIDATION_ERROR", details);
|
|
80
|
+
this.name = "VybitValidationError";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
errors.VybitValidationError = VybitValidationError;
|
|
84
|
+
|
|
85
|
+
(function (exports$1) {
|
|
86
|
+
var __createBinding = this && this.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
87
|
+
if (k2 === void 0) k2 = k;
|
|
88
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
89
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
90
|
+
desc = { enumerable: true, get: function() {
|
|
91
|
+
return m[k];
|
|
92
|
+
} };
|
|
93
|
+
}
|
|
94
|
+
Object.defineProperty(o, k2, desc);
|
|
95
|
+
}) : (function(o, m, k, k2) {
|
|
96
|
+
if (k2 === void 0) k2 = k;
|
|
97
|
+
o[k2] = m[k];
|
|
98
|
+
}));
|
|
99
|
+
var __exportStar = this && this.__exportStar || function(m, exports2) {
|
|
100
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
101
|
+
};
|
|
102
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
103
|
+
__exportStar(types$1, exports$1);
|
|
104
|
+
__exportStar(utils, exports$1);
|
|
105
|
+
__exportStar(errors, exports$1);
|
|
106
|
+
} (dist));
|
|
107
|
+
|
|
108
|
+
Object.defineProperty(apiClient, "__esModule", { value: true });
|
|
109
|
+
apiClient.VybitAPIClient = void 0;
|
|
110
|
+
const core_1 = dist;
|
|
111
|
+
class VybitAPIClient {
|
|
112
|
+
/**
|
|
113
|
+
* Creates a new Vybit Developer API client
|
|
114
|
+
* @param config - API configuration. If apiKey is not provided, falls back to VYBIT_API_KEY environment variable
|
|
115
|
+
* @throws {VybitValidationError} When API key is not provided and VYBIT_API_KEY environment variable is not set
|
|
116
|
+
*/
|
|
117
|
+
constructor(config = {}) {
|
|
118
|
+
const apiKey = config.apiKey || void 0;
|
|
119
|
+
if (!apiKey) {
|
|
120
|
+
throw new core_1.VybitValidationError("API key is required. Provide it in the config or set VYBIT_API_KEY environment variable");
|
|
121
|
+
}
|
|
122
|
+
this.apiKey = apiKey;
|
|
123
|
+
this.baseUrl = config.baseUrl || (0, core_1.getApiBaseUrl)();
|
|
124
|
+
}
|
|
125
|
+
async request(endpoint, options = {}) {
|
|
126
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
127
|
+
const headers = {
|
|
128
|
+
"X-API-Key": this.apiKey,
|
|
129
|
+
...options.headers
|
|
130
|
+
};
|
|
131
|
+
if (options.body && !headers["Content-Type"]) {
|
|
132
|
+
headers["Content-Type"] = "application/json";
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const response = await fetch(url, {
|
|
136
|
+
...options,
|
|
137
|
+
headers
|
|
138
|
+
});
|
|
139
|
+
if (!response.ok) {
|
|
140
|
+
if (response.status === 401) {
|
|
141
|
+
throw new core_1.VybitAuthError("Invalid or missing API key", response.status);
|
|
142
|
+
}
|
|
143
|
+
if (response.status === 429) {
|
|
144
|
+
throw new core_1.VybitAPIError("Rate limit exceeded", response.status);
|
|
145
|
+
}
|
|
146
|
+
const errorData = await response.json().catch(() => ({}));
|
|
147
|
+
if (response.status === 403 && errorData.error === "vybit_limit_reached") {
|
|
148
|
+
throw new core_1.VybitAPIError("Vybit limit reached for your tier. Delete existing vybits or upgrade your account.", response.status);
|
|
149
|
+
}
|
|
150
|
+
throw new core_1.VybitAPIError(errorData.message || errorData.error || `API request failed: ${response.statusText}`, response.status);
|
|
151
|
+
}
|
|
152
|
+
return await response.json();
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (error instanceof core_1.VybitAPIError || error instanceof core_1.VybitAuthError) {
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
throw new core_1.VybitAPIError(`Network error: ${error}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
buildQueryParams(params) {
|
|
161
|
+
if (!params)
|
|
162
|
+
return "";
|
|
163
|
+
const query = new URLSearchParams();
|
|
164
|
+
if (params.offset !== void 0)
|
|
165
|
+
query.append("offset", String(params.offset));
|
|
166
|
+
if (params.limit !== void 0)
|
|
167
|
+
query.append("limit", String(params.limit));
|
|
168
|
+
if ("search" in params && params.search)
|
|
169
|
+
query.append("search", params.search);
|
|
170
|
+
const queryString = query.toString();
|
|
171
|
+
return queryString ? `?${queryString}` : "";
|
|
172
|
+
}
|
|
173
|
+
// ==================== Status & Utility ====================
|
|
174
|
+
/**
|
|
175
|
+
* Check API health status
|
|
176
|
+
* @returns API status response
|
|
177
|
+
*/
|
|
178
|
+
async getStatus() {
|
|
179
|
+
return this.request("/status");
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get usage metrics and tier limits
|
|
183
|
+
* @returns Usage statistics and capacity limits
|
|
184
|
+
*/
|
|
185
|
+
async getMeter() {
|
|
186
|
+
return this.request("/meter");
|
|
187
|
+
}
|
|
188
|
+
// ==================== Profile ====================
|
|
189
|
+
/**
|
|
190
|
+
* Get user profile information
|
|
191
|
+
* @returns User profile data
|
|
192
|
+
*/
|
|
193
|
+
async getProfile() {
|
|
194
|
+
return this.request("/profile");
|
|
195
|
+
}
|
|
196
|
+
// ==================== Vybits ====================
|
|
197
|
+
/**
|
|
198
|
+
* List vybits owned by the authenticated user
|
|
199
|
+
* @param params - Pagination and search parameters
|
|
200
|
+
* @returns Array of vybits
|
|
201
|
+
*/
|
|
202
|
+
async listVybits(params) {
|
|
203
|
+
const query = this.buildQueryParams(params);
|
|
204
|
+
return this.request(`/vybits${query}`);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get a specific vybit by key
|
|
208
|
+
* @param key - Vybit key
|
|
209
|
+
* @returns Vybit details
|
|
210
|
+
*/
|
|
211
|
+
async getVybit(key) {
|
|
212
|
+
return this.request(`/vybit/${key}`);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Create a new vybit
|
|
216
|
+
* @param params - Vybit creation parameters
|
|
217
|
+
* @returns Created vybit
|
|
218
|
+
*/
|
|
219
|
+
async createVybit(params) {
|
|
220
|
+
return this.request("/vybit", {
|
|
221
|
+
method: "POST",
|
|
222
|
+
body: JSON.stringify(params)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Update a vybit (full update)
|
|
227
|
+
* @param key - Vybit key
|
|
228
|
+
* @param params - Vybit update parameters
|
|
229
|
+
* @returns Updated vybit
|
|
230
|
+
*/
|
|
231
|
+
async updateVybit(key, params) {
|
|
232
|
+
return this.request(`/vybit/${key}`, {
|
|
233
|
+
method: "PUT",
|
|
234
|
+
body: JSON.stringify(params)
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Update a vybit (partial update)
|
|
239
|
+
* @param key - Vybit key
|
|
240
|
+
* @param params - Vybit update parameters
|
|
241
|
+
* @returns Updated vybit
|
|
242
|
+
*/
|
|
243
|
+
async patchVybit(key, params) {
|
|
244
|
+
return this.request(`/vybit/${key}`, {
|
|
245
|
+
method: "PATCH",
|
|
246
|
+
body: JSON.stringify(params)
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Delete a vybit
|
|
251
|
+
* @param key - Vybit key
|
|
252
|
+
* @returns Delete confirmation
|
|
253
|
+
*/
|
|
254
|
+
async deleteVybit(key) {
|
|
255
|
+
return this.request(`/vybit/${key}`, {
|
|
256
|
+
method: "DELETE"
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Trigger a vybit notification as the owner
|
|
261
|
+
* @param key - Vybit key
|
|
262
|
+
* @param params - Optional notification content to override defaults
|
|
263
|
+
* @returns Trigger response with log key
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const result = await client.triggerVybit('vybit123abc', {
|
|
268
|
+
* message: 'Server maintenance complete',
|
|
269
|
+
* imageUrl: 'https://example.com/status-ok.jpg'
|
|
270
|
+
* });
|
|
271
|
+
* console.log('Notification triggered, log key:', result.plk);
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
async triggerVybit(key, params) {
|
|
275
|
+
return this.request(`/vybit/${key}/trigger`, {
|
|
276
|
+
method: "POST",
|
|
277
|
+
body: params ? JSON.stringify(params) : void 0
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
// ==================== Subscriptions ====================
|
|
281
|
+
/**
|
|
282
|
+
* List public vybits available for subscription
|
|
283
|
+
* @param params - Pagination and search parameters
|
|
284
|
+
* @returns Array of public vybits
|
|
285
|
+
*/
|
|
286
|
+
async listPublicVybits(params) {
|
|
287
|
+
const query = this.buildQueryParams(params);
|
|
288
|
+
return this.request(`/subscriptions/public${query}`);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Get a public vybit by subscription key
|
|
292
|
+
* @param key - Subscription key
|
|
293
|
+
* @returns Public vybit details
|
|
294
|
+
*/
|
|
295
|
+
async getPublicVybit(key) {
|
|
296
|
+
return this.request(`/subscription/${key}`);
|
|
297
|
+
}
|
|
298
|
+
// ==================== Vybit Subscriptions (Follows) ====================
|
|
299
|
+
/**
|
|
300
|
+
* List vybit subscriptions (follows)
|
|
301
|
+
* @param params - Pagination and search parameters
|
|
302
|
+
* @returns Array of vybit follows
|
|
303
|
+
*/
|
|
304
|
+
async listVybitFollows(params) {
|
|
305
|
+
const query = this.buildQueryParams(params);
|
|
306
|
+
return this.request(`/subscriptions/following${query}`);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Get a specific vybit follow by key
|
|
310
|
+
* @param key - Vybit follow (following) key
|
|
311
|
+
* @returns Vybit follow details
|
|
312
|
+
*/
|
|
313
|
+
async getVybitFollow(key) {
|
|
314
|
+
return this.request(`/subscription/following/${key}`);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Subscribe to a vybit using its subscription key
|
|
318
|
+
* @param subscriptionKey - The subscription key of the vybit to subscribe to
|
|
319
|
+
* @returns Created vybit follow
|
|
320
|
+
*/
|
|
321
|
+
async createVybitFollow(subscriptionKey) {
|
|
322
|
+
return this.request(`/subscription/${subscriptionKey}`, {
|
|
323
|
+
method: "POST"
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Update a vybit subscription
|
|
328
|
+
* @param key - Vybit follow (following) key
|
|
329
|
+
* @param params - Update parameters
|
|
330
|
+
* @returns Updated vybit follow
|
|
331
|
+
*/
|
|
332
|
+
async updateVybitFollow(key, params) {
|
|
333
|
+
return this.request(`/subscription/following/${key}`, {
|
|
334
|
+
method: "PATCH",
|
|
335
|
+
body: JSON.stringify(params)
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Unsubscribe from a vybit (delete follow)
|
|
340
|
+
* @param key - Vybit follow (following) key
|
|
341
|
+
* @returns Delete confirmation
|
|
342
|
+
*/
|
|
343
|
+
async deleteVybitFollow(key) {
|
|
344
|
+
return this.request(`/subscription/following/${key}`, {
|
|
345
|
+
method: "DELETE"
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Send a notification to the owner of a subscribed vybit
|
|
350
|
+
*
|
|
351
|
+
* Only available when the vybit's sendPermissions is set to 'subs_owner'.
|
|
352
|
+
* The subscription must be active (status='on') and granted access.
|
|
353
|
+
*
|
|
354
|
+
* @param followingKey - Vybit following key
|
|
355
|
+
* @param params - Notification content
|
|
356
|
+
* @returns Send response with log key
|
|
357
|
+
* @throws {VybitAPIError} 403 if vybit doesn't allow subscriber-to-owner sends
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```typescript
|
|
361
|
+
* const result = await client.sendToOwner('following123abc', {
|
|
362
|
+
* message: 'Server is back online',
|
|
363
|
+
* linkUrl: 'https://example.com/dashboard'
|
|
364
|
+
* });
|
|
365
|
+
* console.log('Notification sent, log key:', result.plk);
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
async sendToOwner(followingKey, params) {
|
|
369
|
+
return this.request(`/subscription/following/${followingKey}/send-to-owner`, {
|
|
370
|
+
method: "POST",
|
|
371
|
+
body: params ? JSON.stringify(params) : void 0
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Send a notification to all subscribers of a vybit group
|
|
376
|
+
*
|
|
377
|
+
* Only available when the vybit's sendPermissions is set to 'subs_group'.
|
|
378
|
+
* The subscription must be active (status='on') and granted access.
|
|
379
|
+
*
|
|
380
|
+
* @param followingKey - Vybit following key
|
|
381
|
+
* @param params - Notification content
|
|
382
|
+
* @returns Send response with log key
|
|
383
|
+
* @throws {VybitAPIError} 403 if vybit doesn't allow subscriber-to-group sends
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* const result = await client.sendToGroup('following123abc', {
|
|
388
|
+
* message: 'Emergency alert: Check the group chat',
|
|
389
|
+
* linkUrl: 'https://example.com/chat'
|
|
390
|
+
* });
|
|
391
|
+
* console.log('Notification sent to group, log key:', result.plk);
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
async sendToGroup(followingKey, params) {
|
|
395
|
+
return this.request(`/subscription/following/${followingKey}/send-to-group`, {
|
|
396
|
+
method: "POST",
|
|
397
|
+
body: params ? JSON.stringify(params) : void 0
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
// ==================== Sounds ====================
|
|
401
|
+
/**
|
|
402
|
+
* Search for sounds
|
|
403
|
+
* @param params - Pagination and search parameters
|
|
404
|
+
* @returns Array of sounds
|
|
405
|
+
*/
|
|
406
|
+
async searchSounds(params) {
|
|
407
|
+
const query = this.buildQueryParams(params);
|
|
408
|
+
return this.request(`/sounds${query}`);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Get a specific sound by key
|
|
412
|
+
* @param key - Sound key
|
|
413
|
+
* @returns Sound details
|
|
414
|
+
*/
|
|
415
|
+
async getSound(key) {
|
|
416
|
+
return this.request(`/sound/${key}`);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Get the playback URL for a sound
|
|
420
|
+
* @param key - Sound key
|
|
421
|
+
* @returns Full URL to play/download the sound
|
|
422
|
+
*/
|
|
423
|
+
getSoundPlayUrl(key) {
|
|
424
|
+
return `${this.baseUrl}/sound/${key}/play`;
|
|
425
|
+
}
|
|
426
|
+
// ==================== Logs ====================
|
|
427
|
+
/**
|
|
428
|
+
* List all notification logs for the authenticated user
|
|
429
|
+
* @param params - Pagination and search parameters
|
|
430
|
+
* @returns Array of logs
|
|
431
|
+
*/
|
|
432
|
+
async listLogs(params) {
|
|
433
|
+
const query = this.buildQueryParams(params);
|
|
434
|
+
return this.request(`/logs${query}`);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Get a specific log entry by key
|
|
438
|
+
* @param logKey - Log entry key
|
|
439
|
+
* @returns Log entry details
|
|
440
|
+
*/
|
|
441
|
+
async getLog(logKey) {
|
|
442
|
+
return this.request(`/log/${logKey}`);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* List logs for a specific owned vybit
|
|
446
|
+
* @param vybKey - Vybit key
|
|
447
|
+
* @param params - Pagination and search parameters
|
|
448
|
+
* @returns Array of logs for the vybit
|
|
449
|
+
*/
|
|
450
|
+
async listVybitLogs(vybKey, params) {
|
|
451
|
+
const query = this.buildQueryParams(params);
|
|
452
|
+
return this.request(`/logs/vybit/${vybKey}${query}`);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* List logs for a specific vybit subscription
|
|
456
|
+
* @param followingKey - Vybit following key
|
|
457
|
+
* @param params - Pagination and search parameters
|
|
458
|
+
* @returns Array of logs for the subscription
|
|
459
|
+
*/
|
|
460
|
+
async listVybitFollowLogs(followingKey, params) {
|
|
461
|
+
const query = this.buildQueryParams(params);
|
|
462
|
+
return this.request(`/logs/subscription/following/${followingKey}${query}`);
|
|
463
|
+
}
|
|
464
|
+
// ==================== Peeps ====================
|
|
465
|
+
/**
|
|
466
|
+
* List peeps (access invitations)
|
|
467
|
+
* @param params - Pagination and search parameters
|
|
468
|
+
* @returns Array of peeps
|
|
469
|
+
*/
|
|
470
|
+
async listPeeps(params) {
|
|
471
|
+
const query = this.buildQueryParams(params);
|
|
472
|
+
return this.request(`/peeps${query}`);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Get a specific peep by key
|
|
476
|
+
* @param key - Peep key
|
|
477
|
+
* @returns Peep details
|
|
478
|
+
*/
|
|
479
|
+
async getPeep(key) {
|
|
480
|
+
return this.request(`/peep/${key}`);
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Create a peep invitation
|
|
484
|
+
* @param vybitKey - The vybit key to invite the user to
|
|
485
|
+
* @param email - Email address of the user to invite
|
|
486
|
+
* @returns Created peep response
|
|
487
|
+
*/
|
|
488
|
+
async createPeep(vybitKey, email) {
|
|
489
|
+
return this.request(`/peep/${vybitKey}`, {
|
|
490
|
+
method: "POST",
|
|
491
|
+
body: JSON.stringify({ email })
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Remove a peep invitation
|
|
496
|
+
* @param key - Peep key
|
|
497
|
+
* @returns Delete confirmation
|
|
498
|
+
*/
|
|
499
|
+
async deletePeep(key) {
|
|
500
|
+
return this.request(`/peep/${key}`, {
|
|
501
|
+
method: "DELETE"
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* List peeps for a specific vybit
|
|
506
|
+
* @param vybitKey - Vybit key
|
|
507
|
+
* @param params - Pagination and search parameters
|
|
508
|
+
* @returns Array of peeps for the vybit
|
|
509
|
+
*/
|
|
510
|
+
async listVybitPeeps(vybitKey, params) {
|
|
511
|
+
const query = this.buildQueryParams(params);
|
|
512
|
+
return this.request(`/peeps/${vybitKey}${query}`);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
apiClient.VybitAPIClient = VybitAPIClient;
|
|
516
|
+
|
|
517
|
+
var types = {};
|
|
518
|
+
|
|
519
|
+
Object.defineProperty(types, "__esModule", { value: true });
|
|
520
|
+
|
|
521
|
+
(function (exports$1) {
|
|
522
|
+
var __createBinding = this && this.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
523
|
+
if (k2 === void 0) k2 = k;
|
|
524
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
525
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
526
|
+
desc = { enumerable: true, get: function() {
|
|
527
|
+
return m[k];
|
|
528
|
+
} };
|
|
529
|
+
}
|
|
530
|
+
Object.defineProperty(o, k2, desc);
|
|
531
|
+
}) : (function(o, m, k, k2) {
|
|
532
|
+
if (k2 === void 0) k2 = k;
|
|
533
|
+
o[k2] = m[k];
|
|
534
|
+
}));
|
|
535
|
+
var __exportStar = this && this.__exportStar || function(m, exports2) {
|
|
536
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
537
|
+
};
|
|
538
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
539
|
+
__exportStar(apiClient, exports$1);
|
|
540
|
+
__exportStar(types, exports$1);
|
|
541
|
+
} (dist$1));
|
|
542
|
+
|
|
543
|
+
class Vybit {
|
|
544
|
+
constructor() {
|
|
545
|
+
this.description = {
|
|
546
|
+
displayName: "Vybit Push Notifications",
|
|
547
|
+
name: "vybit",
|
|
548
|
+
icon: "file:vybit.png",
|
|
549
|
+
group: ["transform"],
|
|
550
|
+
version: 1,
|
|
551
|
+
subtitle: '={{$parameter["actionType"]}}',
|
|
552
|
+
description: "Send notifications with personalized sounds",
|
|
553
|
+
defaults: {
|
|
554
|
+
name: "Vybit Push Notifications"
|
|
555
|
+
},
|
|
556
|
+
inputs: ["main"],
|
|
557
|
+
outputs: ["main"],
|
|
558
|
+
codex: {
|
|
559
|
+
categories: ["Communication"],
|
|
560
|
+
subcategories: {
|
|
561
|
+
Communication: ["Notifications"]
|
|
562
|
+
},
|
|
563
|
+
resources: {
|
|
564
|
+
primaryDocumentation: [
|
|
565
|
+
{
|
|
566
|
+
url: "https://developer.vybit.net"
|
|
567
|
+
}
|
|
568
|
+
]
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
credentials: [
|
|
572
|
+
{
|
|
573
|
+
name: "vybitOAuth2Api",
|
|
574
|
+
required: true,
|
|
575
|
+
displayOptions: {
|
|
576
|
+
show: {
|
|
577
|
+
authentication: ["oAuth2"]
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
name: "vybitApi",
|
|
583
|
+
required: true,
|
|
584
|
+
displayOptions: {
|
|
585
|
+
show: {
|
|
586
|
+
authentication: ["apiKey"]
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
],
|
|
591
|
+
properties: [
|
|
592
|
+
// Authentication selection FIRST
|
|
593
|
+
{
|
|
594
|
+
displayName: "Authentication",
|
|
595
|
+
name: "authentication",
|
|
596
|
+
type: "options",
|
|
597
|
+
noDataExpression: true,
|
|
598
|
+
options: [
|
|
599
|
+
{
|
|
600
|
+
name: "OAuth2",
|
|
601
|
+
value: "oAuth2",
|
|
602
|
+
description: "Connect your Vybit account (recommended for notifications)"
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
name: "API Key",
|
|
606
|
+
value: "apiKey",
|
|
607
|
+
description: "Developer API key (advanced features)"
|
|
608
|
+
}
|
|
609
|
+
],
|
|
610
|
+
default: "oAuth2"
|
|
611
|
+
},
|
|
612
|
+
// Action Type for OAuth2 - just notification
|
|
613
|
+
{
|
|
614
|
+
displayName: "Action Type",
|
|
615
|
+
name: "actionType",
|
|
616
|
+
type: "hidden",
|
|
617
|
+
displayOptions: {
|
|
618
|
+
show: {
|
|
619
|
+
authentication: ["oAuth2"]
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
default: "notification"
|
|
623
|
+
},
|
|
624
|
+
// Action Type for API Key - all options
|
|
625
|
+
{
|
|
626
|
+
displayName: "Resource",
|
|
627
|
+
name: "actionType",
|
|
628
|
+
type: "options",
|
|
629
|
+
noDataExpression: true,
|
|
630
|
+
displayOptions: {
|
|
631
|
+
show: {
|
|
632
|
+
authentication: ["apiKey"]
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
options: [
|
|
636
|
+
{
|
|
637
|
+
name: "Profile",
|
|
638
|
+
value: "profile",
|
|
639
|
+
description: "View profile and usage metrics",
|
|
640
|
+
action: "View profile"
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
name: "Vybits",
|
|
644
|
+
value: "vybits",
|
|
645
|
+
description: "Manage vybits (custom notifications)",
|
|
646
|
+
action: "Manage vybits"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
name: "Logs",
|
|
650
|
+
value: "logs",
|
|
651
|
+
description: "View notification logs",
|
|
652
|
+
action: "View logs"
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
name: "Sounds",
|
|
656
|
+
value: "sounds",
|
|
657
|
+
description: "Search and manage sounds",
|
|
658
|
+
action: "Manage sounds"
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: "Peeps",
|
|
662
|
+
value: "peeps",
|
|
663
|
+
description: "Manage vybit invitations",
|
|
664
|
+
action: "Manage peeps"
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
name: "Subscriptions",
|
|
668
|
+
value: "subscriptions",
|
|
669
|
+
description: "Manage vybit subscriptions",
|
|
670
|
+
action: "Manage subscriptions"
|
|
671
|
+
}
|
|
672
|
+
],
|
|
673
|
+
default: "vybits"
|
|
674
|
+
},
|
|
675
|
+
// Notification operation (OAuth2) - simplified, just pick vybit
|
|
676
|
+
{
|
|
677
|
+
displayName: "Vybit",
|
|
678
|
+
name: "triggerKey",
|
|
679
|
+
type: "options",
|
|
680
|
+
typeOptions: {
|
|
681
|
+
loadOptionsMethod: "getVybits"
|
|
682
|
+
},
|
|
683
|
+
required: true,
|
|
684
|
+
displayOptions: {
|
|
685
|
+
show: {
|
|
686
|
+
actionType: ["notification"]
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
default: "",
|
|
690
|
+
description: "Select which vybit to trigger"
|
|
691
|
+
},
|
|
692
|
+
// ===== PROFILE OPERATIONS =====
|
|
693
|
+
{
|
|
694
|
+
displayName: "Operation",
|
|
695
|
+
name: "apiOperation",
|
|
696
|
+
type: "options",
|
|
697
|
+
noDataExpression: true,
|
|
698
|
+
displayOptions: {
|
|
699
|
+
show: {
|
|
700
|
+
actionType: ["profile"]
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
options: [
|
|
704
|
+
{
|
|
705
|
+
name: "Get Profile",
|
|
706
|
+
value: "getProfile",
|
|
707
|
+
description: "Get user profile information"
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
name: "Get Usage Metrics",
|
|
711
|
+
value: "getMeter",
|
|
712
|
+
description: "Get current usage statistics and tier limits"
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
name: "Check API Status",
|
|
716
|
+
value: "getStatus",
|
|
717
|
+
description: "Check API service health and availability"
|
|
718
|
+
}
|
|
719
|
+
],
|
|
720
|
+
default: "getProfile"
|
|
721
|
+
},
|
|
722
|
+
// ===== VYBITS OPERATIONS =====
|
|
723
|
+
{
|
|
724
|
+
displayName: "Operation",
|
|
725
|
+
name: "apiOperation",
|
|
726
|
+
type: "options",
|
|
727
|
+
noDataExpression: true,
|
|
728
|
+
displayOptions: {
|
|
729
|
+
show: {
|
|
730
|
+
actionType: ["vybits"]
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
options: [
|
|
734
|
+
{
|
|
735
|
+
name: "List",
|
|
736
|
+
value: "list",
|
|
737
|
+
description: "Get a list of your vybits"
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
name: "Get",
|
|
741
|
+
value: "get",
|
|
742
|
+
description: "Get details of a specific vybit"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
name: "Create",
|
|
746
|
+
value: "create",
|
|
747
|
+
description: "Create a new vybit"
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
name: "Update",
|
|
751
|
+
value: "update",
|
|
752
|
+
description: "Update an existing vybit"
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
name: "Delete",
|
|
756
|
+
value: "delete",
|
|
757
|
+
description: "Delete a vybit"
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
name: "Trigger",
|
|
761
|
+
value: "trigger",
|
|
762
|
+
description: "Trigger a vybit notification"
|
|
763
|
+
}
|
|
764
|
+
],
|
|
765
|
+
default: "list"
|
|
766
|
+
},
|
|
767
|
+
// ===== SUBSCRIPTIONS OPERATIONS =====
|
|
768
|
+
{
|
|
769
|
+
displayName: "Operation",
|
|
770
|
+
name: "apiOperation",
|
|
771
|
+
type: "options",
|
|
772
|
+
noDataExpression: true,
|
|
773
|
+
displayOptions: {
|
|
774
|
+
show: {
|
|
775
|
+
actionType: ["subscriptions"]
|
|
776
|
+
}
|
|
777
|
+
},
|
|
778
|
+
options: [
|
|
779
|
+
{
|
|
780
|
+
name: "List Public Vybits",
|
|
781
|
+
value: "listPublic",
|
|
782
|
+
description: "Browse publicly available vybits"
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
name: "Get Public Vybit",
|
|
786
|
+
value: "getPublic",
|
|
787
|
+
description: "Get details of a public vybit"
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
name: "Subscribe",
|
|
791
|
+
value: "subscribe",
|
|
792
|
+
description: "Subscribe to a vybit"
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
name: "List My Subscriptions",
|
|
796
|
+
value: "listSubscriptions",
|
|
797
|
+
description: "Get list of vybits you subscribe to"
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
name: "Get Subscription",
|
|
801
|
+
value: "getSubscription",
|
|
802
|
+
description: "Get details of a subscription"
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
name: "Update Subscription",
|
|
806
|
+
value: "updateSubscription",
|
|
807
|
+
description: "Update subscription settings"
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
name: "Unsubscribe",
|
|
811
|
+
value: "unsubscribe",
|
|
812
|
+
description: "Unsubscribe from a vybit"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
name: "Send to Owner",
|
|
816
|
+
value: "sendToOwner",
|
|
817
|
+
description: "Send notification to vybit owner"
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
name: "Send to Group",
|
|
821
|
+
value: "sendToGroup",
|
|
822
|
+
description: "Send notification to all subscribers"
|
|
823
|
+
}
|
|
824
|
+
],
|
|
825
|
+
default: "listPublic"
|
|
826
|
+
},
|
|
827
|
+
// ===== SOUNDS OPERATIONS =====
|
|
828
|
+
{
|
|
829
|
+
displayName: "Operation",
|
|
830
|
+
name: "apiOperation",
|
|
831
|
+
type: "options",
|
|
832
|
+
noDataExpression: true,
|
|
833
|
+
displayOptions: {
|
|
834
|
+
show: {
|
|
835
|
+
actionType: ["sounds"]
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
options: [
|
|
839
|
+
{
|
|
840
|
+
name: "Search",
|
|
841
|
+
value: "search",
|
|
842
|
+
description: "Search for sounds"
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
name: "Get",
|
|
846
|
+
value: "get",
|
|
847
|
+
description: "Get sound details"
|
|
848
|
+
}
|
|
849
|
+
],
|
|
850
|
+
default: "search"
|
|
851
|
+
},
|
|
852
|
+
// ===== LOGS OPERATIONS =====
|
|
853
|
+
{
|
|
854
|
+
displayName: "Operation",
|
|
855
|
+
name: "apiOperation",
|
|
856
|
+
type: "options",
|
|
857
|
+
noDataExpression: true,
|
|
858
|
+
displayOptions: {
|
|
859
|
+
show: {
|
|
860
|
+
actionType: ["logs"]
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
options: [
|
|
864
|
+
{
|
|
865
|
+
name: "List All",
|
|
866
|
+
value: "listAll",
|
|
867
|
+
description: "List all notification logs"
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
name: "Get",
|
|
871
|
+
value: "get",
|
|
872
|
+
description: "Get a specific log entry"
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
name: "List by Vybit",
|
|
876
|
+
value: "listByVybit",
|
|
877
|
+
description: "List logs for a specific vybit"
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
name: "List by Subscription",
|
|
881
|
+
value: "listBySubscription",
|
|
882
|
+
description: "List logs for a specific subscription"
|
|
883
|
+
}
|
|
884
|
+
],
|
|
885
|
+
default: "listAll"
|
|
886
|
+
},
|
|
887
|
+
// ===== PEEPS OPERATIONS =====
|
|
888
|
+
{
|
|
889
|
+
displayName: "Operation",
|
|
890
|
+
name: "apiOperation",
|
|
891
|
+
type: "options",
|
|
892
|
+
noDataExpression: true,
|
|
893
|
+
displayOptions: {
|
|
894
|
+
show: {
|
|
895
|
+
actionType: ["peeps"]
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
options: [
|
|
899
|
+
{
|
|
900
|
+
name: "List All",
|
|
901
|
+
value: "listAll",
|
|
902
|
+
description: "List all peep invitations"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
name: "List by Vybit",
|
|
906
|
+
value: "listByVybit",
|
|
907
|
+
description: "List peeps for a specific vybit"
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
name: "Invite",
|
|
911
|
+
value: "create",
|
|
912
|
+
description: "Invite a user to a vybit"
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
name: "Get",
|
|
916
|
+
value: "get",
|
|
917
|
+
description: "Get peep details"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
name: "Delete",
|
|
921
|
+
value: "delete",
|
|
922
|
+
description: "Remove a peep invitation"
|
|
923
|
+
}
|
|
924
|
+
],
|
|
925
|
+
default: "listAll"
|
|
926
|
+
},
|
|
927
|
+
// ===== COMMON PARAMETER FIELDS =====
|
|
928
|
+
// Vybit Key (used by vybits, logs, peeps resources)
|
|
929
|
+
{
|
|
930
|
+
displayName: "Vybit Key",
|
|
931
|
+
name: "vybitKey",
|
|
932
|
+
type: "string",
|
|
933
|
+
required: true,
|
|
934
|
+
displayOptions: {
|
|
935
|
+
show: {
|
|
936
|
+
actionType: ["vybits"],
|
|
937
|
+
apiOperation: ["get", "trigger", "update", "delete"]
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
default: "",
|
|
941
|
+
description: "The unique key of the vybit"
|
|
942
|
+
},
|
|
943
|
+
// Vybit Key for logs
|
|
944
|
+
{
|
|
945
|
+
displayName: "Vybit Key",
|
|
946
|
+
name: "vybitKey",
|
|
947
|
+
type: "string",
|
|
948
|
+
required: true,
|
|
949
|
+
displayOptions: {
|
|
950
|
+
show: {
|
|
951
|
+
actionType: ["logs"],
|
|
952
|
+
apiOperation: ["listByVybit"]
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
default: "",
|
|
956
|
+
description: "The unique key of the vybit"
|
|
957
|
+
},
|
|
958
|
+
// Vybit Key for peeps
|
|
959
|
+
{
|
|
960
|
+
displayName: "Vybit Key",
|
|
961
|
+
name: "vybitKey",
|
|
962
|
+
type: "string",
|
|
963
|
+
required: true,
|
|
964
|
+
displayOptions: {
|
|
965
|
+
show: {
|
|
966
|
+
actionType: ["peeps"],
|
|
967
|
+
apiOperation: ["listByVybit"]
|
|
968
|
+
}
|
|
969
|
+
},
|
|
970
|
+
default: "",
|
|
971
|
+
description: "The unique key of the vybit"
|
|
972
|
+
},
|
|
973
|
+
// Subscription Key
|
|
974
|
+
{
|
|
975
|
+
displayName: "Subscription Key",
|
|
976
|
+
name: "subscriptionKey",
|
|
977
|
+
type: "string",
|
|
978
|
+
required: true,
|
|
979
|
+
displayOptions: {
|
|
980
|
+
show: {
|
|
981
|
+
actionType: ["subscriptions"],
|
|
982
|
+
apiOperation: ["getPublic", "subscribe"]
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
default: "",
|
|
986
|
+
description: "The unique key of the subscription"
|
|
987
|
+
},
|
|
988
|
+
// Following Key (for subscription management)
|
|
989
|
+
{
|
|
990
|
+
displayName: "Following Key",
|
|
991
|
+
name: "followingKey",
|
|
992
|
+
type: "string",
|
|
993
|
+
required: true,
|
|
994
|
+
displayOptions: {
|
|
995
|
+
show: {
|
|
996
|
+
actionType: ["subscriptions"],
|
|
997
|
+
apiOperation: ["getSubscription", "updateSubscription", "unsubscribe", "sendToOwner", "sendToGroup"]
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
default: "",
|
|
1001
|
+
description: "The unique key of the subscription following"
|
|
1002
|
+
},
|
|
1003
|
+
// Following Key for logs
|
|
1004
|
+
{
|
|
1005
|
+
displayName: "Following Key",
|
|
1006
|
+
name: "followingKey",
|
|
1007
|
+
type: "string",
|
|
1008
|
+
required: true,
|
|
1009
|
+
displayOptions: {
|
|
1010
|
+
show: {
|
|
1011
|
+
actionType: ["logs"],
|
|
1012
|
+
apiOperation: ["listBySubscription"]
|
|
1013
|
+
}
|
|
1014
|
+
},
|
|
1015
|
+
default: "",
|
|
1016
|
+
description: "The unique key of the subscription following"
|
|
1017
|
+
},
|
|
1018
|
+
// Sound Key
|
|
1019
|
+
{
|
|
1020
|
+
displayName: "Sound Key",
|
|
1021
|
+
name: "soundKey",
|
|
1022
|
+
type: "string",
|
|
1023
|
+
required: true,
|
|
1024
|
+
displayOptions: {
|
|
1025
|
+
show: {
|
|
1026
|
+
actionType: ["sounds"],
|
|
1027
|
+
apiOperation: ["get"]
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
default: "",
|
|
1031
|
+
description: "The unique key of the sound"
|
|
1032
|
+
},
|
|
1033
|
+
// Log Key
|
|
1034
|
+
{
|
|
1035
|
+
displayName: "Log Key",
|
|
1036
|
+
name: "logKey",
|
|
1037
|
+
type: "string",
|
|
1038
|
+
required: true,
|
|
1039
|
+
displayOptions: {
|
|
1040
|
+
show: {
|
|
1041
|
+
actionType: ["logs"],
|
|
1042
|
+
apiOperation: ["get"]
|
|
1043
|
+
}
|
|
1044
|
+
},
|
|
1045
|
+
default: "",
|
|
1046
|
+
description: "The unique key of the log entry"
|
|
1047
|
+
},
|
|
1048
|
+
// Peep Key
|
|
1049
|
+
{
|
|
1050
|
+
displayName: "Peep Key",
|
|
1051
|
+
name: "peepKey",
|
|
1052
|
+
type: "string",
|
|
1053
|
+
required: true,
|
|
1054
|
+
displayOptions: {
|
|
1055
|
+
show: {
|
|
1056
|
+
actionType: ["peeps"],
|
|
1057
|
+
apiOperation: ["get", "delete"]
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
default: "",
|
|
1061
|
+
description: "The unique key of the peep"
|
|
1062
|
+
},
|
|
1063
|
+
// ===== LIST/SEARCH OPTIONS =====
|
|
1064
|
+
// Options for vybits list
|
|
1065
|
+
{
|
|
1066
|
+
displayName: "Options",
|
|
1067
|
+
name: "options",
|
|
1068
|
+
type: "collection",
|
|
1069
|
+
placeholder: "Add Option",
|
|
1070
|
+
displayOptions: {
|
|
1071
|
+
show: {
|
|
1072
|
+
actionType: ["vybits"],
|
|
1073
|
+
apiOperation: ["list"]
|
|
1074
|
+
}
|
|
1075
|
+
},
|
|
1076
|
+
default: {},
|
|
1077
|
+
options: [
|
|
1078
|
+
{
|
|
1079
|
+
displayName: "Search",
|
|
1080
|
+
name: "search",
|
|
1081
|
+
type: "string",
|
|
1082
|
+
default: "",
|
|
1083
|
+
description: "Search vybits by name"
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
displayName: "Limit",
|
|
1087
|
+
name: "limit",
|
|
1088
|
+
type: "number",
|
|
1089
|
+
default: 30,
|
|
1090
|
+
description: "Max number of results to return"
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
displayName: "Offset",
|
|
1094
|
+
name: "offset",
|
|
1095
|
+
type: "number",
|
|
1096
|
+
default: 0,
|
|
1097
|
+
description: "Number of results to skip"
|
|
1098
|
+
}
|
|
1099
|
+
]
|
|
1100
|
+
},
|
|
1101
|
+
// Options for sounds search
|
|
1102
|
+
{
|
|
1103
|
+
displayName: "Options",
|
|
1104
|
+
name: "options",
|
|
1105
|
+
type: "collection",
|
|
1106
|
+
placeholder: "Add Option",
|
|
1107
|
+
displayOptions: {
|
|
1108
|
+
show: {
|
|
1109
|
+
actionType: ["sounds"],
|
|
1110
|
+
apiOperation: ["search"]
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
default: {},
|
|
1114
|
+
options: [
|
|
1115
|
+
{
|
|
1116
|
+
displayName: "Search",
|
|
1117
|
+
name: "search",
|
|
1118
|
+
type: "string",
|
|
1119
|
+
default: "",
|
|
1120
|
+
description: "Search sounds by name or description"
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
displayName: "Limit",
|
|
1124
|
+
name: "limit",
|
|
1125
|
+
type: "number",
|
|
1126
|
+
default: 30,
|
|
1127
|
+
description: "Max number of results to return"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
displayName: "Offset",
|
|
1131
|
+
name: "offset",
|
|
1132
|
+
type: "number",
|
|
1133
|
+
default: 0,
|
|
1134
|
+
description: "Number of results to skip"
|
|
1135
|
+
}
|
|
1136
|
+
]
|
|
1137
|
+
},
|
|
1138
|
+
// Options for subscriptions list public
|
|
1139
|
+
{
|
|
1140
|
+
displayName: "Options",
|
|
1141
|
+
name: "options",
|
|
1142
|
+
type: "collection",
|
|
1143
|
+
placeholder: "Add Option",
|
|
1144
|
+
displayOptions: {
|
|
1145
|
+
show: {
|
|
1146
|
+
actionType: ["subscriptions"],
|
|
1147
|
+
apiOperation: ["listPublic", "listSubscriptions"]
|
|
1148
|
+
}
|
|
1149
|
+
},
|
|
1150
|
+
default: {},
|
|
1151
|
+
options: [
|
|
1152
|
+
{
|
|
1153
|
+
displayName: "Search",
|
|
1154
|
+
name: "search",
|
|
1155
|
+
type: "string",
|
|
1156
|
+
default: "",
|
|
1157
|
+
description: "Search by name"
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
displayName: "Limit",
|
|
1161
|
+
name: "limit",
|
|
1162
|
+
type: "number",
|
|
1163
|
+
default: 30,
|
|
1164
|
+
description: "Max number of results to return"
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
displayName: "Offset",
|
|
1168
|
+
name: "offset",
|
|
1169
|
+
type: "number",
|
|
1170
|
+
default: 0,
|
|
1171
|
+
description: "Number of results to skip"
|
|
1172
|
+
}
|
|
1173
|
+
]
|
|
1174
|
+
},
|
|
1175
|
+
// Options for logs list
|
|
1176
|
+
{
|
|
1177
|
+
displayName: "Options",
|
|
1178
|
+
name: "options",
|
|
1179
|
+
type: "collection",
|
|
1180
|
+
placeholder: "Add Option",
|
|
1181
|
+
displayOptions: {
|
|
1182
|
+
show: {
|
|
1183
|
+
actionType: ["logs"],
|
|
1184
|
+
apiOperation: ["listAll", "listByVybit", "listBySubscription"]
|
|
1185
|
+
}
|
|
1186
|
+
},
|
|
1187
|
+
default: {},
|
|
1188
|
+
options: [
|
|
1189
|
+
{
|
|
1190
|
+
displayName: "Search",
|
|
1191
|
+
name: "search",
|
|
1192
|
+
type: "string",
|
|
1193
|
+
default: "",
|
|
1194
|
+
description: "Search logs by vybit name or diagnostic fields"
|
|
1195
|
+
},
|
|
1196
|
+
{
|
|
1197
|
+
displayName: "Limit",
|
|
1198
|
+
name: "limit",
|
|
1199
|
+
type: "number",
|
|
1200
|
+
default: 30,
|
|
1201
|
+
description: "Max number of results to return"
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
displayName: "Offset",
|
|
1205
|
+
name: "offset",
|
|
1206
|
+
type: "number",
|
|
1207
|
+
default: 0,
|
|
1208
|
+
description: "Number of results to skip"
|
|
1209
|
+
}
|
|
1210
|
+
]
|
|
1211
|
+
},
|
|
1212
|
+
// Options for peeps list
|
|
1213
|
+
{
|
|
1214
|
+
displayName: "Options",
|
|
1215
|
+
name: "options",
|
|
1216
|
+
type: "collection",
|
|
1217
|
+
placeholder: "Add Option",
|
|
1218
|
+
displayOptions: {
|
|
1219
|
+
show: {
|
|
1220
|
+
actionType: ["peeps"],
|
|
1221
|
+
apiOperation: ["listAll", "listByVybit"]
|
|
1222
|
+
}
|
|
1223
|
+
},
|
|
1224
|
+
default: {},
|
|
1225
|
+
options: [
|
|
1226
|
+
{
|
|
1227
|
+
displayName: "Search",
|
|
1228
|
+
name: "search",
|
|
1229
|
+
type: "string",
|
|
1230
|
+
default: "",
|
|
1231
|
+
description: "Search peeps by name"
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
displayName: "Limit",
|
|
1235
|
+
name: "limit",
|
|
1236
|
+
type: "number",
|
|
1237
|
+
default: 30,
|
|
1238
|
+
description: "Max number of results to return"
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
displayName: "Offset",
|
|
1242
|
+
name: "offset",
|
|
1243
|
+
type: "number",
|
|
1244
|
+
default: 0,
|
|
1245
|
+
description: "Number of results to skip"
|
|
1246
|
+
}
|
|
1247
|
+
]
|
|
1248
|
+
},
|
|
1249
|
+
// Notification parameters (OAuth2)
|
|
1250
|
+
{
|
|
1251
|
+
displayName: "Additional Fields",
|
|
1252
|
+
name: "additionalFields",
|
|
1253
|
+
type: "collection",
|
|
1254
|
+
placeholder: "Add Field",
|
|
1255
|
+
displayOptions: {
|
|
1256
|
+
show: {
|
|
1257
|
+
actionType: ["notification"]
|
|
1258
|
+
}
|
|
1259
|
+
},
|
|
1260
|
+
default: {},
|
|
1261
|
+
options: [
|
|
1262
|
+
{
|
|
1263
|
+
displayName: "Message",
|
|
1264
|
+
name: "message",
|
|
1265
|
+
type: "string",
|
|
1266
|
+
default: "",
|
|
1267
|
+
description: "Optional message to display with notification"
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
displayName: "Image URL",
|
|
1271
|
+
name: "image",
|
|
1272
|
+
type: "string",
|
|
1273
|
+
default: "",
|
|
1274
|
+
description: "Optional image URL to attach to notification"
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
displayName: "Link URL",
|
|
1278
|
+
name: "link",
|
|
1279
|
+
type: "string",
|
|
1280
|
+
default: "",
|
|
1281
|
+
description: "Optional redirect URL when notification is tapped"
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
displayName: "Log",
|
|
1285
|
+
name: "log",
|
|
1286
|
+
type: "string",
|
|
1287
|
+
default: "",
|
|
1288
|
+
description: "Optional content to append to the vybit log"
|
|
1289
|
+
}
|
|
1290
|
+
]
|
|
1291
|
+
},
|
|
1292
|
+
// Trigger parameters for Developer API
|
|
1293
|
+
{
|
|
1294
|
+
displayName: "Additional Fields",
|
|
1295
|
+
name: "additionalFields",
|
|
1296
|
+
type: "collection",
|
|
1297
|
+
placeholder: "Add Field",
|
|
1298
|
+
displayOptions: {
|
|
1299
|
+
show: {
|
|
1300
|
+
actionType: ["vybits"],
|
|
1301
|
+
apiOperation: ["trigger"]
|
|
1302
|
+
}
|
|
1303
|
+
},
|
|
1304
|
+
default: {},
|
|
1305
|
+
options: [
|
|
1306
|
+
{
|
|
1307
|
+
displayName: "Message",
|
|
1308
|
+
name: "message",
|
|
1309
|
+
type: "string",
|
|
1310
|
+
default: "",
|
|
1311
|
+
description: "Optional message to display with notification"
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
displayName: "Image URL",
|
|
1315
|
+
name: "image",
|
|
1316
|
+
type: "string",
|
|
1317
|
+
default: "",
|
|
1318
|
+
description: "Optional image URL to attach to notification"
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
displayName: "Link URL",
|
|
1322
|
+
name: "link",
|
|
1323
|
+
type: "string",
|
|
1324
|
+
default: "",
|
|
1325
|
+
description: "Optional redirect URL when notification is tapped"
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
displayName: "Log",
|
|
1329
|
+
name: "log",
|
|
1330
|
+
type: "string",
|
|
1331
|
+
default: "",
|
|
1332
|
+
description: "Optional content to append to the vybit log"
|
|
1333
|
+
}
|
|
1334
|
+
]
|
|
1335
|
+
},
|
|
1336
|
+
// Create vybit parameters
|
|
1337
|
+
{
|
|
1338
|
+
displayName: "Vybit Name",
|
|
1339
|
+
name: "vybitName",
|
|
1340
|
+
type: "string",
|
|
1341
|
+
required: true,
|
|
1342
|
+
displayOptions: {
|
|
1343
|
+
show: {
|
|
1344
|
+
actionType: ["vybits"],
|
|
1345
|
+
apiOperation: ["create"]
|
|
1346
|
+
}
|
|
1347
|
+
},
|
|
1348
|
+
default: "",
|
|
1349
|
+
description: "The name of the vybit to create"
|
|
1350
|
+
},
|
|
1351
|
+
// Update vybit parameters
|
|
1352
|
+
{
|
|
1353
|
+
displayName: "Update Fields",
|
|
1354
|
+
name: "updateFields",
|
|
1355
|
+
type: "collection",
|
|
1356
|
+
placeholder: "Add Field",
|
|
1357
|
+
displayOptions: {
|
|
1358
|
+
show: {
|
|
1359
|
+
actionType: ["vybits"],
|
|
1360
|
+
apiOperation: ["update"]
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
default: {},
|
|
1364
|
+
options: [
|
|
1365
|
+
{
|
|
1366
|
+
displayName: "Name",
|
|
1367
|
+
name: "name",
|
|
1368
|
+
type: "string",
|
|
1369
|
+
default: "",
|
|
1370
|
+
description: "Vybit display name (max 255 characters)"
|
|
1371
|
+
},
|
|
1372
|
+
{
|
|
1373
|
+
displayName: "Description",
|
|
1374
|
+
name: "description",
|
|
1375
|
+
type: "string",
|
|
1376
|
+
default: "",
|
|
1377
|
+
description: "Detailed vybit description"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
displayName: "Sound Key",
|
|
1381
|
+
name: "soundKey",
|
|
1382
|
+
type: "string",
|
|
1383
|
+
default: "",
|
|
1384
|
+
description: "Key of the sound to play (must be an available sound)"
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
displayName: "Trigger Type",
|
|
1388
|
+
name: "triggerType",
|
|
1389
|
+
type: "options",
|
|
1390
|
+
options: [
|
|
1391
|
+
{ name: "Webhook", value: "webhook" },
|
|
1392
|
+
{ name: "Schedule", value: "schedule" },
|
|
1393
|
+
{ name: "Geofence", value: "geofence" },
|
|
1394
|
+
{ name: "Integration", value: "integration" }
|
|
1395
|
+
],
|
|
1396
|
+
default: "webhook",
|
|
1397
|
+
description: "How this vybit is triggered"
|
|
1398
|
+
},
|
|
1399
|
+
{
|
|
1400
|
+
displayName: "Access",
|
|
1401
|
+
name: "access",
|
|
1402
|
+
type: "options",
|
|
1403
|
+
options: [
|
|
1404
|
+
{ name: "Public", value: "public" },
|
|
1405
|
+
{ name: "Private", value: "private" },
|
|
1406
|
+
{ name: "Unlisted", value: "unlisted" }
|
|
1407
|
+
],
|
|
1408
|
+
default: "private",
|
|
1409
|
+
description: "Vybit visibility and access control"
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
displayName: "Status",
|
|
1413
|
+
name: "status",
|
|
1414
|
+
type: "options",
|
|
1415
|
+
options: [
|
|
1416
|
+
{ name: "On", value: "on" },
|
|
1417
|
+
{ name: "Off", value: "off" }
|
|
1418
|
+
],
|
|
1419
|
+
default: "on",
|
|
1420
|
+
description: "Enable or disable the vybit"
|
|
1421
|
+
},
|
|
1422
|
+
{
|
|
1423
|
+
displayName: "Message",
|
|
1424
|
+
name: "message",
|
|
1425
|
+
type: "string",
|
|
1426
|
+
default: "",
|
|
1427
|
+
description: "Default message displayed with notifications (max 500 characters)"
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
displayName: "Image URL",
|
|
1431
|
+
name: "imageUrl",
|
|
1432
|
+
type: "string",
|
|
1433
|
+
default: "",
|
|
1434
|
+
description: "Default image URL for notifications"
|
|
1435
|
+
},
|
|
1436
|
+
{
|
|
1437
|
+
displayName: "Link URL",
|
|
1438
|
+
name: "linkUrl",
|
|
1439
|
+
type: "string",
|
|
1440
|
+
default: "",
|
|
1441
|
+
description: "Default URL to open when notification is tapped"
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
displayName: "Send Permissions",
|
|
1445
|
+
name: "sendPermissions",
|
|
1446
|
+
type: "options",
|
|
1447
|
+
options: [
|
|
1448
|
+
{ name: "Owner \u2192 Subscribers (one-way)", value: "owner_subs" },
|
|
1449
|
+
{ name: "Owner \u2194 Subscribers (two-way)", value: "subs_owner" },
|
|
1450
|
+
{ name: "Subscribers \u2192 Group (group broadcast)", value: "subs_group" }
|
|
1451
|
+
],
|
|
1452
|
+
default: "owner_subs",
|
|
1453
|
+
description: "Who can trigger and receive notifications"
|
|
1454
|
+
}
|
|
1455
|
+
]
|
|
1456
|
+
}
|
|
1457
|
+
]
|
|
1458
|
+
};
|
|
1459
|
+
this.methods = {
|
|
1460
|
+
loadOptions: {
|
|
1461
|
+
async getVybits() {
|
|
1462
|
+
try {
|
|
1463
|
+
let credentials;
|
|
1464
|
+
try {
|
|
1465
|
+
credentials = await this.getCredentials("vybitOAuth2Api");
|
|
1466
|
+
} catch (error) {
|
|
1467
|
+
this.logger.info("No credentials selected", { error: error.message });
|
|
1468
|
+
return [{
|
|
1469
|
+
name: "Please connect your Vybit account first",
|
|
1470
|
+
value: "",
|
|
1471
|
+
description: "Click above to create or select a credential"
|
|
1472
|
+
}];
|
|
1473
|
+
}
|
|
1474
|
+
const oauthData = credentials?.oauthTokenData;
|
|
1475
|
+
const accessToken = oauthData?.access_token;
|
|
1476
|
+
this.logger.info("OAuth token data", {
|
|
1477
|
+
hasOauthData: !!oauthData,
|
|
1478
|
+
hasAccessToken: !!accessToken,
|
|
1479
|
+
tokenLength: accessToken?.length
|
|
1480
|
+
});
|
|
1481
|
+
if (!accessToken) {
|
|
1482
|
+
this.logger.warn("No access token in credentials", {
|
|
1483
|
+
credentialKeys: credentials ? Object.keys(credentials) : [],
|
|
1484
|
+
oauthDataKeys: oauthData ? Object.keys(oauthData) : []
|
|
1485
|
+
});
|
|
1486
|
+
return [{
|
|
1487
|
+
name: "Please complete OAuth connection",
|
|
1488
|
+
value: "",
|
|
1489
|
+
description: 'Click "Connect my account" to authorize'
|
|
1490
|
+
}];
|
|
1491
|
+
}
|
|
1492
|
+
this.logger.info("Loading vybits...", {
|
|
1493
|
+
url: "https://vybit.net/rest/vybit_list",
|
|
1494
|
+
hasToken: !!accessToken,
|
|
1495
|
+
tokenLength: accessToken?.length
|
|
1496
|
+
});
|
|
1497
|
+
const response = await this.helpers.httpRequest({
|
|
1498
|
+
method: "GET",
|
|
1499
|
+
url: "https://vybit.net/rest/vybit_list",
|
|
1500
|
+
headers: {
|
|
1501
|
+
"Authorization": `Bearer ${accessToken}`,
|
|
1502
|
+
"Content-Type": "application/json"
|
|
1503
|
+
},
|
|
1504
|
+
json: true,
|
|
1505
|
+
returnFullResponse: false
|
|
1506
|
+
});
|
|
1507
|
+
this.logger.info("Vybit API response received", {
|
|
1508
|
+
isArray: Array.isArray(response),
|
|
1509
|
+
type: typeof response,
|
|
1510
|
+
keys: response ? Object.keys(response).slice(0, 5) : [],
|
|
1511
|
+
length: Array.isArray(response) ? response.length : "N/A"
|
|
1512
|
+
});
|
|
1513
|
+
const vybits = Array.isArray(response) ? response : response.vybits || response.data || [];
|
|
1514
|
+
this.logger.info("Processed vybits", {
|
|
1515
|
+
count: vybits.length,
|
|
1516
|
+
firstVybit: vybits[0] ? {
|
|
1517
|
+
name: vybits[0].name,
|
|
1518
|
+
hasTriggerKey: !!vybits[0].triggerKey,
|
|
1519
|
+
keys: Object.keys(vybits[0])
|
|
1520
|
+
} : null
|
|
1521
|
+
});
|
|
1522
|
+
if (!Array.isArray(vybits) || vybits.length === 0) {
|
|
1523
|
+
return [{
|
|
1524
|
+
name: "No vybits found",
|
|
1525
|
+
value: "__no_vybits__",
|
|
1526
|
+
description: "Create a vybit at vybit.net first"
|
|
1527
|
+
}];
|
|
1528
|
+
}
|
|
1529
|
+
return vybits.filter((vybit) => {
|
|
1530
|
+
const key = vybit.triggerKey || vybit.trigger_key || vybit.key;
|
|
1531
|
+
return key && key.length > 0;
|
|
1532
|
+
}).map((vybit) => ({
|
|
1533
|
+
name: vybit.name || vybit.title || "Unnamed Vybit",
|
|
1534
|
+
value: vybit.triggerKey || vybit.trigger_key || vybit.key,
|
|
1535
|
+
description: vybit.description || void 0
|
|
1536
|
+
}));
|
|
1537
|
+
} catch (error) {
|
|
1538
|
+
this.logger.error("Error in getVybits", {
|
|
1539
|
+
message: error.message,
|
|
1540
|
+
stack: error.stack,
|
|
1541
|
+
name: error.name
|
|
1542
|
+
});
|
|
1543
|
+
if (error.message?.includes("401")) {
|
|
1544
|
+
return [{
|
|
1545
|
+
name: "Authorization failed - please reconnect",
|
|
1546
|
+
value: "",
|
|
1547
|
+
description: "Your token may have expired"
|
|
1548
|
+
}];
|
|
1549
|
+
}
|
|
1550
|
+
throw new Error(`Failed to load vybits: ${error.message}`);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
async execute() {
|
|
1557
|
+
const items = this.getInputData();
|
|
1558
|
+
const returnData = [];
|
|
1559
|
+
const actionType = this.getNodeParameter("actionType", 0);
|
|
1560
|
+
let client;
|
|
1561
|
+
if (actionType !== "notification") {
|
|
1562
|
+
const credentials = await this.getCredentials("vybitApi");
|
|
1563
|
+
client = new dist$1.VybitAPIClient({
|
|
1564
|
+
apiKey: credentials.apiKey,
|
|
1565
|
+
baseURL: credentials.baseUrl
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
for (let i = 0; i < items.length; i++) {
|
|
1569
|
+
try {
|
|
1570
|
+
if (actionType === "notification") {
|
|
1571
|
+
const credentials = await this.getCredentials("vybitOAuth2Api");
|
|
1572
|
+
const oauthData = credentials?.oauthTokenData;
|
|
1573
|
+
const accessToken = oauthData?.access_token;
|
|
1574
|
+
const triggerKey = this.getNodeParameter("triggerKey", i);
|
|
1575
|
+
const additionalFields = this.getNodeParameter("additionalFields", i, {});
|
|
1576
|
+
const body = {};
|
|
1577
|
+
if (additionalFields.message) body.message = additionalFields.message;
|
|
1578
|
+
if (additionalFields.image) body.imageUrl = additionalFields.image;
|
|
1579
|
+
if (additionalFields.link) body.linkUrl = additionalFields.link;
|
|
1580
|
+
if (additionalFields.log !== void 0) body.log = additionalFields.log;
|
|
1581
|
+
const result = await this.helpers.httpRequest({
|
|
1582
|
+
method: "POST",
|
|
1583
|
+
url: `https://vybit.net/fire/${triggerKey}`,
|
|
1584
|
+
headers: {
|
|
1585
|
+
"Authorization": `Bearer ${accessToken}`,
|
|
1586
|
+
"Content-Type": "application/json"
|
|
1587
|
+
},
|
|
1588
|
+
body,
|
|
1589
|
+
json: true
|
|
1590
|
+
});
|
|
1591
|
+
returnData.push({ json: result });
|
|
1592
|
+
} else if (actionType === "profile") {
|
|
1593
|
+
const apiOperation = this.getNodeParameter("apiOperation", i);
|
|
1594
|
+
if (apiOperation === "getProfile") {
|
|
1595
|
+
const profile = await client.getProfile();
|
|
1596
|
+
returnData.push({ json: profile });
|
|
1597
|
+
} else if (apiOperation === "getMeter") {
|
|
1598
|
+
const meter = await client.getMeter();
|
|
1599
|
+
returnData.push({ json: meter });
|
|
1600
|
+
} else if (apiOperation === "getStatus") {
|
|
1601
|
+
const status = await client.getStatus();
|
|
1602
|
+
returnData.push({ json: status });
|
|
1603
|
+
}
|
|
1604
|
+
} else if (actionType === "vybits") {
|
|
1605
|
+
const apiOperation = this.getNodeParameter("apiOperation", i);
|
|
1606
|
+
if (apiOperation === "list") {
|
|
1607
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1608
|
+
const vybits = await client.listVybits({
|
|
1609
|
+
search: options.search,
|
|
1610
|
+
limit: options.limit,
|
|
1611
|
+
offset: options.offset
|
|
1612
|
+
});
|
|
1613
|
+
returnData.push({ json: vybits });
|
|
1614
|
+
} else if (apiOperation === "get") {
|
|
1615
|
+
const vybitKey = this.getNodeParameter("vybitKey", i);
|
|
1616
|
+
const vybit = await client.getVybit(vybitKey);
|
|
1617
|
+
returnData.push({ json: vybit });
|
|
1618
|
+
} else if (apiOperation === "create") {
|
|
1619
|
+
const name = this.getNodeParameter("vybitName", i);
|
|
1620
|
+
const vybit = await client.createVybit({ name });
|
|
1621
|
+
returnData.push({ json: vybit });
|
|
1622
|
+
} else if (apiOperation === "update") {
|
|
1623
|
+
const vybitKey = this.getNodeParameter("vybitKey", i);
|
|
1624
|
+
const updateFields = this.getNodeParameter("updateFields", i, {});
|
|
1625
|
+
const vybit = await client.updateVybit(vybitKey, updateFields);
|
|
1626
|
+
returnData.push({ json: vybit });
|
|
1627
|
+
} else if (apiOperation === "delete") {
|
|
1628
|
+
const vybitKey = this.getNodeParameter("vybitKey", i);
|
|
1629
|
+
await client.deleteVybit(vybitKey);
|
|
1630
|
+
returnData.push({ json: { success: true, vybitKey } });
|
|
1631
|
+
} else if (apiOperation === "trigger") {
|
|
1632
|
+
const vybitKey = this.getNodeParameter("vybitKey", i);
|
|
1633
|
+
const additionalFields = this.getNodeParameter("additionalFields", i, {});
|
|
1634
|
+
const result = await client.triggerVybit(vybitKey, {
|
|
1635
|
+
message: additionalFields.message,
|
|
1636
|
+
image: additionalFields.image,
|
|
1637
|
+
link: additionalFields.link,
|
|
1638
|
+
log: additionalFields.log
|
|
1639
|
+
});
|
|
1640
|
+
returnData.push({ json: result });
|
|
1641
|
+
}
|
|
1642
|
+
} else if (actionType === "subscriptions") {
|
|
1643
|
+
const apiOperation = this.getNodeParameter("apiOperation", i);
|
|
1644
|
+
if (apiOperation === "listPublic") {
|
|
1645
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1646
|
+
const vybits = await client.listPublicSubscriptions({
|
|
1647
|
+
search: options.search,
|
|
1648
|
+
limit: options.limit,
|
|
1649
|
+
offset: options.offset
|
|
1650
|
+
});
|
|
1651
|
+
returnData.push({ json: vybits });
|
|
1652
|
+
} else if (apiOperation === "getPublic") {
|
|
1653
|
+
const subscriptionKey = this.getNodeParameter("subscriptionKey", i);
|
|
1654
|
+
const vybit = await client.getPublicSubscription(subscriptionKey);
|
|
1655
|
+
returnData.push({ json: vybit });
|
|
1656
|
+
} else if (apiOperation === "subscribe") {
|
|
1657
|
+
const subscriptionKey = this.getNodeParameter("subscriptionKey", i);
|
|
1658
|
+
const result = await client.subscribe(subscriptionKey);
|
|
1659
|
+
returnData.push({ json: result });
|
|
1660
|
+
} else if (apiOperation === "listSubscriptions") {
|
|
1661
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1662
|
+
const subscriptions = await client.listSubscriptions({
|
|
1663
|
+
search: options.search,
|
|
1664
|
+
limit: options.limit,
|
|
1665
|
+
offset: options.offset
|
|
1666
|
+
});
|
|
1667
|
+
returnData.push({ json: subscriptions });
|
|
1668
|
+
} else if (apiOperation === "getSubscription") {
|
|
1669
|
+
const followingKey = this.getNodeParameter("followingKey", i);
|
|
1670
|
+
const subscription = await client.getSubscription(followingKey);
|
|
1671
|
+
returnData.push({ json: subscription });
|
|
1672
|
+
} else if (apiOperation === "updateSubscription") {
|
|
1673
|
+
const followingKey = this.getNodeParameter("followingKey", i);
|
|
1674
|
+
const updateFields = this.getNodeParameter("updateFields", i, {});
|
|
1675
|
+
const subscription = await client.updateSubscription(followingKey, updateFields);
|
|
1676
|
+
returnData.push({ json: subscription });
|
|
1677
|
+
} else if (apiOperation === "unsubscribe") {
|
|
1678
|
+
const followingKey = this.getNodeParameter("followingKey", i);
|
|
1679
|
+
await client.unsubscribe(followingKey);
|
|
1680
|
+
returnData.push({ json: { success: true, followingKey } });
|
|
1681
|
+
} else if (apiOperation === "sendToOwner") {
|
|
1682
|
+
const followingKey = this.getNodeParameter("followingKey", i);
|
|
1683
|
+
const additionalFields = this.getNodeParameter("additionalFields", i, {});
|
|
1684
|
+
const result = await client.sendToOwner(followingKey, {
|
|
1685
|
+
message: additionalFields.message
|
|
1686
|
+
});
|
|
1687
|
+
returnData.push({ json: result });
|
|
1688
|
+
} else if (apiOperation === "sendToGroup") {
|
|
1689
|
+
const followingKey = this.getNodeParameter("followingKey", i);
|
|
1690
|
+
const additionalFields = this.getNodeParameter("additionalFields", i, {});
|
|
1691
|
+
const result = await client.sendToGroup(followingKey, {
|
|
1692
|
+
message: additionalFields.message
|
|
1693
|
+
});
|
|
1694
|
+
returnData.push({ json: result });
|
|
1695
|
+
}
|
|
1696
|
+
} else if (actionType === "sounds") {
|
|
1697
|
+
const apiOperation = this.getNodeParameter("apiOperation", i);
|
|
1698
|
+
if (apiOperation === "search") {
|
|
1699
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1700
|
+
const sounds = await client.searchSounds({
|
|
1701
|
+
search: options.search,
|
|
1702
|
+
limit: options.limit,
|
|
1703
|
+
offset: options.offset
|
|
1704
|
+
});
|
|
1705
|
+
returnData.push({ json: sounds });
|
|
1706
|
+
} else if (apiOperation === "get") {
|
|
1707
|
+
const soundKey = this.getNodeParameter("soundKey", i);
|
|
1708
|
+
const sound = await client.getSound(soundKey);
|
|
1709
|
+
returnData.push({ json: sound });
|
|
1710
|
+
}
|
|
1711
|
+
} else if (actionType === "logs") {
|
|
1712
|
+
const apiOperation = this.getNodeParameter("apiOperation", i);
|
|
1713
|
+
if (apiOperation === "listAll") {
|
|
1714
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1715
|
+
const logs = await client.listLogs({
|
|
1716
|
+
search: options.search,
|
|
1717
|
+
limit: options.limit,
|
|
1718
|
+
offset: options.offset
|
|
1719
|
+
});
|
|
1720
|
+
returnData.push({ json: logs });
|
|
1721
|
+
} else if (apiOperation === "get") {
|
|
1722
|
+
const logKey = this.getNodeParameter("logKey", i);
|
|
1723
|
+
const log = await client.getLog(logKey);
|
|
1724
|
+
returnData.push({ json: log });
|
|
1725
|
+
} else if (apiOperation === "listByVybit") {
|
|
1726
|
+
const vybitKey = this.getNodeParameter("vybitKey", i);
|
|
1727
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1728
|
+
const logs = await client.listLogsByVybit(vybitKey, {
|
|
1729
|
+
search: options.search,
|
|
1730
|
+
limit: options.limit,
|
|
1731
|
+
offset: options.offset
|
|
1732
|
+
});
|
|
1733
|
+
returnData.push({ json: logs });
|
|
1734
|
+
} else if (apiOperation === "listBySubscription") {
|
|
1735
|
+
const followingKey = this.getNodeParameter("followingKey", i);
|
|
1736
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1737
|
+
const logs = await client.listLogsBySubscription(followingKey, {
|
|
1738
|
+
search: options.search,
|
|
1739
|
+
limit: options.limit,
|
|
1740
|
+
offset: options.offset
|
|
1741
|
+
});
|
|
1742
|
+
returnData.push({ json: logs });
|
|
1743
|
+
}
|
|
1744
|
+
} else if (actionType === "peeps") {
|
|
1745
|
+
const apiOperation = this.getNodeParameter("apiOperation", i);
|
|
1746
|
+
if (apiOperation === "listAll") {
|
|
1747
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1748
|
+
const peeps = await client.listPeeps({
|
|
1749
|
+
search: options.search,
|
|
1750
|
+
limit: options.limit,
|
|
1751
|
+
offset: options.offset
|
|
1752
|
+
});
|
|
1753
|
+
returnData.push({ json: peeps });
|
|
1754
|
+
} else if (apiOperation === "listByVybit") {
|
|
1755
|
+
const vybitKey = this.getNodeParameter("vybitKey", i);
|
|
1756
|
+
const options = this.getNodeParameter("options", i, {});
|
|
1757
|
+
const peeps = await client.listPeepsByVybit(vybitKey, {
|
|
1758
|
+
search: options.search,
|
|
1759
|
+
limit: options.limit,
|
|
1760
|
+
offset: options.offset
|
|
1761
|
+
});
|
|
1762
|
+
returnData.push({ json: peeps });
|
|
1763
|
+
} else if (apiOperation === "create") {
|
|
1764
|
+
const peepKey = this.getNodeParameter("peepKey", i);
|
|
1765
|
+
const result = await client.createPeep(peepKey);
|
|
1766
|
+
returnData.push({ json: result });
|
|
1767
|
+
} else if (apiOperation === "get") {
|
|
1768
|
+
const peepKey = this.getNodeParameter("peepKey", i);
|
|
1769
|
+
const peep = await client.getPeep(peepKey);
|
|
1770
|
+
returnData.push({ json: peep });
|
|
1771
|
+
} else if (apiOperation === "delete") {
|
|
1772
|
+
const peepKey = this.getNodeParameter("peepKey", i);
|
|
1773
|
+
await client.deletePeep(peepKey);
|
|
1774
|
+
returnData.push({ json: { success: true, peepKey } });
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
} catch (error) {
|
|
1778
|
+
if (this.continueOnFail()) {
|
|
1779
|
+
returnData.push({ json: { error: error.message } });
|
|
1780
|
+
continue;
|
|
1781
|
+
}
|
|
1782
|
+
throw error;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
return [returnData];
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
export { Vybit };
|