@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.
Files changed (91) hide show
  1. package/package.json +14 -14
  2. package/readme.md +96 -51
  3. package/schemas/annotation.cos.yaml +1 -0
  4. package/schemas/cloudinary.cos.yaml +37 -0
  5. package/schemas/fs.cos.yaml +2 -0
  6. package/schemas/s3.cos.yaml +1 -0
  7. package/schemas/tmp.cos.yaml +0 -1
  8. package/source/Entry.ts +13 -11
  9. package/source/Factory.ts +16 -9
  10. package/source/Provider.ts +22 -19
  11. package/source/Scanner.ts +58 -26
  12. package/source/Secrets.ts +6 -0
  13. package/source/Storage.test.ts +118 -274
  14. package/source/Storage.ts +62 -207
  15. package/source/deployment.ts +52 -16
  16. package/source/errors.ts +3 -0
  17. package/source/index.ts +3 -1
  18. package/source/manifest.ts +7 -6
  19. package/source/providers/Cloudinary.ts +320 -0
  20. package/source/providers/Declaration.ts +2 -1
  21. package/source/providers/FileSystem.ts +79 -25
  22. package/source/providers/S3.ts +81 -80
  23. package/source/providers/Temporary.ts +2 -3
  24. package/source/providers/Test.ts +4 -4
  25. package/source/providers/index.test.ts +102 -76
  26. package/source/providers/index.ts +10 -4
  27. package/source/schemas.ts +1 -0
  28. package/source/test/.env.example +4 -0
  29. package/source/test/arny.jpg +0 -0
  30. package/source/test/lenna.48x48.jpeg +0 -0
  31. package/source/test/plank.mp4 +0 -0
  32. package/source/test/sample.avi +0 -0
  33. package/source/test/sample.wav +0 -0
  34. package/source/test/sport.mp4 +0 -0
  35. package/source/test/util.ts +62 -12
  36. package/transpiled/Entry.d.ts +15 -11
  37. package/transpiled/Factory.js +11 -5
  38. package/transpiled/Factory.js.map +1 -1
  39. package/transpiled/Provider.d.ts +17 -16
  40. package/transpiled/Provider.js +6 -4
  41. package/transpiled/Provider.js.map +1 -1
  42. package/transpiled/Scanner.d.ts +6 -2
  43. package/transpiled/Scanner.js +49 -22
  44. package/transpiled/Scanner.js.map +1 -1
  45. package/transpiled/Secrets.d.ts +5 -0
  46. package/transpiled/Secrets.js +3 -0
  47. package/transpiled/Secrets.js.map +1 -0
  48. package/transpiled/Storage.d.ts +13 -21
  49. package/transpiled/Storage.js +52 -155
  50. package/transpiled/Storage.js.map +1 -1
  51. package/transpiled/deployment.d.ts +1 -1
  52. package/transpiled/deployment.js +43 -16
  53. package/transpiled/deployment.js.map +1 -1
  54. package/transpiled/errors.d.ts +2 -0
  55. package/transpiled/errors.js +6 -0
  56. package/transpiled/errors.js.map +1 -0
  57. package/transpiled/index.d.ts +3 -1
  58. package/transpiled/manifest.js +5 -2
  59. package/transpiled/manifest.js.map +1 -1
  60. package/transpiled/providers/Cloudinary.d.ts +51 -0
  61. package/transpiled/providers/Cloudinary.js +223 -0
  62. package/transpiled/providers/Cloudinary.js.map +1 -0
  63. package/transpiled/providers/Declaration.d.ts +3 -2
  64. package/transpiled/providers/FileSystem.d.ts +15 -7
  65. package/transpiled/providers/FileSystem.js +64 -24
  66. package/transpiled/providers/FileSystem.js.map +1 -1
  67. package/transpiled/providers/S3.d.ts +14 -14
  68. package/transpiled/providers/S3.js +62 -60
  69. package/transpiled/providers/S3.js.map +1 -1
  70. package/transpiled/providers/Temporary.d.ts +1 -2
  71. package/transpiled/providers/Temporary.js +2 -2
  72. package/transpiled/providers/Temporary.js.map +1 -1
  73. package/transpiled/providers/Test.d.ts +3 -3
  74. package/transpiled/providers/Test.js +2 -2
  75. package/transpiled/providers/Test.js.map +1 -1
  76. package/transpiled/providers/index.d.ts +7 -2
  77. package/transpiled/providers/index.js +2 -2
  78. package/transpiled/providers/index.js.map +1 -1
  79. package/transpiled/schemas.d.ts +1 -0
  80. package/transpiled/schemas.js +2 -1
  81. package/transpiled/schemas.js.map +1 -1
  82. package/transpiled/test/util.d.ts +89 -5
  83. package/transpiled/test/util.js +51 -4
  84. package/transpiled/test/util.js.map +1 -1
  85. package/transpiled/tsconfig.tsbuildinfo +1 -1
  86. package/source/providers/FileSystem.test.ts +0 -5
  87. package/source/providers/Memory.ts +0 -41
  88. package/source/providers/S3.test.ts +0 -133
  89. package/transpiled/providers/Memory.d.ts +0 -13
  90. package/transpiled/providers/Memory.js +0 -60
  91. package/transpiled/providers/Memory.js.map +0 -1
@@ -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 = null;
14
+ error;
12
15
  hash = (0, node_crypto_1.createHash)('md5');
13
16
  claim;
14
17
  accept;
18
+ limit;
15
19
  position = 0;
16
- detected = false;
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.detected)
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, off }) => header.slice(off, off + hex.length) === 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.detected = true;
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 = (0, agent_1.negotiate)(this.accept, [type]) === null;
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.end();
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: 'ffd8ffe0', off: 0, type: 'image/jpeg' },
79
- { hex: 'ffd8ffe1', off: 0, type: 'image/jpeg' },
80
- { hex: 'ffd8ffee', off: 0, type: 'image/jpeg' },
81
- { hex: 'ffd8ffdb', off: 0, type: 'image/jpeg' },
82
- { hex: '89504e47', off: 0, type: 'image/png' },
83
- { hex: '47494638', off: 0, type: 'image/gif' },
84
- { hex: '52494646', off: 0, type: 'image/webp' },
85
- { hex: '4a584c200d0a870a', off: 8, type: 'image/jxl' },
86
- { hex: '6674797068656963', off: 8, type: 'image/heic' },
87
- { hex: '6674797061766966', off: 8, type: 'image/avif' }
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 'signatures' test group in `Storage.test.ts`.
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 = (0, error_value_1.Err)('TYPE_MISMATCH');
97
- const ERR_NOT_ACCEPTABLE = (0, error_value_1.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":";;;AAAA,6CAAiE;AACjE,6CAAwC;AACxC,yCAAyC;AACzC,6CAAiC;AAEjC,MAAa,OAAQ,SAAQ,yBAAW;IAC/B,IAAI,GAAG,CAAC,CAAA;IACR,IAAI,GAAG,0BAA0B,CAAA;IACjC,KAAK,GAAiB,IAAI,CAAA;IAEhB,IAAI,GAAG,IAAA,wBAAU,EAAC,KAAK,CAAC,CAAA;IACxB,KAAK,CAAS;IACd,MAAM,CAAS;IACxB,QAAQ,GAAG,CAAC,CAAA;IACZ,QAAQ,GAAG,KAAK,CAAA;IACP,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,OAAO,EAAE,MAAM,CAAA;IAC/B,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;IAEe,UAAU,CACzB,MAAc,EAAE,QAAwB,EAAE,QAA2B;QACpE,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAE5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACtB,CAAC;IAEgB,OAAO,GAAG,CAAC,MAAc,EAAQ,EAAE;QAClD,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAA;QA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IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;AAExE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,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,5 @@
1
+ export type Secrets<K extends string = string> = Record<K | string, string | undefined>;
2
+ export interface Secret {
3
+ readonly name: string;
4
+ readonly optional?: boolean;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Secrets.js","sourceRoot":"","sources":["../source/Secrets.ts"],"names":[],"mappings":""}
@@ -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
- import type { Entry } from './Entry';
6
- export declare class Storage {
6
+ export declare class Storage<T extends Provider = Provider> {
7
7
  private readonly provider;
8
- constructor(provider: 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<Entry>;
11
- fetch(path: string): Maybe<Readable>;
11
+ get(path: string, options?: unknown): Maybe<Stream>;
12
+ head(path: string): Promise<Maybe<Entry>>;
12
13
  delete(path: string): Maybe<void>;
13
- list(path: string): Promise<string[]>;
14
- permute(path: string, ids: string[]): Maybe<void>;
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
- meta?: Meta;
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 {};
@@ -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 msgpackr_1 = require("msgpackr");
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 tempname = await this.transit(pipe);
19
- if (scanner.error !== null)
20
- return scanner.error;
21
- const id = scanner.digest();
22
- await this.persist(tempname, id);
23
- return await this.create(path, id, scanner.size, scanner.type, options?.meta);
24
- }
25
- async get(path) {
26
- const metapath = node_path_1.posix.join(ENTRIES, path, META);
27
- const result = await this.provider.get(metapath);
28
- if (result === null)
29
- return ERR_NOT_FOUND;
30
- else
31
- return (0, msgpackr_1.decode)(await (0, generic_1.buffer)(result));
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
- created: Date.now(),
128
- variants: [],
129
- meta
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 save(rel, entry) {
139
- const buffer = (0, msgpackr_1.encode)(entry);
140
- const stream = node_stream_1.Readable.from(buffer);
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
- async enroll(path, id, addition = false) {
144
- const dir = node_path_1.posix.join(ENTRIES, path);
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
- parse(path) {
161
- const [last, ...segments] = path.split('/').reverse();
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 ERR_NOT_FOUND = (0, error_value_1.Err)('NOT_FOUND');
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
  //# sourceM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,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;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 SERIALIZATION_PREFIX = "TOA_STORAGES";
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[]>;
@@ -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.SERIALIZATION_PREFIX = void 0;
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.SERIALIZATION_PREFIX = 'TOA_STORAGES';
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.SERIALIZATION_PREFIX, value };
35
+ const pointer = { name: exports.ENV_PREFIX, value };
36
36
  const secrets = getSecrets(annotation);
37
- return {
38
- variables: { global: [pointer, ...secrets] }
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
- for (const secret of Provider.SECRETS)
57
- secrets.push({
58
- name: `${exports.SERIALIZATION_PREFIX}_${name}_${secret.name}`.toUpperCase(),
59
- secret: {
60
- name: `toa-storages-${name}`,
61
- key: secret.name,
62
- optional: secret.optional
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":";;;;;;;;;;;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AAO,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,2 @@
1
+ import { Err } from 'error-value';
2
+ export declare const ERR_NOT_FOUND: Err;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERR_NOT_FOUND = void 0;
4
+ const error_value_1 = require("error-value");
5
+ exports.ERR_NOT_FOUND = new error_value_1.Err('NOT_FOUND');
6
+ //# sourceMappingURL=errors.js.map
@@ -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"}
@@ -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';
@@ -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
- return (0, matchacho_1.match)(manifest, String, (name) => [name], Array, manifest, null, []);
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,yCAAiC;AAEjC,SAAgB,QAAQ,CAAE,QAAkC;IAC1D,OAAO,IAAA,iBAAK,EAAC,QAAQ,EACnB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAChC,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,EAAE,CAAC,CAAA;AACb,CAAC;AALD,4BAKC"}
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"}