@toa.io/extensions.storages 1.0.0-alpha.34 → 1.0.0-alpha.340

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 (122) hide show
  1. package/package.json +43 -18
  2. package/readme.md +127 -47
  3. package/transpiled/Aspect.d.ts +8 -4
  4. package/transpiled/Aspect.js +12 -14
  5. package/transpiled/Aspect.js.map +1 -1
  6. package/transpiled/Entry.d.ts +14 -11
  7. package/transpiled/Entry.js +1 -2
  8. package/transpiled/Factory.d.ts +10 -2
  9. package/transpiled/Factory.js +52 -32
  10. package/transpiled/Factory.js.map +1 -1
  11. package/transpiled/Provider.d.ts +23 -19
  12. package/transpiled/Provider.js +18 -32
  13. package/transpiled/Provider.js.map +1 -1
  14. package/transpiled/Scanner.d.ts +10 -4
  15. package/transpiled/Scanner.js +38 -26
  16. package/transpiled/Scanner.js.map +1 -1
  17. package/transpiled/Secrets.d.ts +5 -0
  18. package/transpiled/Secrets.js +2 -0
  19. package/transpiled/Secrets.js.map +1 -0
  20. package/transpiled/Storage.d.ts +35 -22
  21. package/transpiled/Storage.js +95 -141
  22. package/transpiled/Storage.js.map +1 -1
  23. package/transpiled/errors.d.ts +15 -0
  24. package/transpiled/errors.js +12 -0
  25. package/transpiled/errors.js.map +1 -0
  26. package/transpiled/index.d.ts +4 -4
  27. package/transpiled/index.js +1 -9
  28. package/transpiled/index.js.map +1 -1
  29. package/transpiled/measurements.d.ts +3 -0
  30. package/transpiled/measurements.js +23 -0
  31. package/transpiled/measurements.js.map +1 -0
  32. package/transpiled/providers/Cloudinary.d.ts +55 -0
  33. package/transpiled/providers/Cloudinary.js +232 -0
  34. package/transpiled/providers/Cloudinary.js.map +1 -0
  35. package/transpiled/providers/Declaration.d.ts +9 -5
  36. package/transpiled/providers/Declaration.js +1 -2
  37. package/transpiled/providers/FileSystem.d.ts +16 -11
  38. package/transpiled/providers/FileSystem.js +64 -43
  39. package/transpiled/providers/FileSystem.js.map +1 -1
  40. package/transpiled/providers/S3.d.ts +18 -18
  41. package/transpiled/providers/S3.js +87 -122
  42. package/transpiled/providers/S3.js.map +1 -1
  43. package/transpiled/providers/Spaces.d.ts +12 -0
  44. package/transpiled/providers/Spaces.js +13 -0
  45. package/transpiled/providers/Spaces.js.map +1 -0
  46. package/transpiled/providers/Temporary.d.ts +2 -3
  47. package/transpiled/providers/Temporary.js +7 -11
  48. package/transpiled/providers/Temporary.js.map +1 -1
  49. package/transpiled/providers/Test.d.ts +4 -4
  50. package/transpiled/providers/Test.js +6 -12
  51. package/transpiled/providers/Test.js.map +1 -1
  52. package/transpiled/providers/index.d.ts +23 -11
  53. package/transpiled/providers/index.js +30 -14
  54. package/transpiled/providers/index.js.map +1 -1
  55. package/transpiled/providers/index.types.d.ts +5 -0
  56. package/transpiled/providers/index.types.js +2 -0
  57. package/transpiled/providers/index.types.js.map +1 -0
  58. package/transpiled/test/util.d.ts +113 -6
  59. package/transpiled/test/util.js +68 -15
  60. package/transpiled/test/util.js.map +1 -1
  61. package/schemas/annotation.cos.yaml +0 -10
  62. package/schemas/fs.cos.yaml +0 -9
  63. package/schemas/mem.cos.yaml +0 -6
  64. package/schemas/s3.cos.yaml +0 -16
  65. package/schemas/test.cos.yaml +0 -8
  66. package/schemas/tmp.cos.yaml +0 -9
  67. package/source/Annotation.ts +0 -39
  68. package/source/Aspect.ts +0 -25
  69. package/source/Entry.ts +0 -14
  70. package/source/Factory.ts +0 -68
  71. package/source/Provider.ts +0 -37
  72. package/source/Scanner.ts +0 -153
  73. package/source/Storage.test.ts +0 -472
  74. package/source/Storage.ts +0 -235
  75. package/source/deployment.ts +0 -57
  76. package/source/index.ts +0 -5
  77. package/source/manifest.ts +0 -8
  78. package/source/providers/Declaration.ts +0 -10
  79. package/source/providers/FileSystem.test.ts +0 -5
  80. package/source/providers/FileSystem.ts +0 -63
  81. package/source/providers/Memory.ts +0 -55
  82. package/source/providers/S3.test.ts +0 -134
  83. package/source/providers/S3.ts +0 -196
  84. package/source/providers/Temporary.ts +0 -16
  85. package/source/providers/Test.ts +0 -13
  86. package/source/providers/index.test.ts +0 -136
  87. package/source/providers/index.ts +0 -16
  88. package/source/providers/readme.md +0 -25
  89. package/source/schemas.test.ts +0 -58
  90. package/source/schemas.ts +0 -15
  91. package/source/test/.env.example +0 -1
  92. package/source/test/albert.jpg +0 -0
  93. package/source/test/empty.txt +0 -0
  94. package/source/test/lenna.ascii +0 -64
  95. package/source/test/lenna.png +0 -0
  96. package/source/test/sample.avi +0 -0
  97. package/source/test/sample.avif +0 -0
  98. package/source/test/sample.gif +0 -0
  99. package/source/test/sample.heic +0 -0
  100. package/source/test/sample.jpeg +0 -0
  101. package/source/test/sample.jxl +0 -0
  102. package/source/test/sample.svg +0 -4
  103. package/source/test/sample.wav +0 -0
  104. package/source/test/sample.webp +0 -0
  105. package/source/test/util.ts +0 -45
  106. package/transpiled/Annotation.d.ts +0 -3
  107. package/transpiled/Annotation.js +0 -57
  108. package/transpiled/Annotation.js.map +0 -1
  109. package/transpiled/deployment.d.ts +0 -5
  110. package/transpiled/deployment.js +0 -68
  111. package/transpiled/deployment.js.map +0 -1
  112. package/transpiled/manifest.d.ts +0 -1
  113. package/transpiled/manifest.js +0 -9
  114. package/transpiled/manifest.js.map +0 -1
  115. package/transpiled/providers/Memory.d.ts +0 -15
  116. package/transpiled/providers/Memory.js +0 -72
  117. package/transpiled/providers/Memory.js.map +0 -1
  118. package/transpiled/schemas.d.ts +0 -9
  119. package/transpiled/schemas.js +0 -14
  120. package/transpiled/schemas.js.map +0 -1
  121. package/transpiled/tsconfig.tsbuildinfo +0 -1
  122. package/tsconfig.json +0 -12
@@ -1,36 +1,22 @@
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]; } };
1
+ import { ERR_NO_URL } from './errors.js';
2
+ export class Provider {
3
+ static SECRETS;
4
+ root;
5
+ options;
6
+ constructor(options, secrets) {
7
+ this.options = options;
8
+ new.target.SECRETS?.forEach(({ name, optional }) => {
9
+ if (optional !== true && secrets?.[name] === undefined)
10
+ throw new Error(`Missing secret '${name}'`);
11
+ });
7
12
  }
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.Provider = void 0;
27
- const assert = __importStar(require("node:assert"));
28
- class Provider {
29
- static SECRETS = [];
30
- constructor(_, secrets) {
31
- for (const { name, optional = false } of new.target.SECRETS)
32
- assert.ok(optional || secrets?.[name] !== undefined, `Missing secret '${name}'`);
13
+ /**
14
+ * Where whoever is given it reads the file straight from the provider, with no credentials of
15
+ * their own, for `expires` seconds where the address is signed. A provider that serves no
16
+ * address of its own answers `NO_URL`.
17
+ */
18
+ async url(_path, _expires) {
19
+ return ERR_NO_URL;
33
20
  }
34
21
  }
35
- exports.Provider = Provider;
36
22
  //# sourceMappingURL=Provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.js","sourceRoot":"","sources":["../source/Provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAqC;AASrC,MAAsB,QAAQ;IACrB,MAAM,CAAU,OAAO,GAA8B,EAAE,CAAA;IAE9D,YAAoB,CAAU,EAAE,OAAyB;QACvD,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO;YACzD,MAAM,CAAC,EAAE,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,mBAAmB,IAAI,GAAG,CAAC,CAAA;IACpF,CAAC;;AANH,4BAmBC"}
1
+ {"version":3,"file":"Provider.js","sourceRoot":"","sources":["../source/Provider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,OAAgB,QAAQ;IACrB,MAAM,CAAU,OAAO,CAAoB;IAClC,IAAI,CAAS;IACb,OAAO,CAAS;IAEhC,YAAsB,OAAgB,EAAE,OAAiB;QACvD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QAEtB,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;YACjD,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,SAAS;gBACpD,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,GAAG,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACJ,CAAC;IAcD;;;;OAIG;IACI,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,QAAgB;QAC9C,OAAO,UAAU,CAAA;IACnB,CAAC;CACF"}
@@ -1,26 +1,32 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { PassThrough, type TransformCallback } from 'node:stream';
4
2
  export declare class Scanner extends PassThrough {
5
3
  size: number;
6
4
  type: string;
7
- error: Error | null;
5
+ error?: Error;
8
6
  private readonly hash;
9
7
  private readonly claim?;
10
8
  private readonly accept?;
9
+ private readonly limit?;
11
10
  private position;
12
- private detected;
11
+ private completed;
13
12
  private readonly chunks;
14
13
  constructor(control?: ScanOptions);
15
14
  digest(): string;
16
15
  _transform(buffer: Buffer, encoding: BufferEncoding, callback: TransformCallback): void;
16
+ /**
17
+ * A body that ends before a signature could be read is checked as it is: the type it claims, and
18
+ * what is acceptable, are what any other body is held to.
19
+ */
20
+ _flush(callback: TransformCallback): void;
17
21
  private readonly process;
18
22
  private complete;
19
23
  private verify;
20
24
  private match;
25
+ private negotiate;
21
26
  private interrupt;
22
27
  }
23
28
  export interface ScanOptions {
24
29
  claim?: string;
25
30
  accept?: string;
31
+ limit?: number;
26
32
  }
@@ -1,24 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Scanner = void 0;
4
- const node_stream_1 = require("node:stream");
5
- const node_crypto_1 = require("node:crypto");
6
- const agent_1 = require("@toa.io/agent");
7
- const error_value_1 = require("error-value");
8
- class Scanner extends node_stream_1.PassThrough {
1
+ import { PassThrough } from 'node:stream';
2
+ import { createHash } from 'node:crypto';
3
+ import Negotiator from 'negotiator';
4
+ import { coded } from './errors.js';
5
+ export class Scanner extends PassThrough {
9
6
  size = 0;
10
7
  type = 'application/octet-stream';
11
- error = null;
12
- hash = (0, node_crypto_1.createHash)('md5');
8
+ error;
9
+ hash = createHash('md5');
13
10
  claim;
14
11
  accept;
12
+ limit;
15
13
  position = 0;
16
- detected = false;
14
+ completed = false;
17
15
  chunks = [];
18
16
  constructor(control) {
19
17
  super();
20
18
  this.claim = control?.claim;
21
19
  this.accept = control?.accept;
20
+ this.limit = control?.limit;
22
21
  }
23
22
  digest() {
24
23
  return this.hash.digest('hex');
@@ -27,10 +26,20 @@ class Scanner extends node_stream_1.PassThrough {
27
26
  super._transform(buffer, encoding, callback);
28
27
  this.process(buffer);
29
28
  }
29
+ /**
30
+ * A body that ends before a signature could be read is checked as it is: the type it claims, and
31
+ * what is acceptable, are what any other body is held to.
32
+ */
33
+ _flush(callback) {
34
+ if (!this.completed)
35
+ this.complete();
36
+ if (this.error === undefined)
37
+ callback();
38
+ }
30
39
  process = (buffer) => {
31
40
  this.size += buffer.length;
32
41
  this.hash.update(buffer);
33
- if (this.detected)
42
+ if (this.completed)
34
43
  return;
35
44
  if (this.position + buffer.length > HEADER_SIZE)
36
45
  buffer = buffer.subarray(0, HEADER_SIZE - this.position);
@@ -38,15 +47,14 @@ class Scanner extends node_stream_1.PassThrough {
38
47
  this.position += buffer.length;
39
48
  if (this.position === HEADER_SIZE)
40
49
  this.complete();
50
+ if (this.limit !== undefined && this.size > this.limit)
51
+ this.interrupt(ERR_LIMIT_EXCEEDED);
41
52
  };
42
53
  complete() {
43
54
  const header = Buffer.concat(this.chunks).toString('hex');
44
- const signature = SIGNATURES
45
- .find(({ off, hex, expression }) => {
55
+ const signature = SIGNATURES.find(({ off, hex, expression }) => {
46
56
  const sig = header.slice(off, off + hex.length);
47
- return expression === undefined
48
- ? sig === hex
49
- : expression.test(sig);
57
+ return expression === undefined ? sig === hex : expression.test(sig);
50
58
  });
51
59
  const type = signature?.type ?? this.claim;
52
60
  if (type !== undefined) {
@@ -54,7 +62,7 @@ class Scanner extends node_stream_1.PassThrough {
54
62
  this.type = type;
55
63
  }
56
64
  this.verify(signature);
57
- this.detected = true;
65
+ this.completed = true;
58
66
  }
59
67
  verify(signature) {
60
68
  if (this.claim === undefined || this.claim === 'application/octet-stream')
@@ -68,20 +76,24 @@ class Scanner extends node_stream_1.PassThrough {
68
76
  match(type) {
69
77
  if (this.accept === undefined)
70
78
  return;
71
- const unacceptable = (0, agent_1.negotiate)(this.accept, [type]) === null;
79
+ const unacceptable = this.negotiate(this.accept, [type]) === null;
72
80
  if (unacceptable)
73
81
  this.interrupt(ERR_NOT_ACCEPTABLE);
74
82
  }
83
+ negotiate(accept, type) {
84
+ return new Negotiator({ headers: { accept } }).mediaType(type) ?? null;
85
+ }
75
86
  interrupt(error) {
87
+ this.completed = true;
76
88
  this.error = error;
77
- this.end();
89
+ this.destroy(error);
78
90
  }
79
91
  }
80
- exports.Scanner = Scanner;
81
92
  // https://en.wikipedia.org/wiki/List_of_file_signatures
82
93
  const SIGNATURES = [
83
94
  { hex: 'ff d8 ff e0', off: 0, type: 'image/jpeg' },
84
95
  { hex: 'ff d8 ff e1', off: 0, type: 'image/jpeg' },
96
+ { hex: 'ff d8 ff e2', off: 0, type: 'image/jpeg' },
85
97
  { hex: 'ff d8 ff ee', off: 0, type: 'image/jpeg' },
86
98
  { hex: 'ff d8 ff db', off: 0, type: 'image/jpeg' },
87
99
  { hex: '89 50 4e 47', off: 0, type: 'image/png' },
@@ -94,7 +106,7 @@ const SIGNATURES = [
94
106
  { hex: '52 49 46 46 ?? ?? ?? ?? 57 41 56 45', off: 0, type: 'audio/wav' }
95
107
  /*
96
108
  When adding a new signature, include a copyright-free sample file in the `.tests` directory
97
- and update the 'signatures' test group in `Storage.test.ts`.
109
+ and update the `signatures` test group in `Storage.test.ts`.
98
110
  */
99
111
  ].map((signature) => {
100
112
  signature.hex = signature.hex.replaceAll(' ', '');
@@ -104,9 +116,9 @@ const SIGNATURES = [
104
116
  }
105
117
  return signature;
106
118
  });
107
- const HEADER_SIZE = SIGNATURES
108
- .reduce((max, { off, hex }) => Math.max(max, off + hex.length), 0) / 2;
119
+ const HEADER_SIZE = SIGNATURES.reduce((max, { off, hex }) => Math.max(max, off + hex.length), 0) / 2;
109
120
  const KNOWN_TYPES = new Set(SIGNATURES.map(({ type }) => type));
110
- const ERR_TYPE_MISMATCH = (0, error_value_1.Err)('TYPE_MISMATCH');
111
- const ERR_NOT_ACCEPTABLE = (0, error_value_1.Err)('NOT_ACCEPTABLE');
121
+ const ERR_TYPE_MISMATCH = coded('TYPE_MISMATCH');
122
+ const ERR_NOT_ACCEPTABLE = coded('NOT_ACCEPTABLE');
123
+ const ERR_LIMIT_EXCEEDED = coded('LIMIT_EXCEEDED');
112
124
  //# sourceMappingURL=Scanner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scanner.js","sourceRoot":"","sources":["../source/Scanner.ts"],"names":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,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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Secrets.js","sourceRoot":"","sources":["../source/Secrets.ts"],"names":[],"mappings":""}
@@ -1,30 +1,43 @@
1
- /// <reference types="node" />
2
- import { Readable } from 'node:stream';
3
- import type { ScanOptions } from './Scanner';
4
- import type { Provider } from './Provider';
5
- import type { Entry } from './Entry';
6
- export declare class Storage {
1
+ import type { Readable } from 'node:stream';
2
+ import type { Attributes, Entry, Stream } from './Entry.ts';
3
+ import type { ScanOptions } from './Scanner.ts';
4
+ import type { Provider } from './Provider.ts';
5
+ export declare class Storage<T extends Provider = Provider> {
7
6
  private readonly provider;
8
- constructor(provider: Provider);
7
+ private readonly scope?;
8
+ constructor(provider: T, scope?: Scope);
9
+ options(): T['options'];
9
10
  put(path: string, stream: Readable, options?: Options): Maybe<Entry>;
10
- get(path: string): Maybe<Entry>;
11
- list(path: string): Promise<string[]>;
12
- fetch(path: string): Maybe<Readable>;
11
+ get(path: string, options?: unknown): Maybe<Stream>;
12
+ head(path: string): Promise<Maybe<Entry>>;
13
13
  delete(path: string): Maybe<void>;
14
- move(path: string, to: string): Maybe<void>;
15
- diversify(path: string, name: string, stream: Readable): Maybe<void>;
16
- annotate(path: string, key: string, value?: unknown): Maybe<void>;
17
- private transit;
18
- private persist;
19
- private create;
20
- private save;
21
- private parse;
22
- private destruct;
14
+ /**
15
+ * Where the file is read straight from the provider, by whoever is given the address and with
16
+ * no credentials of their own: a model, a browser, another service. A signed address is good for
17
+ * `expires` seconds, an hour unless asked otherwise and a week at most. `NOT_FOUND` is a file the
18
+ * storage does not have, where the provider can tell; `NO_URL` is a storage that serves no
19
+ * address of its own.
20
+ */
21
+ url(path: string, options?: UrlOptions): Maybe<string>;
22
+ path(): string | null;
23
+ private locate;
24
+ private span;
25
+ }
26
+ export interface UrlOptions {
27
+ /** Seconds a signed address is good for: an hour by default, a week at most. */
28
+ expires?: number;
23
29
  }
24
- type Maybe<T> = Promise<T | Error>;
25
- type Meta = Record<string, string>;
26
30
  interface Options extends ScanOptions {
27
- meta?: Meta;
31
+ id?: string;
32
+ origin?: string;
33
+ attributes?: Attributes;
34
+ }
35
+ type Maybe<T> = Promise<T | Error>;
36
+ export interface Scope {
37
+ /** the logical storage name, e.g. `octets` */
38
+ name: string;
39
+ /** the provider id, e.g. `s3` */
40
+ provider: string;
28
41
  }
29
42
  export type Storages = Record<string, Storage>;
30
43
  export {};
@@ -1,157 +1,111 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Storage = void 0;
4
- const node_stream_1 = require("node:stream");
5
- const node_path_1 = require("node:path");
6
- const consumers_1 = require("node:stream/consumers");
7
- const msgpackr_1 = require("msgpackr");
8
- const generic_1 = require("@toa.io/generic");
9
- const error_value_1 = require("error-value");
10
- const Scanner_1 = require("./Scanner");
11
- class Storage {
1
+ import { basename, dirname, join } from 'node:path';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { console } from 'openspan';
4
+ import { Scanner } from './Scanner.js';
5
+ import { operation } from './measurements.js';
6
+ export class Storage {
12
7
  provider;
13
- constructor(provider) {
8
+ scope;
9
+ constructor(provider, scope) {
14
10
  this.provider = provider;
11
+ this.scope = scope;
15
12
  }
16
- async put(path, stream, options) {
17
- const scanner = new Scanner_1.Scanner(options);
18
- const pipe = stream.pipe(scanner);
19
- const tempname = await this.transit(pipe);
20
- if (scanner.error !== null)
21
- return scanner.error;
22
- const id = scanner.digest();
23
- await this.persist(tempname, id);
24
- return await this.create(path, id, scanner.size, scanner.type, options?.meta);
13
+ options() {
14
+ return this.provider.options;
25
15
  }
26
- async get(path) {
27
- const paths = this.destruct(path);
28
- const result = await this.provider.get(paths.metafile);
29
- if (result === null)
30
- return ERR_NOT_FOUND;
31
- else
32
- return (0, msgpackr_1.decode)(await (0, consumers_1.buffer)(result));
16
+ async put(path, stream, options) {
17
+ return await console.span(this.span('put', path), async () => {
18
+ const scanner = new Scanner(options);
19
+ const pipe = stream.pipe(scanner).on('error', () => undefined);
20
+ const id = options?.id ?? randomUUID().replace(/-/g, '');
21
+ const location = this.locate(path, id);
22
+ /**
23
+ * Provider can return or throw an error.
24
+ * If thrown error is TYPE_MISMATCH from the Scanner, it should be returned.
25
+ */
26
+ const error = await this.provider
27
+ .put(location, pipe)
28
+ .catch((error) => {
29
+ if (error === scanner.error)
30
+ return error;
31
+ else
32
+ throw error;
33
+ });
34
+ if (error instanceof Error)
35
+ return error;
36
+ const metadata = {
37
+ id,
38
+ size: scanner.size,
39
+ type: scanner.type,
40
+ checksum: scanner.digest(),
41
+ created: new Date().toISOString(),
42
+ attributes: options?.attributes ?? {}
43
+ };
44
+ if (options?.origin !== undefined)
45
+ metadata.attributes.origin = options.origin;
46
+ await this.provider.commit(location, metadata);
47
+ return metadata;
48
+ });
33
49
  }
34
- async list(path) {
35
- const dir = node_path_1.posix.join(ENTRIES_ROOT, path, ENTRIES_DIR);
36
- return await this.provider.list(dir);
50
+ async get(path, options) {
51
+ return await console.span(this.span('get', dirname(path)), async () => {
52
+ const location = this.locate(path);
53
+ return await this.provider.get(location, options);
54
+ });
37
55
  }
38
- async fetch(path) {
39
- const { rel, id, variant } = this.parse(path);
40
- if (variant === null && rel !== '') {
41
- const entry = await this.get(path);
42
- if (entry instanceof Error)
43
- return entry;
44
- }
45
- const blob = variant === null
46
- ? node_path_1.posix.join(BLOBs, id)
47
- : node_path_1.posix.join(ENTRIES_ROOT, rel, id, variant);
48
- const stream = await this.provider.get(blob);
49
- if (stream === null)
50
- return ERR_NOT_FOUND;
51
- else
52
- return stream;
56
+ async head(path) {
57
+ return await console.span(this.span('head', dirname(path)), async () => {
58
+ const id = basename(path).split('.')[0];
59
+ const location = this.locate(path);
60
+ const metadata = await this.provider.head(location);
61
+ if (metadata instanceof Error)
62
+ return metadata;
63
+ return {
64
+ id,
65
+ ...metadata
66
+ };
67
+ });
53
68
  }
54
69
  async delete(path) {
55
- const entry = await this.get(path);
56
- if (entry instanceof Error)
57
- return entry;
58
- const paths = this.destruct(path);
59
- await Promise.all([
60
- this.provider.delete(paths.metafile),
61
- this.provider.delete(paths.vardir)
62
- ]);
63
- }
64
- async move(path, to) {
65
- const source = this.destruct(path);
66
- const rel = to.startsWith('.');
67
- const dir = to.endsWith('/');
68
- if (rel)
69
- to = node_path_1.posix.resolve(source.rel + '/', to);
70
- if (dir)
71
- to = node_path_1.posix.join(to, source.ent);
72
- const target = this.destruct(to);
73
- await Promise.all([
74
- this.provider.move(source.metafile, target.metafile),
75
- this.provider.moveDir(source.vardir, target.vardir)
76
- ]);
77
- }
78
- async diversify(path, name, stream) {
79
- const scanner = new Scanner_1.Scanner();
80
- const pipe = stream.pipe(scanner);
81
- await this.provider.put(node_path_1.posix.join(ENTRIES_ROOT, path), name, pipe);
82
- if (scanner.error !== null)
83
- return scanner.error;
84
- const { size, type } = scanner;
85
- const entry = await this.get(path);
86
- if (entry instanceof Error)
87
- return entry;
88
- entry.variants = entry.variants.filter((variant) => variant.name !== name);
89
- entry.variants.push({ name, size, type });
90
- await this.save(path, entry);
70
+ return await console.span(this.span('delete', dirname(path)), async () => {
71
+ const location = this.locate(path);
72
+ return await this.provider.delete(location);
73
+ });
91
74
  }
92
- async annotate(path, key, value) {
93
- const entry = await this.get(path);
94
- if (entry instanceof Error)
95
- return entry;
96
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
97
- if (value === undefined)
98
- delete entry.meta[key];
99
- else
100
- entry.meta[key] = value;
101
- await this.save(path, entry);
75
+ /**
76
+ * Where the file is read straight from the provider, by whoever is given the address and with
77
+ * no credentials of their own: a model, a browser, another service. A signed address is good for
78
+ * `expires` seconds, an hour unless asked otherwise and a week at most. `NOT_FOUND` is a file the
79
+ * storage does not have, where the provider can tell; `NO_URL` is a storage that serves no
80
+ * address of its own.
81
+ */
82
+ async url(path, options) {
83
+ return await console.span(this.span('url', dirname(path)), async () => {
84
+ const expires = Math.min(options?.expires ?? HOUR, WEEK);
85
+ return await this.provider.url(this.locate(path), expires);
86
+ });
102
87
  }
103
- async transit(stream) {
104
- const tempname = (0, generic_1.newid)();
105
- await this.provider.put(TEMP, tempname, stream);
106
- return tempname;
88
+ path() {
89
+ return this.provider.root ?? null;
107
90
  }
108
- async persist(tempname, id) {
109
- const temp = node_path_1.posix.join(TEMP, tempname);
110
- const blob = node_path_1.posix.join(BLOBs, id);
111
- await this.provider.move(temp, blob);
91
+ locate(...rel) {
92
+ return join(ENTRIES, ...rel);
112
93
  }
113
- // eslint-disable-next-line max-params
114
- async create(path, id, size, type, meta = {}) {
115
- const entry = {
116
- id,
117
- size,
118
- type,
119
- created: Date.now(),
120
- variants: [],
121
- meta
94
+ span(method, path) {
95
+ return {
96
+ name: `${method} ${this.scope?.name ?? 'storage'}`,
97
+ kind: 'client',
98
+ attributes: {
99
+ ...(this.scope === undefined ? {} : { provider: this.scope.provider }),
100
+ path
101
+ },
102
+ measure: operation(method, this.scope)
122
103
  };
123
- const metafile = node_path_1.posix.join(path, entry.id);
124
- const existing = await this.get(metafile);
125
- if (existing instanceof Error)
126
- await this.save(metafile, entry);
127
- return entry;
128
- }
129
- async save(path, entry) {
130
- const paths = this.destruct(path);
131
- const stream = node_stream_1.Readable.from((0, msgpackr_1.encode)(entry));
132
- await this.provider.put(paths.metadir, paths.ent, stream);
133
- }
134
- parse(path) {
135
- const [last, ...segments] = path.split('/').reverse();
136
- const [id, ...rest] = last.split('.');
137
- const variant = rest.length > 0 ? rest.join('.') : null;
138
- const rel = segments.reverse().join('/');
139
- return { rel, id, variant };
140
- }
141
- destruct(path) {
142
- const rel = node_path_1.posix.dirname(path);
143
- const dir = node_path_1.posix.join(ENTRIES_ROOT, rel);
144
- const ent = node_path_1.posix.basename(path);
145
- const metadir = node_path_1.posix.join(dir, ENTRIES_DIR);
146
- const metafile = node_path_1.posix.join(metadir, ent);
147
- const vardir = node_path_1.posix.join(dir, ent);
148
- return { rel, dir, ent, metadir, metafile, vardir };
149
104
  }
150
105
  }
151
- exports.Storage = Storage;
152
- const ERR_NOT_FOUND = (0, error_value_1.Err)('NOT_FOUND');
153
- const TEMP = '/temp';
154
- const BLOBs = '/blobs';
155
- const ENTRIES_ROOT = '/entries';
156
- const ENTRIES_DIR = '.meta';
106
+ const ENTRIES = '/';
107
+ /** How long a signed address is good for, unless asked otherwise, s. */
108
+ const HOUR = 60 * 60;
109
+ /** The longest a signed address is good for: what S3 signs for, s. */
110
+ const WEEK = 7 * 24 * HOUR;
157
111
  //# sourceMappingURL=Storage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Storage.js","sourceRoot":"","sources":["../source/Storage.ts"],"names":[],"mappings":";;;AAAA,6CAAsC;AACtC,yCAAiC;AACjC,qDAA8C;AAC9C,uCAAyC;AACzC,6CAAuC;AACvC,6CAAiC;AACjC,uCAAmC;AAKnC,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,OAAO,CAAC,CAAA;QACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAEzC,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI;YACxB,OAAO,OAAO,CAAC,KAAK,CAAA;QAEtB,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAA;QAE3B,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QAEhC,O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