@travetto/model-s3 7.0.5 → 7.0.7
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/README.md +10 -6
- package/package.json +7 -7
- package/src/service.ts +8 -5
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Out of the box, by installing the module, everything should be wired up by defau
|
|
|
25
25
|
**Code: Wiring up a custom Model Source**
|
|
26
26
|
```typescript
|
|
27
27
|
import { InjectableFactory } from '@travetto/di';
|
|
28
|
-
import { S3ModelConfig, S3ModelService } from '@travetto/model-s3';
|
|
28
|
+
import { type S3ModelConfig, S3ModelService } from '@travetto/model-s3';
|
|
29
29
|
|
|
30
30
|
export class Init {
|
|
31
31
|
@InjectableFactory({
|
|
@@ -45,8 +45,10 @@ where the [S3ModelConfig](https://github.com/travetto/travetto/tree/main/module/
|
|
|
45
45
|
export class S3ModelConfig {
|
|
46
46
|
region = 'us-east-1'; // AWS Region
|
|
47
47
|
namespace = ''; // S3 Bucket folder
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
@Required(false)
|
|
49
|
+
bucket: string; // S3 bucket
|
|
50
|
+
@Required(false)
|
|
51
|
+
endpoint: string; // Endpoint url
|
|
50
52
|
|
|
51
53
|
@EnvVar('AWS_ACCESS_KEY_ID')
|
|
52
54
|
accessKeyId: string = '';
|
|
@@ -75,9 +77,7 @@ export class S3ModelConfig {
|
|
|
75
77
|
async postConstruct(): Promise<void> {
|
|
76
78
|
if (!Runtime.production) {
|
|
77
79
|
this.endpoint ??= 'http://localhost:4566'; // From docker
|
|
78
|
-
|
|
79
|
-
this.config.forcePathStyle ??= true;
|
|
80
|
-
}
|
|
80
|
+
this.bucket ??= 'app';
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (!this.accessKeyId && !this.secretAccessKey) {
|
|
@@ -95,6 +95,10 @@ export class S3ModelConfig {
|
|
|
95
95
|
secretAccessKey: this.secretAccessKey
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
+
|
|
99
|
+
if (!Runtime.production && this.endpoint.includes('localhost')) {
|
|
100
|
+
this.config.forcePathStyle ??= true;
|
|
101
|
+
}
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-s3",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "S3 backing for the travetto model module.",
|
|
6
6
|
"keywords": [
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"directory": "module/model-s3"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aws-sdk/client-s3": "^3.
|
|
30
|
-
"@aws-sdk/credential-provider-ini": "^3.
|
|
31
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
32
|
-
"@travetto/config": "^7.0.
|
|
33
|
-
"@travetto/model": "^7.0.
|
|
29
|
+
"@aws-sdk/client-s3": "^3.966.0",
|
|
30
|
+
"@aws-sdk/credential-provider-ini": "^3.966.0",
|
|
31
|
+
"@aws-sdk/s3-request-presigner": "^3.966.0",
|
|
32
|
+
"@travetto/config": "^7.0.6",
|
|
33
|
+
"@travetto/model": "^7.0.6"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^7.0.
|
|
36
|
+
"@travetto/cli": "^7.0.7"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
package/src/service.ts
CHANGED
|
@@ -2,19 +2,22 @@ import { Readable } from 'node:stream';
|
|
|
2
2
|
import { text as toText, buffer as toBuffer } from 'node:stream/consumers';
|
|
3
3
|
import { Agent } from 'node:https';
|
|
4
4
|
|
|
5
|
-
import { S3, CompletedPart, type CreateMultipartUploadRequest, GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3';
|
|
5
|
+
import { S3, type CompletedPart, type CreateMultipartUploadRequest, GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3';
|
|
6
6
|
import type { MetadataBearer } from '@aws-sdk/types';
|
|
7
7
|
import { NodeHttpHandler } from '@smithy/node-http-handler';
|
|
8
8
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
ModelCrudSupport, ModelStorageSupport, ModelType, ModelRegistryIndex, ExistsError, NotFoundError, OptionalId,
|
|
12
|
-
ModelBlobSupport, ModelExpirySupport, ModelBlobUtil, ModelCrudUtil, ModelExpiryUtil, ModelStorageUtil
|
|
11
|
+
type ModelCrudSupport, type ModelStorageSupport, type ModelType, ModelRegistryIndex, ExistsError, NotFoundError, type OptionalId,
|
|
12
|
+
type ModelBlobSupport, type ModelExpirySupport, ModelBlobUtil, ModelCrudUtil, ModelExpiryUtil, ModelStorageUtil
|
|
13
13
|
} from '@travetto/model';
|
|
14
14
|
import { Injectable } from '@travetto/di';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
type Class, AppError, castTo, asFull, type BlobMeta,
|
|
17
|
+
type ByteRange, type BinaryInput, BinaryUtil, type TimeSpan, TimeUtil
|
|
18
|
+
} from '@travetto/runtime';
|
|
16
19
|
|
|
17
|
-
import { S3ModelConfig } from './config.ts';
|
|
20
|
+
import type { S3ModelConfig } from './config.ts';
|
|
18
21
|
|
|
19
22
|
function isMetadataBearer(value: unknown): value is MetadataBearer {
|
|
20
23
|
return !!value && typeof value === 'object' && '$metadata' in value;
|