@proteinjs/db-file 1.10.17 → 1.11.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 +11 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +5 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/routes/FileResponder.d.ts +25 -0
- package/dist/src/routes/FileResponder.d.ts.map +1 -1
- package/dist/src/routes/FileResponder.js +88 -29
- package/dist/src/routes/FileResponder.js.map +1 -1
- package/dist/src/routes/getFileBytes.d.ts +14 -0
- package/dist/src/routes/getFileBytes.d.ts.map +1 -0
- package/dist/src/routes/getFileBytes.js +90 -0
- package/dist/src/routes/getFileBytes.js.map +1 -0
- package/dist/src/routes/getFileRoute.d.ts +14 -0
- package/dist/src/routes/getFileRoute.d.ts.map +1 -1
- package/dist/src/routes/getFileRoute.js +15 -1
- package/dist/src/routes/getFileRoute.js.map +1 -1
- package/dist/src/routes/getFileVariantBytes.d.ts +11 -0
- package/dist/src/routes/getFileVariantBytes.d.ts.map +1 -0
- package/dist/src/routes/getFileVariantBytes.js +103 -0
- package/dist/src/routes/getFileVariantBytes.js.map +1 -0
- package/dist/src/routes/getFileVariantRoute.d.ts +5 -0
- package/dist/src/routes/getFileVariantRoute.d.ts.map +1 -1
- package/dist/src/routes/getFileVariantRoute.js +7 -1
- package/dist/src/routes/getFileVariantRoute.js.map +1 -1
- package/dist/test/GetFileBytesRoute.test.d.ts +2 -0
- package/dist/test/GetFileBytesRoute.test.d.ts.map +1 -0
- package/dist/test/GetFileBytesRoute.test.js +488 -0
- package/dist/test/GetFileBytesRoute.test.js.map +1 -0
- package/generated/index.ts +5 -1
- package/package.json +2 -2
- package/src/routes/FileResponder.ts +62 -18
- package/src/routes/getFileBytes.ts +38 -0
- package/src/routes/getFileRoute.ts +16 -0
- package/src/routes/getFileVariantBytes.ts +42 -0
- package/src/routes/getFileVariantRoute.ts +7 -0
- package/test/GetFileBytesRoute.test.ts +316 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileBytes.d.ts","sourceRoot":"","sources":["../../../src/routes/getFileBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK9C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,KAqB1B,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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.getFileBytes = void 0;
|
|
40
|
+
var user_1 = require("@proteinjs/user");
|
|
41
|
+
var FileStorage_1 = require("../FileStorage");
|
|
42
|
+
var FileResponder_1 = require("./FileResponder");
|
|
43
|
+
/**
|
|
44
|
+
* Serves a file's bytes THEMSELVES, same-origin, never a redirect (`FileResponder.serveBytes`) — the
|
|
45
|
+
* door a page reads when it must keep the bytes (a copy of the file held on the device, say): a `fetch`
|
|
46
|
+
* of `/file/:id` lands on another origin's signed URL whose body the page cannot read and whose URL it
|
|
47
|
+
* cannot keep; this door answers the same bytes from the app's own origin.
|
|
48
|
+
*
|
|
49
|
+
* Auth exactly as `/file/:id` (the same row read is the access decision — `FileStorage.getFile`: the
|
|
50
|
+
* caller's scoped read, else a variant's original, else the shared-content reachability leg); the
|
|
51
|
+
* bytes leave through the same egress decision (the owner's original, the copy for others otherwise).
|
|
52
|
+
* No new permission exists at this door: whoever may read the file by its URL may read its bytes here.
|
|
53
|
+
*/
|
|
54
|
+
exports.getFileBytes = {
|
|
55
|
+
path: '/file/:id/bytes',
|
|
56
|
+
method: 'get',
|
|
57
|
+
onRequest: function (request, response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
var fileId, file, error_1;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
if (!user_1.UserAuth.isLoggedIn()) {
|
|
63
|
+
response.status(401).send('User not logged in');
|
|
64
|
+
return [2 /*return*/];
|
|
65
|
+
}
|
|
66
|
+
fileId = request.params.id;
|
|
67
|
+
_a.label = 1;
|
|
68
|
+
case 1:
|
|
69
|
+
_a.trys.push([1, 4, , 5]);
|
|
70
|
+
return [4 /*yield*/, (0, FileStorage_1.getFileStorage)().getFile(fileId)];
|
|
71
|
+
case 2:
|
|
72
|
+
file = _a.sent();
|
|
73
|
+
if (!file) {
|
|
74
|
+
response.status(404).send('File not found');
|
|
75
|
+
return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
return [4 /*yield*/, FileResponder_1.FileResponder.serveBytes(file, request, response)];
|
|
78
|
+
case 3:
|
|
79
|
+
_a.sent();
|
|
80
|
+
return [3 /*break*/, 5];
|
|
81
|
+
case 4:
|
|
82
|
+
error_1 = _a.sent();
|
|
83
|
+
FileResponder_1.FileResponder.fail(fileId, error_1, response);
|
|
84
|
+
return [3 /*break*/, 5];
|
|
85
|
+
case 5: return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); },
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=getFileBytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileBytes.js","sourceRoot":"","sources":["../../../src/routes/getFileBytes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wCAA2C;AAC3C,8CAAgD;AAChD,iDAAgD;AAEhD;;;;;;;;;;GAUG;AACU,QAAA,YAAY,GAAU;IACjC,IAAI,EAAE,iBAAiB;IACvB,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,UAAO,OAAO,EAAE,QAAQ;;;;;oBACjC,IAAI,CAAC,eAAQ,CAAC,UAAU,EAAE,EAAE;wBAC1B,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;wBAChD,sBAAO;qBACR;oBAEK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;;;;oBAElB,qBAAM,IAAA,4BAAc,GAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;oBAA7C,IAAI,GAAG,SAAsC;oBACnD,IAAI,CAAC,IAAI,EAAE;wBACT,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;wBAC5C,sBAAO;qBACR;oBACD,qBAAM,6BAAa,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAA;;oBAAvD,SAAuD,CAAC;;;;oBAExD,6BAAa,CAAC,IAAI,CAAC,MAAM,EAAE,OAAK,EAAE,QAAQ,CAAC,CAAC;;;;;SAE/C;CACF,CAAC"}
|
|
@@ -2,4 +2,18 @@ export declare const getFileRoute: {
|
|
|
2
2
|
path: (fileId: string) => string;
|
|
3
3
|
method: string;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* THE BYTES DOOR of a file URL — the ONE rule behind `GET /file/:id/bytes` and
|
|
7
|
+
* `GET /file/:id/variant/:kind/bytes`: the URL a surface already asks the file (or its variant) by,
|
|
8
|
+
* plus `/bytes`. A client that holds a file URL derives the door from it here, never by its own
|
|
9
|
+
* string; the typed paths below derive from this same rule.
|
|
10
|
+
*/
|
|
11
|
+
export declare const fileBytesRoute: {
|
|
12
|
+
of: (fileUrl: string) => string;
|
|
13
|
+
};
|
|
14
|
+
/** The same-origin bytes of a file — served by `GET /file/:id/bytes` (never a redirect; see `FileResponder.serveBytes`). */
|
|
15
|
+
export declare const getFileBytesRoute: {
|
|
16
|
+
path: (fileId: string) => string;
|
|
17
|
+
method: string;
|
|
18
|
+
};
|
|
5
19
|
//# sourceMappingURL=getFileRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileRoute.d.ts","sourceRoot":"","sources":["../../../src/routes/getFileRoute.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;mBAAoB,MAAM;;CAAuC,CAAC"}
|
|
1
|
+
{"version":3,"file":"getFileRoute.d.ts","sourceRoot":"","sources":["../../../src/routes/getFileRoute.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;mBAAoB,MAAM;;CAAuC,CAAC;AAE3F;;;;;GAKG;AACH,eAAO,MAAM,cAAc;kBACX,MAAM;CACrB,CAAC;AAEF,4HAA4H;AAC5H,eAAO,MAAM,iBAAiB;mBACb,MAAM;;CAEtB,CAAC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFileRoute = void 0;
|
|
3
|
+
exports.getFileBytesRoute = exports.fileBytesRoute = exports.getFileRoute = void 0;
|
|
4
4
|
exports.getFileRoute = { path: function (fileId) { return "/file/".concat(fileId); }, method: 'get' };
|
|
5
|
+
/**
|
|
6
|
+
* THE BYTES DOOR of a file URL — the ONE rule behind `GET /file/:id/bytes` and
|
|
7
|
+
* `GET /file/:id/variant/:kind/bytes`: the URL a surface already asks the file (or its variant) by,
|
|
8
|
+
* plus `/bytes`. A client that holds a file URL derives the door from it here, never by its own
|
|
9
|
+
* string; the typed paths below derive from this same rule.
|
|
10
|
+
*/
|
|
11
|
+
exports.fileBytesRoute = {
|
|
12
|
+
of: function (fileUrl) { return "".concat(fileUrl, "/bytes"); },
|
|
13
|
+
};
|
|
14
|
+
/** The same-origin bytes of a file — served by `GET /file/:id/bytes` (never a redirect; see `FileResponder.serveBytes`). */
|
|
15
|
+
exports.getFileBytesRoute = {
|
|
16
|
+
path: function (fileId) { return exports.fileBytesRoute.of(exports.getFileRoute.path(fileId)); },
|
|
17
|
+
method: 'get',
|
|
18
|
+
};
|
|
5
19
|
//# sourceMappingURL=getFileRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileRoute.js","sourceRoot":"","sources":["../../../src/routes/getFileRoute.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,EAAE,IAAI,EAAE,UAAC,MAAc,IAAK,OAAA,gBAAS,MAAM,CAAE,EAAjB,CAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"getFileRoute.js","sourceRoot":"","sources":["../../../src/routes/getFileRoute.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,EAAE,IAAI,EAAE,UAAC,MAAc,IAAK,OAAA,gBAAS,MAAM,CAAE,EAAjB,CAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAE3F;;;;;GAKG;AACU,QAAA,cAAc,GAAG;IAC5B,EAAE,EAAE,UAAC,OAAe,IAAK,OAAA,UAAG,OAAO,WAAQ,EAAlB,CAAkB;CAC5C,CAAC;AAEF,4HAA4H;AAC/G,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,UAAC,MAAc,IAAK,OAAA,sBAAc,CAAC,EAAE,CAAC,oBAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAA5C,CAA4C;IACtE,MAAM,EAAE,KAAK;CACd,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Route } from '@proteinjs/server-api';
|
|
2
|
+
/**
|
|
3
|
+
* Serves a file's VARIANT's bytes themselves, same-origin, never a redirect (`FileResponder.serveBytes`)
|
|
4
|
+
* — the bytes door of `/file/:id/variant/:kind`: the variant the row names, derived on this first
|
|
5
|
+
* request when absent, the file itself when none applies; exactly the row `GET /file/:id/variant/:kind`
|
|
6
|
+
* serves, through the same read (`FileStorage.getVariant` — the original's access decision inside) and
|
|
7
|
+
* the same egress (a non-owner is served the copy for others). A kind the library does not know is a
|
|
8
|
+
* 404, as a file that is not there; a caller who may not read the original is answered the same.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getFileVariantBytes: Route;
|
|
11
|
+
//# sourceMappingURL=getFileVariantBytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileVariantBytes.d.ts","sourceRoot":"","sources":["../../../src/routes/getFileVariantBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAM9C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,KA2BjC,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
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.getFileVariantBytes = void 0;
|
|
40
|
+
var user_1 = require("@proteinjs/user");
|
|
41
|
+
var FileStorage_1 = require("../FileStorage");
|
|
42
|
+
var FileVariantMaker_1 = require("../FileVariantMaker");
|
|
43
|
+
var FileResponder_1 = require("./FileResponder");
|
|
44
|
+
/**
|
|
45
|
+
* Serves a file's VARIANT's bytes themselves, same-origin, never a redirect (`FileResponder.serveBytes`)
|
|
46
|
+
* — the bytes door of `/file/:id/variant/:kind`: the variant the row names, derived on this first
|
|
47
|
+
* request when absent, the file itself when none applies; exactly the row `GET /file/:id/variant/:kind`
|
|
48
|
+
* serves, through the same read (`FileStorage.getVariant` — the original's access decision inside) and
|
|
49
|
+
* the same egress (a non-owner is served the copy for others). A kind the library does not know is a
|
|
50
|
+
* 404, as a file that is not there; a caller who may not read the original is answered the same.
|
|
51
|
+
*/
|
|
52
|
+
exports.getFileVariantBytes = {
|
|
53
|
+
path: '/file/:id/variant/:kind/bytes',
|
|
54
|
+
method: 'get',
|
|
55
|
+
onRequest: function (request, response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var fileId, kind, fileStorage, served, _a, error_1;
|
|
57
|
+
var _b;
|
|
58
|
+
return __generator(this, function (_c) {
|
|
59
|
+
switch (_c.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
if (!user_1.UserAuth.isLoggedIn()) {
|
|
62
|
+
response.status(401).send('User not logged in');
|
|
63
|
+
return [2 /*return*/];
|
|
64
|
+
}
|
|
65
|
+
fileId = request.params.id;
|
|
66
|
+
kind = request.params.kind;
|
|
67
|
+
if (!FileVariantMaker_1.FILE_VARIANT_KINDS.includes(kind)) {
|
|
68
|
+
response.status(404).send('File not found');
|
|
69
|
+
return [2 /*return*/];
|
|
70
|
+
}
|
|
71
|
+
_c.label = 1;
|
|
72
|
+
case 1:
|
|
73
|
+
_c.trys.push([1, 7, , 8]);
|
|
74
|
+
fileStorage = new FileStorage_1.FileStorage();
|
|
75
|
+
return [4 /*yield*/, fileStorage.getVariant(fileId, kind)];
|
|
76
|
+
case 2:
|
|
77
|
+
if (!((_b = (_c.sent())) !== null && _b !== void 0)) return [3 /*break*/, 3];
|
|
78
|
+
_a = _b;
|
|
79
|
+
return [3 /*break*/, 5];
|
|
80
|
+
case 3: return [4 /*yield*/, fileStorage.getFile(fileId)];
|
|
81
|
+
case 4:
|
|
82
|
+
_a = (_c.sent());
|
|
83
|
+
_c.label = 5;
|
|
84
|
+
case 5:
|
|
85
|
+
served = _a;
|
|
86
|
+
if (!served) {
|
|
87
|
+
response.status(404).send('File not found');
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
return [4 /*yield*/, FileResponder_1.FileResponder.serveBytes(served, request, response)];
|
|
91
|
+
case 6:
|
|
92
|
+
_c.sent();
|
|
93
|
+
return [3 /*break*/, 8];
|
|
94
|
+
case 7:
|
|
95
|
+
error_1 = _c.sent();
|
|
96
|
+
FileResponder_1.FileResponder.fail(fileId, error_1, response);
|
|
97
|
+
return [3 /*break*/, 8];
|
|
98
|
+
case 8: return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}); },
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=getFileVariantBytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileVariantBytes.js","sourceRoot":"","sources":["../../../src/routes/getFileVariantBytes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wCAA2C;AAC3C,8CAA6C;AAC7C,wDAA0E;AAC1E,iDAAgD;AAEhD;;;;;;;GAOG;AACU,QAAA,mBAAmB,GAAU;IACxC,IAAI,EAAE,+BAA+B;IACrC,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,UAAO,OAAO,EAAE,QAAQ;;;;;;oBACjC,IAAI,CAAC,eAAQ,CAAC,UAAU,EAAE,EAAE;wBAC1B,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;wBAChD,sBAAO;qBACR;oBAEK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC3B,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAuB,CAAC;oBACpD,IAAI,CAAC,qCAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;wBACtC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;wBAC5C,sBAAO;qBACR;;;;oBAEO,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;oBACtB,qBAAM,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,EAAA;;gCAA3C,CAAC,SAA0C,CAAC;;;wBAAK,qBAAM,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;oBAAlC,KAAA,CAAC,SAAiC,CAAC,CAAA;;;oBAA5F,MAAM,KAAsF;oBAClG,IAAI,CAAC,MAAM,EAAE;wBACX,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;wBAC5C,sBAAO;qBACR;oBACD,qBAAM,6BAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAA;;oBAAzD,SAAyD,CAAC;;;;oBAE1D,6BAAa,CAAC,IAAI,CAAC,MAAM,EAAE,OAAK,EAAE,QAAQ,CAAC,CAAC;;;;;SAE/C;CACF,CAAC"}
|
|
@@ -4,4 +4,9 @@ export declare const getFileVariantRoute: {
|
|
|
4
4
|
path: (fileId: string, kind: FileVariantKind) => string;
|
|
5
5
|
method: string;
|
|
6
6
|
};
|
|
7
|
+
/** The same-origin bytes of a file's variant — served by `GET /file/:id/variant/:kind/bytes` (never a redirect; see `FileResponder.serveBytes`). */
|
|
8
|
+
export declare const getFileVariantBytesRoute: {
|
|
9
|
+
path: (fileId: string, kind: FileVariantKind) => string;
|
|
10
|
+
method: string;
|
|
11
|
+
};
|
|
7
12
|
//# sourceMappingURL=getFileVariantRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileVariantRoute.d.ts","sourceRoot":"","sources":["../../../src/routes/getFileVariantRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"getFileVariantRoute.d.ts","sourceRoot":"","sources":["../../../src/routes/getFileVariantRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,0JAA0J;AAC1J,eAAO,MAAM,mBAAmB;mBACf,MAAM,QAAQ,eAAe;;CAE7C,CAAC;AAEF,oJAAoJ;AACpJ,eAAO,MAAM,wBAAwB;mBACpB,MAAM,QAAQ,eAAe;;CAE7C,CAAC"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFileVariantRoute = void 0;
|
|
3
|
+
exports.getFileVariantBytesRoute = exports.getFileVariantRoute = void 0;
|
|
4
|
+
var getFileRoute_1 = require("./getFileRoute");
|
|
4
5
|
/** The URL a surface asks a file's variant of a kind by — served by `GET /file/:id/variant/:kind` (the variant, or the file itself when none applies). */
|
|
5
6
|
exports.getFileVariantRoute = {
|
|
6
7
|
path: function (fileId, kind) { return "/file/".concat(fileId, "/variant/").concat(kind); },
|
|
7
8
|
method: 'get',
|
|
8
9
|
};
|
|
10
|
+
/** The same-origin bytes of a file's variant — served by `GET /file/:id/variant/:kind/bytes` (never a redirect; see `FileResponder.serveBytes`). */
|
|
11
|
+
exports.getFileVariantBytesRoute = {
|
|
12
|
+
path: function (fileId, kind) { return getFileRoute_1.fileBytesRoute.of(exports.getFileVariantRoute.path(fileId, kind)); },
|
|
13
|
+
method: 'get',
|
|
14
|
+
};
|
|
9
15
|
//# sourceMappingURL=getFileVariantRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileVariantRoute.js","sourceRoot":"","sources":["../../../src/routes/getFileVariantRoute.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getFileVariantRoute.js","sourceRoot":"","sources":["../../../src/routes/getFileVariantRoute.ts"],"names":[],"mappings":";;;AACA,+CAAgD;AAEhD,0JAA0J;AAC7I,QAAA,mBAAmB,GAAG;IACjC,IAAI,EAAE,UAAC,MAAc,EAAE,IAAqB,IAAK,OAAA,gBAAS,MAAM,sBAAY,IAAI,CAAE,EAAjC,CAAiC;IAClF,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,oJAAoJ;AACvI,QAAA,wBAAwB,GAAG;IACtC,IAAI,EAAE,UAAC,MAAc,EAAE,IAAqB,IAAK,OAAA,6BAAc,CAAC,EAAE,CAAC,2BAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,EAAzD,CAAyD;IAC1G,MAAM,EAAE,KAAK;CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetFileBytesRoute.test.d.ts","sourceRoot":"","sources":["../../test/GetFileBytesRoute.test.ts"],"names":[],"mappings":""}
|