@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.cjs.js
CHANGED
|
@@ -17814,9 +17814,75 @@ 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 = null, host = null, } = 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
|
+
//@ts-ignore
|
|
17862
|
+
token = token !== null && token !== undefined ? token : __global_env__ === null || __global_env__ === undefined ? undefined : __global_env__.PROJECT_API_TOKEN;
|
|
17863
|
+
}
|
|
17864
|
+
if (token) {
|
|
17865
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
17866
|
+
}
|
|
17867
|
+
if (env) {
|
|
17868
|
+
headers['X-Project-Env'] = env;
|
|
17869
|
+
}
|
|
17870
|
+
const client = axios.create({
|
|
17871
|
+
baseURL: host !== null && host !== undefined ? host : "https://lemon.protokol.io",
|
|
17872
|
+
timeout: 15000,
|
|
17873
|
+
headers: {
|
|
17874
|
+
...headers,
|
|
17875
|
+
},
|
|
17876
|
+
withCredentials: true,
|
|
17877
|
+
});
|
|
17878
|
+
super(client);
|
|
17879
|
+
this.env = null;
|
|
17880
|
+
this.token = null;
|
|
17881
|
+
this.host = null;
|
|
17882
|
+
}
|
|
17883
|
+
}
|
|
17884
|
+
|
|
17885
|
+
class Functions extends PlatformBaseClient {
|
|
17820
17886
|
async list() {
|
|
17821
17887
|
return await this.client.get("/v1/system/function");
|
|
17822
17888
|
}
|
|
@@ -17849,12 +17915,7 @@ class Functions extends BaseClient {
|
|
|
17849
17915
|
}
|
|
17850
17916
|
}
|
|
17851
17917
|
|
|
17852
|
-
|
|
17853
|
-
__proto__: null,
|
|
17854
|
-
default: Functions
|
|
17855
|
-
});
|
|
17856
|
-
|
|
17857
|
-
class Roles extends BaseClient {
|
|
17918
|
+
class Roles extends PlatformBaseClient {
|
|
17858
17919
|
async create(role) {
|
|
17859
17920
|
const res = await this.client.post("/v1/user/role/create", role);
|
|
17860
17921
|
// writeFileSync(`.role.create.json`,JSON.stringify(res))
|
|
@@ -17878,16 +17939,15 @@ class Roles extends BaseClient {
|
|
|
17878
17939
|
}
|
|
17879
17940
|
}
|
|
17880
17941
|
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
default: Roles
|
|
17884
|
-
});
|
|
17885
|
-
|
|
17886
|
-
class APIUser extends BaseClient {
|
|
17887
|
-
async apiAuth(username, password) {
|
|
17942
|
+
class APIUser extends PlatformBaseClient {
|
|
17943
|
+
async auth(username, password, project) {
|
|
17888
17944
|
return this.client.post("/v1/user/api/auth", {
|
|
17889
17945
|
username,
|
|
17890
17946
|
password
|
|
17947
|
+
}, {
|
|
17948
|
+
headers: {
|
|
17949
|
+
"X-Project-Uuid": project
|
|
17950
|
+
}
|
|
17891
17951
|
});
|
|
17892
17952
|
}
|
|
17893
17953
|
async newSecret(uuid) {
|
|
@@ -17907,12 +17967,7 @@ class APIUser extends BaseClient {
|
|
|
17907
17967
|
}
|
|
17908
17968
|
}
|
|
17909
17969
|
|
|
17910
|
-
|
|
17911
|
-
__proto__: null,
|
|
17912
|
-
default: APIUser
|
|
17913
|
-
});
|
|
17914
|
-
|
|
17915
|
-
class Users extends BaseClient {
|
|
17970
|
+
class Users extends PlatformBaseClient {
|
|
17916
17971
|
async invite(email, roles) {
|
|
17917
17972
|
return await this.client.post("/v1/project/invite", {
|
|
17918
17973
|
email,
|
|
@@ -17924,14 +17979,9 @@ class Users extends BaseClient {
|
|
|
17924
17979
|
}
|
|
17925
17980
|
}
|
|
17926
17981
|
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
});
|
|
17931
|
-
|
|
17932
|
-
class Apps extends BaseClient {
|
|
17933
|
-
constructor(client, appType) {
|
|
17934
|
-
super(client);
|
|
17982
|
+
class Apps extends PlatformBaseClient {
|
|
17983
|
+
constructor(appType) {
|
|
17984
|
+
super();
|
|
17935
17985
|
this.appType = appType;
|
|
17936
17986
|
}
|
|
17937
17987
|
async updateSettings(updateValues, ref) {
|
|
@@ -17948,19 +17998,10 @@ class Apps extends BaseClient {
|
|
|
17948
17998
|
}
|
|
17949
17999
|
}
|
|
17950
18000
|
|
|
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) {
|
|
18001
|
+
class Component extends PlatformBaseClient {
|
|
18002
|
+
constructor(ref = null) {
|
|
18003
|
+
super();
|
|
17962
18004
|
this.ref = ref;
|
|
17963
|
-
return this;
|
|
17964
18005
|
}
|
|
17965
18006
|
/**
|
|
17966
18007
|
* Find method to search for models
|
|
@@ -18071,14 +18112,9 @@ class Component extends BaseClient {
|
|
|
18071
18112
|
* @param uuid string - The uuid of the model
|
|
18072
18113
|
* @returns (Promise<Model>)
|
|
18073
18114
|
*/
|
|
18074
|
-
get(uuid) {
|
|
18075
|
-
|
|
18076
|
-
|
|
18077
|
-
resolve(resp.data);
|
|
18078
|
-
}).catch((error) => {
|
|
18079
|
-
reject(error);
|
|
18080
|
-
});
|
|
18081
|
-
});
|
|
18115
|
+
async get(uuid) {
|
|
18116
|
+
const { data } = await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
|
|
18117
|
+
return data;
|
|
18082
18118
|
}
|
|
18083
18119
|
/**
|
|
18084
18120
|
* Update model by uuid
|
|
@@ -18087,73 +18123,62 @@ class Component extends BaseClient {
|
|
|
18087
18123
|
* @param data
|
|
18088
18124
|
* @returns
|
|
18089
18125
|
*/
|
|
18090
|
-
update(uuid, data) {
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
}).then((resp) => {
|
|
18095
|
-
resolve(resp.data);
|
|
18096
|
-
}).catch((error) => {
|
|
18097
|
-
reject(error);
|
|
18098
|
-
});
|
|
18126
|
+
async update(uuid, data, options) {
|
|
18127
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
|
|
18128
|
+
data,
|
|
18129
|
+
options,
|
|
18099
18130
|
});
|
|
18131
|
+
return responseData;
|
|
18100
18132
|
}
|
|
18101
|
-
|
|
18102
|
-
|
|
18103
|
-
|
|
18104
|
-
|
|
18105
|
-
|
|
18106
|
-
|
|
18107
|
-
|
|
18108
|
-
|
|
18109
|
-
|
|
18110
|
-
|
|
18133
|
+
/**
|
|
18134
|
+
* Update many models
|
|
18135
|
+
*
|
|
18136
|
+
* @param data
|
|
18137
|
+
* @param options
|
|
18138
|
+
* @returns
|
|
18139
|
+
*/
|
|
18140
|
+
async updateMany(data, options) {
|
|
18141
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
|
|
18142
|
+
data,
|
|
18143
|
+
options,
|
|
18111
18144
|
});
|
|
18145
|
+
return responseData;
|
|
18112
18146
|
}
|
|
18113
|
-
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18147
|
+
/**
|
|
18148
|
+
* Concurrent update model by uuid
|
|
18149
|
+
*
|
|
18150
|
+
* @param uuid string - The uuid of the model
|
|
18151
|
+
* @param version number - The version of the model
|
|
18152
|
+
* @param data
|
|
18153
|
+
* @returns
|
|
18154
|
+
*/
|
|
18155
|
+
async concurrentUpdate(uuid, version, data, options) {
|
|
18156
|
+
const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
|
|
18157
|
+
version: version,
|
|
18158
|
+
data,
|
|
18159
|
+
options,
|
|
18120
18160
|
});
|
|
18161
|
+
return responseData;
|
|
18121
18162
|
}
|
|
18122
|
-
|
|
18123
|
-
|
|
18124
|
-
|
|
18125
|
-
resolve(resp.data);
|
|
18126
|
-
}).catch((error) => {
|
|
18127
|
-
reject(error);
|
|
18128
|
-
});
|
|
18129
|
-
});
|
|
18163
|
+
async create(model) {
|
|
18164
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/model`, model);
|
|
18165
|
+
return data;
|
|
18130
18166
|
}
|
|
18131
|
-
|
|
18132
|
-
|
|
18133
|
-
|
|
18134
|
-
resolve(resp.data);
|
|
18135
|
-
}).catch((error) => {
|
|
18136
|
-
reject(error);
|
|
18137
|
-
});
|
|
18138
|
-
});
|
|
18167
|
+
async delete(uuid) {
|
|
18168
|
+
const { data } = await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
|
|
18169
|
+
return data;
|
|
18139
18170
|
}
|
|
18140
|
-
|
|
18141
|
-
|
|
18142
|
-
|
|
18143
|
-
resolve(resp.data);
|
|
18144
|
-
}).catch(err => {
|
|
18145
|
-
reject(err);
|
|
18146
|
-
});
|
|
18147
|
-
});
|
|
18171
|
+
async aggregate(pipeline) {
|
|
18172
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
|
|
18173
|
+
return data;
|
|
18148
18174
|
}
|
|
18149
|
-
|
|
18150
|
-
|
|
18151
|
-
|
|
18152
|
-
|
|
18153
|
-
|
|
18154
|
-
|
|
18155
|
-
|
|
18156
|
-
});
|
|
18175
|
+
async settings() {
|
|
18176
|
+
const { data } = await this.client.get(`/v3/system/component/settings/${this.ref}`);
|
|
18177
|
+
return data;
|
|
18178
|
+
}
|
|
18179
|
+
async saveSettings(settings, version) {
|
|
18180
|
+
const { data } = await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
|
|
18181
|
+
return data;
|
|
18157
18182
|
}
|
|
18158
18183
|
async saveTemplatesDist(version, sdkVersion, engine, dist) {
|
|
18159
18184
|
const { data } = await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
|
|
@@ -18166,29 +18191,136 @@ class Component extends BaseClient {
|
|
|
18166
18191
|
return data;
|
|
18167
18192
|
}
|
|
18168
18193
|
async workflow(event, input) {
|
|
18169
|
-
|
|
18194
|
+
const { data } = await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
|
|
18170
18195
|
event,
|
|
18171
18196
|
input
|
|
18172
18197
|
});
|
|
18198
|
+
return data;
|
|
18173
18199
|
}
|
|
18174
18200
|
async function(name, input) {
|
|
18175
|
-
|
|
18201
|
+
const { data } = await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
|
|
18202
|
+
return data;
|
|
18176
18203
|
}
|
|
18177
|
-
|
|
18204
|
+
}
|
|
18205
|
+
|
|
18206
|
+
class ComponentUtils extends PlatformBaseClient {
|
|
18207
|
+
async list() {
|
|
18178
18208
|
const { data } = await this.client.get("/v1/system/components");
|
|
18179
18209
|
return data;
|
|
18180
18210
|
}
|
|
18181
|
-
async
|
|
18182
|
-
|
|
18211
|
+
async create(data) {
|
|
18212
|
+
const { data: responseData } = await this.client.post("/v3/system/component/create", data);
|
|
18213
|
+
return responseData;
|
|
18183
18214
|
}
|
|
18184
18215
|
}
|
|
18185
18216
|
|
|
18186
|
-
|
|
18187
|
-
|
|
18188
|
-
|
|
18189
|
-
|
|
18217
|
+
class Ratchet extends PlatformBaseClient {
|
|
18218
|
+
async query(name, params) {
|
|
18219
|
+
let res = await this.client.post('/v1/ratchet/query', {
|
|
18220
|
+
name: name,
|
|
18221
|
+
params: params
|
|
18222
|
+
});
|
|
18223
|
+
return res.data;
|
|
18224
|
+
}
|
|
18225
|
+
}
|
|
18190
18226
|
|
|
18191
|
-
class
|
|
18227
|
+
class Sandbox extends PlatformBaseClient {
|
|
18228
|
+
/**
|
|
18229
|
+
* Call the sandbox service to execute a serverless function
|
|
18230
|
+
*
|
|
18231
|
+
* @param name
|
|
18232
|
+
* @param data
|
|
18233
|
+
* @returns
|
|
18234
|
+
*
|
|
18235
|
+
* @example
|
|
18236
|
+
* const result = await platform.sandbox().spark("myFunction", { foo: "bar" })
|
|
18237
|
+
*/
|
|
18238
|
+
async spark(name, data) {
|
|
18239
|
+
return await this.client.post(`/v1/project/sandbox/spark/exec/${name}`, data);
|
|
18240
|
+
}
|
|
18241
|
+
}
|
|
18242
|
+
|
|
18243
|
+
class System extends PlatformBaseClient {
|
|
18244
|
+
async resourceResolver(ref, resourceName, format) {
|
|
18245
|
+
const { data } = await this.client.post("/v3/system/resource-resolver", {
|
|
18246
|
+
type: resourceName,
|
|
18247
|
+
format,
|
|
18248
|
+
});
|
|
18249
|
+
if (format) {
|
|
18250
|
+
return data.format;
|
|
18251
|
+
}
|
|
18252
|
+
return data;
|
|
18253
|
+
}
|
|
18254
|
+
}
|
|
18255
|
+
|
|
18256
|
+
class Workflow extends PlatformBaseClient {
|
|
18257
|
+
async trigger(id, event, data) {
|
|
18258
|
+
return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
|
|
18259
|
+
}
|
|
18260
|
+
}
|
|
18261
|
+
|
|
18262
|
+
class Forge extends PlatformBaseClient {
|
|
18263
|
+
async bundleUpload(buffer) {
|
|
18264
|
+
return await this.client.post(`/v3/system/gateway/app-service/forge/upload`, buffer, {
|
|
18265
|
+
headers: {
|
|
18266
|
+
'Content-Type': 'application/octet-stream',
|
|
18267
|
+
'Content-Length': buffer.length
|
|
18268
|
+
}
|
|
18269
|
+
});
|
|
18270
|
+
}
|
|
18271
|
+
async getWorkspaceApps() {
|
|
18272
|
+
return await this.client.get(`/v3/system/gateway/app-service/forge/workspace`);
|
|
18273
|
+
}
|
|
18274
|
+
}
|
|
18275
|
+
|
|
18276
|
+
// apis
|
|
18277
|
+
class Platform extends PlatformBaseClient {
|
|
18278
|
+
getPlatformClient() {
|
|
18279
|
+
return this.client;
|
|
18280
|
+
}
|
|
18281
|
+
getPlatformBaseURL() {
|
|
18282
|
+
var _a;
|
|
18283
|
+
return (_a = this.client.defaults.baseURL) !== null && _a !== undefined ? _a : "";
|
|
18284
|
+
}
|
|
18285
|
+
apiUser() {
|
|
18286
|
+
return (new APIUser()).setClient(this.client);
|
|
18287
|
+
}
|
|
18288
|
+
function() {
|
|
18289
|
+
return (new Functions()).setClient(this.client);
|
|
18290
|
+
}
|
|
18291
|
+
role() {
|
|
18292
|
+
return (new Roles()).setClient(this.client);
|
|
18293
|
+
}
|
|
18294
|
+
user() {
|
|
18295
|
+
return (new Users()).setClient(this.client);
|
|
18296
|
+
}
|
|
18297
|
+
app(appType) {
|
|
18298
|
+
return (new Apps(appType)).setClient(this.client);
|
|
18299
|
+
}
|
|
18300
|
+
forge() {
|
|
18301
|
+
return (new Forge()).setClient(this.client);
|
|
18302
|
+
}
|
|
18303
|
+
component(ref) {
|
|
18304
|
+
return (new Component(ref)).setClient(this.client);
|
|
18305
|
+
}
|
|
18306
|
+
componentUtils() {
|
|
18307
|
+
return (new ComponentUtils()).setClient(this.client);
|
|
18308
|
+
}
|
|
18309
|
+
ratchet() {
|
|
18310
|
+
return (new Ratchet()).setClient(this.client);
|
|
18311
|
+
}
|
|
18312
|
+
sandbox() {
|
|
18313
|
+
return (new Sandbox()).setClient(this.client);
|
|
18314
|
+
}
|
|
18315
|
+
system() {
|
|
18316
|
+
return (new System()).setClient(this.client);
|
|
18317
|
+
}
|
|
18318
|
+
workflow() {
|
|
18319
|
+
return (new Workflow()).setClient(this.client);
|
|
18320
|
+
}
|
|
18321
|
+
}
|
|
18322
|
+
|
|
18323
|
+
class Invoicing extends PlatformBaseClient {
|
|
18192
18324
|
async getSalesInvoices(provider, page) {
|
|
18193
18325
|
return await this.request("GET", `/invoices/${provider}/sales`, {
|
|
18194
18326
|
params: {
|
|
@@ -18207,13 +18339,48 @@ class Invoicing extends BaseClient {
|
|
|
18207
18339
|
async request(method, endpoint, params) {
|
|
18208
18340
|
return await this.client.request({
|
|
18209
18341
|
method: method,
|
|
18210
|
-
url: `/v1/karadjordje/${endpoint}`,
|
|
18342
|
+
url: `/v1/integrations/karadjordje/${endpoint}`,
|
|
18211
18343
|
...params
|
|
18212
18344
|
});
|
|
18213
18345
|
}
|
|
18214
18346
|
}
|
|
18215
18347
|
|
|
18216
|
-
class
|
|
18348
|
+
class IntegrationsBaseClient extends BaseClient {
|
|
18349
|
+
constructor(options) {
|
|
18350
|
+
var _a, _b;
|
|
18351
|
+
let { env = null, token, host, } = options !== null && options !== undefined ? options : {};
|
|
18352
|
+
let headers = {};
|
|
18353
|
+
if (isBrowser) {
|
|
18354
|
+
if (localStorage.getItem('protokol_context') == "forge") {
|
|
18355
|
+
headers['X-Project-Env'] = (_a = localStorage.getItem('forge_app_env')) !== null && _a !== undefined ? _a : "dev";
|
|
18356
|
+
}
|
|
18357
|
+
else {
|
|
18358
|
+
// this potentially means that it is running as dev server in local
|
|
18359
|
+
headers['X-Project-Env'] = "dev";
|
|
18360
|
+
}
|
|
18361
|
+
// @ts-ignore
|
|
18362
|
+
const __global_env__ = window === null || window === undefined ? undefined : window.__ENV_VARIABLES__;
|
|
18363
|
+
host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== undefined ? _b : host;
|
|
18364
|
+
}
|
|
18365
|
+
if (token) {
|
|
18366
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
18367
|
+
}
|
|
18368
|
+
if (env) {
|
|
18369
|
+
headers['X-Project-Env'] = env;
|
|
18370
|
+
}
|
|
18371
|
+
const client = axios.create({
|
|
18372
|
+
baseURL: host !== null && host !== undefined ? host : "https://orange.protokol.io",
|
|
18373
|
+
timeout: 15000,
|
|
18374
|
+
headers: {
|
|
18375
|
+
...headers,
|
|
18376
|
+
},
|
|
18377
|
+
withCredentials: true,
|
|
18378
|
+
});
|
|
18379
|
+
super(client);
|
|
18380
|
+
}
|
|
18381
|
+
}
|
|
18382
|
+
|
|
18383
|
+
class Media extends IntegrationsBaseClient {
|
|
18217
18384
|
async list(data) {
|
|
18218
18385
|
return this.request('POST', 'list', { data });
|
|
18219
18386
|
}
|
|
@@ -18323,7 +18490,7 @@ class Media extends BaseClient {
|
|
|
18323
18490
|
}
|
|
18324
18491
|
}
|
|
18325
18492
|
|
|
18326
|
-
class SerbiaUtil extends
|
|
18493
|
+
class SerbiaUtil extends IntegrationsBaseClient {
|
|
18327
18494
|
async nsbSearch(params) {
|
|
18328
18495
|
return await this.services("GET", "nbs/search", { params });
|
|
18329
18496
|
}
|
|
@@ -18350,7 +18517,7 @@ class SerbiaUtil extends BaseClient {
|
|
|
18350
18517
|
}
|
|
18351
18518
|
}
|
|
18352
18519
|
|
|
18353
|
-
class VPFR extends
|
|
18520
|
+
class VPFR extends IntegrationsBaseClient {
|
|
18354
18521
|
async request(method, endpoint, params) {
|
|
18355
18522
|
return await this.client.request({
|
|
18356
18523
|
method: method,
|
|
@@ -18360,14 +18527,15 @@ class VPFR extends BaseClient {
|
|
|
18360
18527
|
}
|
|
18361
18528
|
}
|
|
18362
18529
|
|
|
18363
|
-
|
|
18364
|
-
|
|
18365
|
-
|
|
18530
|
+
// import integrations
|
|
18531
|
+
class Integrations extends IntegrationsBaseClient {
|
|
18532
|
+
constructor(options) {
|
|
18533
|
+
super(options);
|
|
18366
18534
|
this.integrations = {
|
|
18367
|
-
'protokol-invoicing': new Invoicing(
|
|
18368
|
-
'protokol-vpfr': new VPFR(
|
|
18369
|
-
'protokol-media': new Media(
|
|
18370
|
-
'serbia-utilities': new SerbiaUtil(
|
|
18535
|
+
'protokol-invoicing': new Invoicing().setClient(this.client),
|
|
18536
|
+
'protokol-vpfr': new VPFR().setClient(this.client),
|
|
18537
|
+
'protokol-media': new Media().setClient(this.client),
|
|
18538
|
+
'serbia-utilities': new SerbiaUtil().setClient(this.client),
|
|
18371
18539
|
};
|
|
18372
18540
|
}
|
|
18373
18541
|
getSerbiaUtilities() {
|
|
@@ -18396,192 +18564,16 @@ class Integrations extends BaseClient {
|
|
|
18396
18564
|
}
|
|
18397
18565
|
}
|
|
18398
18566
|
|
|
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;
|
|
18567
|
+
exports.APIUser = APIUser;
|
|
18568
|
+
exports.Apps = Apps;
|
|
18569
|
+
exports.Component = Component;
|
|
18570
|
+
exports.ComponentUtils = ComponentUtils;
|
|
18571
|
+
exports.Functions = Functions;
|
|
18572
|
+
exports.Integration = Integrations;
|
|
18573
|
+
exports.Ratchet = Ratchet;
|
|
18574
|
+
exports.Roles = Roles;
|
|
18575
|
+
exports.Sandbox = Sandbox;
|
|
18576
|
+
exports.System = System;
|
|
18577
|
+
exports.Users = Users;
|
|
18578
|
+
exports.Workflow = Workflow;
|
|
18587
18579
|
exports.default = Platform;
|