@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.cjs.js CHANGED
@@ -19003,24 +19003,23 @@ const isBrowser = typeof window !== "undefined" &&
19003
19003
  */
19004
19004
  class PlatformBaseClient extends BaseClient {
19005
19005
  constructor(options) {
19006
- var _a, _b;
19006
+ var _a, _b, _c;
19007
19007
  let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
19008
19008
  let headers = {};
19009
19009
  var project_uuid = null;
19010
19010
  if (isBrowser) {
19011
- console.log("DEBUG", sessionStorage.getItem('protokol_context'));
19011
+ console.log("PlatformBaseClient: running in browser context");
19012
19012
  if (sessionStorage.getItem('protokol_context') == "forge") {
19013
19013
  headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
19014
19014
  }
19015
19015
  else {
19016
- // this potentially means that it is running as dev server in local
19017
- headers['X-Project-Env'] = "dev";
19016
+ headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
19018
19017
  }
19019
19018
  }
19020
19019
  if (typeof window !== "undefined") {
19021
19020
  // @ts-ignore
19022
19021
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
19023
- host = (_b = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _b !== void 0 ? _b : host;
19022
+ host = (_c = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _c !== void 0 ? _c : host;
19024
19023
  // @ts-ignore
19025
19024
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
19026
19025
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
@@ -19181,11 +19180,7 @@ class Apps extends PlatformBaseClient {
19181
19180
  }
19182
19181
  async upload(formData) {
19183
19182
  return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
19184
- timeout: 60000,
19185
- headers: {
19186
- // set form data headers
19187
- 'Content-Type': 'multipart/form-data'
19188
- }
19183
+ timeout: 60000
19189
19184
  });
19190
19185
  }
19191
19186
  }
@@ -19486,6 +19481,9 @@ class Workflow extends PlatformBaseClient {
19486
19481
  async trigger(id, event, data) {
19487
19482
  return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
19488
19483
  }
19484
+ async publish(event, data) {
19485
+ return await this.client.post(`/v1/project/workflow/workflow/event/${event}`, data);
19486
+ }
19489
19487
  }
19490
19488
 
19491
19489
  class Forge extends PlatformBaseClient {
@@ -19585,7 +19583,7 @@ class Invoicing extends PlatformBaseClient {
19585
19583
 
19586
19584
  class IntegrationsBaseClient extends BaseClient {
19587
19585
  constructor(options) {
19588
- var _a, _b;
19586
+ var _a, _b, _c;
19589
19587
  let { env = null, token, host, } = options !== null && options !== void 0 ? options : {};
19590
19588
  let headers = {};
19591
19589
  var project_uuid = null;
@@ -19594,14 +19592,13 @@ class IntegrationsBaseClient extends BaseClient {
19594
19592
  headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
19595
19593
  }
19596
19594
  else {
19597
- // this potentially means that it is running as dev server in local
19598
- headers['X-Project-Env'] = "dev";
19595
+ headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
19599
19596
  }
19600
19597
  }
19601
19598
  if (typeof window !== "undefined") {
19602
19599
  // @ts-ignore
19603
19600
  const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
19604
- host = (_b = __global_env__.INTEGRATION_API) !== null && _b !== void 0 ? _b : host;
19601
+ host = (_c = __global_env__.INTEGRATION_API) !== null && _c !== void 0 ? _c : host;
19605
19602
  // @ts-ignore
19606
19603
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
19607
19604
  // @ts-ignore
@@ -19629,6 +19626,85 @@ class IntegrationsBaseClient extends BaseClient {
19629
19626
  }
19630
19627
  }
19631
19628
 
19629
+ /**
19630
+ * Document Management System (DMS) API client
19631
+ *
19632
+ * Provides comprehensive document and media management capabilities including:
19633
+ * - File upload, download, and management
19634
+ * - PDF generation and form filling
19635
+ * - Data conversion between JSON, CSV, and Excel formats
19636
+ * - Media processing and EXIF data extraction
19637
+ *
19638
+ * ## Data Conversion Features
19639
+ *
19640
+ * The DMS class includes powerful data conversion capabilities that allow you to:
19641
+ * - Convert between JSON, CSV, and Excel (.xlsx) formats
19642
+ * - Handle structured data with header, items, and footer sections
19643
+ * - Auto-detect structured patterns in JSON arrays
19644
+ * - Validate data format integrity
19645
+ * - Analyze data structure and metadata
19646
+ * - Handle large datasets with memory-efficient processing
19647
+ *
19648
+ * ### Supported Formats
19649
+ * - **JSON**: Array of objects (recommended for tabular data) or structured objects
19650
+ * - **CSV**: Comma-separated values with headers and optional comments
19651
+ * - **Excel**: .xlsx format with optional sheet specification
19652
+ *
19653
+ * ### Structured Data Support
19654
+ * When converting from JSON, the API supports:
19655
+ *
19656
+ * **Explicit Structure**: JSON with dedicated sections
19657
+ * ```json
19658
+ * {
19659
+ * "header": { "content": { "title": "Report" } },
19660
+ * "items": [{ "name": "Data" }],
19661
+ * "footer": { "content": { "total": 100 } }
19662
+ * }
19663
+ * ```
19664
+ *
19665
+ * **Auto-Detection**: Mixed arrays with metadata and summary objects
19666
+ * ```json
19667
+ * [
19668
+ * { "metadata": "Header info" },
19669
+ * { "name": "John", "age": 30 },
19670
+ * { "summary": "Footer info" }
19671
+ * ]
19672
+ * ```
19673
+ *
19674
+ * ### Error Handling
19675
+ * All conversion methods may throw errors with code 3003 for conversion failures.
19676
+ * Always wrap calls in try-catch blocks for production use.
19677
+ *
19678
+ * @example
19679
+ * ```typescript
19680
+ * import { DMS } from 'protokol-sdk';
19681
+ *
19682
+ * const dms = new DMS({
19683
+ * token: 'your-bearer-token',
19684
+ * host: 'http://localhost:8086'
19685
+ * });
19686
+ *
19687
+ * const libraryRef = 'your-library-uuid';
19688
+ *
19689
+ * // Convert structured JSON to CSV with comments
19690
+ * const structuredData = {
19691
+ * header: { content: { title: "Sales Report" } },
19692
+ * items: [{ product: "Widget", sales: 100 }],
19693
+ * footer: { content: { total: 100 } }
19694
+ * };
19695
+ *
19696
+ * try {
19697
+ * const csvResult = await dms.convertData(libraryRef, structuredData, {
19698
+ * from: 'json',
19699
+ * to: 'csv',
19700
+ * header_as_comment: true
19701
+ * });
19702
+ * console.log(csvResult.data); // CSV with header as comments
19703
+ * } catch (error) {
19704
+ * console.error('Conversion failed:', error.message);
19705
+ * }
19706
+ * ```
19707
+ */
19632
19708
  class DMS extends IntegrationsBaseClient {
19633
19709
  async list(data) {
19634
19710
  return this.request('POST', 'media/list', { data });
@@ -19725,18 +19801,16 @@ class DMS extends IntegrationsBaseClient {
19725
19801
  return await this.request("POST", `media/library/${lib}/dirs`, { data });
19726
19802
  }
19727
19803
  async fillPdf(lib, data) {
19728
- const { input_html, input_path, output_path, output_pdf = false, output_type, output_file_name, data: templateData, form_data, forms } = data;
19804
+ const { input_path, output_path, output_pdf = false, output_type, output_file_name, form_data, forms } = data;
19729
19805
  const responseType = output_pdf ? 'arraybuffer' : 'json';
19730
19806
  const contentType = output_pdf ? 'application/pdf' : 'application/json';
19731
19807
  return this.request('POST', `media/library/${lib}/pdf/fill`, {
19732
19808
  data: {
19733
- input_html,
19734
19809
  input_path,
19735
19810
  output_path,
19736
19811
  output_pdf,
19737
19812
  output_type,
19738
19813
  output_file_name,
19739
- data: templateData,
19740
19814
  form_data,
19741
19815
  forms
19742
19816
  },
@@ -19746,10 +19820,456 @@ class DMS extends IntegrationsBaseClient {
19746
19820
  responseType
19747
19821
  });
19748
19822
  }
19823
+ // ===================================================================
19824
+ // Data Converter Methods
19825
+ // ===================================================================
19826
+ //
19827
+ // The following methods provide comprehensive data conversion capabilities
19828
+ // between JSON, CSV, and Excel formats, along with validation and analysis tools.
19829
+ // All methods require a valid library reference UUID and return AxiosResponse objects.
19830
+ //
19831
+ /**
19832
+ * Convert data between different formats (JSON, CSV, Excel)
19833
+ *
19834
+ * Supports structured data when converting from JSON format with:
19835
+ * - Explicit structure: JSON with `header`, `items`, and `footer` properties
19836
+ * - Auto-detection: Mixed JSON arrays with metadata objects and summary rows
19837
+ *
19838
+ * @param lib - Library reference UUID
19839
+ * @param data - Raw data to convert
19840
+ * @param params - Conversion parameters including structured data options
19841
+ * @returns Promise resolving to converted data
19842
+ *
19843
+ * @example
19844
+ * ```typescript
19845
+ * // Convert JSON to CSV
19846
+ * const jsonData = [
19847
+ * { name: "John Doe", age: 30, email: "john@example.com" },
19848
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
19849
+ * ];
19850
+ *
19851
+ * const csvResult = await dms.convertData(libraryRef, jsonData, {
19852
+ * from: 'json',
19853
+ * to: 'csv'
19854
+ * });
19855
+ * console.log(csvResult.data); // CSV string
19856
+ *
19857
+ * // Convert structured JSON with header as comments
19858
+ * const structuredData = {
19859
+ * header: {
19860
+ * content: {
19861
+ * report_title: "Monthly Sales Report",
19862
+ * generated_by: "Sales System"
19863
+ * }
19864
+ * },
19865
+ * items: [
19866
+ * { product: "Widget A", sales: 100 },
19867
+ * { product: "Widget B", sales: 150 }
19868
+ * ],
19869
+ * footer: {
19870
+ * content: {
19871
+ * total_sales: 250
19872
+ * }
19873
+ * }
19874
+ * };
19875
+ *
19876
+ * const csvWithComments = await dms.convertData(libraryRef, structuredData, {
19877
+ * from: 'json',
19878
+ * to: 'csv',
19879
+ * header_as_comment: true,
19880
+ * separator_rows: 2
19881
+ * });
19882
+ *
19883
+ * // Convert JSON to Excel with custom sheet name
19884
+ * const excelResult = await dms.convertData(libraryRef, jsonData, {
19885
+ * from: 'json',
19886
+ * to: 'excel',
19887
+ * sheet_name: 'Customer Data'
19888
+ * });
19889
+ * // excelResult.data is a Blob
19890
+ * ```
19891
+ */
19892
+ async convertData(lib, data, params) {
19893
+ const { from, to, sheet_name, include_header, include_footer, header_as_comment, footer_as_comment, separator_rows } = params;
19894
+ const queryParams = { from, to };
19895
+ // Add optional parameters if provided
19896
+ if (sheet_name)
19897
+ queryParams.sheet_name = sheet_name;
19898
+ if (include_header !== undefined)
19899
+ queryParams.include_header = include_header;
19900
+ if (include_footer !== undefined)
19901
+ queryParams.include_footer = include_footer;
19902
+ if (header_as_comment !== undefined)
19903
+ queryParams.header_as_comment = header_as_comment;
19904
+ if (footer_as_comment !== undefined)
19905
+ queryParams.footer_as_comment = footer_as_comment;
19906
+ if (separator_rows !== undefined)
19907
+ queryParams.separator_rows = separator_rows;
19908
+ // Determine content type based on target format
19909
+ let responseType = 'text';
19910
+ if (to === 'json') {
19911
+ responseType = 'json';
19912
+ }
19913
+ else if (to === 'excel' || to === 'xlsx') {
19914
+ responseType = 'blob';
19915
+ }
19916
+ return this.request('POST', `media/library/${lib}/convert/data`, {
19917
+ data,
19918
+ params: queryParams,
19919
+ responseType,
19920
+ headers: {
19921
+ 'Content-Type': 'application/json'
19922
+ }
19923
+ });
19924
+ }
19925
+ /**
19926
+ * Get information about data format and structure
19927
+ *
19928
+ * @param lib - Library reference UUID
19929
+ * @param data - Raw data to analyze
19930
+ * @param params - Analysis parameters
19931
+ * @returns Promise resolving to data information
19932
+ *
19933
+ * @example
19934
+ * ```typescript
19935
+ * const jsonData = [
19936
+ * { name: "John", age: 30, email: "john@example.com" },
19937
+ * { name: "Jane", age: 25, email: "jane@example.com" }
19938
+ * ];
19939
+ *
19940
+ * const dataInfo = await dms.getDataInfo(libraryRef, jsonData, {
19941
+ * format: 'json'
19942
+ * });
19943
+ *
19944
+ * console.log(dataInfo.data);
19945
+ * // Output:
19946
+ * // {
19947
+ * // format: "json",
19948
+ * // size_bytes: 245,
19949
+ * // record_count: 2,
19950
+ * // field_count: 3,
19951
+ * // fields: ["name", "age", "email"],
19952
+ * // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
19953
+ * // }
19954
+ * ```
19955
+ */
19956
+ async getDataInfo(lib, data, params) {
19957
+ const { format } = params;
19958
+ return this.request('POST', `media/library/${lib}/convert/info`, {
19959
+ data,
19960
+ params: { format },
19961
+ headers: {
19962
+ 'Content-Type': 'application/json'
19963
+ }
19964
+ });
19965
+ }
19966
+ /**
19967
+ * Validate data format without performing conversion
19968
+ *
19969
+ * @param lib - Library reference UUID
19970
+ * @param data - Raw data to validate
19971
+ * @param params - Validation parameters
19972
+ * @returns Promise resolving to validation result
19973
+ *
19974
+ * @example
19975
+ * ```typescript
19976
+ * const jsonData = [{ name: "John", age: 30 }];
19977
+ *
19978
+ * const validation = await dms.validateData(libraryRef, jsonData, {
19979
+ * format: 'json'
19980
+ * });
19981
+ *
19982
+ * console.log(validation.data);
19983
+ * // Output:
19984
+ * // {
19985
+ * // valid: true,
19986
+ * // message: "Data is valid JSON format",
19987
+ * // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
19988
+ * // }
19989
+ *
19990
+ * // Handle invalid data
19991
+ * try {
19992
+ * const invalidValidation = await dms.validateData(libraryRef, "invalid json", {
19993
+ * format: 'json'
19994
+ * });
19995
+ * } catch (error) {
19996
+ * console.error('Validation failed:', error.response?.data?.message);
19997
+ * }
19998
+ * ```
19999
+ */
20000
+ async validateData(lib, data, params) {
20001
+ const { format } = params;
20002
+ return this.request('POST', `media/library/${lib}/convert/validate`, {
20003
+ data,
20004
+ params: { format },
20005
+ headers: {
20006
+ 'Content-Type': 'application/json'
20007
+ }
20008
+ });
20009
+ }
20010
+ /**
20011
+ * Convert JSON data to CSV format
20012
+ *
20013
+ * This method supports both regular JSON arrays and structured data with auto-detection:
20014
+ * - Regular arrays are converted directly to CSV
20015
+ * - Structured data (with metadata objects) is automatically detected and formatted
20016
+ *
20017
+ * @param lib - Library reference UUID
20018
+ * @param jsonData - JSON data (array of objects or structured data)
20019
+ * @returns Promise resolving to CSV string
20020
+ *
20021
+ * @example
20022
+ * ```typescript
20023
+ * // Regular JSON to CSV
20024
+ * const jsonData = [
20025
+ * { name: "John Doe", age: 30, email: "john@example.com" },
20026
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
20027
+ * ];
20028
+ *
20029
+ * const csvResponse = await dms.jsonToCsv(libraryRef, jsonData);
20030
+ * console.log(csvResponse.data);
20031
+ * // Output:
20032
+ * // name,age,email
20033
+ * // John Doe,30,john@example.com
20034
+ * // Jane Smith,25,jane@example.com
20035
+ *
20036
+ * // Structured JSON with auto-detection
20037
+ * const structuredData = [
20038
+ * { metadata: "EMPLOYEE REPORT\nGenerated: 2025-10-08" },
20039
+ * { name: "John Doe", age: 30, position: "Developer" },
20040
+ * { name: "Jane Smith", age: 25, position: "Designer" },
20041
+ * { name: "Total Employees:", age: null, position: "2 people" }
20042
+ * ];
20043
+ *
20044
+ * const structuredCsv = await dms.jsonToCsv(libraryRef, structuredData);
20045
+ * // Auto-detects header, items, and footer sections
20046
+ * ```
20047
+ */
20048
+ async jsonToCsv(lib, jsonData) {
20049
+ return this.request('POST', `media/library/${lib}/convert/json-to-csv`, {
20050
+ data: jsonData,
20051
+ responseType: 'text',
20052
+ headers: {
20053
+ 'Content-Type': 'application/json'
20054
+ }
20055
+ });
20056
+ }
20057
+ /**
20058
+ * Convert JSON data to Excel (.xlsx) format
20059
+ *
20060
+ * Supports both regular JSON arrays and structured data patterns.
20061
+ * Excel files are always generated with .xlsx extension.
20062
+ *
20063
+ * @param lib - Library reference UUID
20064
+ * @param jsonData - JSON data (array of objects or structured data)
20065
+ * @param options - Optional conversion options
20066
+ * @returns Promise resolving to Excel file as Blob
20067
+ *
20068
+ * @example
20069
+ * ```typescript
20070
+ * // Regular JSON to Excel
20071
+ * const jsonData = [
20072
+ * { name: "John Doe", age: 30, email: "john@example.com" },
20073
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
20074
+ * ];
20075
+ *
20076
+ * // Basic conversion
20077
+ * const excelResponse = await dms.jsonToExcel(libraryRef, jsonData);
20078
+ * const blob = excelResponse.data; // Blob for download
20079
+ *
20080
+ * // With custom sheet name
20081
+ * const excelWithOptions = await dms.jsonToExcel(libraryRef, jsonData, {
20082
+ * sheet_name: 'Customer Data'
20083
+ * });
20084
+ *
20085
+ * // Structured data with explicit sections
20086
+ * const structuredData = {
20087
+ * header: { content: { title: "Monthly Report" } },
20088
+ * items: [{ product: "Widget A", sales: 100 }],
20089
+ * footer: { content: { total_sales: 100 } }
20090
+ * };
20091
+ *
20092
+ * const structuredExcel = await dms.jsonToExcel(libraryRef, structuredData);
20093
+ *
20094
+ * // Create download link
20095
+ * const url = URL.createObjectURL(structuredExcel.data);
20096
+ * const link = document.createElement('a');
20097
+ * link.href = url;
20098
+ * link.download = 'report.xlsx'; // Always .xlsx extension
20099
+ * link.click();
20100
+ * ```
20101
+ */
20102
+ async jsonToExcel(lib, jsonData, options) {
20103
+ const params = {};
20104
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
20105
+ params.sheet_name = options.sheet_name;
20106
+ }
20107
+ return this.request('POST', `media/library/${lib}/convert/json-to-excel`, {
20108
+ data: jsonData,
20109
+ params,
20110
+ responseType: 'blob',
20111
+ headers: {
20112
+ 'Content-Type': 'application/json'
20113
+ }
20114
+ });
20115
+ }
20116
+ /**
20117
+ * Convert CSV data to JSON format
20118
+ *
20119
+ * @param lib - Library reference UUID
20120
+ * @param csvData - CSV data string (with headers in first row)
20121
+ * @returns Promise resolving to JSON array
20122
+ *
20123
+ * @example
20124
+ * ```typescript
20125
+ * const csvString = `name,age,email
20126
+ * John Doe,30,john@example.com
20127
+ * Jane Smith,25,jane@example.com`;
20128
+ *
20129
+ * const jsonResponse = await dms.csvToJson(libraryRef, csvString);
20130
+ * console.log(jsonResponse.data);
20131
+ * // Output:
20132
+ * // [
20133
+ * // { name: "John Doe", age: "30", email: "john@example.com" },
20134
+ * // { name: "Jane Smith", age: "25", email: "jane@example.com" }
20135
+ * // ]
20136
+ * ```
20137
+ */
20138
+ async csvToJson(lib, csvData) {
20139
+ return this.request('POST', `media/library/${lib}/convert/csv-to-json`, {
20140
+ data: csvData,
20141
+ responseType: 'json',
20142
+ headers: {
20143
+ 'Content-Type': 'text/csv'
20144
+ }
20145
+ });
20146
+ }
20147
+ /**
20148
+ * Convert CSV data to Excel (.xlsx) format
20149
+ *
20150
+ * @param lib - Library reference UUID
20151
+ * @param csvData - CSV data string (with headers in first row)
20152
+ * @param options - Optional conversion options
20153
+ * @returns Promise resolving to Excel file as Blob
20154
+ *
20155
+ * @example
20156
+ * ```typescript
20157
+ * const csvString = `name,age,email
20158
+ * John Doe,30,john@example.com
20159
+ * Jane Smith,25,jane@example.com`;
20160
+ *
20161
+ * const excelResponse = await dms.csvToExcel(libraryRef, csvString, {
20162
+ * sheet_name: 'Imported Data'
20163
+ * });
20164
+ *
20165
+ * // Handle the Excel blob
20166
+ * const blob = excelResponse.data;
20167
+ * const url = URL.createObjectURL(blob);
20168
+ * // Use url for download or further processing
20169
+ * ```
20170
+ */
20171
+ async csvToExcel(lib, csvData, options) {
20172
+ const params = {};
20173
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
20174
+ params.sheet_name = options.sheet_name;
20175
+ }
20176
+ return this.request('POST', `media/library/${lib}/convert/csv-to-excel`, {
20177
+ data: csvData,
20178
+ params,
20179
+ responseType: 'blob',
20180
+ headers: {
20181
+ 'Content-Type': 'text/csv'
20182
+ }
20183
+ });
20184
+ }
20185
+ /**
20186
+ * Convert Excel (.xlsx) data to JSON format
20187
+ *
20188
+ * @param lib - Library reference UUID
20189
+ * @param excelData - Excel file data as Blob or ArrayBuffer
20190
+ * @param options - Optional conversion options
20191
+ * @returns Promise resolving to JSON array
20192
+ *
20193
+ * @example
20194
+ * ```typescript
20195
+ * // From file input
20196
+ * const fileInput = document.querySelector('input[type="file"]');
20197
+ * const file = fileInput.files[0]; // Excel file
20198
+ *
20199
+ * const jsonResponse = await dms.excelToJson(libraryRef, file, {
20200
+ * sheet_name: 'Sheet1' // optional, defaults to first sheet
20201
+ * });
20202
+ *
20203
+ * console.log(jsonResponse.data);
20204
+ * // Output: JSON array with data from Excel sheet
20205
+ *
20206
+ * // From ArrayBuffer
20207
+ * const arrayBuffer = await file.arrayBuffer();
20208
+ * const jsonFromBuffer = await dms.excelToJson(libraryRef, arrayBuffer);
20209
+ * ```
20210
+ */
20211
+ async excelToJson(lib, excelData, options) {
20212
+ const params = {};
20213
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
20214
+ params.sheet_name = options.sheet_name;
20215
+ }
20216
+ return this.request('POST', `media/library/${lib}/convert/excel-to-json`, {
20217
+ data: excelData,
20218
+ params,
20219
+ responseType: 'json',
20220
+ headers: {
20221
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
20222
+ }
20223
+ });
20224
+ }
20225
+ /**
20226
+ * Convert Excel (.xlsx) data to CSV format
20227
+ *
20228
+ * @param lib - Library reference UUID
20229
+ * @param excelData - Excel file data as Blob or ArrayBuffer
20230
+ * @param options - Optional conversion options
20231
+ * @returns Promise resolving to CSV string
20232
+ *
20233
+ * @example
20234
+ * ```typescript
20235
+ * // From file input
20236
+ * const fileInput = document.querySelector('input[type="file"]');
20237
+ * const file = fileInput.files[0]; // Excel file
20238
+ *
20239
+ * const csvResponse = await dms.excelToCsv(libraryRef, file, {
20240
+ * sheet_name: 'Data' // optional, defaults to first sheet
20241
+ * });
20242
+ *
20243
+ * console.log(csvResponse.data);
20244
+ * // Output: CSV string with data from Excel sheet
20245
+ *
20246
+ * // Save as CSV file
20247
+ * const csvBlob = new Blob([csvResponse.data], { type: 'text/csv' });
20248
+ * const url = URL.createObjectURL(csvBlob);
20249
+ * const link = document.createElement('a');
20250
+ * link.href = url;
20251
+ * link.download = 'converted.csv';
20252
+ * link.click();
20253
+ * ```
20254
+ */
20255
+ async excelToCsv(lib, excelData, options) {
20256
+ const params = {};
20257
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
20258
+ params.sheet_name = options.sheet_name;
20259
+ }
20260
+ return this.request('POST', `media/library/${lib}/convert/excel-to-csv`, {
20261
+ data: excelData,
20262
+ params,
20263
+ responseType: 'text',
20264
+ headers: {
20265
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
20266
+ }
20267
+ });
20268
+ }
19749
20269
  async request(method, endpoint, params) {
19750
20270
  return await this.client.request({
19751
20271
  method: method,
19752
- url: `/v2/dms/${endpoint}`,
20272
+ url: `/v2/${endpoint}`,
19753
20273
  ...params
19754
20274
  });
19755
20275
  }
@@ -19823,7 +20343,7 @@ class Integrations extends IntegrationsBaseClient {
19823
20343
  this.integrations = {
19824
20344
  'protokol-invoicing': new Invoicing().setClient(this.client),
19825
20345
  'protokol-vpfr': new VPFR().setClient(this.client),
19826
- 'protokol-media': new DMS().setClient(this.client),
20346
+ 'protokol-dms': new DMS().setClient(this.client),
19827
20347
  'serbia-utilities': new SerbiaUtil().setClient(this.client),
19828
20348
  'protokol-payments': new Payments().setClient(this.client),
19829
20349
  };
@@ -19832,7 +20352,7 @@ class Integrations extends IntegrationsBaseClient {
19832
20352
  return this.getInterfaceOf('serbia-utilities');
19833
20353
  }
19834
20354
  getDMS() {
19835
- return this.getInterfaceOf('protokol-media');
20355
+ return this.getInterfaceOf('protokol-dms');
19836
20356
  }
19837
20357
  getVPFR() {
19838
20358
  return this.getInterfaceOf('protokol-vpfr');
@@ -19861,12 +20381,12 @@ exports.APIUser = APIUser;
19861
20381
  exports.Apps = Apps;
19862
20382
  exports.Component = Component;
19863
20383
  exports.ComponentUtils = ComponentUtils;
20384
+ exports.DMS = DMS;
19864
20385
  exports.Forge = Forge;
19865
20386
  exports.Functions = Functions;
19866
20387
  exports.Integration = Integrations;
19867
20388
  exports.Integrations = Integrations;
19868
20389
  exports.Invoicing = Invoicing;
19869
- exports.Media = DMS;
19870
20390
  exports.Payments = Payments;
19871
20391
  exports.Ratchet = Ratchet;
19872
20392
  exports.Roles = Roles;