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