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