totalum-api-sdk 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.MD CHANGED
@@ -1,4 +1,4 @@
1
- ## Totalum API SDK (v3.0.2)
1
+ ## Totalum API SDK (v3.0.5)
2
2
 
3
3
  Official TypeScript/JavaScript SDK for the Totalum API. This library provides a fully typed, modern interface to interact with all Totalum endpoints.
4
4
 
@@ -17,82 +17,6 @@ npm i totalum-api-sdk
17
17
  - **Improved Type Safety**: Full TypeScript support with detailed response types
18
18
  - **No Breaking Changes in API**: Same Totalum API, just better developer experience
19
19
 
20
- ## Migration Guide (v2.x → v3.0)
21
-
22
- ### Breaking Changes
23
-
24
- #### 1. Method Names (CRUD Service)
25
- ```javascript
26
- // v2.x
27
- await totalumClient.crud.getItemById(table, id);
28
- await totalumClient.crud.getItems(table, query);
29
- await totalumClient.crud.createItem(table, data);
30
- await totalumClient.crud.editItemById(table, id, data);
31
- await totalumClient.crud.deleteItemById(table, id);
32
- await totalumClient.crud.addManyToManyReferenceItem(table, id, prop, refId);
33
- await totalumClient.crud.dropManyToManyReferenceItem(table, id, prop, refId);
34
- await totalumClient.crud.getManyToManyReferencesItems(table, id, prop, query);
35
-
36
- // v3.0
37
- await totalumClient.crud.getRecordById(table, id);
38
- await totalumClient.crud.getRecords(table, query);
39
- await totalumClient.crud.createRecord(table, data);
40
- await totalumClient.crud.editRecordById(table, id, data);
41
- await totalumClient.crud.deleteRecordById(table, id);
42
- await totalumClient.crud.addManyToManyReferenceRecord(table, id, prop, refId);
43
- await totalumClient.crud.dropManyToManyReferenceRecord(table, id, prop, refId);
44
- await totalumClient.crud.getManyToManyReferencesRecords(table, id, prop, query);
45
- ```
46
-
47
- #### 2. Response Structure
48
- ```javascript
49
- // v2.x (using axios)
50
- const result = await totalumClient.crud.getItems(table, {});
51
- const items = result.data; // Double .data because of axios wrapper
52
-
53
- // v3.0 (using fetch)
54
- const result = await totalumClient.crud.getRecords(table, {});
55
- if (result.errors) {
56
- console.error('Error:', result.errors.errorMessage);
57
- return;
58
- }
59
- const records = result.data; // Direct access to data
60
- ```
61
-
62
- #### 3. Error Handling
63
- ```javascript
64
- // v2.x (axios throws errors)
65
- try {
66
- const result = await totalumClient.crud.getItems(table, {});
67
- const items = result.data;
68
- } catch (error) {
69
- console.error('Error:', error.message);
70
- }
71
-
72
- // v3.0 (errors in response object)
73
- const result = await totalumClient.crud.getRecords(table, {});
74
- if (result.errors) {
75
- console.error('Error:', result.errors.errorMessage);
76
- console.error('Error Code:', result.errors.errorCode);
77
- return;
78
- }
79
- const records = result.data;
80
- ```
81
-
82
- ### Dependencies
83
- ```json
84
- // v2.x
85
- {
86
- "dependencies": {
87
- "axios": "^1.x.x"
88
- }
89
- }
90
-
91
- // v3.0 (no dependencies!)
92
- {
93
- "dependencies": {}
94
- }
95
- ```
96
20
 
97
21
  **Note:** v3.0 requires Node.js 18+ (for native fetch support). If you're using an older Node.js version, you'll need to polyfill `fetch` or upgrade to Node.js 18+.
98
22
 
@@ -47,7 +47,8 @@ class FetchClient {
47
47
  errors: {
48
48
  errorCode: 'RESPONSE_PARSE_ERROR',
49
49
  errorMessage: `Failed to parse response: ${response.statusText}`
50
- }
50
+ },
51
+ data: null
51
52
  };
52
53
  }
53
54
  // Always return the API response structure {data, errors}
@@ -68,7 +69,8 @@ class FetchClient {
68
69
  errors: {
69
70
  errorCode: 'NETWORK_ERROR',
70
71
  errorMessage: error instanceof Error ? error.message : 'Network request failed'
71
- }
72
+ },
73
+ data: null
72
74
  };
73
75
  }
74
76
  });
@@ -8,7 +8,7 @@ export interface ErrorResult {
8
8
  }[];
9
9
  }
10
10
  export interface TotalumApiResponse<T> {
11
- data?: T;
11
+ data: T;
12
12
  errors?: ErrorResult | null;
13
13
  metadata?: any;
14
14
  }
@@ -84,10 +84,10 @@ export type fieldFileI = {
84
84
  };
85
85
  export type fieldTypesEnabled = 'string' | 'number' | 'boolean' | 'date' | 'options' | 'file' | 'long-string' | /*'array' |*/ 'objectReference';
86
86
  export interface DataValues {
87
- _id: string;
88
- createdAt: Date;
89
- updatedAt: Date;
90
- [key: string]: fieldValuesEnabled;
87
+ _id?: string;
88
+ createdAt?: Date;
89
+ updatedAt?: Date;
90
+ [key: string]: fieldValuesEnabled | any;
91
91
  }
92
92
  export interface DataProperties {
93
93
  [key: string]: fieldValuesEnabled | any;
@@ -155,7 +155,7 @@ export interface UpdatesRecordResponse {
155
155
  _id: string;
156
156
  objectId: string;
157
157
  typeId: string;
158
- updates: UpdateRecordChange[];
158
+ updatesRecord: UpdateRecordChange[];
159
159
  }
160
160
  export interface ManyToManyReferenceResponse {
161
161
  acknowledged: boolean;
@@ -10,7 +10,7 @@ export declare class CrudService {
10
10
  * @param {string} id - The ID of the record.
11
11
  * @returns {Promise<TotalumApiResponse<T>>} - A promise that resolves to the record data.
12
12
  */
13
- getRecordById<T = DataValues>(tableName: string, id: string): Promise<TotalumApiResponse<T>>;
13
+ getRecordById<T = DataValues>(tableName: string, id: string): Promise<TotalumApiResponse<any>>;
14
14
  /**
15
15
  * Fetches the historic updates of a record by its ID.
16
16
  * @param {string} recordId - The ID of the record to fetch the historic updates.
@@ -24,14 +24,14 @@ export declare class CrudService {
24
24
  * @param {FilterSearchQueryI} query - Optional query parameters for filtering.
25
25
  * @returns {Promise<TotalumApiResponse<T[]>>} - A promise that resolves to an array of records.
26
26
  */
27
- getRecords<T = DataValues>(tableName: string, query?: FilterSearchQueryI): Promise<TotalumApiResponse<T[]>>;
27
+ getRecords<T = DataValues>(tableName: string, query?: FilterSearchQueryI): Promise<TotalumApiResponse<any[]>>;
28
28
  /**
29
29
  * Fetches nested data across related tables.
30
30
  * @param {NestedQuery} nestedQuery - The nested query structure.
31
31
  * @param {any} options - Optional configuration.
32
32
  * @returns {Promise<TotalumApiResponse<T[]>>} - A promise that resolves to nested data array.
33
33
  */
34
- getNestedData<T = DataValues>(nestedQuery: NestedQuery, options?: any): Promise<TotalumApiResponse<T[]>>;
34
+ getNestedData<T extends DataValues = DataValues>(nestedQuery: NestedQuery, options?: any): Promise<TotalumApiResponse<T[]>>;
35
35
  /**
36
36
  * Deletes a record by its ID.
37
37
  * @param {string} tableName - The type of the record. (table name)
@@ -46,14 +46,14 @@ export declare class CrudService {
46
46
  * @param {T} properties - The properties to update.
47
47
  * @returns {Promise<TotalumApiResponse<T>>} - A promise that resolves to the updated record.
48
48
  */
49
- editRecordById<T = DataValues>(tableName: string, id: string, properties: Partial<T>): Promise<TotalumApiResponse<T>>;
49
+ editRecordById<T = DataValues>(tableName: string, id: string, properties: Partial<any>): Promise<TotalumApiResponse<any>>;
50
50
  /**
51
51
  * Creates a new record.
52
52
  * @param {string} tableName - The type of the record. (table name)
53
- * @param {T} record - The record data to create.
53
+ * @param {Partial<DataValues>} record - The record data to create.
54
54
  * @returns {Promise<TotalumApiResponse<T>>} - A promise that resolves to the created record.
55
55
  */
56
- createRecord<T = DataValues>(tableName: string, record: Partial<T>): Promise<TotalumApiResponse<T>>;
56
+ createRecord<T = DataValues>(tableName: string, record: Partial<any>): Promise<TotalumApiResponse<any>>;
57
57
  /**
58
58
  * Adds a many-to-many reference between records.
59
59
  * @param {string} type - The type id of the record (table name)
@@ -82,5 +82,5 @@ export declare class CrudService {
82
82
  * @param {FilterSearchQueryI} query - The query to filter and sort the results
83
83
  * @returns {Promise<TotalumApiResponse<T[]>>}
84
84
  */
85
- getManyToManyReferencesRecords<T = DataValues>(type: string, id: string, propertyName: string, query?: FilterSearchQueryI): Promise<TotalumApiResponse<T[]>>;
85
+ getManyToManyReferencesRecords<T = DataValues>(type: string, id: string, propertyName: string, query?: FilterSearchQueryI): Promise<TotalumApiResponse<any[]>>;
86
86
  }
@@ -99,7 +99,7 @@ class CrudService {
99
99
  /**
100
100
  * Creates a new record.
101
101
  * @param {string} tableName - The type of the record. (table name)
102
- * @param {T} record - The record data to create.
102
+ * @param {Partial<DataValues>} record - The record data to create.
103
103
  * @returns {Promise<TotalumApiResponse<T>>} - A promise that resolves to the created record.
104
104
  */
105
105
  createRecord(tableName, record) {
@@ -31,7 +31,8 @@ class EmailService {
31
31
  errors: {
32
32
  errorCode: 'TOO_MANY_ATTACHMENTS',
33
33
  errorMessage: `Maximum number of attachments is 10. Received ${emailPayload.attachments.length}.`
34
- }
34
+ },
35
+ data: null
35
36
  };
36
37
  }
37
38
  // Validate attachment URLs
@@ -42,7 +43,8 @@ class EmailService {
42
43
  errors: {
43
44
  errorCode: 'INVALID_ATTACHMENT_URL',
44
45
  errorMessage: `Attachment ${attachment.filename} must have a valid URL`
45
- }
46
+ },
47
+ data: null
46
48
  };
47
49
  }
48
50
  if (!attachment.url.startsWith('http://') && !attachment.url.startsWith('https://')) {
@@ -50,7 +52,8 @@ class EmailService {
50
52
  errors: {
51
53
  errorCode: 'INVALID_ATTACHMENT_URL',
52
54
  errorMessage: `Attachment ${attachment.filename} must have a valid HTTP/HTTPS URL`
53
- }
55
+ },
56
+ data: null
54
57
  };
55
58
  }
56
59
  }
@@ -22,7 +22,7 @@ export declare class FilterService {
22
22
  * @param {filterNestedOptionsI} filterOptions - Extra options for the filter like pagination and sort
23
23
  * @returns {Promise<TotalumApiResponse<T[]>>} - Array of filtered items
24
24
  */
25
- nestedFilter<T = DataValues>(nestedQuery: NestedQueryFilterI, tableNameToGetResults: string, filterOptions?: filterNestedOptionsI): Promise<TotalumApiResponse<T[]>>;
25
+ nestedFilter<T = DataValues>(nestedQuery: NestedQueryFilterI, tableNameToGetResults: string, filterOptions?: filterNestedOptionsI): Promise<TotalumApiResponse<any[]>>;
26
26
  /**
27
27
  * Runs a custom MongoDB aggregation query.
28
28
  * @param {string} type - The table name that will be at the top of the MongoDB aggregation
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.totalumSdk=t():e.totalumSdk=t()}(this,(()=>(()=>{"use strict";var e={429:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endpoints=void 0,t.endpoints={crud:{getObjectById:"api/v1/crud/:typeId/:id",getObjects:"api/v1/crud/query/:typeId",getNestedData:"api/v1/crud/nested",createObject:"api/v1/crud/:typeId",editObjectProperties:"api/v1/crud/:typeId/:id",deleteObject:"api/v1/crud/:typeId/:id",deleteObjectAndSubElements:"api/v1/crud/:typeId/:id/:pageId/subelements",updateLastUsersActions:"api/v1/crud/:typeId/:id/lastUsersActions",addManyToManyReference:"api/v1/crud/:typeId/:id/add-many-to-many-reference",dropManyToManyReference:"api/v1/crud/:typeId/:id/drop-many-to-many-reference",getManyToManyReferencesItems:"api/v1/crud/:typeId/:id/:propertyName"},updatesRecord:{getUpdateRecordByObjectId:"api/v1/updates-record/:objectId"},files:{uploadFile:"api/v1/files/upload",getDownloadUrl:"api/v1/files/download/:fileName",deleteFile:"api/v1/files/:fileName",ocrOfImage:"api/v1/files/ocr/image",ocrOfPdf:"api/v1/files/ocr/pdf",scanInvoice:"api/v1/files/scan-invoice",scanDocument:"api/v1/files/scan-document"},filter:{lookUpFilter:"api/v1/filter/:idPage",nestedFilter:"api/v1/filter/nested-filter",runCustomAggregationQuery:"api/v1/filter/custom-mongo-aggregation-query"},pdfTemplate:{generatePdfByTemplate:"api/v1/pdf-template/generatePdfByTemplate/:id",createPdfFromHtml:"api/v1/pdf-template/createPdfFromHtml"},googleIntegration:{getEmails:"api/v1/google-integration/get-emails",sendEmail:"api/v1/google-integration/send-email",getCalendarEvents:"api/v1/google-integration/get-calendar-events",createCalendarEvent:"api/v1/google-integration/create-calendar-event"},openai:{createCompletion:"api/v1/openai/completion",createChatCompletion:"api/v1/openai/chat-completion",generateImage:"api/v1/openai/image"},notifications:{createNotification:"api/v1/notifications"},statistics:{getStatistic:"api/v1/statistics/get-statistic"},email:{sendEmail:"api/v1/startum/send-email-with-default-domain"}}},731:function(e,t){var i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FetchClient=t.TotalumError=void 0;class n extends Error{constructor(e){super(e.errorMessage),this.errorCode=e.errorCode,this.errorMessage=e.errorMessage,this.hasManyErrors=e.hasManyErrors||!1,this.multipleErrors=e.multipleErrors||[],this.name="TotalumError",Object.setPrototypeOf(this,n.prototype)}toJSON(){return{errorCode:this.errorCode,errorMessage:this.errorMessage,hasManyErrors:this.hasManyErrors,multipleErrors:this.multipleErrors}}}t.TotalumError=n,t.FetchClient=class{constructor(e,t){this.baseUrl=e,this.headers=t}handleResponse(e){return i(this,void 0,void 0,(function*(){let t;try{t=yield e.json()}catch(t){return{errors:{errorCode:"RESPONSE_PARSE_ERROR",errorMessage:`Failed to parse response: ${e.statusText}`}}}return t}))}request(e,t){return i(this,void 0,void 0,(function*(){const i=this.baseUrl+e;try{const e=yield fetch(i,Object.assign(Object.assign({},t),{headers:Object.assign(Object.assign({},this.headers),null==t?void 0:t.headers)}));return this.handleResponse(e)}catch(e){return{errors:{errorCode:"NETWORK_ERROR",errorMessage:e instanceof Error?e.message:"Network request failed"}}}}))}get(e,t){return i(this,void 0,void 0,(function*(){let i=e;if(t){const e=new URLSearchParams(Object.entries(t).reduce(((e,[t,i])=>(null!=i&&(e[t]=String(i)),e)),{})).toString();e&&(i+="?"+e)}return this.request(i,{method:"GET"})}))}post(e,t){return i(this,void 0,void 0,(function*(){const i=t instanceof FormData;return this.request(e,{method:"POST",headers:i?{}:{"Content-Type":"application/json"},body:i?t:JSON.stringify(t)})}))}patch(e,t){return i(this,void 0,void 0,(function*(){return this.request(e,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}))}delete(e){return i(this,void 0,void 0,(function*(){return this.request(e,{method:"DELETE"})}))}put(e,t){return i(this,void 0,void 0,(function*(){return this.request(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}))}}},999:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},879:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},492:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.TotalumApiSdk=t.TotalumError=void 0;const o=i(731),s=i(730),c=i(675),a=i(589),d=i(882),l=i(386),u=i(706),p=i(279);r(i(999),t),r(i(879),t);var f=i(731);Object.defineProperty(t,"TotalumError",{enumerable:!0,get:function(){return f.TotalumError}}),t.TotalumApiSdk=class{constructor(e){var t,i;if(this._baseUrl="https://api.totalum.app/",this.authOptions=e,this._headers={},null===(t=this.authOptions.token)||void 0===t?void 0:t.accessToken)this._headers.authorization=this.authOptions.token.accessToken;else{if(!(null===(i=this.authOptions.apiKey)||void 0===i?void 0:i["api-key"]))throw new Error("Error: invalid auth options");this._headers["api-key"]=this.authOptions.apiKey["api-key"]}this.authOptions.baseUrl&&(this._baseUrl=this.authOptions.baseUrl),this.authOptions.fromEvent&&(this._headers.fromEvent="true"),this.setRequestData()}changeBaseUrl(e){this._baseUrl=e,this.setRequestData()}setRequestData(){this.client=new o.FetchClient(this._baseUrl,this._headers),this.crud=new d.CrudService(this.client),this.openai=new s.OpenaiService(this.client),this.files=new a.FilesService(this.client),this.filter=new c.FilterService(this.client),this.notification=new l.NotificationService(this.client),this.statistic=new u.StatisticService(this.client),this.email=new p.EmailService(this.client)}}},882:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CrudService=void 0;const r=i(591),o=i(429);t.CrudService=class{constructor(e){this.client=e}getRecordById(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.getObjectById,{typeId:e,id:t});return this.client.get(i)}))}getHistoricRecordUpdatesById(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.updatesRecord.getUpdateRecordByObjectId,{objectId:e});return this.client.get(t)}))}getRecords(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.getObjects,{typeId:e});return this.client.post(i,t)}))}getNestedData(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.getNestedData);return this.client.post(i,{nestedQuery:e,options:t})}))}deleteRecordById(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.deleteObject,{typeId:e,id:t});return this.client.delete(i)}))}editRecordById(e,t,i){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.crud.editObjectProperties,{typeId:e,id:t});return this.client.request(n,{method:"PATCH",headers:{"Content-Type":"application/json",returnoption:"fullrecord"},body:JSON.stringify(i)})}))}createRecord(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.createObject,{typeId:e});return this.client.request(i,{method:"POST",headers:{"Content-Type":"application/json",returnoption:"fullrecord"},body:JSON.stringify(t)})}))}addManyToManyReferenceRecord(e,t,i,s){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.crud.addManyToManyReference,{typeId:e,id:t});return this.client.patch(n,{propertyId:i,referenceId:s})}))}dropManyToManyReferenceRecord(e,t,i,s){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.crud.dropManyToManyReference,{typeId:e,id:t});return this.client.patch(n,{propertyId:i,referenceId:s})}))}getManyToManyReferencesRecords(e,t,i,s){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.crud.getManyToManyReferencesItems,{typeId:e,id:t,propertyName:i});return this.client.get(n,s)}))}}},279:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.EmailService=void 0;const r=i(429),o=i(591);t.EmailService=class{constructor(e){this.client=e}sendEmail(e){return n(this,void 0,void 0,(function*(){if(e.attachments&&e.attachments.length>10)return{errors:{errorCode:"TOO_MANY_ATTACHMENTS",errorMessage:`Maximum number of attachments is 10. Received ${e.attachments.length}.`}};if(e.attachments)for(const t of e.attachments){if(!t.url||"string"!=typeof t.url)return{errors:{errorCode:"INVALID_ATTACHMENT_URL",errorMessage:`Attachment ${t.filename} must have a valid URL`}};if(!t.url.startsWith("http://")&&!t.url.startsWith("https://"))return{errors:{errorCode:"INVALID_ATTACHMENT_URL",errorMessage:`Attachment ${t.filename} must have a valid HTTP/HTTPS URL`}}}return this.sendEmailWithDefaultDomain(e)}))}sendEmailWithDefaultDomain(e){return n(this,void 0,void 0,(function*(){const t=o.UtilsService.getUrl("",r.endpoints.email.sendEmail,{});return this.client.post(t,e)}))}}},589:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FilesService=void 0;const r=i(591),o=i(429);t.FilesService=class{constructor(e){this.client=e}uploadFile(e,t){return n(this,void 0,void 0,(function*(){let i=r.UtilsService.getUrl("",o.endpoints.files.uploadFile);return(null==t?void 0:t.compressFile)&&(i+="?compressFile=true"),this.client.post(i,e)}))}deleteFile(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.files.deleteFile,{fileName:e});return this.client.delete(t)}))}getDownloadUrl(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.files.getDownloadUrl,{fileName:e});return this.client.get(i,t)}))}generatePdfByTemplate(e,t,i){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.pdfTemplate.generatePdfByTemplate,{id:e});return this.client.post(n,{templateId:e,variables:t,name:i})}))}createPdfFromHtml(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.pdfTemplate.createPdfFromHtml);let i;return i="undefined"==typeof window?Buffer.from(e.html,"utf-8").toString("base64"):btoa(unescape(encodeURIComponent(e.html))),this.client.post(t,{base64HtmlString:i,name:e.name})}))}ocrOfImage(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.files.ocrOfImage);return this.client.post(t,{fileName:e})}))}ocrOfPdf(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.files.ocrOfPdf);return this.client.post(t,{fileName:e})}))}scanInvoice(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.files.scanInvoice);return this.client.post(i,{fileName:e,options:t})}))}scanDocument(e,t,i){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.files.scanDocument);return this.client.post(n,{fileName:e,properties:t,options:i})}))}}},675:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FilterService=void 0;const r=i(429),o=i(591);t.FilterService=class{constructor(e){this.client=e}lookUpFilter(e,t,i,s){return n(this,void 0,void 0,(function*(){const n=o.UtilsService.getUrl("",r.endpoints.filter.lookUpFilter,{idPage:e}),c={query:encodeURIComponent(JSON.stringify(t)),idsOfMultipleNodesToSearch:i?encodeURIComponent(JSON.stringify(i)):void 0,returnCount:null==s?void 0:s.toString()};return this.client.get(n,c)}))}nestedFilter(e,t,i){return n(this,void 0,void 0,(function*(){const n=o.UtilsService.getUrl("",r.endpoints.filter.nestedFilter,{}),s={nestedFilter:e,tableNameToGetResults:t,filterOptions:i};return this.client.post(n,s)}))}runCustomMongoAggregationQuery(e,t){return n(this,void 0,void 0,(function*(){const i=o.UtilsService.getUrl("",r.endpoints.filter.runCustomAggregationQuery),n={customMongoQuery:t,type:e};return this.client.post(i,n)}))}}},386:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.NotificationService=void 0;const r=i(429),o=i(591);t.NotificationService=class{constructor(e){this.client=e}createNotification(e){return n(this,void 0,void 0,(function*(){const t=o.UtilsService.getUrl("",r.endpoints.notifications.createNotification,{});return this.client.post(t,{notification:e})}))}}},730:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.OpenaiService=void 0;const r=i(591),o=i(429);t.OpenaiService=class{constructor(e){this.client=e}createCompletion(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.openai.createCompletion);return this.client.post(t,e)}))}createChatCompletion(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.openai.createChatCompletion);return this.client.post(t,e)}))}generateImage(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.openai.generateImage);return this.client.post(t,e)}))}}},706:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.StatisticService=void 0;const r=i(429),o=i(591);t.StatisticService=class{constructor(e){this.client=e}getStatistic(e,t){return n(this,void 0,void 0,(function*(){const i=o.UtilsService.getUrl("",r.endpoints.statistics.getStatistic,{}),n={query:e,options:t};return this.client.post(i,n)}))}}},591:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UtilsService=void 0,t.UtilsService=class{static getUrl(e,t,i){let n=e+t;for(const e in i)n=n.replace(`:${e}`,i[e]);return n}}}},t={};return function i(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,i),o.exports}(492)})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.totalumSdk=t():e.totalumSdk=t()}(this,(()=>(()=>{"use strict";var e={429:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endpoints=void 0,t.endpoints={crud:{getObjectById:"api/v1/crud/:typeId/:id",getObjects:"api/v1/crud/query/:typeId",getNestedData:"api/v1/crud/nested",createObject:"api/v1/crud/:typeId",editObjectProperties:"api/v1/crud/:typeId/:id",deleteObject:"api/v1/crud/:typeId/:id",deleteObjectAndSubElements:"api/v1/crud/:typeId/:id/:pageId/subelements",updateLastUsersActions:"api/v1/crud/:typeId/:id/lastUsersActions",addManyToManyReference:"api/v1/crud/:typeId/:id/add-many-to-many-reference",dropManyToManyReference:"api/v1/crud/:typeId/:id/drop-many-to-many-reference",getManyToManyReferencesItems:"api/v1/crud/:typeId/:id/:propertyName"},updatesRecord:{getUpdateRecordByObjectId:"api/v1/updates-record/:objectId"},files:{uploadFile:"api/v1/files/upload",getDownloadUrl:"api/v1/files/download/:fileName",deleteFile:"api/v1/files/:fileName",ocrOfImage:"api/v1/files/ocr/image",ocrOfPdf:"api/v1/files/ocr/pdf",scanInvoice:"api/v1/files/scan-invoice",scanDocument:"api/v1/files/scan-document"},filter:{lookUpFilter:"api/v1/filter/:idPage",nestedFilter:"api/v1/filter/nested-filter",runCustomAggregationQuery:"api/v1/filter/custom-mongo-aggregation-query"},pdfTemplate:{generatePdfByTemplate:"api/v1/pdf-template/generatePdfByTemplate/:id",createPdfFromHtml:"api/v1/pdf-template/createPdfFromHtml"},googleIntegration:{getEmails:"api/v1/google-integration/get-emails",sendEmail:"api/v1/google-integration/send-email",getCalendarEvents:"api/v1/google-integration/get-calendar-events",createCalendarEvent:"api/v1/google-integration/create-calendar-event"},openai:{createCompletion:"api/v1/openai/completion",createChatCompletion:"api/v1/openai/chat-completion",generateImage:"api/v1/openai/image"},notifications:{createNotification:"api/v1/notifications"},statistics:{getStatistic:"api/v1/statistics/get-statistic"},email:{sendEmail:"api/v1/startum/send-email-with-default-domain"}}},731:function(e,t){var i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FetchClient=t.TotalumError=void 0;class n extends Error{constructor(e){super(e.errorMessage),this.errorCode=e.errorCode,this.errorMessage=e.errorMessage,this.hasManyErrors=e.hasManyErrors||!1,this.multipleErrors=e.multipleErrors||[],this.name="TotalumError",Object.setPrototypeOf(this,n.prototype)}toJSON(){return{errorCode:this.errorCode,errorMessage:this.errorMessage,hasManyErrors:this.hasManyErrors,multipleErrors:this.multipleErrors}}}t.TotalumError=n,t.FetchClient=class{constructor(e,t){this.baseUrl=e,this.headers=t}handleResponse(e){return i(this,void 0,void 0,(function*(){let t;try{t=yield e.json()}catch(t){return{errors:{errorCode:"RESPONSE_PARSE_ERROR",errorMessage:`Failed to parse response: ${e.statusText}`},data:null}}return t}))}request(e,t){return i(this,void 0,void 0,(function*(){const i=this.baseUrl+e;try{const e=yield fetch(i,Object.assign(Object.assign({},t),{headers:Object.assign(Object.assign({},this.headers),null==t?void 0:t.headers)}));return this.handleResponse(e)}catch(e){return{errors:{errorCode:"NETWORK_ERROR",errorMessage:e instanceof Error?e.message:"Network request failed"},data:null}}}))}get(e,t){return i(this,void 0,void 0,(function*(){let i=e;if(t){const e=new URLSearchParams(Object.entries(t).reduce(((e,[t,i])=>(null!=i&&(e[t]=String(i)),e)),{})).toString();e&&(i+="?"+e)}return this.request(i,{method:"GET"})}))}post(e,t){return i(this,void 0,void 0,(function*(){const i=t instanceof FormData;return this.request(e,{method:"POST",headers:i?{}:{"Content-Type":"application/json"},body:i?t:JSON.stringify(t)})}))}patch(e,t){return i(this,void 0,void 0,(function*(){return this.request(e,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}))}delete(e){return i(this,void 0,void 0,(function*(){return this.request(e,{method:"DELETE"})}))}put(e,t){return i(this,void 0,void 0,(function*(){return this.request(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}))}}},999:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},879:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},492:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.TotalumApiSdk=t.TotalumError=void 0;const o=i(731),s=i(730),c=i(675),a=i(589),d=i(882),l=i(386),u=i(706),p=i(279);r(i(999),t),r(i(879),t);var f=i(731);Object.defineProperty(t,"TotalumError",{enumerable:!0,get:function(){return f.TotalumError}}),t.TotalumApiSdk=class{constructor(e){var t,i;if(this._baseUrl="https://api.totalum.app/",this.authOptions=e,this._headers={},null===(t=this.authOptions.token)||void 0===t?void 0:t.accessToken)this._headers.authorization=this.authOptions.token.accessToken;else{if(!(null===(i=this.authOptions.apiKey)||void 0===i?void 0:i["api-key"]))throw new Error("Error: invalid auth options");this._headers["api-key"]=this.authOptions.apiKey["api-key"]}this.authOptions.baseUrl&&(this._baseUrl=this.authOptions.baseUrl),this.authOptions.fromEvent&&(this._headers.fromEvent="true"),this.setRequestData()}changeBaseUrl(e){this._baseUrl=e,this.setRequestData()}setRequestData(){this.client=new o.FetchClient(this._baseUrl,this._headers),this.crud=new d.CrudService(this.client),this.openai=new s.OpenaiService(this.client),this.files=new a.FilesService(this.client),this.filter=new c.FilterService(this.client),this.notification=new l.NotificationService(this.client),this.statistic=new u.StatisticService(this.client),this.email=new p.EmailService(this.client)}}},882:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CrudService=void 0;const r=i(591),o=i(429);t.CrudService=class{constructor(e){this.client=e}getRecordById(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.getObjectById,{typeId:e,id:t});return this.client.get(i)}))}getHistoricRecordUpdatesById(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.updatesRecord.getUpdateRecordByObjectId,{objectId:e});return this.client.get(t)}))}getRecords(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.getObjects,{typeId:e});return this.client.post(i,t)}))}getNestedData(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.getNestedData);return this.client.post(i,{nestedQuery:e,options:t})}))}deleteRecordById(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.deleteObject,{typeId:e,id:t});return this.client.delete(i)}))}editRecordById(e,t,i){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.crud.editObjectProperties,{typeId:e,id:t});return this.client.request(n,{method:"PATCH",headers:{"Content-Type":"application/json",returnoption:"fullrecord"},body:JSON.stringify(i)})}))}createRecord(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.crud.createObject,{typeId:e});return this.client.request(i,{method:"POST",headers:{"Content-Type":"application/json",returnoption:"fullrecord"},body:JSON.stringify(t)})}))}addManyToManyReferenceRecord(e,t,i,s){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.crud.addManyToManyReference,{typeId:e,id:t});return this.client.patch(n,{propertyId:i,referenceId:s})}))}dropManyToManyReferenceRecord(e,t,i,s){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.crud.dropManyToManyReference,{typeId:e,id:t});return this.client.patch(n,{propertyId:i,referenceId:s})}))}getManyToManyReferencesRecords(e,t,i,s){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.crud.getManyToManyReferencesItems,{typeId:e,id:t,propertyName:i});return this.client.get(n,s)}))}}},279:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.EmailService=void 0;const r=i(429),o=i(591);t.EmailService=class{constructor(e){this.client=e}sendEmail(e){return n(this,void 0,void 0,(function*(){if(e.attachments&&e.attachments.length>10)return{errors:{errorCode:"TOO_MANY_ATTACHMENTS",errorMessage:`Maximum number of attachments is 10. Received ${e.attachments.length}.`},data:null};if(e.attachments)for(const t of e.attachments){if(!t.url||"string"!=typeof t.url)return{errors:{errorCode:"INVALID_ATTACHMENT_URL",errorMessage:`Attachment ${t.filename} must have a valid URL`},data:null};if(!t.url.startsWith("http://")&&!t.url.startsWith("https://"))return{errors:{errorCode:"INVALID_ATTACHMENT_URL",errorMessage:`Attachment ${t.filename} must have a valid HTTP/HTTPS URL`},data:null}}return this.sendEmailWithDefaultDomain(e)}))}sendEmailWithDefaultDomain(e){return n(this,void 0,void 0,(function*(){const t=o.UtilsService.getUrl("",r.endpoints.email.sendEmail,{});return this.client.post(t,e)}))}}},589:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FilesService=void 0;const r=i(591),o=i(429);t.FilesService=class{constructor(e){this.client=e}uploadFile(e,t){return n(this,void 0,void 0,(function*(){let i=r.UtilsService.getUrl("",o.endpoints.files.uploadFile);return(null==t?void 0:t.compressFile)&&(i+="?compressFile=true"),this.client.post(i,e)}))}deleteFile(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.files.deleteFile,{fileName:e});return this.client.delete(t)}))}getDownloadUrl(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.files.getDownloadUrl,{fileName:e});return this.client.get(i,t)}))}generatePdfByTemplate(e,t,i){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.pdfTemplate.generatePdfByTemplate,{id:e});return this.client.post(n,{templateId:e,variables:t,name:i})}))}createPdfFromHtml(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.pdfTemplate.createPdfFromHtml);let i;return i="undefined"==typeof window?Buffer.from(e.html,"utf-8").toString("base64"):btoa(unescape(encodeURIComponent(e.html))),this.client.post(t,{base64HtmlString:i,name:e.name})}))}ocrOfImage(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.files.ocrOfImage);return this.client.post(t,{fileName:e})}))}ocrOfPdf(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.files.ocrOfPdf);return this.client.post(t,{fileName:e})}))}scanInvoice(e,t){return n(this,void 0,void 0,(function*(){const i=r.UtilsService.getUrl("",o.endpoints.files.scanInvoice);return this.client.post(i,{fileName:e,options:t})}))}scanDocument(e,t,i){return n(this,void 0,void 0,(function*(){const n=r.UtilsService.getUrl("",o.endpoints.files.scanDocument);return this.client.post(n,{fileName:e,properties:t,options:i})}))}}},675:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FilterService=void 0;const r=i(429),o=i(591);t.FilterService=class{constructor(e){this.client=e}lookUpFilter(e,t,i,s){return n(this,void 0,void 0,(function*(){const n=o.UtilsService.getUrl("",r.endpoints.filter.lookUpFilter,{idPage:e}),c={query:encodeURIComponent(JSON.stringify(t)),idsOfMultipleNodesToSearch:i?encodeURIComponent(JSON.stringify(i)):void 0,returnCount:null==s?void 0:s.toString()};return this.client.get(n,c)}))}nestedFilter(e,t,i){return n(this,void 0,void 0,(function*(){const n=o.UtilsService.getUrl("",r.endpoints.filter.nestedFilter,{}),s={nestedFilter:e,tableNameToGetResults:t,filterOptions:i};return this.client.post(n,s)}))}runCustomMongoAggregationQuery(e,t){return n(this,void 0,void 0,(function*(){const i=o.UtilsService.getUrl("",r.endpoints.filter.runCustomAggregationQuery),n={customMongoQuery:t,type:e};return this.client.post(i,n)}))}}},386:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.NotificationService=void 0;const r=i(429),o=i(591);t.NotificationService=class{constructor(e){this.client=e}createNotification(e){return n(this,void 0,void 0,(function*(){const t=o.UtilsService.getUrl("",r.endpoints.notifications.createNotification,{});return this.client.post(t,{notification:e})}))}}},730:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.OpenaiService=void 0;const r=i(591),o=i(429);t.OpenaiService=class{constructor(e){this.client=e}createCompletion(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.openai.createCompletion);return this.client.post(t,e)}))}createChatCompletion(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.openai.createChatCompletion);return this.client.post(t,e)}))}generateImage(e){return n(this,void 0,void 0,(function*(){const t=r.UtilsService.getUrl("",o.endpoints.openai.generateImage);return this.client.post(t,e)}))}}},706:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,o){function s(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.StatisticService=void 0;const r=i(429),o=i(591);t.StatisticService=class{constructor(e){this.client=e}getStatistic(e,t){return n(this,void 0,void 0,(function*(){const i=o.UtilsService.getUrl("",r.endpoints.statistics.getStatistic,{}),n={query:e,options:t};return this.client.post(i,n)}))}}},591:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UtilsService=void 0,t.UtilsService=class{static getUrl(e,t,i){let n=e+t;for(const e in i)n=n.replace(`:${e}`,i[e]);return n}}}},t={};return function i(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,i),o.exports}(492)})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totalum-api-sdk",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Totalum sdk wrapper and utils of totalum api",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",