@toa.io/extensions.storages 1.0.0-alpha.13 → 1.0.0-alpha.143
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 +13 -14
- package/readme.md +94 -49
- package/schemas/annotation.cos.yaml +1 -0
- package/schemas/cloudinary.cos.yaml +30 -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 +11 -11
- package/source/Factory.ts +16 -9
- package/source/Provider.ts +19 -19
- package/source/Scanner.ts +57 -24
- package/source/Secrets.ts +6 -0
- package/source/Storage.test.ts +103 -279
- package/source/Storage.ts +55 -204
- package/source/deployment.ts +48 -15
- package/source/errors.ts +3 -0
- package/source/index.ts +1 -1
- package/source/manifest.ts +7 -6
- package/source/providers/Cloudinary.ts +274 -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 +9 -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/sample.avi +0 -0
- package/source/test/sample.svg +4 -0
- package/source/test/sample.wav +0 -0
- package/source/test/util.ts +54 -12
- package/transpiled/Entry.d.ts +12 -10
- package/transpiled/Factory.js +11 -5
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Provider.d.ts +15 -15
- package/transpiled/Provider.js +3 -3
- package/transpiled/Provider.js.map +1 -1
- package/transpiled/Scanner.d.ts +5 -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 +10 -19
- package/transpiled/Storage.js +47 -153
- package/transpiled/Storage.js.map +1 -1
- package/transpiled/deployment.d.ts +1 -1
- package/transpiled/deployment.js +40 -15
- 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 +1 -1
- package/transpiled/manifest.js +5 -2
- package/transpiled/manifest.js.map +1 -1
- package/transpiled/providers/Cloudinary.d.ts +42 -0
- package/transpiled/providers/Cloudinary.js +189 -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 +6 -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 +70 -5
- package/transpiled/test/util.js +43 -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/Storage.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
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;
|
|
@@ -14,163 +11,60 @@ class Storage {
|
|
|
14
11
|
}
|
|
15
12
|
async put(path, stream, options) {
|
|
16
13
|
const scanner = new Scanner_1.Scanner(options);
|
|
17
|
-
const pipe = stream.pipe(scanner);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const pipe = stream.pipe(scanner).on('error', () => undefined);
|
|
15
|
+
const id = options?.id ?? (0, node_crypto_1.randomUUID)().replace(/-/g, '');
|
|
16
|
+
const location = this.locate(path, id);
|
|
17
|
+
/**
|
|
18
|
+
* Provider can return or throw an error.
|
|
19
|
+
* If thrown error is TYPE_MISMATCH from the Scanner, it should be returned.
|
|
20
|
+
*/
|
|
21
|
+
const error = await this.provider.put(location, pipe).catch((error) => {
|
|
22
|
+
if (error === scanner.error)
|
|
23
|
+
return error;
|
|
24
|
+
else
|
|
25
|
+
throw error;
|
|
26
|
+
});
|
|
27
|
+
if (error instanceof Error)
|
|
28
|
+
return error;
|
|
29
|
+
const metadata = {
|
|
30
|
+
id,
|
|
31
|
+
size: scanner.size,
|
|
32
|
+
type: scanner.type,
|
|
33
|
+
checksum: scanner.digest(),
|
|
34
|
+
created: new Date().toISOString(),
|
|
35
|
+
attributes: options?.attributes ?? {}
|
|
36
|
+
};
|
|
37
|
+
if (options?.origin !== undefined)
|
|
38
|
+
metadata.attributes.origin = options.origin;
|
|
39
|
+
await this.provider.commit(location, metadata);
|
|
40
|
+
return metadata;
|
|
24
41
|
}
|
|
25
42
|
async get(path) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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 = {
|
|
43
|
+
const location = this.locate(path);
|
|
44
|
+
return await this.provider.get(location);
|
|
45
|
+
}
|
|
46
|
+
async head(path) {
|
|
47
|
+
const id = (0, node_path_1.basename)(path);
|
|
48
|
+
const location = this.locate(path);
|
|
49
|
+
const metadata = await this.provider.head(location);
|
|
50
|
+
if (metadata instanceof Error)
|
|
51
|
+
return metadata;
|
|
52
|
+
return {
|
|
124
53
|
id,
|
|
125
|
-
|
|
126
|
-
type,
|
|
127
|
-
created: Date.now(),
|
|
128
|
-
variants: [],
|
|
129
|
-
meta
|
|
54
|
+
...metadata
|
|
130
55
|
};
|
|
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
56
|
}
|
|
138
|
-
async
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
await this.provider.put(node_path_1.posix.join(ENTRIES, rel), META, stream);
|
|
57
|
+
async delete(path) {
|
|
58
|
+
const location = this.locate(path);
|
|
59
|
+
return this.provider.delete(location);
|
|
142
60
|
}
|
|
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)));
|
|
61
|
+
path() {
|
|
62
|
+
return this.provider.root ?? null;
|
|
159
63
|
}
|
|
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 };
|
|
64
|
+
locate(...rel) {
|
|
65
|
+
return (0, node_path_1.join)(ENTRIES, ...rel);
|
|
166
66
|
}
|
|
167
67
|
}
|
|
168
68
|
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';
|
|
69
|
+
const ENTRIES = '/';
|
|
176
70
|
//# 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,CAAU;IAEnC,YAAoB,QAAkB;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,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,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AAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC1C,CAAC;IAEM,KAAK,CAAC,IAAI,CAAE,IAAY;QAC7B,MAAM,EAAE,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAA;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEnD,IAAI,QAAQ,YAAY,KAAK;YAC3B,OAAO,QAAQ,CAAA;QAEjB,OAAO;YACL,EAAE;YACF,GAAG,QAAQ;SACZ,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,MAAM,CAAE,IAAY;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAElC,OAAO,IAAI,CAAC,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;AA3ED,0BA2EC;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,20 +23,22 @@ 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) {
|
|
@@ -53,16 +55,39 @@ function getSecrets(annotation) {
|
|
|
53
55
|
const secrets = [];
|
|
54
56
|
for (const [name, declaration] of Object.entries(annotation)) {
|
|
55
57
|
const Provider = providers_1.providers[declaration.provider];
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
name:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
if (Provider.SECRETS !== undefined)
|
|
59
|
+
// eslint-disable-next-line max-depth
|
|
60
|
+
for (const secret of Provider.SECRETS)
|
|
61
|
+
secrets.push({
|
|
62
|
+
name: `${exports.ENV_PREFIX}_${name}_${secret.name}`.toUpperCase(),
|
|
63
|
+
secret: {
|
|
64
|
+
name: `toa-storages-${name}`,
|
|
65
|
+
key: secret.name,
|
|
66
|
+
optional: secret.optional
|
|
67
|
+
}
|
|
68
|
+
});
|
|
65
69
|
}
|
|
66
70
|
return secrets;
|
|
67
71
|
}
|
|
72
|
+
function getMounts(instances, annotation) {
|
|
73
|
+
let mounts = null;
|
|
74
|
+
for (const { locator, manifest } of instances)
|
|
75
|
+
for (const name of manifest) {
|
|
76
|
+
const declaration = annotation[name];
|
|
77
|
+
// eslint-disable-next-line max-depth
|
|
78
|
+
if (declaration.provider !== 'fs')
|
|
79
|
+
continue;
|
|
80
|
+
// eslint-disable-next-line max-depth
|
|
81
|
+
if (declaration.claim !== undefined) {
|
|
82
|
+
mounts ??= {};
|
|
83
|
+
mounts[locator.label] ??= [];
|
|
84
|
+
mounts[locator.label].push({
|
|
85
|
+
name,
|
|
86
|
+
path: declaration.path,
|
|
87
|
+
claim: declaration.claim
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return mounts;
|
|
92
|
+
}
|
|
68
93
|
//# 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,kBAA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AAE,GAAG,kBAAU,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;oBAC1D,MAAM,EAAE;wBACN,IAAI,EAAE,gBAAgB,IAAI,EAAE;wBAC5B,GAAG,EAAE,MAAM,CAAC,IAAI;wBAChB,QAAQ,EAAE,MAAM,CAAC,QAAQ;qBAC1B;iBACF,CAAC,CAAA;IACR,CAAC;IAED,OAAO,OAAO,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
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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
import { Provider } from '../Provider';
|
|
4
|
+
import type { Maybe } from '@toa.io/types';
|
|
5
|
+
import type { Metadata, Stream } from '../Entry';
|
|
6
|
+
import type { Secret, Secrets } from '../Secrets';
|
|
7
|
+
export type CloudinarySecrets = Secrets<'API_KEY' | 'API_SECRET'>;
|
|
8
|
+
export declare class Cloudinary extends Provider<CloudinaryOptions> {
|
|
9
|
+
static readonly SECRETS: readonly Secret[];
|
|
10
|
+
private readonly type;
|
|
11
|
+
private readonly transformations;
|
|
12
|
+
private readonly config;
|
|
13
|
+
private readonly prefix;
|
|
14
|
+
constructor(options: CloudinaryOptions, secrets?: CloudinarySecrets);
|
|
15
|
+
get(path: string): Promise<Maybe<Stream>>;
|
|
16
|
+
head(path: string): Promise<Maybe<Metadata>>;
|
|
17
|
+
put(path: string, stream: Readable): Promise<void>;
|
|
18
|
+
commit(): Promise<void>;
|
|
19
|
+
delete(path: string): Promise<void>;
|
|
20
|
+
move(from: string, to: string): Promise<void | Error>;
|
|
21
|
+
private fetch;
|
|
22
|
+
private url;
|
|
23
|
+
private toTransformation;
|
|
24
|
+
private metadata;
|
|
25
|
+
private cloudinary;
|
|
26
|
+
}
|
|
27
|
+
export interface CloudinaryOptions {
|
|
28
|
+
environment: string;
|
|
29
|
+
type: StorageType;
|
|
30
|
+
prefix?: string;
|
|
31
|
+
transformations?: TransformationDeclaration[];
|
|
32
|
+
}
|
|
33
|
+
type TransformationDeclaration = Omit<Transformation, 'extension'> & {
|
|
34
|
+
extension: string;
|
|
35
|
+
};
|
|
36
|
+
interface Transformation {
|
|
37
|
+
extension: RegExp;
|
|
38
|
+
transformation: object;
|
|
39
|
+
optional?: boolean;
|
|
40
|
+
}
|
|
41
|
+
type StorageType = 'image' | 'video';
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cloudinary = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const node_stream_1 = require("node:stream");
|
|
6
|
+
const cloudinary_1 = require("cloudinary");
|
|
7
|
+
const openspan_1 = require("openspan");
|
|
8
|
+
const Provider_1 = require("../Provider");
|
|
9
|
+
const errors_1 = require("../errors");
|
|
10
|
+
class Cloudinary extends Provider_1.Provider {
|
|
11
|
+
static SECRETS = [
|
|
12
|
+
{ name: 'API_KEY' },
|
|
13
|
+
{ name: 'API_SECRET' }
|
|
14
|
+
];
|
|
15
|
+
type;
|
|
16
|
+
transformations = [];
|
|
17
|
+
config;
|
|
18
|
+
prefix;
|
|
19
|
+
constructor(options, secrets) {
|
|
20
|
+
super(options, secrets);
|
|
21
|
+
this.type = options.type;
|
|
22
|
+
if (options.transformations !== undefined)
|
|
23
|
+
this.transformations = options.transformations.map((transformation) => {
|
|
24
|
+
const { extension, ...rest } = transformation;
|
|
25
|
+
let expression = extension;
|
|
26
|
+
if (!extension.startsWith('^'))
|
|
27
|
+
expression = '^' + extension;
|
|
28
|
+
if (!extension.endsWith('$'))
|
|
29
|
+
expression = extension + '$';
|
|
30
|
+
return {
|
|
31
|
+
extension: new RegExp(expression),
|
|
32
|
+
...rest
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
this.config = {
|
|
36
|
+
cloud_name: options.environment,
|
|
37
|
+
api_key: secrets.API_KEY,
|
|
38
|
+
api_secret: secrets.API_SECRET
|
|
39
|
+
};
|
|
40
|
+
this.prefix = options.prefix ?? '/';
|
|
41
|
+
}
|
|
42
|
+
async get(path) {
|
|
43
|
+
const response = await this.fetch(path);
|
|
44
|
+
if (response instanceof Error)
|
|
45
|
+
return errors_1.ERR_NOT_FOUND;
|
|
46
|
+
const metadata = this.metadata(response);
|
|
47
|
+
return {
|
|
48
|
+
stream: node_stream_1.Readable.fromWeb(response.body),
|
|
49
|
+
...metadata
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async head(path) {
|
|
53
|
+
const response = await this.fetch(path, 'HEAD');
|
|
54
|
+
if (response instanceof Error)
|
|
55
|
+
return errors_1.ERR_NOT_FOUND;
|
|
56
|
+
return this.metadata(response);
|
|
57
|
+
}
|
|
58
|
+
async put(path, stream) {
|
|
59
|
+
const id = (0, node_path_1.basename)(path);
|
|
60
|
+
const folder = (0, node_path_1.join)(this.prefix, (0, node_path_1.dirname)(path));
|
|
61
|
+
openspan_1.console.debug('Uploading to Cloudinary', { path });
|
|
62
|
+
await new Promise((resolve, reject) => {
|
|
63
|
+
stream.pipe(this.cloudinary().uploader.upload_stream({
|
|
64
|
+
public_id: id,
|
|
65
|
+
folder,
|
|
66
|
+
resource_type: 'auto',
|
|
67
|
+
overwrite: true,
|
|
68
|
+
invalidate: true
|
|
69
|
+
}, (error, result) => {
|
|
70
|
+
if (error !== undefined)
|
|
71
|
+
reject(error);
|
|
72
|
+
else
|
|
73
|
+
resolve(result);
|
|
74
|
+
}));
|
|
75
|
+
stream.on('error', reject);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async commit() {
|
|
79
|
+
// metadata is read-only
|
|
80
|
+
}
|
|
81
|
+
async delete(path) {
|
|
82
|
+
const id = (0, node_path_1.join)(this.prefix, path);
|
|
83
|
+
openspan_1.console.debug('Deleting from Cloudinary', { path: id });
|
|
84
|
+
await this.cloudinary().uploader.destroy(id, { resource_type: this.type, invalidate: true });
|
|
85
|
+
}
|
|
86
|
+
async move(from, to) {
|
|
87
|
+
const source = (0, node_path_1.join)(this.prefix, from);
|
|
88
|
+
const target = (0, node_path_1.join)(this.prefix, to);
|
|
89
|
+
try {
|
|
90
|
+
await this.cloudinary().uploader.rename(source, target, { resource_type: this.type, overwrite: true });
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error.http_code === 404)
|
|
94
|
+
return errors_1.ERR_NOT_FOUND;
|
|
95
|
+
else
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async fetch(path, method = 'GET') {
|
|
100
|
+
const url = this.url(path);
|
|
101
|
+
if (url === null)
|
|
102
|
+
return errors_1.ERR_NOT_FOUND;
|
|
103
|
+
openspan_1.console.debug('Fetching from Cloudinary', {
|
|
104
|
+
method,
|
|
105
|
+
path,
|
|
106
|
+
url
|
|
107
|
+
});
|
|
108
|
+
const response = await fetch(url, { method }).catch((e) => e);
|
|
109
|
+
if (response instanceof Error || response.ok === false) {
|
|
110
|
+
openspan_1.console.debug('Failed to fetch from Cloudinary', {
|
|
111
|
+
url,
|
|
112
|
+
message: response.message
|
|
113
|
+
});
|
|
114
|
+
return errors_1.ERR_NOT_FOUND;
|
|
115
|
+
}
|
|
116
|
+
return response;
|
|
117
|
+
}
|
|
118
|
+
url(path) {
|
|
119
|
+
const [base, transformation] = this.toTransformation(path);
|
|
120
|
+
if (base === null)
|
|
121
|
+
return null;
|
|
122
|
+
const id = (0, node_path_1.join)(this.prefix, base);
|
|
123
|
+
return this.cloudinary().url(id, {
|
|
124
|
+
resource_type: this.type,
|
|
125
|
+
transformation,
|
|
126
|
+
version: 2
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
toTransformation(path) {
|
|
130
|
+
if (this.transformations.length === 0)
|
|
131
|
+
return [path, undefined];
|
|
132
|
+
const [base, ...extensions] = path.split('.');
|
|
133
|
+
const transformations = [];
|
|
134
|
+
let t = 0;
|
|
135
|
+
for (const extension of extensions) {
|
|
136
|
+
let found = false;
|
|
137
|
+
for (t; t < this.transformations.length && !found; t++) {
|
|
138
|
+
const { extension: regex, transformation: options, optional } = this.transformations[t];
|
|
139
|
+
const match = regex.exec(extension);
|
|
140
|
+
// eslint-disable-next-line max-depth
|
|
141
|
+
if (match === null)
|
|
142
|
+
if (optional === true)
|
|
143
|
+
continue;
|
|
144
|
+
else
|
|
145
|
+
return [null, undefined];
|
|
146
|
+
const transformation = Object.fromEntries(Object.entries(options).map(([key, value]) => {
|
|
147
|
+
if (typeof value !== 'string')
|
|
148
|
+
return [key, value];
|
|
149
|
+
if (value.startsWith('<') && value.endsWith('>'))
|
|
150
|
+
value = match.groups[value.slice(1, -1)];
|
|
151
|
+
if (key === 'zoom' && value !== undefined)
|
|
152
|
+
value = Number.parseInt(value) / 100;
|
|
153
|
+
if (key === 'fetch_format' && value === 'jpeg')
|
|
154
|
+
value = 'jpg';
|
|
155
|
+
return [key, value];
|
|
156
|
+
}));
|
|
157
|
+
transformations.push(transformation);
|
|
158
|
+
found = true;
|
|
159
|
+
}
|
|
160
|
+
if (!found)
|
|
161
|
+
return [null, undefined];
|
|
162
|
+
}
|
|
163
|
+
for (t; t < this.transformations.length; t++)
|
|
164
|
+
if (this.transformations[t].optional !== true)
|
|
165
|
+
return [null, undefined];
|
|
166
|
+
return [base, transformations];
|
|
167
|
+
}
|
|
168
|
+
metadata(response) {
|
|
169
|
+
const size = response.headers.get('content-length') === null
|
|
170
|
+
? 0
|
|
171
|
+
: Number.parseInt(response.headers.get('content-length'));
|
|
172
|
+
const created = response.headers.get('date') ?? new Date().toISOString();
|
|
173
|
+
const etag = response.headers.get('etag');
|
|
174
|
+
const checksum = etag === null ? (0, node_path_1.basename)(response.url) : etag.slice(1, -1);
|
|
175
|
+
return {
|
|
176
|
+
type: response.headers.get('content-type'),
|
|
177
|
+
size,
|
|
178
|
+
checksum,
|
|
179
|
+
created,
|
|
180
|
+
attributes: {}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
cloudinary() {
|
|
184
|
+
cloudinary_1.v2.config(this.config);
|
|
185
|
+
return cloudinary_1.v2;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.Cloudinary = Cloudinary;
|
|
189
|
+
//# sourceMappingURL=Cloudinary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cloudinary.js","sourceRoot":"","sources":["../../source/providers/Cloudinary.ts"],"names":[],"mappings":";;;AAAA,yCAAmD;AACnD,6CAAsC;AACtC,2CAA6C;AAC7C,uCAAkC;AAClC,0CAAsC;AACtC,sCAAyC;AAazC,MAAa,UAAW,SAAQ,mBAA2B;IAClD,MAAM,CAAmB,OAAO,GAAsB;QAC3D,EAAE,IAAI,EAAE,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,YAAY,EAAE;KACvB,CAAA;IAEgB,IAAI,CAAa;IACjB,eAAe,GAAqB,EAAE,CAAA;IACtC,MAAM,CAAe;IACrB,MAAM,CAAQ;IAE/B,YAAoB,OAA0B,EAAE,OAA2B;QACzE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAEvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QAExB,IA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