@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.
- package/dist/{index.iife.js → index.0.10.js} +417 -230
- package/dist/index.0.9.js +2849 -0
- package/dist/package.json +12 -7
- package/dist/v0.10/api/component.d.ts +136 -0
- package/dist/v0.10/api/componentUtils.d.ts +16 -0
- package/dist/v0.10/api/index.d.ts +22 -0
- package/dist/{types → v0.10}/api/integrationsBaseClient.d.ts +3 -0
- package/dist/{types → v0.10}/api/platform.d.ts +2 -2
- package/dist/v0.10/apiUser.d.ts +9 -0
- package/dist/v0.10/apps.d.ts +8 -0
- package/dist/v0.10/baseClient.d.ts +6 -0
- package/dist/{types/api → v0.10}/component.d.ts +39 -4
- package/dist/v0.10/componentUtils.d.ts +7 -0
- package/dist/v0.10/config.d.ts +14 -0
- package/dist/v0.10/forge.d.ts +7 -0
- package/dist/v0.10/functions.d.ts +23 -0
- package/dist/{index.cjs.js → v0.10/index.cjs.js} +417 -230
- package/dist/v0.10/index.d.ts +21 -0
- package/dist/{index.esm.js → v0.10/index.esm.js} +416 -227
- package/dist/v0.10/integrations/dms.d.ts +469 -0
- package/dist/v0.10/integrations/invoicing.d.ts +6 -0
- package/dist/v0.10/integrations/minimax.d.ts +289 -0
- package/dist/v0.10/integrations/payments.d.ts +40 -0
- package/dist/v0.10/integrations/serbiaUtil.d.ts +10 -0
- package/dist/v0.10/integrations/vpfr.d.ts +4 -0
- package/dist/v0.10/integrations.d.ts +22 -0
- package/dist/v0.10/integrationsBaseClient.d.ts +11 -0
- package/dist/v0.10/platform.d.ts +34 -0
- package/dist/v0.10/platformBaseClient.d.ts +27 -0
- package/dist/v0.10/project.d.ts +146 -0
- package/dist/v0.10/ratchet.d.ts +196 -0
- package/dist/v0.10/sandbox.d.ts +14 -0
- package/dist/v0.10/system.d.ts +4 -0
- package/dist/v0.10/thunder.d.ts +13 -0
- package/dist/v0.10/types/component.d.ts +298 -0
- package/dist/v0.10/users.d.ts +69 -0
- package/dist/v0.10/workflow.d.ts +5 -0
- package/dist/v0.9/api/apiUser.d.ts +9 -0
- package/dist/v0.9/api/apps.d.ts +8 -0
- package/dist/v0.9/api/baseClient.d.ts +6 -0
- package/dist/v0.9/api/component.d.ts +136 -0
- package/dist/v0.9/api/config.d.ts +14 -0
- package/dist/v0.9/api/forge.d.ts +7 -0
- package/dist/v0.9/api/functions.d.ts +23 -0
- package/dist/v0.9/api/index.d.ts +24 -0
- package/dist/v0.9/api/integrations/dms.d.ts +419 -0
- package/dist/v0.9/api/integrations/invoicing.d.ts +6 -0
- package/dist/v0.9/api/integrations/minimax.d.ts +289 -0
- package/dist/v0.9/api/integrations/payments.d.ts +40 -0
- package/dist/v0.9/api/integrations/serbiaUtil.d.ts +10 -0
- package/dist/v0.9/api/integrations/vpfr.d.ts +4 -0
- package/dist/v0.9/api/integrations.d.ts +22 -0
- package/dist/v0.9/api/integrationsBaseClient.d.ts +11 -0
- package/dist/v0.9/api/platform.d.ts +34 -0
- package/dist/v0.9/api/platformBaseClient.d.ts +27 -0
- package/dist/v0.9/api/project.d.ts +146 -0
- package/dist/v0.9/api/ratchet.d.ts +196 -0
- package/dist/v0.9/api/sandbox.d.ts +14 -0
- package/dist/v0.9/api/system.d.ts +4 -0
- package/dist/v0.9/api/thunder.d.ts +13 -0
- package/dist/v0.9/api/users.d.ts +69 -0
- package/dist/v0.9/api/workflow.d.ts +5 -0
- package/dist/v0.9/apiUser.d.ts +9 -0
- package/dist/v0.9/apps.d.ts +8 -0
- package/dist/v0.9/baseClient.d.ts +6 -0
- package/dist/v0.9/component.d.ts +128 -0
- package/dist/v0.9/componentUtils.d.ts +7 -0
- package/dist/v0.9/config.d.ts +14 -0
- package/dist/v0.9/forge.d.ts +7 -0
- package/dist/v0.9/functions.d.ts +23 -0
- package/dist/v0.9/index.cjs.js +21811 -0
- package/dist/v0.9/index.d.ts +21 -0
- package/dist/v0.9/index.esm.js +2820 -0
- package/dist/v0.9/integrations/dms.d.ts +469 -0
- package/dist/v0.9/integrations/invoicing.d.ts +6 -0
- package/dist/v0.9/integrations/minimax.d.ts +289 -0
- package/dist/v0.9/integrations/payments.d.ts +40 -0
- package/dist/v0.9/integrations/serbiaUtil.d.ts +10 -0
- package/dist/v0.9/integrations/vpfr.d.ts +4 -0
- package/dist/v0.9/integrations.d.ts +22 -0
- package/dist/v0.9/integrationsBaseClient.d.ts +11 -0
- package/dist/v0.9/platform.d.ts +34 -0
- package/dist/v0.9/platformBaseClient.d.ts +27 -0
- package/dist/v0.9/project.d.ts +146 -0
- package/dist/v0.9/ratchet.d.ts +196 -0
- package/dist/v0.9/sandbox.d.ts +14 -0
- package/dist/v0.9/system.d.ts +4 -0
- package/dist/v0.9/thunder.d.ts +13 -0
- package/dist/{types → v0.9}/types/component.d.ts +34 -2
- package/dist/v0.9/types/config.d.ts +11 -0
- package/dist/v0.9/types/integrations.d.ts +321 -0
- package/dist/v0.9/types/project.d.ts +64 -0
- package/dist/v0.9/types/ratchet.d.ts +38 -0
- package/dist/v0.9/types/users.d.ts +66 -0
- package/dist/v0.9/users.d.ts +69 -0
- package/dist/v0.9/util/detectEnv.d.ts +4 -0
- package/dist/v0.9/workflow.d.ts +5 -0
- package/package.json +12 -7
- package/dist/monaco.d.ts +0 -887
- package/dist/types/api/index.d.ts +0 -13
- package/dist/types/api/integrations/media.d.ts +0 -17
- package/dist/types/api/roles.d.ts +0 -9
- package/dist/types/index.d.ts +0 -29
- package/dist/types/types/media.d.ts +0 -103
- /package/dist/{types → v0.10}/api/apiUser.d.ts +0 -0
- /package/dist/{types → v0.10}/api/apps.d.ts +0 -0
- /package/dist/{types → v0.10}/api/baseClient.d.ts +0 -0
- /package/dist/{types → v0.10}/api/config.d.ts +0 -0
- /package/dist/{types → v0.10}/api/forge.d.ts +0 -0
- /package/dist/{types → v0.10}/api/functions.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/dms.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/invoicing.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/minimax.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/payments.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/serbiaUtil.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations/vpfr.d.ts +0 -0
- /package/dist/{types → v0.10}/api/integrations.d.ts +0 -0
- /package/dist/{types → v0.10}/api/platformBaseClient.d.ts +0 -0
- /package/dist/{types → v0.10}/api/project.d.ts +0 -0
- /package/dist/{types → v0.10}/api/ratchet.d.ts +0 -0
- /package/dist/{types → v0.10}/api/sandbox.d.ts +0 -0
- /package/dist/{types → v0.10}/api/system.d.ts +0 -0
- /package/dist/{types → v0.10}/api/thunder.d.ts +0 -0
- /package/dist/{types → v0.10}/api/users.d.ts +0 -0
- /package/dist/{types → v0.10}/api/workflow.d.ts +0 -0
- /package/dist/{types → v0.10}/types/config.d.ts +0 -0
- /package/dist/{types → v0.10}/types/integrations.d.ts +0 -0
- /package/dist/{types → v0.10}/types/project.d.ts +0 -0
- /package/dist/{types → v0.10}/types/ratchet.d.ts +0 -0
- /package/dist/{types → v0.10}/types/users.d.ts +0 -0
- /package/dist/{types → v0.10}/util/detectEnv.d.ts +0 -0
- /package/dist/{types → v0.9}/api/componentUtils.d.ts +0 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import IntegrationsBaseClient from "../integrationsBaseClient";
|
|
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";
|
|
4
|
+
/**
|
|
5
|
+
* Document Management System (DMS) API client
|
|
6
|
+
*
|
|
7
|
+
* Provides comprehensive document and media management capabilities including:
|
|
8
|
+
* - File upload, download, and management
|
|
9
|
+
* - PDF generation and form filling
|
|
10
|
+
* - Data conversion between JSON, CSV, and Excel formats
|
|
11
|
+
* - Media processing and EXIF data extraction
|
|
12
|
+
*
|
|
13
|
+
* ## Data Conversion Features
|
|
14
|
+
*
|
|
15
|
+
* The DMS class includes powerful data conversion capabilities that allow you to:
|
|
16
|
+
* - Convert between JSON, CSV, and Excel (.xlsx) formats
|
|
17
|
+
* - Handle structured data with header, items, and footer sections
|
|
18
|
+
* - Auto-detect structured patterns in JSON arrays
|
|
19
|
+
* - Validate data format integrity
|
|
20
|
+
* - Analyze data structure and metadata
|
|
21
|
+
* - Handle large datasets with memory-efficient processing
|
|
22
|
+
*
|
|
23
|
+
* ### Supported Formats
|
|
24
|
+
* - **JSON**: Array of objects (recommended for tabular data) or structured objects
|
|
25
|
+
* - **CSV**: Comma-separated values with headers and optional comments
|
|
26
|
+
* - **Excel**: .xlsx format with optional sheet specification
|
|
27
|
+
*
|
|
28
|
+
* ### Structured Data Support
|
|
29
|
+
* When converting from JSON, the API supports:
|
|
30
|
+
*
|
|
31
|
+
* **Explicit Structure**: JSON with dedicated sections
|
|
32
|
+
* ```json
|
|
33
|
+
* {
|
|
34
|
+
* "header": { "content": { "title": "Report" } },
|
|
35
|
+
* "items": [{ "name": "Data" }],
|
|
36
|
+
* "footer": { "content": { "total": 100 } }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* **Auto-Detection**: Mixed arrays with metadata and summary objects
|
|
41
|
+
* ```json
|
|
42
|
+
* [
|
|
43
|
+
* { "metadata": "Header info" },
|
|
44
|
+
* { "name": "John", "age": 30 },
|
|
45
|
+
* { "summary": "Footer info" }
|
|
46
|
+
* ]
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* ### Error Handling
|
|
50
|
+
* All conversion methods may throw errors with code 3003 for conversion failures.
|
|
51
|
+
* Always wrap calls in try-catch blocks for production use.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import { DMS } from 'protokol-sdk';
|
|
56
|
+
*
|
|
57
|
+
* const dms = new DMS({
|
|
58
|
+
* token: 'your-bearer-token',
|
|
59
|
+
* host: 'http://localhost:8086'
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* const libraryRef = 'your-library-uuid';
|
|
63
|
+
*
|
|
64
|
+
* // Convert structured JSON to CSV with comments
|
|
65
|
+
* const structuredData = {
|
|
66
|
+
* header: { content: { title: "Sales Report" } },
|
|
67
|
+
* items: [{ product: "Widget", sales: 100 }],
|
|
68
|
+
* footer: { content: { total: 100 } }
|
|
69
|
+
* };
|
|
70
|
+
*
|
|
71
|
+
* try {
|
|
72
|
+
* const csvResult = await dms.convertData(libraryRef, structuredData, {
|
|
73
|
+
* from: 'json',
|
|
74
|
+
* to: 'csv',
|
|
75
|
+
* header_as_comment: true
|
|
76
|
+
* });
|
|
77
|
+
* console.log(csvResult.data); // CSV with header as comments
|
|
78
|
+
* } catch (error) {
|
|
79
|
+
* console.error('Conversion failed:', error.message);
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export default class DMS extends IntegrationsBaseClient {
|
|
84
|
+
list(data: any): Promise<AxiosResponse<any, any>>;
|
|
85
|
+
libraries(): Promise<AxiosResponse<any, any>>;
|
|
86
|
+
/**
|
|
87
|
+
* Upload files using multipart form data
|
|
88
|
+
*
|
|
89
|
+
* @param payload - Upload configuration with files, directory, and options
|
|
90
|
+
* @returns Upload response from the server
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const result = await dms.upload({
|
|
95
|
+
* files: [file1, file2],
|
|
96
|
+
* uploadDir: '/documents/invoices',
|
|
97
|
+
* public: true,
|
|
98
|
+
* replace: true,
|
|
99
|
+
* metadata: { category: 'finance' }
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
upload(payload: MediaUploadPayload): Promise<AxiosResponse<any, any> | undefined>;
|
|
104
|
+
delete(data: any): Promise<AxiosResponse<any, any>>;
|
|
105
|
+
/**
|
|
106
|
+
* Upload files using base64-encoded content
|
|
107
|
+
*
|
|
108
|
+
* @param data - Upload payload with base64-encoded files
|
|
109
|
+
* @returns Upload response from the server
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const result = await dms.uploadBase64({
|
|
114
|
+
* path: '/documents/reports',
|
|
115
|
+
* is_public: false,
|
|
116
|
+
* replace: true,
|
|
117
|
+
* files: [
|
|
118
|
+
* {
|
|
119
|
+
* name: 'report.pdf',
|
|
120
|
+
* content_type: 'application/pdf',
|
|
121
|
+
* data: 'base64EncodedContent...'
|
|
122
|
+
* }
|
|
123
|
+
* ]
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
uploadBase64(data: MediaUploadBase64Payload): Promise<AxiosResponse<any, any>>;
|
|
128
|
+
getMedia(key: string, encoding: string): Promise<AxiosResponse<any, any>>;
|
|
129
|
+
download(key: string): Promise<AxiosResponse<any, any>>;
|
|
130
|
+
getExifData(key: string): Promise<AxiosResponse<any, any>>;
|
|
131
|
+
html2pdf(data: HTML2PDFOptions): Promise<AxiosResponse<any, any>>;
|
|
132
|
+
pdf2html(data: PDF2HTMLOptions): Promise<AxiosResponse<any, any>>;
|
|
133
|
+
createDir(path: string): Promise<AxiosResponse<any, any>>;
|
|
134
|
+
deleteDir(path: string): Promise<AxiosResponse<any, any>>;
|
|
135
|
+
dirs(data: string): Promise<AxiosResponse<any, any>>;
|
|
136
|
+
createDocument(payload: DocumentCreatePayload): Promise<AxiosResponse<DocumentResponse>>;
|
|
137
|
+
getDocument(path: string): Promise<AxiosResponse<DocumentResponse>>;
|
|
138
|
+
getDocumentRaw(path: string): Promise<AxiosResponse<any, any>>;
|
|
139
|
+
updateDocument(payload: DocumentUpdatePayload): Promise<AxiosResponse<DocumentResponse>>;
|
|
140
|
+
deleteDocument(path: string): Promise<AxiosResponse<any, any>>;
|
|
141
|
+
listDocuments(params?: DocumentListParams): Promise<AxiosResponse<DocumentListResponse>>;
|
|
142
|
+
listDeletedDocuments(params?: DocumentListParams): Promise<AxiosResponse<DocumentListResponse>>;
|
|
143
|
+
restoreDocument(payload: DocumentRestorePayload): Promise<AxiosResponse<DocumentResponse>>;
|
|
144
|
+
createDocumentComment(payload: DocumentCommentPayload): Promise<AxiosResponse<any, any>>;
|
|
145
|
+
fillPdf(data: PDFFillOptions): Promise<AxiosResponse<any, any>>;
|
|
146
|
+
/**
|
|
147
|
+
* Convert data between different formats (JSON, CSV, Excel)
|
|
148
|
+
*
|
|
149
|
+
* Supports structured data when converting from JSON format with:
|
|
150
|
+
* - Explicit structure: JSON with `header`, `items`, and `footer` properties
|
|
151
|
+
* - Auto-detection: Mixed JSON arrays with metadata objects and summary rows
|
|
152
|
+
*
|
|
153
|
+
* @param lib - Library reference UUID
|
|
154
|
+
* @param data - Raw data to convert
|
|
155
|
+
* @param params - Conversion parameters including structured data options
|
|
156
|
+
* @returns Promise resolving to converted data
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* // Convert JSON to CSV
|
|
161
|
+
* const jsonData = [
|
|
162
|
+
* { name: "John Doe", age: 30, email: "john@example.com" },
|
|
163
|
+
* { name: "Jane Smith", age: 25, email: "jane@example.com" }
|
|
164
|
+
* ];
|
|
165
|
+
*
|
|
166
|
+
* const csvResult = await dms.convertData(libraryRef, jsonData, {
|
|
167
|
+
* from: 'json',
|
|
168
|
+
* to: 'csv'
|
|
169
|
+
* });
|
|
170
|
+
* console.log(csvResult.data); // CSV string
|
|
171
|
+
*
|
|
172
|
+
* // Convert structured JSON with header as comments
|
|
173
|
+
* const structuredData = {
|
|
174
|
+
* header: {
|
|
175
|
+
* content: {
|
|
176
|
+
* report_title: "Monthly Sales Report",
|
|
177
|
+
* generated_by: "Sales System"
|
|
178
|
+
* }
|
|
179
|
+
* },
|
|
180
|
+
* items: [
|
|
181
|
+
* { product: "Widget A", sales: 100 },
|
|
182
|
+
* { product: "Widget B", sales: 150 }
|
|
183
|
+
* ],
|
|
184
|
+
* footer: {
|
|
185
|
+
* content: {
|
|
186
|
+
* total_sales: 250
|
|
187
|
+
* }
|
|
188
|
+
* }
|
|
189
|
+
* };
|
|
190
|
+
*
|
|
191
|
+
* const csvWithComments = await dms.convertData(libraryRef, structuredData, {
|
|
192
|
+
* from: 'json',
|
|
193
|
+
* to: 'csv',
|
|
194
|
+
* header_as_comment: true,
|
|
195
|
+
* separator_rows: 2
|
|
196
|
+
* });
|
|
197
|
+
*
|
|
198
|
+
* // Convert JSON to Excel with custom sheet name
|
|
199
|
+
* const excelResult = await dms.convertData(libraryRef, jsonData, {
|
|
200
|
+
* from: 'json',
|
|
201
|
+
* to: 'excel',
|
|
202
|
+
* sheet_name: 'Customer Data'
|
|
203
|
+
* });
|
|
204
|
+
* // excelResult.data is a Blob
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
convertData(data: any, params: DataConversionParams): Promise<AxiosResponse<any>>;
|
|
208
|
+
/**
|
|
209
|
+
* Get information about data format and structure
|
|
210
|
+
*
|
|
211
|
+
* @param lib - Library reference UUID
|
|
212
|
+
* @param data - Raw data to analyze
|
|
213
|
+
* @param params - Analysis parameters
|
|
214
|
+
* @returns Promise resolving to data information
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* const jsonData = [
|
|
219
|
+
* { name: "John", age: 30, email: "john@example.com" },
|
|
220
|
+
* { name: "Jane", age: 25, email: "jane@example.com" }
|
|
221
|
+
* ];
|
|
222
|
+
*
|
|
223
|
+
* const dataInfo = await dms.getDataInfo(libraryRef, jsonData, {
|
|
224
|
+
* format: 'json'
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* console.log(dataInfo.data);
|
|
228
|
+
* // Output:
|
|
229
|
+
* // {
|
|
230
|
+
* // format: "json",
|
|
231
|
+
* // size_bytes: 245,
|
|
232
|
+
* // record_count: 2,
|
|
233
|
+
* // field_count: 3,
|
|
234
|
+
* // fields: ["name", "age", "email"],
|
|
235
|
+
* // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
|
|
236
|
+
* // }
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
getDataInfo(data: any, params: DataInfoParams): Promise<AxiosResponse<DataInfo>>;
|
|
240
|
+
/**
|
|
241
|
+
* Validate data format without performing conversion
|
|
242
|
+
*
|
|
243
|
+
* @param lib - Library reference UUID
|
|
244
|
+
* @param data - Raw data to validate
|
|
245
|
+
* @param params - Validation parameters
|
|
246
|
+
* @returns Promise resolving to validation result
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* const jsonData = [{ name: "John", age: 30 }];
|
|
251
|
+
*
|
|
252
|
+
* const validation = await dms.validateData(libraryRef, jsonData, {
|
|
253
|
+
* format: 'json'
|
|
254
|
+
* });
|
|
255
|
+
*
|
|
256
|
+
* console.log(validation.data);
|
|
257
|
+
* // Output:
|
|
258
|
+
* // {
|
|
259
|
+
* // valid: true,
|
|
260
|
+
* // message: "Data is valid JSON format",
|
|
261
|
+
* // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
|
|
262
|
+
* // }
|
|
263
|
+
*
|
|
264
|
+
* // Handle invalid data
|
|
265
|
+
* try {
|
|
266
|
+
* const invalidValidation = await dms.validateData(libraryRef, "invalid json", {
|
|
267
|
+
* format: 'json'
|
|
268
|
+
* });
|
|
269
|
+
* } catch (error) {
|
|
270
|
+
* console.error('Validation failed:', error.response?.data?.message);
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
validateData(data: any, params: DataValidationParams): Promise<AxiosResponse<DataValidationResult>>;
|
|
275
|
+
/**
|
|
276
|
+
* Convert JSON data to CSV format
|
|
277
|
+
*
|
|
278
|
+
* This method supports both regular JSON arrays and structured data with auto-detection:
|
|
279
|
+
* - Regular arrays are converted directly to CSV
|
|
280
|
+
* - Structured data (with metadata objects) is automatically detected and formatted
|
|
281
|
+
*
|
|
282
|
+
* @param lib - Library reference UUID
|
|
283
|
+
* @param jsonData - JSON data (array of objects or structured data)
|
|
284
|
+
* @returns Promise resolving to CSV string
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* // Regular JSON to CSV
|
|
289
|
+
* const jsonData = [
|
|
290
|
+
* { name: "John Doe", age: 30, email: "john@example.com" },
|
|
291
|
+
* { name: "Jane Smith", age: 25, email: "jane@example.com" }
|
|
292
|
+
* ];
|
|
293
|
+
*
|
|
294
|
+
* const csvResponse = await dms.jsonToCsv(libraryRef, jsonData);
|
|
295
|
+
* console.log(csvResponse.data);
|
|
296
|
+
* // Output:
|
|
297
|
+
* // name,age,email
|
|
298
|
+
* // John Doe,30,john@example.com
|
|
299
|
+
* // Jane Smith,25,jane@example.com
|
|
300
|
+
*
|
|
301
|
+
* // Structured JSON with auto-detection
|
|
302
|
+
* const structuredData = [
|
|
303
|
+
* { metadata: "EMPLOYEE REPORT\nGenerated: 2025-10-08" },
|
|
304
|
+
* { name: "John Doe", age: 30, position: "Developer" },
|
|
305
|
+
* { name: "Jane Smith", age: 25, position: "Designer" },
|
|
306
|
+
* { name: "Total Employees:", age: null, position: "2 people" }
|
|
307
|
+
* ];
|
|
308
|
+
*
|
|
309
|
+
* const structuredCsv = await dms.jsonToCsv(libraryRef, structuredData);
|
|
310
|
+
* // Auto-detects header, items, and footer sections
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
jsonToCsv(jsonData: any, options?: ConversionOptions): Promise<AxiosResponse<string>>;
|
|
314
|
+
/**
|
|
315
|
+
* Convert JSON data to Excel (.xlsx) format
|
|
316
|
+
*
|
|
317
|
+
* Supports both regular JSON arrays and structured data patterns.
|
|
318
|
+
* Excel files are always generated with .xlsx extension.
|
|
319
|
+
*
|
|
320
|
+
* @param lib - Library reference UUID
|
|
321
|
+
* @param jsonData - JSON data (array of objects or structured data)
|
|
322
|
+
* @param options - Optional conversion options
|
|
323
|
+
* @returns Promise resolving to Excel file as Blob
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* // Regular JSON to Excel
|
|
328
|
+
* const jsonData = [
|
|
329
|
+
* { name: "John Doe", age: 30, email: "john@example.com" },
|
|
330
|
+
* { name: "Jane Smith", age: 25, email: "jane@example.com" }
|
|
331
|
+
* ];
|
|
332
|
+
*
|
|
333
|
+
* // Basic conversion
|
|
334
|
+
* const excelResponse = await dms.jsonToExcel(libraryRef, jsonData);
|
|
335
|
+
* const blob = excelResponse.data; // Blob for download
|
|
336
|
+
*
|
|
337
|
+
* // With custom sheet name
|
|
338
|
+
* const excelWithOptions = await dms.jsonToExcel(libraryRef, jsonData, {
|
|
339
|
+
* sheet_name: 'Customer Data'
|
|
340
|
+
* });
|
|
341
|
+
*
|
|
342
|
+
* // Structured data with explicit sections
|
|
343
|
+
* const structuredData = {
|
|
344
|
+
* header: { content: { title: "Monthly Report" } },
|
|
345
|
+
* items: [{ product: "Widget A", sales: 100 }],
|
|
346
|
+
* footer: { content: { total_sales: 100 } }
|
|
347
|
+
* };
|
|
348
|
+
*
|
|
349
|
+
* const structuredExcel = await dms.jsonToExcel(libraryRef, structuredData);
|
|
350
|
+
*
|
|
351
|
+
* // Create download link
|
|
352
|
+
* const url = URL.createObjectURL(structuredExcel.data);
|
|
353
|
+
* const link = document.createElement('a');
|
|
354
|
+
* link.href = url;
|
|
355
|
+
* link.download = 'report.xlsx'; // Always .xlsx extension
|
|
356
|
+
* link.click();
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
jsonToExcel(jsonData: any, options?: ConversionOptions): Promise<AxiosResponse<Blob>>;
|
|
360
|
+
/**
|
|
361
|
+
* Convert CSV data to JSON format
|
|
362
|
+
*
|
|
363
|
+
* @param lib - Library reference UUID
|
|
364
|
+
* @param csvData - CSV data string (with headers in first row)
|
|
365
|
+
* @returns Promise resolving to JSON array
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```typescript
|
|
369
|
+
* const csvString = `name,age,email
|
|
370
|
+
* John Doe,30,john@example.com
|
|
371
|
+
* Jane Smith,25,jane@example.com`;
|
|
372
|
+
*
|
|
373
|
+
* const jsonResponse = await dms.csvToJson(libraryRef, csvString);
|
|
374
|
+
* console.log(jsonResponse.data);
|
|
375
|
+
* // Output:
|
|
376
|
+
* // [
|
|
377
|
+
* // { name: "John Doe", age: "30", email: "john@example.com" },
|
|
378
|
+
* // { name: "Jane Smith", age: "25", email: "jane@example.com" }
|
|
379
|
+
* // ]
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
csvToJson(csvData: string): Promise<AxiosResponse<any[]>>;
|
|
383
|
+
/**
|
|
384
|
+
* Convert CSV data to Excel (.xlsx) format
|
|
385
|
+
*
|
|
386
|
+
* @param lib - Library reference UUID
|
|
387
|
+
* @param csvData - CSV data string (with headers in first row)
|
|
388
|
+
* @param options - Optional conversion options
|
|
389
|
+
* @returns Promise resolving to Excel file as Blob
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const csvString = `name,age,email
|
|
394
|
+
* John Doe,30,john@example.com
|
|
395
|
+
* Jane Smith,25,jane@example.com`;
|
|
396
|
+
*
|
|
397
|
+
* const excelResponse = await dms.csvToExcel(libraryRef, csvString, {
|
|
398
|
+
* sheet_name: 'Imported Data'
|
|
399
|
+
* });
|
|
400
|
+
*
|
|
401
|
+
* // Handle the Excel blob
|
|
402
|
+
* const blob = excelResponse.data;
|
|
403
|
+
* const url = URL.createObjectURL(blob);
|
|
404
|
+
* // Use url for download or further processing
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
csvToExcel(csvData: string, options?: ConversionOptions): Promise<AxiosResponse<Blob>>;
|
|
408
|
+
/**
|
|
409
|
+
* Convert Excel (.xlsx) data to JSON format
|
|
410
|
+
*
|
|
411
|
+
* @param lib - Library reference UUID
|
|
412
|
+
* @param excelData - Excel file data as Blob or ArrayBuffer
|
|
413
|
+
* @param options - Optional conversion options
|
|
414
|
+
* @returns Promise resolving to JSON array
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```typescript
|
|
418
|
+
* // From file input
|
|
419
|
+
* const fileInput = document.querySelector('input[type="file"]');
|
|
420
|
+
* const file = fileInput.files[0]; // Excel file
|
|
421
|
+
*
|
|
422
|
+
* const jsonResponse = await dms.excelToJson(libraryRef, file, {
|
|
423
|
+
* sheet_name: 'Sheet1' // optional, defaults to first sheet
|
|
424
|
+
* });
|
|
425
|
+
*
|
|
426
|
+
* console.log(jsonResponse.data);
|
|
427
|
+
* // Output: JSON array with data from Excel sheet
|
|
428
|
+
*
|
|
429
|
+
* // From ArrayBuffer
|
|
430
|
+
* const arrayBuffer = await file.arrayBuffer();
|
|
431
|
+
* const jsonFromBuffer = await dms.excelToJson(libraryRef, arrayBuffer);
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
excelToJson(excelData: Blob | ArrayBuffer, options?: ConversionOptions): Promise<AxiosResponse<any[]>>;
|
|
435
|
+
/**
|
|
436
|
+
* Convert Excel (.xlsx) data to CSV format
|
|
437
|
+
*
|
|
438
|
+
* @param lib - Library reference UUID
|
|
439
|
+
* @param excelData - Excel file data as Blob or ArrayBuffer
|
|
440
|
+
* @param options - Optional conversion options
|
|
441
|
+
* @returns Promise resolving to CSV string
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```typescript
|
|
445
|
+
* // From file input
|
|
446
|
+
* const fileInput = document.querySelector('input[type="file"]');
|
|
447
|
+
* const file = fileInput.files[0]; // Excel file
|
|
448
|
+
*
|
|
449
|
+
* const csvResponse = await dms.excelToCsv(libraryRef, file, {
|
|
450
|
+
* sheet_name: 'Data' // optional, defaults to first sheet
|
|
451
|
+
* });
|
|
452
|
+
*
|
|
453
|
+
* console.log(csvResponse.data);
|
|
454
|
+
* // Output: CSV string with data from Excel sheet
|
|
455
|
+
*
|
|
456
|
+
* // Save as CSV file
|
|
457
|
+
* const csvBlob = new Blob([csvResponse.data], { type: 'text/csv' });
|
|
458
|
+
* const url = URL.createObjectURL(csvBlob);
|
|
459
|
+
* const link = document.createElement('a');
|
|
460
|
+
* link.href = url;
|
|
461
|
+
* link.download = 'converted.csv';
|
|
462
|
+
* link.click();
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
excelToCsv(excelData: Blob | ArrayBuffer, options?: ConversionOptions): Promise<AxiosResponse<string>>;
|
|
466
|
+
request(method: string, endpoint: string, params?: any): Promise<AxiosResponse<any, any>>;
|
|
467
|
+
requestv2(method: string, endpoint: string, params?: any): Promise<AxiosResponse<any, any>>;
|
|
468
|
+
requestv1(method: string, endpoint: string, params?: any): Promise<AxiosResponse<any, any>>;
|
|
469
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import PlatformBaseClient from "../platformBaseClient";
|
|
2
|
+
export default class Invoicing extends PlatformBaseClient {
|
|
3
|
+
getSalesInvoices(provider: string, page: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
|
+
acceptPurchaseInvoice(provider: string, id: string, comment: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
5
|
+
request(method: string, endpoint: string, params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
+
}
|