@travetto/model-s3 4.0.7 → 4.1.0
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 +6 -6
- package/src/service.ts +14 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-s3",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "S3 backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"directory": "module/model-s3"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aws-sdk/client-s3": "^3.
|
|
29
|
-
"@aws-sdk/credential-provider-ini": "^3.
|
|
30
|
-
"@travetto/config": "^4.0
|
|
31
|
-
"@travetto/model": "^4.0
|
|
28
|
+
"@aws-sdk/client-s3": "^3.577.0",
|
|
29
|
+
"@aws-sdk/credential-provider-ini": "^3.577.0",
|
|
30
|
+
"@travetto/config": "^4.1.0",
|
|
31
|
+
"@travetto/model": "^4.1.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@travetto/command": "^4.0
|
|
34
|
+
"@travetto/command": "^4.1.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@travetto/command": {
|
package/src/service.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
import { Agent } from 'node:https';
|
|
2
3
|
|
|
3
4
|
import { S3, CompletedPart, type CreateMultipartUploadRequest } from '@aws-sdk/client-s3';
|
|
4
5
|
import type { MetadataBearer } from '@aws-sdk/types';
|
|
6
|
+
import { NodeHttpHandler } from '@smithy/node-http-handler';
|
|
5
7
|
|
|
6
8
|
import {
|
|
7
9
|
ModelCrudSupport, ModelStreamSupport, ModelStorageSupport, StreamMeta,
|
|
@@ -14,7 +16,6 @@ import { ModelCrudUtil } from '@travetto/model/src/internal/service/crud';
|
|
|
14
16
|
import { ModelExpirySupport } from '@travetto/model/src/service/expiry';
|
|
15
17
|
import { ModelExpiryUtil } from '@travetto/model/src/internal/service/expiry';
|
|
16
18
|
import { ModelStorageUtil } from '@travetto/model/src/internal/service/storage';
|
|
17
|
-
import { ModelStreamUtil } from '@travetto/model/src/internal/service/stream';
|
|
18
19
|
|
|
19
20
|
import { S3ModelConfig } from './config';
|
|
20
21
|
|
|
@@ -163,7 +164,17 @@ export class S3ModelService implements ModelCrudSupport, ModelStreamSupport, Mod
|
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
async postConstruct(): Promise<void> {
|
|
166
|
-
this.client = new S3(
|
|
167
|
+
this.client = new S3({
|
|
168
|
+
...this.config.config,
|
|
169
|
+
...('requestHandler' in this.config.config ? {
|
|
170
|
+
requestHandler: new NodeHttpHandler({
|
|
171
|
+
...this.config.config.requestHandler,
|
|
172
|
+
...('httpsAgent' in this.config.config.requestHandler! ? {
|
|
173
|
+
httpsAgent: new Agent({ ...this.config.config.requestHandler?.httpsAgent ?? {} }),
|
|
174
|
+
} : {})
|
|
175
|
+
}),
|
|
176
|
+
} : {})
|
|
177
|
+
});
|
|
167
178
|
ModelStorageUtil.registerModelChangeListener(this);
|
|
168
179
|
}
|
|
169
180
|
|
|
@@ -313,7 +324,7 @@ export class S3ModelService implements ModelCrudSupport, ModelStreamSupport, Mod
|
|
|
313
324
|
async getStreamPartial(location: string, start: number, end?: number): Promise<PartialStream> {
|
|
314
325
|
const meta = await this.describeStream(location);
|
|
315
326
|
|
|
316
|
-
[start, end] =
|
|
327
|
+
[start, end] = StreamUtil.enforceRange(start, end, meta.size);
|
|
317
328
|
|
|
318
329
|
// Read from s3
|
|
319
330
|
const res = await this.client.getObject(this.#q(STREAM_SPACE, location, {
|