@toa.io/extensions.storages 0.24.0-alpha.9 → 1.0.0-alpha.2
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 +11 -11
- package/readme.md +63 -19
- package/schemas/annotation.cos.yaml +10 -0
- package/schemas/fs.cos.yaml +9 -0
- package/schemas/mem.cos.yaml +6 -0
- package/schemas/s3.cos.yaml +16 -0
- package/schemas/test.cos.yaml +8 -0
- package/schemas/tmp.cos.yaml +9 -0
- package/source/Annotation.ts +39 -0
- package/source/Aspect.ts +6 -4
- package/source/Factory.ts +31 -28
- package/source/Provider.ts +30 -5
- package/source/Scanner.ts +3 -3
- package/source/Storage.test.ts +110 -105
- package/source/Storage.ts +13 -6
- package/source/deployment.ts +21 -29
- package/source/providers/Declaration.ts +10 -0
- package/source/providers/FileSystem.test.ts +1 -9
- package/source/providers/FileSystem.ts +20 -15
- package/source/providers/Memory.ts +41 -0
- package/source/providers/S3.test.ts +133 -0
- package/source/providers/S3.ts +114 -39
- package/source/providers/Temporary.ts +8 -6
- package/source/providers/Test.ts +8 -8
- package/source/providers/index.test.ts +24 -19
- package/source/providers/index.ts +10 -9
- package/source/providers/readme.md +1 -1
- package/source/schemas.test.ts +58 -0
- package/source/schemas.ts +15 -0
- package/source/test/util.ts +25 -54
- package/transpiled/Annotation.d.ts +3 -0
- package/transpiled/Annotation.js +57 -0
- package/transpiled/Annotation.js.map +1 -0
- package/transpiled/Aspect.d.ts +1 -1
- package/transpiled/Aspect.js +7 -3
- package/transpiled/Aspect.js.map +1 -1
- package/transpiled/Factory.d.ts +2 -3
- package/transpiled/Factory.js +24 -21
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Provider.d.ts +17 -5
- package/transpiled/Provider.js +33 -0
- package/transpiled/Provider.js.map +1 -1
- package/transpiled/Scanner.d.ts +2 -2
- package/transpiled/Scanner.js +2 -2
- package/transpiled/Scanner.js.map +1 -1
- package/transpiled/Storage.d.ts +6 -2
- package/transpiled/Storage.js +5 -5
- package/transpiled/Storage.js.map +1 -1
- package/transpiled/deployment.d.ts +2 -3
- package/transpiled/deployment.js +39 -23
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/providers/Declaration.d.ts +14 -0
- package/transpiled/providers/Declaration.js +3 -0
- package/transpiled/providers/Declaration.js.map +1 -0
- package/transpiled/providers/FileSystem.d.ts +7 -3
- package/transpiled/providers/FileSystem.js +17 -14
- package/transpiled/providers/FileSystem.js.map +1 -1
- package/transpiled/providers/Memory.d.ts +13 -0
- package/transpiled/providers/Memory.js +60 -0
- package/transpiled/providers/Memory.js.map +1 -0
- package/transpiled/providers/S3.d.ts +20 -6
- package/transpiled/providers/S3.js +111 -32
- package/transpiled/providers/S3.js.map +1 -1
- package/transpiled/providers/Temporary.d.ts +5 -2
- package/transpiled/providers/Temporary.js +3 -4
- package/transpiled/providers/Temporary.js.map +1 -1
- package/transpiled/providers/Test.d.ts +4 -3
- package/transpiled/providers/Test.js +6 -9
- package/transpiled/providers/Test.js.map +1 -1
- package/transpiled/providers/index.d.ts +12 -4
- package/transpiled/providers/index.js +6 -4
- package/transpiled/providers/index.js.map +1 -1
- package/transpiled/schemas.d.ts +9 -0
- package/transpiled/schemas.js +14 -0
- package/transpiled/schemas.js.map +1 -0
- package/transpiled/test/util.d.ts +29 -10
- package/transpiled/test/util.js +17 -40
- package/transpiled/test/util.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -5,10 +5,12 @@ const FileSystem_1 = require("./FileSystem");
|
|
|
5
5
|
const S3_1 = require("./S3");
|
|
6
6
|
const Temporary_1 = require("./Temporary");
|
|
7
7
|
const Test_1 = require("./Test");
|
|
8
|
+
const Memory_1 = require("./Memory");
|
|
8
9
|
exports.providers = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
s3: S3_1.S3,
|
|
11
|
+
fs: FileSystem_1.FileSystem,
|
|
12
|
+
tmp: Temporary_1.Temporary,
|
|
13
|
+
mem: Memory_1.InMemory,
|
|
14
|
+
test: Test_1.Test
|
|
13
15
|
};
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/providers/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/providers/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,6BAAyB;AACzB,2CAAuC;AACvC,iCAA6B;AAC7B,qCAAmC;AAGtB,QAAA,SAAS,GAAG;IACvB,EAAE,EAAE,OAAE;IACN,EAAE,EAAE,uBAAU;IACd,GAAG,EAAE,qBAAS;IACd,GAAG,EAAE,iBAAQ;IACb,IAAI,EAAE,WAAI;CAC4C,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Declaration } from './providers';
|
|
2
|
+
import type { Schema } from '@toa.io/schemas';
|
|
3
|
+
import type { Annotation } from './Annotation';
|
|
4
|
+
export declare const annotation: Schema<Annotation>;
|
|
5
|
+
export declare const s3: Schema<Declaration>;
|
|
6
|
+
export declare const fs: Schema<Declaration>;
|
|
7
|
+
export declare const mem: Schema<Declaration>;
|
|
8
|
+
export declare const tmp: Schema<Declaration>;
|
|
9
|
+
export declare const test: Schema<Declaration>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.test = exports.tmp = exports.mem = exports.fs = exports.s3 = exports.annotation = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const schemas_1 = require("@toa.io/schemas");
|
|
6
|
+
const path = (0, node_path_1.resolve)(__dirname, '../schemas');
|
|
7
|
+
const ns = (0, schemas_1.namespace)(path);
|
|
8
|
+
exports.annotation = ns.schema('annotation');
|
|
9
|
+
exports.s3 = ns.schema('s3');
|
|
10
|
+
exports.fs = ns.schema('fs');
|
|
11
|
+
exports.mem = ns.schema('mem');
|
|
12
|
+
exports.tmp = ns.schema('tmp');
|
|
13
|
+
exports.test = ns.schema('test');
|
|
14
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../source/schemas.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,6CAA2C;AAK3C,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,YAAY,CAAC,CAAA;AAC7C,MAAM,EAAE,GAAG,IAAA,mBAAS,EAAC,IAAI,CAAC,CAAA;AAEb,QAAA,UAAU,GAAuB,EAAE,CAAC,MAAM,CAAa,YAAY,CAAC,CAAA;AACpE,QAAA,EAAE,GAAwB,EAAE,CAAC,MAAM,CAAc,IAAI,CAAC,CAAA;AACtD,QAAA,EAAE,GAAwB,EAAE,CAAC,MAAM,CAAc,IAAI,CAAC,CAAA;AACtD,QAAA,GAAG,GAAwB,EAAE,CAAC,MAAM,CAAc,KAAK,CAAC,CAAA;AACxD,QAAA,GAAG,GAAwB,EAAE,CAAC,MAAM,CAAc,KAAK,CAAC,CAAA;AACxD,QAAA,IAAI,GAAwB,EAAE,CAAC,MAAM,CAAc,MAAM,CAAC,CAAA"}
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
export declare const suites: ({
|
|
2
|
+
run: true;
|
|
3
|
+
provider: "tmp";
|
|
4
|
+
options: {
|
|
5
|
+
directory: string;
|
|
6
|
+
endpoint?: undefined;
|
|
7
|
+
region?: undefined;
|
|
8
|
+
bucket?: undefined;
|
|
9
|
+
};
|
|
10
|
+
secrets?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
run: true;
|
|
13
|
+
provider: "mem";
|
|
14
|
+
options?: undefined;
|
|
15
|
+
secrets?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
run: boolean;
|
|
18
|
+
provider: "s3";
|
|
19
|
+
options: {
|
|
20
|
+
endpoint: string;
|
|
21
|
+
region: string;
|
|
22
|
+
bucket: string;
|
|
23
|
+
directory?: undefined;
|
|
24
|
+
};
|
|
25
|
+
secrets: {
|
|
26
|
+
ACCESS_KEY_ID: string;
|
|
27
|
+
SECRET_ACCESS_KEY: string;
|
|
28
|
+
};
|
|
29
|
+
})[];
|
package/transpiled/test/util.js
CHANGED
|
@@ -3,59 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.suites = void 0;
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
9
|
-
const node_fs_1 = require("node:fs");
|
|
10
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
11
8
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
12
9
|
dotenv_1.default.config({ path: (0, node_path_1.join)(__dirname, '.env') });
|
|
13
|
-
|
|
10
|
+
exports.suites = [
|
|
14
11
|
{
|
|
15
12
|
run: true,
|
|
16
|
-
|
|
13
|
+
provider: 'tmp',
|
|
14
|
+
options: {
|
|
15
|
+
directory: 'toa-storages-temp'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
run: true,
|
|
20
|
+
provider: 'mem'
|
|
17
21
|
},
|
|
18
22
|
{
|
|
19
23
|
run: process.env.RUN_S3 === '1',
|
|
20
|
-
|
|
24
|
+
provider: 's3',
|
|
25
|
+
options: {
|
|
26
|
+
endpoint: 'http://localhost:4566',
|
|
27
|
+
region: 'us-west-1',
|
|
28
|
+
bucket: 'test-bucket'
|
|
29
|
+
},
|
|
21
30
|
secrets: {
|
|
22
31
|
ACCESS_KEY_ID: 'developer',
|
|
23
32
|
SECRET_ACCESS_KEY: 'secret'
|
|
24
|
-
}
|
|
25
|
-
init: initS3
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
35
|
// add more providers here, use `run` as a condition to run the test
|
|
28
36
|
// e.g.: `run: process.env.ACCESS_KEY_ID !== undefined`
|
|
29
37
|
];
|
|
30
|
-
function map(suite) {
|
|
31
|
-
const url = new URL(suite.ref);
|
|
32
|
-
return [url.protocol, url, suite.secrets ?? {}, suite.init];
|
|
33
|
-
}
|
|
34
|
-
exports.cases = suites.filter(({ run }) => run).map(map);
|
|
35
|
-
function rnd() {
|
|
36
|
-
return Math.random().toString(36).slice(2);
|
|
37
|
-
}
|
|
38
|
-
exports.rnd = rnd;
|
|
39
|
-
function open(rel) {
|
|
40
|
-
const path = (0, node_path_1.join)(__dirname, rel);
|
|
41
|
-
return (0, node_fs_1.createReadStream)(path);
|
|
42
|
-
}
|
|
43
|
-
exports.open = open;
|
|
44
|
-
async function read(rel) {
|
|
45
|
-
const path = (0, node_path_1.join)(__dirname, rel);
|
|
46
|
-
return await promises_1.default.readFile(path);
|
|
47
|
-
}
|
|
48
|
-
exports.read = read;
|
|
49
|
-
async function initS3(url, secrets) {
|
|
50
|
-
const client = new client_s3_1.S3Client({
|
|
51
|
-
credentials: {
|
|
52
|
-
accessKeyId: secrets.ACCESS_KEY_ID,
|
|
53
|
-
secretAccessKey: secrets.SECRET_ACCESS_KEY
|
|
54
|
-
},
|
|
55
|
-
region: url.host,
|
|
56
|
-
endpoint: url.searchParams.get('endpoint') ?? undefined
|
|
57
|
-
});
|
|
58
|
-
const command = new client_s3_1.CreateBucketCommand({ Bucket: url.pathname.substring(1) });
|
|
59
|
-
await client.send(command).catch(() => undefined);
|
|
60
|
-
}
|
|
61
38
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../source/test/util.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../source/test/util.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAgC;AAChC,oDAA2B;AAO3B,gBAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAA,gBAAI,EAAC,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;AAEnC,QAAA,MAAM,GAAG;IACpB;QACE,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE;YACP,SAAS,EAAE,mBAAmB;SAC/B;KACF;IACD;QACE,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,KAAK;KAChB;IACD;QACE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG;QAC/B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,QAAQ,EAAE,uBAAuB;YACjC,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,aAAa;SACtB;QACD,OAAO,EAAE;YACP,aAAa,EAAE,WAAW;YAC1B,iBAAiB,EAAE,QAAQ;SAC5B;KACF;IACD,oEAAoE;IACpE,uDAAuD;CACtC,CAAA"}
|