@ptkl/sdk 0.10.2 → 1.0.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.iife.js → index.0.10.js} +393 -230
- package/dist/index.0.9.js +2849 -0
- package/dist/package.json +12 -7
- package/dist/v0.10/api/component.d.ts +128 -0
- package/dist/v0.10/api/index.d.ts +22 -0
- package/dist/{types → v0.10}/api/integrationsBaseClient.d.ts +3 -0
- package/dist/{types → v0.10}/api/platform.d.ts +2 -2
- package/dist/v0.10/apiUser.d.ts +9 -0
- package/dist/v0.10/apps.d.ts +8 -0
- package/dist/v0.10/baseClient.d.ts +6 -0
- package/dist/{types/api → v0.10}/component.d.ts +39 -4
- package/dist/v0.10/componentUtils.d.ts +7 -0
- package/dist/v0.10/config.d.ts +14 -0
- package/dist/v0.10/forge.d.ts +7 -0
- package/dist/v0.10/functions.d.ts +23 -0
- package/dist/{index.cjs.js → v0.10/index.cjs.js} +393 -230
- package/dist/v0.10/index.d.ts +21 -0
- package/dist/{index.esm.js → v0.10/index.esm.js} +392 -227
- package/dist/v0.10/integrations/dms.d.ts +469 -0
- package/dist/v0.10/integrations/invoicing.d.ts +6 -0
- package/dist/v0.10/integrations/minimax.d.ts +289 -0
- package/dist/v0.10/integrations/payments.d.ts +40 -0
- package/dist/v0.10/integrations/serbiaUtil.d.ts +10 -0
- package/dist/v0.10/integrations/vpfr.d.ts +4 -0
- package/dist/v0.10/integrations.d.ts +22 -0
- package/dist/v0.10/integrationsBaseClient.d.ts +11 -0
- package/dist/v0.10/platform.d.ts +34 -0
- package/dist/v0.10/platformBaseClient.d.ts +27 -0
- package/dist/v0.10/project.d.ts +146 -0
- package/dist/v0.10/ratchet.d.ts +196 -0
- package/dist/v0.10/sandbox.d.ts +14 -0
- package/dist/v0.10/system.d.ts +4 -0
- package/dist/v0.10/thunder.d.ts +13 -0
- package/dist/{types → v0.10}/types/component.d.ts +27 -1
- package/dist/v0.10/users.d.ts +69 -0
- package/dist/v0.10/workflow.d.ts +5 -0
- package/dist/v0.9/api/apiUser.d.ts +9 -0
- package/dist/v0.9/api/apps.d.ts +8 -0
- package/dist/v0.9/api/baseClient.d.ts +6 -0
- package/dist/v0.9/api/component.d.ts +136 -0
- package/dist/v0.9/api/componentUtils.d.ts +7 -0
- package/dist/v0.9/api/config.d.ts +14 -0
- package/dist/v0.9/api/forge.d.ts +7 -0
- package/dist/v0.9/api/functions.d.ts +23 -0
- package/dist/v0.9/api/index.d.ts +24 -0
- package/dist/v0.9/api/integrations/dms.d.ts +419 -0
- package/dist/v0.9/api/integrations/invoicing.d.ts +6 -0
- package/dist/v0.9/api/integrations/minimax.d.ts +289 -0
- package/dist/v0.9/api/integrations/payments.d.ts +40 -0
- package/dist/v0.9/api/integrations/serbiaUtil.d.ts +10 -0
- package/dist/v0.9/api/integrations/vpfr.d.ts +4 -0
- package/dist/v0.9/api/integrations.d.ts +22 -0
- package/dist/v0.9/api/integrationsBaseClient.d.ts +11 -0
- package/dist/v0.9/api/platform.d.ts +34 -0
- package/dist/v0.9/api/platformBaseClient.d.ts +27 -0
- package/dist/v0.9/api/project.d.ts +146 -0
- package/dist/v0.9/api/ratchet.d.ts +196 -0
- package/dist/v0.9/api/sandbox.d.ts +14 -0
- package/dist/v0.9/api/system.d.ts +4 -0
- package/dist/v0.9/api/thunder.d.ts +13 -0
- package/dist/v0.9/api/users.d.ts +69 -0
- package/dist/v0.9/api/workflow.d.ts +5 -0
- package/dist/v0.9/apiUser.d.ts +9 -0
- package/dist/v0.9/apps.d.ts +8 -0
- package/dist/v0.9/baseClient.d.ts +6 -0
- package/dist/v0.9/component.d.ts +128 -0
- package/dist/v0.9/componentUtils.d.ts +7 -0
- package/dist/v0.9/config.d.ts +14 -0
- package/dist/v0.9/forge.d.ts +7 -0
- package/dist/v0.9/functions.d.ts +23 -0
- package/dist/v0.9/index.cjs.js +21811 -0
- package/dist/v0.9/index.d.ts +21 -0
- package/dist/v0.9/index.esm.js +2820 -0
- package/dist/v0.9/integrations/dms.d.ts +469 -0
- package/dist/v0.9/integrations/invoicing.d.ts +6 -0
- package/dist/v0.9/integrations/minimax.d.ts +289 -0
- package/dist/v0.9/integrations/payments.d.ts +40 -0
- package/dist/v0.9/integrations/serbiaUtil.d.ts +10 -0
- package/dist/v0.9/integrations/vpfr.d.ts +4 -0
- package/dist/v0.9/integrations.d.ts +22 -0
- package/dist/v0.9/integrationsBaseClient.d.ts +11 -0
- package/dist/v0.9/platform.d.ts +34 -0
- package/dist/v0.9/platformBaseClient.d.ts +27 -0
- package/dist/v0.9/project.d.ts +146 -0
- package/dist/v0.9/ratchet.d.ts +196 -0
- package/dist/v0.9/sandbox.d.ts +14 -0
- package/dist/v0.9/system.d.ts +4 -0
- package/dist/v0.9/thunder.d.ts +13 -0
- package/dist/v0.9/types/component.d.ts +116 -0
- package/dist/v0.9/types/config.d.ts +11 -0
- package/dist/v0.9/types/integrations.d.ts +321 -0
- package/dist/v0.9/types/project.d.ts +64 -0
- package/dist/v0.9/types/ratchet.d.ts +38 -0
- package/dist/v0.9/types/users.d.ts +66 -0
- package/dist/v0.9/users.d.ts +69 -0
- package/dist/v0.9/util/detectEnv.d.ts +4 -0
- package/dist/v0.9/workflow.d.ts +5 -0
- package/package.json +12 -7
- package/dist/monaco.d.ts +0 -887
- package/dist/types/api/index.d.ts +0 -13
- package/dist/types/api/integrations/media.d.ts +0 -17
- package/dist/types/api/roles.d.ts +0 -9
- package/dist/types/index.d.ts +0 -29
- package/dist/types/types/media.d.ts +0 -103
- /package/dist/{types → v0.10}/api/apiUser.d.ts +0 -0
- /package/dist/{types → v0.10}/api/apps.d.ts +0 -0
- /package/dist/{types → v0.10}/api/baseClient.d.ts +0 -0
- /package/dist/{types → v0.10}/api/componentUtils.d.ts +0 -0
- /package/dist/{types → v0.10}/api/config.d.ts +0 -0
- /package/dist/{types → v0.10}/api/forge.d.ts +0 -0
- /package/dist/{types → v0.10}/api/functions.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/dms.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/invoicing.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/minimax.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/payments.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/serbiaUtil.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/vpfr.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations.d.ts +0 -0
- /package/dist/{types → v0.10}/api/platformBaseClient.d.ts +0 -0
- /package/dist/{types → v0.10}/api/project.d.ts +0 -0
- /package/dist/{types → v0.10}/api/ratchet.d.ts +0 -0
- /package/dist/{types → v0.10}/api/sandbox.d.ts +0 -0
- /package/dist/{types → v0.10}/api/system.d.ts +0 -0
- /package/dist/{types → v0.10}/api/thunder.d.ts +0 -0
- /package/dist/{types → v0.10}/api/users.d.ts +0 -0
- /package/dist/{types → v0.10}/api/workflow.d.ts +0 -0
- /package/dist/{types → v0.10}/types/config.d.ts +0 -0
- /package/dist/{types → v0.10}/types/integrations.d.ts +0 -0
- /package/dist/{types → v0.10}/types/project.d.ts +0 -0
- /package/dist/{types → v0.10}/types/ratchet.d.ts +0 -0
- /package/dist/{types → v0.10}/types/users.d.ts +0 -0
- /package/dist/{types → v0.10}/util/detectEnv.d.ts +0 -0
|
@@ -35,27 +35,32 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
35
35
|
*/
|
|
36
36
|
class PlatformBaseClient extends BaseClient {
|
|
37
37
|
constructor(options) {
|
|
38
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
39
39
|
let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
|
|
40
40
|
let headers = {};
|
|
41
41
|
var project_uuid = null;
|
|
42
42
|
if (isBrowser) {
|
|
43
|
-
console.log("PlatformBaseClient: running in browser context");
|
|
44
43
|
if (sessionStorage.getItem('protokol_context') == "forge") {
|
|
45
44
|
headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
|
|
46
45
|
}
|
|
47
46
|
else {
|
|
48
47
|
headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
|
|
49
48
|
}
|
|
49
|
+
if (typeof window !== "undefined") {
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
|
|
52
|
+
host = (_c = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _c !== void 0 ? _c : host;
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
55
|
+
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
56
|
+
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
57
|
-
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
58
|
-
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
59
|
+
else if (process && process.env) {
|
|
60
|
+
host = (_d = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _d !== void 0 ? _d : null;
|
|
61
|
+
env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
|
|
62
|
+
token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
|
|
63
|
+
project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
|
|
59
64
|
}
|
|
60
65
|
if (token) {
|
|
61
66
|
headers['Authorization'] = `Bearer ${token}`;
|
|
@@ -82,198 +87,22 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
class Functions extends PlatformBaseClient {
|
|
86
|
-
async list() {
|
|
87
|
-
return await this.client.get("/v1/system/function");
|
|
88
|
-
}
|
|
89
|
-
async get(ref) {
|
|
90
|
-
return await this.client.get(`/v1/system/function/${ref}`);
|
|
91
|
-
}
|
|
92
|
-
async update(uuid, update) {
|
|
93
|
-
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Run platform function
|
|
97
|
-
*
|
|
98
|
-
* @param id - Function ID
|
|
99
|
-
* @param input - Input data
|
|
100
|
-
* @param query - Query parameters
|
|
101
|
-
* @returns - Function result
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
105
|
-
*/
|
|
106
|
-
async run(id, d) {
|
|
107
|
-
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
108
|
-
params: d.query,
|
|
109
|
-
headers: d.headers
|
|
110
|
-
});
|
|
111
|
-
return data;
|
|
112
|
-
}
|
|
113
|
-
async generateSignature(ref, env) {
|
|
114
|
-
return await this.client.get(`/v1/system/function/signature/${env}/${ref}`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
class APIUser extends PlatformBaseClient {
|
|
119
|
-
async auth(username, password, project) {
|
|
120
|
-
return this.client.post("/v1/user/api/auth", {
|
|
121
|
-
username,
|
|
122
|
-
password
|
|
123
|
-
}, {
|
|
124
|
-
headers: {
|
|
125
|
-
"X-Project-Uuid": project
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
async newSecret(uuid) {
|
|
130
|
-
return await this.client.post(`/v1/user/api-user/secret/${uuid}`, {});
|
|
131
|
-
}
|
|
132
|
-
async revokeSecret(uuid) {
|
|
133
|
-
return await this.client.delete(`/v1/user/api-user/secret/${uuid}`);
|
|
134
|
-
}
|
|
135
|
-
async edit(uuid, roles) {
|
|
136
|
-
return await this.client.patch(`/v1/user/api-user/${uuid}`, { roles });
|
|
137
|
-
}
|
|
138
|
-
async list() {
|
|
139
|
-
return await this.client.get(`/v1/user/api-user`);
|
|
140
|
-
}
|
|
141
|
-
async get(uuid) {
|
|
142
|
-
return await this.client.get(`/v1/user/api-user/${uuid}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
class Users extends PlatformBaseClient {
|
|
147
|
-
async auth(username, password, project) {
|
|
148
|
-
return await this.client.post("/v1/user/login", {
|
|
149
|
-
username,
|
|
150
|
-
password,
|
|
151
|
-
response_type: 'token',
|
|
152
|
-
}, {
|
|
153
|
-
headers: {
|
|
154
|
-
'X-Project-Uuid': project
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Resend confirmation email
|
|
160
|
-
* @param email User email
|
|
161
|
-
*/
|
|
162
|
-
async resendConfirmationEmail(email) {
|
|
163
|
-
return await this.client.post("/v1/user/send/confirmation/email", {
|
|
164
|
-
email,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
// Password Reset (Request Only)
|
|
168
|
-
// Note: Only the REQUEST is exposed, not the password reset completion
|
|
169
|
-
// The actual password reset should be done through the official web interface
|
|
170
|
-
/**
|
|
171
|
-
* Request password reset email
|
|
172
|
-
* This only sends an email with a reset link, does not expose or change passwords
|
|
173
|
-
* @param email User email
|
|
174
|
-
*/
|
|
175
|
-
async requestPasswordReset(email) {
|
|
176
|
-
return await this.client.post("/v1/user/resetpassword", { email });
|
|
177
|
-
}
|
|
178
|
-
// User Profile & Management
|
|
179
|
-
/**
|
|
180
|
-
* Get current user's model
|
|
181
|
-
*/
|
|
182
|
-
async getUser() {
|
|
183
|
-
return await this.client.get("/v1/user/model");
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Get current user's claims
|
|
187
|
-
*/
|
|
188
|
-
async getClaims() {
|
|
189
|
-
return await this.client.get("/v1/user/claims");
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Edit user profile
|
|
193
|
-
* @param data Profile update data
|
|
194
|
-
*/
|
|
195
|
-
async editProfile(data) {
|
|
196
|
-
return await this.client.post("/v1/user/profile/edit", data);
|
|
197
|
-
}
|
|
198
|
-
// Permissions & Roles
|
|
199
|
-
/**
|
|
200
|
-
* Get user permissions
|
|
201
|
-
*/
|
|
202
|
-
async getPermissions() {
|
|
203
|
-
return await this.client.get("/v1/user/role/permissions");
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Get list of available permissions
|
|
207
|
-
*/
|
|
208
|
-
async listPermissions() {
|
|
209
|
-
return await this.client.get("/v1/user/permissions/list");
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Create a new role
|
|
213
|
-
* @param role Role data including name, permissions, workspaces, and level
|
|
214
|
-
*/
|
|
215
|
-
async createRole(role) {
|
|
216
|
-
return await this.client.post("/v1/user/role/create", role);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Delete a role
|
|
220
|
-
* @param uuid Role UUID
|
|
221
|
-
*/
|
|
222
|
-
async deleteRole(uuid) {
|
|
223
|
-
return await this.client.delete(`/v1/user/role/delete/${uuid}`);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* List all roles
|
|
227
|
-
*/
|
|
228
|
-
async listRoles() {
|
|
229
|
-
return await this.client.get(`/v1/user/role/list`);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Get role details by UUID
|
|
233
|
-
* @param uuid Role UUID
|
|
234
|
-
*/
|
|
235
|
-
async getRoleModel(uuid) {
|
|
236
|
-
return await this.client.get(`/v1/user/role/edit/${uuid}`);
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Edit a role
|
|
240
|
-
* @param uuid Role UUID
|
|
241
|
-
* @param data Role update data including permissions, workspaces, and level
|
|
242
|
-
*/
|
|
243
|
-
async editRole(uuid, data) {
|
|
244
|
-
return await this.client.post(`/v1/user/role/edit/${uuid}`, data);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* @deprecated Use getPermissions() instead
|
|
248
|
-
*/
|
|
249
|
-
async permissions() {
|
|
250
|
-
return await this.client.get(`/v1/user/role/permissions`);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
class Apps extends PlatformBaseClient {
|
|
255
|
-
constructor(appType) {
|
|
256
|
-
super();
|
|
257
|
-
this.appType = appType;
|
|
258
|
-
}
|
|
259
|
-
async updateSettings(updateValues, ref) {
|
|
260
|
-
const payload = { ...updateValues };
|
|
261
|
-
return await this.client.put(`/v3/system/gateway/app-service/${this.appType}/${ref}/settings`, payload);
|
|
262
|
-
}
|
|
263
|
-
async download(ref, version) {
|
|
264
|
-
return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/download`, { version, uuid: ref }, { responseType: "arraybuffer" });
|
|
265
|
-
}
|
|
266
|
-
async upload(formData) {
|
|
267
|
-
return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
|
|
268
|
-
timeout: 60000
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
90
|
class Component extends PlatformBaseClient {
|
|
274
|
-
constructor(ref = null) {
|
|
91
|
+
constructor(ref = null, options) {
|
|
92
|
+
var _a;
|
|
275
93
|
super();
|
|
276
94
|
this.ref = ref;
|
|
95
|
+
this.version = (_a = options === null || options === void 0 ? void 0 : options.version) !== null && _a !== void 0 ? _a : null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the base path for component API calls
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
getComponentPath() {
|
|
102
|
+
if (this.version) {
|
|
103
|
+
return `/v3/system/component/${this.ref}/v/${this.version}`;
|
|
104
|
+
}
|
|
105
|
+
return `/v3/system/component/${this.ref}`;
|
|
277
106
|
}
|
|
278
107
|
/**
|
|
279
108
|
* Find method to search for models
|
|
@@ -343,7 +172,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
343
172
|
params[`_opt_${k}`] = opts ? opts[k] : null;
|
|
344
173
|
});
|
|
345
174
|
}
|
|
346
|
-
return await this.client.get(
|
|
175
|
+
return await this.client.get(`${this.getComponentPath()}/models`, {
|
|
347
176
|
params: params,
|
|
348
177
|
headers: {
|
|
349
178
|
'X-Cache': cache,
|
|
@@ -382,7 +211,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
382
211
|
* @returns (Promise<Model>)
|
|
383
212
|
*/
|
|
384
213
|
async get(uuid) {
|
|
385
|
-
return await this.client.get(
|
|
214
|
+
return await this.client.get(`${this.getComponentPath()}/model/${uuid}`);
|
|
386
215
|
}
|
|
387
216
|
/**
|
|
388
217
|
* Update model by uuid
|
|
@@ -392,7 +221,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
392
221
|
* @returns
|
|
393
222
|
*/
|
|
394
223
|
async update(uuid, data, options) {
|
|
395
|
-
return await this.client.post(
|
|
224
|
+
return await this.client.post(`${this.getComponentPath()}/model/${uuid}`, {
|
|
396
225
|
data,
|
|
397
226
|
options,
|
|
398
227
|
});
|
|
@@ -405,9 +234,9 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
405
234
|
* @returns
|
|
406
235
|
*/
|
|
407
236
|
async updateMany(data, options) {
|
|
408
|
-
return await this.client.
|
|
237
|
+
return await this.client.patch(`${this.getComponentPath()}/models/bulk`, {
|
|
409
238
|
data,
|
|
410
|
-
options
|
|
239
|
+
options
|
|
411
240
|
});
|
|
412
241
|
}
|
|
413
242
|
/**
|
|
@@ -418,7 +247,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
418
247
|
* @returns
|
|
419
248
|
*/
|
|
420
249
|
async modify(filters, data, options) {
|
|
421
|
-
return await this.client.patch(
|
|
250
|
+
return await this.client.patch(`${this.getComponentPath()}/modify/model`, {
|
|
422
251
|
filters,
|
|
423
252
|
data,
|
|
424
253
|
options,
|
|
@@ -433,20 +262,84 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
433
262
|
* @returns
|
|
434
263
|
*/
|
|
435
264
|
async concurrentUpdate(uuid, version, data, options) {
|
|
436
|
-
return await this.client.post(
|
|
265
|
+
return await this.client.post(`${this.getComponentPath()}/model/${uuid}`, {
|
|
437
266
|
version: version,
|
|
438
267
|
data,
|
|
439
268
|
options,
|
|
440
269
|
});
|
|
441
270
|
}
|
|
442
271
|
async create(model) {
|
|
443
|
-
return await this.client.post(
|
|
272
|
+
return await this.client.post(`${this.getComponentPath()}/model`, model);
|
|
444
273
|
}
|
|
445
274
|
async delete(uuid) {
|
|
446
|
-
return await this.client.delete(
|
|
275
|
+
return await this.client.delete(`${this.getComponentPath()}/model/${uuid}`);
|
|
447
276
|
}
|
|
448
|
-
|
|
449
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Execute aggregate pipeline with optional streaming support
|
|
279
|
+
*
|
|
280
|
+
* Returns a chainable object that allows both buffered and streaming modes.
|
|
281
|
+
* Call .onData() to enable streaming mode, or await directly for buffered mode.
|
|
282
|
+
*
|
|
283
|
+
* @param {FindAggregateParams} pipeline - MongoDB aggregation pipeline
|
|
284
|
+
*
|
|
285
|
+
* @returns {AggregateChainable} Chainable object with streaming methods and Promise interface
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* // Buffered response (default, up to 5K documents)
|
|
290
|
+
* const result = await component.aggregate([{ $match: { status: 'active' } }]);
|
|
291
|
+
* console.log(result.data); // All results at once
|
|
292
|
+
*
|
|
293
|
+
* // Streaming response (up to 25K documents)
|
|
294
|
+
* await component.aggregate([{ $match: { status: 'active' } }])
|
|
295
|
+
* .onData((doc) => console.log('Received:', doc))
|
|
296
|
+
* .onError((err) => console.error('Error:', err))
|
|
297
|
+
* .onEnd(() => console.log('Stream complete'));
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
aggregate(pipeline) {
|
|
301
|
+
let onDataCallback = () => { };
|
|
302
|
+
let onErrorCallback;
|
|
303
|
+
let onEndCallback;
|
|
304
|
+
let isStreaming = false;
|
|
305
|
+
let streamPromise = null;
|
|
306
|
+
const chainable = {
|
|
307
|
+
onData: (callback) => {
|
|
308
|
+
onDataCallback = callback;
|
|
309
|
+
isStreaming = true;
|
|
310
|
+
return chainable;
|
|
311
|
+
},
|
|
312
|
+
onError: (callback) => {
|
|
313
|
+
onErrorCallback = callback;
|
|
314
|
+
return chainable;
|
|
315
|
+
},
|
|
316
|
+
onEnd: (callback) => {
|
|
317
|
+
onEndCallback = callback;
|
|
318
|
+
return chainable;
|
|
319
|
+
},
|
|
320
|
+
then: (resolve, reject) => {
|
|
321
|
+
if (isStreaming) {
|
|
322
|
+
if (!streamPromise) {
|
|
323
|
+
const handler = {
|
|
324
|
+
onData: onDataCallback,
|
|
325
|
+
onError: onErrorCallback,
|
|
326
|
+
onEnd: onEndCallback
|
|
327
|
+
};
|
|
328
|
+
streamPromise = this._streamNDJSON(`${this.getComponentPath()}/aggregate`, {
|
|
329
|
+
'Accept': 'application/x-ndjson',
|
|
330
|
+
'Content-Type': 'application/json'
|
|
331
|
+
}, handler, pipeline);
|
|
332
|
+
}
|
|
333
|
+
return streamPromise.then(resolve, reject);
|
|
334
|
+
}
|
|
335
|
+
return this.client.post(`${this.getComponentPath()}/aggregate`, pipeline)
|
|
336
|
+
.then(resolve, reject);
|
|
337
|
+
},
|
|
338
|
+
catch: (reject) => {
|
|
339
|
+
return chainable.then(undefined, reject);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
return chainable;
|
|
450
343
|
}
|
|
451
344
|
async settings() {
|
|
452
345
|
return await this.client.get(`/v3/system/component/settings/${this.ref}`);
|
|
@@ -464,18 +357,281 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
464
357
|
});
|
|
465
358
|
}
|
|
466
359
|
async workflow(event, input) {
|
|
467
|
-
return await this.client.post(
|
|
360
|
+
return await this.client.post(`${this.getComponentPath()}/workflow/event`, {
|
|
468
361
|
event,
|
|
469
362
|
input
|
|
470
363
|
});
|
|
471
364
|
}
|
|
472
365
|
async function(name, input) {
|
|
473
|
-
return await this.client.post(
|
|
366
|
+
return await this.client.post(`${this.getComponentPath()}/function/${name}`, {
|
|
474
367
|
data: input
|
|
475
368
|
});
|
|
476
369
|
}
|
|
477
370
|
async revisions(uuid) {
|
|
478
|
-
return await this.client.get(
|
|
371
|
+
return await this.client.get(`${this.getComponentPath()}/model/${uuid}/revisions`);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Internal method to handle NDJSON streaming responses
|
|
375
|
+
*
|
|
376
|
+
* @private
|
|
377
|
+
*/
|
|
378
|
+
async _streamNDJSON(url, headers, handler, body) {
|
|
379
|
+
try {
|
|
380
|
+
const config = {
|
|
381
|
+
headers,
|
|
382
|
+
responseType: 'stream'
|
|
383
|
+
};
|
|
384
|
+
const response = await this.client.post(url, body, config);
|
|
385
|
+
const stream = response.data;
|
|
386
|
+
let buffer = '';
|
|
387
|
+
return new Promise((resolve, reject) => {
|
|
388
|
+
stream.on('data', (chunk) => {
|
|
389
|
+
buffer += chunk.toString();
|
|
390
|
+
// Process complete lines (separated by newlines)
|
|
391
|
+
const lines = buffer.split('\n');
|
|
392
|
+
buffer = lines.pop() || ''; // Keep incomplete line in buffer
|
|
393
|
+
for (const line of lines) {
|
|
394
|
+
if (line.trim()) {
|
|
395
|
+
try {
|
|
396
|
+
const document = JSON.parse(line);
|
|
397
|
+
const result = handler.onData(document);
|
|
398
|
+
// Support async callbacks
|
|
399
|
+
if (result instanceof Promise) {
|
|
400
|
+
result.catch((err) => {
|
|
401
|
+
if (handler.onError) {
|
|
402
|
+
handler.onError(err);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
catch (err) {
|
|
408
|
+
if (handler.onError) {
|
|
409
|
+
handler.onError(err);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
stream.on('end', () => {
|
|
416
|
+
// Process any remaining data in buffer
|
|
417
|
+
if (buffer.trim()) {
|
|
418
|
+
try {
|
|
419
|
+
const document = JSON.parse(buffer);
|
|
420
|
+
handler.onData(document);
|
|
421
|
+
}
|
|
422
|
+
catch (err) {
|
|
423
|
+
if (handler.onError) {
|
|
424
|
+
handler.onError(err);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (handler.onEnd) {
|
|
429
|
+
handler.onEnd();
|
|
430
|
+
}
|
|
431
|
+
resolve();
|
|
432
|
+
});
|
|
433
|
+
stream.on('error', (err) => {
|
|
434
|
+
if (handler.onError) {
|
|
435
|
+
handler.onError(err);
|
|
436
|
+
}
|
|
437
|
+
reject(err);
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
catch (err) {
|
|
442
|
+
if (handler.onError) {
|
|
443
|
+
handler.onError(err);
|
|
444
|
+
}
|
|
445
|
+
throw err;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
class Functions extends PlatformBaseClient {
|
|
451
|
+
async list() {
|
|
452
|
+
return await this.client.get("/v1/system/function");
|
|
453
|
+
}
|
|
454
|
+
async get(ref) {
|
|
455
|
+
return await this.client.get(`/v1/system/function/${ref}`);
|
|
456
|
+
}
|
|
457
|
+
async update(uuid, update) {
|
|
458
|
+
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Run platform function
|
|
462
|
+
*
|
|
463
|
+
* @param id - Function ID
|
|
464
|
+
* @param input - Input data
|
|
465
|
+
* @param query - Query parameters
|
|
466
|
+
* @returns - Function result
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
470
|
+
*/
|
|
471
|
+
async run(id, d) {
|
|
472
|
+
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
473
|
+
params: d.query,
|
|
474
|
+
headers: d.headers
|
|
475
|
+
});
|
|
476
|
+
return data;
|
|
477
|
+
}
|
|
478
|
+
async generateSignature(ref, env) {
|
|
479
|
+
return await this.client.get(`/v1/system/function/signature/${env}/${ref}`);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
class APIUser extends PlatformBaseClient {
|
|
484
|
+
async auth(username, password, project) {
|
|
485
|
+
return this.client.post("/v1/user/api/auth", {
|
|
486
|
+
username,
|
|
487
|
+
password
|
|
488
|
+
}, {
|
|
489
|
+
headers: {
|
|
490
|
+
"X-Project-Uuid": project
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
async newSecret(uuid) {
|
|
495
|
+
return await this.client.post(`/v1/user/api-user/secret/${uuid}`, {});
|
|
496
|
+
}
|
|
497
|
+
async revokeSecret(uuid) {
|
|
498
|
+
return await this.client.delete(`/v1/user/api-user/secret/${uuid}`);
|
|
499
|
+
}
|
|
500
|
+
async edit(uuid, roles) {
|
|
501
|
+
return await this.client.patch(`/v1/user/api-user/${uuid}`, { roles });
|
|
502
|
+
}
|
|
503
|
+
async list() {
|
|
504
|
+
return await this.client.get(`/v1/user/api-user`);
|
|
505
|
+
}
|
|
506
|
+
async get(uuid) {
|
|
507
|
+
return await this.client.get(`/v1/user/api-user/${uuid}`);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
class Users extends PlatformBaseClient {
|
|
512
|
+
async auth(username, password, project) {
|
|
513
|
+
return await this.client.post("/v1/user/login", {
|
|
514
|
+
username,
|
|
515
|
+
password,
|
|
516
|
+
response_type: 'token',
|
|
517
|
+
}, {
|
|
518
|
+
headers: {
|
|
519
|
+
'X-Project-Uuid': project
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Resend confirmation email
|
|
525
|
+
* @param email User email
|
|
526
|
+
*/
|
|
527
|
+
async resendConfirmationEmail(email) {
|
|
528
|
+
return await this.client.post("/v1/user/send/confirmation/email", {
|
|
529
|
+
email,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
// Password Reset (Request Only)
|
|
533
|
+
// Note: Only the REQUEST is exposed, not the password reset completion
|
|
534
|
+
// The actual password reset should be done through the official web interface
|
|
535
|
+
/**
|
|
536
|
+
* Request password reset email
|
|
537
|
+
* This only sends an email with a reset link, does not expose or change passwords
|
|
538
|
+
* @param email User email
|
|
539
|
+
*/
|
|
540
|
+
async requestPasswordReset(email) {
|
|
541
|
+
return await this.client.post("/v1/user/resetpassword", { email });
|
|
542
|
+
}
|
|
543
|
+
// User Profile & Management
|
|
544
|
+
/**
|
|
545
|
+
* Get current user's model
|
|
546
|
+
*/
|
|
547
|
+
async getUser() {
|
|
548
|
+
return await this.client.get("/v1/user/model");
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Get current user's claims
|
|
552
|
+
*/
|
|
553
|
+
async getClaims() {
|
|
554
|
+
return await this.client.get("/v1/user/claims");
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Edit user profile
|
|
558
|
+
* @param data Profile update data
|
|
559
|
+
*/
|
|
560
|
+
async editProfile(data) {
|
|
561
|
+
return await this.client.post("/v1/user/profile/edit", data);
|
|
562
|
+
}
|
|
563
|
+
// Permissions & Roles
|
|
564
|
+
/**
|
|
565
|
+
* Get user permissions
|
|
566
|
+
*/
|
|
567
|
+
async getPermissions() {
|
|
568
|
+
return await this.client.get("/v1/user/role/permissions");
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Get list of available permissions
|
|
572
|
+
*/
|
|
573
|
+
async listPermissions() {
|
|
574
|
+
return await this.client.get("/v1/user/permissions/list");
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Create a new role
|
|
578
|
+
* @param role Role data including name, permissions, workspaces, and level
|
|
579
|
+
*/
|
|
580
|
+
async createRole(role) {
|
|
581
|
+
return await this.client.post("/v1/user/role/create", role);
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Delete a role
|
|
585
|
+
* @param uuid Role UUID
|
|
586
|
+
*/
|
|
587
|
+
async deleteRole(uuid) {
|
|
588
|
+
return await this.client.delete(`/v1/user/role/delete/${uuid}`);
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* List all roles
|
|
592
|
+
*/
|
|
593
|
+
async listRoles() {
|
|
594
|
+
return await this.client.get(`/v1/user/role/list`);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Get role details by UUID
|
|
598
|
+
* @param uuid Role UUID
|
|
599
|
+
*/
|
|
600
|
+
async getRoleModel(uuid) {
|
|
601
|
+
return await this.client.get(`/v1/user/role/edit/${uuid}`);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Edit a role
|
|
605
|
+
* @param uuid Role UUID
|
|
606
|
+
* @param data Role update data including permissions, workspaces, and level
|
|
607
|
+
*/
|
|
608
|
+
async editRole(uuid, data) {
|
|
609
|
+
return await this.client.post(`/v1/user/role/edit/${uuid}`, data);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* @deprecated Use getPermissions() instead
|
|
613
|
+
*/
|
|
614
|
+
async permissions() {
|
|
615
|
+
return await this.client.get(`/v1/user/role/permissions`);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
class Apps extends PlatformBaseClient {
|
|
620
|
+
constructor(appType) {
|
|
621
|
+
super();
|
|
622
|
+
this.appType = appType;
|
|
623
|
+
}
|
|
624
|
+
async updateSettings(updateValues, ref) {
|
|
625
|
+
const payload = { ...updateValues };
|
|
626
|
+
return await this.client.put(`/v3/system/gateway/app-service/${this.appType}/${ref}/settings`, payload);
|
|
627
|
+
}
|
|
628
|
+
async download(ref, version) {
|
|
629
|
+
return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/download`, { version, uuid: ref }, { responseType: "arraybuffer" });
|
|
630
|
+
}
|
|
631
|
+
async upload(formData) {
|
|
632
|
+
return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
|
|
633
|
+
timeout: 60000
|
|
634
|
+
});
|
|
479
635
|
}
|
|
480
636
|
}
|
|
481
637
|
|
|
@@ -1010,8 +1166,8 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1010
1166
|
forge() {
|
|
1011
1167
|
return (new Forge()).setClient(this.client);
|
|
1012
1168
|
}
|
|
1013
|
-
component(ref) {
|
|
1014
|
-
return (new Component(ref)).setClient(this.client);
|
|
1169
|
+
component(ref, options) {
|
|
1170
|
+
return (new Component(ref, options)).setClient(this.client);
|
|
1015
1171
|
}
|
|
1016
1172
|
componentUtils() {
|
|
1017
1173
|
return (new ComponentUtils()).setClient(this.client);
|
|
@@ -1066,8 +1222,8 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1066
1222
|
|
|
1067
1223
|
class IntegrationsBaseClient extends BaseClient {
|
|
1068
1224
|
constructor(options) {
|
|
1069
|
-
var _a, _b, _c;
|
|
1070
|
-
let { env = null, token, host, } = options !== null && options !== void 0 ? options : {};
|
|
1225
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1226
|
+
let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
|
|
1071
1227
|
let headers = {};
|
|
1072
1228
|
var project_uuid = null;
|
|
1073
1229
|
if (isBrowser) {
|
|
@@ -1077,16 +1233,22 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1077
1233
|
else {
|
|
1078
1234
|
headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
|
|
1079
1235
|
}
|
|
1236
|
+
if (typeof window !== "undefined") {
|
|
1237
|
+
// @ts-ignore
|
|
1238
|
+
const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
|
|
1239
|
+
host = (_c = __global_env__.INTEGRATION_API) !== null && _c !== void 0 ? _c : host;
|
|
1240
|
+
// @ts-ignore
|
|
1241
|
+
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
1242
|
+
// @ts-ignore
|
|
1243
|
+
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
1244
|
+
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
1245
|
+
}
|
|
1080
1246
|
}
|
|
1081
|
-
if (
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
1087
|
-
// @ts-ignore
|
|
1088
|
-
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
1089
|
-
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
1247
|
+
else if (process && process.env) {
|
|
1248
|
+
host = (_d = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _d !== void 0 ? _d : null;
|
|
1249
|
+
env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
|
|
1250
|
+
token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
|
|
1251
|
+
project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
|
|
1090
1252
|
}
|
|
1091
1253
|
if (token) {
|
|
1092
1254
|
headers['Authorization'] = `Bearer ${token}`;
|
|
@@ -1106,6 +1268,9 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1106
1268
|
withCredentials: true,
|
|
1107
1269
|
});
|
|
1108
1270
|
super(client);
|
|
1271
|
+
this.env = null;
|
|
1272
|
+
this.token = null;
|
|
1273
|
+
this.host = null;
|
|
1109
1274
|
}
|
|
1110
1275
|
}
|
|
1111
1276
|
|
|
@@ -2750,18 +2915,16 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
2750
2915
|
exports.Integrations = Integrations;
|
|
2751
2916
|
exports.Invoicing = Invoicing;
|
|
2752
2917
|
exports.Payments = Payments;
|
|
2918
|
+
exports.Platform = Platform;
|
|
2753
2919
|
exports.Project = Project;
|
|
2754
2920
|
exports.Ratchet = Ratchet;
|
|
2755
2921
|
exports.Sandbox = Sandbox;
|
|
2756
2922
|
exports.SerbiaUtil = SerbiaUtil;
|
|
2757
2923
|
exports.System = System;
|
|
2758
2924
|
exports.Thunder = Thunder;
|
|
2759
|
-
exports.
|
|
2925
|
+
exports.Users = Users;
|
|
2760
2926
|
exports.VPFR = VPFR;
|
|
2761
2927
|
exports.Workflow = Workflow;
|
|
2762
|
-
exports.default = Platform;
|
|
2763
|
-
|
|
2764
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2765
2928
|
|
|
2766
2929
|
return exports;
|
|
2767
2930
|
|