@ptkl/sdk 1.10.0 → 1.11.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.
@@ -19079,73 +19079,60 @@ class Component extends PlatformBaseClient {
19079
19079
  super();
19080
19080
  this.ref = ref;
19081
19081
  }
19082
- /**
19083
- * Find method to search for models
19084
- *
19085
- * @param {FindParams} filters - The filters to apply to the search
19086
- * @param {FindOptions} opts - The options to apply to the search
19087
- *
19088
- * @returns {Promise<FindResponse>} - The result of the search
19089
- *
19090
- * @example
19091
- * platform.component(name).find({
19092
- * currentPage: 1,
19093
- * perPage: 10,
19094
- * })
19095
- *
19096
- * // advanced search
19097
- * platform.component(name).find({
19098
- * $adv: {
19099
- * name: "John Doe",
19100
- * }
19101
- * )
19102
- **/
19103
- async find(filters, opts) {
19104
- var _a;
19105
- let payload = {
19106
- context: filters,
19107
- ref: this.ref,
19108
- };
19109
- let ctx = payload.context;
19110
- let offset = ctx.currentPage;
19111
- if (offset == undefined) {
19112
- offset = 0;
19113
- }
19114
- let limit = ctx.perPage;
19115
- if (limit == undefined || limit == -1) {
19116
- limit = 10;
19117
- }
19118
- let sortDesc = 1;
19119
- if (ctx.sortDesc) {
19120
- sortDesc = -1;
19121
- }
19122
- if (ctx.filterOn === undefined) {
19123
- ctx.filterOn = [];
19124
- }
19125
- let params = {
19126
- offset: offset,
19127
- sortBy: ctx.sortBy,
19128
- sortDesc: sortDesc,
19129
- filter: ctx.filter,
19130
- filterOn: ctx.filterOn,
19131
- limit: limit,
19132
- dateFrom: ctx.dateFrom,
19133
- dateTo: ctx.dateTo,
19134
- dateField: ctx.dateField,
19135
- };
19136
- if (ctx.only && ctx.only.length > 0) {
19137
- params.only = ctx.only;
19138
- }
19139
- if (Object.keys(ctx.$adv || []).length > 0) {
19140
- params.$adv = [(_a = ctx.$adv) !== null && _a !== void 0 ? _a : {}];
19141
- }
19142
- if (ctx.$aggregate && ctx.$aggregate.length > 0) {
19143
- params.$aggregate = ctx.$aggregate;
19082
+ find(filters, opts) {
19083
+ if (opts && opts.stream === true) {
19084
+ let onMetaCallback = () => { };
19085
+ let onDataCallback = () => { };
19086
+ let onErrorCallback;
19087
+ let onEndCallback;
19088
+ let isFirstLine = true;
19089
+ const chainable = {
19090
+ onMeta: (callback) => {
19091
+ onMetaCallback = callback;
19092
+ return chainable;
19093
+ },
19094
+ onData: (callback) => {
19095
+ onDataCallback = callback;
19096
+ return chainable;
19097
+ },
19098
+ onError: (callback) => {
19099
+ onErrorCallback = callback;
19100
+ return chainable;
19101
+ },
19102
+ onEnd: (callback) => {
19103
+ onEndCallback = callback;
19104
+ return chainable;
19105
+ },
19106
+ stream: () => {
19107
+ const body = this._buildFindBody(filters, opts);
19108
+ const handler = {
19109
+ onData: async (doc) => {
19110
+ if (isFirstLine) {
19111
+ isFirstLine = false;
19112
+ const result = onMetaCallback(doc);
19113
+ if (result instanceof Promise)
19114
+ await result;
19115
+ }
19116
+ else {
19117
+ const result = onDataCallback(doc);
19118
+ if (result instanceof Promise)
19119
+ await result;
19120
+ }
19121
+ },
19122
+ onError: onErrorCallback,
19123
+ onEnd: onEndCallback,
19124
+ };
19125
+ return this._streamNDJSON(`/v4/system/component/${this.ref}/models/stream`, {
19126
+ 'Accept': 'application/x-ndjson',
19127
+ 'Content-Type': 'application/json',
19128
+ 'Accept-Language': (opts === null || opts === void 0 ? void 0 : opts.locale) || 'en_US',
19129
+ }, handler, body);
19130
+ }
19131
+ };
19132
+ return chainable;
19144
19133
  }
19145
- return await this.client.post(`/v4/system/component/${this.ref}/models`, {
19146
- ...params,
19147
- options: opts
19148
- }, {
19134
+ const body = this._buildFindBody(filters, opts);
19135
+ return this.client.post(`/v4/system/component/${this.ref}/models`, body, {
19149
19136
  headers: {
19150
19137
  "Accept-Language": (opts === null || opts === void 0 ? void 0 : opts.locale) || "en_US",
19151
19138
  }
@@ -19174,6 +19161,34 @@ class Component extends PlatformBaseClient {
19174
19161
  }
19175
19162
  return null;
19176
19163
  }
19164
+ /** @private Build the POST body shared by `find` (streaming and non-streaming) */
19165
+ _buildFindBody(filters, opts) {
19166
+ var _a, _b;
19167
+ let ctx = { ...filters };
19168
+ let offset = (_a = ctx.currentPage) !== null && _a !== void 0 ? _a : 0;
19169
+ let limit = (ctx.perPage == null || ctx.perPage === -1) ? 10 : ctx.perPage;
19170
+ let sortDesc = ctx.sortDesc ? -1 : 1;
19171
+ if (ctx.filterOn === undefined)
19172
+ ctx.filterOn = [];
19173
+ const params = {
19174
+ offset,
19175
+ sortBy: ctx.sortBy,
19176
+ sortDesc,
19177
+ filter: ctx.filter,
19178
+ filterOn: ctx.filterOn,
19179
+ limit,
19180
+ dateFrom: ctx.dateFrom,
19181
+ dateTo: ctx.dateTo,
19182
+ dateField: ctx.dateField,
19183
+ };
19184
+ if (ctx.only && ctx.only.length > 0)
19185
+ params.only = ctx.only;
19186
+ if (Object.keys(ctx.$adv || {}).length > 0)
19187
+ params.$adv = [(_b = ctx.$adv) !== null && _b !== void 0 ? _b : {}];
19188
+ if (ctx.$aggregate && ctx.$aggregate.length > 0)
19189
+ params.$aggregate = ctx.$aggregate;
19190
+ return { ...params, options: opts };
19191
+ }
19177
19192
  /**
19178
19193
  * Get model by uuid
19179
19194
  *
@@ -20259,6 +20274,145 @@ class Forge extends PlatformBaseClient {
20259
20274
  }
20260
20275
  }
20261
20276
 
20277
+ const BASE = '/luma/kortex/v1';
20278
+ class Kortex extends PlatformBaseClient {
20279
+ // ── Agents ──
20280
+ async createAgent(data) {
20281
+ return await this.client.post(`${BASE}/agents`, data);
20282
+ }
20283
+ async listAgents(params) {
20284
+ return await this.client.get(`${BASE}/agents`, { params });
20285
+ }
20286
+ async getAgent(uuid) {
20287
+ return await this.client.get(`${BASE}/agents/${uuid}`);
20288
+ }
20289
+ async updateAgent(uuid, data) {
20290
+ return await this.client.patch(`${BASE}/agents/${uuid}`, data);
20291
+ }
20292
+ async deleteAgent(uuid) {
20293
+ return await this.client.delete(`${BASE}/agents/${uuid}`);
20294
+ }
20295
+ async listAgentKnowledgeBases(agentUUID) {
20296
+ return await this.client.get(`${BASE}/agents/${agentUUID}/knowledge-bases`);
20297
+ }
20298
+ // ── Knowledge Bases ──
20299
+ async createKnowledgeBase(data) {
20300
+ return await this.client.post(`${BASE}/knowledge-bases`, data);
20301
+ }
20302
+ async listKnowledgeBases(params) {
20303
+ return await this.client.get(`${BASE}/knowledge-bases`, { params });
20304
+ }
20305
+ async getKnowledgeBase(uuid) {
20306
+ return await this.client.get(`${BASE}/knowledge-bases/${uuid}`);
20307
+ }
20308
+ async updateKnowledgeBase(uuid, data) {
20309
+ return await this.client.put(`${BASE}/knowledge-bases/${uuid}`, data);
20310
+ }
20311
+ async deleteKnowledgeBase(uuid) {
20312
+ return await this.client.delete(`${BASE}/knowledge-bases/${uuid}`);
20313
+ }
20314
+ // ── Documents ──
20315
+ async listDocuments(kbUUID, params) {
20316
+ return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents`, { params });
20317
+ }
20318
+ async uploadDocument(kbUUID, formData) {
20319
+ return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents`, formData, {
20320
+ headers: { 'Content-Type': 'multipart/form-data' },
20321
+ timeout: 120000,
20322
+ });
20323
+ }
20324
+ async getDocument(kbUUID, uuid) {
20325
+ return await this.client.get(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
20326
+ }
20327
+ async deleteDocument(kbUUID, uuid) {
20328
+ return await this.client.delete(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}`);
20329
+ }
20330
+ async retryDocument(kbUUID, uuid) {
20331
+ return await this.client.post(`${BASE}/knowledge-bases/${kbUUID}/documents/${uuid}/retry`);
20332
+ }
20333
+ // ── Conversations ──
20334
+ async createConversation(data) {
20335
+ return await this.client.post(`${BASE}/conversations`, data);
20336
+ }
20337
+ async listConversations(params) {
20338
+ return await this.client.get(`${BASE}/conversations`, { params });
20339
+ }
20340
+ async getConversation(uuid) {
20341
+ return await this.client.get(`${BASE}/conversations/${uuid}`);
20342
+ }
20343
+ async updateConversation(uuid, data) {
20344
+ return await this.client.put(`${BASE}/conversations/${uuid}`, data);
20345
+ }
20346
+ async deleteConversation(uuid) {
20347
+ return await this.client.delete(`${BASE}/conversations/${uuid}`);
20348
+ }
20349
+ async archiveConversation(uuid) {
20350
+ return await this.client.post(`${BASE}/conversations/${uuid}/archive`);
20351
+ }
20352
+ async unarchiveConversation(uuid) {
20353
+ return await this.client.post(`${BASE}/conversations/${uuid}/unarchive`);
20354
+ }
20355
+ async addParticipant(conversationUUID, data) {
20356
+ return await this.client.post(`${BASE}/conversations/${conversationUUID}/participants`, data);
20357
+ }
20358
+ async removeParticipant(conversationUUID, agentUUID) {
20359
+ return await this.client.delete(`${BASE}/conversations/${conversationUUID}/participants/${agentUUID}`);
20360
+ }
20361
+ // ── Messages / Completions ──
20362
+ async sendMessage(conversationUUID, data) {
20363
+ return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, data);
20364
+ }
20365
+ async streamMessage(conversationUUID, data) {
20366
+ return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages`, { ...data, stream: true }, {
20367
+ responseType: 'stream',
20368
+ timeout: 120000,
20369
+ });
20370
+ }
20371
+ async listMessages(conversationUUID, params) {
20372
+ return await this.client.get(`${BASE}/conversations/${conversationUUID}/messages`, { params });
20373
+ }
20374
+ async injectMessage(conversationUUID, data) {
20375
+ return await this.client.post(`${BASE}/conversations/${conversationUUID}/messages/inject`, data);
20376
+ }
20377
+ // ── OCR ──
20378
+ async ocr(data) {
20379
+ return await this.client.post(`${BASE}/ocr`, data, { timeout: 120000 });
20380
+ }
20381
+ // ── User Access ──
20382
+ async createUserAccess(data) {
20383
+ return await this.client.post(`${BASE}/user-access`, data);
20384
+ }
20385
+ async listUserAccess(params) {
20386
+ return await this.client.get(`${BASE}/user-access`, { params });
20387
+ }
20388
+ async getUserAccess(uuid) {
20389
+ return await this.client.get(`${BASE}/user-access/${uuid}`);
20390
+ }
20391
+ async updateUserAccess(uuid, data) {
20392
+ return await this.client.patch(`${BASE}/user-access/${uuid}`, data);
20393
+ }
20394
+ async deleteUserAccess(uuid) {
20395
+ return await this.client.delete(`${BASE}/user-access/${uuid}`);
20396
+ }
20397
+ async getUserMonthlyUsage(uuid, params) {
20398
+ return await this.client.get(`${BASE}/user-access/${uuid}/usage`, { params });
20399
+ }
20400
+ async getUserUsageBreakdown(uuid) {
20401
+ return await this.client.get(`${BASE}/user-access/${uuid}/usage/breakdown`);
20402
+ }
20403
+ async getMyAccess() {
20404
+ return await this.client.get(`${BASE}/my-access`);
20405
+ }
20406
+ // ── Usage (Admin) ──
20407
+ async listUsage(params) {
20408
+ return await this.client.get(`${BASE}/usage`, { params });
20409
+ }
20410
+ // ── Tier ──
20411
+ async getTier() {
20412
+ return await this.client.get(`${BASE}/tier`);
20413
+ }
20414
+ }
20415
+
20262
20416
  class Project extends PlatformBaseClient {
20263
20417
  /**
20264
20418
  * Get list of all projects for the current user
@@ -20483,6 +20637,9 @@ class Platform extends PlatformBaseClient {
20483
20637
  forge() {
20484
20638
  return (new Forge()).setClient(this.client);
20485
20639
  }
20640
+ kortex() {
20641
+ return (new Kortex()).setClient(this.client);
20642
+ }
20486
20643
  component(ref) {
20487
20644
  return (new Component(ref)).setClient(this.client);
20488
20645
  }
@@ -20849,6 +21006,12 @@ class DMS extends IntegrationsBaseClient {
20849
21006
  async generateDocument(payload) {
20850
21007
  return this.requestv2('POST', 'documents/document/generate', { data: payload });
20851
21008
  }
21009
+ async listDocumentRevisions(path) {
21010
+ return this.requestv2('GET', `documents/revisions/${path}`);
21011
+ }
21012
+ async getDocumentRevision(path, version) {
21013
+ return this.requestv2('GET', `documents/revision/${path}`, { params: { version } });
21014
+ }
20852
21015
  async fillPdf(data) {
20853
21016
  const { input_path, output_path, output_pdf = false, output_type, output_file_name, replace, form_data, forms } = data;
20854
21017
  const responseType = output_pdf ? 'arraybuffer' : 'json';
@@ -22395,6 +22558,45 @@ class Ecommerce extends IntegrationsBaseClient {
22395
22558
  }
22396
22559
  }
22397
22560
 
22561
+ class Timber extends IntegrationsBaseClient {
22562
+ async query(params = {}) {
22563
+ const { data } = await this.client.get("/v1/timber/logs", {
22564
+ params: this.normalizeParams(params),
22565
+ });
22566
+ return data;
22567
+ }
22568
+ async write(payload) {
22569
+ const { data } = await this.client.post("/v1/timber/logs", payload);
22570
+ return data;
22571
+ }
22572
+ async usage() {
22573
+ const { data } = await this.client.get("/v1/timber/usage");
22574
+ return data;
22575
+ }
22576
+ async debug(message, payload) {
22577
+ return this.write({ ...payload, message, level: 'debug' });
22578
+ }
22579
+ async info(message, payload) {
22580
+ return this.write({ ...payload, message, level: 'info' });
22581
+ }
22582
+ async warn(message, payload) {
22583
+ return this.write({ ...payload, message, level: 'warn' });
22584
+ }
22585
+ async error(message, payload) {
22586
+ return this.write({ ...payload, message, level: 'error' });
22587
+ }
22588
+ normalizeParams(params) {
22589
+ const normalized = { ...params };
22590
+ if (params.from instanceof Date) {
22591
+ normalized.from = params.from.toISOString();
22592
+ }
22593
+ if (params.to instanceof Date) {
22594
+ normalized.to = params.to.toISOString();
22595
+ }
22596
+ return normalized;
22597
+ }
22598
+ }
22599
+
22398
22600
  class Integrations extends IntegrationsBaseClient {
22399
22601
  constructor(options) {
22400
22602
  super(options);
@@ -22406,6 +22608,7 @@ class Integrations extends IntegrationsBaseClient {
22406
22608
  'protokol-payments': new Payments().setClient(this.client),
22407
22609
  'protokol-minimax': new Minimax().setClient(this.client),
22408
22610
  'protokol-ecommerce': new Ecommerce().setClient(this.client),
22611
+ 'protokol-timber': new Timber().setClient(this.client),
22409
22612
  };
22410
22613
  }
22411
22614
  getDMS() {
@@ -22432,6 +22635,9 @@ class Integrations extends IntegrationsBaseClient {
22432
22635
  getEcommerce() {
22433
22636
  return this.getInterfaceOf('protokol-ecommerce');
22434
22637
  }
22638
+ getTimber() {
22639
+ return this.getInterfaceOf('protokol-timber');
22640
+ }
22435
22641
  async list() {
22436
22642
  const { data } = await this.client.get("/v1/integrations");
22437
22643
  return data;
@@ -22618,6 +22824,7 @@ exports.Functions = Functions;
22618
22824
  exports.Integration = Integrations;
22619
22825
  exports.Integrations = Integrations;
22620
22826
  exports.Invoicing = Invoicing;
22827
+ exports.Kortex = Kortex;
22621
22828
  exports.Mail = Mail;
22622
22829
  exports.NBS = NBS;
22623
22830
  exports.PRN = PRN;
@@ -22629,6 +22836,7 @@ exports.Sandbox = Sandbox;
22629
22836
  exports.SerbiaMinFin = MinFin;
22630
22837
  exports.System = System;
22631
22838
  exports.Thunder = Thunder;
22839
+ exports.Timber = Timber;
22632
22840
  exports.Users = Users;
22633
22841
  exports.VPFR = VPFR;
22634
22842
  exports.Workflow = Workflow;