@proteinjs/db-file 1.8.3 → 1.9.0
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/CHANGELOG.md +38 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +3 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/src/DbFileStorageDriver.d.ts +7 -0
- package/dist/src/DbFileStorageDriver.d.ts.map +1 -1
- package/dist/src/DbFileStorageDriver.js +69 -41
- package/dist/src/DbFileStorageDriver.js.map +1 -1
- package/dist/src/FileCopyForOthers.d.ts +52 -0
- package/dist/src/FileCopyForOthers.d.ts.map +1 -0
- package/dist/src/FileCopyForOthers.js +62 -0
- package/dist/src/FileCopyForOthers.js.map +1 -0
- package/dist/src/FileStorage.d.ts +145 -11
- package/dist/src/FileStorage.d.ts.map +1 -1
- package/dist/src/FileStorage.js +537 -41
- package/dist/src/FileStorage.js.map +1 -1
- package/dist/src/FileStorageDriver.d.ts +11 -0
- package/dist/src/FileStorageDriver.d.ts.map +1 -1
- package/dist/src/FileStorageError.d.ts +62 -0
- package/dist/src/FileStorageError.d.ts.map +1 -0
- package/dist/src/FileStorageError.js +118 -0
- package/dist/src/FileStorageError.js.map +1 -0
- package/dist/src/FileVariantMaker.d.ts +61 -0
- package/dist/src/FileVariantMaker.d.ts.map +1 -0
- package/dist/src/FileVariantMaker.js +62 -0
- package/dist/src/FileVariantMaker.js.map +1 -0
- package/dist/src/routes/FileResponder.d.ts +41 -0
- package/dist/src/routes/FileResponder.d.ts.map +1 -0
- package/dist/src/routes/FileResponder.js +135 -0
- package/dist/src/routes/FileResponder.js.map +1 -0
- package/dist/src/routes/getFile.d.ts +5 -13
- package/dist/src/routes/getFile.d.ts.map +1 -1
- package/dist/src/routes/getFile.js +20 -56
- package/dist/src/routes/getFile.js.map +1 -1
- package/dist/src/routes/getFileVariant.d.ts +20 -0
- package/dist/src/routes/getFileVariant.d.ts.map +1 -0
- package/dist/src/routes/getFileVariant.js +112 -0
- package/dist/src/routes/getFileVariant.js.map +1 -0
- package/dist/src/routes/getFileVariantRoute.d.ts +7 -0
- package/dist/src/routes/getFileVariantRoute.d.ts.map +1 -0
- package/dist/src/routes/getFileVariantRoute.js +9 -0
- package/dist/src/routes/getFileVariantRoute.js.map +1 -0
- package/dist/src/tables/FileTable.d.ts +55 -2
- package/dist/src/tables/FileTable.d.ts.map +1 -1
- package/dist/src/tables/FileTable.js +8 -0
- package/dist/src/tables/FileTable.js.map +1 -1
- package/dist/test/DbFileStorageDriverMissingBytes.test.d.ts +2 -0
- package/dist/test/DbFileStorageDriverMissingBytes.test.d.ts.map +1 -0
- package/dist/test/DbFileStorageDriverMissingBytes.test.js +184 -0
- package/dist/test/DbFileStorageDriverMissingBytes.test.js.map +1 -0
- package/dist/test/FileByteAccess.test.js +6 -3
- package/dist/test/FileByteAccess.test.js.map +1 -1
- package/dist/test/FileCopyForOthers.test.d.ts +2 -0
- package/dist/test/FileCopyForOthers.test.d.ts.map +1 -0
- package/dist/test/FileCopyForOthers.test.js +1143 -0
- package/dist/test/FileCopyForOthers.test.js.map +1 -0
- package/dist/test/FileMediaMetadata.test.js +60 -5
- package/dist/test/FileMediaMetadata.test.js.map +1 -1
- package/dist/test/FileStorageError.test.d.ts +2 -0
- package/dist/test/FileStorageError.test.d.ts.map +1 -0
- package/dist/test/FileStorageError.test.js +68 -0
- package/dist/test/FileStorageError.test.js.map +1 -0
- package/dist/test/FileTestEnvironment.d.ts.map +1 -1
- package/dist/test/FileTestEnvironment.js +3 -0
- package/dist/test/FileTestEnvironment.js.map +1 -1
- package/dist/test/FileVariants.test.d.ts +2 -0
- package/dist/test/FileVariants.test.d.ts.map +1 -0
- package/dist/test/FileVariants.test.js +1008 -0
- package/dist/test/FileVariants.test.js.map +1 -0
- package/dist/test/GetFileRoute.test.js +29 -0
- package/dist/test/GetFileRoute.test.js.map +1 -1
- package/generated/index.ts +3 -1
- package/index.ts +4 -0
- package/package.json +5 -5
- package/src/DbFileStorageDriver.ts +32 -21
- package/src/FileCopyForOthers.ts +71 -0
- package/src/FileStorage.ts +351 -18
- package/src/FileStorageDriver.ts +12 -0
- package/src/FileStorageError.ts +123 -0
- package/src/FileVariantMaker.ts +84 -0
- package/src/routes/FileResponder.ts +85 -0
- package/src/routes/getFile.ts +9 -44
- package/src/routes/getFileVariant.ts +53 -0
- package/src/routes/getFileVariantRoute.ts +7 -0
- package/src/tables/FileTable.ts +57 -1
- package/test/DbFileStorageDriverMissingBytes.test.ts +85 -0
- package/test/FileByteAccess.test.ts +7 -1
- package/test/FileCopyForOthers.test.ts +702 -0
- package/test/FileMediaMetadata.test.ts +44 -0
- package/test/FileStorageError.test.ts +79 -0
- package/test/FileTestEnvironment.ts +3 -0
- package/test/FileVariants.test.ts +604 -0
- package/test/GetFileRoute.test.ts +19 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileStorage.js","sourceRoot":"","sources":["../../src/FileStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAiF;AAEjF,0CAAyC;AACzC,oEAA0F;AAE1F,uEAA0E;AAC1E,oDAAmE;AACnE,4CAA2C;AAC3C,6DAA4D;AAE5D;;;KAGK;AACE,IAAM,cAAc,GAAG;IAC5B,OAAA,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAE,IAAA,0CAAqB,GAAkB;AAA1F,CAA0F,CAAC;AADhF,QAAA,cAAc,kBACkE;AAS7F;;;;GAIG;AACH;IAAA;QAGS,oBAAe,GAAG;YACvB,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI;aACf;SACF,CAAC;IAqKJ,CAAC;IAnKC;;;;;OAKG;IACI,qBAAS,GAAhB;QACE,IAAI,CAAC,WA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AD1C,IAAK,CAAA;;;;;;KAGzB;IAED;;;;;;OAMG;IACY,oBAAQ,GAAvB;QACE,OAAO,IAAI,wBAAc,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IACnD,CAAC;IA5eD,sGAAsG;IACvF,uBAAW,GAAG,IAAI,GAAG,EAAuC,AAAjD,CAAkD;IA4e9E,kBAAC;CAAA,AA/eD,IA+eC;AA/eY,kCAAW"}
|
|
@@ -6,6 +6,17 @@ import { File } from './tables/FileTable';
|
|
|
6
6
|
* file's true bytes — for text and binary files alike. Drivers own their at-rest representation,
|
|
7
7
|
* with one hard requirement: a driver that serves blobs directly to clients (`getSignedUrl`)
|
|
8
8
|
* MUST store the true bytes at rest, because clients read its objects without any decode step.
|
|
9
|
+
*
|
|
10
|
+
* Error contract: a failed byte operation throws a {@link FileStorageError} — a code, a plain
|
|
11
|
+
* message and the store's HTTP status where it has one — and NEVER the store client's own error
|
|
12
|
+
* object or anything hanging off one (a request config, a request, a response, headers, a signed
|
|
13
|
+
* URL): a client's error holds the request it made, and that request holds the driver's
|
|
14
|
+
* credentials, so an application logging what it caught would write a live credential. Bytes that
|
|
15
|
+
* are not there are reported as the `not-found` code on every read and overwrite, so callers
|
|
16
|
+
* branch on one thing whichever driver is behind them (`deleteFile` alone treats missing bytes as
|
|
17
|
+
* success — see its contract). A driver whose store IS the application's database
|
|
18
|
+
* (`DbFileStorageDriver`) lets the database layer's own errors through unchanged: they are
|
|
19
|
+
* already that layer's owned errors, and a transaction runner must see them to retry.
|
|
9
20
|
*/
|
|
10
21
|
export interface FileStorageDriver {
|
|
11
22
|
createFile(file: File, fileData: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileStorageDriver.d.ts","sourceRoot":"","sources":["../../src/FileStorageDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileStorageDriver.d.ts","sourceRoot":"","sources":["../../src/FileStorageDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC;;;;;;OAMG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7E;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a byte operation failed — the closed set a caller branches on.
|
|
3
|
+
*
|
|
4
|
+
* - `not-found`: the stored bytes for that file id are not there.
|
|
5
|
+
* - `precondition-failed`: the store refused a conditional write (the object changed underneath it).
|
|
6
|
+
* - `forbidden`: the store refused the driver's credentials or permissions.
|
|
7
|
+
* - `unavailable`: the store could not be reached or asked to be retried later.
|
|
8
|
+
* - `unknown`: anything else.
|
|
9
|
+
*/
|
|
10
|
+
export type FileStorageErrorCode = 'not-found' | 'precondition-failed' | 'forbidden' | 'unavailable' | 'unknown';
|
|
11
|
+
/**
|
|
12
|
+
* THE error a {@link FileStorageDriver} throws — the only thing that leaves a driver when a byte
|
|
13
|
+
* operation fails.
|
|
14
|
+
*
|
|
15
|
+
* It carries three plain facts and nothing else: a {@link FileStorageErrorCode}, a one-line
|
|
16
|
+
* message, and the HTTP status where the store speaks HTTP. It NEVER carries the store client's own
|
|
17
|
+
* error object, nor anything hanging off one — a request config, a request, a response, headers, a
|
|
18
|
+
* signed URL. A store client's error routinely holds the request it made, and that request holds
|
|
19
|
+
* the driver's credentials (an `Authorization` header); an application that logs the error it
|
|
20
|
+
* caught would write a live credential into its logs. The driver is the only party that talks to
|
|
21
|
+
* the store, so the driver owns what its errors carry, and no caller has to know to strip one.
|
|
22
|
+
*
|
|
23
|
+
* Callers branch on `code` — through {@link FileStorageError.is} / {@link FileStorageError.isNotFound},
|
|
24
|
+
* which read the error's shape rather than its prototype, so they hold across duplicate copies of
|
|
25
|
+
* this package in one process.
|
|
26
|
+
*/
|
|
27
|
+
export declare class FileStorageError extends Error {
|
|
28
|
+
private static readonly NAME;
|
|
29
|
+
private static readonly CODES;
|
|
30
|
+
/** Free text that reaches a message is one line and bounded. */
|
|
31
|
+
private static readonly MAX_DETAIL_CHARS;
|
|
32
|
+
readonly code: FileStorageErrorCode;
|
|
33
|
+
/** The store's HTTP status, where it has one. */
|
|
34
|
+
readonly status?: number;
|
|
35
|
+
/**
|
|
36
|
+
* @param code what went wrong, for callers to branch on
|
|
37
|
+
* @param summary the driver's own words for the failed operation (e.g. `getFileData failed for file <id>`)
|
|
38
|
+
* @param options.status the store's HTTP status, where it has one
|
|
39
|
+
* @param options.detail the store's own message text — made plain (see {@link plain}) before it is kept
|
|
40
|
+
*/
|
|
41
|
+
constructor(code: FileStorageErrorCode, summary: string, options?: {
|
|
42
|
+
status?: number;
|
|
43
|
+
detail?: unknown;
|
|
44
|
+
});
|
|
45
|
+
/** Is this a driver's error? Read by shape, so it holds across duplicate copies of this package. */
|
|
46
|
+
static is(error: unknown): error is FileStorageError;
|
|
47
|
+
/** The stored bytes for that file id are not there. */
|
|
48
|
+
static isNotFound(error: unknown): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The code an HTTP status means. Drivers whose store speaks HTTP share this table so one status
|
|
51
|
+
* never reads two ways.
|
|
52
|
+
*/
|
|
53
|
+
static codeForStatus(status: number | undefined): FileStorageErrorCode;
|
|
54
|
+
private static describe;
|
|
55
|
+
/**
|
|
56
|
+
* A store's message text made safe to keep: text only (an object is never read into it), one
|
|
57
|
+
* line, bounded, with every URL's query string dropped (a signed URL's signature lives there)
|
|
58
|
+
* and any bearer credential masked.
|
|
59
|
+
*/
|
|
60
|
+
private static plain;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=FileStorageError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorageError.d.ts","sourceRoot":"","sources":["../../src/FileStorageError.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,qBAAqB,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;AAEjH;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAsB;IAClD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAM3B;IACF,gEAAgE;IAChE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAO;IAE/C,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,iDAAiD;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;gBACS,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE;IAUxG,oGAAoG;IACpG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB;IAQpD,uDAAuD;IACvD,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAI1C;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,oBAAoB;IAgBtE,OAAO,CAAC,MAAM,CAAC,QAAQ;IAUvB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,KAAK;CAcrB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.FileStorageError = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* THE error a {@link FileStorageDriver} throws — the only thing that leaves a driver when a byte
|
|
21
|
+
* operation fails.
|
|
22
|
+
*
|
|
23
|
+
* It carries three plain facts and nothing else: a {@link FileStorageErrorCode}, a one-line
|
|
24
|
+
* message, and the HTTP status where the store speaks HTTP. It NEVER carries the store client's own
|
|
25
|
+
* error object, nor anything hanging off one — a request config, a request, a response, headers, a
|
|
26
|
+
* signed URL. A store client's error routinely holds the request it made, and that request holds
|
|
27
|
+
* the driver's credentials (an `Authorization` header); an application that logs the error it
|
|
28
|
+
* caught would write a live credential into its logs. The driver is the only party that talks to
|
|
29
|
+
* the store, so the driver owns what its errors carry, and no caller has to know to strip one.
|
|
30
|
+
*
|
|
31
|
+
* Callers branch on `code` — through {@link FileStorageError.is} / {@link FileStorageError.isNotFound},
|
|
32
|
+
* which read the error's shape rather than its prototype, so they hold across duplicate copies of
|
|
33
|
+
* this package in one process.
|
|
34
|
+
*/
|
|
35
|
+
var FileStorageError = /** @class */ (function (_super) {
|
|
36
|
+
__extends(FileStorageError, _super);
|
|
37
|
+
/**
|
|
38
|
+
* @param code what went wrong, for callers to branch on
|
|
39
|
+
* @param summary the driver's own words for the failed operation (e.g. `getFileData failed for file <id>`)
|
|
40
|
+
* @param options.status the store's HTTP status, where it has one
|
|
41
|
+
* @param options.detail the store's own message text — made plain (see {@link plain}) before it is kept
|
|
42
|
+
*/
|
|
43
|
+
function FileStorageError(code, summary, options) {
|
|
44
|
+
var _this = _super.call(this, FileStorageError.describe(code, summary, options)) || this;
|
|
45
|
+
_this.name = FileStorageError.NAME;
|
|
46
|
+
Object.setPrototypeOf(_this, FileStorageError.prototype);
|
|
47
|
+
_this.code = code;
|
|
48
|
+
if ((options === null || options === void 0 ? void 0 : options.status) !== undefined) {
|
|
49
|
+
_this.status = options.status;
|
|
50
|
+
}
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
/** Is this a driver's error? Read by shape, so it holds across duplicate copies of this package. */
|
|
54
|
+
FileStorageError.is = function (error) {
|
|
55
|
+
var candidate = error;
|
|
56
|
+
return ((candidate === null || candidate === void 0 ? void 0 : candidate.name) === FileStorageError.NAME &&
|
|
57
|
+
FileStorageError.CODES.includes(candidate.code));
|
|
58
|
+
};
|
|
59
|
+
/** The stored bytes for that file id are not there. */
|
|
60
|
+
FileStorageError.isNotFound = function (error) {
|
|
61
|
+
return FileStorageError.is(error) && error.code === 'not-found';
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The code an HTTP status means. Drivers whose store speaks HTTP share this table so one status
|
|
65
|
+
* never reads two ways.
|
|
66
|
+
*/
|
|
67
|
+
FileStorageError.codeForStatus = function (status) {
|
|
68
|
+
if (status === 404) {
|
|
69
|
+
return 'not-found';
|
|
70
|
+
}
|
|
71
|
+
if (status === 412) {
|
|
72
|
+
return 'precondition-failed';
|
|
73
|
+
}
|
|
74
|
+
if (status === 401 || status === 403) {
|
|
75
|
+
return 'forbidden';
|
|
76
|
+
}
|
|
77
|
+
if (status === 408 || status === 429 || (status !== undefined && status >= 500 && status <= 599)) {
|
|
78
|
+
return 'unavailable';
|
|
79
|
+
}
|
|
80
|
+
return 'unknown';
|
|
81
|
+
};
|
|
82
|
+
FileStorageError.describe = function (code, summary, options) {
|
|
83
|
+
var status = (options === null || options === void 0 ? void 0 : options.status) !== undefined ? " (HTTP ".concat(options.status, ")") : '';
|
|
84
|
+
var detail = FileStorageError.plain(options === null || options === void 0 ? void 0 : options.detail);
|
|
85
|
+
return "".concat(summary, ": ").concat(code).concat(status).concat(detail ? " \u2014 ".concat(detail) : '');
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* A store's message text made safe to keep: text only (an object is never read into it), one
|
|
89
|
+
* line, bounded, with every URL's query string dropped (a signed URL's signature lives there)
|
|
90
|
+
* and any bearer credential masked.
|
|
91
|
+
*/
|
|
92
|
+
FileStorageError.plain = function (detail) {
|
|
93
|
+
if (typeof detail !== 'string') {
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
var oneLine = detail
|
|
97
|
+
.replace(/\s+/g, ' ')
|
|
98
|
+
.replace(/(https?:\/\/[^\s?#]+)[?#]\S*/gi, '$1')
|
|
99
|
+
.replace(/\b(bearer|basic)\s+\S+/gi, '$1 [masked]')
|
|
100
|
+
.trim();
|
|
101
|
+
return oneLine.length > FileStorageError.MAX_DETAIL_CHARS
|
|
102
|
+
? "".concat(oneLine.slice(0, FileStorageError.MAX_DETAIL_CHARS), "\u2026")
|
|
103
|
+
: oneLine;
|
|
104
|
+
};
|
|
105
|
+
FileStorageError.NAME = 'FileStorageError';
|
|
106
|
+
FileStorageError.CODES = [
|
|
107
|
+
'not-found',
|
|
108
|
+
'precondition-failed',
|
|
109
|
+
'forbidden',
|
|
110
|
+
'unavailable',
|
|
111
|
+
'unknown',
|
|
112
|
+
];
|
|
113
|
+
/** Free text that reaches a message is one line and bounded. */
|
|
114
|
+
FileStorageError.MAX_DETAIL_CHARS = 300;
|
|
115
|
+
return FileStorageError;
|
|
116
|
+
}(Error));
|
|
117
|
+
exports.FileStorageError = FileStorageError;
|
|
118
|
+
//# sourceMappingURL=FileStorageError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorageError.js","sourceRoot":"","sources":["../../src/FileStorageError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;GAeG;AACH;IAAsC,oCAAK;IAgBzC;;;;;OAKG;IACH,0BAAY,IAA0B,EAAE,OAAe,EAAE,OAA+C;QAAxG,YACE,kBAAM,gBAAgB,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,SAOzD;QANC,KAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACxD,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,MAAK,SAAS,EAAE;YACjC,KAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;SAC9B;;IACH,CAAC;IAED,oGAAoG;IAC7F,mBAAE,GAAT,UAAU,KAAc;QACtB,IAAM,SAAS,GAAG,KAA8D,CAAC;QACjF,OAAO,CACL,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,MAAK,gBAAgB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ACY,sBAAK,GAApB,UAAqB,MAAe;QAClC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,OAAO,EAAE,CAAC;SACX;QAED,IAAM,OAAO,GAAG,MAAM;aACnB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,OAAO,CAAC,gCAAgC,EAAE,IAAI,CAAC;aAC/C,OAAO,CAAC,0BAA0B,EAAE,aAAa,CAAC;aAClD,IAAI,EAAE,CAAC;QACV,OAAO,OAAO,CAAC,MAAM,GAAG,gBAAgB,CAAC,gBAAgB;YACvD,CAAC,CAAC,UAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,WAAG;YAC3D,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;IA7FuB,qBAAI,GAAG,kBAAkB,CAAC;IAC1B,sBAAK,GAA2B;QACtD,WAAW;QACX,qBAAqB;QACrB,WAAW;QACX,aAAa;QACb,SAAS;KACV,CAAC;IACF,gEAAgE;IACxC,iCAAgB,GAAG,GAAG,CAAC;IAqFjD,uBAAC;CAAA,AA/FD,CAAsC,KAAK,GA+F1C;AA/FY,4CAAgB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Loadable } from '@proteinjs/reflection';
|
|
4
|
+
import { File } from './tables/FileTable';
|
|
5
|
+
/**
|
|
6
|
+
* The kinds of derived File a file can carry — each a seat on the row (`File.preview`,
|
|
7
|
+
* `File.stage`) with one lifecycle: made once, named on the row, dropped when the original's
|
|
8
|
+
* bytes change, deleted with the original, readable by whoever can read the original.
|
|
9
|
+
*/
|
|
10
|
+
export type FileVariantKind = 'preview' | 'stage';
|
|
11
|
+
export declare const FILE_VARIANT_KINDS: readonly FileVariantKind[];
|
|
12
|
+
/** What the maker hands back for a variant: the bytes, their type, and the facts a consumer renders from without loading them. */
|
|
13
|
+
export interface FileVariant {
|
|
14
|
+
bytes: Buffer;
|
|
15
|
+
type: string;
|
|
16
|
+
width?: number;
|
|
17
|
+
height?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* How a derived File of a File is made — ONE owner for "a variant of this file's bytes".
|
|
21
|
+
*
|
|
22
|
+
* The library owns the seat on the row, the lifecycle and the access rule for every variant
|
|
23
|
+
* (`FileStorage.deriveVariants` at ingest, `FileStorage.getVariant` on the read path); the one
|
|
24
|
+
* package that knows the file's format registers how the variant's bytes are made — a picture's
|
|
25
|
+
* 512 px thumbnail (`preview`) and its 1600 px rendition for the stage (`stage`) are two answers
|
|
26
|
+
* of the same maker, never two mechanisms. Dependency direction is the
|
|
27
|
+
* {@link FileReachabilityResolver} / {@link FileCopyForOthers} pattern: the interface here, the
|
|
28
|
+
* implementation above, discovered through the SourceRepository. With no maker registered no
|
|
29
|
+
* variant is ever made and every consumer draws the original.
|
|
30
|
+
*/
|
|
31
|
+
export interface FileVariantMaker extends Loadable {
|
|
32
|
+
/**
|
|
33
|
+
* Whether a variant of this kind is made of this file at all — decided from the row alone,
|
|
34
|
+
* never from its bytes (a document, a clip, a picture already small enough cost no read). True
|
|
35
|
+
* means {@link make} is called once with the original's bytes and its answer is stored.
|
|
36
|
+
*/
|
|
37
|
+
appliesTo(file: File, kind: FileVariantKind): boolean;
|
|
38
|
+
/** The variant, made from the original's bytes. Throws when it cannot be made — nothing is stored, the consumer draws the original. */
|
|
39
|
+
make(file: File, bytes: Buffer, kind: FileVariantKind): Promise<FileVariant>;
|
|
40
|
+
}
|
|
41
|
+
export declare const getFileVariantMaker: () => FileVariantMaker | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* What a derivation becomes when the registered maker could not make the variant of these
|
|
44
|
+
* bytes: nothing is stored. Thrown by `FileStorage` in place of whatever the maker threw (the
|
|
45
|
+
* maker's own one-line reason kept as `reason`), so the ingest door can report it to the caller
|
|
46
|
+
* holding the bytes and the read path can tell it from a failure of the store or the database
|
|
47
|
+
* (and serve the file itself). Read by shape ({@link FileVariantNotMade.is}), like
|
|
48
|
+
* `FileCopyRefused`, so it holds across duplicate copies of this package.
|
|
49
|
+
*/
|
|
50
|
+
export declare class FileVariantNotMade extends Error {
|
|
51
|
+
private static readonly NAME;
|
|
52
|
+
/** Free text that reaches a message is one line and bounded. */
|
|
53
|
+
private static readonly MAX_REASON_CHARS;
|
|
54
|
+
readonly fileId: string;
|
|
55
|
+
readonly kind: FileVariantKind;
|
|
56
|
+
readonly reason: string;
|
|
57
|
+
constructor(fileId: string, kind: FileVariantKind, cause: unknown);
|
|
58
|
+
static is(error: unknown): error is FileVariantNotMade;
|
|
59
|
+
private static plain;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=FileVariantMaker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileVariantMaker.d.ts","sourceRoot":"","sources":["../../src/FileVariantMaker.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC;AAElD,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EAAyB,CAAC;AAEnF,kIAAkI;AAClI,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC;IACtD,uIAAuI;IACvI,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9E;AAED,eAAO,MAAM,mBAAmB,QAAO,gBAAgB,GAAG,SAC8B,CAAC;AAEzF;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAwB;IACpD,gEAAgE;IAChE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAO;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO;IAUjE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB;IAItD,OAAO,CAAC,MAAM,CAAC,KAAK;CAOrB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.FileVariantNotMade = exports.getFileVariantMaker = exports.FILE_VARIANT_KINDS = void 0;
|
|
19
|
+
var reflection_1 = require("@proteinjs/reflection");
|
|
20
|
+
exports.FILE_VARIANT_KINDS = ['preview', 'stage'];
|
|
21
|
+
var getFileVariantMaker = function () {
|
|
22
|
+
return reflection_1.SourceRepository.get().object('@proteinjs/db-file/FileVariantMaker');
|
|
23
|
+
};
|
|
24
|
+
exports.getFileVariantMaker = getFileVariantMaker;
|
|
25
|
+
/**
|
|
26
|
+
* What a derivation becomes when the registered maker could not make the variant of these
|
|
27
|
+
* bytes: nothing is stored. Thrown by `FileStorage` in place of whatever the maker threw (the
|
|
28
|
+
* maker's own one-line reason kept as `reason`), so the ingest door can report it to the caller
|
|
29
|
+
* holding the bytes and the read path can tell it from a failure of the store or the database
|
|
30
|
+
* (and serve the file itself). Read by shape ({@link FileVariantNotMade.is}), like
|
|
31
|
+
* `FileCopyRefused`, so it holds across duplicate copies of this package.
|
|
32
|
+
*/
|
|
33
|
+
var FileVariantNotMade = /** @class */ (function (_super) {
|
|
34
|
+
__extends(FileVariantNotMade, _super);
|
|
35
|
+
function FileVariantNotMade(fileId, kind, cause) {
|
|
36
|
+
var _this = this;
|
|
37
|
+
var reason = FileVariantNotMade.plain(cause);
|
|
38
|
+
_this = _super.call(this, "No ".concat(kind, " variant could be made of file ").concat(fileId).concat(reason ? ": ".concat(reason) : '')) || this;
|
|
39
|
+
_this.name = FileVariantNotMade.NAME;
|
|
40
|
+
Object.setPrototypeOf(_this, FileVariantNotMade.prototype);
|
|
41
|
+
_this.fileId = fileId;
|
|
42
|
+
_this.kind = kind;
|
|
43
|
+
_this.reason = reason;
|
|
44
|
+
return _this;
|
|
45
|
+
}
|
|
46
|
+
FileVariantNotMade.is = function (error) {
|
|
47
|
+
return (error === null || error === void 0 ? void 0 : error.name) === FileVariantNotMade.NAME;
|
|
48
|
+
};
|
|
49
|
+
FileVariantNotMade.plain = function (cause) {
|
|
50
|
+
var message = cause instanceof Error ? cause.message : typeof cause === 'string' ? cause : '';
|
|
51
|
+
var line = message.replace(/\s+/g, ' ').trim();
|
|
52
|
+
return line.length > FileVariantNotMade.MAX_REASON_CHARS
|
|
53
|
+
? "".concat(line.slice(0, FileVariantNotMade.MAX_REASON_CHARS), "\u2026")
|
|
54
|
+
: line;
|
|
55
|
+
};
|
|
56
|
+
FileVariantNotMade.NAME = 'FileVariantNotMade';
|
|
57
|
+
/** Free text that reaches a message is one line and bounded. */
|
|
58
|
+
FileVariantNotMade.MAX_REASON_CHARS = 300;
|
|
59
|
+
return FileVariantNotMade;
|
|
60
|
+
}(Error));
|
|
61
|
+
exports.FileVariantNotMade = FileVariantNotMade;
|
|
62
|
+
//# sourceMappingURL=FileVariantMaker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileVariantMaker.js","sourceRoot":"","sources":["../../src/FileVariantMaker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oDAAmE;AAUtD,QAAA,kBAAkB,GAA+B,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAiC5E,IAAM,mBAAmB,GAAG;IACjC,OAAA,6BAAgB,CAAC,GAAG,EAAE,CAAC,MAAM,CAAmB,qCAAqC,CAAC;AAAtF,CAAsF,CAAC;AAD5E,QAAA,mBAAmB,uBACyD;AAEzF;;;;;;;GAOG;AACH;IAAwC,sCAAK;IAQ3C,4BAAY,MAAc,EAAE,IAAqB,EAAE,KAAc;QAAjE,iBAQC;QAPC,IAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC/C,kBAAM,aAAM,IAAI,4CAAkC,MAAM,SAAG,MAAM,CAAC,CAAC,CAAC,YAAK,MAAM,CAAE,CAAC,CAAC,CAAC,EAAE,CAAE,CAAC;QACzF,KAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAC1D,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;IACvB,CAAC;IAEM,qBAAE,GAAT,UAAU,KAAc;QACtB,OAAO,CAAC,KAA+C,aAA/C,KAAK,uBAAL,KAAK,CAA4C,IAAI,MAAK,kBAAkB,CAAC,IAAI,CAAC;IAC5F,CAAC;IAEc,wBAAK,GAApB,UAAqB,KAAc;QACjC,IAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAChG,IAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC,MAAM,GAAG,kBAAkB,CAAC,gBAAgB;YACtD,CAAC,CAAC,UAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,WAAG;YAC1D,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IA3BuB,uBAAI,GAAG,oBAAoB,CAAC;IACpD,gEAAgE;IACxC,mCAAgB,GAAG,GAAG,CAAC;IA0BjD,yBAAC;CAAA,AA7BD,CAAwC,KAAK,GA6B5C;AA7BY,gDAAkB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { File } from '../tables/FileTable';
|
|
2
|
+
/** The express members the file routes touch — typed narrowly so the routes and their tests agree. */
|
|
3
|
+
export type FileRequest = {
|
|
4
|
+
params: Record<string, string>;
|
|
5
|
+
headers?: {
|
|
6
|
+
range?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export type FileResponse = {
|
|
10
|
+
status(code: number): {
|
|
11
|
+
send(body: unknown): unknown;
|
|
12
|
+
};
|
|
13
|
+
send(body: unknown): unknown;
|
|
14
|
+
setHeader(name: string, value: string): void;
|
|
15
|
+
redirect(status: number, url: string): void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* THE ONE SERVING PATH for a file's bytes — `GET /file/:id` and `GET /file/:id/variant/:kind`
|
|
19
|
+
* answer through it, so a variant is served exactly as any File is. Two shapes:
|
|
20
|
+
*
|
|
21
|
+
* - **302 redirect** to a short-lived signed URL when the driver's store has an external URL
|
|
22
|
+
* space (GCS). The app URL stays the one stable reference every `<img>`/`<video>`/chip uses;
|
|
23
|
+
* the client follows the redirect and reads the store directly — native Range/206 for video
|
|
24
|
+
* seeking, real caching, bytes never transit the app server. The redirect itself is cached
|
|
25
|
+
* briefly (client-private, well under the signed TTL) so repeated loads reuse one URL.
|
|
26
|
+
* - **Proxy** for drivers with no external URL space (`DbFileStorageDriver`): the interface's
|
|
27
|
+
* base64 is decoded so every mime — binary or text — serves its true bytes, and HTTP Range
|
|
28
|
+
* is honored (206/416 via {@link resolveByteRange}) so a `<video>` can SEEK against a
|
|
29
|
+
* proxy-served blob — streaming parity with the signed-URL path instead of download-then-watch.
|
|
30
|
+
*
|
|
31
|
+
* WHICH bytes is `FileStorage`'s decision (`getSignedUrl` / `getFileData` substitute the copy
|
|
32
|
+
* for others for anyone but the owner); the headers are the row's (its name and type). The
|
|
33
|
+
* route decided existence and access before calling here (`FileStorage.getFile`).
|
|
34
|
+
*/
|
|
35
|
+
export declare class FileResponder {
|
|
36
|
+
/** Serve `file` (a row the caller may read) to `response`; every failure shape mapped to its status. */
|
|
37
|
+
static serve(file: File, request: FileRequest, response: FileResponse): Promise<void>;
|
|
38
|
+
/** The failure shapes a file read has: bytes missing behind a row (404), a refusal (its status, 404), anything else (500, logged). */
|
|
39
|
+
static fail(fileId: string, error: unknown, response: FileResponse): void;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=FileResponder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileResponder.d.ts","sourceRoot":"","sources":["../../../src/routes/FileResponder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAM3C,sGAAsG;AACtG,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAC3F,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAA;KAAE,CAAC;IACvD,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAa;IACxB,wGAAwG;WAC3F,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC3F,sIAAsI;IACtI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;CAgB1E"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.FileResponder = void 0;
|
|
40
|
+
var FileStorage_1 = require("../FileStorage");
|
|
41
|
+
var FileStorageError_1 = require("../FileStorageError");
|
|
42
|
+
var service_1 = require("@proteinjs/service");
|
|
43
|
+
var byteRange_1 = require("./byteRange");
|
|
44
|
+
/**
|
|
45
|
+
* THE ONE SERVING PATH for a file's bytes — `GET /file/:id` and `GET /file/:id/variant/:kind`
|
|
46
|
+
* answer through it, so a variant is served exactly as any File is. Two shapes:
|
|
47
|
+
*
|
|
48
|
+
* - **302 redirect** to a short-lived signed URL when the driver's store has an external URL
|
|
49
|
+
* space (GCS). The app URL stays the one stable reference every `<img>`/`<video>`/chip uses;
|
|
50
|
+
* the client follows the redirect and reads the store directly — native Range/206 for video
|
|
51
|
+
* seeking, real caching, bytes never transit the app server. The redirect itself is cached
|
|
52
|
+
* briefly (client-private, well under the signed TTL) so repeated loads reuse one URL.
|
|
53
|
+
* - **Proxy** for drivers with no external URL space (`DbFileStorageDriver`): the interface's
|
|
54
|
+
* base64 is decoded so every mime — binary or text — serves its true bytes, and HTTP Range
|
|
55
|
+
* is honored (206/416 via {@link resolveByteRange}) so a `<video>` can SEEK against a
|
|
56
|
+
* proxy-served blob — streaming parity with the signed-URL path instead of download-then-watch.
|
|
57
|
+
*
|
|
58
|
+
* WHICH bytes is `FileStorage`'s decision (`getSignedUrl` / `getFileData` substitute the copy
|
|
59
|
+
* for others for anyone but the owner); the headers are the row's (its name and type). The
|
|
60
|
+
* route decided existence and access before calling here (`FileStorage.getFile`).
|
|
61
|
+
*/
|
|
62
|
+
var FileResponder = /** @class */ (function () {
|
|
63
|
+
function FileResponder() {
|
|
64
|
+
}
|
|
65
|
+
/** Serve `file` (a row the caller may read) to `response`; every failure shape mapped to its status. */
|
|
66
|
+
FileResponder.serve = function (file, request, response) {
|
|
67
|
+
var _a;
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
var fileStorage, signedUrl, bytes, _b, _c, safeFilename, range, error_1;
|
|
70
|
+
return __generator(this, function (_d) {
|
|
71
|
+
switch (_d.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
fileStorage = new FileStorage_1.FileStorage();
|
|
74
|
+
_d.label = 1;
|
|
75
|
+
case 1:
|
|
76
|
+
_d.trys.push([1, 4, , 5]);
|
|
77
|
+
return [4 /*yield*/, fileStorage.getSignedUrl(file.id)];
|
|
78
|
+
case 2:
|
|
79
|
+
signedUrl = _d.sent();
|
|
80
|
+
if (signedUrl) {
|
|
81
|
+
response.setHeader('Cache-Control', 'private, max-age=300');
|
|
82
|
+
response.redirect(302, signedUrl);
|
|
83
|
+
return [2 /*return*/];
|
|
84
|
+
}
|
|
85
|
+
_c = (_b = Buffer).from;
|
|
86
|
+
return [4 /*yield*/, fileStorage.getFileData(file.id)];
|
|
87
|
+
case 3:
|
|
88
|
+
bytes = _c.apply(_b, [_d.sent(), 'base64']);
|
|
89
|
+
safeFilename = encodeURIComponent(file.name);
|
|
90
|
+
response.setHeader('Content-Disposition', "inline; filename=\"".concat(safeFilename, "\""));
|
|
91
|
+
response.setHeader('Content-Type', file.type);
|
|
92
|
+
response.setHeader('Accept-Ranges', 'bytes');
|
|
93
|
+
range = (0, byteRange_1.resolveByteRange)((_a = request.headers) === null || _a === void 0 ? void 0 : _a.range, bytes.length);
|
|
94
|
+
if (range === 'unsatisfiable') {
|
|
95
|
+
response.setHeader('Content-Range', "bytes */".concat(bytes.length));
|
|
96
|
+
response.status(416).send('Range Not Satisfiable');
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
if (range) {
|
|
100
|
+
response.setHeader('Content-Range', "bytes ".concat(range.start, "-").concat(range.end, "/").concat(bytes.length));
|
|
101
|
+
response.status(206).send(bytes.subarray(range.start, range.end + 1));
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
response.send(bytes);
|
|
105
|
+
return [3 /*break*/, 5];
|
|
106
|
+
case 4:
|
|
107
|
+
error_1 = _d.sent();
|
|
108
|
+
FileResponder.fail(file.id, error_1, response);
|
|
109
|
+
return [3 /*break*/, 5];
|
|
110
|
+
case 5: return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
/** The failure shapes a file read has: bytes missing behind a row (404), a refusal (its status, 404), anything else (500, logged). */
|
|
116
|
+
FileResponder.fail = function (fileId, error, response) {
|
|
117
|
+
if (FileStorageError_1.FileStorageError.isNotFound(error)) {
|
|
118
|
+
// The row is there and its bytes are not: the same answer as a row that is not there.
|
|
119
|
+
response.status(404).send('File not found');
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (service_1.ServiceRefusal.is(error)) {
|
|
123
|
+
// A deliberate refusal, not a failure — a file no copy can be made of is not there for anyone
|
|
124
|
+
// but its owner (`FileStorage` answers every door the same 404 and keeps the maker's reason in
|
|
125
|
+
// its own WARN). The same words as a row the caller cannot read; quiet, and never a 500.
|
|
126
|
+
response.status(error.status).send('File not found');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
console.error("Error fetching file (".concat(fileId, "):"), error);
|
|
130
|
+
response.status(500).send('Internal Server Error');
|
|
131
|
+
};
|
|
132
|
+
return FileResponder;
|
|
133
|
+
}());
|
|
134
|
+
exports.FileResponder = FileResponder;
|
|
135
|
+
//# sourceMappingURL=FileResponder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileResponder.js","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CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACrD,CAAC;IACH,oBAAC;AAAD,CAAC,AAnDD,IAmDC;AAnDY,sCAAa"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { Route } from '@proteinjs/server-api';
|
|
2
2
|
/**
|
|
3
3
|
* Serves a file's bytes. Auth first: logged-in, then the `FileStorage.getFile` row read as the
|
|
4
|
-
* access decision — the caller's SCOPED read, else the shared-content
|
|
5
|
-
* (`FileReachabilityResolver`: the caller may read a file when they may read a
|
|
6
|
-
* references it, e.g. a shared thought's media node). Then
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* space (GCS). The app URL stays the one stable reference every `<img>`/`<video>`/chip uses;
|
|
10
|
-
* the client follows the redirect and reads the store directly — native Range/206 for video
|
|
11
|
-
* seeking, real caching, bytes never transit the app server. The redirect itself is cached
|
|
12
|
-
* briefly (client-private, well under the signed TTL) so repeated loads reuse one URL.
|
|
13
|
-
* - **Proxy** for drivers with no external URL space (`DbFileStorageDriver`): the interface's
|
|
14
|
-
* base64 is decoded so every mime — binary or text — serves its true bytes, and HTTP Range
|
|
15
|
-
* is honored (206/416 via {@link resolveByteRange}) so a `<video>` can SEEK against a
|
|
16
|
-
* proxy-served blob — streaming parity with the signed-URL path instead of download-then-watch.
|
|
4
|
+
* access decision — the caller's SCOPED read, else a variant's original, else the shared-content
|
|
5
|
+
* reachability leg (`FileReachabilityResolver`: the caller may read a file when they may read a
|
|
6
|
+
* row that references it, e.g. a shared thought's media node). Then {@link FileResponder} — the
|
|
7
|
+
* one serving path (a 302 to a signed URL, or the proxy with Range) every file route answers
|
|
8
|
+
* through.
|
|
17
9
|
*/
|
|
18
10
|
export declare const getFile: Route;
|
|
19
11
|
//# sourceMappingURL=getFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../src/routes/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK9C
|
|
1
|
+
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../src/routes/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK9C;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EAAE,KAsBrB,CAAC"}
|