@pulze-io/renderflow 1.2.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/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/index.d.mts +921 -0
- package/dist/index.d.ts +921 -0
- package/dist/index.js +812 -0
- package/dist/index.mjs +776 -0
- package/package.json +37 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,812 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
EventListener: () => EventListener,
|
|
34
|
+
RenderFlow: () => RenderFlow
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
var import_axios2 = __toESM(require("axios"));
|
|
38
|
+
|
|
39
|
+
// src/api.ts
|
|
40
|
+
var import_axios = __toESM(require("axios"));
|
|
41
|
+
var HttpClient = class {
|
|
42
|
+
constructor({
|
|
43
|
+
securityWorker,
|
|
44
|
+
secure,
|
|
45
|
+
format,
|
|
46
|
+
...axiosConfig
|
|
47
|
+
} = {}) {
|
|
48
|
+
this.securityData = null;
|
|
49
|
+
this.setSecurityData = (data) => {
|
|
50
|
+
this.securityData = data;
|
|
51
|
+
};
|
|
52
|
+
this.request = async ({
|
|
53
|
+
secure,
|
|
54
|
+
path,
|
|
55
|
+
type,
|
|
56
|
+
query,
|
|
57
|
+
format,
|
|
58
|
+
body,
|
|
59
|
+
...params
|
|
60
|
+
}) => {
|
|
61
|
+
const secureParams = (typeof secure === "boolean" ? secure : this.secure) && this.securityWorker && await this.securityWorker(this.securityData) || {};
|
|
62
|
+
const requestParams = this.mergeRequestParams(params, secureParams);
|
|
63
|
+
const responseFormat = format || this.format || void 0;
|
|
64
|
+
if (type === "multipart/form-data" /* FormData */ && body && body !== null && typeof body === "object") {
|
|
65
|
+
body = this.createFormData(body);
|
|
66
|
+
}
|
|
67
|
+
if (type === "text/plain" /* Text */ && body && body !== null && typeof body !== "string") {
|
|
68
|
+
body = JSON.stringify(body);
|
|
69
|
+
}
|
|
70
|
+
return this.instance.request({
|
|
71
|
+
...requestParams,
|
|
72
|
+
headers: {
|
|
73
|
+
...requestParams.headers || {},
|
|
74
|
+
...type ? { "Content-Type": type } : {}
|
|
75
|
+
},
|
|
76
|
+
params: query,
|
|
77
|
+
responseType: responseFormat,
|
|
78
|
+
data: body,
|
|
79
|
+
url: path
|
|
80
|
+
}).then((response) => response.data);
|
|
81
|
+
};
|
|
82
|
+
this.instance = import_axios.default.create({
|
|
83
|
+
...axiosConfig,
|
|
84
|
+
baseURL: axiosConfig.baseURL || "/api/v1"
|
|
85
|
+
});
|
|
86
|
+
this.secure = secure;
|
|
87
|
+
this.format = format;
|
|
88
|
+
this.securityWorker = securityWorker;
|
|
89
|
+
}
|
|
90
|
+
mergeRequestParams(params1, params2) {
|
|
91
|
+
const method = params1.method || params2 && params2.method;
|
|
92
|
+
return {
|
|
93
|
+
...this.instance.defaults,
|
|
94
|
+
...params1,
|
|
95
|
+
...params2 || {},
|
|
96
|
+
headers: {
|
|
97
|
+
...method && this.instance.defaults.headers[method.toLowerCase()] || {},
|
|
98
|
+
...params1.headers || {},
|
|
99
|
+
...params2 && params2.headers || {}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
stringifyFormItem(formItem) {
|
|
104
|
+
if (typeof formItem === "object" && formItem !== null) {
|
|
105
|
+
return JSON.stringify(formItem);
|
|
106
|
+
} else {
|
|
107
|
+
return `${formItem}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
createFormData(input) {
|
|
111
|
+
if (input instanceof FormData) {
|
|
112
|
+
return input;
|
|
113
|
+
}
|
|
114
|
+
return Object.keys(input || {}).reduce((formData, key) => {
|
|
115
|
+
const property = input[key];
|
|
116
|
+
const propertyContent = property instanceof Array ? property : [property];
|
|
117
|
+
for (const formItem of propertyContent) {
|
|
118
|
+
const isFileType = formItem instanceof Blob || formItem instanceof File;
|
|
119
|
+
formData.append(
|
|
120
|
+
key,
|
|
121
|
+
isFileType ? formItem : this.stringifyFormItem(formItem)
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return formData;
|
|
125
|
+
}, new FormData());
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var Api = class {
|
|
129
|
+
constructor(http) {
|
|
130
|
+
this.users = {
|
|
131
|
+
/**
|
|
132
|
+
* @description Get all users
|
|
133
|
+
*
|
|
134
|
+
* @tags Users
|
|
135
|
+
* @name GetUsers
|
|
136
|
+
* @request GET:/users
|
|
137
|
+
* @secure
|
|
138
|
+
*/
|
|
139
|
+
getUsers: (params = {}) => this.http.request({
|
|
140
|
+
path: `/users`,
|
|
141
|
+
method: "GET",
|
|
142
|
+
secure: true,
|
|
143
|
+
format: "json",
|
|
144
|
+
...params
|
|
145
|
+
}),
|
|
146
|
+
/**
|
|
147
|
+
* @description Get a specific user by id
|
|
148
|
+
*
|
|
149
|
+
* @tags Users
|
|
150
|
+
* @name GetUser
|
|
151
|
+
* @request GET:/users/{id}
|
|
152
|
+
* @secure
|
|
153
|
+
*/
|
|
154
|
+
getUser: (id, params = {}) => this.http.request({
|
|
155
|
+
path: `/users/${id}`,
|
|
156
|
+
method: "GET",
|
|
157
|
+
secure: true,
|
|
158
|
+
format: "json",
|
|
159
|
+
...params
|
|
160
|
+
})
|
|
161
|
+
};
|
|
162
|
+
this.tasks = {
|
|
163
|
+
/**
|
|
164
|
+
* @description Get tasks for a specific job
|
|
165
|
+
*
|
|
166
|
+
* @tags Tasks
|
|
167
|
+
* @name GetTasks
|
|
168
|
+
* @request GET:/tasks
|
|
169
|
+
* @secure
|
|
170
|
+
*/
|
|
171
|
+
getTasks: (query, params = {}) => this.http.request({
|
|
172
|
+
path: `/tasks`,
|
|
173
|
+
method: "GET",
|
|
174
|
+
query,
|
|
175
|
+
secure: true,
|
|
176
|
+
format: "json",
|
|
177
|
+
...params
|
|
178
|
+
}),
|
|
179
|
+
/**
|
|
180
|
+
* @description Receive update stream from tasks
|
|
181
|
+
*
|
|
182
|
+
* @tags Tasks
|
|
183
|
+
* @name GetTaskEvents
|
|
184
|
+
* @request GET:/tasks/events/{job_id}
|
|
185
|
+
* @secure
|
|
186
|
+
*/
|
|
187
|
+
getTaskEvents: (jobId, params = {}) => this.http.request({
|
|
188
|
+
path: `/tasks/events/${jobId}`,
|
|
189
|
+
method: "GET",
|
|
190
|
+
secure: true,
|
|
191
|
+
...params
|
|
192
|
+
}),
|
|
193
|
+
/**
|
|
194
|
+
* @description Get task logs
|
|
195
|
+
*
|
|
196
|
+
* @tags Tasks
|
|
197
|
+
* @name GetTaskLogs
|
|
198
|
+
* @request GET:/tasks/{id}/logs
|
|
199
|
+
* @secure
|
|
200
|
+
*/
|
|
201
|
+
getTaskLogs: (id, query, params = {}) => this.http.request({
|
|
202
|
+
path: `/tasks/${id}/logs`,
|
|
203
|
+
method: "GET",
|
|
204
|
+
query,
|
|
205
|
+
secure: true,
|
|
206
|
+
format: "json",
|
|
207
|
+
...params
|
|
208
|
+
}),
|
|
209
|
+
/**
|
|
210
|
+
* @description Stream task logs via SSE
|
|
211
|
+
*
|
|
212
|
+
* @tags Tasks
|
|
213
|
+
* @name StreamTaskLogs
|
|
214
|
+
* @request GET:/tasks/{id}/logs/stream
|
|
215
|
+
* @secure
|
|
216
|
+
*/
|
|
217
|
+
streamTaskLogs: (id, params = {}) => this.http.request({
|
|
218
|
+
path: `/tasks/${id}/logs/stream`,
|
|
219
|
+
method: "GET",
|
|
220
|
+
secure: true,
|
|
221
|
+
...params
|
|
222
|
+
}),
|
|
223
|
+
/**
|
|
224
|
+
* @description Get task thumbnail
|
|
225
|
+
*
|
|
226
|
+
* @tags Tasks
|
|
227
|
+
* @name GetThumbnail
|
|
228
|
+
* @request GET:/tasks/{id}/thumbnail
|
|
229
|
+
* @secure
|
|
230
|
+
*/
|
|
231
|
+
getThumbnail: (id, params = {}) => this.http.request({
|
|
232
|
+
path: `/tasks/${id}/thumbnail`,
|
|
233
|
+
method: "GET",
|
|
234
|
+
secure: true,
|
|
235
|
+
...params
|
|
236
|
+
}),
|
|
237
|
+
/**
|
|
238
|
+
* @description Get a specific task by id
|
|
239
|
+
*
|
|
240
|
+
* @tags Tasks
|
|
241
|
+
* @name GetTask
|
|
242
|
+
* @request GET:/tasks/{id}
|
|
243
|
+
* @secure
|
|
244
|
+
*/
|
|
245
|
+
getTask: (id, params = {}) => this.http.request({
|
|
246
|
+
path: `/tasks/${id}`,
|
|
247
|
+
method: "GET",
|
|
248
|
+
secure: true,
|
|
249
|
+
format: "json",
|
|
250
|
+
...params
|
|
251
|
+
})
|
|
252
|
+
};
|
|
253
|
+
this.pools = {
|
|
254
|
+
/**
|
|
255
|
+
* @description Get all pools
|
|
256
|
+
*
|
|
257
|
+
* @tags Pools
|
|
258
|
+
* @name GetPools
|
|
259
|
+
* @request GET:/pools
|
|
260
|
+
* @secure
|
|
261
|
+
*/
|
|
262
|
+
getPools: (params = {}) => this.http.request({
|
|
263
|
+
path: `/pools`,
|
|
264
|
+
method: "GET",
|
|
265
|
+
secure: true,
|
|
266
|
+
format: "json",
|
|
267
|
+
...params
|
|
268
|
+
}),
|
|
269
|
+
/**
|
|
270
|
+
* @description Get a specific pool by id
|
|
271
|
+
*
|
|
272
|
+
* @tags Pools
|
|
273
|
+
* @name GetPool
|
|
274
|
+
* @request GET:/pools/{id}
|
|
275
|
+
* @secure
|
|
276
|
+
*/
|
|
277
|
+
getPool: (id, params = {}) => this.http.request({
|
|
278
|
+
path: `/pools/${id}`,
|
|
279
|
+
method: "GET",
|
|
280
|
+
secure: true,
|
|
281
|
+
format: "json",
|
|
282
|
+
...params
|
|
283
|
+
})
|
|
284
|
+
};
|
|
285
|
+
this.nodes = {
|
|
286
|
+
/**
|
|
287
|
+
* @description Get all nodes
|
|
288
|
+
*
|
|
289
|
+
* @tags Nodes
|
|
290
|
+
* @name GetNodes
|
|
291
|
+
* @request GET:/nodes
|
|
292
|
+
* @secure
|
|
293
|
+
*/
|
|
294
|
+
getNodes: (params = {}) => this.http.request({
|
|
295
|
+
path: `/nodes`,
|
|
296
|
+
method: "GET",
|
|
297
|
+
secure: true,
|
|
298
|
+
format: "json",
|
|
299
|
+
...params
|
|
300
|
+
}),
|
|
301
|
+
/**
|
|
302
|
+
* @description Get a specific node by id
|
|
303
|
+
*
|
|
304
|
+
* @tags Nodes
|
|
305
|
+
* @name GetNode
|
|
306
|
+
* @request GET:/nodes/{id}
|
|
307
|
+
* @secure
|
|
308
|
+
*/
|
|
309
|
+
getNode: (id, params = {}) => this.http.request({
|
|
310
|
+
path: `/nodes/${id}`,
|
|
311
|
+
method: "GET",
|
|
312
|
+
secure: true,
|
|
313
|
+
format: "json",
|
|
314
|
+
...params
|
|
315
|
+
}),
|
|
316
|
+
/**
|
|
317
|
+
* @description Delete a node by id
|
|
318
|
+
*
|
|
319
|
+
* @tags Nodes
|
|
320
|
+
* @name DeleteNode
|
|
321
|
+
* @request DELETE:/nodes/{id}
|
|
322
|
+
* @secure
|
|
323
|
+
*/
|
|
324
|
+
deleteNode: (id, params = {}) => this.http.request({
|
|
325
|
+
path: `/nodes/${id}`,
|
|
326
|
+
method: "DELETE",
|
|
327
|
+
secure: true,
|
|
328
|
+
format: "json",
|
|
329
|
+
...params
|
|
330
|
+
}),
|
|
331
|
+
/**
|
|
332
|
+
* @description Receive update stream from nodes
|
|
333
|
+
*
|
|
334
|
+
* @tags Nodes
|
|
335
|
+
* @name GetNodeEvents
|
|
336
|
+
* @request GET:/nodes/events
|
|
337
|
+
* @secure
|
|
338
|
+
*/
|
|
339
|
+
getNodeEvents: (params = {}) => this.http.request({
|
|
340
|
+
path: `/nodes/events`,
|
|
341
|
+
method: "GET",
|
|
342
|
+
secure: true,
|
|
343
|
+
...params
|
|
344
|
+
}),
|
|
345
|
+
/**
|
|
346
|
+
* @description Update the status of a node
|
|
347
|
+
*
|
|
348
|
+
* @tags Nodes
|
|
349
|
+
* @name UpdateStatus
|
|
350
|
+
* @request PATCH:/nodes/{id}/status
|
|
351
|
+
* @secure
|
|
352
|
+
*/
|
|
353
|
+
updateStatus: (id, data, params = {}) => this.http.request({
|
|
354
|
+
path: `/nodes/${id}/status`,
|
|
355
|
+
method: "PATCH",
|
|
356
|
+
body: data,
|
|
357
|
+
secure: true,
|
|
358
|
+
type: "application/json" /* Json */,
|
|
359
|
+
format: "json",
|
|
360
|
+
...params
|
|
361
|
+
}),
|
|
362
|
+
/**
|
|
363
|
+
* @description Get current hardware utilization for a node
|
|
364
|
+
*
|
|
365
|
+
* @tags Nodes
|
|
366
|
+
* @name GetNodeUtilization
|
|
367
|
+
* @request GET:/nodes/{id}/utilization
|
|
368
|
+
* @secure
|
|
369
|
+
*/
|
|
370
|
+
getNodeUtilization: (id, params = {}) => this.http.request({
|
|
371
|
+
path: `/nodes/${id}/utilization`,
|
|
372
|
+
method: "GET",
|
|
373
|
+
secure: true,
|
|
374
|
+
format: "json",
|
|
375
|
+
...params
|
|
376
|
+
}),
|
|
377
|
+
/**
|
|
378
|
+
* @description Update the pool of a node
|
|
379
|
+
*
|
|
380
|
+
* @tags Nodes
|
|
381
|
+
* @name UpdateNodePool
|
|
382
|
+
* @request PATCH:/nodes/{id}/pool
|
|
383
|
+
* @secure
|
|
384
|
+
*/
|
|
385
|
+
updateNodePool: (id, data, params = {}) => this.http.request({
|
|
386
|
+
path: `/nodes/${id}/pool`,
|
|
387
|
+
method: "PATCH",
|
|
388
|
+
body: data,
|
|
389
|
+
secure: true,
|
|
390
|
+
type: "application/json" /* Json */,
|
|
391
|
+
format: "json",
|
|
392
|
+
...params
|
|
393
|
+
}),
|
|
394
|
+
/**
|
|
395
|
+
* @description Get node benchmark rankings
|
|
396
|
+
*
|
|
397
|
+
* @tags Nodes
|
|
398
|
+
* @name GetNodeBenchmarkRanking
|
|
399
|
+
* @request GET:/nodes/benchmarks/ranking
|
|
400
|
+
* @secure
|
|
401
|
+
*/
|
|
402
|
+
getNodeBenchmarkRanking: (query, params = {}) => this.http.request({
|
|
403
|
+
path: `/nodes/benchmarks/ranking`,
|
|
404
|
+
method: "GET",
|
|
405
|
+
query,
|
|
406
|
+
secure: true,
|
|
407
|
+
format: "json",
|
|
408
|
+
...params
|
|
409
|
+
})
|
|
410
|
+
};
|
|
411
|
+
this.jobs = {
|
|
412
|
+
/**
|
|
413
|
+
* @description Receive update stream from jobs
|
|
414
|
+
*
|
|
415
|
+
* @tags Jobs
|
|
416
|
+
* @name GetJobEvents
|
|
417
|
+
* @request GET:/jobs/events
|
|
418
|
+
* @secure
|
|
419
|
+
*/
|
|
420
|
+
getJobEvents: (params = {}) => this.http.request({
|
|
421
|
+
path: `/jobs/events`,
|
|
422
|
+
method: "GET",
|
|
423
|
+
secure: true,
|
|
424
|
+
...params
|
|
425
|
+
}),
|
|
426
|
+
/**
|
|
427
|
+
* @description Get a specific job by id
|
|
428
|
+
*
|
|
429
|
+
* @tags Jobs
|
|
430
|
+
* @name GetJob
|
|
431
|
+
* @request GET:/jobs/{id}
|
|
432
|
+
* @secure
|
|
433
|
+
*/
|
|
434
|
+
getJob: (id, params = {}) => this.http.request({
|
|
435
|
+
path: `/jobs/${id}`,
|
|
436
|
+
method: "GET",
|
|
437
|
+
secure: true,
|
|
438
|
+
format: "json",
|
|
439
|
+
...params
|
|
440
|
+
}),
|
|
441
|
+
/**
|
|
442
|
+
* @description Update a job
|
|
443
|
+
*
|
|
444
|
+
* @tags Jobs
|
|
445
|
+
* @name UpdateJob
|
|
446
|
+
* @request PATCH:/jobs/{id}
|
|
447
|
+
* @secure
|
|
448
|
+
*/
|
|
449
|
+
updateJob: (id, data, params = {}) => this.http.request({
|
|
450
|
+
path: `/jobs/${id}`,
|
|
451
|
+
method: "PATCH",
|
|
452
|
+
body: data,
|
|
453
|
+
secure: true,
|
|
454
|
+
type: "application/json" /* Json */,
|
|
455
|
+
format: "json",
|
|
456
|
+
...params
|
|
457
|
+
}),
|
|
458
|
+
/**
|
|
459
|
+
* @description Delete a job
|
|
460
|
+
*
|
|
461
|
+
* @tags Jobs
|
|
462
|
+
* @name DeleteJob
|
|
463
|
+
* @request DELETE:/jobs/{id}
|
|
464
|
+
* @secure
|
|
465
|
+
*/
|
|
466
|
+
deleteJob: (id, params = {}) => this.http.request({
|
|
467
|
+
path: `/jobs/${id}`,
|
|
468
|
+
method: "DELETE",
|
|
469
|
+
secure: true,
|
|
470
|
+
format: "json",
|
|
471
|
+
...params
|
|
472
|
+
}),
|
|
473
|
+
/**
|
|
474
|
+
* @description Get all jobs
|
|
475
|
+
*
|
|
476
|
+
* @tags Jobs
|
|
477
|
+
* @name GetJobs
|
|
478
|
+
* @request GET:/jobs
|
|
479
|
+
* @secure
|
|
480
|
+
*/
|
|
481
|
+
getJobs: (params = {}) => this.http.request({
|
|
482
|
+
path: `/jobs`,
|
|
483
|
+
method: "GET",
|
|
484
|
+
secure: true,
|
|
485
|
+
format: "json",
|
|
486
|
+
...params
|
|
487
|
+
}),
|
|
488
|
+
/**
|
|
489
|
+
* @description Create a new job
|
|
490
|
+
*
|
|
491
|
+
* @tags Jobs
|
|
492
|
+
* @name CreateJob
|
|
493
|
+
* @request POST:/jobs/create
|
|
494
|
+
*/
|
|
495
|
+
createJob: (data, params = {}) => this.http.request({
|
|
496
|
+
path: `/jobs/create`,
|
|
497
|
+
method: "POST",
|
|
498
|
+
body: data,
|
|
499
|
+
type: "application/json" /* Json */,
|
|
500
|
+
format: "json",
|
|
501
|
+
...params
|
|
502
|
+
}),
|
|
503
|
+
/**
|
|
504
|
+
* @description Start a job
|
|
505
|
+
*
|
|
506
|
+
* @tags Jobs
|
|
507
|
+
* @name StartJob
|
|
508
|
+
* @request POST:/jobs/{id}/start
|
|
509
|
+
* @secure
|
|
510
|
+
*/
|
|
511
|
+
startJob: (id, params = {}) => this.http.request({
|
|
512
|
+
path: `/jobs/${id}/start`,
|
|
513
|
+
method: "POST",
|
|
514
|
+
secure: true,
|
|
515
|
+
format: "json",
|
|
516
|
+
...params
|
|
517
|
+
}),
|
|
518
|
+
/**
|
|
519
|
+
* @description Stop a job
|
|
520
|
+
*
|
|
521
|
+
* @tags Jobs
|
|
522
|
+
* @name StopJob
|
|
523
|
+
* @request POST:/jobs/{id}/stop
|
|
524
|
+
* @secure
|
|
525
|
+
*/
|
|
526
|
+
stopJob: (id, params = {}) => this.http.request({
|
|
527
|
+
path: `/jobs/${id}/stop`,
|
|
528
|
+
method: "POST",
|
|
529
|
+
secure: true,
|
|
530
|
+
format: "json",
|
|
531
|
+
...params
|
|
532
|
+
}),
|
|
533
|
+
/**
|
|
534
|
+
* @description Reset a job
|
|
535
|
+
*
|
|
536
|
+
* @tags Jobs
|
|
537
|
+
* @name ResetJob
|
|
538
|
+
* @request POST:/jobs/{id}/reset
|
|
539
|
+
* @secure
|
|
540
|
+
*/
|
|
541
|
+
resetJob: (id, params = {}) => this.http.request({
|
|
542
|
+
path: `/jobs/${id}/reset`,
|
|
543
|
+
method: "POST",
|
|
544
|
+
secure: true,
|
|
545
|
+
format: "json",
|
|
546
|
+
...params
|
|
547
|
+
}),
|
|
548
|
+
/**
|
|
549
|
+
* @description Archive a job
|
|
550
|
+
*
|
|
551
|
+
* @tags Jobs
|
|
552
|
+
* @name ArchiveJob
|
|
553
|
+
* @request POST:/jobs/{id}/archive
|
|
554
|
+
* @secure
|
|
555
|
+
*/
|
|
556
|
+
archiveJob: (id, params = {}) => this.http.request({
|
|
557
|
+
path: `/jobs/${id}/archive`,
|
|
558
|
+
method: "POST",
|
|
559
|
+
secure: true,
|
|
560
|
+
format: "json",
|
|
561
|
+
...params
|
|
562
|
+
}),
|
|
563
|
+
/**
|
|
564
|
+
* @description Update the pool of a job
|
|
565
|
+
*
|
|
566
|
+
* @tags Jobs
|
|
567
|
+
* @name UpdateJobPool
|
|
568
|
+
* @request PATCH:/jobs/{id}/pool
|
|
569
|
+
* @secure
|
|
570
|
+
*/
|
|
571
|
+
updateJobPool: (id, data, params = {}) => this.http.request({
|
|
572
|
+
path: `/jobs/${id}/pool`,
|
|
573
|
+
method: "PATCH",
|
|
574
|
+
body: data,
|
|
575
|
+
secure: true,
|
|
576
|
+
type: "application/json" /* Json */,
|
|
577
|
+
format: "json",
|
|
578
|
+
...params
|
|
579
|
+
})
|
|
580
|
+
};
|
|
581
|
+
this.info = {
|
|
582
|
+
/**
|
|
583
|
+
* @description Get information about the currently running RenderFlow instance
|
|
584
|
+
*
|
|
585
|
+
* @tags Info
|
|
586
|
+
* @name GetInfo
|
|
587
|
+
* @request GET:/info
|
|
588
|
+
* @secure
|
|
589
|
+
*/
|
|
590
|
+
getInfo: (params = {}) => this.http.request({
|
|
591
|
+
path: `/info`,
|
|
592
|
+
method: "GET",
|
|
593
|
+
secure: true,
|
|
594
|
+
format: "json",
|
|
595
|
+
...params
|
|
596
|
+
})
|
|
597
|
+
};
|
|
598
|
+
this.icons = {
|
|
599
|
+
/**
|
|
600
|
+
* @description Get job icon
|
|
601
|
+
*
|
|
602
|
+
* @tags Icons
|
|
603
|
+
* @name GetJobIcon
|
|
604
|
+
* @request GET:/icons/jobs/{type}
|
|
605
|
+
* @secure
|
|
606
|
+
*/
|
|
607
|
+
getJobIcon: (type, params = {}) => this.http.request({
|
|
608
|
+
path: `/icons/jobs/${type}`,
|
|
609
|
+
method: "GET",
|
|
610
|
+
secure: true,
|
|
611
|
+
...params
|
|
612
|
+
}),
|
|
613
|
+
/**
|
|
614
|
+
* @description Get software icon
|
|
615
|
+
*
|
|
616
|
+
* @tags Icons
|
|
617
|
+
* @name GetSoftwareIcon
|
|
618
|
+
* @request GET:/icons/software/{id}
|
|
619
|
+
* @secure
|
|
620
|
+
*/
|
|
621
|
+
getSoftwareIcon: (id, params = {}) => this.http.request({
|
|
622
|
+
path: `/icons/software/${id}`,
|
|
623
|
+
method: "GET",
|
|
624
|
+
secure: true,
|
|
625
|
+
...params
|
|
626
|
+
})
|
|
627
|
+
};
|
|
628
|
+
this.errors = {
|
|
629
|
+
/**
|
|
630
|
+
* @description Get all errors
|
|
631
|
+
*
|
|
632
|
+
* @tags Errors
|
|
633
|
+
* @name GetErrors
|
|
634
|
+
* @request GET:/errors
|
|
635
|
+
* @secure
|
|
636
|
+
*/
|
|
637
|
+
getErrors: (params = {}) => this.http.request({
|
|
638
|
+
path: `/errors`,
|
|
639
|
+
method: "GET",
|
|
640
|
+
secure: true,
|
|
641
|
+
format: "json",
|
|
642
|
+
...params
|
|
643
|
+
}),
|
|
644
|
+
/**
|
|
645
|
+
* @description Get errors by job id
|
|
646
|
+
*
|
|
647
|
+
* @tags Errors
|
|
648
|
+
* @name GetErrorsByJobId
|
|
649
|
+
* @request GET:/errors/job/{id}
|
|
650
|
+
* @secure
|
|
651
|
+
*/
|
|
652
|
+
getErrorsByJobId: (id, params = {}) => this.http.request({
|
|
653
|
+
path: `/errors/job/${id}`,
|
|
654
|
+
method: "GET",
|
|
655
|
+
secure: true,
|
|
656
|
+
format: "json",
|
|
657
|
+
...params
|
|
658
|
+
}),
|
|
659
|
+
/**
|
|
660
|
+
* @description Get errors by node id
|
|
661
|
+
*
|
|
662
|
+
* @tags Errors
|
|
663
|
+
* @name GetErrorsByNodeId
|
|
664
|
+
* @request GET:/errors/node/{id}
|
|
665
|
+
* @secure
|
|
666
|
+
*/
|
|
667
|
+
getErrorsByNodeId: (id, params = {}) => this.http.request({
|
|
668
|
+
path: `/errors/node/${id}`,
|
|
669
|
+
method: "GET",
|
|
670
|
+
secure: true,
|
|
671
|
+
format: "json",
|
|
672
|
+
...params
|
|
673
|
+
})
|
|
674
|
+
};
|
|
675
|
+
this.http = http;
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
// src/index.ts
|
|
680
|
+
function parseEvent(raw) {
|
|
681
|
+
return {
|
|
682
|
+
type: raw.operationType,
|
|
683
|
+
document: raw.fullDocument ?? {},
|
|
684
|
+
updated: raw.updateDescription?.updatedFields,
|
|
685
|
+
time: raw.wallTime ?? 0
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
var EventListener = class {
|
|
689
|
+
constructor(url, headers, onEvent, onError) {
|
|
690
|
+
this._closed = false;
|
|
691
|
+
this._controller = new AbortController();
|
|
692
|
+
this._connect(url, headers, onEvent, onError);
|
|
693
|
+
}
|
|
694
|
+
async _connect(url, headers, onEvent, onError) {
|
|
695
|
+
try {
|
|
696
|
+
const response = await import_axios2.default.get(url, {
|
|
697
|
+
headers: { ...headers, Accept: "text/event-stream" },
|
|
698
|
+
responseType: "stream",
|
|
699
|
+
signal: this._controller.signal
|
|
700
|
+
});
|
|
701
|
+
let buffer = "";
|
|
702
|
+
response.data.on("data", (chunk) => {
|
|
703
|
+
buffer += chunk.toString();
|
|
704
|
+
const parts = buffer.split("\n\n");
|
|
705
|
+
buffer = parts.pop() || "";
|
|
706
|
+
for (const part of parts) {
|
|
707
|
+
const line = part.trim();
|
|
708
|
+
if (!line || line.startsWith(":")) continue;
|
|
709
|
+
const dataPrefix = "data: ";
|
|
710
|
+
const dataLine = line.split("\n").find((l) => l.startsWith(dataPrefix));
|
|
711
|
+
if (!dataLine) continue;
|
|
712
|
+
try {
|
|
713
|
+
const raw = JSON.parse(dataLine.slice(dataPrefix.length));
|
|
714
|
+
onEvent(parseEvent(raw));
|
|
715
|
+
} catch {
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
response.data.on("error", (err) => {
|
|
720
|
+
if (!this._closed && onError) {
|
|
721
|
+
onError(err);
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
} catch (err) {
|
|
725
|
+
if (!this._closed && onError) {
|
|
726
|
+
onError(err instanceof Error ? err : new Error(String(err)));
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
close() {
|
|
731
|
+
this._closed = true;
|
|
732
|
+
this._controller.abort();
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
var RenderFlow = class {
|
|
736
|
+
constructor(options = {}) {
|
|
737
|
+
const { baseUrl = "http://localhost:44442/api/v1", apiKey, timeout = 3e4 } = options;
|
|
738
|
+
this._baseUrl = baseUrl;
|
|
739
|
+
this._headers = apiKey ? { "x-renderflow-api-key": apiKey } : {};
|
|
740
|
+
const httpClient = new HttpClient({
|
|
741
|
+
baseURL: baseUrl,
|
|
742
|
+
timeout,
|
|
743
|
+
headers: this._headers
|
|
744
|
+
});
|
|
745
|
+
const api = new Api(httpClient);
|
|
746
|
+
const self = this;
|
|
747
|
+
this.info = {
|
|
748
|
+
get: () => api.info.getInfo()
|
|
749
|
+
};
|
|
750
|
+
this.jobs = {
|
|
751
|
+
list: () => api.jobs.getJobs(),
|
|
752
|
+
get: (id) => api.jobs.getJob(id),
|
|
753
|
+
create: (data) => api.jobs.createJob(data),
|
|
754
|
+
update: (id, data) => api.jobs.updateJob(id, data),
|
|
755
|
+
delete: (id) => api.jobs.deleteJob(id),
|
|
756
|
+
start: (id) => api.jobs.startJob(id),
|
|
757
|
+
stop: (id) => api.jobs.stopJob(id),
|
|
758
|
+
reset: (id) => api.jobs.resetJob(id),
|
|
759
|
+
archive: (id) => api.jobs.archiveJob(id),
|
|
760
|
+
updatePool: (id, poolId) => api.jobs.updateJobPool(id, { poolId }),
|
|
761
|
+
on: (callback, onError) => {
|
|
762
|
+
return new EventListener(`${self._baseUrl}/jobs/events`, self._headers, callback, onError);
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
this.tasks = {
|
|
766
|
+
list: (jobId, page = 1, limit = 20) => api.tasks.getTasks({ jobId, pageInput: page, limit }),
|
|
767
|
+
get: (id) => api.tasks.getTask(id),
|
|
768
|
+
logs: (id, offset = 0, limit = 200) => api.tasks.getTaskLogs(id, { offset, limit }),
|
|
769
|
+
thumbnail: (id) => api.tasks.getThumbnail(id),
|
|
770
|
+
on: (jobId, callback, onError) => {
|
|
771
|
+
return new EventListener(`${self._baseUrl}/tasks/events/${jobId}`, self._headers, callback, onError);
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
this.nodes = {
|
|
775
|
+
list: () => api.nodes.getNodes(),
|
|
776
|
+
get: (id) => api.nodes.getNode(id),
|
|
777
|
+
delete: (id) => api.nodes.deleteNode(id),
|
|
778
|
+
updateStatus: (id, status) => api.nodes.updateStatus(id, { status }),
|
|
779
|
+
updatePool: (id, poolId) => api.nodes.updateNodePool(id, { poolId }),
|
|
780
|
+
utilization: (id) => api.nodes.getNodeUtilization(id),
|
|
781
|
+
benchmarks: (type) => api.nodes.getNodeBenchmarkRanking({ type }),
|
|
782
|
+
on: (callback, onError) => {
|
|
783
|
+
return new EventListener(`${self._baseUrl}/nodes/events`, self._headers, callback, onError);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
this.pools = {
|
|
787
|
+
list: () => api.pools.getPools(),
|
|
788
|
+
get: (id) => api.pools.getPool(id)
|
|
789
|
+
};
|
|
790
|
+
this.users = {
|
|
791
|
+
list: () => api.users.getUsers(),
|
|
792
|
+
get: (id) => api.users.getUser(id)
|
|
793
|
+
};
|
|
794
|
+
this.errors = {
|
|
795
|
+
list: () => api.errors.getErrors(),
|
|
796
|
+
byJob: (id) => api.errors.getErrorsByJobId(id),
|
|
797
|
+
byNode: (id) => api.errors.getErrorsByNodeId(id)
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
802
|
+
0 && (module.exports = {
|
|
803
|
+
EventListener,
|
|
804
|
+
RenderFlow
|
|
805
|
+
});
|
|
806
|
+
/**
|
|
807
|
+
* @title RenderFlow API Docs
|
|
808
|
+
* @version 1.0
|
|
809
|
+
* @license UNLICENSED
|
|
810
|
+
* @baseUrl /api/v1
|
|
811
|
+
* @contact Pulze
|
|
812
|
+
*/
|