@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.esm.js
CHANGED
|
@@ -4,9 +4,73 @@ 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, host, } = 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
|
+
}
|
|
52
|
+
if (token) {
|
|
53
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
54
|
+
}
|
|
55
|
+
if (env) {
|
|
56
|
+
headers['X-Project-Env'] = env;
|
|
57
|
+
}
|
|
58
|
+
const client = axios.create({
|
|
59
|
+
baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
|
|
60
|
+
timeout: 15000,
|
|
61
|
+
headers: {
|
|
62
|
+
...headers,
|
|
63
|
+
},
|
|
64
|
+
withCredentials: true,
|
|
65
|
+
});
|
|
66
|
+
super(client);
|
|
67
|
+
this.env = null;
|
|
68
|
+
this.token = null;
|
|
69
|
+
this.host = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
class Functions extends PlatformBaseClient {
|
|
10
74
|
async list() {
|
|
11
75
|
return await this.client.get("/v1/system/function");
|
|
12
76
|
}
|
|
@@ -39,12 +103,7 @@ class Functions extends BaseClient {
|
|
|
39
103
|
}
|
|
40
104
|
}
|
|
41
105
|
|
|
42
|
-
|
|
43
|
-
__proto__: null,
|
|
44
|
-
default: Functions
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
class Roles extends BaseClient {
|
|
106
|
+
class Roles extends PlatformBaseClient {
|
|
48
107
|
async create(role) {
|
|
49
108
|
const res = await this.client.post("/v1/user/role/create", role);
|
|
50
109
|
// writeFileSync(`.role.create.json`,JSON.stringify(res))
|
|
@@ -68,16 +127,15 @@ class Roles extends BaseClient {
|
|
|
68
127
|
}
|
|
69
128
|
}
|
|
70
129
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
default: Roles
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
class APIUser extends BaseClient {
|
|
77
|
-
async apiAuth(username, password) {
|
|
130
|
+
class APIUser extends PlatformBaseClient {
|
|
131
|
+
async auth(username, password, project) {
|
|
78
132
|
return this.client.post("/v1/user/api/auth", {
|
|
79
133
|
username,
|
|
80
134
|
password
|
|
135
|
+
}, {
|
|
136
|
+
headers: {
|
|
137
|
+
"X-Project-Uuid": project
|
|
138
|
+
}
|
|
81
139
|
});
|
|
82
140
|
}
|
|
83
141
|
async newSecret(uuid) {
|
|
@@ -97,12 +155,7 @@ class APIUser extends BaseClient {
|
|
|
97
155
|
}
|
|
98
156
|
}
|
|
99
157
|
|
|
100
|
-
|
|
101
|
-
__proto__: null,
|
|
102
|
-
default: APIUser
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
class Users extends BaseClient {
|
|
158
|
+
class Users extends PlatformBaseClient {
|
|
106
159
|
async invite(email, roles) {
|
|
107
160
|
return await this.client.post("/v1/project/invite", {
|
|
108
161
|
email,
|
|
@@ -114,14 +167,9 @@ class Users extends BaseClient {
|
|
|
114
167
|
}
|
|
115
168
|
}
|
|
116
169
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
class Apps extends BaseClient {
|
|
123
|
-
constructor(client, appType) {
|
|
124
|
-
super(client);
|
|
170
|
+
class Apps extends PlatformBaseClient {
|
|
171
|
+
constructor(appType) {
|
|
172
|
+
super();
|
|
125
173
|
this.appType = appType;
|
|
126
174
|
}
|
|
127
175
|
async updateSettings(updateValues, ref) {
|
|
@@ -138,19 +186,10 @@ class Apps extends BaseClient {
|
|
|
138
186
|
}
|
|
139
187
|
}
|
|
140
188
|
|
|
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) {
|
|
189
|
+
class Component extends PlatformBaseClient {
|
|
190
|
+
constructor(ref = null) {
|
|
191
|
+
super();
|
|
152
192
|
this.ref = ref;
|
|
153
|
-
return this;
|
|
154
193
|
}
|
|
155
194
|
/**
|
|
156
195
|
* Find method to search for models
|
|
@@ -261,14 +300,9 @@ class Component extends BaseClient {
|
|
|
261
300
|
* @param uuid string - The uuid of the model
|
|
262
301
|
* @returns (Promise<Model>)
|
|
263
302
|
*/
|
|
264
|
-
get(uuid) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
resolve(resp.data);
|
|
268
|
-
}).catch((error) => {
|
|
269
|
-
reject(error);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
303
|
+
async get(uuid) {
|
|
304
|
+
const { data } = await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
|
|
305
|
+
return data;
|
|
272
306
|
}
|
|
273
307
|
/**
|
|
274
308
|
* Update model by uuid
|
|
@@ -277,73 +311,62 @@ class Component extends BaseClient {
|
|
|
277
311
|
* @param data
|
|
278
312
|
* @returns
|
|
279
313
|
*/
|
|
280
|
-
update(uuid, data) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}).then((resp) => {
|
|
285
|
-
resolve(resp.data);
|
|
286
|
-
}).catch((error) => {
|
|
287
|
-
reject(error);
|
|
288
|
-
});
|
|
314
|
+
async update(uuid, data, options) {
|
|
315
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
|
|
316
|
+
data,
|
|
317
|
+
options,
|
|
289
318
|
});
|
|
319
|
+
return responseData;
|
|
290
320
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Update many models
|
|
323
|
+
*
|
|
324
|
+
* @param data
|
|
325
|
+
* @param options
|
|
326
|
+
* @returns
|
|
327
|
+
*/
|
|
328
|
+
async updateMany(data, options) {
|
|
329
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
|
|
330
|
+
data,
|
|
331
|
+
options,
|
|
301
332
|
});
|
|
333
|
+
return responseData;
|
|
302
334
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Concurrent update model by uuid
|
|
337
|
+
*
|
|
338
|
+
* @param uuid string - The uuid of the model
|
|
339
|
+
* @param version number - The version of the model
|
|
340
|
+
* @param data
|
|
341
|
+
* @returns
|
|
342
|
+
*/
|
|
343
|
+
async concurrentUpdate(uuid, version, data, options) {
|
|
344
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
|
|
345
|
+
version: version,
|
|
346
|
+
data,
|
|
347
|
+
options,
|
|
310
348
|
});
|
|
349
|
+
return responseData;
|
|
311
350
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
resolve(resp.data);
|
|
316
|
-
}).catch((error) => {
|
|
317
|
-
reject(error);
|
|
318
|
-
});
|
|
319
|
-
});
|
|
351
|
+
async create(model) {
|
|
352
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/model`, model);
|
|
353
|
+
return data;
|
|
320
354
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
resolve(resp.data);
|
|
325
|
-
}).catch((error) => {
|
|
326
|
-
reject(error);
|
|
327
|
-
});
|
|
328
|
-
});
|
|
355
|
+
async delete(uuid) {
|
|
356
|
+
const { data } = await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
|
|
357
|
+
return data;
|
|
329
358
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
resolve(resp.data);
|
|
334
|
-
}).catch(err => {
|
|
335
|
-
reject(err);
|
|
336
|
-
});
|
|
337
|
-
});
|
|
359
|
+
async aggregate(pipeline) {
|
|
360
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
|
|
361
|
+
return data;
|
|
338
362
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
});
|
|
363
|
+
async settings() {
|
|
364
|
+
const { data } = await this.client.get(`/v3/system/component/settings/${this.ref}`);
|
|
365
|
+
return data;
|
|
366
|
+
}
|
|
367
|
+
async saveSettings(settings, version) {
|
|
368
|
+
const { data } = await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
|
|
369
|
+
return data;
|
|
347
370
|
}
|
|
348
371
|
async saveTemplatesDist(version, sdkVersion, engine, dist) {
|
|
349
372
|
const { data } = await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
|
|
@@ -356,29 +379,136 @@ class Component extends BaseClient {
|
|
|
356
379
|
return data;
|
|
357
380
|
}
|
|
358
381
|
async workflow(event, input) {
|
|
359
|
-
|
|
382
|
+
const { data } = await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
|
|
360
383
|
event,
|
|
361
384
|
input
|
|
362
385
|
});
|
|
386
|
+
return data;
|
|
363
387
|
}
|
|
364
388
|
async function(name, input) {
|
|
365
|
-
|
|
389
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
|
|
390
|
+
return data;
|
|
366
391
|
}
|
|
367
|
-
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
class ComponentUtils extends PlatformBaseClient {
|
|
395
|
+
async list() {
|
|
368
396
|
const { data } = await this.client.get("/v1/system/components");
|
|
369
397
|
return data;
|
|
370
398
|
}
|
|
371
|
-
async
|
|
372
|
-
|
|
399
|
+
async create(data) {
|
|
400
|
+
const { data: responseData } = await this.client.post("/v3/system/component/create", data);
|
|
401
|
+
return responseData;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
class Ratchet extends PlatformBaseClient {
|
|
406
|
+
async query(name, params) {
|
|
407
|
+
let res = await this.client.post('/v1/ratchet/query', {
|
|
408
|
+
name: name,
|
|
409
|
+
params: params
|
|
410
|
+
});
|
|
411
|
+
return res.data;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
class Sandbox extends PlatformBaseClient {
|
|
416
|
+
/**
|
|
417
|
+
* Call the sandbox service to execute a serverless function
|
|
418
|
+
*
|
|
419
|
+
* @param name
|
|
420
|
+
* @param data
|
|
421
|
+
* @returns
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* const result = await platform.sandbox().spark("myFunction", { foo: "bar" })
|
|
425
|
+
*/
|
|
426
|
+
async spark(name, data) {
|
|
427
|
+
return await this.client.post(`/v1/project/sandbox/spark/exec/${name}`, data);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
class System extends PlatformBaseClient {
|
|
432
|
+
async resourceResolver(ref, resourceName, format) {
|
|
433
|
+
const { data } = await this.client.post("/v3/system/resource-resolver", {
|
|
434
|
+
type: resourceName,
|
|
435
|
+
format,
|
|
436
|
+
});
|
|
437
|
+
if (format) {
|
|
438
|
+
return data.format;
|
|
439
|
+
}
|
|
440
|
+
return data;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
class Workflow extends PlatformBaseClient {
|
|
445
|
+
async trigger(id, event, data) {
|
|
446
|
+
return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
|
|
373
447
|
}
|
|
374
448
|
}
|
|
375
449
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
450
|
+
class Forge extends PlatformBaseClient {
|
|
451
|
+
async bundleUpload(buffer) {
|
|
452
|
+
return await this.client.post(`/v3/system/gateway/app-service/forge/upload`, buffer, {
|
|
453
|
+
headers: {
|
|
454
|
+
'Content-Type': 'application/octet-stream',
|
|
455
|
+
'Content-Length': buffer.length
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
async getWorkspaceApps() {
|
|
460
|
+
return await this.client.get(`/v3/system/gateway/app-service/forge/workspace`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
380
463
|
|
|
381
|
-
|
|
464
|
+
// apis
|
|
465
|
+
class Platform extends PlatformBaseClient {
|
|
466
|
+
getPlatformClient() {
|
|
467
|
+
return this.client;
|
|
468
|
+
}
|
|
469
|
+
getPlatformBaseURL() {
|
|
470
|
+
var _a;
|
|
471
|
+
return (_a = this.client.defaults.baseURL) !== null && _a !== undefined ? _a : "";
|
|
472
|
+
}
|
|
473
|
+
apiUser() {
|
|
474
|
+
return (new APIUser()).setClient(this.client);
|
|
475
|
+
}
|
|
476
|
+
function() {
|
|
477
|
+
return (new Functions()).setClient(this.client);
|
|
478
|
+
}
|
|
479
|
+
role() {
|
|
480
|
+
return (new Roles()).setClient(this.client);
|
|
481
|
+
}
|
|
482
|
+
user() {
|
|
483
|
+
return (new Users()).setClient(this.client);
|
|
484
|
+
}
|
|
485
|
+
app(appType) {
|
|
486
|
+
return (new Apps(appType)).setClient(this.client);
|
|
487
|
+
}
|
|
488
|
+
forge() {
|
|
489
|
+
return (new Forge()).setClient(this.client);
|
|
490
|
+
}
|
|
491
|
+
component(ref) {
|
|
492
|
+
return (new Component(ref)).setClient(this.client);
|
|
493
|
+
}
|
|
494
|
+
componentUtils() {
|
|
495
|
+
return (new ComponentUtils()).setClient(this.client);
|
|
496
|
+
}
|
|
497
|
+
ratchet() {
|
|
498
|
+
return (new Ratchet()).setClient(this.client);
|
|
499
|
+
}
|
|
500
|
+
sandbox() {
|
|
501
|
+
return (new Sandbox()).setClient(this.client);
|
|
502
|
+
}
|
|
503
|
+
system() {
|
|
504
|
+
return (new System()).setClient(this.client);
|
|
505
|
+
}
|
|
506
|
+
workflow() {
|
|
507
|
+
return (new Workflow()).setClient(this.client);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
class Invoicing extends PlatformBaseClient {
|
|
382
512
|
async getSalesInvoices(provider, page) {
|
|
383
513
|
return await this.request("GET", `/invoices/${provider}/sales`, {
|
|
384
514
|
params: {
|
|
@@ -397,13 +527,48 @@ class Invoicing extends BaseClient {
|
|
|
397
527
|
async request(method, endpoint, params) {
|
|
398
528
|
return await this.client.request({
|
|
399
529
|
method: method,
|
|
400
|
-
url: `/v1/karadjordje/${endpoint}`,
|
|
530
|
+
url: `/v1/integrations/karadjordje/${endpoint}`,
|
|
401
531
|
...params
|
|
402
532
|
});
|
|
403
533
|
}
|
|
404
534
|
}
|
|
405
535
|
|
|
406
|
-
class
|
|
536
|
+
class IntegrationsBaseClient extends BaseClient {
|
|
537
|
+
constructor(options) {
|
|
538
|
+
var _a, _b;
|
|
539
|
+
let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
|
|
540
|
+
let headers = {};
|
|
541
|
+
if (isBrowser) {
|
|
542
|
+
if (localStorage.getItem('protokol_context') == "forge") {
|
|
543
|
+
headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
// this potentially means that it is running as dev server in local
|
|
547
|
+
headers['X-Project-Env'] = "dev";
|
|
548
|
+
}
|
|
549
|
+
// @ts-ignore
|
|
550
|
+
const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
|
|
551
|
+
host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== undefined ? _b : host;
|
|
552
|
+
}
|
|
553
|
+
if (token) {
|
|
554
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
555
|
+
}
|
|
556
|
+
if (env) {
|
|
557
|
+
headers['X-Project-Env'] = env;
|
|
558
|
+
}
|
|
559
|
+
const client = axios.create({
|
|
560
|
+
baseURL: host !== null && host !== undefined ? host : "https://orange.protokol.io",
|
|
561
|
+
timeout: 15000,
|
|
562
|
+
headers: {
|
|
563
|
+
...headers,
|
|
564
|
+
},
|
|
565
|
+
withCredentials: true,
|
|
566
|
+
});
|
|
567
|
+
super(client);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
class Media extends IntegrationsBaseClient {
|
|
407
572
|
async list(data) {
|
|
408
573
|
return this.request('POST', 'list', { data });
|
|
409
574
|
}
|
|
@@ -513,7 +678,7 @@ class Media extends BaseClient {
|
|
|
513
678
|
}
|
|
514
679
|
}
|
|
515
680
|
|
|
516
|
-
class SerbiaUtil extends
|
|
681
|
+
class SerbiaUtil extends IntegrationsBaseClient {
|
|
517
682
|
async nsbSearch(params) {
|
|
518
683
|
return await this.services("GET", "nbs/search", { params });
|
|
519
684
|
}
|
|
@@ -540,7 +705,7 @@ class SerbiaUtil extends BaseClient {
|
|
|
540
705
|
}
|
|
541
706
|
}
|
|
542
707
|
|
|
543
|
-
class VPFR extends
|
|
708
|
+
class VPFR extends IntegrationsBaseClient {
|
|
544
709
|
async request(method, endpoint, params) {
|
|
545
710
|
return await this.client.request({
|
|
546
711
|
method: method,
|
|
@@ -550,14 +715,15 @@ class VPFR extends BaseClient {
|
|
|
550
715
|
}
|
|
551
716
|
}
|
|
552
717
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
718
|
+
// import integrations
|
|
719
|
+
class Integrations extends IntegrationsBaseClient {
|
|
720
|
+
constructor(options) {
|
|
721
|
+
super(options);
|
|
556
722
|
this.integrations = {
|
|
557
|
-
'protokol-invoicing': new Invoicing(
|
|
558
|
-
'protokol-vpfr': new VPFR(
|
|
559
|
-
'protokol-media': new Media(
|
|
560
|
-
'serbia-utilities': new SerbiaUtil(
|
|
723
|
+
'protokol-invoicing': new Invoicing().setClient(this.client),
|
|
724
|
+
'protokol-vpfr': new VPFR().setClient(this.client),
|
|
725
|
+
'protokol-media': new Media().setClient(this.client),
|
|
726
|
+
'serbia-utilities': new SerbiaUtil().setClient(this.client),
|
|
561
727
|
};
|
|
562
728
|
}
|
|
563
729
|
getSerbiaUtilities() {
|
|
@@ -586,181 +752,4 @@ class Integrations extends BaseClient {
|
|
|
586
752
|
}
|
|
587
753
|
}
|
|
588
754
|
|
|
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 };
|
|
755
|
+
export { APIUser, Apps, Component, ComponentUtils, Functions, Integrations as Integration, Ratchet, Roles, Sandbox, System, Users, Workflow, Platform as default };
|