diff --git a/apps/server/src/infra/s3-client/s3-client.adapter.spec.ts b/apps/server/src/infra/s3-client/s3-client.adapter.spec.ts index 7986e692ca9..f3d629413ac 100644 --- a/apps/server/src/infra/s3-client/s3-client.adapter.spec.ts +++ b/apps/server/src/infra/s3-client/s3-client.adapter.spec.ts @@ -52,7 +52,7 @@ describe('S3ClientAdapter', () => { }).compile(); service = module.get(S3ClientAdapter); - client = module.get('S3_Client'); + client = module.get(S3_CLIENT); }); afterAll(async () => { @@ -197,7 +197,7 @@ describe('S3ClientAdapter', () => { return { file }; }; - describe('WHEN file is created successfully', () => { + describe.only('WHEN file is created successfully', () => { const setup = () => { const { file } = createFile(); const { pathToFile } = createParameter(); diff --git a/apps/server/src/infra/s3-client/s3-client.adapter.ts b/apps/server/src/infra/s3-client/s3-client.adapter.ts index a7f44aa8936..211d2a012bb 100644 --- a/apps/server/src/infra/s3-client/s3-client.adapter.ts +++ b/apps/server/src/infra/s3-client/s3-client.adapter.ts @@ -8,6 +8,7 @@ import { HeadObjectCommand, HeadObjectCommandOutput, ListObjectsV2Command, + PutObjectCommandInput, S3Client, ServiceOutputTypes, } from '@aws-sdk/client-s3'; @@ -86,12 +87,14 @@ export class S3ClientAdapter { try { this.logger.debug({ action: 'create', params: { path, bucket: this.config.bucket } }); - const req = { + const req: PutObjectCommandInput = { Body: file.data, Bucket: this.config.bucket, Key: path, ContentType: file.mimeType, }; + + console.log(this.client); const upload = new Upload({ client: this.client, params: req, diff --git a/apps/server/src/shared/common/guards/type.guard.ts b/apps/server/src/shared/common/guards/type.guard.ts index 2ab300e0368..38c84b4c87c 100644 --- a/apps/server/src/shared/common/guards/type.guard.ts +++ b/apps/server/src/shared/common/guards/type.guard.ts @@ -89,11 +89,7 @@ export class TypeGuard { /** @return undefined if no object or key do not exists, otherwise the value of the key. */ static getValueFromObjectKey(value: unknown, key: string): unknown { - if (!TypeGuard.checkDefinedObject(value)) { - return undefined; - } - - const result: unknown = (value as object)[key]; + const result: unknown = TypeGuard.isDefinedObject(value) ? value[key] : undefined; return result; } diff --git a/package-lock.json b/package-lock.json index 1a126417ebb..83315365e27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { - "@aws-sdk/lib-storage": "^3.616.0", + "@aws-sdk/lib-storage": "^3.617.0", "@feathersjs/adapter-commons": "^5.0.12", "@feathersjs/authentication": "^5.0.12", "@feathersjs/authentication-local": "^5.0.12", @@ -147,7 +147,7 @@ "yjs": "^13.6.11" }, "devDependencies": { - "@aws-sdk/client-s3": "^3.352.0", + "@aws-sdk/client-s3": "^3.617.0", "@faker-js/faker": "^8.0.2", "@feathersjs/adapter-tests": "^5.0.12", "@golevelup/ts-jest": "^0.3.4", @@ -709,9 +709,9 @@ } }, "node_modules/@aws-sdk/client-s3": { - "version": "3.616.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.616.0.tgz", - "integrity": "sha512-6gyZnBlAgOU8cwNqPhFO9s6maGI4/iHV3cmqvQgUn3uqhi1EgTSZSsTMuRzKEgBpTGgC+9Bm6djKqOderMqjdA==", + "version": "3.617.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.617.0.tgz", + "integrity": "sha512-0f954CU42BhPFVRQCCBc1jAvV9N4XW9I3D4h7tJ8tzxft7fS62MSJkgxRIXNKgWKLeGR7DUbz+XGZ1R5e7pyjA==", "dependencies": { "@aws-crypto/sha1-browser": "5.2.0", "@aws-crypto/sha256-browser": "5.2.0", @@ -727,12 +727,12 @@ "@aws-sdk/middleware-location-constraint": "3.609.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.616.0", - "@aws-sdk/middleware-sdk-s3": "3.616.0", + "@aws-sdk/middleware-sdk-s3": "3.617.0", "@aws-sdk/middleware-signing": "3.616.0", "@aws-sdk/middleware-ssec": "3.609.0", "@aws-sdk/middleware-user-agent": "3.616.0", "@aws-sdk/region-config-resolver": "3.614.0", - "@aws-sdk/signature-v4-multi-region": "3.616.0", + "@aws-sdk/signature-v4-multi-region": "3.617.0", "@aws-sdk/types": "3.609.0", "@aws-sdk/util-endpoints": "3.614.0", "@aws-sdk/util-user-agent-browser": "3.609.0", @@ -1762,9 +1762,9 @@ } }, "node_modules/@aws-sdk/lib-storage": { - "version": "3.616.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/lib-storage/-/lib-storage-3.616.0.tgz", - "integrity": "sha512-VhuJGCbJvI1TGGWDd5pdnCa+pobKAGv5/H4MqN1GlyRuWd6Biwby+pRaFb2nL4GT3bOJdCcM24CyZXO2PefPaw==", + "version": "3.617.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/lib-storage/-/lib-storage-3.617.0.tgz", + "integrity": "sha512-bR+3E66Dp3CyuSGywxMSwrYQCfwuFu7gRJxOpk1i2AKV1Wh7g0y1eANXHVKnk+UbVRz4S53UCD8LEiKp2KYShA==", "dependencies": { "@smithy/abort-controller": "^3.1.1", "@smithy/middleware-endpoint": "^3.0.5", @@ -1778,7 +1778,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-s3": "^3.616.0" + "@aws-sdk/client-s3": "^3.617.0" } }, "node_modules/@aws-sdk/lib-storage/node_modules/buffer": { @@ -2121,9 +2121,9 @@ } }, "node_modules/@aws-sdk/middleware-sdk-s3": { - "version": "3.616.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.616.0.tgz", - "integrity": "sha512-heq9pzn0NRX6VL/oMlmwZdgcCh5eJUDscvwMl/oGev0tNdTpB2oGU+wPaNMka7IrW3eBPn7APmY9fdS1kBaBoQ==", + "version": "3.617.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.617.0.tgz", + "integrity": "sha512-zVOS6sNGcLGhq7i+5POmVqmSPNmrQYDFsynpnWMSLsNaej+xvkdSOnytLrUvag3Du4kAxfO5NNIC0GuNj9lcCg==", "dependencies": { "@aws-sdk/types": "3.609.0", "@aws-sdk/util-arn-parser": "3.568.0", @@ -2154,9 +2154,9 @@ } }, "node_modules/@aws-sdk/middleware-sdk-s3/node_modules/@smithy/protocol-http": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-4.0.4.tgz", - "integrity": "sha512-fAA2O4EFyNRyYdFLVIv5xMMeRb+3fRKc/Rt2flh5k831vLvUmNFXcydeg7V3UeEhGURJI4c1asmGJBjvmF6j8Q==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-4.1.0.tgz", + "integrity": "sha512-dPVoHYQ2wcHooGXg3LQisa1hH0e4y0pAddPMeeUPipI1tEOqL6A4N0/G7abeq+K8wrwSgjk4C0wnD1XZpJm5aA==", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -2434,11 +2434,11 @@ } }, "node_modules/@aws-sdk/signature-v4-multi-region": { - "version": "3.616.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.616.0.tgz", - "integrity": "sha512-WQn43cfnwbG6jnPjh/SyujDQVqbRjGFY9tGI/tqtUvvGwoDhI343TSDCA7fvs0FEC6Za6vgOBq1CwPv3CFyfhA==", + "version": "3.617.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.617.0.tgz", + "integrity": "sha512-kGbLs9q0/ziuzA1huf0BBh05ChxDeZ8ZWc/kedb80ocq6izOLaGgeqqUR8oB0ianwjel4AQq/iv1fsOIt3wmAA==", "dependencies": { - "@aws-sdk/middleware-sdk-s3": "3.616.0", + "@aws-sdk/middleware-sdk-s3": "3.617.0", "@aws-sdk/types": "3.609.0", "@smithy/protocol-http": "^4.0.4", "@smithy/signature-v4": "^4.0.0", @@ -2462,9 +2462,9 @@ } }, "node_modules/@aws-sdk/signature-v4-multi-region/node_modules/@smithy/protocol-http": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-4.0.4.tgz", - "integrity": "sha512-fAA2O4EFyNRyYdFLVIv5xMMeRb+3fRKc/Rt2flh5k831vLvUmNFXcydeg7V3UeEhGURJI4c1asmGJBjvmF6j8Q==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-4.1.0.tgz", + "integrity": "sha512-dPVoHYQ2wcHooGXg3LQisa1hH0e4y0pAddPMeeUPipI1tEOqL6A4N0/G7abeq+K8wrwSgjk4C0wnD1XZpJm5aA==", "dependencies": { "@smithy/types": "^3.3.0", "tslib": "^2.6.2" diff --git a/package.json b/package.json index 28216db0cd2..f7d387b2262 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,7 @@ "generate-client:etherpad": "node ./scripts/generate-client.js -u 'http://localhost:9001/api/openapi.json' -p 'apps/server/src/infra/etherpad-client/etherpad-api-client' -c 'openapitools-config.json'" }, "dependencies": { - "@aws-sdk/lib-storage": "^3.616.0", + "@aws-sdk/lib-storage": "^3.617.0", "@feathersjs/adapter-commons": "^5.0.12", "@feathersjs/authentication": "^5.0.12", "@feathersjs/authentication-local": "^5.0.12", @@ -263,7 +263,7 @@ "yjs": "^13.6.11" }, "devDependencies": { - "@aws-sdk/client-s3": "^3.352.0", + "@aws-sdk/client-s3": "^3.617.0", "@faker-js/faker": "^8.0.2", "@feathersjs/adapter-tests": "^5.0.12", "@golevelup/ts-jest": "^0.3.4",