@ptkl/sdk 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +307 -315
- package/dist/index.esm.js +296 -305
- package/dist/index.umd.js +307 -315
- package/dist/package.json +1 -1
- package/dist/types/api/apiUser.d.ts +3 -3
- package/dist/types/api/apps.d.ts +3 -3
- package/dist/types/api/baseClient.d.ts +1 -0
- package/dist/types/api/component.d.ts +30 -18
- package/dist/types/api/componentUtils.d.ts +5 -0
- package/dist/types/api/forge.d.ts +2 -3
- package/dist/types/api/functions.d.ts +2 -2
- package/dist/types/api/integrations/invoicing.d.ts +2 -2
- package/dist/types/api/integrations/media.d.ts +2 -2
- package/dist/types/api/integrations/serbiaUtil.d.ts +2 -2
- package/dist/types/api/integrations/vpfr.d.ts +2 -2
- package/dist/types/api/integrations.d.ts +7 -4
- package/dist/types/api/integrationsBaseClient.d.ts +8 -0
- package/dist/types/api/platform.d.ts +4 -12
- package/dist/types/api/platformBaseClient.d.ts +27 -0
- package/dist/types/api/ratchet.d.ts +2 -2
- package/dist/types/api/roles.d.ts +2 -2
- package/dist/types/api/sandbox.d.ts +2 -2
- package/dist/types/api/system.d.ts +2 -2
- package/dist/types/api/thunder.d.ts +2 -2
- package/dist/types/api/users.d.ts +2 -2
- package/dist/types/api/workflow.d.ts +2 -2
- package/dist/types/index.d.ts +12 -11
- package/dist/types/types/component.d.ts +4 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -4,9 +4,75 @@ class BaseClient {
|
|
|
4
4
|
constructor(client) {
|
|
5
5
|
this.client = client;
|
|
6
6
|
}
|
|
7
|
+
setClient(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
7
11
|
}
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
typeof process !== "undefined" &&
|
|
14
|
+
process.versions != null &&
|
|
15
|
+
process.versions.node != null;
|
|
16
|
+
const isBrowser = typeof window !== "undefined" &&
|
|
17
|
+
typeof document !== "undefined";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Base client for the platform API
|
|
21
|
+
* Classes that extend PlatformBaseClient have intentins of only working in platform context
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* @class PlatformBaseClient
|
|
25
|
+
* @extends BaseClient
|
|
26
|
+
* @constructor
|
|
27
|
+
* @param {AxiosInstance} [client] - The axios instance to use for the client
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // if sdk is used in the forge app that is running in the platform context
|
|
31
|
+
* const utils = new ComponentUtils()
|
|
32
|
+
* // this won't work outside of platform context because client needs authtorization to communicate with the API.
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
class PlatformBaseClient extends BaseClient {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
let { env = null, token = null, host = null, } = options !== null && options !== undefined ? options : {};
|
|
39
|
+
let headers = {};
|
|
40
|
+
if (isBrowser) {
|
|
41
|
+
if (localStorage.getItem('protokol_context') == "forge") {
|
|
42
|
+
headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// this potentially means that it is running as dev server in local
|
|
46
|
+
headers['X-Project-Env'] = "dev";
|
|
47
|
+
}
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
|
|
50
|
+
host = (_b = __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.API_HOST) !== null && _b !== undefined ? _b : host;
|
|
51
|
+
//@ts-ignore
|
|
52
|
+
token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
|
|
53
|
+
}
|
|
54
|
+
if (token) {
|
|
55
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
56
|
+
}
|
|
57
|
+
if (env) {
|
|
58
|
+
headers['X-Project-Env'] = env;
|
|
59
|
+
}
|
|
60
|
+
const client = axios.create({
|
|
61
|
+
baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
|
|
62
|
+
timeout: 15000,
|
|
63
|
+
headers: {
|
|
64
|
+
...headers,
|
|
65
|
+
},
|
|
66
|
+
withCredentials: true,
|
|
67
|
+
});
|
|
68
|
+
super(client);
|
|
69
|
+
this.env = null;
|
|
70
|
+
this.token = null;
|
|
71
|
+
this.host = null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
class Functions extends PlatformBaseClient {
|
|
10
76
|
async list() {
|
|
11
77
|
return await this.client.get("/v1/system/function");
|
|
12
78
|
}
|
|
@@ -39,12 +105,7 @@ class Functions extends BaseClient {
|
|
|
39
105
|
}
|
|
40
106
|
}
|
|
41
107
|
|
|
42
|
-
|
|
43
|
-
__proto__: null,
|
|
44
|
-
default: Functions
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
class Roles extends BaseClient {
|
|
108
|
+
class Roles extends PlatformBaseClient {
|
|
48
109
|
async create(role) {
|
|
49
110
|
const res = await this.client.post("/v1/user/role/create", role);
|
|
50
111
|
// writeFileSync(`.role.create.json`,JSON.stringify(res))
|
|
@@ -68,16 +129,15 @@ class Roles extends BaseClient {
|
|
|
68
129
|
}
|
|
69
130
|
}
|
|
70
131
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
default: Roles
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
class APIUser extends BaseClient {
|
|
77
|
-
async apiAuth(username, password) {
|
|
132
|
+
class APIUser extends PlatformBaseClient {
|
|
133
|
+
async auth(username, password, project) {
|
|
78
134
|
return this.client.post("/v1/user/api/auth", {
|
|
79
135
|
username,
|
|
80
136
|
password
|
|
137
|
+
}, {
|
|
138
|
+
headers: {
|
|
139
|
+
"X-Project-Uuid": project
|
|
140
|
+
}
|
|
81
141
|
});
|
|
82
142
|
}
|
|
83
143
|
async newSecret(uuid) {
|
|
@@ -97,12 +157,7 @@ class APIUser extends BaseClient {
|
|
|
97
157
|
}
|
|
98
158
|
}
|
|
99
159
|
|
|
100
|
-
|
|
101
|
-
__proto__: null,
|
|
102
|
-
default: APIUser
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
class Users extends BaseClient {
|
|
160
|
+
class Users extends PlatformBaseClient {
|
|
106
161
|
async invite(email, roles) {
|
|
107
162
|
return await this.client.post("/v1/project/invite", {
|
|
108
163
|
email,
|
|
@@ -114,14 +169,9 @@ class Users extends BaseClient {
|
|
|
114
169
|
}
|
|
115
170
|
}
|
|
116
171
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
class Apps extends BaseClient {
|
|
123
|
-
constructor(client, appType) {
|
|
124
|
-
super(client);
|
|
172
|
+
class Apps extends PlatformBaseClient {
|
|
173
|
+
constructor(appType) {
|
|
174
|
+
super();
|
|
125
175
|
this.appType = appType;
|
|
126
176
|
}
|
|
127
177
|
async updateSettings(updateValues, ref) {
|
|
@@ -138,19 +188,10 @@ class Apps extends BaseClient {
|
|
|
138
188
|
}
|
|
139
189
|
}
|
|
140
190
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
class Component extends BaseClient {
|
|
147
|
-
constructor(adapter, ref) {
|
|
148
|
-
super(adapter);
|
|
149
|
-
this.ref = ref;
|
|
150
|
-
}
|
|
151
|
-
new(ref) {
|
|
191
|
+
class Component extends PlatformBaseClient {
|
|
192
|
+
constructor(ref = null) {
|
|
193
|
+
super();
|
|
152
194
|
this.ref = ref;
|
|
153
|
-
return this;
|
|
154
195
|
}
|
|
155
196
|
/**
|
|
156
197
|
* Find method to search for models
|
|
@@ -261,14 +302,9 @@ class Component extends BaseClient {
|
|
|
261
302
|
* @param uuid string - The uuid of the model
|
|
262
303
|
* @returns (Promise<Model>)
|
|
263
304
|
*/
|
|
264
|
-
get(uuid) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
resolve(resp.data);
|
|
268
|
-
}).catch((error) => {
|
|
269
|
-
reject(error);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
305
|
+
async get(uuid) {
|
|
306
|
+
const { data } = await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
|
|
307
|
+
return data;
|
|
272
308
|
}
|
|
273
309
|
/**
|
|
274
310
|
* Update model by uuid
|
|
@@ -277,73 +313,62 @@ class Component extends BaseClient {
|
|
|
277
313
|
* @param data
|
|
278
314
|
* @returns
|
|
279
315
|
*/
|
|
280
|
-
update(uuid, data) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}).then((resp) => {
|
|
285
|
-
resolve(resp.data);
|
|
286
|
-
}).catch((error) => {
|
|
287
|
-
reject(error);
|
|
288
|
-
});
|
|
316
|
+
async update(uuid, data, options) {
|
|
317
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
|
|
318
|
+
data,
|
|
319
|
+
options,
|
|
289
320
|
});
|
|
321
|
+
return responseData;
|
|
290
322
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Update many models
|
|
325
|
+
*
|
|
326
|
+
* @param data
|
|
327
|
+
* @param options
|
|
328
|
+
* @returns
|
|
329
|
+
*/
|
|
330
|
+
async updateMany(data, options) {
|
|
331
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
|
|
332
|
+
data,
|
|
333
|
+
options,
|
|
301
334
|
});
|
|
335
|
+
return responseData;
|
|
302
336
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
337
|
+
/**
|
|
338
|
+
* Concurrent update model by uuid
|
|
339
|
+
*
|
|
340
|
+
* @param uuid string - The uuid of the model
|
|
341
|
+
* @param version number - The version of the model
|
|
342
|
+
* @param data
|
|
343
|
+
* @returns
|
|
344
|
+
*/
|
|
345
|
+
async concurrentUpdate(uuid, version, data, options) {
|
|
346
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
|
|
347
|
+
version: version,
|
|
348
|
+
data,
|
|
349
|
+
options,
|
|
310
350
|
});
|
|
351
|
+
return responseData;
|
|
311
352
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
resolve(resp.data);
|
|
316
|
-
}).catch((error) => {
|
|
317
|
-
reject(error);
|
|
318
|
-
});
|
|
319
|
-
});
|
|
353
|
+
async create(model) {
|
|
354
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/model`, model);
|
|
355
|
+
return data;
|
|
320
356
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
resolve(resp.data);
|
|
325
|
-
}).catch((error) => {
|
|
326
|
-
reject(error);
|
|
327
|
-
});
|
|
328
|
-
});
|
|
357
|
+
async delete(uuid) {
|
|
358
|
+
const { data } = await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
|
|
359
|
+
return data;
|
|
329
360
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
resolve(resp.data);
|
|
334
|
-
}).catch(err => {
|
|
335
|
-
reject(err);
|
|
336
|
-
});
|
|
337
|
-
});
|
|
361
|
+
async aggregate(pipeline) {
|
|
362
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
|
|
363
|
+
return data;
|
|
338
364
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
});
|
|
365
|
+
async settings() {
|
|
366
|
+
const { data } = await this.client.get(`/v3/system/component/settings/${this.ref}`);
|
|
367
|
+
return data;
|
|
368
|
+
}
|
|
369
|
+
async saveSettings(settings, version) {
|
|
370
|
+
const { data } = await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
|
|
371
|
+
return data;
|
|
347
372
|
}
|
|
348
373
|
async saveTemplatesDist(version, sdkVersion, engine, dist) {
|
|
349
374
|
const { data } = await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
|
|
@@ -356,29 +381,136 @@ class Component extends BaseClient {
|
|
|
356
381
|
return data;
|
|
357
382
|
}
|
|
358
383
|
async workflow(event, input) {
|
|
359
|
-
|
|
384
|
+
const { data } = await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
|
|
360
385
|
event,
|
|
361
386
|
input
|
|
362
387
|
});
|
|
388
|
+
return data;
|
|
363
389
|
}
|
|
364
390
|
async function(name, input) {
|
|
365
|
-
|
|
391
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
|
|
392
|
+
return data;
|
|
366
393
|
}
|
|
367
|
-
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
class ComponentUtils extends PlatformBaseClient {
|
|
397
|
+
async list() {
|
|
368
398
|
const { data } = await this.client.get("/v1/system/components");
|
|
369
399
|
return data;
|
|
370
400
|
}
|
|
371
|
-
async
|
|
372
|
-
|
|
401
|
+
async create(data) {
|
|
402
|
+
const { data: responseData } = await this.client.post("/v3/system/component/create", data);
|
|
403
|
+
return responseData;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
class Ratchet extends PlatformBaseClient {
|
|
408
|
+
async query(name, params) {
|
|
409
|
+
let res = await this.client.post('/v1/ratchet/query', {
|
|
410
|
+
name: name,
|
|
411
|
+
params: params
|
|
412
|
+
});
|
|
413
|
+
return res.data;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
class Sandbox extends PlatformBaseClient {
|
|
418
|
+
/**
|
|
419
|
+
* Call the sandbox service to execute a serverless function
|
|
420
|
+
*
|
|
421
|
+
* @param name
|
|
422
|
+
* @param data
|
|
423
|
+
* @returns
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* const result = await platform.sandbox().spark("myFunction", { foo: "bar" })
|
|
427
|
+
*/
|
|
428
|
+
async spark(name, data) {
|
|
429
|
+
return await this.client.post(`/v1/project/sandbox/spark/exec/${name}`, data);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
class System extends PlatformBaseClient {
|
|
434
|
+
async resourceResolver(ref, resourceName, format) {
|
|
435
|
+
const { data } = await this.client.post("/v3/system/resource-resolver", {
|
|
436
|
+
type: resourceName,
|
|
437
|
+
format,
|
|
438
|
+
});
|
|
439
|
+
if (format) {
|
|
440
|
+
return data.format;
|
|
441
|
+
}
|
|
442
|
+
return data;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
class Workflow extends PlatformBaseClient {
|
|
447
|
+
async trigger(id, event, data) {
|
|
448
|
+
return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
|
|
373
449
|
}
|
|
374
450
|
}
|
|
375
451
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
452
|
+
class Forge extends PlatformBaseClient {
|
|
453
|
+
async bundleUpload(buffer) {
|
|
454
|
+
return await this.client.post(`/v3/system/gateway/app-service/forge/upload`, buffer, {
|
|
455
|
+
headers: {
|
|
456
|
+
'Content-Type': 'application/octet-stream',
|
|
457
|
+
'Content-Length': buffer.length
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
async getWorkspaceApps() {
|
|
462
|
+
return await this.client.get(`/v3/system/gateway/app-service/forge/workspace`);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
380
465
|
|
|
381
|
-
|
|
466
|
+
// apis
|
|
467
|
+
class Platform extends PlatformBaseClient {
|
|
468
|
+
getPlatformClient() {
|
|
469
|
+
return this.client;
|
|
470
|
+
}
|
|
471
|
+
getPlatformBaseURL() {
|
|
472
|
+
var _a;
|
|
473
|
+
return (_a = this.client.defaults.baseURL) !== null && _a !== undefined ? _a : "";
|
|
474
|
+
}
|
|
475
|
+
apiUser() {
|
|
476
|
+
return (new APIUser()).setClient(this.client);
|
|
477
|
+
}
|
|
478
|
+
function() {
|
|
479
|
+
return (new Functions()).setClient(this.client);
|
|
480
|
+
}
|
|
481
|
+
role() {
|
|
482
|
+
return (new Roles()).setClient(this.client);
|
|
483
|
+
}
|
|
484
|
+
user() {
|
|
485
|
+
return (new Users()).setClient(this.client);
|
|
486
|
+
}
|
|
487
|
+
app(appType) {
|
|
488
|
+
return (new Apps(appType)).setClient(this.client);
|
|
489
|
+
}
|
|
490
|
+
forge() {
|
|
491
|
+
return (new Forge()).setClient(this.client);
|
|
492
|
+
}
|
|
493
|
+
component(ref) {
|
|
494
|
+
return (new Component(ref)).setClient(this.client);
|
|
495
|
+
}
|
|
496
|
+
componentUtils() {
|
|
497
|
+
return (new ComponentUtils()).setClient(this.client);
|
|
498
|
+
}
|
|
499
|
+
ratchet() {
|
|
500
|
+
return (new Ratchet()).setClient(this.client);
|
|
501
|
+
}
|
|
502
|
+
sandbox() {
|
|
503
|
+
return (new Sandbox()).setClient(this.client);
|
|
504
|
+
}
|
|
505
|
+
system() {
|
|
506
|
+
return (new System()).setClient(this.client);
|
|
507
|
+
}
|
|
508
|
+
workflow() {
|
|
509
|
+
return (new Workflow()).setClient(this.client);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
class Invoicing extends PlatformBaseClient {
|
|
382
514
|
async getSalesInvoices(provider, page) {
|
|
383
515
|
return await this.request("GET", `/invoices/${provider}/sales`, {
|
|
384
516
|
params: {
|
|
@@ -397,13 +529,48 @@ class Invoicing extends BaseClient {
|
|
|
397
529
|
async request(method, endpoint, params) {
|
|
398
530
|
return await this.client.request({
|
|
399
531
|
method: method,
|
|
400
|
-
url: `/v1/karadjordje/${endpoint}`,
|
|
532
|
+
url: `/v1/integrations/karadjordje/${endpoint}`,
|
|
401
533
|
...params
|
|
402
534
|
});
|
|
403
535
|
}
|
|
404
536
|
}
|
|
405
537
|
|
|
406
|
-
class
|
|
538
|
+
class IntegrationsBaseClient extends BaseClient {
|
|
539
|
+
constructor(options) {
|
|
540
|
+
var _a, _b;
|
|
541
|
+
let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
|
|
542
|
+
let headers = {};
|
|
543
|
+
if (isBrowser) {
|
|
544
|
+
if (localStorage.getItem('protokol_context') == "forge") {
|
|
545
|
+
headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
// this potentially means that it is running as dev server in local
|
|
549
|
+
headers['X-Project-Env'] = "dev";
|
|
550
|
+
}
|
|
551
|
+
// @ts-ignore
|
|
552
|
+
const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
|
|
553
|
+
host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== undefined ? _b : host;
|
|
554
|
+
}
|
|
555
|
+
if (token) {
|
|
556
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
557
|
+
}
|
|
558
|
+
if (env) {
|
|
559
|
+
headers['X-Project-Env'] = env;
|
|
560
|
+
}
|
|
561
|
+
const client = axios.create({
|
|
562
|
+
baseURL: host !== null && host !== undefined ? host : "https://orange.protokol.io",
|
|
563
|
+
timeout: 15000,
|
|
564
|
+
headers: {
|
|
565
|
+
...headers,
|
|
566
|
+
},
|
|
567
|
+
withCredentials: true,
|
|
568
|
+
});
|
|
569
|
+
super(client);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
class Media extends IntegrationsBaseClient {
|
|
407
574
|
async list(data) {
|
|
408
575
|
return this.request('POST', 'list', { data });
|
|
409
576
|
}
|
|
@@ -513,7 +680,7 @@ class Media extends BaseClient {
|
|
|
513
680
|
}
|
|
514
681
|
}
|
|
515
682
|
|
|
516
|
-
class SerbiaUtil extends
|
|
683
|
+
class SerbiaUtil extends IntegrationsBaseClient {
|
|
517
684
|
async nsbSearch(params) {
|
|
518
685
|
return await this.services("GET", "nbs/search", { params });
|
|
519
686
|
}
|
|
@@ -540,7 +707,7 @@ class SerbiaUtil extends BaseClient {
|
|
|
540
707
|
}
|
|
541
708
|
}
|
|
542
709
|
|
|
543
|
-
class VPFR extends
|
|
710
|
+
class VPFR extends IntegrationsBaseClient {
|
|
544
711
|
async request(method, endpoint, params) {
|
|
545
712
|
return await this.client.request({
|
|
546
713
|
method: method,
|
|
@@ -550,14 +717,15 @@ class VPFR extends BaseClient {
|
|
|
550
717
|
}
|
|
551
718
|
}
|
|
552
719
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
720
|
+
// import integrations
|
|
721
|
+
class Integrations extends IntegrationsBaseClient {
|
|
722
|
+
constructor(options) {
|
|
723
|
+
super(options);
|
|
556
724
|
this.integrations = {
|
|
557
|
-
'protokol-invoicing': new Invoicing(
|
|
558
|
-
'protokol-vpfr': new VPFR(
|
|
559
|
-
'protokol-media': new Media(
|
|
560
|
-
'serbia-utilities': new SerbiaUtil(
|
|
725
|
+
'protokol-invoicing': new Invoicing().setClient(this.client),
|
|
726
|
+
'protokol-vpfr': new VPFR().setClient(this.client),
|
|
727
|
+
'protokol-media': new Media().setClient(this.client),
|
|
728
|
+
'serbia-utilities': new SerbiaUtil().setClient(this.client),
|
|
561
729
|
};
|
|
562
730
|
}
|
|
563
731
|
getSerbiaUtilities() {
|
|
@@ -586,181 +754,4 @@ class Integrations extends BaseClient {
|
|
|
586
754
|
}
|
|
587
755
|
}
|
|
588
756
|
|
|
589
|
-
|
|
590
|
-
__proto__: null,
|
|
591
|
-
default: Integrations
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
class Ratchet extends BaseClient {
|
|
595
|
-
async query(name, params) {
|
|
596
|
-
let res = await this.client.post('/v1/ratchet/query', {
|
|
597
|
-
name: name,
|
|
598
|
-
params: params
|
|
599
|
-
});
|
|
600
|
-
return res.data;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
var ratchet = /*#__PURE__*/Object.freeze({
|
|
605
|
-
__proto__: null,
|
|
606
|
-
default: Ratchet
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
class Sandbox extends BaseClient {
|
|
610
|
-
/**
|
|
611
|
-
* Call the sandbox service to execute a serverless function
|
|
612
|
-
*
|
|
613
|
-
* @param name
|
|
614
|
-
* @param data
|
|
615
|
-
* @returns
|
|
616
|
-
*
|
|
617
|
-
* @example
|
|
618
|
-
* const result = await platform.sandbox().spark("myFunction", { foo: "bar" })
|
|
619
|
-
*/
|
|
620
|
-
async spark(name, data) {
|
|
621
|
-
return await this.client.post(`/v1/project/sandbox/spark/exec/${name}`, data);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
var sandbox = /*#__PURE__*/Object.freeze({
|
|
626
|
-
__proto__: null,
|
|
627
|
-
default: Sandbox
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
class System extends BaseClient {
|
|
631
|
-
async resourceResolver(ref, resourceName, format) {
|
|
632
|
-
const { data } = await this.client.post("/v3/system/resource-resolver", {
|
|
633
|
-
type: resourceName,
|
|
634
|
-
format,
|
|
635
|
-
});
|
|
636
|
-
if (format) {
|
|
637
|
-
return data.format;
|
|
638
|
-
}
|
|
639
|
-
return data;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
var system = /*#__PURE__*/Object.freeze({
|
|
644
|
-
__proto__: null,
|
|
645
|
-
default: System
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
class Workflow extends BaseClient {
|
|
649
|
-
async trigger(id, event, data) {
|
|
650
|
-
return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
var workflow = /*#__PURE__*/Object.freeze({
|
|
655
|
-
__proto__: null,
|
|
656
|
-
default: Workflow
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
class Forge extends BaseClient {
|
|
660
|
-
constructor(client) {
|
|
661
|
-
super(client);
|
|
662
|
-
}
|
|
663
|
-
async bundleUpload(buffer) {
|
|
664
|
-
return await this.client.post(`/v3/system/gateway/app-service/forge/upload`, buffer, {
|
|
665
|
-
headers: {
|
|
666
|
-
'Content-Type': 'application/octet-stream',
|
|
667
|
-
'Content-Length': buffer.length
|
|
668
|
-
}
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
async getWorkspaceApps() {
|
|
672
|
-
return await this.client.get(`/v3/system/gateway/app-service/forge/workspace`);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
typeof process !== "undefined" &&
|
|
677
|
-
process.versions != null &&
|
|
678
|
-
process.versions.node != null;
|
|
679
|
-
const isBrowser = typeof window !== "undefined" &&
|
|
680
|
-
typeof document !== "undefined";
|
|
681
|
-
|
|
682
|
-
class Platform {
|
|
683
|
-
constructor(options) {
|
|
684
|
-
var _a;
|
|
685
|
-
let { env = null, token, host, integrationHost } = options !== null && options !== undefined ? options : {};
|
|
686
|
-
let headers = {};
|
|
687
|
-
if (isBrowser) {
|
|
688
|
-
if (localStorage.getItem('protokol_context') == "forge") {
|
|
689
|
-
headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
|
|
690
|
-
}
|
|
691
|
-
else {
|
|
692
|
-
// this potentially means that it is running as dev server in local
|
|
693
|
-
headers['X-Project-Env'] = "dev";
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
if (token) {
|
|
697
|
-
headers['Authorization'] = `Bearer ${token}`;
|
|
698
|
-
}
|
|
699
|
-
if (env) {
|
|
700
|
-
headers['X-Project-Env'] = env;
|
|
701
|
-
}
|
|
702
|
-
this.platformClient = axios.create({
|
|
703
|
-
baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
|
|
704
|
-
timeout: 15000,
|
|
705
|
-
headers: {
|
|
706
|
-
...headers,
|
|
707
|
-
},
|
|
708
|
-
withCredentials: true,
|
|
709
|
-
});
|
|
710
|
-
this.integrationsClient = axios.create({
|
|
711
|
-
baseURL: integrationHost !== null && integrationHost !== undefined ? integrationHost : "https://orange.protokol.io",
|
|
712
|
-
timeout: 15000,
|
|
713
|
-
headers: {
|
|
714
|
-
...headers,
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
setPlatformClient(client) {
|
|
719
|
-
this.platformClient = client;
|
|
720
|
-
}
|
|
721
|
-
getPlatformClient() {
|
|
722
|
-
return this.platformClient;
|
|
723
|
-
}
|
|
724
|
-
getPlatformBaseURL() {
|
|
725
|
-
var _a;
|
|
726
|
-
return (_a = this.platformClient.defaults.baseURL) !== null && _a !== undefined ? _a : "";
|
|
727
|
-
}
|
|
728
|
-
apiUser() {
|
|
729
|
-
return new APIUser(this.platformClient);
|
|
730
|
-
}
|
|
731
|
-
function() {
|
|
732
|
-
return new Functions(this.platformClient);
|
|
733
|
-
}
|
|
734
|
-
role() {
|
|
735
|
-
return new Roles(this.platformClient);
|
|
736
|
-
}
|
|
737
|
-
user() {
|
|
738
|
-
return new Users(this.platformClient);
|
|
739
|
-
}
|
|
740
|
-
app(appType) {
|
|
741
|
-
return new Apps(this.platformClient, appType);
|
|
742
|
-
}
|
|
743
|
-
forge() {
|
|
744
|
-
return new Forge(this.platformClient);
|
|
745
|
-
}
|
|
746
|
-
component(ref) {
|
|
747
|
-
return new Component(this.platformClient, ref);
|
|
748
|
-
}
|
|
749
|
-
integrations() {
|
|
750
|
-
return new Integrations(this.integrationsClient);
|
|
751
|
-
}
|
|
752
|
-
ratchet() {
|
|
753
|
-
return new Ratchet(this.platformClient);
|
|
754
|
-
}
|
|
755
|
-
sandbox() {
|
|
756
|
-
return new Sandbox(this.platformClient);
|
|
757
|
-
}
|
|
758
|
-
system() {
|
|
759
|
-
return new System(this.platformClient);
|
|
760
|
-
}
|
|
761
|
-
workflow() {
|
|
762
|
-
return new Workflow(this.platformClient);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
export { apiUser as APIUser, apps as Apps, component as Component, functions as Functions, integrations as Integration, ratchet as Ratchet, roles as Roles, sandbox as Sandbox, system as System, users as Users, workflow as Workflow, Platform as default };
|
|
757
|
+
export { APIUser, Apps, Component, ComponentUtils, Functions, Integrations as Integration, Ratchet, Roles, Sandbox, System, Users, Workflow, Platform as default };
|