@proteinjs/db-file 1.1.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/.eslintrc.js +20 -0
- package/.prettierignore +4 -0
- package/.prettierrc +8 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/dist/generated/index.d.ts +10 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +42 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/src/DbFileStorageDriver.d.ts +14 -0
- package/dist/src/DbFileStorageDriver.d.ts.map +1 -0
- package/dist/src/DbFileStorageDriver.js +143 -0
- package/dist/src/DbFileStorageDriver.js.map +1 -0
- package/dist/src/FileStorage.d.ts +70 -0
- package/dist/src/FileStorage.d.ts.map +1 -0
- package/dist/src/FileStorage.js +210 -0
- package/dist/src/FileStorage.js.map +1 -0
- package/dist/src/FileStorageDriver.d.ts +9 -0
- package/dist/src/FileStorageDriver.d.ts.map +1 -0
- package/dist/src/FileStorageDriver.js +3 -0
- package/dist/src/FileStorageDriver.js.map +1 -0
- package/dist/src/routes/getFile.d.ts +3 -0
- package/dist/src/routes/getFile.d.ts.map +1 -0
- package/dist/src/routes/getFile.js +86 -0
- package/dist/src/routes/getFile.js.map +1 -0
- package/dist/src/routes/getFileRoute.d.ts +5 -0
- package/dist/src/routes/getFileRoute.d.ts.map +1 -0
- package/dist/src/routes/getFileRoute.js +5 -0
- package/dist/src/routes/getFileRoute.js.map +1 -0
- package/dist/src/services/FileStorageService.d.ts +13 -0
- package/dist/src/services/FileStorageService.d.ts.map +1 -0
- package/dist/src/services/FileStorageService.js +6 -0
- package/dist/src/services/FileStorageService.js.map +1 -0
- package/dist/src/tables/FileDataTable.d.ts +23 -0
- package/dist/src/tables/FileDataTable.d.ts.map +1 -0
- package/dist/src/tables/FileDataTable.js +45 -0
- package/dist/src/tables/FileDataTable.js.map +1 -0
- package/dist/src/tables/FileTable.d.ts +26 -0
- package/dist/src/tables/FileTable.d.ts.map +1 -0
- package/dist/src/tables/FileTable.js +51 -0
- package/dist/src/tables/FileTable.js.map +1 -0
- package/dist/src/tables/tables.d.ts +8 -0
- package/dist/src/tables/tables.d.ts.map +1 -0
- package/dist/src/tables/tables.js +10 -0
- package/dist/src/tables/tables.js.map +1 -0
- package/generated/index.ts +35 -0
- package/index.ts +14 -0
- package/jest.config.js +9 -0
- package/package.json +48 -0
- package/src/DbFileStorageDriver.ts +67 -0
- package/src/FileStorage.ts +128 -0
- package/src/FileStorageDriver.ts +9 -0
- package/src/routes/getFile.ts +33 -0
- package/src/routes/getFileRoute.ts +1 -0
- package/src/services/FileStorageService.ts +14 -0
- package/src/tables/FileDataTable.ts +26 -0
- package/src/tables/FileTable.ts +32 -0
- package/src/tables/tables.ts +8 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,210 @@
|
|
|
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.FileStorage = exports.getFileStorage = void 0;
|
|
40
|
+
var user_1 = require("@proteinjs/user");
|
|
41
|
+
var tables_1 = require("./tables/tables");
|
|
42
|
+
var FileStorageService_1 = require("./services/FileStorageService");
|
|
43
|
+
var reflection_1 = require("@proteinjs/reflection");
|
|
44
|
+
var util_1 = require("@proteinjs/util");
|
|
45
|
+
var DbFileStorageDriver_1 = require("./DbFileStorageDriver");
|
|
46
|
+
/**
|
|
47
|
+
* A convenience factory function so code using this is portable (can be used in server or browser).
|
|
48
|
+
* @returns an instance of the `FileStorageService` when called from the browser, and an instance of `FileStorage` otherwise
|
|
49
|
+
* */
|
|
50
|
+
var getFileStorage = function () {
|
|
51
|
+
return typeof self === 'undefined' ? new FileStorage() : (0, FileStorageService_1.getFileStorageService)();
|
|
52
|
+
};
|
|
53
|
+
exports.getFileStorage = getFileStorage;
|
|
54
|
+
/**
|
|
55
|
+
* A simple api for file storage.
|
|
56
|
+
* File metadata is stored in the `FileTable`.
|
|
57
|
+
* File data is stored by the `FileStorageDriver`.
|
|
58
|
+
*/
|
|
59
|
+
var FileStorage = /** @class */ (function () {
|
|
60
|
+
function FileStorage(driver) {
|
|
61
|
+
this.logger = new util_1.Logger(this.constructor.name);
|
|
62
|
+
this.serviceMetadata = {
|
|
63
|
+
auth: {
|
|
64
|
+
allUsers: true,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
this.driver = driver ? driver : this.getDefaultDriver();
|
|
68
|
+
}
|
|
69
|
+
FileStorage.prototype.getDefaultDriver = function () {
|
|
70
|
+
if (!FileStorage.defaultDriver) {
|
|
71
|
+
var defaultDriverFactory = reflection_1.SourceRepository.get().object('@proteinjs/db-file/DefaultFileStorageDriverFactory');
|
|
72
|
+
if (defaultDriverFactory) {
|
|
73
|
+
FileStorage.defaultDriver = defaultDriverFactory.getDriver();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.logger.info("Defaulting to DbFileStorageDriver since no FileStorageDriver was provided");
|
|
77
|
+
FileStorage.defaultDriver = new DbFileStorageDriver_1.DbFileStorageDriver();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return FileStorage.defaultDriver;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Creates a new file record and its associated data chunks.
|
|
84
|
+
* @param fileMetaData - The file metadata (name, type, size).
|
|
85
|
+
* @param fileData - The file data as a string.
|
|
86
|
+
* @returns The created file record.
|
|
87
|
+
*/
|
|
88
|
+
FileStorage.prototype.createFile = function (fileMetaData, fileData) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var db, file;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
db = (0, user_1.getScopedDb)();
|
|
95
|
+
return [4 /*yield*/, db.insert(tables_1.tables.File, fileMetaData)];
|
|
96
|
+
case 1:
|
|
97
|
+
file = _a.sent();
|
|
98
|
+
return [4 /*yield*/, this.driver.createFile(file, fileData)];
|
|
99
|
+
case 2:
|
|
100
|
+
_a.sent();
|
|
101
|
+
return [2 /*return*/, file];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves the metadata of a given file.
|
|
108
|
+
* @param fileId - The `id` of the file.
|
|
109
|
+
* @returns The file metadata.
|
|
110
|
+
*/
|
|
111
|
+
FileStorage.prototype.getFile = function (fileId) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var db, file;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
db = (0, user_1.getScopedDb)();
|
|
118
|
+
return [4 /*yield*/, db.get(tables_1.tables.File, { id: fileId })];
|
|
119
|
+
case 1:
|
|
120
|
+
file = _a.sent();
|
|
121
|
+
return [2 /*return*/, file];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Retrieves the data chunks associated with a given file.
|
|
128
|
+
* @param fileId - The `id` of the file.
|
|
129
|
+
* @returns The file data as a single string.
|
|
130
|
+
*/
|
|
131
|
+
FileStorage.prototype.getFileData = function (fileId) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0: return [4 /*yield*/, this.driver.getFileData(fileId)];
|
|
136
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Updates the data chunks associated with a given file.
|
|
143
|
+
* @param fileId - The `id` of the file.
|
|
144
|
+
* @param data - The new data string to replace the existing data.
|
|
145
|
+
*/
|
|
146
|
+
FileStorage.prototype.updateFileData = function (fileId, data) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0: return [4 /*yield*/, this.driver.updateFileData(fileId, data)];
|
|
151
|
+
case 1:
|
|
152
|
+
_a.sent();
|
|
153
|
+
return [2 /*return*/];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Updates the metadata of a given file.
|
|
160
|
+
* @param file - The updated file to persist.
|
|
161
|
+
*/
|
|
162
|
+
FileStorage.prototype.updateFile = function (file) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
+
var db;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0:
|
|
168
|
+
db = (0, user_1.getScopedDb)();
|
|
169
|
+
return [4 /*yield*/, db.update(tables_1.tables.File, file)];
|
|
170
|
+
case 1:
|
|
171
|
+
_a.sent();
|
|
172
|
+
if (!this.driver.updateFile) return [3 /*break*/, 3];
|
|
173
|
+
return [4 /*yield*/, this.driver.updateFile(file)];
|
|
174
|
+
case 2:
|
|
175
|
+
_a.sent();
|
|
176
|
+
_a.label = 3;
|
|
177
|
+
case 3: return [2 /*return*/];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Deletes a file and its data.
|
|
184
|
+
* The file data is deleted by a cascade delete rule defined on the `FileTable`
|
|
185
|
+
* @param fileId - The `id` of the file to delete.
|
|
186
|
+
*/
|
|
187
|
+
FileStorage.prototype.deleteFile = function (fileId) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var db;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
db = (0, user_1.getScopedDb)();
|
|
194
|
+
if (!this.driver.deleteFile) return [3 /*break*/, 2];
|
|
195
|
+
return [4 /*yield*/, this.driver.deleteFile(fileId)];
|
|
196
|
+
case 1:
|
|
197
|
+
_a.sent();
|
|
198
|
+
_a.label = 2;
|
|
199
|
+
case 2: return [4 /*yield*/, db.delete(tables_1.tables.File, { id: fileId })];
|
|
200
|
+
case 3:
|
|
201
|
+
_a.sent();
|
|
202
|
+
return [2 /*return*/];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
return FileStorage;
|
|
208
|
+
}());
|
|
209
|
+
exports.FileStorage = FileStorage;
|
|
210
|
+
//# sourceMappingURL=FileStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorage.js","sourceRoot":"","sources":["../../src/FileStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAA4D;AAE5D,0CAAyC;AACzC,oEAA0F;AAE1F,oDAAmE;AACnE,wCAAyC;AACzC,6DAA4D;AAE5D;;;KAGK;AACE,IAAM,cAAc,GAAG;IAC5B,OAAA,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,E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,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAA;;wBAA5C,SAA4C,CAAC;;;;;KAC9C;IACH,kBAAC;AAAD,CAAC,AAnGD,IAmGC;AAnGY,kCAAW"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { File } from './tables/FileTable';
|
|
2
|
+
export interface FileStorageDriver {
|
|
3
|
+
createFile(file: File, fileData: string): Promise<void>;
|
|
4
|
+
getFileData(fileId: string): Promise<string>;
|
|
5
|
+
updateFileData(fileId: string, data: string): Promise<void>;
|
|
6
|
+
updateFile?(file: File): Promise<void>;
|
|
7
|
+
deleteFile?(fileId: string): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=FileStorageDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorageDriver.d.ts","sourceRoot":"","sources":["../../src/FileStorageDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,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,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorageDriver.js","sourceRoot":"","sources":["../../src/FileStorageDriver.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../src/routes/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI9C,eAAO,MAAM,OAAO,EAAE,KA4BrB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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.getFile = void 0;
|
|
40
|
+
var FileStorage_1 = require("../FileStorage");
|
|
41
|
+
var user_1 = require("@proteinjs/user");
|
|
42
|
+
exports.getFile = {
|
|
43
|
+
path: '/file/:id',
|
|
44
|
+
method: 'get',
|
|
45
|
+
onRequest: function (request, response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var fileId, fileStorage, file, fileDataBase64, safeFilename, fileData, error_1;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
if (!user_1.UserAuth.isLoggedIn()) {
|
|
51
|
+
response.status(401).send('User not logged in');
|
|
52
|
+
return [2 /*return*/];
|
|
53
|
+
}
|
|
54
|
+
fileId = request.params.id;
|
|
55
|
+
fileStorage = (0, FileStorage_1.getFileStorage)();
|
|
56
|
+
_a.label = 1;
|
|
57
|
+
case 1:
|
|
58
|
+
_a.trys.push([1, 4, , 5]);
|
|
59
|
+
return [4 /*yield*/, fileStorage.getFile(fileId)];
|
|
60
|
+
case 2:
|
|
61
|
+
file = _a.sent();
|
|
62
|
+
return [4 /*yield*/, fileStorage.getFileData(fileId)];
|
|
63
|
+
case 3:
|
|
64
|
+
fileDataBase64 = _a.sent();
|
|
65
|
+
if (!file || !fileDataBase64) {
|
|
66
|
+
response.status(404).send('File not found');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
safeFilename = encodeURIComponent(file.name);
|
|
70
|
+
fileData = file.type.startsWith('image/') ? Buffer.from(fileDataBase64, 'base64') : fileDataBase64;
|
|
71
|
+
response.setHeader('Content-Disposition', "inline; filename=\"".concat(safeFilename, "\""));
|
|
72
|
+
response.setHeader('Content-Type', file.type);
|
|
73
|
+
response.send(fileData);
|
|
74
|
+
}
|
|
75
|
+
return [3 /*break*/, 5];
|
|
76
|
+
case 4:
|
|
77
|
+
error_1 = _a.sent();
|
|
78
|
+
console.error("Error fetching file (".concat(fileId, "):"), error_1);
|
|
79
|
+
response.status(500).send('Internal Server Error');
|
|
80
|
+
return [3 /*break*/, 5];
|
|
81
|
+
case 5: return [2 /*return*/];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}); },
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=getFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFile.js","sourceRoot":"","sources":["../../../src/routes/getFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAgD;AAChD,wCAA2C;AAE9B,QAAA,OAAO,GAAU;IAC5B,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,UAAO,OAAO,EAAE,QAAQ;;;;;oBACjC,IAAI,CAAC,eAAQ,CAAC,UAAU,EAAE,EAAE;wBAC1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ources":["../../../src/routes/getFileRoute.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;mBAAoB,MAAM;;CAAuC,CAAC"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Service } from '@proteinjs/service';
|
|
2
|
+
import { ScopedRecord } from '@proteinjs/user';
|
|
3
|
+
import { File } from '../tables/FileTable';
|
|
4
|
+
export declare const getFileStorageService: () => FileStorageService;
|
|
5
|
+
export interface FileStorageService extends Service {
|
|
6
|
+
createFile(fileMetaData: Omit<File, keyof ScopedRecord>, fileData: string): Promise<File>;
|
|
7
|
+
getFile(fileId: string): Promise<File>;
|
|
8
|
+
getFileData(fileId: string): Promise<string>;
|
|
9
|
+
updateFileData(fileId: string, data: string): Promise<void>;
|
|
10
|
+
updateFile(file: Omit<File, keyof ScopedRecord>): Promise<void>;
|
|
11
|
+
deleteFile(fileId: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=FileStorageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorageService.d.ts","sourceRoot":"","sources":["../../../src/services/FileStorageService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,eAAO,MAAM,qBAAqB,0BAA8E,CAAC;AAEjH,MAAM,WAAW,kBAAmB,SAAQ,OAAO;IACjD,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,YAAY,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1F,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,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,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFileStorageService = void 0;
|
|
4
|
+
var service_1 = require("@proteinjs/service");
|
|
5
|
+
exports.getFileStorageService = (0, service_1.serviceFactory)('@proteinjs/db-file/FileStorageService');
|
|
6
|
+
//# sourceMappingURL=FileStorageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorageService.js","sourceRoot":"","sources":["../../../src/services/FileStorageService.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;AAIhD,QAAA,qBAAqB,GAAG,IAAA,wBAAc,EAAqB,uCAAuC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Table, Reference } from '@proteinjs/db';
|
|
2
|
+
import { ScopedRecord } from '@proteinjs/user';
|
|
3
|
+
import { File } from './FileTable';
|
|
4
|
+
export interface FileData extends ScopedRecord {
|
|
5
|
+
file: Reference<File>;
|
|
6
|
+
order: number;
|
|
7
|
+
data: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class FileDataTable extends Table<FileData> {
|
|
10
|
+
name: string;
|
|
11
|
+
auth: Table<FileData>['auth'];
|
|
12
|
+
columns: {
|
|
13
|
+
scope: import("@proteinjs/db").Column<string, any>;
|
|
14
|
+
id: import("@proteinjs/db").Column<string, any>;
|
|
15
|
+
created: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
16
|
+
updated: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
17
|
+
} & {} & {
|
|
18
|
+
file: import("@proteinjs/db").Column<Reference<File>, any>;
|
|
19
|
+
order: import("@proteinjs/db").Column<number, any>;
|
|
20
|
+
data: import("@proteinjs/db").Column<string, any>;
|
|
21
|
+
} & {};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=FileDataTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDataTable.d.ts","sourceRoot":"","sources":["../../../src/tables/FileDataTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAgD,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,YAAY,EAA2B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,IAAI,EAAa,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,QAAS,SAAQ,YAAY;IAC5C,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,aAAc,SAAQ,KAAK,CAAC,QAAQ,CAAC;IACzC,IAAI,SAAe;IACnB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAOlC;IACK,OAAO;;;;;;;;;WAIX;CACJ"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.FileDataTable = void 0;
|
|
19
|
+
var db_1 = require("@proteinjs/db");
|
|
20
|
+
var user_1 = require("@proteinjs/user");
|
|
21
|
+
var FileTable_1 = require("./FileTable");
|
|
22
|
+
var FileDataTable = /** @class */ (function (_super) {
|
|
23
|
+
__extends(FileDataTable, _super);
|
|
24
|
+
function FileDataTable() {
|
|
25
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
26
|
+
_this.name = 'file_data';
|
|
27
|
+
_this.auth = {
|
|
28
|
+
db: {
|
|
29
|
+
all: 'authenticated',
|
|
30
|
+
},
|
|
31
|
+
service: {
|
|
32
|
+
all: 'authenticated',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
_this.columns = (0, user_1.withScopedRecordColumns)({
|
|
36
|
+
file: new db_1.ReferenceColumn('file', new FileTable_1.FileTable().name, false),
|
|
37
|
+
order: new db_1.IntegerColumn('order'),
|
|
38
|
+
data: new db_1.StringColumn('data', {}, 'MAX'),
|
|
39
|
+
});
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
return FileDataTable;
|
|
43
|
+
}(db_1.Table));
|
|
44
|
+
exports.FileDataTable = FileDataTable;
|
|
45
|
+
//# sourceMappingURL=FileDataTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDataTable.js","sourceRoot":"","sources":["../../../src/tables/FileDataTable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oCAA+F;AAC/F,wCAAwE;AACxE,yCAA8C;AAQ9C;IAAmC,iCAAe;IAAlD;QAAA,qEAeC;QAdQ,UAAI,GAAG,WAAW,CAAC;QACnB,UAAI,GAA4B;YACrC,EAAE,EAAE;gBACF,GAAG,EAAE,eAAe;aACrB;YACD,OAAO,EAAE;gBACP,GAAG,EAAE,eAAe;aACrB;SACF,CAAC;QACK,aAAO,GAAG,IAAA,8BAAuB,EAAW;YACjD,IAAI,EAAE,IAAI,oBAAe,CAAO,MAAM,EAAE,IAAI,qBAAS,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;YACpE,KAAK,EAAE,IAAI,kBAAa,CAAC,OAAO,CAAC;YACjC,IAAI,EAAE,IAAI,iBAAY,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,CAAC;SAC1C,CAAC,CAAC;;IACL,CAAC;IAAD,oBAAC;AAAD,CAAC,AAfD,CAAmC,UAAK,GAevC;AAfY,sCAAa"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Table } from '@proteinjs/db';
|
|
2
|
+
import { ScopedRecord } from '@proteinjs/user';
|
|
3
|
+
export interface File extends ScopedRecord {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
size: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class FileTable extends Table<File> {
|
|
9
|
+
name: string;
|
|
10
|
+
auth: Table<File>['auth'];
|
|
11
|
+
columns: {
|
|
12
|
+
scope: import("@proteinjs/db").Column<string, any>;
|
|
13
|
+
id: import("@proteinjs/db").Column<string, any>;
|
|
14
|
+
created: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
15
|
+
updated: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
16
|
+
} & {} & {
|
|
17
|
+
name: import("@proteinjs/db").Column<string, any>;
|
|
18
|
+
type: import("@proteinjs/db").Column<string, any>;
|
|
19
|
+
size: import("@proteinjs/db").Column<number, any>;
|
|
20
|
+
} & {};
|
|
21
|
+
cascadeDeleteReferences: () => {
|
|
22
|
+
table: string;
|
|
23
|
+
referenceColumn: string;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=FileTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileTable.d.ts","sourceRoot":"","sources":["../../../src/tables/FileTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA+B,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,YAAY,EAA2B,MAAM,iBAAiB,CAAC;AAGxE,MAAM,WAAW,IAAK,SAAQ,YAAY;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,SAAU,SAAQ,KAAK,CAAC,IAAI,CAAC;IACjC,IAAI,SAAU;IACd,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAO9B;IACK,OAAO;;;;;;;;;WAIX;IACI,uBAAuB;;;QAK5B;CACH"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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.FileTable = void 0;
|
|
19
|
+
var db_1 = require("@proteinjs/db");
|
|
20
|
+
var user_1 = require("@proteinjs/user");
|
|
21
|
+
var FileDataTable_1 = require("./FileDataTable");
|
|
22
|
+
var FileTable = /** @class */ (function (_super) {
|
|
23
|
+
__extends(FileTable, _super);
|
|
24
|
+
function FileTable() {
|
|
25
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
26
|
+
_this.name = 'file';
|
|
27
|
+
_this.auth = {
|
|
28
|
+
db: {
|
|
29
|
+
all: 'authenticated',
|
|
30
|
+
},
|
|
31
|
+
service: {
|
|
32
|
+
all: 'authenticated',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
_this.columns = (0, user_1.withScopedRecordColumns)({
|
|
36
|
+
name: new db_1.StringColumn('name'),
|
|
37
|
+
type: new db_1.StringColumn('type'),
|
|
38
|
+
size: new db_1.IntegerColumn('size'),
|
|
39
|
+
});
|
|
40
|
+
_this.cascadeDeleteReferences = function () { return [
|
|
41
|
+
{
|
|
42
|
+
table: new FileDataTable_1.FileDataTable().name,
|
|
43
|
+
referenceColumn: new FileDataTable_1.FileDataTable().columns.file.name,
|
|
44
|
+
},
|
|
45
|
+
]; };
|
|
46
|
+
return _this;
|
|
47
|
+
}
|
|
48
|
+
return FileTable;
|
|
49
|
+
}(db_1.Table));
|
|
50
|
+
exports.FileTable = FileTable;
|
|
51
|
+
//# sourceMappingURL=FileTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileTable.js","sourceRoot":"","sources":["../../../src/tables/FileTable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oCAAmE;AACnE,wCAAwE;AACxE,iDAAgD;AAQhD;IAA+B,6BAAW;IAA1C;QAAA,qEAqBC;QApBQ,UAAI,GAAG,MAAM,CAAC;QACd,UAAI,GAAwB;YACjC,EAAE,EAAE;gBACF,GAAG,EAAE,eAAe;aACrB;YACD,OAAO,EAAE;gBACP,GAAG,EAAE,eAAe;aACrB;SACF,CAAC;QACK,aAAO,GAAG,IAAA,8BAAuB,EAAO;YAC7C,IAAI,EAAE,IAAI,iBAAY,CAAC,MAAM,CAAC;YAC9B,IAAI,EAAE,IAAI,iBAAY,CAAC,MAAM,CAAC;YAC9B,IAAI,EAAE,IAAI,kBAAa,CAAC,MAAM,CAAC;SAChC,CAAC,CAAC;QACI,6BAAuB,GAAG,cAAM,OAAA;YACrC;gBACE,KAAK,EAAE,IAAI,6BAAa,EAAE,CAAC,IAAI;gBAC/B,eAAe,EAAE,IAAI,6BAAa,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;aACvD;SACF,EALsC,CAKtC,CAAC;;IACJ,CAAC;IAAD,gBAAC;AAAD,CAAC,AArBD,CAA+B,UAAK,GAqBnC;AArBY,8BAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../src/tables/tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAa,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAiB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE1D,eAAO,MAAM,MAAM;;;CAGlB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tables = void 0;
|
|
4
|
+
var FileTable_1 = require("./FileTable");
|
|
5
|
+
var FileDataTable_1 = require("./FileDataTable");
|
|
6
|
+
exports.tables = {
|
|
7
|
+
File: new FileTable_1.FileTable(),
|
|
8
|
+
FileData: new FileDataTable_1.FileDataTable(),
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/tables/tables.ts"],"names":[],"mappings":";;;AACA,yCAA8C;AAC9C,iDAA0D;AAE7C,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,IAAI,qBAAS,EAAiB;IACpC,QAAQ,EAAE,IAAI,6BAAa,EAAqB;CACjD,CAAC"}
|