@ptkl/sdk 1.5.3 → 1.6.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.
- package/README.md +29 -0
- package/dist/index.0.10.js +142 -24
- package/dist/index.0.9.js +5 -0
- package/dist/package.json +1 -1
- package/dist/v0.10/api/component.d.ts +13 -1
- package/dist/v0.10/api/componentUtils.d.ts +1 -0
- package/dist/v0.10/api/integrations/dms.d.ts +2 -1
- package/dist/v0.10/api/thunder.d.ts +4 -4
- package/dist/v0.10/index.cjs.js +142 -24
- package/dist/v0.10/index.esm.js +142 -24
- package/dist/v0.10/types/component.d.ts +3 -1
- package/dist/v0.10/types/integrations.d.ts +20 -0
- package/dist/v0.9/api/componentUtils.d.ts +1 -0
- package/dist/v0.9/index.cjs.js +5 -0
- package/dist/v0.9/index.esm.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,4 +13,33 @@ const platform = new Platform({
|
|
|
13
13
|
|
|
14
14
|
// now you can
|
|
15
15
|
const results = await platform.function().run("hello_world", {text: "Hi!"})
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Component Query Options (beta)
|
|
19
|
+
|
|
20
|
+
For the beta SDK export (`@ptkl/sdk/beta`), component model reads support:
|
|
21
|
+
|
|
22
|
+
- `cacheTTL` (number, seconds) in `find` options
|
|
23
|
+
- `only` (string[]) field projection in `find` filters
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const resp = await platform.component("ecommerce::orders").find(
|
|
27
|
+
{
|
|
28
|
+
currentPage: 1,
|
|
29
|
+
perPage: 20,
|
|
30
|
+
only: ["uuid", "status", "total"],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
cacheTTL: 0, // force fresh read
|
|
34
|
+
locale: "en_US",
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Thunder Projection (beta)
|
|
40
|
+
|
|
41
|
+
Thunder read methods support optional `only` projection fields:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
const row = await platform.thunder().findOne("user_settings", { user_id: 42 }, ["theme", "timezone"])
|
|
16
45
|
```
|
package/dist/index.0.10.js
CHANGED
|
@@ -78,6 +78,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
78
78
|
const client = axios.create({
|
|
79
79
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
|
|
80
80
|
timeout: 30000,
|
|
81
|
+
withCredentials: true,
|
|
81
82
|
headers: {
|
|
82
83
|
...headers,
|
|
83
84
|
'Content-Type': 'application/json',
|
|
@@ -154,6 +155,13 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
154
155
|
dateTo: ctx.dateTo,
|
|
155
156
|
dateField: ctx.dateField,
|
|
156
157
|
};
|
|
158
|
+
if (ctx.only && ctx.only.length > 0) {
|
|
159
|
+
params.only = ctx.only;
|
|
160
|
+
}
|
|
161
|
+
else if (ctx.includeFields && ctx.includeFields.length > 0) {
|
|
162
|
+
// Backward-compatible alias. The API now prefers `only`.
|
|
163
|
+
params.includeFields = ctx.includeFields;
|
|
164
|
+
}
|
|
157
165
|
if (Object.keys(ctx.$adv || []).length > 0) {
|
|
158
166
|
params.$adv = [(_a = ctx.$adv) !== null && _a !== void 0 ? _a : {}];
|
|
159
167
|
}
|
|
@@ -560,11 +568,122 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
560
568
|
return await this.client.delete(`/v4/system/component/${this.ref}/${version}/policies/${name}`);
|
|
561
569
|
}
|
|
562
570
|
/**
|
|
563
|
-
* Internal method to handle NDJSON streaming responses
|
|
571
|
+
* Internal method to handle NDJSON streaming responses.
|
|
572
|
+
* Uses native fetch + ReadableStream in browser environments and
|
|
573
|
+
* Axios responseType:'stream' in Node.js environments.
|
|
564
574
|
*
|
|
565
575
|
* @private
|
|
566
576
|
*/
|
|
567
577
|
async _streamNDJSON(url, headers, handler, body) {
|
|
578
|
+
const inBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
579
|
+
if (inBrowser) {
|
|
580
|
+
return this._streamNDJSONBrowser(url, headers, handler, body);
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
return this._streamNDJSONNode(url, headers, handler, body);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Browser implementation: native fetch + ReadableStream (NDJSON).
|
|
588
|
+
* @private
|
|
589
|
+
*/
|
|
590
|
+
async _streamNDJSONBrowser(url, headers, handler, body) {
|
|
591
|
+
var _a, _b;
|
|
592
|
+
try {
|
|
593
|
+
// Derive full URL from the axios instance's baseURL
|
|
594
|
+
const baseURL = ((_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : 'https://lemon.protokol.io').replace(/\/$/, '');
|
|
595
|
+
const fullURL = `${baseURL}${url}`;
|
|
596
|
+
// Collect auth/env headers from the axios instance defaults
|
|
597
|
+
const defaultHeaders = {};
|
|
598
|
+
const axDefaults = this.client.defaults.headers;
|
|
599
|
+
for (const [k, v] of Object.entries(axDefaults)) {
|
|
600
|
+
if (typeof v === 'string')
|
|
601
|
+
defaultHeaders[k] = v;
|
|
602
|
+
}
|
|
603
|
+
if (axDefaults.common && typeof axDefaults.common === 'object') {
|
|
604
|
+
for (const [k, v] of Object.entries(axDefaults.common)) {
|
|
605
|
+
if (typeof v === 'string')
|
|
606
|
+
defaultHeaders[k] = v;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const mergedHeaders = {
|
|
610
|
+
'Content-Type': 'application/json',
|
|
611
|
+
...defaultHeaders,
|
|
612
|
+
...headers,
|
|
613
|
+
};
|
|
614
|
+
const response = await fetch(fullURL, {
|
|
615
|
+
method: 'POST',
|
|
616
|
+
headers: mergedHeaders,
|
|
617
|
+
body: JSON.stringify(body),
|
|
618
|
+
credentials: 'include',
|
|
619
|
+
});
|
|
620
|
+
if (!response.ok) {
|
|
621
|
+
const err = new Error(`Aggregate stream failed: ${response.status} ${response.statusText}`);
|
|
622
|
+
if (handler.onError)
|
|
623
|
+
handler.onError(err);
|
|
624
|
+
throw err;
|
|
625
|
+
}
|
|
626
|
+
if (!response.body) {
|
|
627
|
+
if (handler.onEnd)
|
|
628
|
+
handler.onEnd();
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
const reader = response.body.getReader();
|
|
632
|
+
const decoder = new TextDecoder();
|
|
633
|
+
let buffer = '';
|
|
634
|
+
while (true) {
|
|
635
|
+
const { done, value } = await reader.read();
|
|
636
|
+
if (done) {
|
|
637
|
+
if (buffer.trim()) {
|
|
638
|
+
try {
|
|
639
|
+
const document = JSON.parse(buffer);
|
|
640
|
+
const result = handler.onData(document);
|
|
641
|
+
if (result instanceof Promise) {
|
|
642
|
+
await result.catch((err) => { if (handler.onError)
|
|
643
|
+
handler.onError(err); });
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
catch (err) {
|
|
647
|
+
if (handler.onError)
|
|
648
|
+
handler.onError(err);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if (handler.onEnd)
|
|
652
|
+
handler.onEnd();
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
buffer += decoder.decode(value, { stream: true });
|
|
656
|
+
const lines = buffer.split('\n');
|
|
657
|
+
buffer = (_b = lines.pop()) !== null && _b !== void 0 ? _b : '';
|
|
658
|
+
for (const line of lines) {
|
|
659
|
+
if (!line.trim())
|
|
660
|
+
continue;
|
|
661
|
+
try {
|
|
662
|
+
const document = JSON.parse(line);
|
|
663
|
+
const result = handler.onData(document);
|
|
664
|
+
if (result instanceof Promise) {
|
|
665
|
+
await result.catch((err) => { if (handler.onError)
|
|
666
|
+
handler.onError(err); });
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
catch (err) {
|
|
670
|
+
if (handler.onError)
|
|
671
|
+
handler.onError(err);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
catch (err) {
|
|
677
|
+
if (handler.onError)
|
|
678
|
+
handler.onError(err);
|
|
679
|
+
throw err;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Node.js implementation: Axios responseType:'stream' + EventEmitter API.
|
|
684
|
+
* @private
|
|
685
|
+
*/
|
|
686
|
+
async _streamNDJSONNode(url, headers, handler, body) {
|
|
568
687
|
try {
|
|
569
688
|
const config = {
|
|
570
689
|
headers,
|
|
@@ -576,61 +695,52 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
576
695
|
return new Promise((resolve, reject) => {
|
|
577
696
|
stream.on('data', (chunk) => {
|
|
578
697
|
buffer += chunk.toString();
|
|
579
|
-
// Process complete lines (separated by newlines)
|
|
580
698
|
const lines = buffer.split('\n');
|
|
581
|
-
buffer = lines.pop() || '';
|
|
699
|
+
buffer = lines.pop() || '';
|
|
582
700
|
for (const line of lines) {
|
|
583
701
|
if (line.trim()) {
|
|
584
702
|
try {
|
|
585
703
|
const document = JSON.parse(line);
|
|
586
704
|
const result = handler.onData(document);
|
|
587
|
-
// Support async callbacks
|
|
588
705
|
if (result instanceof Promise) {
|
|
589
706
|
result.catch((err) => {
|
|
590
|
-
if (handler.onError)
|
|
707
|
+
if (handler.onError)
|
|
591
708
|
handler.onError(err);
|
|
592
|
-
}
|
|
593
709
|
});
|
|
594
710
|
}
|
|
595
711
|
}
|
|
596
712
|
catch (err) {
|
|
597
|
-
if (handler.onError)
|
|
713
|
+
if (handler.onError)
|
|
598
714
|
handler.onError(err);
|
|
599
|
-
}
|
|
600
715
|
}
|
|
601
716
|
}
|
|
602
717
|
}
|
|
603
718
|
});
|
|
604
719
|
stream.on('end', () => {
|
|
605
|
-
// Process any remaining data in buffer
|
|
606
720
|
if (buffer.trim()) {
|
|
607
721
|
try {
|
|
608
722
|
const document = JSON.parse(buffer);
|
|
609
723
|
handler.onData(document);
|
|
610
724
|
}
|
|
611
725
|
catch (err) {
|
|
612
|
-
if (handler.onError)
|
|
726
|
+
if (handler.onError)
|
|
613
727
|
handler.onError(err);
|
|
614
|
-
}
|
|
615
728
|
}
|
|
616
729
|
}
|
|
617
|
-
if (handler.onEnd)
|
|
730
|
+
if (handler.onEnd)
|
|
618
731
|
handler.onEnd();
|
|
619
|
-
}
|
|
620
732
|
resolve();
|
|
621
733
|
});
|
|
622
734
|
stream.on('error', (err) => {
|
|
623
|
-
if (handler.onError)
|
|
735
|
+
if (handler.onError)
|
|
624
736
|
handler.onError(err);
|
|
625
|
-
}
|
|
626
737
|
reject(err);
|
|
627
738
|
});
|
|
628
739
|
});
|
|
629
740
|
}
|
|
630
741
|
catch (err) {
|
|
631
|
-
if (handler.onError)
|
|
742
|
+
if (handler.onError)
|
|
632
743
|
handler.onError(err);
|
|
633
|
-
}
|
|
634
744
|
throw err;
|
|
635
745
|
}
|
|
636
746
|
}
|
|
@@ -820,6 +930,9 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
820
930
|
async create(data) {
|
|
821
931
|
return await this.client.post("/v3/system/component/create", data);
|
|
822
932
|
}
|
|
933
|
+
async delete(ref) {
|
|
934
|
+
return await this.client.delete(`/v3/system/component/${ref}`);
|
|
935
|
+
}
|
|
823
936
|
/**
|
|
824
937
|
* Setup a component with settings in a single atomic operation.
|
|
825
938
|
* This is more comprehensive than create as it handles component creation
|
|
@@ -834,12 +947,13 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
834
947
|
}
|
|
835
948
|
|
|
836
949
|
class Thunder extends PlatformBaseClient {
|
|
837
|
-
async read(type, filters, flag, options) {
|
|
950
|
+
async read(type, filters, flag, options, only) {
|
|
838
951
|
return await this.client.post("/v3/system/thunder", {
|
|
839
952
|
type,
|
|
840
953
|
filters,
|
|
841
954
|
flag,
|
|
842
955
|
options,
|
|
956
|
+
only,
|
|
843
957
|
});
|
|
844
958
|
}
|
|
845
959
|
async write(type, filters, d, flag) {
|
|
@@ -853,14 +967,14 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
853
967
|
async operation(name, filters, data) {
|
|
854
968
|
return await this.write(name, filters, data, "Operation");
|
|
855
969
|
}
|
|
856
|
-
async find(name, filters) {
|
|
857
|
-
return await this.read(name, filters, "Find");
|
|
970
|
+
async find(name, filters, only) {
|
|
971
|
+
return await this.read(name, filters, "Find", undefined, only);
|
|
858
972
|
}
|
|
859
|
-
async findOne(name, filters) {
|
|
860
|
-
return await this.read(name, filters, "FindOne");
|
|
973
|
+
async findOne(name, filters, only) {
|
|
974
|
+
return await this.read(name, filters, "FindOne", undefined, only);
|
|
861
975
|
}
|
|
862
|
-
async paginate(name, filters, options) {
|
|
863
|
-
return await this.read(name, filters, "Paginate", options);
|
|
976
|
+
async paginate(name, filters, options, only) {
|
|
977
|
+
return await this.read(name, filters, "Paginate", options, only);
|
|
864
978
|
}
|
|
865
979
|
async upsert(name, filters, data) {
|
|
866
980
|
return await this.write(name, filters, data, "Upsert");
|
|
@@ -1450,6 +1564,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1450
1564
|
const client = axios.create({
|
|
1451
1565
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
|
|
1452
1566
|
timeout: 30000,
|
|
1567
|
+
withCredentials: true,
|
|
1453
1568
|
headers: {
|
|
1454
1569
|
...headers,
|
|
1455
1570
|
},
|
|
@@ -1728,6 +1843,9 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1728
1843
|
async createDocumentComment(payload) {
|
|
1729
1844
|
return this.requestv2('POST', 'documents/document/comment', { data: payload });
|
|
1730
1845
|
}
|
|
1846
|
+
async generateDocument(payload) {
|
|
1847
|
+
return this.requestv2('POST', 'documents/document/generate', { data: payload });
|
|
1848
|
+
}
|
|
1731
1849
|
async fillPdf(data) {
|
|
1732
1850
|
const { input_path, output_path, output_pdf = false, output_type, output_file_name, replace, form_data, forms } = data;
|
|
1733
1851
|
const responseType = output_pdf ? 'arraybuffer' : 'json';
|
package/dist/index.0.9.js
CHANGED
|
@@ -78,6 +78,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
78
78
|
const client = axios.create({
|
|
79
79
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
|
|
80
80
|
timeout: 30000,
|
|
81
|
+
withCredentials: true,
|
|
81
82
|
headers: {
|
|
82
83
|
...headers,
|
|
83
84
|
'Content-Type': 'application/json',
|
|
@@ -647,6 +648,9 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
647
648
|
async create(data) {
|
|
648
649
|
return await this.client.post("/v3/system/component/create", data);
|
|
649
650
|
}
|
|
651
|
+
async delete(ref) {
|
|
652
|
+
return await this.client.delete(`/v3/system/component/${ref}`);
|
|
653
|
+
}
|
|
650
654
|
}
|
|
651
655
|
|
|
652
656
|
class Thunder extends PlatformBaseClient {
|
|
@@ -1275,6 +1279,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
1275
1279
|
const client = axios.create({
|
|
1276
1280
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
|
|
1277
1281
|
timeout: 30000,
|
|
1282
|
+
withCredentials: true,
|
|
1278
1283
|
headers: {
|
|
1279
1284
|
...headers,
|
|
1280
1285
|
}
|
package/dist/package.json
CHANGED
|
@@ -303,10 +303,22 @@ export default class Component<C extends string = string> extends PlatformBaseCl
|
|
|
303
303
|
*/
|
|
304
304
|
deletePolicy(name: string, version: string): Promise<AxiosResponse<any, any>>;
|
|
305
305
|
/**
|
|
306
|
-
* Internal method to handle NDJSON streaming responses
|
|
306
|
+
* Internal method to handle NDJSON streaming responses.
|
|
307
|
+
* Uses native fetch + ReadableStream in browser environments and
|
|
308
|
+
* Axios responseType:'stream' in Node.js environments.
|
|
307
309
|
*
|
|
308
310
|
* @private
|
|
309
311
|
*/
|
|
310
312
|
private _streamNDJSON;
|
|
313
|
+
/**
|
|
314
|
+
* Browser implementation: native fetch + ReadableStream (NDJSON).
|
|
315
|
+
* @private
|
|
316
|
+
*/
|
|
317
|
+
private _streamNDJSONBrowser;
|
|
318
|
+
/**
|
|
319
|
+
* Node.js implementation: Axios responseType:'stream' + EventEmitter API.
|
|
320
|
+
* @private
|
|
321
|
+
*/
|
|
322
|
+
private _streamNDJSONNode;
|
|
311
323
|
}
|
|
312
324
|
export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, StreamHandler, AggregateChainable, ComponentOptions, Extension, };
|
|
@@ -4,6 +4,7 @@ import PlatformBaseClient from "./platformBaseClient";
|
|
|
4
4
|
export default class ComponentUtils extends PlatformBaseClient {
|
|
5
5
|
list(): Promise<AxiosResponse<ComponentListResponse>>;
|
|
6
6
|
create(data: any): Promise<AxiosResponse<any, any>>;
|
|
7
|
+
delete(ref: string): Promise<AxiosResponse<any, any>>;
|
|
7
8
|
/**
|
|
8
9
|
* Setup a component with settings in a single atomic operation.
|
|
9
10
|
* This is more comprehensive than create as it handles component creation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import IntegrationsBaseClient from "../integrationsBaseClient";
|
|
2
2
|
import { AxiosResponse } from "axios";
|
|
3
|
-
import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions, PDF2HTMLOptions, MediaUploadPayload, MediaUploadBase64Payload, DocumentListParams, DocumentListResponse, DocumentCreatePayload, DocumentUpdatePayload, DocumentRestorePayload, DocumentCommentPayload, DocumentResponse } from "../../types/integrations";
|
|
3
|
+
import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions, PDF2HTMLOptions, MediaUploadPayload, MediaUploadBase64Payload, DocumentListParams, DocumentListResponse, DocumentCreatePayload, DocumentUpdatePayload, DocumentRestorePayload, DocumentCommentPayload, DocumentResponse, DocumentGeneratePayload, DocumentGenerateResponse } from "../../types/integrations";
|
|
4
4
|
/**
|
|
5
5
|
* Document Management System (DMS) API client
|
|
6
6
|
*
|
|
@@ -142,6 +142,7 @@ export default class DMS extends IntegrationsBaseClient {
|
|
|
142
142
|
listDeletedDocuments(params?: DocumentListParams): Promise<AxiosResponse<DocumentListResponse>>;
|
|
143
143
|
restoreDocument(payload: DocumentRestorePayload): Promise<AxiosResponse<DocumentResponse>>;
|
|
144
144
|
createDocumentComment(payload: DocumentCommentPayload): Promise<AxiosResponse<any, any>>;
|
|
145
|
+
generateDocument(payload: DocumentGeneratePayload): Promise<AxiosResponse<DocumentGenerateResponse>>;
|
|
145
146
|
fillPdf(data: PDFFillOptions): Promise<AxiosResponse<any, any>>;
|
|
146
147
|
/**
|
|
147
148
|
* Convert data between different formats (JSON, CSV, Excel)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import PlatformBaseClient from "./platformBaseClient";
|
|
2
2
|
export default class Thunder extends PlatformBaseClient {
|
|
3
|
-
read(type: string, filters: any, flag: string, options?: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
3
|
+
read(type: string, filters: any, flag: string, options?: any, only?: string[]): Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
4
|
write(type: string, filters: any, d: any, flag: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
5
5
|
operation(name: string, filters: any, data: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
-
find(name: string, filters: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
-
findOne(name: string, filters: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
-
paginate(name: string, filters: any, options?: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
+
find(name: string, filters: any, only?: string[]): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
+
findOne(name: string, filters: any, only?: string[]): Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
+
paginate(name: string, filters: any, options?: any, only?: string[]): Promise<import("axios").AxiosResponse<any, any>>;
|
|
9
9
|
upsert(name: string, filters: any, data: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
10
10
|
insertOne(name: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
11
11
|
updateOne(name: string, filters: any, data: any): Promise<import("axios").AxiosResponse<any, any>>;
|
package/dist/v0.10/index.cjs.js
CHANGED
|
@@ -19044,6 +19044,7 @@ class PlatformBaseClient extends BaseClient {
|
|
|
19044
19044
|
const client = axios.create({
|
|
19045
19045
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
|
|
19046
19046
|
timeout: 30000,
|
|
19047
|
+
withCredentials: true,
|
|
19047
19048
|
headers: {
|
|
19048
19049
|
...headers,
|
|
19049
19050
|
'Content-Type': 'application/json',
|
|
@@ -19120,6 +19121,13 @@ class Component extends PlatformBaseClient {
|
|
|
19120
19121
|
dateTo: ctx.dateTo,
|
|
19121
19122
|
dateField: ctx.dateField,
|
|
19122
19123
|
};
|
|
19124
|
+
if (ctx.only && ctx.only.length > 0) {
|
|
19125
|
+
params.only = ctx.only;
|
|
19126
|
+
}
|
|
19127
|
+
else if (ctx.includeFields && ctx.includeFields.length > 0) {
|
|
19128
|
+
// Backward-compatible alias. The API now prefers `only`.
|
|
19129
|
+
params.includeFields = ctx.includeFields;
|
|
19130
|
+
}
|
|
19123
19131
|
if (Object.keys(ctx.$adv || []).length > 0) {
|
|
19124
19132
|
params.$adv = [(_a = ctx.$adv) !== null && _a !== void 0 ? _a : {}];
|
|
19125
19133
|
}
|
|
@@ -19526,11 +19534,122 @@ class Component extends PlatformBaseClient {
|
|
|
19526
19534
|
return await this.client.delete(`/v4/system/component/${this.ref}/${version}/policies/${name}`);
|
|
19527
19535
|
}
|
|
19528
19536
|
/**
|
|
19529
|
-
* Internal method to handle NDJSON streaming responses
|
|
19537
|
+
* Internal method to handle NDJSON streaming responses.
|
|
19538
|
+
* Uses native fetch + ReadableStream in browser environments and
|
|
19539
|
+
* Axios responseType:'stream' in Node.js environments.
|
|
19530
19540
|
*
|
|
19531
19541
|
* @private
|
|
19532
19542
|
*/
|
|
19533
19543
|
async _streamNDJSON(url, headers, handler, body) {
|
|
19544
|
+
const inBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
19545
|
+
if (inBrowser) {
|
|
19546
|
+
return this._streamNDJSONBrowser(url, headers, handler, body);
|
|
19547
|
+
}
|
|
19548
|
+
else {
|
|
19549
|
+
return this._streamNDJSONNode(url, headers, handler, body);
|
|
19550
|
+
}
|
|
19551
|
+
}
|
|
19552
|
+
/**
|
|
19553
|
+
* Browser implementation: native fetch + ReadableStream (NDJSON).
|
|
19554
|
+
* @private
|
|
19555
|
+
*/
|
|
19556
|
+
async _streamNDJSONBrowser(url, headers, handler, body) {
|
|
19557
|
+
var _a, _b;
|
|
19558
|
+
try {
|
|
19559
|
+
// Derive full URL from the axios instance's baseURL
|
|
19560
|
+
const baseURL = ((_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : 'https://lemon.protokol.io').replace(/\/$/, '');
|
|
19561
|
+
const fullURL = `${baseURL}${url}`;
|
|
19562
|
+
// Collect auth/env headers from the axios instance defaults
|
|
19563
|
+
const defaultHeaders = {};
|
|
19564
|
+
const axDefaults = this.client.defaults.headers;
|
|
19565
|
+
for (const [k, v] of Object.entries(axDefaults)) {
|
|
19566
|
+
if (typeof v === 'string')
|
|
19567
|
+
defaultHeaders[k] = v;
|
|
19568
|
+
}
|
|
19569
|
+
if (axDefaults.common && typeof axDefaults.common === 'object') {
|
|
19570
|
+
for (const [k, v] of Object.entries(axDefaults.common)) {
|
|
19571
|
+
if (typeof v === 'string')
|
|
19572
|
+
defaultHeaders[k] = v;
|
|
19573
|
+
}
|
|
19574
|
+
}
|
|
19575
|
+
const mergedHeaders = {
|
|
19576
|
+
'Content-Type': 'application/json',
|
|
19577
|
+
...defaultHeaders,
|
|
19578
|
+
...headers,
|
|
19579
|
+
};
|
|
19580
|
+
const response = await fetch(fullURL, {
|
|
19581
|
+
method: 'POST',
|
|
19582
|
+
headers: mergedHeaders,
|
|
19583
|
+
body: JSON.stringify(body),
|
|
19584
|
+
credentials: 'include',
|
|
19585
|
+
});
|
|
19586
|
+
if (!response.ok) {
|
|
19587
|
+
const err = new Error(`Aggregate stream failed: ${response.status} ${response.statusText}`);
|
|
19588
|
+
if (handler.onError)
|
|
19589
|
+
handler.onError(err);
|
|
19590
|
+
throw err;
|
|
19591
|
+
}
|
|
19592
|
+
if (!response.body) {
|
|
19593
|
+
if (handler.onEnd)
|
|
19594
|
+
handler.onEnd();
|
|
19595
|
+
return;
|
|
19596
|
+
}
|
|
19597
|
+
const reader = response.body.getReader();
|
|
19598
|
+
const decoder = new TextDecoder();
|
|
19599
|
+
let buffer = '';
|
|
19600
|
+
while (true) {
|
|
19601
|
+
const { done, value } = await reader.read();
|
|
19602
|
+
if (done) {
|
|
19603
|
+
if (buffer.trim()) {
|
|
19604
|
+
try {
|
|
19605
|
+
const document = JSON.parse(buffer);
|
|
19606
|
+
const result = handler.onData(document);
|
|
19607
|
+
if (result instanceof Promise) {
|
|
19608
|
+
await result.catch((err) => { if (handler.onError)
|
|
19609
|
+
handler.onError(err); });
|
|
19610
|
+
}
|
|
19611
|
+
}
|
|
19612
|
+
catch (err) {
|
|
19613
|
+
if (handler.onError)
|
|
19614
|
+
handler.onError(err);
|
|
19615
|
+
}
|
|
19616
|
+
}
|
|
19617
|
+
if (handler.onEnd)
|
|
19618
|
+
handler.onEnd();
|
|
19619
|
+
break;
|
|
19620
|
+
}
|
|
19621
|
+
buffer += decoder.decode(value, { stream: true });
|
|
19622
|
+
const lines = buffer.split('\n');
|
|
19623
|
+
buffer = (_b = lines.pop()) !== null && _b !== void 0 ? _b : '';
|
|
19624
|
+
for (const line of lines) {
|
|
19625
|
+
if (!line.trim())
|
|
19626
|
+
continue;
|
|
19627
|
+
try {
|
|
19628
|
+
const document = JSON.parse(line);
|
|
19629
|
+
const result = handler.onData(document);
|
|
19630
|
+
if (result instanceof Promise) {
|
|
19631
|
+
await result.catch((err) => { if (handler.onError)
|
|
19632
|
+
handler.onError(err); });
|
|
19633
|
+
}
|
|
19634
|
+
}
|
|
19635
|
+
catch (err) {
|
|
19636
|
+
if (handler.onError)
|
|
19637
|
+
handler.onError(err);
|
|
19638
|
+
}
|
|
19639
|
+
}
|
|
19640
|
+
}
|
|
19641
|
+
}
|
|
19642
|
+
catch (err) {
|
|
19643
|
+
if (handler.onError)
|
|
19644
|
+
handler.onError(err);
|
|
19645
|
+
throw err;
|
|
19646
|
+
}
|
|
19647
|
+
}
|
|
19648
|
+
/**
|
|
19649
|
+
* Node.js implementation: Axios responseType:'stream' + EventEmitter API.
|
|
19650
|
+
* @private
|
|
19651
|
+
*/
|
|
19652
|
+
async _streamNDJSONNode(url, headers, handler, body) {
|
|
19534
19653
|
try {
|
|
19535
19654
|
const config = {
|
|
19536
19655
|
headers,
|
|
@@ -19542,61 +19661,52 @@ class Component extends PlatformBaseClient {
|
|
|
19542
19661
|
return new Promise((resolve, reject) => {
|
|
19543
19662
|
stream.on('data', (chunk) => {
|
|
19544
19663
|
buffer += chunk.toString();
|
|
19545
|
-
// Process complete lines (separated by newlines)
|
|
19546
19664
|
const lines = buffer.split('\n');
|
|
19547
|
-
buffer = lines.pop() || '';
|
|
19665
|
+
buffer = lines.pop() || '';
|
|
19548
19666
|
for (const line of lines) {
|
|
19549
19667
|
if (line.trim()) {
|
|
19550
19668
|
try {
|
|
19551
19669
|
const document = JSON.parse(line);
|
|
19552
19670
|
const result = handler.onData(document);
|
|
19553
|
-
// Support async callbacks
|
|
19554
19671
|
if (result instanceof Promise) {
|
|
19555
19672
|
result.catch((err) => {
|
|
19556
|
-
if (handler.onError)
|
|
19673
|
+
if (handler.onError)
|
|
19557
19674
|
handler.onError(err);
|
|
19558
|
-
}
|
|
19559
19675
|
});
|
|
19560
19676
|
}
|
|
19561
19677
|
}
|
|
19562
19678
|
catch (err) {
|
|
19563
|
-
if (handler.onError)
|
|
19679
|
+
if (handler.onError)
|
|
19564
19680
|
handler.onError(err);
|
|
19565
|
-
}
|
|
19566
19681
|
}
|
|
19567
19682
|
}
|
|
19568
19683
|
}
|
|
19569
19684
|
});
|
|
19570
19685
|
stream.on('end', () => {
|
|
19571
|
-
// Process any remaining data in buffer
|
|
19572
19686
|
if (buffer.trim()) {
|
|
19573
19687
|
try {
|
|
19574
19688
|
const document = JSON.parse(buffer);
|
|
19575
19689
|
handler.onData(document);
|
|
19576
19690
|
}
|
|
19577
19691
|
catch (err) {
|
|
19578
|
-
if (handler.onError)
|
|
19692
|
+
if (handler.onError)
|
|
19579
19693
|
handler.onError(err);
|
|
19580
|
-
}
|
|
19581
19694
|
}
|
|
19582
19695
|
}
|
|
19583
|
-
if (handler.onEnd)
|
|
19696
|
+
if (handler.onEnd)
|
|
19584
19697
|
handler.onEnd();
|
|
19585
|
-
}
|
|
19586
19698
|
resolve();
|
|
19587
19699
|
});
|
|
19588
19700
|
stream.on('error', (err) => {
|
|
19589
|
-
if (handler.onError)
|
|
19701
|
+
if (handler.onError)
|
|
19590
19702
|
handler.onError(err);
|
|
19591
|
-
}
|
|
19592
19703
|
reject(err);
|
|
19593
19704
|
});
|
|
19594
19705
|
});
|
|
19595
19706
|
}
|
|
19596
19707
|
catch (err) {
|
|
19597
|
-
if (handler.onError)
|
|
19708
|
+
if (handler.onError)
|
|
19598
19709
|
handler.onError(err);
|
|
19599
|
-
}
|
|
19600
19710
|
throw err;
|
|
19601
19711
|
}
|
|
19602
19712
|
}
|
|
@@ -19786,6 +19896,9 @@ class ComponentUtils extends PlatformBaseClient {
|
|
|
19786
19896
|
async create(data) {
|
|
19787
19897
|
return await this.client.post("/v3/system/component/create", data);
|
|
19788
19898
|
}
|
|
19899
|
+
async delete(ref) {
|
|
19900
|
+
return await this.client.delete(`/v3/system/component/${ref}`);
|
|
19901
|
+
}
|
|
19789
19902
|
/**
|
|
19790
19903
|
* Setup a component with settings in a single atomic operation.
|
|
19791
19904
|
* This is more comprehensive than create as it handles component creation
|
|
@@ -19800,12 +19913,13 @@ class ComponentUtils extends PlatformBaseClient {
|
|
|
19800
19913
|
}
|
|
19801
19914
|
|
|
19802
19915
|
class Thunder extends PlatformBaseClient {
|
|
19803
|
-
async read(type, filters, flag, options) {
|
|
19916
|
+
async read(type, filters, flag, options, only) {
|
|
19804
19917
|
return await this.client.post("/v3/system/thunder", {
|
|
19805
19918
|
type,
|
|
19806
19919
|
filters,
|
|
19807
19920
|
flag,
|
|
19808
19921
|
options,
|
|
19922
|
+
only,
|
|
19809
19923
|
});
|
|
19810
19924
|
}
|
|
19811
19925
|
async write(type, filters, d, flag) {
|
|
@@ -19819,14 +19933,14 @@ class Thunder extends PlatformBaseClient {
|
|
|
19819
19933
|
async operation(name, filters, data) {
|
|
19820
19934
|
return await this.write(name, filters, data, "Operation");
|
|
19821
19935
|
}
|
|
19822
|
-
async find(name, filters) {
|
|
19823
|
-
return await this.read(name, filters, "Find");
|
|
19936
|
+
async find(name, filters, only) {
|
|
19937
|
+
return await this.read(name, filters, "Find", undefined, only);
|
|
19824
19938
|
}
|
|
19825
|
-
async findOne(name, filters) {
|
|
19826
|
-
return await this.read(name, filters, "FindOne");
|
|
19939
|
+
async findOne(name, filters, only) {
|
|
19940
|
+
return await this.read(name, filters, "FindOne", undefined, only);
|
|
19827
19941
|
}
|
|
19828
|
-
async paginate(name, filters, options) {
|
|
19829
|
-
return await this.read(name, filters, "Paginate", options);
|
|
19942
|
+
async paginate(name, filters, options, only) {
|
|
19943
|
+
return await this.read(name, filters, "Paginate", options, only);
|
|
19830
19944
|
}
|
|
19831
19945
|
async upsert(name, filters, data) {
|
|
19832
19946
|
return await this.write(name, filters, data, "Upsert");
|
|
@@ -20416,6 +20530,7 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
20416
20530
|
const client = axios.create({
|
|
20417
20531
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
|
|
20418
20532
|
timeout: 30000,
|
|
20533
|
+
withCredentials: true,
|
|
20419
20534
|
headers: {
|
|
20420
20535
|
...headers,
|
|
20421
20536
|
},
|
|
@@ -20694,6 +20809,9 @@ class DMS extends IntegrationsBaseClient {
|
|
|
20694
20809
|
async createDocumentComment(payload) {
|
|
20695
20810
|
return this.requestv2('POST', 'documents/document/comment', { data: payload });
|
|
20696
20811
|
}
|
|
20812
|
+
async generateDocument(payload) {
|
|
20813
|
+
return this.requestv2('POST', 'documents/document/generate', { data: payload });
|
|
20814
|
+
}
|
|
20697
20815
|
async fillPdf(data) {
|
|
20698
20816
|
const { input_path, output_path, output_pdf = false, output_type, output_file_name, replace, form_data, forms } = data;
|
|
20699
20817
|
const responseType = output_pdf ? 'arraybuffer' : 'json';
|
package/dist/v0.10/index.esm.js
CHANGED
|
@@ -77,6 +77,7 @@ class PlatformBaseClient extends BaseClient {
|
|
|
77
77
|
const client = axios.create({
|
|
78
78
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
|
|
79
79
|
timeout: 30000,
|
|
80
|
+
withCredentials: true,
|
|
80
81
|
headers: {
|
|
81
82
|
...headers,
|
|
82
83
|
'Content-Type': 'application/json',
|
|
@@ -153,6 +154,13 @@ class Component extends PlatformBaseClient {
|
|
|
153
154
|
dateTo: ctx.dateTo,
|
|
154
155
|
dateField: ctx.dateField,
|
|
155
156
|
};
|
|
157
|
+
if (ctx.only && ctx.only.length > 0) {
|
|
158
|
+
params.only = ctx.only;
|
|
159
|
+
}
|
|
160
|
+
else if (ctx.includeFields && ctx.includeFields.length > 0) {
|
|
161
|
+
// Backward-compatible alias. The API now prefers `only`.
|
|
162
|
+
params.includeFields = ctx.includeFields;
|
|
163
|
+
}
|
|
156
164
|
if (Object.keys(ctx.$adv || []).length > 0) {
|
|
157
165
|
params.$adv = [(_a = ctx.$adv) !== null && _a !== void 0 ? _a : {}];
|
|
158
166
|
}
|
|
@@ -559,11 +567,122 @@ class Component extends PlatformBaseClient {
|
|
|
559
567
|
return await this.client.delete(`/v4/system/component/${this.ref}/${version}/policies/${name}`);
|
|
560
568
|
}
|
|
561
569
|
/**
|
|
562
|
-
* Internal method to handle NDJSON streaming responses
|
|
570
|
+
* Internal method to handle NDJSON streaming responses.
|
|
571
|
+
* Uses native fetch + ReadableStream in browser environments and
|
|
572
|
+
* Axios responseType:'stream' in Node.js environments.
|
|
563
573
|
*
|
|
564
574
|
* @private
|
|
565
575
|
*/
|
|
566
576
|
async _streamNDJSON(url, headers, handler, body) {
|
|
577
|
+
const inBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
578
|
+
if (inBrowser) {
|
|
579
|
+
return this._streamNDJSONBrowser(url, headers, handler, body);
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
return this._streamNDJSONNode(url, headers, handler, body);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Browser implementation: native fetch + ReadableStream (NDJSON).
|
|
587
|
+
* @private
|
|
588
|
+
*/
|
|
589
|
+
async _streamNDJSONBrowser(url, headers, handler, body) {
|
|
590
|
+
var _a, _b;
|
|
591
|
+
try {
|
|
592
|
+
// Derive full URL from the axios instance's baseURL
|
|
593
|
+
const baseURL = ((_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : 'https://lemon.protokol.io').replace(/\/$/, '');
|
|
594
|
+
const fullURL = `${baseURL}${url}`;
|
|
595
|
+
// Collect auth/env headers from the axios instance defaults
|
|
596
|
+
const defaultHeaders = {};
|
|
597
|
+
const axDefaults = this.client.defaults.headers;
|
|
598
|
+
for (const [k, v] of Object.entries(axDefaults)) {
|
|
599
|
+
if (typeof v === 'string')
|
|
600
|
+
defaultHeaders[k] = v;
|
|
601
|
+
}
|
|
602
|
+
if (axDefaults.common && typeof axDefaults.common === 'object') {
|
|
603
|
+
for (const [k, v] of Object.entries(axDefaults.common)) {
|
|
604
|
+
if (typeof v === 'string')
|
|
605
|
+
defaultHeaders[k] = v;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const mergedHeaders = {
|
|
609
|
+
'Content-Type': 'application/json',
|
|
610
|
+
...defaultHeaders,
|
|
611
|
+
...headers,
|
|
612
|
+
};
|
|
613
|
+
const response = await fetch(fullURL, {
|
|
614
|
+
method: 'POST',
|
|
615
|
+
headers: mergedHeaders,
|
|
616
|
+
body: JSON.stringify(body),
|
|
617
|
+
credentials: 'include',
|
|
618
|
+
});
|
|
619
|
+
if (!response.ok) {
|
|
620
|
+
const err = new Error(`Aggregate stream failed: ${response.status} ${response.statusText}`);
|
|
621
|
+
if (handler.onError)
|
|
622
|
+
handler.onError(err);
|
|
623
|
+
throw err;
|
|
624
|
+
}
|
|
625
|
+
if (!response.body) {
|
|
626
|
+
if (handler.onEnd)
|
|
627
|
+
handler.onEnd();
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const reader = response.body.getReader();
|
|
631
|
+
const decoder = new TextDecoder();
|
|
632
|
+
let buffer = '';
|
|
633
|
+
while (true) {
|
|
634
|
+
const { done, value } = await reader.read();
|
|
635
|
+
if (done) {
|
|
636
|
+
if (buffer.trim()) {
|
|
637
|
+
try {
|
|
638
|
+
const document = JSON.parse(buffer);
|
|
639
|
+
const result = handler.onData(document);
|
|
640
|
+
if (result instanceof Promise) {
|
|
641
|
+
await result.catch((err) => { if (handler.onError)
|
|
642
|
+
handler.onError(err); });
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
catch (err) {
|
|
646
|
+
if (handler.onError)
|
|
647
|
+
handler.onError(err);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (handler.onEnd)
|
|
651
|
+
handler.onEnd();
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
buffer += decoder.decode(value, { stream: true });
|
|
655
|
+
const lines = buffer.split('\n');
|
|
656
|
+
buffer = (_b = lines.pop()) !== null && _b !== void 0 ? _b : '';
|
|
657
|
+
for (const line of lines) {
|
|
658
|
+
if (!line.trim())
|
|
659
|
+
continue;
|
|
660
|
+
try {
|
|
661
|
+
const document = JSON.parse(line);
|
|
662
|
+
const result = handler.onData(document);
|
|
663
|
+
if (result instanceof Promise) {
|
|
664
|
+
await result.catch((err) => { if (handler.onError)
|
|
665
|
+
handler.onError(err); });
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
catch (err) {
|
|
669
|
+
if (handler.onError)
|
|
670
|
+
handler.onError(err);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
catch (err) {
|
|
676
|
+
if (handler.onError)
|
|
677
|
+
handler.onError(err);
|
|
678
|
+
throw err;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Node.js implementation: Axios responseType:'stream' + EventEmitter API.
|
|
683
|
+
* @private
|
|
684
|
+
*/
|
|
685
|
+
async _streamNDJSONNode(url, headers, handler, body) {
|
|
567
686
|
try {
|
|
568
687
|
const config = {
|
|
569
688
|
headers,
|
|
@@ -575,61 +694,52 @@ class Component extends PlatformBaseClient {
|
|
|
575
694
|
return new Promise((resolve, reject) => {
|
|
576
695
|
stream.on('data', (chunk) => {
|
|
577
696
|
buffer += chunk.toString();
|
|
578
|
-
// Process complete lines (separated by newlines)
|
|
579
697
|
const lines = buffer.split('\n');
|
|
580
|
-
buffer = lines.pop() || '';
|
|
698
|
+
buffer = lines.pop() || '';
|
|
581
699
|
for (const line of lines) {
|
|
582
700
|
if (line.trim()) {
|
|
583
701
|
try {
|
|
584
702
|
const document = JSON.parse(line);
|
|
585
703
|
const result = handler.onData(document);
|
|
586
|
-
// Support async callbacks
|
|
587
704
|
if (result instanceof Promise) {
|
|
588
705
|
result.catch((err) => {
|
|
589
|
-
if (handler.onError)
|
|
706
|
+
if (handler.onError)
|
|
590
707
|
handler.onError(err);
|
|
591
|
-
}
|
|
592
708
|
});
|
|
593
709
|
}
|
|
594
710
|
}
|
|
595
711
|
catch (err) {
|
|
596
|
-
if (handler.onError)
|
|
712
|
+
if (handler.onError)
|
|
597
713
|
handler.onError(err);
|
|
598
|
-
}
|
|
599
714
|
}
|
|
600
715
|
}
|
|
601
716
|
}
|
|
602
717
|
});
|
|
603
718
|
stream.on('end', () => {
|
|
604
|
-
// Process any remaining data in buffer
|
|
605
719
|
if (buffer.trim()) {
|
|
606
720
|
try {
|
|
607
721
|
const document = JSON.parse(buffer);
|
|
608
722
|
handler.onData(document);
|
|
609
723
|
}
|
|
610
724
|
catch (err) {
|
|
611
|
-
if (handler.onError)
|
|
725
|
+
if (handler.onError)
|
|
612
726
|
handler.onError(err);
|
|
613
|
-
}
|
|
614
727
|
}
|
|
615
728
|
}
|
|
616
|
-
if (handler.onEnd)
|
|
729
|
+
if (handler.onEnd)
|
|
617
730
|
handler.onEnd();
|
|
618
|
-
}
|
|
619
731
|
resolve();
|
|
620
732
|
});
|
|
621
733
|
stream.on('error', (err) => {
|
|
622
|
-
if (handler.onError)
|
|
734
|
+
if (handler.onError)
|
|
623
735
|
handler.onError(err);
|
|
624
|
-
}
|
|
625
736
|
reject(err);
|
|
626
737
|
});
|
|
627
738
|
});
|
|
628
739
|
}
|
|
629
740
|
catch (err) {
|
|
630
|
-
if (handler.onError)
|
|
741
|
+
if (handler.onError)
|
|
631
742
|
handler.onError(err);
|
|
632
|
-
}
|
|
633
743
|
throw err;
|
|
634
744
|
}
|
|
635
745
|
}
|
|
@@ -819,6 +929,9 @@ class ComponentUtils extends PlatformBaseClient {
|
|
|
819
929
|
async create(data) {
|
|
820
930
|
return await this.client.post("/v3/system/component/create", data);
|
|
821
931
|
}
|
|
932
|
+
async delete(ref) {
|
|
933
|
+
return await this.client.delete(`/v3/system/component/${ref}`);
|
|
934
|
+
}
|
|
822
935
|
/**
|
|
823
936
|
* Setup a component with settings in a single atomic operation.
|
|
824
937
|
* This is more comprehensive than create as it handles component creation
|
|
@@ -833,12 +946,13 @@ class ComponentUtils extends PlatformBaseClient {
|
|
|
833
946
|
}
|
|
834
947
|
|
|
835
948
|
class Thunder extends PlatformBaseClient {
|
|
836
|
-
async read(type, filters, flag, options) {
|
|
949
|
+
async read(type, filters, flag, options, only) {
|
|
837
950
|
return await this.client.post("/v3/system/thunder", {
|
|
838
951
|
type,
|
|
839
952
|
filters,
|
|
840
953
|
flag,
|
|
841
954
|
options,
|
|
955
|
+
only,
|
|
842
956
|
});
|
|
843
957
|
}
|
|
844
958
|
async write(type, filters, d, flag) {
|
|
@@ -852,14 +966,14 @@ class Thunder extends PlatformBaseClient {
|
|
|
852
966
|
async operation(name, filters, data) {
|
|
853
967
|
return await this.write(name, filters, data, "Operation");
|
|
854
968
|
}
|
|
855
|
-
async find(name, filters) {
|
|
856
|
-
return await this.read(name, filters, "Find");
|
|
969
|
+
async find(name, filters, only) {
|
|
970
|
+
return await this.read(name, filters, "Find", undefined, only);
|
|
857
971
|
}
|
|
858
|
-
async findOne(name, filters) {
|
|
859
|
-
return await this.read(name, filters, "FindOne");
|
|
972
|
+
async findOne(name, filters, only) {
|
|
973
|
+
return await this.read(name, filters, "FindOne", undefined, only);
|
|
860
974
|
}
|
|
861
|
-
async paginate(name, filters, options) {
|
|
862
|
-
return await this.read(name, filters, "Paginate", options);
|
|
975
|
+
async paginate(name, filters, options, only) {
|
|
976
|
+
return await this.read(name, filters, "Paginate", options, only);
|
|
863
977
|
}
|
|
864
978
|
async upsert(name, filters, data) {
|
|
865
979
|
return await this.write(name, filters, data, "Upsert");
|
|
@@ -1449,6 +1563,7 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
1449
1563
|
const client = axios.create({
|
|
1450
1564
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
|
|
1451
1565
|
timeout: 30000,
|
|
1566
|
+
withCredentials: true,
|
|
1452
1567
|
headers: {
|
|
1453
1568
|
...headers,
|
|
1454
1569
|
},
|
|
@@ -1727,6 +1842,9 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1727
1842
|
async createDocumentComment(payload) {
|
|
1728
1843
|
return this.requestv2('POST', 'documents/document/comment', { data: payload });
|
|
1729
1844
|
}
|
|
1845
|
+
async generateDocument(payload) {
|
|
1846
|
+
return this.requestv2('POST', 'documents/document/generate', { data: payload });
|
|
1847
|
+
}
|
|
1730
1848
|
async fillPdf(data) {
|
|
1731
1849
|
const { input_path, output_path, output_pdf = false, output_type, output_file_name, replace, form_data, forms } = data;
|
|
1732
1850
|
const responseType = output_pdf ? 'arraybuffer' : 'json';
|
|
@@ -9,11 +9,13 @@ type FindParams = {
|
|
|
9
9
|
dateFrom?: string;
|
|
10
10
|
dateTo?: string;
|
|
11
11
|
dateField?: string;
|
|
12
|
+
only?: string[];
|
|
13
|
+
includeFields?: string[];
|
|
12
14
|
$adv?: FindAdvancedParams;
|
|
13
15
|
$aggregate?: FindAggregateParams[];
|
|
14
16
|
};
|
|
15
17
|
type FindOptions = {
|
|
16
|
-
cacheTTL?:
|
|
18
|
+
cacheTTL?: number;
|
|
17
19
|
buildTTL?: number;
|
|
18
20
|
locale?: string;
|
|
19
21
|
unmaskPasswords?: boolean;
|
|
@@ -319,3 +319,23 @@ export type DocumentCommentPayload = {
|
|
|
319
319
|
/** Comment end position */
|
|
320
320
|
to?: number;
|
|
321
321
|
};
|
|
322
|
+
/**
|
|
323
|
+
* Payload for generating (rendering) a document template with data
|
|
324
|
+
*/
|
|
325
|
+
export type DocumentGeneratePayload = {
|
|
326
|
+
/** Path to the document template */
|
|
327
|
+
path: string;
|
|
328
|
+
/** Variant to render (defaults to "default") */
|
|
329
|
+
variant?: string;
|
|
330
|
+
/** Data map passed to the Go text/template engine */
|
|
331
|
+
data: Record<string, any>;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Response from document generation
|
|
335
|
+
*/
|
|
336
|
+
export type DocumentGenerateResponse = {
|
|
337
|
+
/** Whether the generation was successful */
|
|
338
|
+
status: boolean;
|
|
339
|
+
/** Rendered document content */
|
|
340
|
+
content: string;
|
|
341
|
+
};
|
|
@@ -4,4 +4,5 @@ import PlatformBaseClient from "./platformBaseClient";
|
|
|
4
4
|
export default class ComponentUtils extends PlatformBaseClient {
|
|
5
5
|
list(): Promise<AxiosResponse<ComponentListResponse>>;
|
|
6
6
|
create(data: any): Promise<AxiosResponse<any, any>>;
|
|
7
|
+
delete(ref: string): Promise<AxiosResponse<any, any>>;
|
|
7
8
|
}
|
package/dist/v0.9/index.cjs.js
CHANGED
|
@@ -19046,6 +19046,7 @@ class PlatformBaseClient extends BaseClient {
|
|
|
19046
19046
|
const client = axios.create({
|
|
19047
19047
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
|
|
19048
19048
|
timeout: 30000,
|
|
19049
|
+
withCredentials: true,
|
|
19049
19050
|
headers: {
|
|
19050
19051
|
...headers,
|
|
19051
19052
|
'Content-Type': 'application/json',
|
|
@@ -19615,6 +19616,9 @@ class ComponentUtils extends PlatformBaseClient {
|
|
|
19615
19616
|
async create(data) {
|
|
19616
19617
|
return await this.client.post("/v3/system/component/create", data);
|
|
19617
19618
|
}
|
|
19619
|
+
async delete(ref) {
|
|
19620
|
+
return await this.client.delete(`/v3/system/component/${ref}`);
|
|
19621
|
+
}
|
|
19618
19622
|
}
|
|
19619
19623
|
|
|
19620
19624
|
class Thunder extends PlatformBaseClient {
|
|
@@ -20243,6 +20247,7 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
20243
20247
|
const client = axios.create({
|
|
20244
20248
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
|
|
20245
20249
|
timeout: 30000,
|
|
20250
|
+
withCredentials: true,
|
|
20246
20251
|
headers: {
|
|
20247
20252
|
...headers,
|
|
20248
20253
|
}
|
package/dist/v0.9/index.esm.js
CHANGED
|
@@ -77,6 +77,7 @@ class PlatformBaseClient extends BaseClient {
|
|
|
77
77
|
const client = axios.create({
|
|
78
78
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
|
|
79
79
|
timeout: 30000,
|
|
80
|
+
withCredentials: true,
|
|
80
81
|
headers: {
|
|
81
82
|
...headers,
|
|
82
83
|
'Content-Type': 'application/json',
|
|
@@ -646,6 +647,9 @@ class ComponentUtils extends PlatformBaseClient {
|
|
|
646
647
|
async create(data) {
|
|
647
648
|
return await this.client.post("/v3/system/component/create", data);
|
|
648
649
|
}
|
|
650
|
+
async delete(ref) {
|
|
651
|
+
return await this.client.delete(`/v3/system/component/${ref}`);
|
|
652
|
+
}
|
|
649
653
|
}
|
|
650
654
|
|
|
651
655
|
class Thunder extends PlatformBaseClient {
|
|
@@ -1274,6 +1278,7 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
1274
1278
|
const client = axios.create({
|
|
1275
1279
|
baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
|
|
1276
1280
|
timeout: 30000,
|
|
1281
|
+
withCredentials: true,
|
|
1277
1282
|
headers: {
|
|
1278
1283
|
...headers,
|
|
1279
1284
|
}
|