@ptkl/sdk 0.10.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/{index.iife.js → index.0.10.js} +1206 -238
  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 +128 -0
  5. package/dist/v0.10/api/componentUtils.d.ts +7 -0
  6. package/dist/v0.10/api/index.d.ts +22 -0
  7. package/dist/v0.10/api/integrations/dms.d.ts +469 -0
  8. package/dist/v0.10/api/integrations/minimax.d.ts +289 -0
  9. package/dist/v0.10/api/integrations/payments.d.ts +40 -0
  10. package/dist/{types → v0.10}/api/integrations.d.ts +2 -0
  11. package/dist/{types → v0.10}/api/integrationsBaseClient.d.ts +3 -0
  12. package/dist/{types → v0.10}/api/platform.d.ts +2 -2
  13. package/dist/v0.10/apiUser.d.ts +9 -0
  14. package/dist/v0.10/apps.d.ts +8 -0
  15. package/dist/v0.10/baseClient.d.ts +6 -0
  16. package/dist/{types/api → v0.10}/component.d.ts +39 -4
  17. package/dist/v0.10/componentUtils.d.ts +7 -0
  18. package/dist/v0.10/config.d.ts +14 -0
  19. package/dist/v0.10/forge.d.ts +7 -0
  20. package/dist/v0.10/functions.d.ts +23 -0
  21. package/dist/{index.cjs.js → v0.10/index.cjs.js} +1206 -238
  22. package/dist/v0.10/index.d.ts +21 -0
  23. package/dist/{index.esm.js → v0.10/index.esm.js} +1205 -235
  24. package/dist/{types/api → v0.10}/integrations/dms.d.ts +11 -1
  25. package/dist/v0.10/integrations/invoicing.d.ts +6 -0
  26. package/dist/v0.10/integrations/minimax.d.ts +289 -0
  27. package/dist/v0.10/integrations/payments.d.ts +40 -0
  28. package/dist/v0.10/integrations/serbiaUtil.d.ts +10 -0
  29. package/dist/v0.10/integrations/vpfr.d.ts +4 -0
  30. package/dist/v0.10/integrations.d.ts +22 -0
  31. package/dist/v0.10/integrationsBaseClient.d.ts +11 -0
  32. package/dist/v0.10/platform.d.ts +34 -0
  33. package/dist/v0.10/platformBaseClient.d.ts +27 -0
  34. package/dist/v0.10/project.d.ts +146 -0
  35. package/dist/v0.10/ratchet.d.ts +196 -0
  36. package/dist/v0.10/sandbox.d.ts +14 -0
  37. package/dist/v0.10/system.d.ts +4 -0
  38. package/dist/v0.10/thunder.d.ts +13 -0
  39. package/dist/v0.10/types/component.d.ts +110 -0
  40. package/dist/{types → v0.10}/types/integrations.d.ts +114 -1
  41. package/dist/v0.10/users.d.ts +69 -0
  42. package/dist/v0.10/workflow.d.ts +5 -0
  43. package/dist/v0.9/api/apiUser.d.ts +9 -0
  44. package/dist/v0.9/api/apps.d.ts +8 -0
  45. package/dist/v0.9/api/baseClient.d.ts +6 -0
  46. package/dist/v0.9/api/component.d.ts +136 -0
  47. package/dist/v0.9/api/componentUtils.d.ts +7 -0
  48. package/dist/v0.9/api/config.d.ts +14 -0
  49. package/dist/v0.9/api/forge.d.ts +7 -0
  50. package/dist/v0.9/api/functions.d.ts +23 -0
  51. package/dist/v0.9/api/index.d.ts +24 -0
  52. package/dist/v0.9/api/integrations/dms.d.ts +419 -0
  53. package/dist/v0.9/api/integrations/invoicing.d.ts +6 -0
  54. package/dist/v0.9/api/integrations/minimax.d.ts +289 -0
  55. package/dist/v0.9/api/integrations/payments.d.ts +40 -0
  56. package/dist/v0.9/api/integrations/serbiaUtil.d.ts +10 -0
  57. package/dist/v0.9/api/integrations/vpfr.d.ts +4 -0
  58. package/dist/v0.9/api/integrations.d.ts +22 -0
  59. package/dist/v0.9/api/integrationsBaseClient.d.ts +11 -0
  60. package/dist/v0.9/api/platform.d.ts +34 -0
  61. package/dist/v0.9/api/platformBaseClient.d.ts +27 -0
  62. package/dist/v0.9/api/project.d.ts +146 -0
  63. package/dist/v0.9/api/ratchet.d.ts +196 -0
  64. package/dist/v0.9/api/sandbox.d.ts +14 -0
  65. package/dist/v0.9/api/system.d.ts +4 -0
  66. package/dist/v0.9/api/thunder.d.ts +13 -0
  67. package/dist/v0.9/api/users.d.ts +69 -0
  68. package/dist/v0.9/api/workflow.d.ts +5 -0
  69. package/dist/v0.9/apiUser.d.ts +9 -0
  70. package/dist/v0.9/apps.d.ts +8 -0
  71. package/dist/v0.9/baseClient.d.ts +6 -0
  72. package/dist/v0.9/component.d.ts +128 -0
  73. package/dist/v0.9/componentUtils.d.ts +7 -0
  74. package/dist/v0.9/config.d.ts +14 -0
  75. package/dist/v0.9/forge.d.ts +7 -0
  76. package/dist/v0.9/functions.d.ts +23 -0
  77. package/dist/v0.9/index.cjs.js +21811 -0
  78. package/dist/v0.9/index.d.ts +21 -0
  79. package/dist/v0.9/index.esm.js +2820 -0
  80. package/dist/v0.9/integrations/dms.d.ts +469 -0
  81. package/dist/v0.9/integrations/invoicing.d.ts +6 -0
  82. package/dist/v0.9/integrations/minimax.d.ts +289 -0
  83. package/dist/v0.9/integrations/payments.d.ts +40 -0
  84. package/dist/v0.9/integrations/serbiaUtil.d.ts +10 -0
  85. package/dist/v0.9/integrations/vpfr.d.ts +4 -0
  86. package/dist/v0.9/integrations.d.ts +22 -0
  87. package/dist/v0.9/integrationsBaseClient.d.ts +11 -0
  88. package/dist/v0.9/platform.d.ts +34 -0
  89. package/dist/v0.9/platformBaseClient.d.ts +27 -0
  90. package/dist/v0.9/project.d.ts +146 -0
  91. package/dist/v0.9/ratchet.d.ts +196 -0
  92. package/dist/v0.9/sandbox.d.ts +14 -0
  93. package/dist/v0.9/system.d.ts +4 -0
  94. package/dist/v0.9/thunder.d.ts +13 -0
  95. package/dist/v0.9/types/component.d.ts +116 -0
  96. package/dist/v0.9/types/config.d.ts +11 -0
  97. package/dist/v0.9/types/integrations.d.ts +321 -0
  98. package/dist/v0.9/types/project.d.ts +64 -0
  99. package/dist/v0.9/types/ratchet.d.ts +38 -0
  100. package/dist/v0.9/types/users.d.ts +66 -0
  101. package/dist/v0.9/users.d.ts +69 -0
  102. package/dist/v0.9/util/detectEnv.d.ts +4 -0
  103. package/dist/v0.9/workflow.d.ts +5 -0
  104. package/package.json +12 -7
  105. package/dist/monaco.d.ts +0 -887
  106. package/dist/types/api/componentUtils.d.ts +0 -5
  107. package/dist/types/api/index.d.ts +0 -13
  108. package/dist/types/api/integrations/media.d.ts +0 -17
  109. package/dist/types/api/integrations/payments.d.ts +0 -7
  110. package/dist/types/api/roles.d.ts +0 -9
  111. package/dist/types/index.d.ts +0 -29
  112. package/dist/types/types/component.d.ts +0 -50
  113. package/dist/types/types/media.d.ts +0 -103
  114. /package/dist/{types → v0.10}/api/apiUser.d.ts +0 -0
  115. /package/dist/{types → v0.10}/api/apps.d.ts +0 -0
  116. /package/dist/{types → v0.10}/api/baseClient.d.ts +0 -0
  117. /package/dist/{types → v0.10}/api/config.d.ts +0 -0
  118. /package/dist/{types → v0.10}/api/forge.d.ts +0 -0
  119. /package/dist/{types → v0.10}/api/functions.d.ts +0 -0
  120. /package/dist/{types → v0.10}/api/integrations/invoicing.d.ts +0 -0
  121. /package/dist/{types → v0.10}/api/integrations/serbiaUtil.d.ts +0 -0
  122. /package/dist/{types → v0.10}/api/integrations/vpfr.d.ts +0 -0
  123. /package/dist/{types → v0.10}/api/platformBaseClient.d.ts +0 -0
  124. /package/dist/{types → v0.10}/api/project.d.ts +0 -0
  125. /package/dist/{types → v0.10}/api/ratchet.d.ts +0 -0
  126. /package/dist/{types → v0.10}/api/sandbox.d.ts +0 -0
  127. /package/dist/{types → v0.10}/api/system.d.ts +0 -0
  128. /package/dist/{types → v0.10}/api/thunder.d.ts +0 -0
  129. /package/dist/{types → v0.10}/api/users.d.ts +0 -0
  130. /package/dist/{types → v0.10}/api/workflow.d.ts +0 -0
  131. /package/dist/{types → v0.10}/types/config.d.ts +0 -0
  132. /package/dist/{types → v0.10}/types/project.d.ts +0 -0
  133. /package/dist/{types → v0.10}/types/ratchet.d.ts +0 -0
  134. /package/dist/{types → v0.10}/types/users.d.ts +0 -0
  135. /package/dist/{types → v0.10}/util/detectEnv.d.ts +0 -0
@@ -0,0 +1,136 @@
1
+ import { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, StreamHandler, AggregateChainable, ComponentOptions, UpdateManyOptions, CreateManyOptions } from "../types/component";
2
+ import PlatformBaseClient from "./platformBaseClient";
3
+ import { AxiosResponse } from "axios";
4
+ export default class Component extends PlatformBaseClient {
5
+ private ref;
6
+ private version;
7
+ constructor(ref?: string | null, options?: ComponentOptions);
8
+ /**
9
+ * Get the base path for component API calls
10
+ * @private
11
+ */
12
+ private getComponentPath;
13
+ /**
14
+ * Find method to search for models
15
+ *
16
+ * @param {FindParams} filters - The filters to apply to the search
17
+ * @param {FindOptions} opts - The options to apply to the search
18
+ *
19
+ * @returns {Promise<FindResponse>} - The result of the search
20
+ *
21
+ * @example
22
+ * platform.component(name).find({
23
+ * currentPage: 1,
24
+ * perPage: 10,
25
+ * })
26
+ *
27
+ * // advanced search
28
+ * platform.component(name).find({
29
+ * $adv: {
30
+ * name: "John Doe",
31
+ * }
32
+ * )
33
+ **/
34
+ find(filters: FindParams, opts?: FindOptions): Promise<AxiosResponse<FindResponse>>;
35
+ /**
36
+ * FindOne method to search for a single model
37
+ *
38
+ * @param {FindAdvancedParams} filter - The filters to apply to the search
39
+ * @param {FindOptions} opts - The options to apply to the search
40
+ *
41
+ * @returns {Promise<?Model>} - The result of the search
42
+ *
43
+ * @example
44
+ * platform.component(name).findOne({
45
+ * name: "John Doe",
46
+ * })
47
+ **/
48
+ findOne(filter: FindAdvancedParams, opts: FindOptions): Promise<Model | null>;
49
+ /**
50
+ * Get model by uuid
51
+ *
52
+ * @param uuid string - The uuid of the model
53
+ * @returns (Promise<Model>)
54
+ */
55
+ get(uuid: string): Promise<AxiosResponse<Model>>;
56
+ /**
57
+ * Update model by uuid
58
+ *
59
+ * @param uuid string - The uuid of the model
60
+ * @param data
61
+ * @returns
62
+ */
63
+ update(uuid: string, data: Record<string, any>, options: UpdateOptions): Promise<AxiosResponse<any, any>>;
64
+ /**
65
+ * Update many models
66
+ *
67
+ * @param data
68
+ * @param options
69
+ * @returns
70
+ */
71
+ updateMany(data: Record<string, any>[], options: UpdateManyOptions): Promise<AxiosResponse<any, any>>;
72
+ /**
73
+ * Create many models
74
+ *
75
+ * @param data
76
+ * @param options
77
+ * @returns
78
+ */
79
+ createMany(data: Record<string, any>[], options: CreateManyOptions): Promise<AxiosResponse<any, any>>;
80
+ /**
81
+ * Modify models by filters
82
+ *
83
+ * @param data
84
+ * @param options
85
+ * @returns
86
+ */
87
+ modify(filters: Record<string, any>, data: Record<string, any>, options: ModifyOptions): Promise<AxiosResponse<any, any>>;
88
+ /**
89
+ * Concurrent update model by uuid
90
+ *
91
+ * @param uuid string - The uuid of the model
92
+ * @param version number - The version of the model
93
+ * @param data
94
+ * @returns
95
+ */
96
+ concurrentUpdate(uuid: string, version: number, data: Record<string, any>, options: UpdateOptions): Promise<AxiosResponse<any, any>>;
97
+ create(model: Record<string, any>): Promise<AxiosResponse<any, any>>;
98
+ delete(uuid: string): Promise<AxiosResponse<any, any>>;
99
+ /**
100
+ * Execute aggregate pipeline with optional streaming support
101
+ *
102
+ * Returns a chainable object that allows both buffered and streaming modes.
103
+ * Call .onData() to enable streaming mode, or await directly for buffered mode.
104
+ *
105
+ * @param {FindAggregateParams} pipeline - MongoDB aggregation pipeline
106
+ *
107
+ * @returns {AggregateChainable} Chainable object with streaming methods and Promise interface
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Buffered response (default, up to 5K documents)
112
+ * const result = await component.aggregate([{ $match: { status: 'active' } }]);
113
+ * console.log(result.data); // All results at once
114
+ *
115
+ * // Streaming response (up to 25K documents)
116
+ * await component.aggregate([{ $match: { status: 'active' } }])
117
+ * .onData((doc) => console.log('Received:', doc))
118
+ * .onError((err) => console.error('Error:', err))
119
+ * .onEnd(() => console.log('Stream complete'));
120
+ * ```
121
+ */
122
+ aggregate(pipeline: FindAggregateParams): AggregateChainable;
123
+ settings(): Promise<AxiosResponse<any, any>>;
124
+ saveSettings(settings: any, version: string): Promise<AxiosResponse<any, any>>;
125
+ saveTemplatesDist(version: string, sdkVersion: string, engine: string, dist: Record<string, string>): Promise<any>;
126
+ workflow(event: string, input: any): Promise<AxiosResponse<any, any>>;
127
+ function(name: string, input: any): Promise<AxiosResponse<any, any>>;
128
+ revisions(uuid: string): Promise<AxiosResponse<any, any>>;
129
+ /**
130
+ * Internal method to handle NDJSON streaming responses
131
+ *
132
+ * @private
133
+ */
134
+ private _streamNDJSON;
135
+ }
136
+ export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, StreamHandler, AggregateChainable, ComponentOptions, };
@@ -0,0 +1,7 @@
1
+ import { AxiosResponse } from "axios";
2
+ import { ComponentListResponse } from "../types/component";
3
+ import PlatformBaseClient from "./platformBaseClient";
4
+ export default class ComponentUtils extends PlatformBaseClient {
5
+ list(): Promise<AxiosResponse<ComponentListResponse>>;
6
+ create(data: any): Promise<AxiosResponse<any, any>>;
7
+ }
@@ -0,0 +1,14 @@
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ import { AxiosResponse } from "axios";
3
+ import { ConfigUpdateRequest, UserConfig } from '../types/config';
4
+ export default class Config extends PlatformBaseClient {
5
+ /**
6
+ * Get user configuration
7
+ */
8
+ getUserConfig(): Promise<AxiosResponse<UserConfig>>;
9
+ /**
10
+ * Update user configuration
11
+ * @param config Configuration data
12
+ */
13
+ updateUserConfig(config: ConfigUpdateRequest): Promise<AxiosResponse<any>>;
14
+ }
@@ -0,0 +1,7 @@
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Forge extends PlatformBaseClient {
3
+ bundleUpload(buffer: Buffer): Promise<any>;
4
+ getWorkspaceApps(): Promise<any>;
5
+ removeVersion(ref: string, version: string): Promise<any>;
6
+ list(): Promise<any>;
7
+ }
@@ -0,0 +1,23 @@
1
+ import PlatformBaseClient from "./platformBaseClient";
2
+ export default class Functions extends PlatformBaseClient {
3
+ list(): Promise<any>;
4
+ get(ref: string): Promise<any>;
5
+ update(uuid: string, update: any): Promise<any>;
6
+ /**
7
+ * Run platform function
8
+ *
9
+ * @param id - Function ID
10
+ * @param input - Input data
11
+ * @param query - Query parameters
12
+ * @returns - Function result
13
+ *
14
+ * @example
15
+ * const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
16
+ */
17
+ run(id: string, d: {
18
+ input?: Record<string, any>;
19
+ query?: Record<string, string>;
20
+ headers?: Record<string, string>;
21
+ }): Promise<any>;
22
+ generateSignature(ref: string, env: string): Promise<import("axios").AxiosResponse<any, any>>;
23
+ }
@@ -0,0 +1,24 @@
1
+ export { default as Component } from './component';
2
+ export { default as Platform } from './platform';
3
+ export { default as Functions } from './functions';
4
+ export { default as APIUser } from './apiUser';
5
+ export { default as Users } from './users';
6
+ export { default as Apps } from './apps';
7
+ export { default as ComponentUtils } from './componentUtils';
8
+ export { default as Thunder } from './thunder';
9
+ export { default as Ratchet } from './ratchet';
10
+ export { default as Sandbox } from './sandbox';
11
+ export { default as System } from './system';
12
+ export { default as Workflow } from './workflow';
13
+ export { default as Forge } from './forge';
14
+ export { default as Project } from './project';
15
+ export { default as Config } from './config';
16
+ export { default as Integrations } from './integrations';
17
+ export { default as Integration } from './integrations';
18
+ export { default as Payments } from './integrations/payments';
19
+ export { default as Invoicing } from './integrations/invoicing';
20
+ export { default as DMS } from './integrations/dms';
21
+ export { default as SerbiaUtil } from './integrations/serbiaUtil';
22
+ export { default as VPFR } from './integrations/vpfr';
23
+ import Platfrom from './platform';
24
+ export default Platfrom;
@@ -0,0 +1,419 @@
1
+ import IntegrationsBaseClient from "../integrationsBaseClient";
2
+ import { AxiosResponse } from "axios";
3
+ import { PDFFillOptions, DataConversionParams, DataValidationParams, DataInfoParams, DataInfo, DataValidationResult, ConversionOptions, HTML2PDFOptions } 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
+ upload(payload: any): Promise<AxiosResponse<any, any> | undefined>;
87
+ delete(data: any): Promise<AxiosResponse<any, any>>;
88
+ uploadBase64(data: any): Promise<AxiosResponse<any, any>>;
89
+ getMedia(lib: string, key: string, encoding: string): Promise<AxiosResponse<any, any>>;
90
+ download(lib: string, key: string): Promise<AxiosResponse<any, any>>;
91
+ getExifData(lib: string, key: string): Promise<AxiosResponse<any, any>>;
92
+ html2pdf(lib: string, data: HTML2PDFOptions): Promise<AxiosResponse<any, any>>;
93
+ createDir(lib: string, path: string): Promise<AxiosResponse<any, any>>;
94
+ deleteDir(lib: string, path: string): Promise<AxiosResponse<any, any>>;
95
+ dirs(lib: string, data: string): Promise<AxiosResponse<any, any>>;
96
+ fillPdf(lib: string, data: PDFFillOptions): Promise<AxiosResponse<any, any>>;
97
+ /**
98
+ * Convert data between different formats (JSON, CSV, Excel)
99
+ *
100
+ * Supports structured data when converting from JSON format with:
101
+ * - Explicit structure: JSON with `header`, `items`, and `footer` properties
102
+ * - Auto-detection: Mixed JSON arrays with metadata objects and summary rows
103
+ *
104
+ * @param lib - Library reference UUID
105
+ * @param data - Raw data to convert
106
+ * @param params - Conversion parameters including structured data options
107
+ * @returns Promise resolving to converted data
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Convert JSON to CSV
112
+ * const jsonData = [
113
+ * { name: "John Doe", age: 30, email: "john@example.com" },
114
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
115
+ * ];
116
+ *
117
+ * const csvResult = await dms.convertData(libraryRef, jsonData, {
118
+ * from: 'json',
119
+ * to: 'csv'
120
+ * });
121
+ * console.log(csvResult.data); // CSV string
122
+ *
123
+ * // Convert structured JSON with header as comments
124
+ * const structuredData = {
125
+ * header: {
126
+ * content: {
127
+ * report_title: "Monthly Sales Report",
128
+ * generated_by: "Sales System"
129
+ * }
130
+ * },
131
+ * items: [
132
+ * { product: "Widget A", sales: 100 },
133
+ * { product: "Widget B", sales: 150 }
134
+ * ],
135
+ * footer: {
136
+ * content: {
137
+ * total_sales: 250
138
+ * }
139
+ * }
140
+ * };
141
+ *
142
+ * const csvWithComments = await dms.convertData(libraryRef, structuredData, {
143
+ * from: 'json',
144
+ * to: 'csv',
145
+ * header_as_comment: true,
146
+ * separator_rows: 2
147
+ * });
148
+ *
149
+ * // Convert JSON to Excel with custom sheet name
150
+ * const excelResult = await dms.convertData(libraryRef, jsonData, {
151
+ * from: 'json',
152
+ * to: 'excel',
153
+ * sheet_name: 'Customer Data'
154
+ * });
155
+ * // excelResult.data is a Blob
156
+ * ```
157
+ */
158
+ convertData(lib: string, data: any, params: DataConversionParams): Promise<AxiosResponse<any>>;
159
+ /**
160
+ * Get information about data format and structure
161
+ *
162
+ * @param lib - Library reference UUID
163
+ * @param data - Raw data to analyze
164
+ * @param params - Analysis parameters
165
+ * @returns Promise resolving to data information
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * const jsonData = [
170
+ * { name: "John", age: 30, email: "john@example.com" },
171
+ * { name: "Jane", age: 25, email: "jane@example.com" }
172
+ * ];
173
+ *
174
+ * const dataInfo = await dms.getDataInfo(libraryRef, jsonData, {
175
+ * format: 'json'
176
+ * });
177
+ *
178
+ * console.log(dataInfo.data);
179
+ * // Output:
180
+ * // {
181
+ * // format: "json",
182
+ * // size_bytes: 245,
183
+ * // record_count: 2,
184
+ * // field_count: 3,
185
+ * // fields: ["name", "age", "email"],
186
+ * // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
187
+ * // }
188
+ * ```
189
+ */
190
+ getDataInfo(lib: string, data: any, params: DataInfoParams): Promise<AxiosResponse<DataInfo>>;
191
+ /**
192
+ * Validate data format without performing conversion
193
+ *
194
+ * @param lib - Library reference UUID
195
+ * @param data - Raw data to validate
196
+ * @param params - Validation parameters
197
+ * @returns Promise resolving to validation result
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * const jsonData = [{ name: "John", age: 30 }];
202
+ *
203
+ * const validation = await dms.validateData(libraryRef, jsonData, {
204
+ * format: 'json'
205
+ * });
206
+ *
207
+ * console.log(validation.data);
208
+ * // Output:
209
+ * // {
210
+ * // valid: true,
211
+ * // message: "Data is valid JSON format",
212
+ * // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
213
+ * // }
214
+ *
215
+ * // Handle invalid data
216
+ * try {
217
+ * const invalidValidation = await dms.validateData(libraryRef, "invalid json", {
218
+ * format: 'json'
219
+ * });
220
+ * } catch (error) {
221
+ * console.error('Validation failed:', error.response?.data?.message);
222
+ * }
223
+ * ```
224
+ */
225
+ validateData(lib: string, data: any, params: DataValidationParams): Promise<AxiosResponse<DataValidationResult>>;
226
+ /**
227
+ * Convert JSON data to CSV format
228
+ *
229
+ * This method supports both regular JSON arrays and structured data with auto-detection:
230
+ * - Regular arrays are converted directly to CSV
231
+ * - Structured data (with metadata objects) is automatically detected and formatted
232
+ *
233
+ * @param lib - Library reference UUID
234
+ * @param jsonData - JSON data (array of objects or structured data)
235
+ * @returns Promise resolving to CSV string
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * // Regular JSON to CSV
240
+ * const jsonData = [
241
+ * { name: "John Doe", age: 30, email: "john@example.com" },
242
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
243
+ * ];
244
+ *
245
+ * const csvResponse = await dms.jsonToCsv(libraryRef, jsonData);
246
+ * console.log(csvResponse.data);
247
+ * // Output:
248
+ * // name,age,email
249
+ * // John Doe,30,john@example.com
250
+ * // Jane Smith,25,jane@example.com
251
+ *
252
+ * // Structured JSON with auto-detection
253
+ * const structuredData = [
254
+ * { metadata: "EMPLOYEE REPORT\nGenerated: 2025-10-08" },
255
+ * { name: "John Doe", age: 30, position: "Developer" },
256
+ * { name: "Jane Smith", age: 25, position: "Designer" },
257
+ * { name: "Total Employees:", age: null, position: "2 people" }
258
+ * ];
259
+ *
260
+ * const structuredCsv = await dms.jsonToCsv(libraryRef, structuredData);
261
+ * // Auto-detects header, items, and footer sections
262
+ * ```
263
+ */
264
+ jsonToCsv(lib: string, jsonData: any, options?: ConversionOptions): Promise<AxiosResponse<string>>;
265
+ /**
266
+ * Convert JSON data to Excel (.xlsx) format
267
+ *
268
+ * Supports both regular JSON arrays and structured data patterns.
269
+ * Excel files are always generated with .xlsx extension.
270
+ *
271
+ * @param lib - Library reference UUID
272
+ * @param jsonData - JSON data (array of objects or structured data)
273
+ * @param options - Optional conversion options
274
+ * @returns Promise resolving to Excel file as Blob
275
+ *
276
+ * @example
277
+ * ```typescript
278
+ * // Regular JSON to Excel
279
+ * const jsonData = [
280
+ * { name: "John Doe", age: 30, email: "john@example.com" },
281
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
282
+ * ];
283
+ *
284
+ * // Basic conversion
285
+ * const excelResponse = await dms.jsonToExcel(libraryRef, jsonData);
286
+ * const blob = excelResponse.data; // Blob for download
287
+ *
288
+ * // With custom sheet name
289
+ * const excelWithOptions = await dms.jsonToExcel(libraryRef, jsonData, {
290
+ * sheet_name: 'Customer Data'
291
+ * });
292
+ *
293
+ * // Structured data with explicit sections
294
+ * const structuredData = {
295
+ * header: { content: { title: "Monthly Report" } },
296
+ * items: [{ product: "Widget A", sales: 100 }],
297
+ * footer: { content: { total_sales: 100 } }
298
+ * };
299
+ *
300
+ * const structuredExcel = await dms.jsonToExcel(libraryRef, structuredData);
301
+ *
302
+ * // Create download link
303
+ * const url = URL.createObjectURL(structuredExcel.data);
304
+ * const link = document.createElement('a');
305
+ * link.href = url;
306
+ * link.download = 'report.xlsx'; // Always .xlsx extension
307
+ * link.click();
308
+ * ```
309
+ */
310
+ jsonToExcel(lib: string, jsonData: any, options?: ConversionOptions): Promise<AxiosResponse<Blob>>;
311
+ /**
312
+ * Convert CSV data to JSON format
313
+ *
314
+ * @param lib - Library reference UUID
315
+ * @param csvData - CSV data string (with headers in first row)
316
+ * @returns Promise resolving to JSON array
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * const csvString = `name,age,email
321
+ * John Doe,30,john@example.com
322
+ * Jane Smith,25,jane@example.com`;
323
+ *
324
+ * const jsonResponse = await dms.csvToJson(libraryRef, csvString);
325
+ * console.log(jsonResponse.data);
326
+ * // Output:
327
+ * // [
328
+ * // { name: "John Doe", age: "30", email: "john@example.com" },
329
+ * // { name: "Jane Smith", age: "25", email: "jane@example.com" }
330
+ * // ]
331
+ * ```
332
+ */
333
+ csvToJson(lib: string, csvData: string): Promise<AxiosResponse<any[]>>;
334
+ /**
335
+ * Convert CSV data to Excel (.xlsx) format
336
+ *
337
+ * @param lib - Library reference UUID
338
+ * @param csvData - CSV data string (with headers in first row)
339
+ * @param options - Optional conversion options
340
+ * @returns Promise resolving to Excel file as Blob
341
+ *
342
+ * @example
343
+ * ```typescript
344
+ * const csvString = `name,age,email
345
+ * John Doe,30,john@example.com
346
+ * Jane Smith,25,jane@example.com`;
347
+ *
348
+ * const excelResponse = await dms.csvToExcel(libraryRef, csvString, {
349
+ * sheet_name: 'Imported Data'
350
+ * });
351
+ *
352
+ * // Handle the Excel blob
353
+ * const blob = excelResponse.data;
354
+ * const url = URL.createObjectURL(blob);
355
+ * // Use url for download or further processing
356
+ * ```
357
+ */
358
+ csvToExcel(lib: string, csvData: string, options?: ConversionOptions): Promise<AxiosResponse<Blob>>;
359
+ /**
360
+ * Convert Excel (.xlsx) data to JSON format
361
+ *
362
+ * @param lib - Library reference UUID
363
+ * @param excelData - Excel file data as Blob or ArrayBuffer
364
+ * @param options - Optional conversion options
365
+ * @returns Promise resolving to JSON array
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * // From file input
370
+ * const fileInput = document.querySelector('input[type="file"]');
371
+ * const file = fileInput.files[0]; // Excel file
372
+ *
373
+ * const jsonResponse = await dms.excelToJson(libraryRef, file, {
374
+ * sheet_name: 'Sheet1' // optional, defaults to first sheet
375
+ * });
376
+ *
377
+ * console.log(jsonResponse.data);
378
+ * // Output: JSON array with data from Excel sheet
379
+ *
380
+ * // From ArrayBuffer
381
+ * const arrayBuffer = await file.arrayBuffer();
382
+ * const jsonFromBuffer = await dms.excelToJson(libraryRef, arrayBuffer);
383
+ * ```
384
+ */
385
+ excelToJson(lib: string, excelData: Blob | ArrayBuffer, options?: ConversionOptions): Promise<AxiosResponse<any[]>>;
386
+ /**
387
+ * Convert Excel (.xlsx) data to CSV format
388
+ *
389
+ * @param lib - Library reference UUID
390
+ * @param excelData - Excel file data as Blob or ArrayBuffer
391
+ * @param options - Optional conversion options
392
+ * @returns Promise resolving to CSV string
393
+ *
394
+ * @example
395
+ * ```typescript
396
+ * // From file input
397
+ * const fileInput = document.querySelector('input[type="file"]');
398
+ * const file = fileInput.files[0]; // Excel file
399
+ *
400
+ * const csvResponse = await dms.excelToCsv(libraryRef, file, {
401
+ * sheet_name: 'Data' // optional, defaults to first sheet
402
+ * });
403
+ *
404
+ * console.log(csvResponse.data);
405
+ * // Output: CSV string with data from Excel sheet
406
+ *
407
+ * // Save as CSV file
408
+ * const csvBlob = new Blob([csvResponse.data], { type: 'text/csv' });
409
+ * const url = URL.createObjectURL(csvBlob);
410
+ * const link = document.createElement('a');
411
+ * link.href = url;
412
+ * link.download = 'converted.csv';
413
+ * link.click();
414
+ * ```
415
+ */
416
+ excelToCsv(lib: string, excelData: Blob | ArrayBuffer, options?: ConversionOptions): Promise<AxiosResponse<string>>;
417
+ request(method: string, endpoint: string, params?: any): Promise<AxiosResponse<any, any>>;
418
+ requestv1(method: string, endpoint: string, params?: any): Promise<AxiosResponse<any, any>>;
419
+ }
@@ -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
+ }