pangea-server 3.3.154 → 3.3.156

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.
@@ -67,10 +67,10 @@ class FileStorage {
67
67
  if (previousFile)
68
68
  await this.DeleteFile(previousFile);
69
69
  if (Buffer.isBuffer(file))
70
- return uploadFile(file, { folder, fileType: 'application/octet-stream' });
70
+ return uploadFile(file, { folder, fileType: getBufferMimeType(file) });
71
71
  if (typeof file === 'string') {
72
72
  const buffer = await promises_1.default.readFile(path_1.default.join(process.cwd(), file));
73
- return uploadFile(buffer, { folder, fileType: 'application/octet-stream' });
73
+ return uploadFile(buffer, { folder, fileType: getBufferMimeType(buffer) });
74
74
  }
75
75
  const stream = fs_1.default.createReadStream(file.path);
76
76
  try {
@@ -102,7 +102,6 @@ class FileStorage {
102
102
  exports.FileStorage = FileStorage;
103
103
  // internal functions
104
104
  function getGeneralUploadParams(config) {
105
- console.log(config.fileType);
106
105
  const extension = mimeExtensions[config.fileType];
107
106
  const suffix = extension ? `.${extension}` : '';
108
107
  const fileName = `${config.folder}/${(0, random_helpers_1.getRandomString)('short')}${suffix}`;
@@ -114,3 +113,20 @@ async function uploadFile(body, config) {
114
113
  (0, print_helpers_1.printInfo)('file', `file uploaded to ${res.Location}`);
115
114
  return params.Key;
116
115
  }
116
+ function getBufferMimeType(buffer) {
117
+ if (buffer.toString('ascii', 0, 4) === '%PDF')
118
+ return 'application/pdf';
119
+ if (buffer[0] === 0x89 && buffer.toString('ascii', 1, 4) === 'PNG')
120
+ return 'image/png';
121
+ if (buffer[0] === 0xff && buffer[1] === 0xd8 && buffer[2] === 0xff)
122
+ return 'image/jpeg';
123
+ if (buffer.toString('ascii', 0, 4) === 'GIF8')
124
+ return 'image/gif';
125
+ if (buffer.toString('ascii', 0, 4) === 'RIFF' && buffer.toString('ascii', 8, 12) === 'WEBP')
126
+ return 'image/webp';
127
+ if (buffer[0] === 0x1a && buffer[1] === 0x45 && buffer[2] === 0xdf && buffer[3] === 0xa3)
128
+ return 'video/webm';
129
+ if (buffer.toString('ascii', 4, 8) === 'ftyp')
130
+ return 'video/mp4';
131
+ return 'application/octet-stream';
132
+ }
@@ -1,7 +1,7 @@
1
1
  type GetEventsOptions = {
2
- maxresults?: number;
3
- timemin?: Date;
4
- timemax?: Date;
2
+ maxResults?: number;
3
+ timeMin?: Date;
4
+ timeMax?: Date;
5
5
  query?: string;
6
6
  };
7
7
  type CreateEventOptions = {
@@ -13,24 +13,17 @@ type CreateEventOptions = {
13
13
  attendees?: string[];
14
14
  meet?: boolean;
15
15
  };
16
- type UpdateEventOptions = {
17
- title?: string;
18
- description?: string;
19
- location?: string;
20
- start?: Date;
21
- end?: Date;
22
- attendees?: string[];
23
- };
16
+ type UpdateEventOptions = Partial<Omit<CreateEventOptions, 'meet'>>;
24
17
  export declare class GoogleCalendar {
25
18
  private __calendar;
26
- constructor({ accesstoken, refreshtoken }: {
27
- accesstoken: string;
28
- refreshtoken: string;
19
+ constructor({ accessToken, refreshToken }: {
20
+ accessToken: string;
21
+ refreshToken: string;
29
22
  });
30
- static GetAuthUrl(redirectTo: string): Promise<string>;
23
+ static GetAuthUrl(redirectTo: string): string;
31
24
  static GetTokens(code: string, redirectTo: string): Promise<{
32
- accesstoken: string;
33
- refreshtoken: string;
25
+ accessToken: string;
26
+ refreshToken: string;
34
27
  }>;
35
28
  getEvent(eventId: string): Promise<{
36
29
  id: string;
@@ -6,20 +6,20 @@ const googleapis_1 = require("googleapis");
6
6
  const helpers_1 = require("../helpers");
7
7
  const scopes = ['https://www.googleapis.com/auth/calendar.events'];
8
8
  class GoogleCalendar {
9
- constructor({ accesstoken, refreshtoken }) {
9
+ constructor({ accessToken, refreshToken }) {
10
10
  const auth = getOAuth2();
11
- auth.setCredentials({ access_token: accesstoken, refresh_token: refreshtoken });
11
+ auth.setCredentials({ access_token: accessToken, refresh_token: refreshToken });
12
12
  this.__calendar = googleapis_1.google.calendar({ version: 'v3', auth });
13
13
  }
14
14
  // class methods
15
- static async GetAuthUrl(redirectTo) {
15
+ static GetAuthUrl(redirectTo) {
16
16
  const auth = getOAuth2();
17
17
  return auth.generateAuthUrl({ access_type: 'offline', prompt: 'consent', scope: scopes, redirect_uri: redirectTo });
18
18
  }
19
19
  static async GetTokens(code, redirectTo) {
20
20
  const auth = getOAuth2();
21
21
  const { tokens } = await auth.getToken({ code, redirect_uri: redirectTo });
22
- return { accesstoken: tokens.access_token, refreshtoken: tokens.refresh_token };
22
+ return { accessToken: tokens.access_token, refreshToken: tokens.refresh_token };
23
23
  }
24
24
  // methods
25
25
  async getEvent(eventId) {
@@ -29,9 +29,9 @@ class GoogleCalendar {
29
29
  async getEvents(options = {}) {
30
30
  const response = await this.__calendar.events.list({
31
31
  calendarId: 'primary',
32
- maxResults: options.maxresults || 10,
33
- timeMin: options.timemin?.toISOString(),
34
- timeMax: options.timemax?.toISOString(),
32
+ maxResults: options.maxResults || 10,
33
+ timeMin: options.timeMin?.toISOString(),
34
+ timeMax: options.timeMax?.toISOString(),
35
35
  q: options.query,
36
36
  singleEvents: true,
37
37
  orderBy: 'startTime',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.154",
4
+ "version": "3.3.156",
5
5
  "engines": {
6
6
  "node": "22.14.0"
7
7
  },