@ptkl/sdk 0.9.8 → 0.9.10

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.esm.js CHANGED
@@ -34,24 +34,23 @@ const isBrowser = typeof window !== "undefined" &&
34
34
  */
35
35
  class PlatformBaseClient extends BaseClient {
36
36
  constructor(options) {
37
- var _a, _b;
37
+ var _a, _b, _c;
38
38
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
39
39
  let headers = {};
40
40
  var project_uuid = null;
41
41
  if (isBrowser) {
42
- console.log("DEBUG", sessionStorage.getItem('protokol_context'));
42
+ console.log("PlatformBaseClient: running in browser context");
43
43
  if (sessionStorage.getItem('protokol_context') == "forge") {
44
44
  headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
45
45
  }
46
46
  else {
47
- // this potentially means that it is running as dev server in local
48
- headers['X-Project-Env'] = "dev";
47
+ headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
49
48
  }
50
49
  }
51
50
  if (typeof window !== "undefined") {
52
51
  // @ts-ignore
53
52
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
54
- host = (_b = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _b !== void 0 ? _b : host;
53
+ host = (_c = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _c !== void 0 ? _c : host;
55
54
  // @ts-ignore
56
55
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
57
56
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
@@ -212,11 +211,7 @@ class Apps extends PlatformBaseClient {
212
211
  }
213
212
  async upload(formData) {
214
213
  return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
215
- timeout: 60000,
216
- headers: {
217
- // set form data headers
218
- 'Content-Type': 'multipart/form-data'
219
- }
214
+ timeout: 60000
220
215
  });
221
216
  }
222
217
  }
@@ -517,6 +512,9 @@ class Workflow extends PlatformBaseClient {
517
512
  async trigger(id, event, data) {
518
513
  return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
519
514
  }
515
+ async publish(event, data) {
516
+ return await this.client.post(`/v1/project/workflow/workflow/event/${event}`, data);
517
+ }
520
518
  }
521
519
 
522
520
  class Forge extends PlatformBaseClient {
@@ -616,7 +614,7 @@ class Invoicing extends PlatformBaseClient {
616
614
 
617
615
  class IntegrationsBaseClient extends BaseClient {
618
616
  constructor(options) {
619
- var _a, _b;
617
+ var _a, _b, _c;
620
618
  let { env = null, token, host, } = options !== null && options !== void 0 ? options : {};
621
619
  let headers = {};
622
620
  var project_uuid = null;
@@ -625,14 +623,13 @@ class IntegrationsBaseClient extends BaseClient {
625
623
  headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
626
624
  }
627
625
  else {
628
- // this potentially means that it is running as dev server in local
629
- headers['X-Project-Env'] = "dev";
626
+ headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
630
627
  }
631
628
  }
632
629
  if (typeof window !== "undefined") {
633
630
  // @ts-ignore
634
631
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
635
- host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== void 0 ? _b : host;
632
+ host = (_c = __global_env__.INTEGRATION_API) !== null && _c !== void 0 ? _c : host;
636
633
  // @ts-ignore
637
634
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
638
635
  // @ts-ignore
@@ -660,6 +657,85 @@ class IntegrationsBaseClient extends BaseClient {
660
657
  }
661
658
  }
662
659
 
660
+ /**
661
+ * Document Management System (DMS) API client
662
+ *
663
+ * Provides comprehensive document and media management capabilities including:
664
+ * - File upload, download, and management
665
+ * - PDF generation and form filling
666
+ * - Data conversion between JSON, CSV, and Excel formats
667
+ * - Media processing and EXIF data extraction
668
+ *
669
+ * ## Data Conversion Features
670
+ *
671
+ * The DMS class includes powerful data conversion capabilities that allow you to:
672
+ * - Convert between JSON, CSV, and Excel (.xlsx) formats
673
+ * - Handle structured data with header, items, and footer sections
674
+ * - Auto-detect structured patterns in JSON arrays
675
+ * - Validate data format integrity
676
+ * - Analyze data structure and metadata
677
+ * - Handle large datasets with memory-efficient processing
678
+ *
679
+ * ### Supported Formats
680
+ * - **JSON**: Array of objects (recommended for tabular data) or structured objects
681
+ * - **CSV**: Comma-separated values with headers and optional comments
682
+ * - **Excel**: .xlsx format with optional sheet specification
683
+ *
684
+ * ### Structured Data Support
685
+ * When converting from JSON, the API supports:
686
+ *
687
+ * **Explicit Structure**: JSON with dedicated sections
688
+ * ```json
689
+ * {
690
+ * "header": { "content": { "title": "Report" } },
691
+ * "items": [{ "name": "Data" }],
692
+ * "footer": { "content": { "total": 100 } }
693
+ * }
694
+ * ```
695
+ *
696
+ * **Auto-Detection**: Mixed arrays with metadata and summary objects
697
+ * ```json
698
+ * [
699
+ * { "metadata": "Header info" },
700
+ * { "name": "John", "age": 30 },
701
+ * { "summary": "Footer info" }
702
+ * ]
703
+ * ```
704
+ *
705
+ * ### Error Handling
706
+ * All conversion methods may throw errors with code 3003 for conversion failures.
707
+ * Always wrap calls in try-catch blocks for production use.
708
+ *
709
+ * @example
710
+ * ```typescript
711
+ * import { DMS } from 'protokol-sdk';
712
+ *
713
+ * const dms = new DMS({
714
+ * token: 'your-bearer-token',
715
+ * host: 'http://localhost:8086'
716
+ * });
717
+ *
718
+ * const libraryRef = 'your-library-uuid';
719
+ *
720
+ * // Convert structured JSON to CSV with comments
721
+ * const structuredData = {
722
+ * header: { content: { title: "Sales Report" } },
723
+ * items: [{ product: "Widget", sales: 100 }],
724
+ * footer: { content: { total: 100 } }
725
+ * };
726
+ *
727
+ * try {
728
+ * const csvResult = await dms.convertData(libraryRef, structuredData, {
729
+ * from: 'json',
730
+ * to: 'csv',
731
+ * header_as_comment: true
732
+ * });
733
+ * console.log(csvResult.data); // CSV with header as comments
734
+ * } catch (error) {
735
+ * console.error('Conversion failed:', error.message);
736
+ * }
737
+ * ```
738
+ */
663
739
  class DMS extends IntegrationsBaseClient {
664
740
  async list(data) {
665
741
  return this.request('POST', 'media/list', { data });
@@ -756,18 +832,16 @@ class DMS extends IntegrationsBaseClient {
756
832
  return await this.request("POST", `media/library/${lib}/dirs`, { data });
757
833
  }
758
834
  async fillPdf(lib, data) {
759
- const { input_html, input_path, output_path, output_pdf = false, output_type, output_file_name, data: templateData, form_data, forms } = data;
835
+ const { input_path, output_path, output_pdf = false, output_type, output_file_name, form_data, forms } = data;
760
836
  const responseType = output_pdf ? 'arraybuffer' : 'json';
761
837
  const contentType = output_pdf ? 'application/pdf' : 'application/json';
762
838
  return this.request('POST', `media/library/${lib}/pdf/fill`, {
763
839
  data: {
764
- input_html,
765
840
  input_path,
766
841
  output_path,
767
842
  output_pdf,
768
843
  output_type,
769
844
  output_file_name,
770
- data: templateData,
771
845
  form_data,
772
846
  forms
773
847
  },
@@ -777,10 +851,456 @@ class DMS extends IntegrationsBaseClient {
777
851
  responseType
778
852
  });
779
853
  }
854
+ // ===================================================================
855
+ // Data Converter Methods
856
+ // ===================================================================
857
+ //
858
+ // The following methods provide comprehensive data conversion capabilities
859
+ // between JSON, CSV, and Excel formats, along with validation and analysis tools.
860
+ // All methods require a valid library reference UUID and return AxiosResponse objects.
861
+ //
862
+ /**
863
+ * Convert data between different formats (JSON, CSV, Excel)
864
+ *
865
+ * Supports structured data when converting from JSON format with:
866
+ * - Explicit structure: JSON with `header`, `items`, and `footer` properties
867
+ * - Auto-detection: Mixed JSON arrays with metadata objects and summary rows
868
+ *
869
+ * @param lib - Library reference UUID
870
+ * @param data - Raw data to convert
871
+ * @param params - Conversion parameters including structured data options
872
+ * @returns Promise resolving to converted data
873
+ *
874
+ * @example
875
+ * ```typescript
876
+ * // Convert JSON to CSV
877
+ * const jsonData = [
878
+ * { name: "John Doe", age: 30, email: "john@example.com" },
879
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
880
+ * ];
881
+ *
882
+ * const csvResult = await dms.convertData(libraryRef, jsonData, {
883
+ * from: 'json',
884
+ * to: 'csv'
885
+ * });
886
+ * console.log(csvResult.data); // CSV string
887
+ *
888
+ * // Convert structured JSON with header as comments
889
+ * const structuredData = {
890
+ * header: {
891
+ * content: {
892
+ * report_title: "Monthly Sales Report",
893
+ * generated_by: "Sales System"
894
+ * }
895
+ * },
896
+ * items: [
897
+ * { product: "Widget A", sales: 100 },
898
+ * { product: "Widget B", sales: 150 }
899
+ * ],
900
+ * footer: {
901
+ * content: {
902
+ * total_sales: 250
903
+ * }
904
+ * }
905
+ * };
906
+ *
907
+ * const csvWithComments = await dms.convertData(libraryRef, structuredData, {
908
+ * from: 'json',
909
+ * to: 'csv',
910
+ * header_as_comment: true,
911
+ * separator_rows: 2
912
+ * });
913
+ *
914
+ * // Convert JSON to Excel with custom sheet name
915
+ * const excelResult = await dms.convertData(libraryRef, jsonData, {
916
+ * from: 'json',
917
+ * to: 'excel',
918
+ * sheet_name: 'Customer Data'
919
+ * });
920
+ * // excelResult.data is a Blob
921
+ * ```
922
+ */
923
+ async convertData(lib, data, params) {
924
+ const { from, to, sheet_name, include_header, include_footer, header_as_comment, footer_as_comment, separator_rows } = params;
925
+ const queryParams = { from, to };
926
+ // Add optional parameters if provided
927
+ if (sheet_name)
928
+ queryParams.sheet_name = sheet_name;
929
+ if (include_header !== undefined)
930
+ queryParams.include_header = include_header;
931
+ if (include_footer !== undefined)
932
+ queryParams.include_footer = include_footer;
933
+ if (header_as_comment !== undefined)
934
+ queryParams.header_as_comment = header_as_comment;
935
+ if (footer_as_comment !== undefined)
936
+ queryParams.footer_as_comment = footer_as_comment;
937
+ if (separator_rows !== undefined)
938
+ queryParams.separator_rows = separator_rows;
939
+ // Determine content type based on target format
940
+ let responseType = 'text';
941
+ if (to === 'json') {
942
+ responseType = 'json';
943
+ }
944
+ else if (to === 'excel' || to === 'xlsx') {
945
+ responseType = 'blob';
946
+ }
947
+ return this.request('POST', `media/library/${lib}/convert/data`, {
948
+ data,
949
+ params: queryParams,
950
+ responseType,
951
+ headers: {
952
+ 'Content-Type': 'application/json'
953
+ }
954
+ });
955
+ }
956
+ /**
957
+ * Get information about data format and structure
958
+ *
959
+ * @param lib - Library reference UUID
960
+ * @param data - Raw data to analyze
961
+ * @param params - Analysis parameters
962
+ * @returns Promise resolving to data information
963
+ *
964
+ * @example
965
+ * ```typescript
966
+ * const jsonData = [
967
+ * { name: "John", age: 30, email: "john@example.com" },
968
+ * { name: "Jane", age: 25, email: "jane@example.com" }
969
+ * ];
970
+ *
971
+ * const dataInfo = await dms.getDataInfo(libraryRef, jsonData, {
972
+ * format: 'json'
973
+ * });
974
+ *
975
+ * console.log(dataInfo.data);
976
+ * // Output:
977
+ * // {
978
+ * // format: "json",
979
+ * // size_bytes: 245,
980
+ * // record_count: 2,
981
+ * // field_count: 3,
982
+ * // fields: ["name", "age", "email"],
983
+ * // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
984
+ * // }
985
+ * ```
986
+ */
987
+ async getDataInfo(lib, data, params) {
988
+ const { format } = params;
989
+ return this.request('POST', `media/library/${lib}/convert/info`, {
990
+ data,
991
+ params: { format },
992
+ headers: {
993
+ 'Content-Type': 'application/json'
994
+ }
995
+ });
996
+ }
997
+ /**
998
+ * Validate data format without performing conversion
999
+ *
1000
+ * @param lib - Library reference UUID
1001
+ * @param data - Raw data to validate
1002
+ * @param params - Validation parameters
1003
+ * @returns Promise resolving to validation result
1004
+ *
1005
+ * @example
1006
+ * ```typescript
1007
+ * const jsonData = [{ name: "John", age: 30 }];
1008
+ *
1009
+ * const validation = await dms.validateData(libraryRef, jsonData, {
1010
+ * format: 'json'
1011
+ * });
1012
+ *
1013
+ * console.log(validation.data);
1014
+ * // Output:
1015
+ * // {
1016
+ * // valid: true,
1017
+ * // message: "Data is valid JSON format",
1018
+ * // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
1019
+ * // }
1020
+ *
1021
+ * // Handle invalid data
1022
+ * try {
1023
+ * const invalidValidation = await dms.validateData(libraryRef, "invalid json", {
1024
+ * format: 'json'
1025
+ * });
1026
+ * } catch (error) {
1027
+ * console.error('Validation failed:', error.response?.data?.message);
1028
+ * }
1029
+ * ```
1030
+ */
1031
+ async validateData(lib, data, params) {
1032
+ const { format } = params;
1033
+ return this.request('POST', `media/library/${lib}/convert/validate`, {
1034
+ data,
1035
+ params: { format },
1036
+ headers: {
1037
+ 'Content-Type': 'application/json'
1038
+ }
1039
+ });
1040
+ }
1041
+ /**
1042
+ * Convert JSON data to CSV format
1043
+ *
1044
+ * This method supports both regular JSON arrays and structured data with auto-detection:
1045
+ * - Regular arrays are converted directly to CSV
1046
+ * - Structured data (with metadata objects) is automatically detected and formatted
1047
+ *
1048
+ * @param lib - Library reference UUID
1049
+ * @param jsonData - JSON data (array of objects or structured data)
1050
+ * @returns Promise resolving to CSV string
1051
+ *
1052
+ * @example
1053
+ * ```typescript
1054
+ * // Regular JSON to CSV
1055
+ * const jsonData = [
1056
+ * { name: "John Doe", age: 30, email: "john@example.com" },
1057
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
1058
+ * ];
1059
+ *
1060
+ * const csvResponse = await dms.jsonToCsv(libraryRef, jsonData);
1061
+ * console.log(csvResponse.data);
1062
+ * // Output:
1063
+ * // name,age,email
1064
+ * // John Doe,30,john@example.com
1065
+ * // Jane Smith,25,jane@example.com
1066
+ *
1067
+ * // Structured JSON with auto-detection
1068
+ * const structuredData = [
1069
+ * { metadata: "EMPLOYEE REPORT\nGenerated: 2025-10-08" },
1070
+ * { name: "John Doe", age: 30, position: "Developer" },
1071
+ * { name: "Jane Smith", age: 25, position: "Designer" },
1072
+ * { name: "Total Employees:", age: null, position: "2 people" }
1073
+ * ];
1074
+ *
1075
+ * const structuredCsv = await dms.jsonToCsv(libraryRef, structuredData);
1076
+ * // Auto-detects header, items, and footer sections
1077
+ * ```
1078
+ */
1079
+ async jsonToCsv(lib, jsonData) {
1080
+ return this.request('POST', `media/library/${lib}/convert/json-to-csv`, {
1081
+ data: jsonData,
1082
+ responseType: 'text',
1083
+ headers: {
1084
+ 'Content-Type': 'application/json'
1085
+ }
1086
+ });
1087
+ }
1088
+ /**
1089
+ * Convert JSON data to Excel (.xlsx) format
1090
+ *
1091
+ * Supports both regular JSON arrays and structured data patterns.
1092
+ * Excel files are always generated with .xlsx extension.
1093
+ *
1094
+ * @param lib - Library reference UUID
1095
+ * @param jsonData - JSON data (array of objects or structured data)
1096
+ * @param options - Optional conversion options
1097
+ * @returns Promise resolving to Excel file as Blob
1098
+ *
1099
+ * @example
1100
+ * ```typescript
1101
+ * // Regular JSON to Excel
1102
+ * const jsonData = [
1103
+ * { name: "John Doe", age: 30, email: "john@example.com" },
1104
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
1105
+ * ];
1106
+ *
1107
+ * // Basic conversion
1108
+ * const excelResponse = await dms.jsonToExcel(libraryRef, jsonData);
1109
+ * const blob = excelResponse.data; // Blob for download
1110
+ *
1111
+ * // With custom sheet name
1112
+ * const excelWithOptions = await dms.jsonToExcel(libraryRef, jsonData, {
1113
+ * sheet_name: 'Customer Data'
1114
+ * });
1115
+ *
1116
+ * // Structured data with explicit sections
1117
+ * const structuredData = {
1118
+ * header: { content: { title: "Monthly Report" } },
1119
+ * items: [{ product: "Widget A", sales: 100 }],
1120
+ * footer: { content: { total_sales: 100 } }
1121
+ * };
1122
+ *
1123
+ * const structuredExcel = await dms.jsonToExcel(libraryRef, structuredData);
1124
+ *
1125
+ * // Create download link
1126
+ * const url = URL.createObjectURL(structuredExcel.data);
1127
+ * const link = document.createElement('a');
1128
+ * link.href = url;
1129
+ * link.download = 'report.xlsx'; // Always .xlsx extension
1130
+ * link.click();
1131
+ * ```
1132
+ */
1133
+ async jsonToExcel(lib, jsonData, options) {
1134
+ const params = {};
1135
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1136
+ params.sheet_name = options.sheet_name;
1137
+ }
1138
+ return this.request('POST', `media/library/${lib}/convert/json-to-excel`, {
1139
+ data: jsonData,
1140
+ params,
1141
+ responseType: 'blob',
1142
+ headers: {
1143
+ 'Content-Type': 'application/json'
1144
+ }
1145
+ });
1146
+ }
1147
+ /**
1148
+ * Convert CSV data to JSON format
1149
+ *
1150
+ * @param lib - Library reference UUID
1151
+ * @param csvData - CSV data string (with headers in first row)
1152
+ * @returns Promise resolving to JSON array
1153
+ *
1154
+ * @example
1155
+ * ```typescript
1156
+ * const csvString = `name,age,email
1157
+ * John Doe,30,john@example.com
1158
+ * Jane Smith,25,jane@example.com`;
1159
+ *
1160
+ * const jsonResponse = await dms.csvToJson(libraryRef, csvString);
1161
+ * console.log(jsonResponse.data);
1162
+ * // Output:
1163
+ * // [
1164
+ * // { name: "John Doe", age: "30", email: "john@example.com" },
1165
+ * // { name: "Jane Smith", age: "25", email: "jane@example.com" }
1166
+ * // ]
1167
+ * ```
1168
+ */
1169
+ async csvToJson(lib, csvData) {
1170
+ return this.request('POST', `media/library/${lib}/convert/csv-to-json`, {
1171
+ data: csvData,
1172
+ responseType: 'json',
1173
+ headers: {
1174
+ 'Content-Type': 'text/csv'
1175
+ }
1176
+ });
1177
+ }
1178
+ /**
1179
+ * Convert CSV data to Excel (.xlsx) format
1180
+ *
1181
+ * @param lib - Library reference UUID
1182
+ * @param csvData - CSV data string (with headers in first row)
1183
+ * @param options - Optional conversion options
1184
+ * @returns Promise resolving to Excel file as Blob
1185
+ *
1186
+ * @example
1187
+ * ```typescript
1188
+ * const csvString = `name,age,email
1189
+ * John Doe,30,john@example.com
1190
+ * Jane Smith,25,jane@example.com`;
1191
+ *
1192
+ * const excelResponse = await dms.csvToExcel(libraryRef, csvString, {
1193
+ * sheet_name: 'Imported Data'
1194
+ * });
1195
+ *
1196
+ * // Handle the Excel blob
1197
+ * const blob = excelResponse.data;
1198
+ * const url = URL.createObjectURL(blob);
1199
+ * // Use url for download or further processing
1200
+ * ```
1201
+ */
1202
+ async csvToExcel(lib, csvData, options) {
1203
+ const params = {};
1204
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1205
+ params.sheet_name = options.sheet_name;
1206
+ }
1207
+ return this.request('POST', `media/library/${lib}/convert/csv-to-excel`, {
1208
+ data: csvData,
1209
+ params,
1210
+ responseType: 'blob',
1211
+ headers: {
1212
+ 'Content-Type': 'text/csv'
1213
+ }
1214
+ });
1215
+ }
1216
+ /**
1217
+ * Convert Excel (.xlsx) data to JSON format
1218
+ *
1219
+ * @param lib - Library reference UUID
1220
+ * @param excelData - Excel file data as Blob or ArrayBuffer
1221
+ * @param options - Optional conversion options
1222
+ * @returns Promise resolving to JSON array
1223
+ *
1224
+ * @example
1225
+ * ```typescript
1226
+ * // From file input
1227
+ * const fileInput = document.querySelector('input[type="file"]');
1228
+ * const file = fileInput.files[0]; // Excel file
1229
+ *
1230
+ * const jsonResponse = await dms.excelToJson(libraryRef, file, {
1231
+ * sheet_name: 'Sheet1' // optional, defaults to first sheet
1232
+ * });
1233
+ *
1234
+ * console.log(jsonResponse.data);
1235
+ * // Output: JSON array with data from Excel sheet
1236
+ *
1237
+ * // From ArrayBuffer
1238
+ * const arrayBuffer = await file.arrayBuffer();
1239
+ * const jsonFromBuffer = await dms.excelToJson(libraryRef, arrayBuffer);
1240
+ * ```
1241
+ */
1242
+ async excelToJson(lib, excelData, options) {
1243
+ const params = {};
1244
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1245
+ params.sheet_name = options.sheet_name;
1246
+ }
1247
+ return this.request('POST', `media/library/${lib}/convert/excel-to-json`, {
1248
+ data: excelData,
1249
+ params,
1250
+ responseType: 'json',
1251
+ headers: {
1252
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
1253
+ }
1254
+ });
1255
+ }
1256
+ /**
1257
+ * Convert Excel (.xlsx) data to CSV format
1258
+ *
1259
+ * @param lib - Library reference UUID
1260
+ * @param excelData - Excel file data as Blob or ArrayBuffer
1261
+ * @param options - Optional conversion options
1262
+ * @returns Promise resolving to CSV string
1263
+ *
1264
+ * @example
1265
+ * ```typescript
1266
+ * // From file input
1267
+ * const fileInput = document.querySelector('input[type="file"]');
1268
+ * const file = fileInput.files[0]; // Excel file
1269
+ *
1270
+ * const csvResponse = await dms.excelToCsv(libraryRef, file, {
1271
+ * sheet_name: 'Data' // optional, defaults to first sheet
1272
+ * });
1273
+ *
1274
+ * console.log(csvResponse.data);
1275
+ * // Output: CSV string with data from Excel sheet
1276
+ *
1277
+ * // Save as CSV file
1278
+ * const csvBlob = new Blob([csvResponse.data], { type: 'text/csv' });
1279
+ * const url = URL.createObjectURL(csvBlob);
1280
+ * const link = document.createElement('a');
1281
+ * link.href = url;
1282
+ * link.download = 'converted.csv';
1283
+ * link.click();
1284
+ * ```
1285
+ */
1286
+ async excelToCsv(lib, excelData, options) {
1287
+ const params = {};
1288
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1289
+ params.sheet_name = options.sheet_name;
1290
+ }
1291
+ return this.request('POST', `media/library/${lib}/convert/excel-to-csv`, {
1292
+ data: excelData,
1293
+ params,
1294
+ responseType: 'text',
1295
+ headers: {
1296
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
1297
+ }
1298
+ });
1299
+ }
780
1300
  async request(method, endpoint, params) {
781
1301
  return await this.client.request({
782
1302
  method: method,
783
- url: `/v2/dms/${endpoint}`,
1303
+ url: `/v2/${endpoint}`,
784
1304
  ...params
785
1305
  });
786
1306
  }
@@ -854,7 +1374,7 @@ class Integrations extends IntegrationsBaseClient {
854
1374
  this.integrations = {
855
1375
  'protokol-invoicing': new Invoicing().setClient(this.client),
856
1376
  'protokol-vpfr': new VPFR().setClient(this.client),
857
- 'protokol-media': new DMS().setClient(this.client),
1377
+ 'protokol-dms': new DMS().setClient(this.client),
858
1378
  'serbia-utilities': new SerbiaUtil().setClient(this.client),
859
1379
  'protokol-payments': new Payments().setClient(this.client),
860
1380
  };
@@ -863,7 +1383,7 @@ class Integrations extends IntegrationsBaseClient {
863
1383
  return this.getInterfaceOf('serbia-utilities');
864
1384
  }
865
1385
  getDMS() {
866
- return this.getInterfaceOf('protokol-media');
1386
+ return this.getInterfaceOf('protokol-dms');
867
1387
  }
868
1388
  getVPFR() {
869
1389
  return this.getInterfaceOf('protokol-vpfr');
@@ -888,4 +1408,4 @@ class Integrations extends IntegrationsBaseClient {
888
1408
  }
889
1409
  }
890
1410
 
891
- export { APIUser, Apps, Component, ComponentUtils, Forge, Functions, Integrations as Integration, Integrations, Invoicing, DMS as Media, Payments, Ratchet, Roles, Sandbox, SerbiaUtil, System, Thunder, Users as User, VPFR, Workflow, Platform as default };
1411
+ export { APIUser, Apps, Component, ComponentUtils, DMS, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Payments, Ratchet, Roles, Sandbox, SerbiaUtil, System, Thunder, Users as User, VPFR, Workflow, Platform as default };