totalum-api-sdk 2.0.6 → 2.0.8

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.
@@ -0,0 +1,37 @@
1
+ export declare const endpoints: {
2
+ crud: {
3
+ getObjectById: string;
4
+ getObjects: string;
5
+ createObject: string;
6
+ editObjectProperties: string;
7
+ deleteObject: string;
8
+ deleteObjectAndSubElements: string;
9
+ updateLastUsersActions: string;
10
+ };
11
+ files: {
12
+ uploadFile: string;
13
+ getDownloadUrl: string;
14
+ deleteFile: string;
15
+ ocrOfImage: string;
16
+ ocrOfPdf: string;
17
+ };
18
+ filter: {
19
+ lookUpFilter: string;
20
+ customMongoFilter: string;
21
+ runCustomAggregationQuery: string;
22
+ };
23
+ pdfTemplate: {
24
+ generatePdfByTemplate: string;
25
+ };
26
+ googleIntegration: {
27
+ getEmails: string;
28
+ sendEmail: string;
29
+ getCalendarEvents: string;
30
+ createCalendarEvent: string;
31
+ };
32
+ openai: {
33
+ createCompletion: string;
34
+ createChatCompletion: string;
35
+ generateImage: string;
36
+ };
37
+ };
@@ -1,5 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.endpoints = void 0;
1
4
  // ENDPOINTS
2
- export const endpoints = {
5
+ exports.endpoints = {
3
6
  crud: {
4
7
  getObjectById: 'api/v1/crud/:typeId/:id',
5
8
  getObjects: 'api/v1/crud/:typeId',
@@ -35,4 +38,4 @@ export const endpoints = {
35
38
  createChatCompletion: 'api/v1/openai/chat-completion',
36
39
  generateImage: 'api/v1/openai/image',
37
40
  }
38
- }
41
+ };
@@ -0,0 +1,173 @@
1
+ export interface GoogleCalendarI {
2
+ summary: string;
3
+ location?: string;
4
+ description?: string;
5
+ start: {
6
+ dateTime: string;
7
+ timeZone?: string;
8
+ };
9
+ end: {
10
+ dateTime: string;
11
+ timeZone?: string;
12
+ };
13
+ attendees?: {
14
+ email: string;
15
+ }[];
16
+ reminders?: Reminders;
17
+ }
18
+ interface Reminders {
19
+ useDefault: boolean;
20
+ overrides?: {
21
+ method: string;
22
+ minutes: number;
23
+ }[];
24
+ }
25
+ export interface GoogleCalendarEventsResponseI {
26
+ accessRole: string;
27
+ defaultReminders: {
28
+ method: string;
29
+ minutes: number;
30
+ }[];
31
+ etag: string;
32
+ items: {
33
+ kind: string;
34
+ etag: string;
35
+ id: string;
36
+ attendees?: {
37
+ email: string;
38
+ responseStatus: string;
39
+ }[];
40
+ created: string;
41
+ creator: {
42
+ email: string;
43
+ self?: boolean;
44
+ };
45
+ description: string;
46
+ end: {
47
+ dateTime: string;
48
+ timeZone: string;
49
+ };
50
+ eventType: string;
51
+ htmlLink: string;
52
+ iCalUID: string;
53
+ location: string;
54
+ organizer: {
55
+ email: string;
56
+ self?: boolean;
57
+ };
58
+ reminders: {
59
+ useDefault: boolean;
60
+ };
61
+ sequence: number;
62
+ start: {
63
+ dateTime: string;
64
+ timeZone: string;
65
+ };
66
+ status: string;
67
+ summary: string;
68
+ }[];
69
+ }
70
+ export interface GoogleEmailI {
71
+ to: string;
72
+ subject: string;
73
+ message: string;
74
+ }
75
+ export interface GoogleEmailResponseI {
76
+ id: string;
77
+ threadId: string;
78
+ labelIds: string[];
79
+ snippet: string;
80
+ payload: {
81
+ partId: string;
82
+ mimeType: string;
83
+ filename: string;
84
+ headers: {
85
+ name: string;
86
+ value: string;
87
+ }[];
88
+ body: {
89
+ size: number;
90
+ data: string;
91
+ };
92
+ };
93
+ sizeEstimate: number;
94
+ historyId: string;
95
+ internalDate: string;
96
+ fullText: string;
97
+ }
98
+ export interface StructureLevels {
99
+ id: string;
100
+ typeId: string;
101
+ propertyId?: string;
102
+ children: Array<StructureLevels>;
103
+ }
104
+ export interface FilterSearchQueryI {
105
+ filter?: FiltersArrayI;
106
+ sort?: ISearchQuerySort[];
107
+ pagination?: {
108
+ limit?: number;
109
+ page?: number;
110
+ skip?: number;
111
+ };
112
+ }
113
+ export type FilterLookupSearchQueryI = {
114
+ pagination: {
115
+ limit?: number;
116
+ page?: number;
117
+ skip?: number;
118
+ };
119
+ filters: FilterStructureLevelsI;
120
+ };
121
+ export interface FilterStructureLevelsI extends StructureLevels {
122
+ filters?: FiltersArrayI;
123
+ children: FilterStructureLevelsI[];
124
+ }
125
+ export type FiltersArrayI = Array<ISearchQueryFilterOr | ISearchQueryFilterOptions>;
126
+ export interface ISearchQueryFilterOr {
127
+ or: ISearchQueryFilterOptions[];
128
+ }
129
+ export interface ISearchQuerySort {
130
+ [key: string]: 1 | -1;
131
+ }
132
+ export interface ISearchQueryFilterOptions {
133
+ [key: string]: number | Date | boolean | string | PropertyQueryOptionsI;
134
+ }
135
+ export interface PropertyQueryOptionsI {
136
+ regex?: number | string;
137
+ options?: 'i' | 'm' | 'x' | 's';
138
+ gte?: number | Date;
139
+ lte?: number | Date;
140
+ gt?: number | Date;
141
+ lt?: number | Date;
142
+ }
143
+ export type fieldValuesEnabled = string | number | boolean | Date;
144
+ export interface DataValues {
145
+ typeId: string;
146
+ id: string;
147
+ _id: string;
148
+ properties: DataProperties;
149
+ updates?: string;
150
+ createdAt?: Date;
151
+ updatedAt?: Date;
152
+ lastUsersActions?: {
153
+ [key: string]: any;
154
+ };
155
+ }
156
+ export interface DataProperties {
157
+ [key: string]: fieldValuesEnabled | {
158
+ name: string;
159
+ previousFilename: string;
160
+ };
161
+ }
162
+ export interface AuthOptions {
163
+ token?: {
164
+ accessToken: string;
165
+ };
166
+ apiKey?: {
167
+ apiKey: string;
168
+ apiKeyName: string;
169
+ organizationId: string;
170
+ };
171
+ baseUrl?: string;
172
+ }
173
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ //INTERFACES
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import { AuthOptions } from './common/interfaces';
2
+ import { OpenaiService } from './services/OpenaiService';
3
+ import { GoogleService } from './services/GoogleService';
4
+ import { FilterService } from './services/FilterService';
5
+ import { FilesService } from './services/FilesService';
6
+ import { CrudService } from './services/CrudService';
7
+ export declare class TotalumApiSdk {
8
+ private authOptions;
9
+ private _baseUrl;
10
+ private _headers;
11
+ openai: OpenaiService;
12
+ files: FilesService;
13
+ google: GoogleService;
14
+ filter: FilterService;
15
+ crud: CrudService;
16
+ constructor(authOptions: AuthOptions);
17
+ changeBaseUrl(newBaseUrl: string): void;
18
+ private setRequestData;
19
+ }
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TotalumApiSdk = void 0;
4
+ const OpenaiService_1 = require("./services/OpenaiService");
5
+ const GoogleService_1 = require("./services/GoogleService");
6
+ const FilterService_1 = require("./services/FilterService");
7
+ const FilesService_1 = require("./services/FilesService");
8
+ const CrudService_1 = require("./services/CrudService");
9
+ class TotalumApiSdk {
10
+ constructor(authOptions) {
11
+ var _a, _b, _c;
12
+ this._baseUrl = 'https://api.totalum.app/';
13
+ this.authOptions = authOptions;
14
+ if ((_a = this.authOptions.token) === null || _a === void 0 ? void 0 : _a.accessToken) {
15
+ this._headers = {
16
+ authorization: this.authOptions.token.accessToken
17
+ };
18
+ }
19
+ else if (((_b = this.authOptions.apiKey) === null || _b === void 0 ? void 0 : _b.apiKey) && ((_c = this.authOptions.apiKey) === null || _c === void 0 ? void 0 : _c.organizationId)) {
20
+ this._headers = {
21
+ 'api-key': this.authOptions.apiKey.apiKey,
22
+ 'organization-id': this.authOptions.apiKey.organizationId,
23
+ 'api-key-name': this.authOptions.apiKey.apiKeyName
24
+ };
25
+ }
26
+ else {
27
+ throw new Error('Error: invalid auth options');
28
+ }
29
+ if (this.authOptions.baseUrl) {
30
+ this._baseUrl = this.authOptions.baseUrl;
31
+ }
32
+ this.setRequestData();
33
+ }
34
+ changeBaseUrl(newBaseUrl) {
35
+ this._baseUrl = newBaseUrl;
36
+ //update services with new implementation
37
+ this.setRequestData();
38
+ }
39
+ setRequestData() {
40
+ this.crud = new CrudService_1.CrudService(this._baseUrl, this._headers);
41
+ this.openai = new OpenaiService_1.OpenaiService(this._baseUrl, this._headers);
42
+ this.files = new FilesService_1.FilesService(this._baseUrl, this._headers);
43
+ this.google = new GoogleService_1.GoogleService(this._baseUrl, this._headers);
44
+ this.filter = new FilterService_1.FilterService(this._baseUrl, this._headers);
45
+ }
46
+ }
47
+ exports.TotalumApiSdk = TotalumApiSdk;
@@ -0,0 +1,11 @@
1
+ import { FilterSearchQueryI, DataProperties } from "../common/interfaces";
2
+ export declare class CrudService {
3
+ private headers;
4
+ private baseUrl;
5
+ constructor(baseUrl: string, headers: any);
6
+ getItemById(itemType: string, id: string): Promise<import("axios").AxiosResponse<any, any>>;
7
+ getItems(itemType: string, query?: FilterSearchQueryI): Promise<import("axios").AxiosResponse<any, any>>;
8
+ deleteItemById(itemType: string, id: string): Promise<import("axios").AxiosResponse<any, any>>;
9
+ editItemById(itemType: string, id: string, properties: any): Promise<import("axios").AxiosResponse<any, any>>;
10
+ createItem(itemType: string, item: DataProperties): Promise<import("axios").AxiosResponse<any, any>>;
11
+ }
@@ -0,0 +1,53 @@
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
+ }
53
+ exports.CrudService = CrudService;
@@ -0,0 +1,12 @@
1
+ export declare class FilesService {
2
+ private headers;
3
+ private baseUrl;
4
+ constructor(baseUrl: string, headers: any);
5
+ uploadFile(fileFormData: any): Promise<import("axios").AxiosResponse<any, any>>;
6
+ getDownloadUrl(fileName: string): Promise<import("axios").AxiosResponse<any, any>>;
7
+ generatePdfByTemplate(id: string, variables: {
8
+ [variableName: string]: any;
9
+ }, name: string): Promise<import("axios").AxiosResponse<any, any>>;
10
+ ocrOfImage(fileName: string): Promise<import("axios").AxiosResponse<any, any>>;
11
+ ocrOfPdf(fileName: string): Promise<import("axios").AxiosResponse<any, any>>;
12
+ }
@@ -0,0 +1,55 @@
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
+ getDownloadUrl(fileName) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.getDownloadUrl, { fileName });
33
+ return axios_1.default.get(url, { headers: this.headers });
34
+ });
35
+ }
36
+ generatePdfByTemplate(id, variables, name) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.pdfTemplate.generatePdfByTemplate, { id });
39
+ return axios_1.default.post(url, { templateId: id, variables, name }, { headers: this.headers });
40
+ });
41
+ }
42
+ ocrOfImage(fileName) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.ocrOfImage);
45
+ return axios_1.default.post(url, { fileName }, { headers: this.headers });
46
+ });
47
+ }
48
+ ocrOfPdf(fileName) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.files.ocrOfPdf);
51
+ return axios_1.default.post(url, { fileName }, { headers: this.headers });
52
+ });
53
+ }
54
+ }
55
+ exports.FilesService = FilesService;
@@ -0,0 +1,8 @@
1
+ import { FilterLookupSearchQueryI } from "../common/interfaces";
2
+ export declare class FilterService {
3
+ private headers;
4
+ private baseUrl;
5
+ constructor(baseUrl: string, headers: any);
6
+ lookUpFilter(idPage: string, query: FilterLookupSearchQueryI, idsOfMultipleNodesToSearch?: string[], returnCount?: boolean): Promise<import("axios").AxiosResponse<any, any>>;
7
+ runCustomMongoAggregationQuery(type: string, customMongoQuery: string): Promise<import("axios").AxiosResponse<any, any>>;
8
+ }
@@ -0,0 +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;
@@ -0,0 +1,15 @@
1
+ import { GoogleCalendarI } from "../common/interfaces";
2
+ export declare class GoogleService {
3
+ private headers;
4
+ private baseUrl;
5
+ constructor(baseUrl: string, headers: any);
6
+ getGoogleAccountEmails(accountEmail: string): Promise<import("axios").AxiosResponse<any, any>>;
7
+ googleAccountSendEmail(accountEmail: string, body: {
8
+ to: string;
9
+ subject: string;
10
+ message?: string;
11
+ html?: string;
12
+ }): Promise<import("axios").AxiosResponse<any, any>>;
13
+ getGoogleCalendarEvents(accountEmail: string): Promise<import("axios").AxiosResponse<any, any>>;
14
+ createCalendarEvent(accountEmail: string, body: GoogleCalendarI): Promise<import("axios").AxiosResponse<any, any>>;
15
+ }
@@ -0,0 +1,53 @@
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.GoogleService = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const endpoints_1 = require("../common/endpoints");
18
+ const utils_1 = require("../utils");
19
+ class GoogleService {
20
+ constructor(baseUrl, headers) {
21
+ this.headers = headers;
22
+ this.baseUrl = baseUrl;
23
+ }
24
+ getGoogleAccountEmails(accountEmail) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.googleIntegration.getEmails, {});
27
+ const params = { userEmail: accountEmail };
28
+ return axios_1.default.get(url, { params: params, headers: this.headers });
29
+ });
30
+ }
31
+ googleAccountSendEmail(accountEmail, body) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.googleIntegration.sendEmail, {});
34
+ const params = { userEmail: accountEmail };
35
+ return axios_1.default.post(url, body, { params: params, headers: this.headers });
36
+ });
37
+ }
38
+ getGoogleCalendarEvents(accountEmail) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.googleIntegration.getCalendarEvents, {});
41
+ const params = { userEmail: accountEmail };
42
+ return axios_1.default.get(url, { params: params, headers: this.headers });
43
+ });
44
+ }
45
+ createCalendarEvent(accountEmail, body) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.googleIntegration.createCalendarEvent, {});
48
+ const params = { userEmail: accountEmail };
49
+ return axios_1.default.post(url, body, { params: params, headers: this.headers });
50
+ });
51
+ }
52
+ }
53
+ exports.GoogleService = GoogleService;
@@ -0,0 +1,38 @@
1
+ import { AxiosResponse } from "axios";
2
+ import { Completion } from "openai/resources";
3
+ import { ChatCompletionCreateParamsBase } from "openai/resources/chat/completions";
4
+ import { CompletionCreateParamsBase } from "openai/resources/completions";
5
+ export declare class OpenaiService {
6
+ private headers;
7
+ private baseUrl;
8
+ constructor(baseUrl: string, headers: any);
9
+ /**
10
+ *
11
+ * @param body the openai completion body, more info here: https://platform.openai.com/docs/api-reference/completions/create
12
+ * @returns the completion provided by openai api
13
+ * @deprecated use createChatCompletion instead
14
+ */
15
+ createCompletion(body: CompletionCreateParamsBase): Promise<AxiosResponse<{
16
+ data: Completion;
17
+ }>>;
18
+ /**
19
+ *
20
+ * @param body the openai chat completion body, more info here: https://platform.openai.com/docs/api-reference/chat/create
21
+ * @returns the chat completion provided by openai api
22
+ */
23
+ createChatCompletion(body: ChatCompletionCreateParamsBase): Promise<AxiosResponse<{
24
+ data: Completion;
25
+ }>>;
26
+ /**
27
+ *
28
+ * @param body the openai chat completion body, more info here: https://platform.openai.com/docs/api-reference/chat/create
29
+ * @returns the chat completion provided by openai api
30
+ */
31
+ generateImage(body: {
32
+ prompt: string;
33
+ size: '256x256' | '512x512' | '1024x1024';
34
+ fileName: string;
35
+ }): Promise<AxiosResponse<{
36
+ data: Completion;
37
+ }>>;
38
+ }
@@ -0,0 +1,62 @@
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.OpenaiService = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const utils_1 = require("../utils");
18
+ const endpoints_1 = require("../common/endpoints");
19
+ class OpenaiService {
20
+ constructor(baseUrl, headers) {
21
+ this.headers = headers;
22
+ this.baseUrl = baseUrl;
23
+ }
24
+ /**
25
+ *
26
+ * @param body the openai completion body, more info here: https://platform.openai.com/docs/api-reference/completions/create
27
+ * @returns the completion provided by openai api
28
+ * @deprecated use createChatCompletion instead
29
+ */
30
+ createCompletion(body) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.openai.createCompletion);
33
+ const b = body;
34
+ return axios_1.default.post(url, b, { headers: this.headers });
35
+ });
36
+ }
37
+ /**
38
+ *
39
+ * @param body the openai chat completion body, more info here: https://platform.openai.com/docs/api-reference/chat/create
40
+ * @returns the chat completion provided by openai api
41
+ */
42
+ createChatCompletion(body) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.openai.createChatCompletion);
45
+ const b = body;
46
+ return axios_1.default.post(url, b, { headers: this.headers });
47
+ });
48
+ }
49
+ /**
50
+ *
51
+ * @param body the openai chat completion body, more info here: https://platform.openai.com/docs/api-reference/chat/create
52
+ * @returns the chat completion provided by openai api
53
+ */
54
+ generateImage(body) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const url = utils_1.UtilsService.getUrl(this.baseUrl, endpoints_1.endpoints.openai.generateImage);
57
+ const b = body;
58
+ return axios_1.default.post(url, b, { headers: this.headers });
59
+ });
60
+ }
61
+ }
62
+ exports.OpenaiService = OpenaiService;
@@ -0,0 +1,3 @@
1
+ export declare class UtilsService {
2
+ static getUrl(baseUrl: string, pattern: string, params?: any): string;
3
+ }