@kensio/yulin 0.1.2 → 0.3.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/README.md +76 -1
- package/dist/serve/controller/sim-aws-service-controller-container.d.ts +17 -0
- package/dist/serve/controller/sim-aws-service-controller-container.d.ts.map +1 -0
- package/dist/serve/controller/sim-aws-service-controller-container.js +29 -0
- package/dist/serve/controller/sim-aws-service-controller-container.js.map +1 -0
- package/dist/serve/controller/sim-service-controller.d.ts +22 -0
- package/dist/serve/controller/sim-service-controller.d.ts.map +1 -0
- package/dist/serve/controller/sim-service-controller.js +2 -0
- package/dist/serve/controller/sim-service-controller.js.map +1 -0
- package/dist/serve/http/sim-aws-http.d.ts +20 -0
- package/dist/serve/http/sim-aws-http.d.ts.map +1 -0
- package/dist/serve/http/sim-aws-http.js +57 -0
- package/dist/serve/http/sim-aws-http.js.map +1 -0
- package/dist/serve/http/sim-aws-local-server.d.ts +37 -0
- package/dist/serve/http/sim-aws-local-server.d.ts.map +1 -0
- package/dist/serve/http/sim-aws-local-server.js +132 -0
- package/dist/serve/http/sim-aws-local-server.js.map +1 -0
- package/dist/serve/http/sim-aws-local.conf.d.ts +8 -0
- package/dist/serve/http/sim-aws-local.conf.d.ts.map +1 -0
- package/dist/serve/http/sim-aws-local.conf.js +8 -0
- package/dist/serve/http/sim-aws-local.conf.js.map +1 -0
- package/dist/serve/index.d.ts +3 -0
- package/dist/serve/index.d.ts.map +1 -0
- package/dist/serve/index.js +3 -0
- package/dist/serve/index.js.map +1 -0
- package/dist/serve/resolve/sim-aws-local-service-resolver.d.ts +13 -0
- package/dist/serve/resolve/sim-aws-local-service-resolver.d.ts.map +1 -0
- package/dist/serve/resolve/sim-aws-local-service-resolver.js +38 -0
- package/dist/serve/resolve/sim-aws-local-service-resolver.js.map +1 -0
- package/dist/service/aws/arn.d.ts +17 -0
- package/dist/service/aws/arn.d.ts.map +1 -0
- package/dist/service/aws/arn.js +21 -0
- package/dist/service/aws/arn.js.map +1 -0
- package/dist/service/aws/sim-aws-account-region-scope.d.ts +38 -0
- package/dist/service/aws/sim-aws-account-region-scope.d.ts.map +1 -0
- package/dist/service/aws/sim-aws-account-region-scope.js +52 -0
- package/dist/service/aws/sim-aws-account-region-scope.js.map +1 -0
- package/dist/service/aws/sim-aws-account.d.ts +33 -0
- package/dist/service/aws/sim-aws-account.d.ts.map +1 -0
- package/dist/service/aws/sim-aws-account.js +38 -0
- package/dist/service/aws/sim-aws-account.js.map +1 -0
- package/dist/service/aws/sim-aws-region.d.ts +33 -0
- package/dist/service/aws/sim-aws-region.d.ts.map +1 -0
- package/dist/service/aws/sim-aws-region.js +74 -0
- package/dist/service/aws/sim-aws-region.js.map +1 -0
- package/dist/service/aws/sim-aws-services.d.ts +21 -0
- package/dist/service/aws/sim-aws-services.d.ts.map +1 -0
- package/dist/service/aws/sim-aws-services.js +2 -0
- package/dist/service/aws/sim-aws-services.js.map +1 -0
- package/dist/service/aws/sim-aws.d.ts +50 -0
- package/dist/service/aws/sim-aws.d.ts.map +1 -0
- package/dist/service/aws/sim-aws.js +82 -0
- package/dist/service/aws/sim-aws.js.map +1 -0
- package/dist/service/dynamodb/command/create-table/create-table.handler.d.ts +3 -1
- package/dist/service/dynamodb/command/create-table/create-table.handler.d.ts.map +1 -1
- package/dist/service/dynamodb/command/create-table/create-table.handler.js +9 -6
- package/dist/service/dynamodb/command/create-table/create-table.handler.js.map +1 -1
- package/dist/service/dynamodb/index.d.ts +1 -1
- package/dist/service/dynamodb/index.d.ts.map +1 -1
- package/dist/service/dynamodb/index.js +1 -1
- package/dist/service/dynamodb/index.js.map +1 -1
- package/dist/service/dynamodb/sim-dynamodb.d.ts +29 -0
- package/dist/service/dynamodb/sim-dynamodb.d.ts.map +1 -0
- package/dist/service/dynamodb/sim-dynamodb.js +47 -0
- package/dist/service/dynamodb/sim-dynamodb.js.map +1 -0
- package/dist/service/dynamodb/table/dynamodb-table.d.ts +8 -6
- package/dist/service/dynamodb/table/dynamodb-table.d.ts.map +1 -1
- package/dist/service/dynamodb/table/dynamodb-table.js +16 -9
- package/dist/service/dynamodb/table/dynamodb-table.js.map +1 -1
- package/dist/service/organizations/sim-aws-account.d.ts +12 -1
- package/dist/service/organizations/sim-aws-account.d.ts.map +1 -1
- package/dist/service/organizations/sim-aws-account.js +15 -2
- package/dist/service/organizations/sim-aws-account.js.map +1 -1
- package/dist/service/organizations/sim-aws-region.d.ts +23 -0
- package/dist/service/organizations/sim-aws-region.d.ts.map +1 -0
- package/dist/service/organizations/sim-aws-region.js +27 -0
- package/dist/service/organizations/sim-aws-region.js.map +1 -0
- package/dist/service/s3/bucket/s3-bucket.d.ts +30 -0
- package/dist/service/s3/bucket/s3-bucket.d.ts.map +1 -0
- package/dist/service/s3/bucket/s3-bucket.js +42 -0
- package/dist/service/s3/bucket/s3-bucket.js.map +1 -0
- package/dist/service/s3/command/create-bucket/create-bucket.handler.d.ts +21 -0
- package/dist/service/s3/command/create-bucket/create-bucket.handler.d.ts.map +1 -0
- package/dist/service/s3/command/create-bucket/create-bucket.handler.js +58 -0
- package/dist/service/s3/command/create-bucket/create-bucket.handler.js.map +1 -0
- package/dist/service/s3/command/get-object/get-object.handler.d.ts +17 -0
- package/dist/service/s3/command/get-object/get-object.handler.d.ts.map +1 -0
- package/dist/service/s3/command/get-object/get-object.handler.js +44 -0
- package/dist/service/s3/command/get-object/get-object.handler.js.map +1 -0
- package/dist/service/s3/command/list-buckets/list-buckets.handler.d.ts +19 -0
- package/dist/service/s3/command/list-buckets/list-buckets.handler.d.ts.map +1 -0
- package/dist/service/s3/command/list-buckets/list-buckets.handler.js +52 -0
- package/dist/service/s3/command/list-buckets/list-buckets.handler.js.map +1 -0
- package/dist/service/s3/command/list-objects/list-objects.handler.d.ts +17 -0
- package/dist/service/s3/command/list-objects/list-objects.handler.d.ts.map +1 -0
- package/dist/service/s3/command/list-objects/list-objects.handler.js +54 -0
- package/dist/service/s3/command/list-objects/list-objects.handler.js.map +1 -0
- package/dist/service/s3/command/put-object/put-object.handler.d.ts +19 -0
- package/dist/service/s3/command/put-object/put-object.handler.d.ts.map +1 -0
- package/dist/service/s3/command/put-object/put-object.handler.js +57 -0
- package/dist/service/s3/command/put-object/put-object.handler.js.map +1 -0
- package/dist/service/s3/index.d.ts +1 -1
- package/dist/service/s3/index.d.ts.map +1 -1
- package/dist/service/s3/index.js +1 -2
- package/dist/service/s3/index.js.map +1 -1
- package/dist/service/s3/object/s3-object.d.ts +17 -0
- package/dist/service/s3/object/s3-object.d.ts.map +1 -0
- package/dist/service/s3/object/s3-object.js +23 -0
- package/dist/service/s3/object/s3-object.js.map +1 -0
- package/dist/service/s3/s3.d.ts +33 -0
- package/dist/service/s3/s3.d.ts.map +1 -0
- package/dist/service/s3/s3.js +56 -0
- package/dist/service/s3/s3.js.map +1 -0
- package/dist/service/s3/serve/sim-s3-controller.d.ts +15 -0
- package/dist/service/s3/serve/sim-s3-controller.d.ts.map +1 -0
- package/dist/service/s3/serve/sim-s3-controller.js +29 -0
- package/dist/service/s3/serve/sim-s3-controller.js.map +1 -0
- package/dist/service/s3/serve/sim-s3-get-obj-controller.d.ts +11 -0
- package/dist/service/s3/serve/sim-s3-get-obj-controller.d.ts.map +1 -0
- package/dist/service/s3/serve/sim-s3-get-obj-controller.js +35 -0
- package/dist/service/s3/serve/sim-s3-get-obj-controller.js.map +1 -0
- package/dist/service/s3/serve/sim-s3-req-router.d.ts +26 -0
- package/dist/service/s3/serve/sim-s3-req-router.d.ts.map +1 -0
- package/dist/service/s3/serve/sim-s3-req-router.js +79 -0
- package/dist/service/s3/serve/sim-s3-req-router.js.map +1 -0
- package/dist/service/s3/sim-s3-global-registry.d.ts +20 -0
- package/dist/service/s3/sim-s3-global-registry.d.ts.map +1 -0
- package/dist/service/s3/sim-s3-global-registry.js +22 -0
- package/dist/service/s3/sim-s3-global-registry.js.map +1 -0
- package/dist/service/s3/sim-s3.d.ts +38 -0
- package/dist/service/s3/sim-s3.d.ts.map +1 -0
- package/dist/service/s3/sim-s3.js +61 -0
- package/dist/service/s3/sim-s3.js.map +1 -0
- package/dist/service/s3/storage/s3-body-buffer.d.ts +5 -0
- package/dist/service/s3/storage/s3-body-buffer.d.ts.map +1 -0
- package/dist/service/s3/storage/s3-body-buffer.js +11 -0
- package/dist/service/s3/storage/s3-body-buffer.js.map +1 -0
- package/dist/service/s3/storage/s3-bucket-storage.d.ts +20 -0
- package/dist/service/s3/storage/s3-bucket-storage.d.ts.map +1 -0
- package/dist/service/s3/storage/s3-bucket-storage.js +2 -0
- package/dist/service/s3/storage/s3-bucket-storage.js.map +1 -0
- package/dist/service/s3/storage/s3-filesystem-storage.d.ts +59 -0
- package/dist/service/s3/storage/s3-filesystem-storage.d.ts.map +1 -0
- package/dist/service/s3/storage/s3-filesystem-storage.js +266 -0
- package/dist/service/s3/storage/s3-filesystem-storage.js.map +1 -0
- package/dist/service/s3/storage/s3-memory-storage.d.ts +27 -0
- package/dist/service/s3/storage/s3-memory-storage.d.ts.map +1 -0
- package/dist/service/s3/storage/s3-memory-storage.js +37 -0
- package/dist/service/s3/storage/s3-memory-storage.js.map +1 -0
- package/package.json +25 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-s3.d.ts","sourceRoot":"","sources":["../../../src/service/s3/sim-s3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,wCAAwC,CAAC;AAEhD;;GAEG;AACH,qBAAa,KAAK;IAId,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAJnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;gBAGhD,kBAAkB,GAAE,wBAAiE,EACrF,gBAAgB,GAAE,mBAA+C;IAGpF;;OAEG;IACG,YAAY,CAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,yBAAyB,CAAC;IASrC;;OAEG;IACG,WAAW,CACf,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,wBAAwB,CAAC;IAKpC;;OAEG;IACG,SAAS,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKvE;;OAEG;IACG,SAAS,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAKvE;;OAEG;IACG,WAAW,CACf,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,wBAAwB,CAAC;IAKpC;;OAEG;IACH,kBAAkB,CAAC,UAAU,EAAE,eAAe,GAAG,WAAW,GAAG,SAAS;CAGzE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CreateBucketCommandHandler } from "./command/create-bucket/create-bucket.handler.js";
|
|
2
|
+
import { ListBucketsCommandHandler } from "./command/list-buckets/list-buckets.handler.js";
|
|
3
|
+
import { PutObjectCommandHandler } from "./command/put-object/put-object.handler.js";
|
|
4
|
+
import { GetObjectCommandHandler } from "./command/get-object/get-object.handler.js";
|
|
5
|
+
import { ListObjectsCommandHandler } from "./command/list-objects/list-objects.handler.js";
|
|
6
|
+
import { SimS3GlobalRegistry } from "./sim-s3-global-registry.js";
|
|
7
|
+
import { simAwsAccountRegionScopeFactory, } from "../aws/sim-aws-account-region-scope.js";
|
|
8
|
+
/**
|
|
9
|
+
* Simulated S3. Handles SDK commands. Emulates AWS behaviour and state.
|
|
10
|
+
*/
|
|
11
|
+
export class SimS3 {
|
|
12
|
+
accountRegionScope;
|
|
13
|
+
s3GlobalRegistry;
|
|
14
|
+
buckets = new Map();
|
|
15
|
+
constructor(accountRegionScope = simAwsAccountRegionScopeFactory.make(), s3GlobalRegistry = new SimS3GlobalRegistry()) {
|
|
16
|
+
this.accountRegionScope = accountRegionScope;
|
|
17
|
+
this.s3GlobalRegistry = s3GlobalRegistry;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Handle a Create Bucket Command from the SDK.
|
|
21
|
+
*/
|
|
22
|
+
async createBucket(cmd) {
|
|
23
|
+
const handler = new CreateBucketCommandHandler(this.accountRegionScope, this.buckets, this.s3GlobalRegistry);
|
|
24
|
+
return await handler.handle(cmd);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Handle a List Buckets Command from the SDK.
|
|
28
|
+
*/
|
|
29
|
+
async listBuckets(cmd) {
|
|
30
|
+
const handler = new ListBucketsCommandHandler(this.buckets);
|
|
31
|
+
return await handler.handle(cmd);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Handle a Put Object Command from the SDK.
|
|
35
|
+
*/
|
|
36
|
+
async putObject(cmd) {
|
|
37
|
+
const handler = new PutObjectCommandHandler(this.buckets);
|
|
38
|
+
return await handler.handle(cmd);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Handle a Get Object Command from the SDK.
|
|
42
|
+
*/
|
|
43
|
+
async getObject(cmd) {
|
|
44
|
+
const handler = new GetObjectCommandHandler(this.buckets);
|
|
45
|
+
return await handler.handle(cmd);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Handle a List Objects Command from the SDK.
|
|
49
|
+
*/
|
|
50
|
+
async listObjects(cmd) {
|
|
51
|
+
const handler = new ListObjectsCommandHandler(this.buckets);
|
|
52
|
+
return await handler.handle(cmd);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get a simulated S3 Bucket instance by name.
|
|
56
|
+
*/
|
|
57
|
+
getSimBucketByName(bucketName) {
|
|
58
|
+
return this.buckets.get(bucketName);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=sim-s3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-s3.js","sourceRoot":"","sources":["../../../src/service/s3/sim-s3.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAEL,+BAA+B,GAChC,MAAM,wCAAwC,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,KAAK;IAIG;IACA;IAJF,OAAO,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEnE,YACmB,qBAA+C,+BAA+B,CAAC,IAAI,EAAE,EACrF,mBAAwC,IAAI,mBAAmB,EAAE;QADjE,uBAAkB,GAAlB,kBAAkB,CAAmE;QACrF,qBAAgB,GAAhB,gBAAgB,CAAiD;IACjF,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,YAAY,CAChB,GAAwB;QAExB,MAAM,OAAO,GAAG,IAAI,0BAA0B,CAC5C,IAAI,CAAC,kBAAkB,EACvB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,gBAAgB,CACtB,CAAC;QACF,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,GAAuB;QAEvB,MAAM,OAAO,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5D,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAqB;QACnC,MAAM,OAAO,GAAG,IAAI,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1D,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAqB;QACnC,MAAM,OAAO,GAAG,IAAI,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1D,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,GAAuB;QAEvB,MAAM,OAAO,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5D,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,UAA2B;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-body-buffer.d.ts","sourceRoot":"","sources":["../../../../src/service/s3/storage/s3-body-buffer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAC1B,OAAO,CAAC,MAAM,CAAC,CAQjB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an AsyncIterable<Buffer> simulated S3 Object body to a Buffer.
|
|
3
|
+
*/
|
|
4
|
+
export async function simS3BodyToBuffer(body) {
|
|
5
|
+
const chunks = [];
|
|
6
|
+
for await (const chunk of body) {
|
|
7
|
+
chunks.push(chunk);
|
|
8
|
+
}
|
|
9
|
+
return Buffer.concat(chunks);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=s3-body-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-body-buffer.js","sourceRoot":"","sources":["../../../../src/service/s3/storage/s3-body-buffer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAA2B;IAE3B,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SimS3Object } from "../object/s3-object.js";
|
|
2
|
+
export interface SimS3BucketStorage {
|
|
3
|
+
/**
|
|
4
|
+
* Put a simulated Object into storage.
|
|
5
|
+
*/
|
|
6
|
+
putObject(object: SimS3Object): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Get a simulated Object from storage.
|
|
9
|
+
*/
|
|
10
|
+
getObject(key: string): Promise<SimS3Object | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* List simulated Objects in storage.
|
|
13
|
+
*/
|
|
14
|
+
listObjects(prefix?: string): Promise<SimS3Object[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Is it OK to change to a different storage implementation?
|
|
17
|
+
*/
|
|
18
|
+
allowChangeStorage(): boolean;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=s3-bucket-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-bucket-storage.d.ts","sourceRoot":"","sources":["../../../../src/service/s3/storage/s3-bucket-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IAEzD;;OAEG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAErD;;OAEG;IACH,kBAAkB,IAAI,OAAO,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-bucket-storage.js","sourceRoot":"","sources":["../../../../src/service/s3/storage/s3-bucket-storage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { SimS3BucketStorage } from "./s3-bucket-storage.js";
|
|
2
|
+
import { SimS3Object } from "../object/s3-object.js";
|
|
3
|
+
/**
|
|
4
|
+
* Maps simulated S3 Objects to files under a directory.
|
|
5
|
+
* This is useful for local development, such as serving a static website
|
|
6
|
+
* locally out of simulated S3.
|
|
7
|
+
* This class has some simple checks to reduce the risk of reading or writing
|
|
8
|
+
* files that might be unsafe, but it cannot completely protect against all
|
|
9
|
+
* potential safety issues.
|
|
10
|
+
*/
|
|
11
|
+
export declare class FilesystemS3BucketStorage implements SimS3BucketStorage {
|
|
12
|
+
private readonly directoryPath;
|
|
13
|
+
private readonly allowedDirectoryNames;
|
|
14
|
+
constructor(directoryPath: string, options?: FilesystemS3BucketStorageOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Get a simulated Object from a file in the directory.
|
|
17
|
+
*/
|
|
18
|
+
getObject(key: string): Promise<SimS3Object | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* List simulated Objects based on files in the directory.
|
|
21
|
+
*/
|
|
22
|
+
listObjects(prefix?: string): Promise<SimS3Object[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Store a simulated Object as a file in the directory.
|
|
25
|
+
*/
|
|
26
|
+
putObject(object: SimS3Object): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Is it OK to change to a different storage implementation?
|
|
29
|
+
* For now, we're assuming that a user should not need to change from a
|
|
30
|
+
* filesystem storage at runtime, so this is always false.
|
|
31
|
+
*/
|
|
32
|
+
allowChangeStorage(): boolean;
|
|
33
|
+
private filePathForObjectKey;
|
|
34
|
+
private listObjectKeys;
|
|
35
|
+
private listObjectKeysInDirectory;
|
|
36
|
+
/**
|
|
37
|
+
* Make up reasonable metadata for an Object based on the file on disk.
|
|
38
|
+
*/
|
|
39
|
+
private metadataForObjectKey;
|
|
40
|
+
/**
|
|
41
|
+
* Guess a reasonable content type for an Object key based on its file
|
|
42
|
+
* extension on disk.
|
|
43
|
+
*/
|
|
44
|
+
private contentTypeForObjectKey;
|
|
45
|
+
private assertSafeDirectoryPath;
|
|
46
|
+
private assertSafeObjectKey;
|
|
47
|
+
private pathContainsParentDirectorySegment;
|
|
48
|
+
private isAllowedObjectKeyExtension;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options for filesystem-based simulated S3 Bucket storage.
|
|
52
|
+
*/
|
|
53
|
+
export interface FilesystemS3BucketStorageOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Directory names that are safe to use as filesystem storage roots.
|
|
56
|
+
*/
|
|
57
|
+
readonly allowedDirectoryNames?: readonly string[];
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=s3-filesystem-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-filesystem-storage.d.ts","sourceRoot":"","sources":["../../../../src/service/s3/storage/s3-filesystem-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAuB,MAAM,wBAAwB,CAAC;AAK1E;;;;;;;GAOG;AACH,qBAAa,yBAA0B,YAAW,kBAAkB;IAClE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAoB;gBAGxD,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,gCAAqC;IAQhD;;OAEG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAqB9D;;OAEG;IACG,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAmB1D;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IASnD;;;;OAIG;IACH,kBAAkB,IAAI,OAAO;IAI7B,OAAO,CAAC,oBAAoB;YAkBd,cAAc;YAoBd,yBAAyB;IAiCvC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAqD/B,OAAO,CAAC,uBAAuB;IAuC/B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,kCAAkC;IAI1C,OAAO,CAAC,2BAA2B;CAGpC;AAED;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;OAEG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpD"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { SimS3Object, SimS3ObjectMetadata } from "../object/s3-object.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
5
|
+
/**
|
|
6
|
+
* Maps simulated S3 Objects to files under a directory.
|
|
7
|
+
* This is useful for local development, such as serving a static website
|
|
8
|
+
* locally out of simulated S3.
|
|
9
|
+
* This class has some simple checks to reduce the risk of reading or writing
|
|
10
|
+
* files that might be unsafe, but it cannot completely protect against all
|
|
11
|
+
* potential safety issues.
|
|
12
|
+
*/
|
|
13
|
+
export class FilesystemS3BucketStorage {
|
|
14
|
+
directoryPath;
|
|
15
|
+
allowedDirectoryNames;
|
|
16
|
+
constructor(directoryPath, options = {}) {
|
|
17
|
+
this.allowedDirectoryNames =
|
|
18
|
+
options.allowedDirectoryNames ?? defaultAllowedDirectoryNames;
|
|
19
|
+
this.assertSafeDirectoryPath(directoryPath);
|
|
20
|
+
this.directoryPath = path.resolve(directoryPath);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get a simulated Object from a file in the directory.
|
|
24
|
+
*/
|
|
25
|
+
async getObject(key) {
|
|
26
|
+
const filePath = this.filePathForObjectKey(key);
|
|
27
|
+
try {
|
|
28
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
29
|
+
const body = await readFile(filePath);
|
|
30
|
+
return new SimS3Object(key, body, this.metadataForObjectKey(key));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error instanceof Error &&
|
|
34
|
+
"code" in error &&
|
|
35
|
+
error.code === "ENOENT") {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
/* v8 ignore next */
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* List simulated Objects based on files in the directory.
|
|
44
|
+
*/
|
|
45
|
+
async listObjects(prefix) {
|
|
46
|
+
const objectKeys = await this.listObjectKeys();
|
|
47
|
+
return await Promise.all(objectKeys
|
|
48
|
+
.filter((key) => prefix === undefined || key.startsWith(prefix))
|
|
49
|
+
.map(async (key) => {
|
|
50
|
+
const object = await this.getObject(key);
|
|
51
|
+
/* v8 ignore next -- defensive guard for filesystem race */
|
|
52
|
+
if (object === undefined) {
|
|
53
|
+
throw new Error(`Object listed but not found: ${key}`);
|
|
54
|
+
}
|
|
55
|
+
return object;
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Store a simulated Object as a file in the directory.
|
|
60
|
+
*/
|
|
61
|
+
async putObject(object) {
|
|
62
|
+
const filePath = this.filePathForObjectKey(object.key);
|
|
63
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
64
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
65
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
66
|
+
await writeFile(filePath, object.body);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Is it OK to change to a different storage implementation?
|
|
70
|
+
* For now, we're assuming that a user should not need to change from a
|
|
71
|
+
* filesystem storage at runtime, so this is always false.
|
|
72
|
+
*/
|
|
73
|
+
allowChangeStorage() {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
filePathForObjectKey(key) {
|
|
77
|
+
this.assertSafeObjectKey(key);
|
|
78
|
+
const filePath = path.resolve(this.directoryPath, key);
|
|
79
|
+
/* v8 ignore if -- defensive guard after object key validation */
|
|
80
|
+
if (filePath !== this.directoryPath &&
|
|
81
|
+
!filePath.startsWith(`${this.directoryPath}${path.sep}`)) {
|
|
82
|
+
throw new Error(`Invalid S3 Object key outside storage directory: ${key}`);
|
|
83
|
+
}
|
|
84
|
+
return filePath;
|
|
85
|
+
}
|
|
86
|
+
async listObjectKeys() {
|
|
87
|
+
try {
|
|
88
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
89
|
+
await stat(this.directoryPath);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (error instanceof Error &&
|
|
93
|
+
"code" in error &&
|
|
94
|
+
error.code === "ENOENT") {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
/* v8 ignore next */
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
return await this.listObjectKeysInDirectory(this.directoryPath);
|
|
101
|
+
}
|
|
102
|
+
async listObjectKeysInDirectory(directoryPath) {
|
|
103
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
104
|
+
const entries = await readdir(directoryPath, { withFileTypes: true });
|
|
105
|
+
const keys = [];
|
|
106
|
+
const nestedKeyPromises = [];
|
|
107
|
+
for (const entry of entries) {
|
|
108
|
+
const entryPath = path.join(directoryPath, entry.name);
|
|
109
|
+
if (entry.isDirectory()) {
|
|
110
|
+
nestedKeyPromises.push(this.listObjectKeysInDirectory(entryPath));
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (entry.isFile()) {
|
|
114
|
+
const key = path
|
|
115
|
+
.relative(this.directoryPath, entryPath)
|
|
116
|
+
.split(path.sep)
|
|
117
|
+
.join("/");
|
|
118
|
+
if (this.isAllowedObjectKeyExtension(key)) {
|
|
119
|
+
keys.push(key);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const nestedKeys = await Promise.all(nestedKeyPromises);
|
|
124
|
+
return [...keys, ...nestedKeys.flat()];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Make up reasonable metadata for an Object based on the file on disk.
|
|
128
|
+
*/
|
|
129
|
+
metadataForObjectKey(key) {
|
|
130
|
+
const contentType = this.contentTypeForObjectKey(key);
|
|
131
|
+
/* v8 ignore if -- defensive fallback */
|
|
132
|
+
if (contentType === undefined) {
|
|
133
|
+
return new SimS3ObjectMetadata();
|
|
134
|
+
}
|
|
135
|
+
return new SimS3ObjectMetadata({
|
|
136
|
+
"content-type": contentType,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Guess a reasonable content type for an Object key based on its file
|
|
141
|
+
* extension on disk.
|
|
142
|
+
*/
|
|
143
|
+
contentTypeForObjectKey(key) {
|
|
144
|
+
const extension = path.extname(key).toLowerCase();
|
|
145
|
+
switch (extension) {
|
|
146
|
+
case ".css": {
|
|
147
|
+
return "text/css";
|
|
148
|
+
}
|
|
149
|
+
case ".gif": {
|
|
150
|
+
return "image/gif";
|
|
151
|
+
}
|
|
152
|
+
case ".html":
|
|
153
|
+
case ".htm": {
|
|
154
|
+
return "text/html";
|
|
155
|
+
}
|
|
156
|
+
case ".ico": {
|
|
157
|
+
return "image/x-icon";
|
|
158
|
+
}
|
|
159
|
+
case ".jpeg":
|
|
160
|
+
case ".jpg": {
|
|
161
|
+
return "image/jpeg";
|
|
162
|
+
}
|
|
163
|
+
case ".js":
|
|
164
|
+
case ".mjs": {
|
|
165
|
+
return "text/javascript";
|
|
166
|
+
}
|
|
167
|
+
case ".json": {
|
|
168
|
+
return "application/json";
|
|
169
|
+
}
|
|
170
|
+
case ".map": {
|
|
171
|
+
return "application/json";
|
|
172
|
+
}
|
|
173
|
+
case ".png": {
|
|
174
|
+
return "image/png";
|
|
175
|
+
}
|
|
176
|
+
case ".svg": {
|
|
177
|
+
return "image/svg+xml";
|
|
178
|
+
}
|
|
179
|
+
case ".txt": {
|
|
180
|
+
return "text/plain";
|
|
181
|
+
}
|
|
182
|
+
case ".webp": {
|
|
183
|
+
return "image/webp";
|
|
184
|
+
}
|
|
185
|
+
case ".xml": {
|
|
186
|
+
return "application/xml";
|
|
187
|
+
}
|
|
188
|
+
default: {
|
|
189
|
+
/* v8 ignore next */
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
assertSafeDirectoryPath(directoryPath) {
|
|
195
|
+
if (!path.isAbsolute(directoryPath)) {
|
|
196
|
+
throw new Error(`Filesystem S3 storage directory path must be absolute: ${directoryPath}`);
|
|
197
|
+
}
|
|
198
|
+
if (this.pathContainsParentDirectorySegment(directoryPath)) {
|
|
199
|
+
throw new Error(`Filesystem S3 storage directory path must not contain '..': ${directoryPath}`);
|
|
200
|
+
}
|
|
201
|
+
const resolvedDirectoryPath = path.resolve(directoryPath);
|
|
202
|
+
const parsedDirectoryPath = path.parse(resolvedDirectoryPath);
|
|
203
|
+
if (resolvedDirectoryPath === parsedDirectoryPath.root) {
|
|
204
|
+
throw new Error(`Filesystem S3 storage directory path must not be a filesystem root: ${directoryPath}`);
|
|
205
|
+
}
|
|
206
|
+
if (resolvedDirectoryPath === path.resolve(homedir())) {
|
|
207
|
+
throw new Error(`Filesystem S3 storage directory path must not be the user home directory: ${directoryPath}`);
|
|
208
|
+
}
|
|
209
|
+
const directoryName = path.basename(resolvedDirectoryPath);
|
|
210
|
+
if (!this.allowedDirectoryNames.includes(directoryName)) {
|
|
211
|
+
throw new Error(`Filesystem S3 storage directory name must be one of: ${this.allowedDirectoryNames.join(", ")}. Got: ${directoryName}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
assertSafeObjectKey(key) {
|
|
215
|
+
if (path.isAbsolute(key)) {
|
|
216
|
+
throw new Error(`S3 Object key must not be an absolute path: ${key}`);
|
|
217
|
+
}
|
|
218
|
+
if (this.pathContainsParentDirectorySegment(key)) {
|
|
219
|
+
throw new Error(`S3 Object key must not contain '..': ${key}`);
|
|
220
|
+
}
|
|
221
|
+
if (!this.isAllowedObjectKeyExtension(key)) {
|
|
222
|
+
throw new Error(`S3 Object key has unsupported file extension: ${key}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
pathContainsParentDirectorySegment(value) {
|
|
226
|
+
return value.split(/[\\/]/u).includes("..");
|
|
227
|
+
}
|
|
228
|
+
isAllowedObjectKeyExtension(key) {
|
|
229
|
+
return allowedObjectFileExtensions.has(path.extname(key).toLowerCase());
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Default directory names that are safe to use as filesystem storage roots.
|
|
234
|
+
*/
|
|
235
|
+
const defaultAllowedDirectoryNames = [
|
|
236
|
+
"assets",
|
|
237
|
+
"build",
|
|
238
|
+
"dist",
|
|
239
|
+
"out",
|
|
240
|
+
"public",
|
|
241
|
+
"static",
|
|
242
|
+
"www",
|
|
243
|
+
];
|
|
244
|
+
/**
|
|
245
|
+
* Cautious list of allowed file extensions for simulated S3 objects. This is to
|
|
246
|
+
* try and avoid reading or writing other files that might be unsafe.
|
|
247
|
+
*/
|
|
248
|
+
const allowedObjectFileExtensions = new Set([
|
|
249
|
+
".css",
|
|
250
|
+
".gif",
|
|
251
|
+
".htm",
|
|
252
|
+
".html",
|
|
253
|
+
".ico",
|
|
254
|
+
".jpeg",
|
|
255
|
+
".jpg",
|
|
256
|
+
".js",
|
|
257
|
+
".json",
|
|
258
|
+
".map",
|
|
259
|
+
".mjs",
|
|
260
|
+
".png",
|
|
261
|
+
".svg",
|
|
262
|
+
".txt",
|
|
263
|
+
".webp",
|
|
264
|
+
".xml",
|
|
265
|
+
]);
|
|
266
|
+
//# sourceMappingURL=s3-filesystem-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-filesystem-storage.js","sourceRoot":"","sources":["../../../../src/service/s3/storage/s3-filesystem-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAyB;IACnB,aAAa,CAAS;IACtB,qBAAqB,CAAoB;IAE1D,YACE,aAAqB,EACrB,UAA4C,EAAE;QAE9C,IAAI,CAAC,qBAAqB;YACxB,OAAO,CAAC,qBAAqB,IAAI,4BAA4B,CAAC;QAChE,IAAI,CAAC,uBAAuB,CAAC,aAAa,CAAC,CAAC;QAC5C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAW;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,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AAkC,CAAC,GAAG,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,iDAAiD,GAAG,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAEO,kCAAkC,CAAC,KAAa;QACtD,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEO,2BAA2B,CAAC,GAAW;QAC7C,OAAO,2BAA2B,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF;AAYD;;GAEG;AACH,MAAM,4BAA4B,GAAG;IACnC,QAAQ;IACR,OAAO;IACP,MAAM;IACN,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,KAAK;CACG,CAAC;AAEX;;;GAGG;AACH,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC;IAC1C,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;CACP,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SimS3Object } from "../object/s3-object.js";
|
|
2
|
+
import type { SimS3BucketStorage } from "./s3-bucket-storage.js";
|
|
3
|
+
/**
|
|
4
|
+
* Default in-memory simulated S3 Bucket storage.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MemoryS3BucketStorage implements SimS3BucketStorage {
|
|
7
|
+
private readonly objects;
|
|
8
|
+
/**
|
|
9
|
+
* Get a simulated Object from in-memory storage.
|
|
10
|
+
*/
|
|
11
|
+
getObject(key: string): Promise<SimS3Object | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* List simulated Objects in in-memory storage.
|
|
14
|
+
*/
|
|
15
|
+
listObjects(prefix?: string): Promise<SimS3Object[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Put a simulated Object into in-memory storage.
|
|
18
|
+
*/
|
|
19
|
+
putObject(object: SimS3Object): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Is it OK to change to a different storage implementation?
|
|
22
|
+
* To reduce unexpected behaviours, we disallow changing from in-memory
|
|
23
|
+
* storage if it currently contains any objects.
|
|
24
|
+
*/
|
|
25
|
+
allowChangeStorage(): boolean;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=s3-memory-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-memory-storage.d.ts","sourceRoot":"","sources":["../../../../src/service/s3/storage/s3-memory-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;GAEG;AACH,qBAAa,qBAAsB,YAAW,kBAAkB;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAIxD;;OAEG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAQpD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7C;;;;OAIG;IACH,kBAAkB,IAAI,OAAO;CAG9B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default in-memory simulated S3 Bucket storage.
|
|
3
|
+
*/
|
|
4
|
+
export class MemoryS3BucketStorage {
|
|
5
|
+
objects = new Map();
|
|
6
|
+
/**
|
|
7
|
+
* Get a simulated Object from in-memory storage.
|
|
8
|
+
*/
|
|
9
|
+
getObject(key) {
|
|
10
|
+
return Promise.resolve(this.objects.get(key));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* List simulated Objects in in-memory storage.
|
|
14
|
+
*/
|
|
15
|
+
listObjects(prefix) {
|
|
16
|
+
const objects = [...this.objects.entries()]
|
|
17
|
+
.filter(([key]) => prefix === undefined || key.startsWith(prefix))
|
|
18
|
+
.map(([, object]) => object);
|
|
19
|
+
return Promise.resolve(objects);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Put a simulated Object into in-memory storage.
|
|
23
|
+
*/
|
|
24
|
+
putObject(object) {
|
|
25
|
+
this.objects.set(object.key, object);
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Is it OK to change to a different storage implementation?
|
|
30
|
+
* To reduce unexpected behaviours, we disallow changing from in-memory
|
|
31
|
+
* storage if it currently contains any objects.
|
|
32
|
+
*/
|
|
33
|
+
allowChangeStorage() {
|
|
34
|
+
return this.objects.size === 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=s3-memory-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-memory-storage.js","sourceRoot":"","sources":["../../../../src/service/s3/storage/s3-memory-storage.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACf,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE1D;;OAEG;IACH,SAAS,CAAC,GAAW;QACnB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,MAAe;QACzB,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;aACxC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aACjE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;QAE/B,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,MAAmB;QAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC;IACjC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kensio/yulin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "AWS system behaviour simulation for isolated unit testing",
|
|
5
5
|
"repository": "https://github.com/KensioSoftware/yulin",
|
|
6
6
|
"type": "module",
|
|
@@ -15,19 +15,31 @@
|
|
|
15
15
|
"isolated"
|
|
16
16
|
],
|
|
17
17
|
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
18
19
|
".": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
21
22
|
},
|
|
22
23
|
"./cloudfront": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
24
|
+
"import": "./dist/service/cloudfront/index.js",
|
|
25
|
+
"types": "./dist/service/cloudfront/index.d.ts"
|
|
25
26
|
},
|
|
26
27
|
"./cloudfront/globals": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
28
|
+
"import": "./dist/service/cloudfront/globals.js",
|
|
29
|
+
"types": "./dist/service/cloudfront/globals.d.ts"
|
|
29
30
|
},
|
|
30
|
-
"./
|
|
31
|
+
"./dynamodb": {
|
|
32
|
+
"import": "./dist/service/dynamodb/index.js",
|
|
33
|
+
"types": "./dist/service/dynamodb/index.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./s3": {
|
|
36
|
+
"import": "./dist/service/s3/index.js",
|
|
37
|
+
"types": "./dist/service/s3/index.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./serve": {
|
|
40
|
+
"import": "./dist/serve/index.js",
|
|
41
|
+
"types": "./dist/serve/index.d.ts"
|
|
42
|
+
}
|
|
31
43
|
},
|
|
32
44
|
"files": [
|
|
33
45
|
"dist",
|
|
@@ -37,11 +49,11 @@
|
|
|
37
49
|
"author": "Kensio Software",
|
|
38
50
|
"license": "AGPL-3.0",
|
|
39
51
|
"devDependencies": {
|
|
40
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
41
|
-
"@aws-sdk/client-s3": "^3.
|
|
52
|
+
"@aws-sdk/client-dynamodb": "^3.1057.0",
|
|
53
|
+
"@aws-sdk/client-s3": "^3.1057.0",
|
|
42
54
|
"@eslint/js": "^10.0.1",
|
|
43
55
|
"@faker-js/faker": "^10.4.0",
|
|
44
|
-
"@kensio/smartass": "^1.0.
|
|
56
|
+
"@kensio/smartass": "^1.0.2",
|
|
45
57
|
"@smithy/smithy-client": "^4.13.5",
|
|
46
58
|
"@smithy/types": "^4.14.2",
|
|
47
59
|
"@types/eslint-plugin-security": "^3.0.1",
|
|
@@ -50,7 +62,7 @@
|
|
|
50
62
|
"@vitest/coverage-v8": "^4.1.7",
|
|
51
63
|
"@vitest/eslint-plugin": "^1.6.18",
|
|
52
64
|
"aws-sdk-client-mock": "^4.1.0",
|
|
53
|
-
"eslint": "^10.4.
|
|
65
|
+
"eslint": "^10.4.1",
|
|
54
66
|
"eslint-config-prettier": "^10.1.8",
|
|
55
67
|
"eslint-plugin-jsdoc": "^62.9.0",
|
|
56
68
|
"eslint-plugin-no-secrets": "^2.3.3",
|
|
@@ -65,6 +77,7 @@
|
|
|
65
77
|
"peerDependencies": {
|
|
66
78
|
"@aws-sdk/client-dynamodb": "^3.1001.0",
|
|
67
79
|
"@aws-sdk/client-s3": "^3.1001.0",
|
|
80
|
+
"@faker-js/faker": "^10.4.0",
|
|
68
81
|
"@smithy/smithy-client": "^4.12.1"
|
|
69
82
|
},
|
|
70
83
|
"peerDependenciesMeta": {
|