@ptkl/sdk 0.10.2 → 1.0.1

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.
Files changed (132) hide show
  1. package/dist/{index.iife.js → index.0.10.js} +417 -230
  2. package/dist/index.0.9.js +2849 -0
  3. package/dist/package.json +12 -7
  4. package/dist/v0.10/api/component.d.ts +136 -0
  5. package/dist/v0.10/api/componentUtils.d.ts +16 -0
  6. package/dist/v0.10/api/index.d.ts +22 -0
  7. package/dist/{types → v0.10}/api/integrationsBaseClient.d.ts +3 -0
  8. package/dist/{types → v0.10}/api/platform.d.ts +2 -2
  9. package/dist/v0.10/apiUser.d.ts +9 -0
  10. package/dist/v0.10/apps.d.ts +8 -0
  11. package/dist/v0.10/baseClient.d.ts +6 -0
  12. package/dist/{types/api → v0.10}/component.d.ts +39 -4
  13. package/dist/v0.10/componentUtils.d.ts +7 -0
  14. package/dist/v0.10/config.d.ts +14 -0
  15. package/dist/v0.10/forge.d.ts +7 -0
  16. package/dist/v0.10/functions.d.ts +23 -0
  17. package/dist/{index.cjs.js → v0.10/index.cjs.js} +417 -230
  18. package/dist/v0.10/index.d.ts +21 -0
  19. package/dist/{index.esm.js → v0.10/index.esm.js} +416 -227
  20. package/dist/v0.10/integrations/dms.d.ts +469 -0
  21. package/dist/v0.10/integrations/invoicing.d.ts +6 -0
  22. package/dist/v0.10/integrations/minimax.d.ts +289 -0
  23. package/dist/v0.10/integrations/payments.d.ts +40 -0
  24. package/dist/v0.10/integrations/serbiaUtil.d.ts +10 -0
  25. package/dist/v0.10/integrations/vpfr.d.ts +4 -0
  26. package/dist/v0.10/integrations.d.ts +22 -0
  27. package/dist/v0.10/integrationsBaseClient.d.ts +11 -0
  28. package/dist/v0.10/platform.d.ts +34 -0
  29. package/dist/v0.10/platformBaseClient.d.ts +27 -0
  30. package/dist/v0.10/project.d.ts +146 -0
  31. package/dist/v0.10/ratchet.d.ts +196 -0
  32. package/dist/v0.10/sandbox.d.ts +14 -0
  33. package/dist/v0.10/system.d.ts +4 -0
  34. package/dist/v0.10/thunder.d.ts +13 -0
  35. package/dist/v0.10/types/component.d.ts +298 -0
  36. package/dist/v0.10/users.d.ts +69 -0
  37. package/dist/v0.10/workflow.d.ts +5 -0
  38. package/dist/v0.9/api/apiUser.d.ts +9 -0
  39. package/dist/v0.9/api/apps.d.ts +8 -0
  40. package/dist/v0.9/api/baseClient.d.ts +6 -0
  41. package/dist/v0.9/api/component.d.ts +136 -0
  42. package/dist/v0.9/api/config.d.ts +14 -0
  43. package/dist/v0.9/api/forge.d.ts +7 -0
  44. package/dist/v0.9/api/functions.d.ts +23 -0
  45. package/dist/v0.9/api/index.d.ts +24 -0
  46. package/dist/v0.9/api/integrations/dms.d.ts +419 -0
  47. package/dist/v0.9/api/integrations/invoicing.d.ts +6 -0
  48. package/dist/v0.9/api/integrations/minimax.d.ts +289 -0
  49. package/dist/v0.9/api/integrations/payments.d.ts +40 -0
  50. package/dist/v0.9/api/integrations/serbiaUtil.d.ts +10 -0
  51. package/dist/v0.9/api/integrations/vpfr.d.ts +4 -0
  52. package/dist/v0.9/api/integrations.d.ts +22 -0
  53. package/dist/v0.9/api/integrationsBaseClient.d.ts +11 -0
  54. package/dist/v0.9/api/platform.d.ts +34 -0
  55. package/dist/v0.9/api/platformBaseClient.d.ts +27 -0
  56. package/dist/v0.9/api/project.d.ts +146 -0
  57. package/dist/v0.9/api/ratchet.d.ts +196 -0
  58. package/dist/v0.9/api/sandbox.d.ts +14 -0
  59. package/dist/v0.9/api/system.d.ts +4 -0
  60. package/dist/v0.9/api/thunder.d.ts +13 -0
  61. package/dist/v0.9/api/users.d.ts +69 -0
  62. package/dist/v0.9/api/workflow.d.ts +5 -0
  63. package/dist/v0.9/apiUser.d.ts +9 -0
  64. package/dist/v0.9/apps.d.ts +8 -0
  65. package/dist/v0.9/baseClient.d.ts +6 -0
  66. package/dist/v0.9/component.d.ts +128 -0
  67. package/dist/v0.9/componentUtils.d.ts +7 -0
  68. package/dist/v0.9/config.d.ts +14 -0
  69. package/dist/v0.9/forge.d.ts +7 -0
  70. package/dist/v0.9/functions.d.ts +23 -0
  71. package/dist/v0.9/index.cjs.js +21811 -0
  72. package/dist/v0.9/index.d.ts +21 -0
  73. package/dist/v0.9/index.esm.js +2820 -0
  74. package/dist/v0.9/integrations/dms.d.ts +469 -0
  75. package/dist/v0.9/integrations/invoicing.d.ts +6 -0
  76. package/dist/v0.9/integrations/minimax.d.ts +289 -0
  77. package/dist/v0.9/integrations/payments.d.ts +40 -0
  78. package/dist/v0.9/integrations/serbiaUtil.d.ts +10 -0
  79. package/dist/v0.9/integrations/vpfr.d.ts +4 -0
  80. package/dist/v0.9/integrations.d.ts +22 -0
  81. package/dist/v0.9/integrationsBaseClient.d.ts +11 -0
  82. package/dist/v0.9/platform.d.ts +34 -0
  83. package/dist/v0.9/platformBaseClient.d.ts +27 -0
  84. package/dist/v0.9/project.d.ts +146 -0
  85. package/dist/v0.9/ratchet.d.ts +196 -0
  86. package/dist/v0.9/sandbox.d.ts +14 -0
  87. package/dist/v0.9/system.d.ts +4 -0
  88. package/dist/v0.9/thunder.d.ts +13 -0
  89. package/dist/{types → v0.9}/types/component.d.ts +34 -2
  90. package/dist/v0.9/types/config.d.ts +11 -0
  91. package/dist/v0.9/types/integrations.d.ts +321 -0
  92. package/dist/v0.9/types/project.d.ts +64 -0
  93. package/dist/v0.9/types/ratchet.d.ts +38 -0
  94. package/dist/v0.9/types/users.d.ts +66 -0
  95. package/dist/v0.9/users.d.ts +69 -0
  96. package/dist/v0.9/util/detectEnv.d.ts +4 -0
  97. package/dist/v0.9/workflow.d.ts +5 -0
  98. package/package.json +12 -7
  99. package/dist/monaco.d.ts +0 -887
  100. package/dist/types/api/index.d.ts +0 -13
  101. package/dist/types/api/integrations/media.d.ts +0 -17
  102. package/dist/types/api/roles.d.ts +0 -9
  103. package/dist/types/index.d.ts +0 -29
  104. package/dist/types/types/media.d.ts +0 -103
  105. /package/dist/{types → v0.10}/api/apiUser.d.ts +0 -0
  106. /package/dist/{types → v0.10}/api/apps.d.ts +0 -0
  107. /package/dist/{types → v0.10}/api/baseClient.d.ts +0 -0
  108. /package/dist/{types → v0.10}/api/config.d.ts +0 -0
  109. /package/dist/{types → v0.10}/api/forge.d.ts +0 -0
  110. /package/dist/{types → v0.10}/api/functions.d.ts +0 -0
  111. /package/dist/{types → v0.10}/api/integrations/dms.d.ts +0 -0
  112. /package/dist/{types → v0.10}/api/integrations/invoicing.d.ts +0 -0
  113. /package/dist/{types → v0.10}/api/integrations/minimax.d.ts +0 -0
  114. /package/dist/{types → v0.10}/api/integrations/payments.d.ts +0 -0
  115. /package/dist/{types → v0.10}/api/integrations/serbiaUtil.d.ts +0 -0
  116. /package/dist/{types → v0.10}/api/integrations/vpfr.d.ts +0 -0
  117. /package/dist/{types → v0.10}/api/integrations.d.ts +0 -0
  118. /package/dist/{types → v0.10}/api/platformBaseClient.d.ts +0 -0
  119. /package/dist/{types → v0.10}/api/project.d.ts +0 -0
  120. /package/dist/{types → v0.10}/api/ratchet.d.ts +0 -0
  121. /package/dist/{types → v0.10}/api/sandbox.d.ts +0 -0
  122. /package/dist/{types → v0.10}/api/system.d.ts +0 -0
  123. /package/dist/{types → v0.10}/api/thunder.d.ts +0 -0
  124. /package/dist/{types → v0.10}/api/users.d.ts +0 -0
  125. /package/dist/{types → v0.10}/api/workflow.d.ts +0 -0
  126. /package/dist/{types → v0.10}/types/config.d.ts +0 -0
  127. /package/dist/{types → v0.10}/types/integrations.d.ts +0 -0
  128. /package/dist/{types → v0.10}/types/project.d.ts +0 -0
  129. /package/dist/{types → v0.10}/types/ratchet.d.ts +0 -0
  130. /package/dist/{types → v0.10}/types/users.d.ts +0 -0
  131. /package/dist/{types → v0.10}/util/detectEnv.d.ts +0 -0
  132. /package/dist/{types → v0.9}/api/componentUtils.d.ts +0 -0
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var require$$1 = require('util');
6
4
  var stream = require('stream');
7
5
  var require$$1$1 = require('path');
@@ -19003,27 +19001,32 @@ const isBrowser = typeof window !== "undefined" &&
19003
19001
  */
19004
19002
  class PlatformBaseClient extends BaseClient {
19005
19003
  constructor(options) {
19006
- var _a, _b, _c;
19004
+ var _a, _b, _c, _d, _e, _f, _g;
19007
19005
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
19008
19006
  let headers = {};
19009
19007
  var project_uuid = null;
19010
19008
  if (isBrowser) {
19011
- console.log("PlatformBaseClient: running in browser context");
19012
19009
  if (sessionStorage.getItem('protokol_context') == "forge") {
19013
19010
  headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
19014
19011
  }
19015
19012
  else {
19016
19013
  headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
19017
19014
  }
19015
+ if (typeof window !== "undefined") {
19016
+ // @ts-ignore
19017
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
19018
+ host = (_c = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _c !== void 0 ? _c : host;
19019
+ // @ts-ignore
19020
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
19021
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
19022
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
19023
+ }
19018
19024
  }
19019
- if (typeof window !== "undefined") {
19020
- // @ts-ignore
19021
- const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
19022
- host = (_c = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _c !== void 0 ? _c : host;
19023
- // @ts-ignore
19024
- env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
19025
- token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
19026
- project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
19025
+ else if (process && process.env) {
19026
+ host = (_d = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _d !== void 0 ? _d : null;
19027
+ env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
19028
+ token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
19029
+ project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
19027
19030
  }
19028
19031
  if (token) {
19029
19032
  headers['Authorization'] = `Bearer ${token}`;
@@ -19050,198 +19053,22 @@ class PlatformBaseClient extends BaseClient {
19050
19053
  }
19051
19054
  }
19052
19055
 
19053
- class Functions extends PlatformBaseClient {
19054
- async list() {
19055
- return await this.client.get("/v1/system/function");
19056
- }
19057
- async get(ref) {
19058
- return await this.client.get(`/v1/system/function/${ref}`);
19059
- }
19060
- async update(uuid, update) {
19061
- return await this.client.patch(`/v1/system/function/${uuid}`, update);
19062
- }
19063
- /**
19064
- * Run platform function
19065
- *
19066
- * @param id - Function ID
19067
- * @param input - Input data
19068
- * @param query - Query parameters
19069
- * @returns - Function result
19070
- *
19071
- * @example
19072
- * const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
19073
- */
19074
- async run(id, d) {
19075
- const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
19076
- params: d.query,
19077
- headers: d.headers
19078
- });
19079
- return data;
19080
- }
19081
- async generateSignature(ref, env) {
19082
- return await this.client.get(`/v1/system/function/signature/${env}/${ref}`);
19083
- }
19084
- }
19085
-
19086
- class APIUser extends PlatformBaseClient {
19087
- async auth(username, password, project) {
19088
- return this.client.post("/v1/user/api/auth", {
19089
- username,
19090
- password
19091
- }, {
19092
- headers: {
19093
- "X-Project-Uuid": project
19094
- }
19095
- });
19096
- }
19097
- async newSecret(uuid) {
19098
- return await this.client.post(`/v1/user/api-user/secret/${uuid}`, {});
19099
- }
19100
- async revokeSecret(uuid) {
19101
- return await this.client.delete(`/v1/user/api-user/secret/${uuid}`);
19102
- }
19103
- async edit(uuid, roles) {
19104
- return await this.client.patch(`/v1/user/api-user/${uuid}`, { roles });
19105
- }
19106
- async list() {
19107
- return await this.client.get(`/v1/user/api-user`);
19108
- }
19109
- async get(uuid) {
19110
- return await this.client.get(`/v1/user/api-user/${uuid}`);
19111
- }
19112
- }
19113
-
19114
- class Users extends PlatformBaseClient {
19115
- async auth(username, password, project) {
19116
- return await this.client.post("/v1/user/login", {
19117
- username,
19118
- password,
19119
- response_type: 'token',
19120
- }, {
19121
- headers: {
19122
- 'X-Project-Uuid': project
19123
- }
19124
- });
19125
- }
19126
- /**
19127
- * Resend confirmation email
19128
- * @param email User email
19129
- */
19130
- async resendConfirmationEmail(email) {
19131
- return await this.client.post("/v1/user/send/confirmation/email", {
19132
- email,
19133
- });
19134
- }
19135
- // Password Reset (Request Only)
19136
- // Note: Only the REQUEST is exposed, not the password reset completion
19137
- // The actual password reset should be done through the official web interface
19138
- /**
19139
- * Request password reset email
19140
- * This only sends an email with a reset link, does not expose or change passwords
19141
- * @param email User email
19142
- */
19143
- async requestPasswordReset(email) {
19144
- return await this.client.post("/v1/user/resetpassword", { email });
19145
- }
19146
- // User Profile & Management
19147
- /**
19148
- * Get current user's model
19149
- */
19150
- async getUser() {
19151
- return await this.client.get("/v1/user/model");
19152
- }
19153
- /**
19154
- * Get current user's claims
19155
- */
19156
- async getClaims() {
19157
- return await this.client.get("/v1/user/claims");
19158
- }
19159
- /**
19160
- * Edit user profile
19161
- * @param data Profile update data
19162
- */
19163
- async editProfile(data) {
19164
- return await this.client.post("/v1/user/profile/edit", data);
19165
- }
19166
- // Permissions & Roles
19167
- /**
19168
- * Get user permissions
19169
- */
19170
- async getPermissions() {
19171
- return await this.client.get("/v1/user/role/permissions");
19172
- }
19173
- /**
19174
- * Get list of available permissions
19175
- */
19176
- async listPermissions() {
19177
- return await this.client.get("/v1/user/permissions/list");
19178
- }
19179
- /**
19180
- * Create a new role
19181
- * @param role Role data including name, permissions, workspaces, and level
19182
- */
19183
- async createRole(role) {
19184
- return await this.client.post("/v1/user/role/create", role);
19185
- }
19186
- /**
19187
- * Delete a role
19188
- * @param uuid Role UUID
19189
- */
19190
- async deleteRole(uuid) {
19191
- return await this.client.delete(`/v1/user/role/delete/${uuid}`);
19192
- }
19193
- /**
19194
- * List all roles
19195
- */
19196
- async listRoles() {
19197
- return await this.client.get(`/v1/user/role/list`);
19198
- }
19199
- /**
19200
- * Get role details by UUID
19201
- * @param uuid Role UUID
19202
- */
19203
- async getRoleModel(uuid) {
19204
- return await this.client.get(`/v1/user/role/edit/${uuid}`);
19205
- }
19206
- /**
19207
- * Edit a role
19208
- * @param uuid Role UUID
19209
- * @param data Role update data including permissions, workspaces, and level
19210
- */
19211
- async editRole(uuid, data) {
19212
- return await this.client.post(`/v1/user/role/edit/${uuid}`, data);
19213
- }
19214
- /**
19215
- * @deprecated Use getPermissions() instead
19216
- */
19217
- async permissions() {
19218
- return await this.client.get(`/v1/user/role/permissions`);
19219
- }
19220
- }
19221
-
19222
- class Apps extends PlatformBaseClient {
19223
- constructor(appType) {
19224
- super();
19225
- this.appType = appType;
19226
- }
19227
- async updateSettings(updateValues, ref) {
19228
- const payload = { ...updateValues };
19229
- return await this.client.put(`/v3/system/gateway/app-service/${this.appType}/${ref}/settings`, payload);
19230
- }
19231
- async download(ref, version) {
19232
- return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/download`, { version, uuid: ref }, { responseType: "arraybuffer" });
19233
- }
19234
- async upload(formData) {
19235
- return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
19236
- timeout: 60000
19237
- });
19238
- }
19239
- }
19240
-
19241
19056
  class Component extends PlatformBaseClient {
19242
- constructor(ref = null) {
19057
+ constructor(ref = null, options) {
19058
+ var _a;
19243
19059
  super();
19244
19060
  this.ref = ref;
19061
+ this.version = (_a = options === null || options === void 0 ? void 0 : options.version) !== null && _a !== void 0 ? _a : null;
19062
+ }
19063
+ /**
19064
+ * Get the base path for component API calls
19065
+ * @private
19066
+ */
19067
+ getComponentPath() {
19068
+ if (this.version) {
19069
+ return `/v3/system/component/${this.ref}/v/${this.version}`;
19070
+ }
19071
+ return `/v3/system/component/${this.ref}`;
19245
19072
  }
19246
19073
  /**
19247
19074
  * Find method to search for models
@@ -19311,7 +19138,7 @@ class Component extends PlatformBaseClient {
19311
19138
  params[`_opt_${k}`] = opts ? opts[k] : null;
19312
19139
  });
19313
19140
  }
19314
- return await this.client.get(`/v3/system/component/${this.ref}/models`, {
19141
+ return await this.client.get(`${this.getComponentPath()}/models`, {
19315
19142
  params: params,
19316
19143
  headers: {
19317
19144
  'X-Cache': cache,
@@ -19350,7 +19177,7 @@ class Component extends PlatformBaseClient {
19350
19177
  * @returns (Promise<Model>)
19351
19178
  */
19352
19179
  async get(uuid) {
19353
- return await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
19180
+ return await this.client.get(`${this.getComponentPath()}/model/${uuid}`);
19354
19181
  }
19355
19182
  /**
19356
19183
  * Update model by uuid
@@ -19360,7 +19187,7 @@ class Component extends PlatformBaseClient {
19360
19187
  * @returns
19361
19188
  */
19362
19189
  async update(uuid, data, options) {
19363
- return await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
19190
+ return await this.client.post(`${this.getComponentPath()}/model/${uuid}`, {
19364
19191
  data,
19365
19192
  options,
19366
19193
  });
@@ -19373,9 +19200,22 @@ class Component extends PlatformBaseClient {
19373
19200
  * @returns
19374
19201
  */
19375
19202
  async updateMany(data, options) {
19376
- return await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
19203
+ return await this.client.patch(`${this.getComponentPath()}/models/bulk`, {
19377
19204
  data,
19378
- options,
19205
+ options
19206
+ });
19207
+ }
19208
+ /**
19209
+ * Create many models
19210
+ *
19211
+ * @param data
19212
+ * @param options
19213
+ * @returns
19214
+ */
19215
+ async createMany(data, options) {
19216
+ return await this.client.post(`${this.getComponentPath()}/models/bulk`, {
19217
+ data,
19218
+ options
19379
19219
  });
19380
19220
  }
19381
19221
  /**
@@ -19386,7 +19226,7 @@ class Component extends PlatformBaseClient {
19386
19226
  * @returns
19387
19227
  */
19388
19228
  async modify(filters, data, options) {
19389
- return await this.client.patch(`/v3/system/component/${this.ref}/modify/model`, {
19229
+ return await this.client.patch(`${this.getComponentPath()}/modify/model`, {
19390
19230
  filters,
19391
19231
  data,
19392
19232
  options,
@@ -19401,20 +19241,84 @@ class Component extends PlatformBaseClient {
19401
19241
  * @returns
19402
19242
  */
19403
19243
  async concurrentUpdate(uuid, version, data, options) {
19404
- return await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
19244
+ return await this.client.post(`${this.getComponentPath()}/model/${uuid}`, {
19405
19245
  version: version,
19406
19246
  data,
19407
19247
  options,
19408
19248
  });
19409
19249
  }
19410
19250
  async create(model) {
19411
- return await this.client.post(`/v3/system/component/${this.ref}/model`, model);
19251
+ return await this.client.post(`${this.getComponentPath()}/model`, model);
19412
19252
  }
19413
19253
  async delete(uuid) {
19414
- return await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
19254
+ return await this.client.delete(`${this.getComponentPath()}/model/${uuid}`);
19415
19255
  }
19416
- async aggregate(pipeline) {
19417
- return await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
19256
+ /**
19257
+ * Execute aggregate pipeline with optional streaming support
19258
+ *
19259
+ * Returns a chainable object that allows both buffered and streaming modes.
19260
+ * Call .onData() to enable streaming mode, or await directly for buffered mode.
19261
+ *
19262
+ * @param {FindAggregateParams} pipeline - MongoDB aggregation pipeline
19263
+ *
19264
+ * @returns {AggregateChainable} Chainable object with streaming methods and Promise interface
19265
+ *
19266
+ * @example
19267
+ * ```typescript
19268
+ * // Buffered response (default, up to 5K documents)
19269
+ * const result = await component.aggregate([{ $match: { status: 'active' } }]);
19270
+ * console.log(result.data); // All results at once
19271
+ *
19272
+ * // Streaming response (up to 25K documents)
19273
+ * await component.aggregate([{ $match: { status: 'active' } }])
19274
+ * .onData((doc) => console.log('Received:', doc))
19275
+ * .onError((err) => console.error('Error:', err))
19276
+ * .onEnd(() => console.log('Stream complete'));
19277
+ * ```
19278
+ */
19279
+ aggregate(pipeline) {
19280
+ let onDataCallback = () => { };
19281
+ let onErrorCallback;
19282
+ let onEndCallback;
19283
+ let isStreaming = false;
19284
+ let streamPromise = null;
19285
+ const chainable = {
19286
+ onData: (callback) => {
19287
+ onDataCallback = callback;
19288
+ isStreaming = true;
19289
+ return chainable;
19290
+ },
19291
+ onError: (callback) => {
19292
+ onErrorCallback = callback;
19293
+ return chainable;
19294
+ },
19295
+ onEnd: (callback) => {
19296
+ onEndCallback = callback;
19297
+ return chainable;
19298
+ },
19299
+ then: (resolve, reject) => {
19300
+ if (isStreaming) {
19301
+ if (!streamPromise) {
19302
+ const handler = {
19303
+ onData: onDataCallback,
19304
+ onError: onErrorCallback,
19305
+ onEnd: onEndCallback
19306
+ };
19307
+ streamPromise = this._streamNDJSON(`${this.getComponentPath()}/aggregate`, {
19308
+ 'Accept': 'application/x-ndjson',
19309
+ 'Content-Type': 'application/json'
19310
+ }, handler, pipeline);
19311
+ }
19312
+ return streamPromise.then(resolve, reject);
19313
+ }
19314
+ return this.client.post(`${this.getComponentPath()}/aggregate`, pipeline)
19315
+ .then(resolve, reject);
19316
+ },
19317
+ catch: (reject) => {
19318
+ return chainable.then(undefined, reject);
19319
+ }
19320
+ };
19321
+ return chainable;
19418
19322
  }
19419
19323
  async settings() {
19420
19324
  return await this.client.get(`/v3/system/component/settings/${this.ref}`);
@@ -19432,18 +19336,281 @@ class Component extends PlatformBaseClient {
19432
19336
  });
19433
19337
  }
19434
19338
  async workflow(event, input) {
19435
- return await this.client.post(`/v3/system/component/${this.ref}/workflow/event`, {
19339
+ return await this.client.post(`${this.getComponentPath()}/workflow/event`, {
19436
19340
  event,
19437
19341
  input
19438
19342
  });
19439
19343
  }
19440
19344
  async function(name, input) {
19441
- return await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, {
19345
+ return await this.client.post(`${this.getComponentPath()}/function/${name}`, {
19442
19346
  data: input
19443
19347
  });
19444
19348
  }
19445
19349
  async revisions(uuid) {
19446
- return await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}/revisions`);
19350
+ return await this.client.get(`${this.getComponentPath()}/model/${uuid}/revisions`);
19351
+ }
19352
+ /**
19353
+ * Internal method to handle NDJSON streaming responses
19354
+ *
19355
+ * @private
19356
+ */
19357
+ async _streamNDJSON(url, headers, handler, body) {
19358
+ try {
19359
+ const config = {
19360
+ headers,
19361
+ responseType: 'stream'
19362
+ };
19363
+ const response = await this.client.post(url, body, config);
19364
+ const stream = response.data;
19365
+ let buffer = '';
19366
+ return new Promise((resolve, reject) => {
19367
+ stream.on('data', (chunk) => {
19368
+ buffer += chunk.toString();
19369
+ // Process complete lines (separated by newlines)
19370
+ const lines = buffer.split('\n');
19371
+ buffer = lines.pop() || ''; // Keep incomplete line in buffer
19372
+ for (const line of lines) {
19373
+ if (line.trim()) {
19374
+ try {
19375
+ const document = JSON.parse(line);
19376
+ const result = handler.onData(document);
19377
+ // Support async callbacks
19378
+ if (result instanceof Promise) {
19379
+ result.catch((err) => {
19380
+ if (handler.onError) {
19381
+ handler.onError(err);
19382
+ }
19383
+ });
19384
+ }
19385
+ }
19386
+ catch (err) {
19387
+ if (handler.onError) {
19388
+ handler.onError(err);
19389
+ }
19390
+ }
19391
+ }
19392
+ }
19393
+ });
19394
+ stream.on('end', () => {
19395
+ // Process any remaining data in buffer
19396
+ if (buffer.trim()) {
19397
+ try {
19398
+ const document = JSON.parse(buffer);
19399
+ handler.onData(document);
19400
+ }
19401
+ catch (err) {
19402
+ if (handler.onError) {
19403
+ handler.onError(err);
19404
+ }
19405
+ }
19406
+ }
19407
+ if (handler.onEnd) {
19408
+ handler.onEnd();
19409
+ }
19410
+ resolve();
19411
+ });
19412
+ stream.on('error', (err) => {
19413
+ if (handler.onError) {
19414
+ handler.onError(err);
19415
+ }
19416
+ reject(err);
19417
+ });
19418
+ });
19419
+ }
19420
+ catch (err) {
19421
+ if (handler.onError) {
19422
+ handler.onError(err);
19423
+ }
19424
+ throw err;
19425
+ }
19426
+ }
19427
+ }
19428
+
19429
+ class Functions extends PlatformBaseClient {
19430
+ async list() {
19431
+ return await this.client.get("/v1/system/function");
19432
+ }
19433
+ async get(ref) {
19434
+ return await this.client.get(`/v1/system/function/${ref}`);
19435
+ }
19436
+ async update(uuid, update) {
19437
+ return await this.client.patch(`/v1/system/function/${uuid}`, update);
19438
+ }
19439
+ /**
19440
+ * Run platform function
19441
+ *
19442
+ * @param id - Function ID
19443
+ * @param input - Input data
19444
+ * @param query - Query parameters
19445
+ * @returns - Function result
19446
+ *
19447
+ * @example
19448
+ * const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
19449
+ */
19450
+ async run(id, d) {
19451
+ const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
19452
+ params: d.query,
19453
+ headers: d.headers
19454
+ });
19455
+ return data;
19456
+ }
19457
+ async generateSignature(ref, env) {
19458
+ return await this.client.get(`/v1/system/function/signature/${env}/${ref}`);
19459
+ }
19460
+ }
19461
+
19462
+ class APIUser extends PlatformBaseClient {
19463
+ async auth(username, password, project) {
19464
+ return this.client.post("/v1/user/api/auth", {
19465
+ username,
19466
+ password
19467
+ }, {
19468
+ headers: {
19469
+ "X-Project-Uuid": project
19470
+ }
19471
+ });
19472
+ }
19473
+ async newSecret(uuid) {
19474
+ return await this.client.post(`/v1/user/api-user/secret/${uuid}`, {});
19475
+ }
19476
+ async revokeSecret(uuid) {
19477
+ return await this.client.delete(`/v1/user/api-user/secret/${uuid}`);
19478
+ }
19479
+ async edit(uuid, roles) {
19480
+ return await this.client.patch(`/v1/user/api-user/${uuid}`, { roles });
19481
+ }
19482
+ async list() {
19483
+ return await this.client.get(`/v1/user/api-user`);
19484
+ }
19485
+ async get(uuid) {
19486
+ return await this.client.get(`/v1/user/api-user/${uuid}`);
19487
+ }
19488
+ }
19489
+
19490
+ class Users extends PlatformBaseClient {
19491
+ async auth(username, password, project) {
19492
+ return await this.client.post("/v1/user/login", {
19493
+ username,
19494
+ password,
19495
+ response_type: 'token',
19496
+ }, {
19497
+ headers: {
19498
+ 'X-Project-Uuid': project
19499
+ }
19500
+ });
19501
+ }
19502
+ /**
19503
+ * Resend confirmation email
19504
+ * @param email User email
19505
+ */
19506
+ async resendConfirmationEmail(email) {
19507
+ return await this.client.post("/v1/user/send/confirmation/email", {
19508
+ email,
19509
+ });
19510
+ }
19511
+ // Password Reset (Request Only)
19512
+ // Note: Only the REQUEST is exposed, not the password reset completion
19513
+ // The actual password reset should be done through the official web interface
19514
+ /**
19515
+ * Request password reset email
19516
+ * This only sends an email with a reset link, does not expose or change passwords
19517
+ * @param email User email
19518
+ */
19519
+ async requestPasswordReset(email) {
19520
+ return await this.client.post("/v1/user/resetpassword", { email });
19521
+ }
19522
+ // User Profile & Management
19523
+ /**
19524
+ * Get current user's model
19525
+ */
19526
+ async getUser() {
19527
+ return await this.client.get("/v1/user/model");
19528
+ }
19529
+ /**
19530
+ * Get current user's claims
19531
+ */
19532
+ async getClaims() {
19533
+ return await this.client.get("/v1/user/claims");
19534
+ }
19535
+ /**
19536
+ * Edit user profile
19537
+ * @param data Profile update data
19538
+ */
19539
+ async editProfile(data) {
19540
+ return await this.client.post("/v1/user/profile/edit", data);
19541
+ }
19542
+ // Permissions & Roles
19543
+ /**
19544
+ * Get user permissions
19545
+ */
19546
+ async getPermissions() {
19547
+ return await this.client.get("/v1/user/role/permissions");
19548
+ }
19549
+ /**
19550
+ * Get list of available permissions
19551
+ */
19552
+ async listPermissions() {
19553
+ return await this.client.get("/v1/user/permissions/list");
19554
+ }
19555
+ /**
19556
+ * Create a new role
19557
+ * @param role Role data including name, permissions, workspaces, and level
19558
+ */
19559
+ async createRole(role) {
19560
+ return await this.client.post("/v1/user/role/create", role);
19561
+ }
19562
+ /**
19563
+ * Delete a role
19564
+ * @param uuid Role UUID
19565
+ */
19566
+ async deleteRole(uuid) {
19567
+ return await this.client.delete(`/v1/user/role/delete/${uuid}`);
19568
+ }
19569
+ /**
19570
+ * List all roles
19571
+ */
19572
+ async listRoles() {
19573
+ return await this.client.get(`/v1/user/role/list`);
19574
+ }
19575
+ /**
19576
+ * Get role details by UUID
19577
+ * @param uuid Role UUID
19578
+ */
19579
+ async getRoleModel(uuid) {
19580
+ return await this.client.get(`/v1/user/role/edit/${uuid}`);
19581
+ }
19582
+ /**
19583
+ * Edit a role
19584
+ * @param uuid Role UUID
19585
+ * @param data Role update data including permissions, workspaces, and level
19586
+ */
19587
+ async editRole(uuid, data) {
19588
+ return await this.client.post(`/v1/user/role/edit/${uuid}`, data);
19589
+ }
19590
+ /**
19591
+ * @deprecated Use getPermissions() instead
19592
+ */
19593
+ async permissions() {
19594
+ return await this.client.get(`/v1/user/role/permissions`);
19595
+ }
19596
+ }
19597
+
19598
+ class Apps extends PlatformBaseClient {
19599
+ constructor(appType) {
19600
+ super();
19601
+ this.appType = appType;
19602
+ }
19603
+ async updateSettings(updateValues, ref) {
19604
+ const payload = { ...updateValues };
19605
+ return await this.client.put(`/v3/system/gateway/app-service/${this.appType}/${ref}/settings`, payload);
19606
+ }
19607
+ async download(ref, version) {
19608
+ return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/download`, { version, uuid: ref }, { responseType: "arraybuffer" });
19609
+ }
19610
+ async upload(formData) {
19611
+ return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
19612
+ timeout: 60000
19613
+ });
19447
19614
  }
19448
19615
  }
19449
19616
 
@@ -19454,6 +19621,17 @@ class ComponentUtils extends PlatformBaseClient {
19454
19621
  async create(data) {
19455
19622
  return await this.client.post("/v3/system/component/create", data);
19456
19623
  }
19624
+ /**
19625
+ * Setup a component with settings in a single atomic operation.
19626
+ * This is more comprehensive than create as it handles component creation
19627
+ * and settings initialization together.
19628
+ *
19629
+ * @param data - Component setup data including name, settings, versions, etc.
19630
+ * @returns Promise resolving to the created/updated component
19631
+ */
19632
+ async setup(data) {
19633
+ return await this.client.post("/v3/system/component/setup", data);
19634
+ }
19457
19635
  }
19458
19636
 
19459
19637
  class Thunder extends PlatformBaseClient {
@@ -19978,8 +20156,8 @@ class Platform extends PlatformBaseClient {
19978
20156
  forge() {
19979
20157
  return (new Forge()).setClient(this.client);
19980
20158
  }
19981
- component(ref) {
19982
- return (new Component(ref)).setClient(this.client);
20159
+ component(ref, options) {
20160
+ return (new Component(ref, options)).setClient(this.client);
19983
20161
  }
19984
20162
  componentUtils() {
19985
20163
  return (new ComponentUtils()).setClient(this.client);
@@ -20034,8 +20212,8 @@ class Invoicing extends PlatformBaseClient {
20034
20212
 
20035
20213
  class IntegrationsBaseClient extends BaseClient {
20036
20214
  constructor(options) {
20037
- var _a, _b, _c;
20038
- let { env = null, token, host, } = options !== null && options !== void 0 ? options : {};
20215
+ var _a, _b, _c, _d, _e, _f, _g;
20216
+ let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
20039
20217
  let headers = {};
20040
20218
  var project_uuid = null;
20041
20219
  if (isBrowser) {
@@ -20045,16 +20223,22 @@ class IntegrationsBaseClient extends BaseClient {
20045
20223
  else {
20046
20224
  headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
20047
20225
  }
20226
+ if (typeof window !== "undefined") {
20227
+ // @ts-ignore
20228
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
20229
+ host = (_c = __global_env__.INTEGRATION_API) !== null && _c !== void 0 ? _c : host;
20230
+ // @ts-ignore
20231
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
20232
+ // @ts-ignore
20233
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
20234
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
20235
+ }
20048
20236
  }
20049
- if (typeof window !== "undefined") {
20050
- // @ts-ignore
20051
- const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
20052
- host = (_c = __global_env__.INTEGRATION_API) !== null && _c !== void 0 ? _c : host;
20053
- // @ts-ignore
20054
- token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
20055
- // @ts-ignore
20056
- env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
20057
- project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
20237
+ else if (process && process.env) {
20238
+ host = (_d = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _d !== void 0 ? _d : null;
20239
+ env = (_e = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _e !== void 0 ? _e : null;
20240
+ token = (_f = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _f !== void 0 ? _f : null;
20241
+ project_uuid = (_g = process.env.PROJECT_UUID) !== null && _g !== void 0 ? _g : null;
20058
20242
  }
20059
20243
  if (token) {
20060
20244
  headers['Authorization'] = `Bearer ${token}`;
@@ -20074,6 +20258,9 @@ class IntegrationsBaseClient extends BaseClient {
20074
20258
  withCredentials: true,
20075
20259
  });
20076
20260
  super(client);
20261
+ this.env = null;
20262
+ this.token = null;
20263
+ this.host = null;
20077
20264
  }
20078
20265
  }
20079
20266
 
@@ -21718,13 +21905,13 @@ exports.Integration = Integrations;
21718
21905
  exports.Integrations = Integrations;
21719
21906
  exports.Invoicing = Invoicing;
21720
21907
  exports.Payments = Payments;
21908
+ exports.Platform = Platform;
21721
21909
  exports.Project = Project;
21722
21910
  exports.Ratchet = Ratchet;
21723
21911
  exports.Sandbox = Sandbox;
21724
21912
  exports.SerbiaUtil = SerbiaUtil;
21725
21913
  exports.System = System;
21726
21914
  exports.Thunder = Thunder;
21727
- exports.User = Users;
21915
+ exports.Users = Users;
21728
21916
  exports.VPFR = VPFR;
21729
21917
  exports.Workflow = Workflow;
21730
- exports.default = Platform;