@toa.io/extensions.storages 1.0.0-alpha.21 → 1.0.0-alpha.219
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 +14 -14
- package/readme.md +96 -51
- package/schemas/annotation.cos.yaml +1 -0
- package/schemas/cloudinary.cos.yaml +37 -0
- package/schemas/fs.cos.yaml +2 -0
- package/schemas/s3.cos.yaml +1 -0
- package/schemas/tmp.cos.yaml +0 -1
- package/source/Entry.ts +13 -11
- package/source/Factory.ts +16 -9
- package/source/Provider.ts +22 -19
- package/source/Scanner.ts +58 -26
- package/source/Secrets.ts +6 -0
- package/source/Storage.test.ts +118 -274
- package/source/Storage.ts +62 -207
- package/source/deployment.ts +52 -16
- package/source/errors.ts +3 -0
- package/source/index.ts +3 -1
- package/source/manifest.ts +7 -6
- package/source/providers/Cloudinary.ts +320 -0
- package/source/providers/Declaration.ts +2 -1
- package/source/providers/FileSystem.ts +79 -25
- package/source/providers/S3.ts +81 -80
- package/source/providers/Temporary.ts +2 -3
- package/source/providers/Test.ts +4 -4
- package/source/providers/index.test.ts +102 -76
- package/source/providers/index.ts +10 -4
- package/source/schemas.ts +1 -0
- package/source/test/.env.example +4 -0
- package/source/test/arny.jpg +0 -0
- package/source/test/lenna.48x48.jpeg +0 -0
- package/source/test/plank.mp4 +0 -0
- package/source/test/sample.avi +0 -0
- package/source/test/sample.wav +0 -0
- package/source/test/sport.mp4 +0 -0
- package/source/test/util.ts +62 -12
- package/transpiled/Entry.d.ts +15 -11
- package/transpiled/Factory.js +11 -5
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Provider.d.ts +17 -16
- package/transpiled/Provider.js +6 -4
- package/transpiled/Provider.js.map +1 -1
- package/transpiled/Scanner.d.ts +6 -2
- package/transpiled/Scanner.js +49 -22
- package/transpiled/Scanner.js.map +1 -1
- package/transpiled/Secrets.d.ts +5 -0
- package/transpiled/Secrets.js +3 -0
- package/transpiled/Secrets.js.map +1 -0
- package/transpiled/Storage.d.ts +13 -21
- package/transpiled/Storage.js +52 -155
- package/transpiled/Storage.js.map +1 -1
- package/transpiled/deployment.d.ts +1 -1
- package/transpiled/deployment.js +43 -16
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/errors.d.ts +2 -0
- package/transpiled/errors.js +6 -0
- package/transpiled/errors.js.map +1 -0
- package/transpiled/index.d.ts +3 -1
- package/transpiled/manifest.js +5 -2
- package/transpiled/manifest.js.map +1 -1
- package/transpiled/providers/Cloudinary.d.ts +51 -0
- package/transpiled/providers/Cloudinary.js +223 -0
- package/transpiled/providers/Cloudinary.js.map +1 -0
- package/transpiled/providers/Declaration.d.ts +3 -2
- package/transpiled/providers/FileSystem.d.ts +15 -7
- package/transpiled/providers/FileSystem.js +64 -24
- package/transpiled/providers/FileSystem.js.map +1 -1
- package/transpiled/providers/S3.d.ts +14 -14
- package/transpiled/providers/S3.js +62 -60
- package/transpiled/providers/S3.js.map +1 -1
- package/transpiled/providers/Temporary.d.ts +1 -2
- package/transpiled/providers/Temporary.js +2 -2
- package/transpiled/providers/Temporary.js.map +1 -1
- package/transpiled/providers/Test.d.ts +3 -3
- package/transpiled/providers/Test.js +2 -2
- package/transpiled/providers/Test.js.map +1 -1
- package/transpiled/providers/index.d.ts +7 -2
- package/transpiled/providers/index.js +2 -2
- package/transpiled/providers/index.js.map +1 -1
- package/transpiled/schemas.d.ts +1 -0
- package/transpiled/schemas.js +2 -1
- package/transpiled/schemas.js.map +1 -1
- package/transpiled/test/util.d.ts +89 -5
- package/transpiled/test/util.js +51 -4
- package/transpiled/test/util.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
- package/source/providers/FileSystem.test.ts +0 -5
- package/source/providers/Memory.ts +0 -41
- package/source/providers/S3.test.ts +0 -133
- package/transpiled/providers/Memory.d.ts +0 -13
- package/transpiled/providers/Memory.js +0 -60
- package/transpiled/providers/Memory.js.map +0 -1
package/transpiled/Scanner.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Scanner = void 0;
|
|
4
7
|
const node_stream_1 = require("node:stream");
|
|
5
8
|
const node_crypto_1 = require("node:crypto");
|
|
6
|
-
const agent_1 = require("@toa.io/agent");
|
|
7
9
|
const error_value_1 = require("error-value");
|
|
10
|
+
const negotiator_1 = __importDefault(require("negotiator"));
|
|
8
11
|
class Scanner extends node_stream_1.PassThrough {
|
|
9
12
|
size = 0;
|
|
10
13
|
type = 'application/octet-stream';
|
|
11
|
-
error
|
|
14
|
+
error;
|
|
12
15
|
hash = (0, node_crypto_1.createHash)('md5');
|
|
13
16
|
claim;
|
|
14
17
|
accept;
|
|
18
|
+
limit;
|
|
15
19
|
position = 0;
|
|
16
|
-
|
|
20
|
+
completed = false;
|
|
17
21
|
chunks = [];
|
|
18
22
|
constructor(control) {
|
|
19
23
|
super();
|
|
20
24
|
this.claim = control?.claim;
|
|
21
25
|
this.accept = control?.accept;
|
|
26
|
+
this.limit = control?.limit;
|
|
22
27
|
}
|
|
23
28
|
digest() {
|
|
24
29
|
return this.hash.digest('hex');
|
|
@@ -30,7 +35,7 @@ class Scanner extends node_stream_1.PassThrough {
|
|
|
30
35
|
process = (buffer) => {
|
|
31
36
|
this.size += buffer.length;
|
|
32
37
|
this.hash.update(buffer);
|
|
33
|
-
if (this.
|
|
38
|
+
if (this.completed)
|
|
34
39
|
return;
|
|
35
40
|
if (this.position + buffer.length > HEADER_SIZE)
|
|
36
41
|
buffer = buffer.subarray(0, HEADER_SIZE - this.position);
|
|
@@ -38,18 +43,25 @@ class Scanner extends node_stream_1.PassThrough {
|
|
|
38
43
|
this.position += buffer.length;
|
|
39
44
|
if (this.position === HEADER_SIZE)
|
|
40
45
|
this.complete();
|
|
46
|
+
if (this.limit !== undefined && this.size > this.limit)
|
|
47
|
+
this.interrupt(ERR_LIMIT_EXCEEDED);
|
|
41
48
|
};
|
|
42
49
|
complete() {
|
|
43
50
|
const header = Buffer.concat(this.chunks).toString('hex');
|
|
44
51
|
const signature = SIGNATURES
|
|
45
|
-
.find(({ hex,
|
|
52
|
+
.find(({ off, hex, expression }) => {
|
|
53
|
+
const sig = header.slice(off, off + hex.length);
|
|
54
|
+
return expression === undefined
|
|
55
|
+
? sig === hex
|
|
56
|
+
: expression.test(sig);
|
|
57
|
+
});
|
|
46
58
|
const type = signature?.type ?? this.claim;
|
|
47
59
|
if (type !== undefined) {
|
|
48
60
|
this.match(type);
|
|
49
61
|
this.type = type;
|
|
50
62
|
}
|
|
51
63
|
this.verify(signature);
|
|
52
|
-
this.
|
|
64
|
+
this.completed = true;
|
|
53
65
|
}
|
|
54
66
|
verify(signature) {
|
|
55
67
|
if (this.claim === undefined || this.claim === 'application/octet-stream')
|
|
@@ -63,36 +75,51 @@ class Scanner extends node_stream_1.PassThrough {
|
|
|
63
75
|
match(type) {
|
|
64
76
|
if (this.accept === undefined)
|
|
65
77
|
return;
|
|
66
|
-
const unacceptable =
|
|
78
|
+
const unacceptable = this.negotiate(this.accept, [type]) === null;
|
|
67
79
|
if (unacceptable)
|
|
68
80
|
this.interrupt(ERR_NOT_ACCEPTABLE);
|
|
69
81
|
}
|
|
82
|
+
negotiate(accept, type) {
|
|
83
|
+
return new negotiator_1.default({ headers: { accept } }).mediaType(type) ?? null;
|
|
84
|
+
}
|
|
70
85
|
interrupt(error) {
|
|
86
|
+
this.completed = true;
|
|
71
87
|
this.error = error;
|
|
72
|
-
this.
|
|
88
|
+
this.destroy(error);
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
91
|
exports.Scanner = Scanner;
|
|
76
92
|
// https://en.wikipedia.org/wiki/List_of_file_signatures
|
|
77
93
|
const SIGNATURES = [
|
|
78
|
-
{ hex: '
|
|
79
|
-
{ hex: '
|
|
80
|
-
{ hex: '
|
|
81
|
-
{ hex: '
|
|
82
|
-
{ hex: '
|
|
83
|
-
{ hex: '
|
|
84
|
-
{ hex: '
|
|
85
|
-
{ hex: '
|
|
86
|
-
{ hex: '
|
|
87
|
-
{ hex: '
|
|
94
|
+
{ hex: 'ff d8 ff e0', off: 0, type: 'image/jpeg' },
|
|
95
|
+
{ hex: 'ff d8 ff e1', off: 0, type: 'image/jpeg' },
|
|
96
|
+
{ hex: 'ff d8 ff e2', off: 0, type: 'image/jpeg' },
|
|
97
|
+
{ hex: 'ff d8 ff ee', off: 0, type: 'image/jpeg' },
|
|
98
|
+
{ hex: 'ff d8 ff db', off: 0, type: 'image/jpeg' },
|
|
99
|
+
{ hex: '89 50 4e 47', off: 0, type: 'image/png' },
|
|
100
|
+
{ hex: '47 49 46 38', off: 0, type: 'image/gif' },
|
|
101
|
+
{ hex: '52 49 46 46 ?? ?? ?? ?? 57 45 42 50', off: 0, type: 'image/webp' },
|
|
102
|
+
{ hex: '4a 58 4c 20 0d 0a 87 0a', off: 8, type: 'image/jxl' },
|
|
103
|
+
{ hex: '66 74 79 70 68 65 69 63', off: 8, type: 'image/heic' },
|
|
104
|
+
{ hex: '66 74 79 70 61 76 69 66', off: 8, type: 'image/avif' },
|
|
105
|
+
{ hex: '52 49 46 46 ?? ?? ?? ?? 41 56 49 20', off: 0, type: 'video/avi' },
|
|
106
|
+
{ hex: '52 49 46 46 ?? ?? ?? ?? 57 41 56 45', off: 0, type: 'audio/wav' }
|
|
88
107
|
/*
|
|
89
108
|
When adding a new signature, include a copyright-free sample file in the `.tests` directory
|
|
90
|
-
and update the
|
|
109
|
+
and update the `signatures` test group in `Storage.test.ts`.
|
|
91
110
|
*/
|
|
92
|
-
]
|
|
111
|
+
].map((signature) => {
|
|
112
|
+
signature.hex = signature.hex.replaceAll(' ', '');
|
|
113
|
+
if (signature.hex.includes('??')) {
|
|
114
|
+
const expression = signature.hex.replaceAll(/(?<wildcards>\?{1,24})/g, (_, wildcards) => `[0-9a-f]{${wildcards.length}}`);
|
|
115
|
+
signature.expression = new RegExp(expression, 'i');
|
|
116
|
+
}
|
|
117
|
+
return signature;
|
|
118
|
+
});
|
|
93
119
|
const HEADER_SIZE = SIGNATURES
|
|
94
120
|
.reduce((max, { off, hex }) => Math.max(max, off + hex.length), 0) / 2;
|
|
95
121
|
const KNOWN_TYPES = new Set(SIGNATURES.map(({ type }) => type));
|
|
96
|
-
const ERR_TYPE_MISMATCH =
|
|
97
|
-
const ERR_NOT_ACCEPTABLE =
|
|
122
|
+
const ERR_TYPE_MISMATCH = new error_value_1.Err('TYPE_MISMATCH');
|
|
123
|
+
const ERR_NOT_ACCEPTABLE = new error_value_1.Err('NOT_ACCEPTABLE');
|
|
124
|
+
const ERR_LIMIT_EXCEEDED = new error_value_1.Err('LIMIT_EXCEEDED');
|
|
98
125
|
//# sourceMappingURL=Scanner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scanner.js","sourceRoot":"","sources":["../source/Scanner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Scanner.js","sourceRoot":"","sources":["../source/Scanner.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAiE;AACjE,6CAAwC;AACxC,6CAAiC;AACjC,4DAAmC;AAEnC,MAAa,OAAQ,SAAQ,yBAAW;IAC/B,IAAI,GAAG,CAAC,CAAA;IACR,IAAI,GAAG,0BAA0B,CAAA;IACjC,KAAK,CAAQ;IAEH,IAAI,GAAG,IAAA,wBAAU,EAAC,KAAK,CAAC,CAAA;IACxB,KAAK,CAAS;IACd,MAAM,CAAS;IACf,KAAK,CAAS;IACvB,QAAQ,GAAG,CAAC,CAAA;IACZ,SAAS,GAAG,KAAK,CAAA;IACR,MAAM,GAAa,EAAE,CAAA;IAEtC,YAAoB,OAAqB;QACvC,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,OAA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AE,CAAC,IAAI,CAAC,CAAC,CAAA;AAE/D,MAAM,iBAAiB,GAAG,IAAI,iBAAG,CAAC,eAAe,CAAC,CAAA;AAClD,MAAM,kBAAkB,GAAG,IAAI,iBAAG,CAAC,gBAAgB,CAAC,CAAA;AACpD,MAAM,kBAAkB,GAAG,IAAI,iBAAG,CAAC,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Secrets.js","sourceRoot":"","sources":["../source/Secrets.ts"],"names":[],"mappings":""}
|
package/transpiled/Storage.d.ts
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Readable } from 'node:stream';
|
|
2
|
+
import type { Readable } from 'node:stream';
|
|
3
|
+
import type { Attributes, Entry, Stream } from './Entry';
|
|
3
4
|
import type { ScanOptions } from './Scanner';
|
|
4
5
|
import type { Provider } from './Provider';
|
|
5
|
-
|
|
6
|
-
export declare class Storage {
|
|
6
|
+
export declare class Storage<T extends Provider = Provider> {
|
|
7
7
|
private readonly provider;
|
|
8
|
-
constructor(provider:
|
|
8
|
+
constructor(provider: T);
|
|
9
|
+
options(): T['options'];
|
|
9
10
|
put(path: string, stream: Readable, options?: Options): Maybe<Entry>;
|
|
10
|
-
get(path: string): Maybe<
|
|
11
|
-
|
|
11
|
+
get(path: string, options?: unknown): Maybe<Stream>;
|
|
12
|
+
head(path: string): Promise<Maybe<Entry>>;
|
|
12
13
|
delete(path: string): Maybe<void>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
conceal(path: string): Maybe<void>;
|
|
16
|
-
reveal(path: string): Maybe<void>;
|
|
17
|
-
diversify(path: string, name: string, stream: Readable): Maybe<void>;
|
|
18
|
-
annotate(path: string, key: string, value?: unknown): Maybe<void>;
|
|
19
|
-
private transit;
|
|
20
|
-
private persist;
|
|
21
|
-
private create;
|
|
22
|
-
private save;
|
|
23
|
-
private enroll;
|
|
24
|
-
private parse;
|
|
14
|
+
path(): string | null;
|
|
15
|
+
private locate;
|
|
25
16
|
}
|
|
26
|
-
type Maybe<T> = Promise<T | Error>;
|
|
27
|
-
type Meta = Record<string, string>;
|
|
28
17
|
interface Options extends ScanOptions {
|
|
29
|
-
|
|
18
|
+
id?: string;
|
|
19
|
+
origin?: string;
|
|
20
|
+
attributes?: Attributes;
|
|
30
21
|
}
|
|
22
|
+
type Maybe<T> = Promise<T | Error>;
|
|
31
23
|
export type Storages = Record<string, Storage>;
|
|
32
24
|
export {};
|
package/transpiled/Storage.js
CHANGED
|
@@ -1,176 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Storage = void 0;
|
|
4
|
-
const node_stream_1 = require("node:stream");
|
|
5
4
|
const node_path_1 = require("node:path");
|
|
6
|
-
const
|
|
7
|
-
const generic_1 = require("@toa.io/generic");
|
|
8
|
-
const error_value_1 = require("error-value");
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
9
6
|
const Scanner_1 = require("./Scanner");
|
|
10
7
|
class Storage {
|
|
11
8
|
provider;
|
|
12
9
|
constructor(provider) {
|
|
13
10
|
this.provider = provider;
|
|
14
11
|
}
|
|
12
|
+
options() {
|
|
13
|
+
return this.provider.options;
|
|
14
|
+
}
|
|
15
15
|
async put(path, stream, options) {
|
|
16
16
|
const scanner = new Scanner_1.Scanner(options);
|
|
17
|
-
const pipe = stream.pipe(scanner);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
async fetch(path) {
|
|
34
|
-
const { rel, id, variant } = this.parse(path);
|
|
35
|
-
if (variant === null && rel !== '') {
|
|
36
|
-
const entry = await this.get(path);
|
|
37
|
-
if (entry instanceof Error)
|
|
38
|
-
return entry;
|
|
39
|
-
}
|
|
40
|
-
const blob = variant === null
|
|
41
|
-
? node_path_1.posix.join(BLOBs, id)
|
|
42
|
-
: node_path_1.posix.join(ENTRIES, rel, id, variant);
|
|
43
|
-
const stream = await this.provider.get(blob);
|
|
44
|
-
if (stream === null)
|
|
45
|
-
return ERR_NOT_FOUND;
|
|
46
|
-
else
|
|
47
|
-
return stream;
|
|
48
|
-
}
|
|
49
|
-
async delete(path) {
|
|
50
|
-
const entry = await this.get(path);
|
|
51
|
-
if (entry instanceof Error)
|
|
52
|
-
return entry;
|
|
53
|
-
await this.conceal(path);
|
|
54
|
-
await this.provider.delete(node_path_1.posix.join(ENTRIES, path));
|
|
55
|
-
}
|
|
56
|
-
async list(path) {
|
|
57
|
-
const listfile = node_path_1.posix.join(ENTRIES, path, LIST);
|
|
58
|
-
const stream = await this.provider.get(listfile);
|
|
59
|
-
return stream === null ? [] : (0, msgpackr_1.decode)(await (0, generic_1.buffer)(stream));
|
|
60
|
-
}
|
|
61
|
-
async permute(path, ids) {
|
|
62
|
-
const unique = new Set(ids);
|
|
63
|
-
const dir = node_path_1.posix.join(ENTRIES, path);
|
|
64
|
-
const list = await this.list(path);
|
|
65
|
-
if (list.length !== ids.length || unique.size !== ids.length)
|
|
66
|
-
return ERR_PERMUTATION_MISMATCH;
|
|
67
|
-
for (const id of ids)
|
|
68
|
-
if (!list.includes(id))
|
|
69
|
-
return ERR_PERMUTATION_MISMATCH;
|
|
70
|
-
await this.provider.put(dir, LIST, node_stream_1.Readable.from((0, msgpackr_1.encode)(ids)));
|
|
71
|
-
}
|
|
72
|
-
async conceal(path) {
|
|
73
|
-
const { id, rel } = this.parse(path);
|
|
74
|
-
const dir = node_path_1.posix.join(ENTRIES, rel);
|
|
75
|
-
const list = await this.list(rel);
|
|
76
|
-
const index = list.indexOf(id);
|
|
77
|
-
if (index === -1)
|
|
78
|
-
return ERR_NOT_FOUND;
|
|
79
|
-
list.splice(index, 1);
|
|
80
|
-
await this.provider.put(dir, LIST, node_stream_1.Readable.from((0, msgpackr_1.encode)(list)));
|
|
81
|
-
}
|
|
82
|
-
async reveal(path) {
|
|
83
|
-
const { id, rel } = this.parse(path);
|
|
84
|
-
return await this.enroll(rel, id);
|
|
85
|
-
}
|
|
86
|
-
async diversify(path, name, stream) {
|
|
87
|
-
const scanner = new Scanner_1.Scanner();
|
|
88
|
-
const pipe = stream.pipe(scanner);
|
|
89
|
-
await this.provider.put(node_path_1.posix.join(ENTRIES, path), name, pipe);
|
|
90
|
-
if (scanner.error !== null)
|
|
91
|
-
return scanner.error;
|
|
92
|
-
const { size, type } = scanner;
|
|
93
|
-
const entry = await this.get(path);
|
|
94
|
-
if (entry instanceof Error)
|
|
95
|
-
return entry;
|
|
96
|
-
entry.variants = entry.variants.filter((variant) => variant.name !== name);
|
|
97
|
-
entry.variants.push({ name, size, type });
|
|
98
|
-
await this.save(path, entry);
|
|
99
|
-
}
|
|
100
|
-
async annotate(path, key, value) {
|
|
101
|
-
const entry = await this.get(path);
|
|
102
|
-
if (entry instanceof Error)
|
|
103
|
-
return entry;
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
105
|
-
if (value === undefined)
|
|
106
|
-
delete entry.meta[key];
|
|
107
|
-
else
|
|
108
|
-
entry.meta[key] = value;
|
|
109
|
-
await this.save(path, entry);
|
|
110
|
-
}
|
|
111
|
-
async transit(stream) {
|
|
112
|
-
const tempname = (0, generic_1.newid)();
|
|
113
|
-
await this.provider.put(TEMP, tempname, stream);
|
|
114
|
-
return tempname;
|
|
115
|
-
}
|
|
116
|
-
async persist(tempname, id) {
|
|
117
|
-
const temp = node_path_1.posix.join(TEMP, tempname);
|
|
118
|
-
const blob = node_path_1.posix.join(BLOBs, id);
|
|
119
|
-
await this.provider.move(temp, blob);
|
|
120
|
-
}
|
|
121
|
-
// eslint-disable-next-line max-params
|
|
122
|
-
async create(path, id, size, type, meta = {}) {
|
|
123
|
-
const entry = {
|
|
17
|
+
const pipe = stream.pipe(scanner).on('error', () => undefined);
|
|
18
|
+
const id = options?.id ?? (0, node_crypto_1.randomUUID)().replace(/-/g, '');
|
|
19
|
+
const location = this.locate(path, id);
|
|
20
|
+
/**
|
|
21
|
+
* Provider can return or throw an error.
|
|
22
|
+
* If thrown error is TYPE_MISMATCH from the Scanner, it should be returned.
|
|
23
|
+
*/
|
|
24
|
+
const error = await this.provider.put(location, pipe).catch((error) => {
|
|
25
|
+
if (error === scanner.error)
|
|
26
|
+
return error;
|
|
27
|
+
else
|
|
28
|
+
throw error;
|
|
29
|
+
});
|
|
30
|
+
if (error instanceof Error)
|
|
31
|
+
return error;
|
|
32
|
+
const metadata = {
|
|
124
33
|
id,
|
|
125
|
-
size,
|
|
126
|
-
type,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
34
|
+
size: scanner.size,
|
|
35
|
+
type: scanner.type,
|
|
36
|
+
checksum: scanner.digest(),
|
|
37
|
+
created: new Date().toISOString(),
|
|
38
|
+
attributes: options?.attributes ?? {}
|
|
39
|
+
};
|
|
40
|
+
if (options?.origin !== undefined)
|
|
41
|
+
metadata.attributes.origin = options.origin;
|
|
42
|
+
await this.provider.commit(location, metadata);
|
|
43
|
+
return metadata;
|
|
44
|
+
}
|
|
45
|
+
async get(path, options) {
|
|
46
|
+
const location = this.locate(path);
|
|
47
|
+
return await this.provider.get(location, options);
|
|
48
|
+
}
|
|
49
|
+
async head(path) {
|
|
50
|
+
const id = (0, node_path_1.basename)(path).split('.')[0];
|
|
51
|
+
const location = this.locate(path);
|
|
52
|
+
const metadata = await this.provider.head(location);
|
|
53
|
+
if (metadata instanceof Error)
|
|
54
|
+
return metadata;
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
...metadata
|
|
130
58
|
};
|
|
131
|
-
const metafile = node_path_1.posix.join(path, entry.id);
|
|
132
|
-
const existing = await this.get(metafile);
|
|
133
|
-
if (existing instanceof Error)
|
|
134
|
-
await this.save(metafile, entry);
|
|
135
|
-
await this.enroll(path, id, true);
|
|
136
|
-
return entry;
|
|
137
59
|
}
|
|
138
|
-
async
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
await this.provider.put(node_path_1.posix.join(ENTRIES, rel), META, stream);
|
|
60
|
+
async delete(path) {
|
|
61
|
+
const location = this.locate(path);
|
|
62
|
+
return this.provider.delete(location);
|
|
142
63
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const list = await this.list(path);
|
|
146
|
-
const index = list.indexOf(id);
|
|
147
|
-
if (index !== -1)
|
|
148
|
-
if (addition)
|
|
149
|
-
list.splice(index, 1);
|
|
150
|
-
else
|
|
151
|
-
return;
|
|
152
|
-
else if (!addition) {
|
|
153
|
-
const entry = await this.get(node_path_1.posix.join(path, id));
|
|
154
|
-
if (entry instanceof Error)
|
|
155
|
-
return entry;
|
|
156
|
-
}
|
|
157
|
-
list.push(id);
|
|
158
|
-
await this.provider.put(dir, LIST, node_stream_1.Readable.from((0, msgpackr_1.encode)(list)));
|
|
64
|
+
path() {
|
|
65
|
+
return this.provider.root ?? null;
|
|
159
66
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const [id, ...rest] = last.split('.');
|
|
163
|
-
const variant = rest.length > 0 ? rest.join('.') : null;
|
|
164
|
-
const rel = segments.reverse().join('/');
|
|
165
|
-
return { rel, id, variant };
|
|
67
|
+
locate(...rel) {
|
|
68
|
+
return (0, node_path_1.join)(ENTRIES, ...rel);
|
|
166
69
|
}
|
|
167
70
|
}
|
|
168
71
|
exports.Storage = Storage;
|
|
169
|
-
const
|
|
170
|
-
const ERR_PERMUTATION_MISMATCH = (0, error_value_1.Err)('PERMUTATION_MISMATCH');
|
|
171
|
-
const TEMP = '/temp';
|
|
172
|
-
const BLOBs = '/blobs';
|
|
173
|
-
const ENTRIES = '/entries';
|
|
174
|
-
const LIST = '.list';
|
|
175
|
-
const META = '.meta';
|
|
72
|
+
const ENTRIES = '/';
|
|
176
73
|
//# sourceMappingURL=Storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../source/Storage.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../source/Storage.ts"],"names":[],"mappings":";;;AAAA,yCAA0C;AAC1C,6CAAwC;AACxC,uCAAmC;AAMnC,MAAa,OAAO;IACD,QAAQ,CAAG;IAE5B,YAAoB,QAAW;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAC,GAAG,CAAE,IAAY,EAAE,MAAgB,EAAE,OAAiB;QACjE,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,OAAO,CAAC,CAAA;QACpC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAC9D,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,IAAA,wBAAU,GAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAEtC;;;WAGG;QACH,MAAM,KAAK,GAAsB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAU,EAAE,EAAE;YAC5F,IAAI,KAAK,KAAK,OAAO,CAAC,KAAK;gBAAE,OAAO,KAAK,CAAA;;gBACpC,MAAM,KAAK,CAAA;QAClB,CAAC,CAAC,CAAA;QAEF,IAAI,KAAK,YAAY,KAAK;YACxB,OAAO,KAAK,CAAA;QAEd,MAAM,QAAQ,GAAU;YACtB,EA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AAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACvC,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAA;IACnC,CAAC;IAEO,MAAM,CAAE,GAAG,GAAa;QAC9B,OAAO,IAAA,gBAAI,EAAC,OAAO,EAAE,GAAG,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF;AA/ED,0BA+EC;AAED,MAAM,OAAO,GAAG,GAAG,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dependency } from '@toa.io/operations';
|
|
2
2
|
import type { context } from '@toa.io/norm';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ENV_PREFIX = "TOA_STORAGES";
|
|
4
4
|
export declare function deployment(instances: Instance[], annotation: unknown): Dependency;
|
|
5
5
|
export type Instance = context.Dependency<string[]>;
|
package/transpiled/deployment.js
CHANGED
|
@@ -23,26 +23,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.deployment = exports.
|
|
26
|
+
exports.deployment = exports.ENV_PREFIX = void 0;
|
|
27
27
|
const assert = __importStar(require("node:assert"));
|
|
28
28
|
const generic_1 = require("@toa.io/generic");
|
|
29
29
|
const providers_1 = require("./providers");
|
|
30
30
|
const Annotation_1 = require("./Annotation");
|
|
31
|
-
exports.
|
|
31
|
+
exports.ENV_PREFIX = 'TOA_STORAGES';
|
|
32
32
|
function deployment(instances, annotation) {
|
|
33
33
|
validate(instances, annotation);
|
|
34
34
|
const value = (0, generic_1.encode)(annotation);
|
|
35
|
-
const pointer = { name: exports.
|
|
35
|
+
const pointer = { name: exports.ENV_PREFIX, value };
|
|
36
36
|
const secrets = getSecrets(annotation);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const mounts = getMounts(instances, annotation);
|
|
38
|
+
const dependency = { variables: { global: [pointer, ...secrets] } };
|
|
39
|
+
if (mounts !== null)
|
|
40
|
+
dependency.mounts = mounts;
|
|
41
|
+
return dependency;
|
|
40
42
|
}
|
|
41
43
|
exports.deployment = deployment;
|
|
42
44
|
function validate(instances, annotation) {
|
|
43
45
|
(0, Annotation_1.validateAnnotation)(annotation);
|
|
44
|
-
for (const instance of instances)
|
|
46
|
+
for (const instance of instances) {
|
|
47
|
+
instance.manifest ??= [];
|
|
45
48
|
contains(instance, annotation);
|
|
49
|
+
}
|
|
46
50
|
}
|
|
47
51
|
function contains(instance, annotation) {
|
|
48
52
|
for (const name of instance.manifest)
|
|
@@ -53,16 +57,39 @@ function getSecrets(annotation) {
|
|
|
53
57
|
const secrets = [];
|
|
54
58
|
for (const [name, declaration] of Object.entries(annotation)) {
|
|
55
59
|
const Provider = providers_1.providers[declaration.provider];
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
name:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
if (Provider.SECRETS !== undefined)
|
|
61
|
+
// eslint-disable-next-line max-depth
|
|
62
|
+
for (const secret of Provider.SECRETS)
|
|
63
|
+
secrets.push({
|
|
64
|
+
name: `${exports.ENV_PREFIX}_${name}_${secret.name}`.toUpperCase(),
|
|
65
|
+
secret: {
|
|
66
|
+
name: `toa-storages-${name}`,
|
|
67
|
+
key: secret.name,
|
|
68
|
+
optional: secret.optional
|
|
69
|
+
}
|
|
70
|
+
});
|
|
65
71
|
}
|
|
66
72
|
return secrets;
|
|
67
73
|
}
|
|
74
|
+
function getMounts(instances, annotation) {
|
|
75
|
+
let mounts = null;
|
|
76
|
+
for (const { locator, manifest } of instances)
|
|
77
|
+
for (const name of manifest) {
|
|
78
|
+
const declaration = annotation[name];
|
|
79
|
+
// eslint-disable-next-line max-depth
|
|
80
|
+
if (declaration.provider !== 'fs')
|
|
81
|
+
continue;
|
|
82
|
+
// eslint-disable-next-line max-depth
|
|
83
|
+
if (declaration.claim !== undefined) {
|
|
84
|
+
mounts ??= {};
|
|
85
|
+
mounts[locator.label] ??= [];
|
|
86
|
+
mounts[locator.label].push({
|
|
87
|
+
name,
|
|
88
|
+
path: declaration.path,
|
|
89
|
+
claim: declaration.claim
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return mounts;
|
|
94
|
+
}
|
|
68
95
|
//# sourceMappingURL=deployment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../source/deployment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,6CAAwC;AACxC,2CAAuC;AACvC,6CAAiD;AAKpC,QAAA,
|
|
1
|
+
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../source/deployment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,6CAAwC;AACxC,2CAAuC;AACvC,6CAAiD;AAKpC,QAAA,UAAU,GAAG,cAAc,CAAA;AAExC,SAAgB,UAAU,CAAE,SAAqB,EAAE,UAAmB;IACpE,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAE/B,MAAM,KAAK,GAAG,IAAA,gBAAM,EAAC,UAAU,CAAC,CAAA;IAChC,MAAM,OAAO,GAAa,EAAE,IAAI,EAAE,kBAAU,EAAE,KAAK,EAAE,CAAA;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAE/C,MAAM,UAAU,GAAe,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,CAAA;IAE/E,IAAI,MAAM,KAAK,IAAI;QACjB,UAAU,CAAC,MAAM,GAAG,MAAM,CAA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O,CAAA;AAChB,CAAC;AAED,SAAS,SAAS,CAAE,SAAqB,EAAE,UAAsB;IAC/D,IAAI,MAAM,GAAkB,IAAI,CAAA;IAEhC,KAAK,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,SAAS;QAC3C,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;YAEpC,qCAAqC;YACrC,IAAI,WAAW,CAAC,QAAQ,KAAK,IAAI;gBAC/B,SAAQ;YAEV,qCAAqC;YACrC,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBACpC,MAAM,KAAK,EAAE,CAAA;gBACb,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;gBAE5B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;oBACzB,IAAI;oBACJ,IAAI,EAAE,WAAW,CAAC,IAAI;oBACtB,KAAK,EAAE,WAAW,CAAC,KAAK;iBACzB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IAEH,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../source/errors.ts"],"names":[],"mappings":";;;AAAA,6CAAiC;AAEpB,QAAA,aAAa,GAAG,IAAI,iBAAG,CAAC,WAAW,CAAC,CAAA"}
|
package/transpiled/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { Factory } from './Factory';
|
|
2
2
|
export { deployment } from './deployment';
|
|
3
3
|
export { manifest } from './manifest';
|
|
4
|
-
export type { Entry } from './Entry';
|
|
4
|
+
export type { Entry, Stream } from './Entry';
|
|
5
|
+
export type { Storage } from './Storage';
|
|
6
|
+
export type * from './providers';
|
package/transpiled/manifest.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.manifest = void 0;
|
|
4
|
-
const matchacho_1 = require("matchacho");
|
|
5
4
|
function manifest(manifest) {
|
|
6
|
-
|
|
5
|
+
if (manifest === null)
|
|
6
|
+
return [];
|
|
7
|
+
if (typeof manifest === 'string')
|
|
8
|
+
return [manifest];
|
|
9
|
+
return manifest;
|
|
7
10
|
}
|
|
8
11
|
exports.manifest = manifest;
|
|
9
12
|
//# sourceMappingURL=manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../source/manifest.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../source/manifest.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAE,QAAkC;IAC1D,IAAI,QAAQ,KAAK,IAAI;QACnB,OAAO,EAAE,CAAA;IAEX,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAC9B,OAAO,CAAC,QAAQ,CAAC,CAAA;IAEnB,OAAO,QAAQ,CAAA;AACjB,CAAC;AARD,4BAQC"}
|