@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
package/transpiled/deployment.js
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deployment = void 0;
|
|
4
|
-
const
|
|
26
|
+
exports.deployment = exports.SERIALIZATION_PREFIX = void 0;
|
|
27
|
+
const assert = __importStar(require("node:assert"));
|
|
28
|
+
const generic_1 = require("@toa.io/generic");
|
|
5
29
|
const providers_1 = require("./providers");
|
|
30
|
+
const Annotation_1 = require("./Annotation");
|
|
31
|
+
exports.SERIALIZATION_PREFIX = 'TOA_STORAGES';
|
|
6
32
|
function deployment(instances, annotation) {
|
|
7
33
|
validate(instances, annotation);
|
|
8
|
-
const value = (0,
|
|
9
|
-
const pointer = { name:
|
|
34
|
+
const value = (0, generic_1.encode)(annotation);
|
|
35
|
+
const pointer = { name: exports.SERIALIZATION_PREFIX, value };
|
|
10
36
|
const secrets = getSecrets(annotation);
|
|
11
37
|
return {
|
|
12
38
|
variables: { global: [pointer, ...secrets] }
|
|
@@ -14,36 +40,26 @@ function deployment(instances, annotation) {
|
|
|
14
40
|
}
|
|
15
41
|
exports.deployment = deployment;
|
|
16
42
|
function validate(instances, annotation) {
|
|
17
|
-
|
|
18
|
-
throw new Error('Storages annotation is required by: ' +
|
|
19
|
-
`'${instances.map((i) => i.component.locator.id).join("', '")}'`);
|
|
43
|
+
(0, Annotation_1.validateAnnotation)(annotation);
|
|
20
44
|
for (const instance of instances)
|
|
21
45
|
contains(instance, annotation);
|
|
22
|
-
for (const ref of Object.values(annotation)) {
|
|
23
|
-
const url = new URL(ref);
|
|
24
|
-
if (!(url.protocol in providers_1.providers))
|
|
25
|
-
throw new Error(`Unknown storage provider '${url.protocol}'`);
|
|
26
|
-
}
|
|
27
46
|
}
|
|
28
47
|
function contains(instance, annotation) {
|
|
29
48
|
for (const name of instance.manifest)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`declared in '${instance.component.locator.id}'`);
|
|
49
|
+
assert.ok(name in annotation, `Missing '${name}' storage annotation ` +
|
|
50
|
+
`declared in '${instance.component.locator.id}'`);
|
|
33
51
|
}
|
|
34
52
|
function getSecrets(annotation) {
|
|
35
53
|
const secrets = [];
|
|
36
|
-
for (const [
|
|
37
|
-
const
|
|
38
|
-
const Provider = providers_1.providers[url.protocol];
|
|
39
|
-
if (Provider.SECRETS === undefined)
|
|
40
|
-
continue;
|
|
54
|
+
for (const [name, declaration] of Object.entries(annotation)) {
|
|
55
|
+
const Provider = providers_1.providers[declaration.provider];
|
|
41
56
|
for (const secret of Provider.SECRETS)
|
|
42
57
|
secrets.push({
|
|
43
|
-
name:
|
|
58
|
+
name: `${exports.SERIALIZATION_PREFIX}_${name}_${secret.name}`.toUpperCase(),
|
|
44
59
|
secret: {
|
|
45
|
-
name: `toa-storages-${
|
|
46
|
-
key: secret
|
|
60
|
+
name: `toa-storages-${name}`,
|
|
61
|
+
key: secret.name,
|
|
62
|
+
optional: secret.optional
|
|
47
63
|
}
|
|
48
64
|
});
|
|
49
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../source/deployment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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,QAAQ,GAAG,qBAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAEhD,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO;YACnC,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,GAAG,4BAAoB,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpE,MAAM,EAAE;oBACN,IAAI,EAAE,gBAAgB,IAAI,EAAE;oBAC5B,GAAG,EAAE,MAAM,CAAC,IAAI;oBAChB,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBAC1B;aACF,CAAC,CAAA;IACN,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { S3Options } from './S3';
|
|
2
|
+
import type { FileSystemOptions } from './FileSystem';
|
|
3
|
+
import type { TemporaryOptions } from './Temporary';
|
|
4
|
+
export type Declaration = ({
|
|
5
|
+
provider: 's3';
|
|
6
|
+
} & S3Options) | ({
|
|
7
|
+
provider: 'fs';
|
|
8
|
+
} & FileSystemOptions) | ({
|
|
9
|
+
provider: 'tmp';
|
|
10
|
+
} & TemporaryOptions) | ({
|
|
11
|
+
provider: 'mem';
|
|
12
|
+
}) | ({
|
|
13
|
+
provider: 'test';
|
|
14
|
+
} & TemporaryOptions);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Declaration.js","sourceRoot":"","sources":["../../source/providers/Declaration.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { type Readable } from 'node:stream';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { Provider } from '../Provider';
|
|
4
|
+
import type { ProviderSecrets } from '../Provider';
|
|
5
|
+
export interface FileSystemOptions {
|
|
6
|
+
path: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class FileSystem extends Provider<FileSystemOptions> {
|
|
5
9
|
protected readonly path: string;
|
|
6
|
-
constructor(
|
|
10
|
+
constructor(options: FileSystemOptions, secrets?: ProviderSecrets);
|
|
7
11
|
get(path: string): Promise<Readable | null>;
|
|
8
12
|
put(rel: string, filename: string, stream: Readable): Promise<void>;
|
|
9
13
|
delete(path: string): Promise<void>;
|
|
@@ -5,35 +5,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FileSystem = void 0;
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
|
-
const node_fs_1 = require("node:fs");
|
|
9
8
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
10
|
-
const
|
|
11
|
-
class FileSystem {
|
|
9
|
+
const Provider_1 = require("../Provider");
|
|
10
|
+
class FileSystem extends Provider_1.Provider {
|
|
12
11
|
path;
|
|
13
|
-
constructor(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.path = url.pathname;
|
|
12
|
+
constructor(options, secrets) {
|
|
13
|
+
super(options, secrets);
|
|
14
|
+
this.path = options.path;
|
|
17
15
|
}
|
|
18
16
|
async get(path) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
|
|
17
|
+
try {
|
|
18
|
+
const fd = await promises_1.default.open((0, node_path_1.join)(this.path, path));
|
|
19
|
+
return fd.createReadStream();
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (err?.code === 'ENOENT')
|
|
23
|
+
return null;
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
async put(rel, filename, stream) {
|
|
25
28
|
const dir = (0, node_path_1.join)(this.path, rel);
|
|
26
29
|
const path = (0, node_path_1.join)(dir, filename);
|
|
27
|
-
await
|
|
30
|
+
await promises_1.default.mkdir((0, node_path_1.dirname)(path), { recursive: true });
|
|
28
31
|
await promises_1.default.writeFile(path, stream);
|
|
29
32
|
}
|
|
30
33
|
async delete(path) {
|
|
31
|
-
await
|
|
34
|
+
await promises_1.default.rm((0, node_path_1.join)(this.path, path), { recursive: true, force: true });
|
|
32
35
|
}
|
|
33
36
|
async move(from, to) {
|
|
34
37
|
from = (0, node_path_1.join)(this.path, from);
|
|
35
38
|
to = (0, node_path_1.join)(this.path, to);
|
|
36
|
-
await
|
|
39
|
+
await promises_1.default.mkdir((0, node_path_1.dirname)(to), { recursive: true });
|
|
37
40
|
await promises_1.default.rename(from, to);
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.js","sourceRoot":"","sources":["../../source/providers/FileSystem.ts"],"names":[],"mappings":";;;;;;AACA,yCAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"FileSystem.js","sourceRoot":"","sources":["../../source/providers/FileSystem.ts"],"names":[],"mappings":";;;;;;AACA,yCAAyC;AACzC,gEAAiC;AACjC,0CAAsC;AAOtC,MAAa,UAAW,SAAQ,mBAA2B;IACtC,IAAI,CAAQ;IAE/B,YAAoB,OAA0B,EAAE,OAAyB;QACvE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAEvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IAC1B,CAAC;IAEM,KAAK,CAAC,GAAG,CAAE,IAAY;QAC5B,IAAI,CAAC;YACH,MAAM,EAAE,GAAG,MAAM,kBAAE,CAAC,IAAI,CAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;YAE/C,OAAO,EAAE,CAAC,gBAAgB,EAAE,CAAA;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAK,GAA6B,EAAE,IAAI,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAA;YAElE,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,GAAG,CAAE,GAAW,EAAE,QAAgB,EAAE,MAAgB;QAC/D,MAAM,GAAG,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QAChC,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QAEhC,MAAM,kBAAE,CAAC,KAAK,CAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAClD,MAAM,kBAAE,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAClC,CAAC;IAEM,KAAK,CAAC,MAAM,CAAE,IAAY;QAC/B,MAAM,kBAAE,CAAC,EAAE,CAAC,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACtE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAE,IAAY,EAAE,EAAU;QACzC,IAAI,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC5B,EAAE,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAExB,MAAM,kBAAE,CAAC,KAAK,CAAC,IAAA,mBAAO,EAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAChD,MAAM,kBAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IAC3B,CAAC;CACF;AAxCD,gCAwCC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
import { Provider } from '../Provider';
|
|
4
|
+
/**
|
|
5
|
+
* In-memory provider
|
|
6
|
+
*/
|
|
7
|
+
export declare class InMemory extends Provider {
|
|
8
|
+
private readonly storage;
|
|
9
|
+
get(path: string): Promise<Readable | null>;
|
|
10
|
+
put(path: string, filename: string, stream: Readable): Promise<void>;
|
|
11
|
+
delete(path: string): Promise<void>;
|
|
12
|
+
move(from: string, to: string): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.InMemory = void 0;
|
|
27
|
+
const node_stream_1 = require("node:stream");
|
|
28
|
+
const node_path_1 = require("node:path");
|
|
29
|
+
const consumers_1 = require("node:stream/consumers");
|
|
30
|
+
const assert = __importStar(require("node:assert"));
|
|
31
|
+
const Provider_1 = require("../Provider");
|
|
32
|
+
/**
|
|
33
|
+
* In-memory provider
|
|
34
|
+
*/
|
|
35
|
+
class InMemory extends Provider_1.Provider {
|
|
36
|
+
storage = new Map();
|
|
37
|
+
async get(path) {
|
|
38
|
+
const data = this.storage.get(path);
|
|
39
|
+
if (data === undefined)
|
|
40
|
+
return null;
|
|
41
|
+
return node_stream_1.Readable.from(data);
|
|
42
|
+
}
|
|
43
|
+
async put(path, filename, stream) {
|
|
44
|
+
this.storage.set((0, node_path_1.join)(path, filename), await (0, consumers_1.buffer)(stream));
|
|
45
|
+
}
|
|
46
|
+
async delete(path) {
|
|
47
|
+
for (const f of this.storage.keys())
|
|
48
|
+
if (f.startsWith(path))
|
|
49
|
+
this.storage.delete(f);
|
|
50
|
+
}
|
|
51
|
+
async move(from, to) {
|
|
52
|
+
assert.notEqual(from, to, 'Source and destination are the same');
|
|
53
|
+
const buf = this.storage.get(from);
|
|
54
|
+
assert.ok(buf !== undefined, `File not found: ${from}`);
|
|
55
|
+
this.storage.set(to, buf);
|
|
56
|
+
this.storage.delete(from);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.InMemory = InMemory;
|
|
60
|
+
//# sourceMappingURL=Memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Memory.js","sourceRoot":"","sources":["../../source/providers/Memory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAsC;AACtC,yCAAgC;AAChC,qDAA8C;AAC9C,oDAAqC;AAErC,0CAAsC;AAEtC;;GAEG;AACH,MAAa,QAAS,SAAQ,mBAAQ;IACnB,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAA;IAEpC,KAAK,CAAC,GAAG,CAAE,IAAY;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEnC,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAA;QAEnC,OAAO,sBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;IAEe,KAAK,CAAC,GAAG,CAAE,IAAY,EAAE,QAAgB,EAAE,MAAgB;QACzE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,gBAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAA,kBAAM,EAAC,MAAM,CAAC,CAAC,CAAA;IAC9D,CAAC;IAEe,KAAK,CAAC,MAAM,CAAE,IAAY;QACxC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YACjC,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;IAEe,KAAK,CAAC,IAAI,CAAE,IAAY,EAAE,EAAU;QAClD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,qCAAqC,CAAC,CAAA;QAEhE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAElC,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,SAAS,EAAE,mBAAmB,IAAI,EAAE,CAAC,CAAA;QAEvD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;QACzB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;CACF;AA9BD,4BA8BC"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
3
|
import { S3Client } from '@aws-sdk/client-s3';
|
|
4
|
-
import { type
|
|
5
|
-
export
|
|
4
|
+
import { Provider, type ProviderSecret, type ProviderSecrets } from '../Provider';
|
|
5
|
+
export interface S3Options {
|
|
6
|
+
bucket: string;
|
|
7
|
+
region?: string;
|
|
8
|
+
prefix?: string;
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
}
|
|
11
|
+
type S3Secrets = ProviderSecrets<'ACCESS_KEY_ID' | 'SECRET_ACCESS_KEY'>;
|
|
12
|
+
export declare class S3 extends Provider<S3Options> {
|
|
13
|
+
static readonly SECRETS: readonly ProviderSecret[];
|
|
6
14
|
protected readonly bucket: string;
|
|
7
15
|
protected readonly client: S3Client;
|
|
8
|
-
constructor(
|
|
9
|
-
get(
|
|
16
|
+
constructor(options: S3Options, secrets?: S3Secrets);
|
|
17
|
+
get(Key: string): Promise<Readable | null>;
|
|
10
18
|
put(path: string, filename: string, stream: Readable): Promise<void>;
|
|
11
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Deletes either a single object or "directory" - all objects
|
|
21
|
+
* with given prefix (prefix will be enforced to finish with `/`)
|
|
22
|
+
* @param Key - key name or path prefix
|
|
23
|
+
*/
|
|
24
|
+
delete(Key: string): Promise<void>;
|
|
12
25
|
move(from: string, keyTo: string): Promise<void>;
|
|
13
26
|
}
|
|
27
|
+
export {};
|
|
@@ -1,74 +1,153 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
29
|
exports.S3 = void 0;
|
|
30
|
+
const node_stream_1 = require("node:stream");
|
|
31
|
+
const node_buffer_1 = require("node:buffer");
|
|
4
32
|
const posix_1 = require("node:path/posix");
|
|
33
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
5
34
|
const lib_storage_1 = require("@aws-sdk/lib-storage");
|
|
6
35
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
7
|
-
|
|
36
|
+
const nodeNativeFetch = __importStar(require("smithy-node-native-fetch"));
|
|
37
|
+
const Provider_1 = require("../Provider");
|
|
38
|
+
class S3 extends Provider_1.Provider {
|
|
39
|
+
static SECRETS = [
|
|
40
|
+
{ name: 'ACCESS_KEY_ID', optional: true },
|
|
41
|
+
{ name: 'SECRET_ACCESS_KEY', optional: true }
|
|
42
|
+
];
|
|
8
43
|
bucket;
|
|
9
44
|
client;
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
throw new Error('S3 bucket not specified');
|
|
45
|
+
constructor(options, secrets) {
|
|
46
|
+
super(options);
|
|
47
|
+
this.bucket = options.bucket;
|
|
14
48
|
const s3Config = {
|
|
15
|
-
|
|
49
|
+
retryMode: 'adaptive',
|
|
50
|
+
...nodeNativeFetch
|
|
51
|
+
};
|
|
52
|
+
if (options.endpoint !== undefined) {
|
|
53
|
+
s3Config.forcePathStyle = options.endpoint.startsWith('http://');
|
|
54
|
+
s3Config.endpoint = options.endpoint;
|
|
55
|
+
}
|
|
56
|
+
if (options.region !== undefined)
|
|
57
|
+
s3Config.region = options.region;
|
|
58
|
+
if (typeof secrets?.ACCESS_KEY_ID === 'string') {
|
|
59
|
+
node_assert_1.default.ok(secrets.SECRET_ACCESS_KEY !== undefined, 'SECRET_ACCESS_KEY is required if ACCESS_KEY_ID is provided');
|
|
60
|
+
s3Config.credentials = {
|
|
16
61
|
accessKeyId: secrets.ACCESS_KEY_ID,
|
|
17
62
|
secretAccessKey: secrets.SECRET_ACCESS_KEY
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
endpoint: url.searchParams.get('endpoint') ?? undefined
|
|
21
|
-
};
|
|
63
|
+
};
|
|
64
|
+
}
|
|
22
65
|
this.client = new client_s3_1.S3Client(s3Config);
|
|
66
|
+
this.client.middlewareStack.add((next, _context) => async (args) => {
|
|
67
|
+
if ('Key' in args.input && typeof args.input.Key === 'string')
|
|
68
|
+
// removes leading slash
|
|
69
|
+
args.input.Key = args.input.Key.replace(/^\//, '');
|
|
70
|
+
if ('Prefix' in args.input && typeof args.input.Prefix === 'string')
|
|
71
|
+
// removes leading slash and ensures finishing slash
|
|
72
|
+
args.input.Prefix = args.input.Prefix.replace(/^\/|\/$/g, '') + '/';
|
|
73
|
+
return next(args);
|
|
74
|
+
}, {
|
|
75
|
+
step: 'initialize',
|
|
76
|
+
priority: 'high',
|
|
77
|
+
name: 'normalizesSlashesInPath'
|
|
78
|
+
});
|
|
23
79
|
}
|
|
24
|
-
async get(
|
|
80
|
+
async get(Key) {
|
|
25
81
|
try {
|
|
26
82
|
const fileResponse = await this.client.send(new client_s3_1.GetObjectCommand({
|
|
27
83
|
Bucket: this.bucket,
|
|
28
|
-
Key
|
|
84
|
+
Key
|
|
29
85
|
}));
|
|
30
|
-
|
|
86
|
+
if (fileResponse.Body === undefined)
|
|
87
|
+
return null; // should never happen
|
|
88
|
+
if (fileResponse.Body instanceof node_stream_1.Readable)
|
|
89
|
+
return fileResponse.Body;
|
|
90
|
+
return node_stream_1.Readable.fromWeb((fileResponse.Body instanceof node_buffer_1.Blob
|
|
91
|
+
? fileResponse.Body.stream()
|
|
92
|
+
: fileResponse.Body)); // types mismatch between Node 20 and aws-sdk
|
|
31
93
|
}
|
|
32
94
|
catch (err) {
|
|
33
|
-
if (err
|
|
95
|
+
if (err instanceof client_s3_1.NotFound || err instanceof client_s3_1.NoSuchKey)
|
|
34
96
|
return null;
|
|
35
97
|
else
|
|
36
98
|
throw err;
|
|
37
99
|
}
|
|
38
100
|
}
|
|
39
101
|
async put(path, filename, stream) {
|
|
40
|
-
const key = (0, posix_1.join)(path, filename);
|
|
41
102
|
await new lib_storage_1.Upload({
|
|
42
103
|
client: this.client,
|
|
43
104
|
params: {
|
|
44
105
|
Bucket: this.bucket,
|
|
45
|
-
Key:
|
|
106
|
+
Key: (0, posix_1.join)(path, filename),
|
|
46
107
|
Body: stream
|
|
47
108
|
}
|
|
48
109
|
}).done();
|
|
49
110
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Deletes either a single object or "directory" - all objects
|
|
113
|
+
* with given prefix (prefix will be enforced to finish with `/`)
|
|
114
|
+
* @param Key - key name or path prefix
|
|
115
|
+
*/
|
|
116
|
+
async delete(Key) {
|
|
117
|
+
const { client, bucket: Bucket } = this;
|
|
118
|
+
// checking if given key is a single file
|
|
119
|
+
if (!Key.endsWith('/'))
|
|
120
|
+
try {
|
|
121
|
+
// DeleteObject on S3 returns no error if object does not exist
|
|
122
|
+
await client.send(new client_s3_1.HeadObjectCommand({ Bucket, Key }));
|
|
123
|
+
await client.send(new client_s3_1.DeleteObjectCommand({ Bucket, Key }));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
node_assert_1.default.ok(err instanceof client_s3_1.NotFound || err instanceof client_s3_1.NoSuchKey, err);
|
|
128
|
+
}
|
|
129
|
+
const objectsToRemove = [];
|
|
130
|
+
for await (const page of (0, client_s3_1.paginateListObjectsV2)({ client }, { Bucket, Prefix: Key }))
|
|
131
|
+
for (const { Key } of page.Contents ?? [])
|
|
132
|
+
objectsToRemove.push({ Key });
|
|
133
|
+
// Removing all objects in parallel in batches
|
|
134
|
+
await Promise.all((function* () {
|
|
135
|
+
while (objectsToRemove.length > 0)
|
|
136
|
+
yield client.send(new client_s3_1.DeleteObjectsCommand({
|
|
137
|
+
Bucket,
|
|
138
|
+
Delete: {
|
|
139
|
+
Objects: objectsToRemove.splice(0, 1000 /* max batch size for DeleteObjects */)
|
|
140
|
+
}
|
|
141
|
+
}));
|
|
142
|
+
})());
|
|
62
143
|
}
|
|
63
144
|
async move(from, keyTo) {
|
|
64
|
-
const keyFrom = (0, posix_1.join)(this.bucket, from);
|
|
65
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
66
145
|
await this.client.send(new client_s3_1.CopyObjectCommand({
|
|
67
146
|
Bucket: this.bucket,
|
|
68
147
|
Key: keyTo,
|
|
69
|
-
CopySource:
|
|
148
|
+
CopySource: (0, posix_1.join)(this.bucket, from)
|
|
70
149
|
}));
|
|
71
|
-
await this.
|
|
150
|
+
await this.client.send(new client_s3_1.DeleteObjectCommand({ Bucket: this.bucket, Key: from }));
|
|
72
151
|
}
|
|
73
152
|
}
|
|
74
153
|
exports.S3 = S3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"S3.js","sourceRoot":"","sources":["../../source/providers/S3.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"S3.js","sourceRoot":"","sources":["../../source/providers/S3.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAsC;AACtC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ptions {
|
|
4
|
+
directory: string;
|
|
5
|
+
}
|
|
2
6
|
export declare class Temporary extends FileSystem {
|
|
3
|
-
|
|
4
|
-
constructor(url: URL);
|
|
7
|
+
constructor(options: TemporaryOptions, secrets?: ProviderSecrets);
|
|
5
8
|
}
|
|
@@ -5,10 +5,9 @@ const node_os_1 = require("node:os");
|
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const FileSystem_1 = require("./FileSystem");
|
|
7
7
|
class Temporary extends FileSystem_1.FileSystem {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
super(
|
|
11
|
-
this.path = (0, node_path_1.join)((0, node_os_1.tmpdir)(), url.pathname);
|
|
8
|
+
constructor(options, secrets) {
|
|
9
|
+
const path = (0, node_path_1.join)((0, node_os_1.tmpdir)(), options.directory);
|
|
10
|
+
super({ path }, secrets);
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
exports.Temporary = Temporary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Temporary.js","sourceRoot":"","sources":["../../source/providers/Temporary.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAChC,yCAAgC;
|
|
1
|
+
{"version":3,"file":"Temporary.js","sourceRoot":"","sources":["../../source/providers/Temporary.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAChC,yCAAgC;AAChC,6CAAyC;AAOzC,MAAa,SAAU,SAAQ,uBAAU;IACvC,YAAoB,OAAyB,EAAE,OAAyB;QACtE,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QAE9C,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAA;IAC1B,CAAC;CACF;AAND,8BAMC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Temporary } from './Temporary';
|
|
1
|
+
import { Temporary, type TemporaryOptions } from './Temporary';
|
|
2
|
+
import type { ProviderSecret, ProviderSecrets } from '../Provider';
|
|
2
3
|
export declare class Test extends Temporary {
|
|
3
|
-
static readonly SECRETS:
|
|
4
|
-
constructor(
|
|
4
|
+
static readonly SECRETS: readonly ProviderSecret[];
|
|
5
|
+
constructor(options: TemporaryOptions, secrets?: ProviderSecrets);
|
|
5
6
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Test = void 0;
|
|
7
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
4
|
const Temporary_1 = require("./Temporary");
|
|
9
5
|
class Test extends Temporary_1.Temporary {
|
|
10
|
-
static SECRETS = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
static SECRETS = [
|
|
7
|
+
{ name: 'USERNAME' },
|
|
8
|
+
{ name: 'PASSWORD' }
|
|
9
|
+
];
|
|
10
|
+
constructor(options, secrets) {
|
|
11
|
+
super(options, secrets);
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
14
|
exports.Test = Test;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Test.js","sourceRoot":"","sources":["../../source/providers/Test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Test.js","sourceRoot":"","sources":["../../source/providers/Test.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAG9D,MAAa,IAAK,SAAQ,qBAAS;IAC1B,MAAM,CAAmB,OAAO,GAA8B;QACnE,EAAE,IAAI,EAAE,UAAU,EAAE;QACpB,EAAE,IAAI,EAAE,UAAU,EAAE;KACrB,CAAA;IAED,YAAoB,OAAyB,EAAE,OAAyB;QACtE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACzB,CAAC;;AARH,oBASC"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { FileSystem } from './FileSystem';
|
|
2
|
+
import { S3 } from './S3';
|
|
3
|
+
import { Temporary } from './Temporary';
|
|
4
|
+
import { Test } from './Test';
|
|
5
|
+
import { InMemory } from './Memory';
|
|
6
|
+
export declare const providers: {
|
|
7
|
+
readonly s3: typeof S3;
|
|
8
|
+
readonly fs: typeof FileSystem;
|
|
9
|
+
readonly tmp: typeof Temporary;
|
|
10
|
+
readonly mem: typeof InMemory;
|
|
11
|
+
readonly test: typeof Test;
|
|
5
12
|
};
|
|
13
|
+
export type { Declaration } from './Declaration';
|