@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.cjs.js
CHANGED
|
@@ -17814,9 +17814,73 @@ class BaseClient {
|
|
|
17814
17814
|
constructor(client) {
|
|
17815
17815
|
this.client = client;
|
|
17816
17816
|
}
|
|
17817
|
+
setClient(client) {
|
|
17818
|
+
this.client = client;
|
|
17819
|
+
return this;
|
|
17820
|
+
}
|
|
17817
17821
|
}
|
|
17818
17822
|
|
|
17819
|
-
|
|
17823
|
+
typeof process !== "undefined" &&
|
|
17824
|
+
process.versions != null &&
|
|
17825
|
+
process.versions.node != null;
|
|
17826
|
+
const isBrowser = typeof window !== "undefined" &&
|
|
17827
|
+
typeof document !== "undefined";
|
|
17828
|
+
|
|
17829
|
+
/**
|
|
17830
|
+
* Base client for the platform API
|
|
17831
|
+
* Classes that extend PlatformBaseClient have intentins of only working in platform context
|
|
17832
|
+
*
|
|
17833
|
+
*
|
|
17834
|
+
* @class PlatformBaseClient
|
|
17835
|
+
* @extends BaseClient
|
|
17836
|
+
* @constructor
|
|
17837
|
+
* @param {AxiosInstance} [client] - The axios instance to use for the client
|
|
17838
|
+
*
|
|
17839
|
+
* @example
|
|
17840
|
+
* // if sdk is used in the forge app that is running in the platform context
|
|
17841
|
+
* const utils = new ComponentUtils()
|
|
17842
|
+
* // this won't work outside of platform context because client needs authtorization to communicate with the API.
|
|
17843
|
+
*
|
|
17844
|
+
*/
|
|
17845
|
+
class PlatformBaseClient extends BaseClient {
|
|
17846
|
+
constructor(options) {
|
|
17847
|
+
var _a, _b;
|
|
17848
|
+
let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
|
|
17849
|
+
let headers = {};
|
|
17850
|
+
if (isBrowser) {
|
|
17851
|
+
if (localStorage.getItem('protokol_context') == "forge") {
|
|
17852
|
+
headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
|
|
17853
|
+
}
|
|
17854
|
+
else {
|
|
17855
|
+
// this potentially means that it is running as dev server in local
|
|
17856
|
+
headers['X-Project-Env'] = "dev";
|
|
17857
|
+
}
|
|
17858
|
+
// @ts-ignore
|
|
17859
|
+
const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
|
|
17860
|
+
host = (_b = __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.API_HOST) !== null && _b !== undefined ? _b : host;
|
|
17861
|
+
}
|
|
17862
|
+
if (token) {
|
|
17863
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
17864
|
+
}
|
|
17865
|
+
if (env) {
|
|
17866
|
+
headers['X-Project-Env'] = env;
|
|
17867
|
+
}
|
|
17868
|
+
const client = axios.create({
|
|
17869
|
+
baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
|
|
17870
|
+
timeout: 15000,
|
|
17871
|
+
headers: {
|
|
17872
|
+
...headers,
|
|
17873
|
+
},
|
|
17874
|
+
withCredentials: true,
|
|
17875
|
+
});
|
|
17876
|
+
super(client);
|
|
17877
|
+
this.env = null;
|
|
17878
|
+
this.token = null;
|
|
17879
|
+
this.host = null;
|
|
17880
|
+
}
|
|
17881
|
+
}
|
|
17882
|
+
|
|
17883
|
+
class Functions extends PlatformBaseClient {
|
|
17820
17884
|
async list() {
|
|
17821
17885
|
return await this.client.get("/v1/system/function");
|
|
17822
17886
|
}
|
|
@@ -17849,12 +17913,7 @@ class Functions extends BaseClient {
|
|
|
17849
17913
|
}
|
|
17850
17914
|
}
|
|
17851
17915
|
|
|
17852
|
-
|
|
17853
|
-
__proto__: null,
|
|
17854
|
-
default: Functions
|
|
17855
|
-
});
|
|
17856
|
-
|
|
17857
|
-
class Roles extends BaseClient {
|
|
17916
|
+
class Roles extends PlatformBaseClient {
|
|
17858
17917
|
async create(role) {
|
|
17859
17918
|
const res = await this.client.post("/v1/user/role/create", role);
|
|
17860
17919
|
// writeFileSync(`.role.create.json`,JSON.stringify(res))
|
|
@@ -17878,16 +17937,15 @@ class Roles extends BaseClient {
|
|
|
17878
17937
|
}
|
|
17879
17938
|
}
|
|
17880
17939
|
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
default: Roles
|
|
17884
|
-
});
|
|
17885
|
-
|
|
17886
|
-
class APIUser extends BaseClient {
|
|
17887
|
-
async apiAuth(username, password) {
|
|
17940
|
+
class APIUser extends PlatformBaseClient {
|
|
17941
|
+
async auth(username, password, project) {
|
|
17888
17942
|
return this.client.post("/v1/user/api/auth", {
|
|
17889
17943
|
username,
|
|
17890
17944
|
password
|
|
17945
|
+
}, {
|
|
17946
|
+
headers: {
|
|
17947
|
+
"X-Project-Uuid": project
|
|
17948
|
+
}
|
|
17891
17949
|
});
|
|
17892
17950
|
}
|
|
17893
17951
|
async newSecret(uuid) {
|
|
@@ -17907,12 +17965,7 @@ class APIUser extends BaseClient {
|
|
|
17907
17965
|
}
|
|
17908
17966
|
}
|
|
17909
17967
|
|
|
17910
|
-
|
|
17911
|
-
__proto__: null,
|
|
17912
|
-
default: APIUser
|
|
17913
|
-
});
|
|
17914
|
-
|
|
17915
|
-
class Users extends BaseClient {
|
|
17968
|
+
class Users extends PlatformBaseClient {
|
|
17916
17969
|
async invite(email, roles) {
|
|
17917
17970
|
return await this.client.post("/v1/project/invite", {
|
|
17918
17971
|
email,
|
|
@@ -17924,14 +17977,9 @@ class Users extends BaseClient {
|
|
|
17924
17977
|
}
|
|
17925
17978
|
}
|
|
17926
17979
|
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
});
|
|
17931
|
-
|
|
17932
|
-
class Apps extends BaseClient {
|
|
17933
|
-
constructor(client, appType) {
|
|
17934
|
-
super(client);
|
|
17980
|
+
class Apps extends PlatformBaseClient {
|
|
17981
|
+
constructor(appType) {
|
|
17982
|
+
super();
|
|
17935
17983
|
this.appType = appType;
|
|
17936
17984
|
}
|
|
17937
17985
|
async updateSettings(updateValues, ref) {
|
|
@@ -17948,19 +17996,10 @@ class Apps extends BaseClient {
|
|
|
17948
17996
|
}
|
|
17949
17997
|
}
|
|
17950
17998
|
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
});
|
|
17955
|
-
|
|
17956
|
-
class Component extends BaseClient {
|
|
17957
|
-
constructor(adapter, ref) {
|
|
17958
|
-
super(adapter);
|
|
17959
|
-
this.ref = ref;
|
|
17960
|
-
}
|
|
17961
|
-
new(ref) {
|
|
17999
|
+
class Component extends PlatformBaseClient {
|
|
18000
|
+
constructor(ref = null) {
|
|
18001
|
+
super();
|
|
17962
18002
|
this.ref = ref;
|
|
17963
|
-
return this;
|
|
17964
18003
|
}
|
|
17965
18004
|
/**
|
|
17966
18005
|
* Find method to search for models
|
|
@@ -18071,14 +18110,9 @@ class Component extends BaseClient {
|
|
|
18071
18110
|
* @param uuid string - The uuid of the model
|
|
18072
18111
|
* @returns (Promise<Model>)
|
|
18073
18112
|
*/
|
|
18074
|
-
get(uuid) {
|
|
18075
|
-
|
|
18076
|
-
|
|
18077
|
-
resolve(resp.data);
|
|
18078
|
-
}).catch((error) => {
|
|
18079
|
-
reject(error);
|
|
18080
|
-
});
|
|
18081
|
-
});
|
|
18113
|
+
async get(uuid) {
|
|
18114
|
+
const { data } = await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
|
|
18115
|
+
return data;
|
|
18082
18116
|
}
|
|
18083
18117
|
/**
|
|
18084
18118
|
* Update model by uuid
|
|
@@ -18087,73 +18121,62 @@ class Component extends BaseClient {
|
|
|
18087
18121
|
* @param data
|
|
18088
18122
|
* @returns
|
|
18089
18123
|
*/
|
|
18090
|
-
update(uuid, data) {
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
}).then((resp) => {
|
|
18095
|
-
resolve(resp.data);
|
|
18096
|
-
}).catch((error) => {
|
|
18097
|
-
reject(error);
|
|
18098
|
-
});
|
|
18124
|
+
async update(uuid, data, options) {
|
|
18125
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
|
|
18126
|
+
data,
|
|
18127
|
+
options,
|
|
18099
18128
|
});
|
|
18129
|
+
return responseData;
|
|
18100
18130
|
}
|
|
18101
|
-
|
|
18102
|
-
|
|
18103
|
-
|
|
18104
|
-
|
|
18105
|
-
|
|
18106
|
-
|
|
18107
|
-
|
|
18108
|
-
|
|
18109
|
-
|
|
18110
|
-
|
|
18131
|
+
/**
|
|
18132
|
+
* Update many models
|
|
18133
|
+
*
|
|
18134
|
+
* @param data
|
|
18135
|
+
* @param options
|
|
18136
|
+
* @returns
|
|
18137
|
+
*/
|
|
18138
|
+
async updateMany(data, options) {
|
|
18139
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
|
|
18140
|
+
data,
|
|
18141
|
+
options,
|
|
18111
18142
|
});
|
|
18143
|
+
return responseData;
|
|
18112
18144
|
}
|
|
18113
|
-
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18145
|
+
/**
|
|
18146
|
+
* Concurrent update model by uuid
|
|
18147
|
+
*
|
|
18148
|
+
* @param uuid string - The uuid of the model
|
|
18149
|
+
* @param version number - The version of the model
|
|
18150
|
+
* @param data
|
|
18151
|
+
* @returns
|
|
18152
|
+
*/
|
|
18153
|
+
async concurrentUpdate(uuid, version, data, options) {
|
|
18154
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
|
|
18155
|
+
version: version,
|
|
18156
|
+
data,
|
|
18157
|
+
options,
|
|
18120
18158
|
});
|
|
18159
|
+
return responseData;
|
|
18121
18160
|
}
|
|
18122
|
-
|
|
18123
|
-
|
|
18124
|
-
|
|
18125
|
-
resolve(resp.data);
|
|
18126
|
-
}).catch((error) => {
|
|
18127
|
-
reject(error);
|
|
18128
|
-
});
|
|
18129
|
-
});
|
|
18161
|
+
async create(model) {
|
|
18162
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/model`, model);
|
|
18163
|
+
return data;
|
|
18130
18164
|
}
|
|
18131
|
-
|
|
18132
|
-
|
|
18133
|
-
|
|
18134
|
-
resolve(resp.data);
|
|
18135
|
-
}).catch((error) => {
|
|
18136
|
-
reject(error);
|
|
18137
|
-
});
|
|
18138
|
-
});
|
|
18165
|
+
async delete(uuid) {
|
|
18166
|
+
const { data } = await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
|
|
18167
|
+
return data;
|
|
18139
18168
|
}
|
|
18140
|
-
|
|
18141
|
-
|
|
18142
|
-
|
|
18143
|
-
resolve(resp.data);
|
|
18144
|
-
}).catch(err => {
|
|
18145
|
-
reject(err);
|
|
18146
|
-
});
|
|
18147
|
-
});
|
|
18169
|
+
async aggregate(pipeline) {
|
|
18170
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
|
|
18171
|
+
return data;
|
|
18148
18172
|
}
|
|
18149
|
-
|
|
18150
|
-
|
|
18151
|
-
|
|
18152
|
-
|
|
18153
|
-
|
|
18154
|
-
|
|
18155
|
-
|
|
18156
|
-
});
|
|
18173
|
+
async settings() {
|
|
18174
|
+
const { data } = await this.client.get(`/v3/system/component/settings/${this.ref}`);
|
|
18175
|
+
return data;
|
|
18176
|
+
}
|
|
18177
|
+
async saveSettings(settings, version) {
|
|
18178
|
+
const { data } = await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
|
|
18179
|
+
return data;
|
|
18157
18180
|
}
|
|
18158
18181
|
async saveTemplatesDist(version, sdkVersion, engine, dist) {
|
|
18159
18182
|
const { data } = await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
|
|
@@ -18166,29 +18189,136 @@ class Component extends BaseClient {
|
|
|
18166
18189
|
return data;
|
|
18167
18190
|
}
|
|
18168
18191
|
async workflow(event, input) {
|
|
18169
|
-
|
|
18192
|
+
const { data } = await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
|
|
18170
18193
|
event,
|
|
18171
18194
|
input
|
|
18172
18195
|
});
|
|
18196
|
+
return data;
|
|
18173
18197
|
}
|
|
18174
18198
|
async function(name, input) {
|
|
18175
|
-
|
|
18199
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
|
|
18200
|
+
return data;
|
|
18176
18201
|
}
|
|
18177
|
-
|
|
18202
|
+
}
|
|
18203
|
+
|
|
18204
|
+
class ComponentUtils extends PlatformBaseClient {
|
|
18205
|
+
async list() {
|
|
18178
18206
|
const { data } = await this.client.get("/v1/system/components");
|
|
18179
18207
|
return data;
|
|
18180
18208
|
}
|
|
18181
|
-
async
|
|
18182
|
-
|
|
18209
|
+
async create(data) {
|
|
18210
|
+
const { data: responseData } = await this.client.post("/v3/system/component/create", data);
|
|
18211
|
+
return responseData;
|
|
18183
18212
|
}
|
|
18184
18213
|
}
|
|
18185
18214
|
|
|
18186
|
-
|
|
18187
|
-
|
|
18188
|
-
|
|
18189
|
-
|
|
18215
|
+
class Ratchet extends PlatformBaseClient {
|
|
18216
|
+
async query(name, params) {
|
|
18217
|
+
let res = await this.client.post('/v1/ratchet/query', {
|
|
18218
|
+
name: name,
|
|
18219
|
+
params: params
|
|
18220
|
+
});
|
|
18221
|
+
return res.data;
|
|
18222
|
+
}
|
|
18223
|
+
}
|
|
18190
18224
|
|
|
18191
|
-
class
|
|
18225
|
+
class Sandbox extends PlatformBaseClient {
|
|
18226
|
+
/**
|
|
18227
|
+
* Call the sandbox service to execute a serverless function
|
|
18228
|
+
*
|
|
18229
|
+
* @param name
|
|
18230
|
+
* @param data
|
|
18231
|
+
* @returns
|
|
18232
|
+
*
|
|
18233
|
+
* @example
|
|
18234
|
+
* const result = await platform.sandbox().spark("myFunction", { foo: "bar" })
|
|
18235
|
+
*/
|
|
18236
|
+
async spark(name, data) {
|
|
18237
|
+
return await this.client.post(`/v1/project/sandbox/spark/exec/${name}`, data);
|
|
18238
|
+
}
|
|
18239
|
+
}
|
|
18240
|
+
|
|
18241
|
+
class System extends PlatformBaseClient {
|
|
18242
|
+
async resourceResolver(ref, resourceName, format) {
|
|
18243
|
+
const { data } = await this.client.post("/v3/system/resource-resolver", {
|
|
18244
|
+
type: resourceName,
|
|
18245
|
+
format,
|
|
18246
|
+
});
|
|
18247
|
+
if (format) {
|
|
18248
|
+
return data.format;
|
|
18249
|
+
}
|
|
18250
|
+
return data;
|
|
18251
|
+
}
|
|
18252
|
+
}
|
|
18253
|
+
|
|
18254
|
+
class Workflow extends PlatformBaseClient {
|
|
18255
|
+
async trigger(id, event, data) {
|
|
18256
|
+
return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
|
|
18257
|
+
}
|
|
18258
|
+
}
|
|
18259
|
+
|
|
18260
|
+
class Forge extends PlatformBaseClient {
|
|
18261
|
+
async bundleUpload(buffer) {
|
|
18262
|
+
return await this.client.post(`/v3/system/gateway/app-service/forge/upload`, buffer, {
|
|
18263
|
+
headers: {
|
|
18264
|
+
'Content-Type': 'application/octet-stream',
|
|
18265
|
+
'Content-Length': buffer.length
|
|
18266
|
+
}
|
|
18267
|
+
});
|
|
18268
|
+
}
|
|
18269
|
+
async getWorkspaceApps() {
|
|
18270
|
+
return await this.client.get(`/v3/system/gateway/app-service/forge/workspace`);
|
|
18271
|
+
}
|
|
18272
|
+
}
|
|
18273
|
+
|
|
18274
|
+
// apis
|
|
18275
|
+
class Platform extends PlatformBaseClient {
|
|
18276
|
+
getPlatformClient() {
|
|
18277
|
+
return this.client;
|
|
18278
|
+
}
|
|
18279
|
+
getPlatformBaseURL() {
|
|
18280
|
+
var _a;
|
|
18281
|
+
return (_a = this.client.defaults.baseURL) !== null && _a !== undefined ? _a : "";
|
|
18282
|
+
}
|
|
18283
|
+
apiUser() {
|
|
18284
|
+
return (new APIUser()).setClient(this.client);
|
|
18285
|
+
}
|
|
18286
|
+
function() {
|
|
18287
|
+
return (new Functions()).setClient(this.client);
|
|
18288
|
+
}
|
|
18289
|
+
role() {
|
|
18290
|
+
return (new Roles()).setClient(this.client);
|
|
18291
|
+
}
|
|
18292
|
+
user() {
|
|
18293
|
+
return (new Users()).setClient(this.client);
|
|
18294
|
+
}
|
|
18295
|
+
app(appType) {
|
|
18296
|
+
return (new Apps(appType)).setClient(this.client);
|
|
18297
|
+
}
|
|
18298
|
+
forge() {
|
|
18299
|
+
return (new Forge()).setClient(this.client);
|
|
18300
|
+
}
|
|
18301
|
+
component(ref) {
|
|
18302
|
+
return (new Component(ref)).setClient(this.client);
|
|
18303
|
+
}
|
|
18304
|
+
componentUtils() {
|
|
18305
|
+
return (new ComponentUtils()).setClient(this.client);
|
|
18306
|
+
}
|
|
18307
|
+
ratchet() {
|
|
18308
|
+
return (new Ratchet()).setClient(this.client);
|
|
18309
|
+
}
|
|
18310
|
+
sandbox() {
|
|
18311
|
+
return (new Sandbox()).setClient(this.client);
|
|
18312
|
+
}
|
|
18313
|
+
system() {
|
|
18314
|
+
return (new System()).setClient(this.client);
|
|
18315
|
+
}
|
|
18316
|
+
workflow() {
|
|
18317
|
+
return (new Workflow()).setClient(this.client);
|
|
18318
|
+
}
|
|
18319
|
+
}
|
|
18320
|
+
|
|
18321
|
+
class Invoicing extends PlatformBaseClient {
|
|
18192
18322
|
async getSalesInvoices(provider, page) {
|
|
18193
18323
|
return await this.request("GET", `/invoices/${provider}/sales`, {
|
|
18194
18324
|
params: {
|
|
@@ -18207,13 +18337,48 @@ class Invoicing extends BaseClient {
|
|
|
18207
18337
|
async request(method, endpoint, params) {
|
|
18208
18338
|
return await this.client.request({
|
|
18209
18339
|
method: method,
|
|
18210
|
-
url: `/v1/karadjordje/${endpoint}`,
|
|
18340
|
+
url: `/v1/integrations/karadjordje/${endpoint}`,
|
|
18211
18341
|
...params
|
|
18212
18342
|
});
|
|
18213
18343
|
}
|
|
18214
18344
|
}
|
|
18215
18345
|
|
|
18216
|
-
class
|
|
18346
|
+
class IntegrationsBaseClient extends BaseClient {
|
|
18347
|
+
constructor(options) {
|
|
18348
|
+
var _a, _b;
|
|
18349
|
+
let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
|
|
18350
|
+
let headers = {};
|
|
18351
|
+
if (isBrowser) {
|
|
18352
|
+
if (localStorage.getItem('protokol_context') == "forge") {
|
|
18353
|
+
headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
|
|
18354
|
+
}
|
|
18355
|
+
else {
|
|
18356
|
+
// this potentially means that it is running as dev server in local
|
|
18357
|
+
headers['X-Project-Env'] = "dev";
|
|
18358
|
+
}
|
|
18359
|
+
// @ts-ignore
|
|
18360
|
+
const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
|
|
18361
|
+
host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== undefined ? _b : host;
|
|
18362
|
+
}
|
|
18363
|
+
if (token) {
|
|
18364
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
18365
|
+
}
|
|
18366
|
+
if (env) {
|
|
18367
|
+
headers['X-Project-Env'] = env;
|
|
18368
|
+
}
|
|
18369
|
+
const client = axios.create({
|
|
18370
|
+
baseURL: host !== null && host !== undefined ? host : "https://orange.protokol.io",
|
|
18371
|
+
timeout: 15000,
|
|
18372
|
+
headers: {
|
|
18373
|
+
...headers,
|
|
18374
|
+
},
|
|
18375
|
+
withCredentials: true,
|
|
18376
|
+
});
|
|
18377
|
+
super(client);
|
|
18378
|
+
}
|
|
18379
|
+
}
|
|
18380
|
+
|
|
18381
|
+
class Media extends IntegrationsBaseClient {
|
|
18217
18382
|
async list(data) {
|
|
18218
18383
|
return this.request('POST', 'list', { data });
|
|
18219
18384
|
}
|
|
@@ -18323,7 +18488,7 @@ class Media extends BaseClient {
|
|
|
18323
18488
|
}
|
|
18324
18489
|
}
|
|
18325
18490
|
|
|
18326
|
-
class SerbiaUtil extends
|
|
18491
|
+
class SerbiaUtil extends IntegrationsBaseClient {
|
|
18327
18492
|
async nsbSearch(params) {
|
|
18328
18493
|
return await this.services("GET", "nbs/search", { params });
|
|
18329
18494
|
}
|
|
@@ -18350,7 +18515,7 @@ class SerbiaUtil extends BaseClient {
|
|
|
18350
18515
|
}
|
|
18351
18516
|
}
|
|
18352
18517
|
|
|
18353
|
-
class VPFR extends
|
|
18518
|
+
class VPFR extends IntegrationsBaseClient {
|
|
18354
18519
|
async request(method, endpoint, params) {
|
|
18355
18520
|
return await this.client.request({
|
|
18356
18521
|
method: method,
|
|
@@ -18360,14 +18525,15 @@ class VPFR extends BaseClient {
|
|
|
18360
18525
|
}
|
|
18361
18526
|
}
|
|
18362
18527
|
|
|
18363
|
-
|
|
18364
|
-
|
|
18365
|
-
|
|
18528
|
+
// import integrations
|
|
18529
|
+
class Integrations extends IntegrationsBaseClient {
|
|
18530
|
+
constructor(options) {
|
|
18531
|
+
super(options);
|
|
18366
18532
|
this.integrations = {
|
|
18367
|
-
'protokol-invoicing': new Invoicing(
|
|
18368
|
-
'protokol-vpfr': new VPFR(
|
|
18369
|
-
'protokol-media': new Media(
|
|
18370
|
-
'serbia-utilities': new SerbiaUtil(
|
|
18533
|
+
'protokol-invoicing': new Invoicing().setClient(this.client),
|
|
18534
|
+
'protokol-vpfr': new VPFR().setClient(this.client),
|
|
18535
|
+
'protokol-media': new Media().setClient(this.client),
|
|
18536
|
+
'serbia-utilities': new SerbiaUtil().setClient(this.client),
|
|
18371
18537
|
};
|
|
18372
18538
|
}
|
|
18373
18539
|
getSerbiaUtilities() {
|
|
@@ -18396,192 +18562,16 @@ class Integrations extends BaseClient {
|
|
|
18396
18562
|
}
|
|
18397
18563
|
}
|
|
18398
18564
|
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
|
|
18405
|
-
|
|
18406
|
-
|
|
18407
|
-
|
|
18408
|
-
|
|
18409
|
-
|
|
18410
|
-
|
|
18411
|
-
}
|
|
18412
|
-
}
|
|
18413
|
-
|
|
18414
|
-
var ratchet = /*#__PURE__*/Object.freeze({
|
|
18415
|
-
__proto__: null,
|
|
18416
|
-
default: Ratchet
|
|
18417
|
-
});
|
|
18418
|
-
|
|
18419
|
-
class Sandbox extends BaseClient {
|
|
18420
|
-
/**
|
|
18421
|
-
* Call the sandbox service to execute a serverless function
|
|
18422
|
-
*
|
|
18423
|
-
* @param name
|
|
18424
|
-
* @param data
|
|
18425
|
-
* @returns
|
|
18426
|
-
*
|
|
18427
|
-
* @example
|
|
18428
|
-
* const result = await platform.sandbox().spark("myFunction", { foo: "bar" })
|
|
18429
|
-
*/
|
|
18430
|
-
async spark(name, data) {
|
|
18431
|
-
return await this.client.post(`/v1/project/sandbox/spark/exec/${name}`, data);
|
|
18432
|
-
}
|
|
18433
|
-
}
|
|
18434
|
-
|
|
18435
|
-
var sandbox = /*#__PURE__*/Object.freeze({
|
|
18436
|
-
__proto__: null,
|
|
18437
|
-
default: Sandbox
|
|
18438
|
-
});
|
|
18439
|
-
|
|
18440
|
-
class System extends BaseClient {
|
|
18441
|
-
async resourceResolver(ref, resourceName, format) {
|
|
18442
|
-
const { data } = await this.client.post("/v3/system/resource-resolver", {
|
|
18443
|
-
type: resourceName,
|
|
18444
|
-
format,
|
|
18445
|
-
});
|
|
18446
|
-
if (format) {
|
|
18447
|
-
return data.format;
|
|
18448
|
-
}
|
|
18449
|
-
return data;
|
|
18450
|
-
}
|
|
18451
|
-
}
|
|
18452
|
-
|
|
18453
|
-
var system = /*#__PURE__*/Object.freeze({
|
|
18454
|
-
__proto__: null,
|
|
18455
|
-
default: System
|
|
18456
|
-
});
|
|
18457
|
-
|
|
18458
|
-
class Workflow extends BaseClient {
|
|
18459
|
-
async trigger(id, event, data) {
|
|
18460
|
-
return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
|
|
18461
|
-
}
|
|
18462
|
-
}
|
|
18463
|
-
|
|
18464
|
-
var workflow = /*#__PURE__*/Object.freeze({
|
|
18465
|
-
__proto__: null,
|
|
18466
|
-
default: Workflow
|
|
18467
|
-
});
|
|
18468
|
-
|
|
18469
|
-
class Forge extends BaseClient {
|
|
18470
|
-
constructor(client) {
|
|
18471
|
-
super(client);
|
|
18472
|
-
}
|
|
18473
|
-
async bundleUpload(buffer) {
|
|
18474
|
-
return await this.client.post(`/v3/system/gateway/app-service/forge/upload`, buffer, {
|
|
18475
|
-
headers: {
|
|
18476
|
-
'Content-Type': 'application/octet-stream',
|
|
18477
|
-
'Content-Length': buffer.length
|
|
18478
|
-
}
|
|
18479
|
-
});
|
|
18480
|
-
}
|
|
18481
|
-
async getWorkspaceApps() {
|
|
18482
|
-
return await this.client.get(`/v3/system/gateway/app-service/forge/workspace`);
|
|
18483
|
-
}
|
|
18484
|
-
}
|
|
18485
|
-
|
|
18486
|
-
typeof process !== "undefined" &&
|
|
18487
|
-
process.versions != null &&
|
|
18488
|
-
process.versions.node != null;
|
|
18489
|
-
const isBrowser = typeof window !== "undefined" &&
|
|
18490
|
-
typeof document !== "undefined";
|
|
18491
|
-
|
|
18492
|
-
class Platform {
|
|
18493
|
-
constructor(options) {
|
|
18494
|
-
var _a;
|
|
18495
|
-
let { env = null, token, host, integrationHost } = options !== null && options !== undefined ? options : {};
|
|
18496
|
-
let headers = {};
|
|
18497
|
-
if (isBrowser) {
|
|
18498
|
-
if (localStorage.getItem('protokol_context') == "forge") {
|
|
18499
|
-
headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
|
|
18500
|
-
}
|
|
18501
|
-
else {
|
|
18502
|
-
// this potentially means that it is running as dev server in local
|
|
18503
|
-
headers['X-Project-Env'] = "dev";
|
|
18504
|
-
}
|
|
18505
|
-
}
|
|
18506
|
-
if (token) {
|
|
18507
|
-
headers['Authorization'] = `Bearer ${token}`;
|
|
18508
|
-
}
|
|
18509
|
-
if (env) {
|
|
18510
|
-
headers['X-Project-Env'] = env;
|
|
18511
|
-
}
|
|
18512
|
-
this.platformClient = axios.create({
|
|
18513
|
-
baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
|
|
18514
|
-
timeout: 15000,
|
|
18515
|
-
headers: {
|
|
18516
|
-
...headers,
|
|
18517
|
-
},
|
|
18518
|
-
withCredentials: true,
|
|
18519
|
-
});
|
|
18520
|
-
this.integrationsClient = axios.create({
|
|
18521
|
-
baseURL: integrationHost !== null && integrationHost !== undefined ? integrationHost : "https://orange.protokol.io",
|
|
18522
|
-
timeout: 15000,
|
|
18523
|
-
headers: {
|
|
18524
|
-
...headers,
|
|
18525
|
-
}
|
|
18526
|
-
});
|
|
18527
|
-
}
|
|
18528
|
-
setPlatformClient(client) {
|
|
18529
|
-
this.platformClient = client;
|
|
18530
|
-
}
|
|
18531
|
-
getPlatformClient() {
|
|
18532
|
-
return this.platformClient;
|
|
18533
|
-
}
|
|
18534
|
-
getPlatformBaseURL() {
|
|
18535
|
-
var _a;
|
|
18536
|
-
return (_a = this.platformClient.defaults.baseURL) !== null && _a !== undefined ? _a : "";
|
|
18537
|
-
}
|
|
18538
|
-
apiUser() {
|
|
18539
|
-
return new APIUser(this.platformClient);
|
|
18540
|
-
}
|
|
18541
|
-
function() {
|
|
18542
|
-
return new Functions(this.platformClient);
|
|
18543
|
-
}
|
|
18544
|
-
role() {
|
|
18545
|
-
return new Roles(this.platformClient);
|
|
18546
|
-
}
|
|
18547
|
-
user() {
|
|
18548
|
-
return new Users(this.platformClient);
|
|
18549
|
-
}
|
|
18550
|
-
app(appType) {
|
|
18551
|
-
return new Apps(this.platformClient, appType);
|
|
18552
|
-
}
|
|
18553
|
-
forge() {
|
|
18554
|
-
return new Forge(this.platformClient);
|
|
18555
|
-
}
|
|
18556
|
-
component(ref) {
|
|
18557
|
-
return new Component(this.platformClient, ref);
|
|
18558
|
-
}
|
|
18559
|
-
integrations() {
|
|
18560
|
-
return new Integrations(this.integrationsClient);
|
|
18561
|
-
}
|
|
18562
|
-
ratchet() {
|
|
18563
|
-
return new Ratchet(this.platformClient);
|
|
18564
|
-
}
|
|
18565
|
-
sandbox() {
|
|
18566
|
-
return new Sandbox(this.platformClient);
|
|
18567
|
-
}
|
|
18568
|
-
system() {
|
|
18569
|
-
return new System(this.platformClient);
|
|
18570
|
-
}
|
|
18571
|
-
workflow() {
|
|
18572
|
-
return new Workflow(this.platformClient);
|
|
18573
|
-
}
|
|
18574
|
-
}
|
|
18575
|
-
|
|
18576
|
-
exports.APIUser = apiUser;
|
|
18577
|
-
exports.Apps = apps;
|
|
18578
|
-
exports.Component = component;
|
|
18579
|
-
exports.Functions = functions;
|
|
18580
|
-
exports.Integration = integrations;
|
|
18581
|
-
exports.Ratchet = ratchet;
|
|
18582
|
-
exports.Roles = roles;
|
|
18583
|
-
exports.Sandbox = sandbox;
|
|
18584
|
-
exports.System = system;
|
|
18585
|
-
exports.Users = users;
|
|
18586
|
-
exports.Workflow = workflow;
|
|
18565
|
+
exports.APIUser = APIUser;
|
|
18566
|
+
exports.Apps = Apps;
|
|
18567
|
+
exports.Component = Component;
|
|
18568
|
+
exports.ComponentUtils = ComponentUtils;
|
|
18569
|
+
exports.Functions = Functions;
|
|
18570
|
+
exports.Integration = Integrations;
|
|
18571
|
+
exports.Ratchet = Ratchet;
|
|
18572
|
+
exports.Roles = Roles;
|
|
18573
|
+
exports.Sandbox = Sandbox;
|
|
18574
|
+
exports.System = System;
|
|
18575
|
+
exports.Users = Users;
|
|
18576
|
+
exports.Workflow = Workflow;
|
|
18587
18577
|
exports.default = Platform;
|