totalum-api-sdk 2.0.21 → 2.0.22

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.
@@ -1,44 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.endpoints = void 0;
4
- // ENDPOINTS
5
- exports.endpoints = {
6
- crud: {
7
- getObjectById: 'api/v1/crud/:typeId/:id',
8
- getObjects: 'api/v1/crud/:typeId',
9
- createObject: 'api/v1/crud/:typeId',
10
- editObjectProperties: 'api/v1/crud/:typeId/:id',
11
- deleteObject: 'api/v1/crud/:typeId/:id',
12
- deleteObjectAndSubElements: 'api/v1/crud/:typeId/:id/:pageId/subelements',
13
- updateLastUsersActions: 'api/v1/crud/:typeId/:id/lastUsersActions',
14
- addManyToManyReference: 'api/v1/crud/:typeId/:id/add-many-to-many-reference',
15
- dropManyToManyReference: 'api/v1/crud/:typeId/:id/drop-many-to-many-reference',
16
- getManyToManyReferencesItems: 'api/v1/crud/:typeId/:id/:propertyName', //currently only used for many to many references
17
- },
18
- files: {
19
- uploadFile: 'api/v1/files/upload',
20
- getDownloadUrl: 'api/v1/files/download/:fileName',
21
- deleteFile: 'api/v1/files/:fileName',
22
- ocrOfImage: 'api/v1/files/ocr/image',
23
- ocrOfPdf: 'api/v1/files/ocr/pdf'
24
- },
25
- filter: {
26
- lookUpFilter: 'api/v1/filter/:idPage',
27
- customMongoFilter: 'api/v1/filter/custom-mongo-filter',
28
- runCustomAggregationQuery: 'api/v1/filter/custom-mongo-aggregation-query'
29
- },
30
- pdfTemplate: {
31
- generatePdfByTemplate: 'api/v1/pdf-template/generatePdfByTemplate/:id'
32
- },
33
- googleIntegration: {
34
- getEmails: 'api/v1/google-integration/get-emails',
35
- sendEmail: 'api/v1/google-integration/send-email',
36
- getCalendarEvents: 'api/v1/google-integration/get-calendar-events',
37
- createCalendarEvent: 'api/v1/google-integration/create-calendar-event',
38
- },
39
- openai: {
40
- createCompletion: 'api/v1/openai/completion',
41
- createChatCompletion: 'api/v1/openai/chat-completion',
42
- generateImage: 'api/v1/openai/image',
43
- }
44
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.endpoints = void 0;
4
+ // ENDPOINTS
5
+ exports.endpoints = {
6
+ crud: {
7
+ getObjectById: 'api/v1/crud/:typeId/:id',
8
+ getObjects: 'api/v1/crud/:typeId',
9
+ createObject: 'api/v1/crud/:typeId',
10
+ editObjectProperties: 'api/v1/crud/:typeId/:id',
11
+ deleteObject: 'api/v1/crud/:typeId/:id',
12
+ deleteObjectAndSubElements: 'api/v1/crud/:typeId/:id/:pageId/subelements',
13
+ updateLastUsersActions: 'api/v1/crud/:typeId/:id/lastUsersActions',
14
+ addManyToManyReference: 'api/v1/crud/:typeId/:id/add-many-to-many-reference',
15
+ dropManyToManyReference: 'api/v1/crud/:typeId/:id/drop-many-to-many-reference',
16
+ getManyToManyReferencesItems: 'api/v1/crud/:typeId/:id/:propertyName', //currently only used for many to many references
17
+ },
18
+ files: {
19
+ uploadFile: 'api/v1/files/upload',
20
+ getDownloadUrl: 'api/v1/files/download/:fileName',
21
+ deleteFile: 'api/v1/files/:fileName',
22
+ ocrOfImage: 'api/v1/files/ocr/image',
23
+ ocrOfPdf: 'api/v1/files/ocr/pdf'
24
+ },
25
+ filter: {
26
+ lookUpFilter: 'api/v1/filter/:idPage',
27
+ customMongoFilter: 'api/v1/filter/custom-mongo-filter',
28
+ runCustomAggregationQuery: 'api/v1/filter/custom-mongo-aggregation-query'
29
+ },
30
+ pdfTemplate: {
31
+ generatePdfByTemplate: 'api/v1/pdf-template/generatePdfByTemplate/:id'
32
+ },
33
+ googleIntegration: {
34
+ getEmails: 'api/v1/google-integration/get-emails',
35
+ sendEmail: 'api/v1/google-integration/send-email',
36
+ getCalendarEvents: 'api/v1/google-integration/get-calendar-events',
37
+ createCalendarEvent: 'api/v1/google-integration/create-calendar-event',
38
+ },
39
+ openai: {
40
+ createCompletion: 'api/v1/openai/completion',
41
+ createChatCompletion: 'api/v1/openai/chat-completion',
42
+ generateImage: 'api/v1/openai/image',
43
+ }
44
+ };
@@ -1,3 +1,3 @@
1
- "use strict";
2
- //INTERFACES
3
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ //INTERFACES
3
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.js CHANGED
@@ -1,58 +1,58 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.TotalumApiSdk = void 0;
18
- const OpenaiService_1 = require("./services/OpenaiService");
19
- const FilterService_1 = require("./services/FilterService");
20
- const FilesService_1 = require("./services/FilesService");
21
- const CrudService_1 = require("./services/CrudService");
22
- __exportStar(require("./common/interfaces"), exports);
23
- class TotalumApiSdk {
24
- constructor(authOptions) {
25
- var _a, _b;
26
- this._baseUrl = 'https://api.totalum.app/';
27
- this.authOptions = authOptions;
28
- if ((_a = this.authOptions.token) === null || _a === void 0 ? void 0 : _a.accessToken) {
29
- this._headers = {
30
- authorization: this.authOptions.token.accessToken
31
- };
32
- }
33
- else if ((_b = this.authOptions.apiKey) === null || _b === void 0 ? void 0 : _b['api-key']) {
34
- this._headers = {
35
- 'api-key': this.authOptions.apiKey['api-key'],
36
- };
37
- }
38
- else {
39
- throw new Error('Error: invalid auth options');
40
- }
41
- if (this.authOptions.baseUrl) {
42
- this._baseUrl = this.authOptions.baseUrl;
43
- }
44
- this.setRequestData();
45
- }
46
- changeBaseUrl(newBaseUrl) {
47
- this._baseUrl = newBaseUrl;
48
- //update services with new implementation
49
- this.setRequestData();
50
- }
51
- setRequestData() {
52
- this.crud = new CrudService_1.CrudService(this._baseUrl, this._headers);
53
- this.openai = new OpenaiService_1.OpenaiService(this._baseUrl, this._headers);
54
- this.files = new FilesService_1.FilesService(this._baseUrl, this._headers);
55
- this.filter = new FilterService_1.FilterService(this._baseUrl, this._headers);
56
- }
57
- }
58
- exports.TotalumApiSdk = TotalumApiSdk;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TotalumApiSdk = void 0;
18
+ const OpenaiService_1 = require("./services/OpenaiService");
19
+ const FilterService_1 = require("./services/FilterService");
20
+ const FilesService_1 = require("./services/FilesService");
21
+ const CrudService_1 = require("./services/CrudService");
22
+ __exportStar(require("./common/interfaces"), exports);
23
+ class TotalumApiSdk {
24
+ constructor(authOptions) {
25
+ var _a, _b;
26
+ this._baseUrl = 'https://api.totalum.app/';
27
+ this.authOptions = authOptions;
28
+ if ((_a = this.authOptions.token) === null || _a === void 0 ? void 0 : _a.accessToken) {
29
+ this._headers = {
30
+ authorization: this.authOptions.token.accessToken
31
+ };
32
+ }
33
+ else if ((_b = this.authOptions.apiKey) === null || _b === void 0 ? void 0 : _b['api-key']) {
34
+ this._headers = {
35
+ 'api-key': this.authOptions.apiKey['api-key'],
36
+ };
37
+ }
38
+ else {
39
+ throw new Error('Error: invalid auth options');
40
+ }
41
+ if (this.authOptions.baseUrl) {
42
+ this._baseUrl = this.authOptions.baseUrl;
43
+ }
44
+ this.setRequestData();
45
+ }
46
+ changeBaseUrl(newBaseUrl) {
47
+ this._baseUrl = newBaseUrl;
48
+ //update services with new implementation
49
+ this.setRequestData();
50
+ }
51
+ setRequestData() {
52
+ this.crud = new CrudService_1.CrudService(this._baseUrl, this._headers);
53
+ this.openai = new OpenaiService_1.OpenaiService(this._baseUrl, this._headers);
54
+ this.files = new FilesService_1.FilesService(this._baseUrl, this._headers);
55
+ this.filter = new FilterService_1.FilterService(this._baseUrl, this._headers);
56
+ }
57
+ }
58
+ exports.TotalumApiSdk = TotalumApiSdk;
@@ -1,93 +1,93 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CrudService = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const utils_1 = require("../utils");
18
- const endpoints_1 = require("../common/endpoints");
19
- class CrudService {
20
- constructor(baseUrl, headers) {
21
- this.headers = headers;
22
- this.baseUrl = baseUrl;
23
- }
24
- getItemById(itemType, id) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.getObjectById, { typeId: itemType, id });
27
- return axios_1.default.get(url, { headers: this.headers });
28
- });
29
- }
30
- getItems(itemType, query) {
31
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.getObjects, { typeId: itemType });
32
- return axios_1.default.get(url, { params: query, headers: this.headers });
33
- }
34
- deleteItemById(itemType, id) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.deleteObject, { typeId: itemType, id });
37
- return axios_1.default.delete(url, { headers: this.headers });
38
- });
39
- }
40
- editItemById(itemType, id, properties) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.editObjectProperties, { typeId: itemType, id });
43
- return axios_1.default.patch(url, properties, { headers: this.headers });
44
- });
45
- }
46
- createItem(itemType, item) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.createObject, { typeId: itemType });
49
- return axios_1.default.post(url, item, { headers: this.headers });
50
- });
51
- }
52
- // many to many functions
53
- /**
54
- *
55
- * @param typeId the type id of the item (table name)
56
- * @param id the id of the item that we want to add a many to many reference
57
- * @param propertyId the property that we want to add a many to many reference
58
- * @param referenceId the id of the item that we want to add as a many to many reference
59
- */
60
- addManyToManyReferenceItem(type, id, propertyName, referenceId) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.addManyToManyReference, { typeId: type, id });
63
- return axios_1.default.patch(url, { propertyId: propertyName, referenceId }, { headers: this.headers });
64
- });
65
- }
66
- /**
67
- *
68
- * @param typeId the type id of the item (table name)
69
- * @param id the id of the item that we want to drop a many to many reference
70
- * @param propertyId the property that we want to drop a many to many reference
71
- * @param referenceId the id of the item that we want to drop as a many to many reference
72
- */
73
- dropManyToManyReferenceItem(type, id, propertyName, referenceId) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.dropManyToManyReference, { typeId: type, id });
76
- return axios_1.default.patch(url, { propertyId: propertyName, referenceId }, { headers: this.headers });
77
- });
78
- }
79
- /**
80
- *
81
- * @param typeId the type id of the item (table name)
82
- * @param id the id of the item that we want to get many to many references
83
- * @param propertyName the property that we want to get many to many references
84
- * @param query the query to filter and sort the results
85
- */
86
- getManyToManyReferencesItems(type, id, propertyName, query) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.getManyToManyReferencesItems, { typeId: type, id, propertyName });
89
- return axios_1.default.get(url, { params: query, headers: this.headers });
90
- });
91
- }
92
- }
93
- exports.CrudService = CrudService;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CrudService = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const utils_1 = require("../utils");
18
+ const endpoints_1 = require("../common/endpoints");
19
+ class CrudService {
20
+ constructor(baseUrl, headers) {
21
+ this.headers = headers;
22
+ this.baseUrl = baseUrl;
23
+ }
24
+ getItemById(itemType, id) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.getObjectById, { typeId: itemType, id });
27
+ return axios_1.default.get(url, { headers: this.headers });
28
+ });
29
+ }
30
+ getItems(itemType, query) {
31
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.getObjects, { typeId: itemType });
32
+ return axios_1.default.get(url, { params: query, headers: this.headers });
33
+ }
34
+ deleteItemById(itemType, id) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.deleteObject, { typeId: itemType, id });
37
+ return axios_1.default.delete(url, { headers: this.headers });
38
+ });
39
+ }
40
+ editItemById(itemType, id, properties) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.editObjectProperties, { typeId: itemType, id });
43
+ return axios_1.default.patch(url, properties, { headers: this.headers });
44
+ });
45
+ }
46
+ createItem(itemType, item) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.createObject, { typeId: itemType });
49
+ return axios_1.default.post(url, item, { headers: this.headers });
50
+ });
51
+ }
52
+ // many to many functions
53
+ /**
54
+ *
55
+ * @param typeId the type id of the item (table name)
56
+ * @param id the id of the item that we want to add a many to many reference
57
+ * @param propertyId the property that we want to add a many to many reference
58
+ * @param referenceId the id of the item that we want to add as a many to many reference
59
+ */
60
+ addManyToManyReferenceItem(type, id, propertyName, referenceId) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.addManyToManyReference, { typeId: type, id });
63
+ return axios_1.default.patch(url, { propertyId: propertyName, referenceId }, { headers: this.headers });
64
+ });
65
+ }
66
+ /**
67
+ *
68
+ * @param typeId the type id of the item (table name)
69
+ * @param id the id of the item that we want to drop a many to many reference
70
+ * @param propertyId the property that we want to drop a many to many reference
71
+ * @param referenceId the id of the item that we want to drop as a many to many reference
72
+ */
73
+ dropManyToManyReferenceItem(type, id, propertyName, referenceId) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.dropManyToManyReference, { typeId: type, id });
76
+ return axios_1.default.patch(url, { propertyId: propertyName, referenceId }, { headers: this.headers });
77
+ });
78
+ }
79
+ /**
80
+ *
81
+ * @param typeId the type id of the item (table name)
82
+ * @param id the id of the item that we want to get many to many references
83
+ * @param propertyName the property that we want to get many to many references
84
+ * @param query the query to filter and sort the results
85
+ */
86
+ getManyToManyReferencesItems(type, id, propertyName, query) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.crud.getManyToManyReferencesItems, { typeId: type, id, propertyName });
89
+ return axios_1.default.get(url, { params: query, headers: this.headers });
90
+ });
91
+ }
92
+ }
93
+ exports.CrudService = CrudService;
@@ -1,61 +1,61 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.FilesService = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const utils_1 = require("../utils");
18
- const endpoints_1 = require("../common/endpoints");
19
- class FilesService {
20
- constructor(baseUrl, headers) {
21
- this.headers = headers;
22
- this.baseUrl = baseUrl;
23
- }
24
- uploadFile(fileFormData) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.uploadFile);
27
- return axios_1.default.post(url, fileFormData, { headers: this.headers });
28
- });
29
- }
30
- /**
31
- *
32
- * @param fileName
33
- * @param options options.expirationTime - is the time in milliseconds that the signed URL should be valid for. The default is 128 hours
34
- * @returns
35
- */
36
- getDownloadUrl(fileName, options) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.getDownloadUrl, { fileName });
39
- return axios_1.default.get(url, { headers: this.headers, params: options });
40
- });
41
- }
42
- generatePdfByTemplate(id, variables, name) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.pdfTemplate.generatePdfByTemplate, { id });
45
- return axios_1.default.post(url, { templateId: id, variables, name }, { headers: this.headers });
46
- });
47
- }
48
- ocrOfImage(fileName) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.ocrOfImage);
51
- return axios_1.default.post(url, { fileName }, { headers: this.headers });
52
- });
53
- }
54
- ocrOfPdf(fileName) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.ocrOfPdf);
57
- return axios_1.default.post(url, { fileName }, { headers: this.headers });
58
- });
59
- }
60
- }
61
- exports.FilesService = FilesService;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FilesService = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const utils_1 = require("../utils");
18
+ const endpoints_1 = require("../common/endpoints");
19
+ class FilesService {
20
+ constructor(baseUrl, headers) {
21
+ this.headers = headers;
22
+ this.baseUrl = baseUrl;
23
+ }
24
+ uploadFile(fileFormData) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.uploadFile);
27
+ return axios_1.default.post(url, fileFormData, { headers: this.headers });
28
+ });
29
+ }
30
+ /**
31
+ *
32
+ * @param fileName
33
+ * @param options options.expirationTime - is the time in milliseconds that the signed URL should be valid for. The default is 128 hours
34
+ * @returns
35
+ */
36
+ getDownloadUrl(fileName, options) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.getDownloadUrl, { fileName });
39
+ return axios_1.default.get(url, { headers: this.headers, params: options });
40
+ });
41
+ }
42
+ generatePdfByTemplate(id, variables, name) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.pdfTemplate.generatePdfByTemplate, { id });
45
+ return axios_1.default.post(url, { templateId: id, variables, name }, { headers: this.headers });
46
+ });
47
+ }
48
+ ocrOfImage(fileName) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.ocrOfImage);
51
+ return axios_1.default.post(url, { fileName }, { headers: this.headers });
52
+ });
53
+ }
54
+ ocrOfPdf(fileName) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.ocrOfPdf);
57
+ return axios_1.default.post(url, { fileName }, { headers: this.headers });
58
+ });
59
+ }
60
+ }
61
+ exports.FilesService = FilesService;
@@ -1,49 +1,49 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.FilterService = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const endpoints_1 = require("../common/endpoints");
18
- const utils_1 = require("../utils");
19
- class FilterService {
20
- constructor(baseUrl, headers) {
21
- this.headers = headers;
22
- this.baseUrl = baseUrl;
23
- }
24
- /*public async customMongoFilter(customMongoFilter: string, rootTypeId: string, typeIdToGet: string, options?: { variables?: any, pagination?: any, sort?: any, returnCount?: boolean }) {
25
- const url = UtilsService.getUrl(this.baseUrl, endpoints.filter.customMongoFilter, {});
26
- const body = { sort: options?.sort, variables: options?.variables, customMongoFilter, pagination: options?.pagination, rootTypeId, typeIdToGet };
27
- const params = options?.returnCount ? { returnCount: options?.returnCount } : null;
28
- return axios.post(url, body, { params: params, headers: this.headers });
29
- }*/
30
- lookUpFilter(idPage, query, idsOfMultipleNodesToSearch, returnCount) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.filter.lookUpFilter, { idPage });
33
- const params = {
34
- query: encodeURIComponent(JSON.stringify(query)),
35
- idsOfMultipleNodesToSearch: encodeURIComponent(JSON.stringify(idsOfMultipleNodesToSearch)),
36
- returnCount: returnCount,
37
- };
38
- return axios_1.default.get(url, { params: params, headers: this.headers });
39
- });
40
- }
41
- runCustomMongoAggregationQuery(type, customMongoQuery) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.filter.runCustomAggregationQuery);
44
- const body = { customMongoQuery, type };
45
- return axios_1.default.post(url, body, { headers: this.headers });
46
- });
47
- }
48
- }
49
- exports.FilterService = FilterService;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FilterService = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const endpoints_1 = require("../common/endpoints");
18
+ const utils_1 = require("../utils");
19
+ class FilterService {
20
+ constructor(baseUrl, headers) {
21
+ this.headers = headers;
22
+ this.baseUrl = baseUrl;
23
+ }
24
+ /*public async customMongoFilter(customMongoFilter: string, rootTypeId: string, typeIdToGet: string, options?: { variables?: any, pagination?: any, sort?: any, returnCount?: boolean }) {
25
+ const url = UtilsService.getUrl(this.baseUrl, endpoints.filter.customMongoFilter, {});
26
+ const body = { sort: options?.sort, variables: options?.variables, customMongoFilter, pagination: options?.pagination, rootTypeId, typeIdToGet };
27
+ const params = options?.returnCount ? { returnCount: options?.returnCount } : null;
28
+ return axios.post(url, body, { params: params, headers: this.headers });
29
+ }*/
30
+ lookUpFilter(idPage, query, idsOfMultipleNodesToSearch, returnCount) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.filter.lookUpFilter, { idPage });
33
+ const params = {
34
+ query: encodeURIComponent(JSON.stringify(query)),
35
+ idsOfMultipleNodesToSearch: encodeURIComponent(JSON.stringify(idsOfMultipleNodesToSearch)),
36
+ returnCount: returnCount,
37
+ };
38
+ return axios_1.default.get(url, { params: params, headers: this.headers });
39
+ });
40
+ }
41
+ runCustomMongoAggregationQuery(type, customMongoQuery) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.filter.runCustomAggregationQuery);
44
+ const body = { customMongoQuery, type };
45
+ return axios_1.default.post(url, body, { headers: this.headers });
46
+ });
47
+ }
48
+ }
49
+ exports.FilterService = FilterService;