@social-mail/social-mail-web-server 1.8.6 → 1.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "@aws-sdk/client-s3": "^3.717.0",
23
23
  "@azure/storage-blob": "^12.25.0",
24
24
  "@entity-access/entity-access": "^1.0.499",
25
- "@entity-access/server-pages": "^1.1.502",
25
+ "@entity-access/server-pages": "^1.1.503",
26
26
  "@peculiar/asn1-schema": "^2.3.15",
27
27
  "@social-mail/shared": "^1.0.29",
28
28
  "@socket.io/cluster-adapter": "^0.2.2",
@@ -13,13 +13,8 @@ export default function ensureDir(folder: string) {
13
13
  return;
14
14
  }
15
15
 
16
- const parent = dirname(folder);
17
- if (parent !== "/") {
18
- ensureDir(parent);
19
- }
20
-
21
16
  try {
22
- mkdirSync(folder);
17
+ mkdirSync(folder, { recursive: true});
23
18
  } catch (error) {
24
19
  if (existsSync(folder)) {
25
20
  return;
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-console */
2
- import { Stream } from "stream";
2
+ import { Readable, Stream } from "stream";
3
3
  // import TempFileService, { LocalFile } from "./TempFileService.js";
4
4
  import Inject, { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
5
5
  import SocialMailContext from "../model/SocialMailContext.js";
@@ -43,7 +43,7 @@ export default abstract class BaseStorage {
43
43
 
44
44
  abstract deleteFile(cloudPath: string): Promise<void>;
45
45
 
46
- abstract streamFile(cloudPath: string): Promise<{ contentType: string, stream: Stream }>;
46
+ abstract streamFile(cloudPath: string): Promise<{ contentType: string, stream: Readable }>;
47
47
 
48
48
  async getContentHash(file: LocalFile) {
49
49
  return await this.cryptoService.hashBuffer(file.openRead());
@@ -40,11 +40,11 @@ export default class AzureStorage extends BaseStorage {
40
40
  const blob = this.container.getBlockBlobClient(cloudPath);
41
41
  await blob.deleteIfExists();
42
42
  }
43
- async streamFile(cloudPath: string): Promise<{ contentType: string; stream: Stream; }> {
43
+ async streamFile(cloudPath: string): Promise<{ contentType: string; stream: Readable; }> {
44
44
  const blob = this.container.getBlockBlobClient(cloudPath);
45
45
  const buffer = await blob.download();
46
46
  const contentType = buffer.contentType ?? "application/octet-stream";
47
- return { contentType, stream: buffer.readableStreamBody as any as Stream };
47
+ return { contentType, stream: buffer.readableStreamBody as any as Readable };
48
48
  }
49
49
 
50
50
  }
@@ -1,26 +1,26 @@
1
1
 
2
- import { promisify } from "node:util";
3
- import { pipeline, Stream, Writable } from "node:stream";
2
+ import { Stream, Writable } from "node:stream";
4
3
  import * as zlib from "node:zlib";
5
4
  import { createWriteStream } from "node:fs";
6
-
7
- const pipe = promisify(pipeline);
5
+ import { pipeline } from "node:stream/promises";
8
6
 
9
7
  export default class GZip {
10
8
 
11
- static unzipFile(input: Stream, output: string) {
12
- return new Promise<void>((resolve, reject) => {
13
- const outputStream = createWriteStream(output);
14
- input.pipe(zlib.createGunzip()).pipe(outputStream).on("finish", (error) => error ? reject(error) : resolve());
15
- });
16
- }
17
-
18
-
19
- static unzip(input: Stream, output: Writable) {
20
- return new Promise<void>((resolve, reject) => {
21
- input.pipe(zlib.createGunzip()).pipe(output).on("finish", (error) => error ? reject(error) : resolve());
22
- });
23
- }
9
+ // static unzipFile(input: Stream, output: string) {
10
+ // const outputStream = createWriteStream(output);
11
+ // return pipeline(input, zlib.createGunzip())
12
+ // // return new Promise<void>((resolve, reject) => {
13
+ // // const outputStream = createWriteStream(output);
14
+ // // input.pipe(zlib.createGunzip()).pipe(outputStream).on("finish", (error) => error ? reject(error) : resolve());
15
+ // // });
16
+ // }
17
+
18
+
19
+ // static unzip(input: Stream, output: Writable) {
20
+ // return new Promise<void>((resolve, reject) => {
21
+ // input.pipe(zlib.createGunzip()).pipe(output).on("finish", (error) => error ? reject(error) : resolve());
22
+ // });
23
+ // }
24
24
 
25
25
  static zip(input: Stream) {
26
26
  return input.pipe(zlib.createGzip());
@@ -65,7 +65,7 @@ export default class DbStorage extends BaseStorage {
65
65
  .delete(file, (p) => (x) => x.fileID === p.fileID);
66
66
  }
67
67
 
68
- async streamFile(cloudPath: string): Promise<{ contentType: string; stream: Stream; }> {
68
+ async streamFile(cloudPath: string): Promise<{ contentType: string; stream: Readable; }> {
69
69
  using scope = await this.createScope();
70
70
  const db = scope.resolve(DbStorageContext);
71
71
  const file = await db.dbFiles.where({ cloudPath }, (p) => (x) => x.path === p.cloudPath ).first();
@@ -36,14 +36,14 @@ export default class S3Storage extends BaseStorage {
36
36
  }));
37
37
  }
38
38
 
39
- async streamFile(Key: string): Promise<{ contentType: string, stream: Stream }> {
39
+ async streamFile(Key: string): Promise<{ contentType: string, stream: Readable }> {
40
40
  const r = await this.client.send(new GetObjectCommand({
41
41
  Bucket,
42
42
  Key
43
43
  }));
44
44
  return {
45
45
  contentType: r.ContentType,
46
- stream: r.Body as Stream
46
+ stream: r.Body as Readable
47
47
  } ;
48
48
  }
49
49
 
@@ -5,7 +5,7 @@ import ensureDir from "../../common/FileApi.js";
5
5
 
6
6
 
7
7
  const tmpdir = path.join(globalEnv.tmpDir, "t");
8
- ensureDir(tmpdir);
8
+ // ensureDir(tmpdir);
9
9
  export const tempDiskCache = new BaseDiskCache({
10
10
  root: tmpdir,
11
11
  keepTTLSeconds: 4 * 60 * 60,