prostgles-server 2.0.188 → 2.0.191
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/dist/DboBuilder/insertDataParse.d.ts.map +1 -1
- package/dist/DboBuilder/insertDataParse.js +14 -4
- package/dist/DboBuilder/insertDataParse.js.map +1 -1
- package/dist/DboBuilder.d.ts +5 -3
- package/dist/DboBuilder.d.ts.map +1 -1
- package/dist/DboBuilder.js +67 -161
- package/dist/DboBuilder.js.map +1 -1
- package/dist/FileManager.d.ts +20 -72
- package/dist/FileManager.d.ts.map +1 -1
- package/dist/FileManager.js +232 -164
- package/dist/FileManager.js.map +1 -1
- package/dist/Prostgles.d.ts +13 -2
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js.map +1 -1
- package/dist/TableConfig.d.ts +1 -2
- package/dist/TableConfig.d.ts.map +1 -1
- package/dist/TableConfig.js.map +1 -1
- package/lib/DboBuilder/insertDataParse.d.ts.map +1 -1
- package/lib/DboBuilder/insertDataParse.js +14 -4
- package/lib/DboBuilder/insertDataParse.ts +14 -4
- package/lib/DboBuilder.d.ts +5 -3
- package/lib/DboBuilder.d.ts.map +1 -1
- package/lib/DboBuilder.js +67 -161
- package/lib/DboBuilder.ts +84 -191
- package/lib/FileManager.d.ts +19 -71
- package/lib/FileManager.d.ts.map +1 -1
- package/lib/FileManager.js +232 -164
- package/lib/FileManager.ts +272 -191
- package/lib/Prostgles.d.ts +13 -2
- package/lib/Prostgles.d.ts.map +1 -1
- package/lib/Prostgles.ts +2 -2
- package/lib/TableConfig.d.ts +1 -2
- package/lib/TableConfig.d.ts.map +1 -1
- package/lib/TableConfig.ts +2 -4
- package/lib/fileType/core.js +1527 -0
- package/lib/fileType/supported.js +278 -0
- package/package.json +5 -5
- package/tests/client/PID.txt +1 -1
- package/tests/server/DBoGenerated.d.ts +1 -1
- package/tests/server/package-lock.json +9 -9
package/lib/FileManager.ts
CHANGED
|
@@ -3,12 +3,11 @@ import { S3 } from 'aws-sdk';
|
|
|
3
3
|
import { ManagedUpload } from 'aws-sdk/clients/s3';
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
|
|
6
|
-
import * as FileType from "file-type";
|
|
7
6
|
import * as sharp from "sharp";
|
|
8
7
|
|
|
9
8
|
import { DB, DBHandlerServer, Prostgles } from './Prostgles';
|
|
10
|
-
import { asName, getKeys } from 'prostgles-types';
|
|
11
|
-
import { TableHandler } from './DboBuilder';
|
|
9
|
+
import { ALLOWED_CONTENT_TYPE, ALLOWED_EXTENSION, asName, CONTENT_TYPE_TO_EXT, getKeys, isObject, ValidatedColumnInfo } from 'prostgles-types';
|
|
10
|
+
import { TableHandler, ViewHandler } from './DboBuilder';
|
|
12
11
|
|
|
13
12
|
const HOUR = 3600 * 1000;
|
|
14
13
|
|
|
@@ -89,7 +88,7 @@ export default class FileManager {
|
|
|
89
88
|
this.imageOptions = imageOptions;
|
|
90
89
|
|
|
91
90
|
if("region" in config){
|
|
92
|
-
const { region,accessKeyId, secretAccessKey } = config;
|
|
91
|
+
const { region, accessKeyId, secretAccessKey } = config;
|
|
93
92
|
this.s3Client = new S3({
|
|
94
93
|
region,
|
|
95
94
|
credentials: { accessKeyId, secretAccessKey },
|
|
@@ -97,81 +96,136 @@ export default class FileManager {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
async
|
|
101
|
-
file: Buffer |
|
|
102
|
-
fileName: string,
|
|
103
|
-
allowedExtensions?: Array<ALLOWED_EXTENSION>,
|
|
104
|
-
dissallowedExtensions?: Array<ALLOWED_EXTENSION>,
|
|
105
|
-
onlyFromName = true
|
|
106
|
-
): Promise<{
|
|
107
|
-
mime: string;
|
|
108
|
-
ext: string | ALLOWED_EXTENSION;
|
|
99
|
+
async parseFile(args: {
|
|
100
|
+
file: Buffer | string;
|
|
109
101
|
fileName: string;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
mime = getKeys(CONTENT_TYPE_TO_EXT).find(k => (CONTENT_TYPE_TO_EXT[k] as readonly string[]).includes(nameExt));
|
|
116
|
-
|
|
117
|
-
let type = {
|
|
118
|
-
fileName,
|
|
119
|
-
mime,
|
|
120
|
-
ext: nameExt,
|
|
121
|
-
}
|
|
102
|
+
colName?: string;
|
|
103
|
+
tableName?: string;
|
|
104
|
+
}): Promise<{
|
|
105
|
+
mime: string | ALLOWED_CONTENT_TYPE;
|
|
106
|
+
ext: string | ALLOWED_EXTENSION;
|
|
122
107
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
108
|
+
/** File name is not returned because we fail if the extensions do not match */
|
|
109
|
+
// fileName: string;
|
|
110
|
+
}> {
|
|
111
|
+
const { file, fileName, tableName, colName } = args;
|
|
112
|
+
const config = this.prostgles?.opts.fileTable;
|
|
113
|
+
if(!config) throw new Error("File table config missing");
|
|
114
|
+
|
|
115
|
+
const buffer = typeof file === "string"? Buffer.from(file, 'utf8') : file;
|
|
116
|
+
const mime = await getFileType(buffer, fileName);
|
|
117
|
+
|
|
118
|
+
if(tableName && colName){
|
|
119
|
+
const tableConfig = config.referencedTables?.[tableName];
|
|
120
|
+
|
|
121
|
+
if(tableConfig && isObject(tableConfig) && tableConfig.referenceColumns[colName]){
|
|
122
|
+
const colConfig = tableConfig.referenceColumns[colName];
|
|
123
|
+
if(colConfig.maxFileSizeMB){
|
|
124
|
+
const actualBufferSize = Buffer.byteLength(buffer);
|
|
125
|
+
if((actualBufferSize/1e6) > colConfig.maxFileSizeMB){
|
|
126
|
+
throw new Error(`Provided file is larger than the ${colConfig.maxFileSizeMB}MB limit`);
|
|
127
|
+
}
|
|
136
128
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
|
|
130
|
+
if("acceptedContent" in colConfig && colConfig.acceptedContent){
|
|
131
|
+
const CONTENTS = [
|
|
132
|
+
"image",
|
|
133
|
+
"audio",
|
|
134
|
+
"video",
|
|
135
|
+
"text",
|
|
136
|
+
"application",
|
|
137
|
+
];
|
|
138
|
+
const allowedContent = ViewHandler._parseFieldFilter(colConfig.acceptedContent, false, CONTENTS);
|
|
139
|
+
if(!allowedContent.some(c => mime.mime.startsWith(c))){
|
|
140
|
+
throw new Error(`Dissallowed content type provided: ${mime.mime.split("/")[0]}. Allowed content types: ${allowedContent} `)
|
|
141
|
+
}
|
|
142
|
+
} else if("acceptedContentType" in colConfig && colConfig.acceptedContentType){
|
|
143
|
+
const allowedContentTypes = ViewHandler._parseFieldFilter(colConfig.acceptedContentType, false, getKeys(CONTENT_TYPE_TO_EXT));
|
|
144
|
+
|
|
145
|
+
if(!allowedContentTypes.some(c => c === mime.mime)){
|
|
146
|
+
throw new Error(`Dissallowed MIME provided: ${mime.mime}. Allowed MIME values: ${allowedContentTypes} `)
|
|
147
|
+
}
|
|
148
|
+
} else if("acceptedFileTypes" in colConfig && colConfig.acceptedFileTypes){
|
|
149
|
+
const allowedExtensions = ViewHandler._parseFieldFilter(colConfig.acceptedFileTypes, false, Object.values(CONTENT_TYPE_TO_EXT).flat());
|
|
150
|
+
|
|
151
|
+
if(!allowedExtensions.some(c => c === mime.ext)){
|
|
152
|
+
throw new Error(`Dissallowed extension provided: ${mime.ext}. Allowed extension values: ${allowedExtensions} `)
|
|
153
|
+
}
|
|
142
154
|
}
|
|
143
|
-
}
|
|
144
|
-
throw "Unexpected file. Expecting: Buffer | String";
|
|
145
|
-
}
|
|
155
|
+
}
|
|
146
156
|
}
|
|
147
157
|
|
|
148
|
-
|
|
149
|
-
allowedExtensions &&
|
|
150
|
-
!allowedExtensions.map(v => v.toLowerCase())?.includes(type.ext)
|
|
151
|
-
){
|
|
152
|
-
throw fileName + " -> File type ( " + type.ext + " ) not allowed. Expecting one of: " + allowedExtensions.map(v => v.toLowerCase()).join(", ");
|
|
153
|
-
|
|
154
|
-
} else if(
|
|
155
|
-
dissallowedExtensions &&
|
|
156
|
-
dissallowedExtensions.map(v => v.toLowerCase())?.includes(type.ext)
|
|
157
|
-
){
|
|
158
|
-
throw fileName + " -> File type ( " + type.ext + " ) not allowed";
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if(!onlyFromName){
|
|
163
|
-
let { ext } = type;
|
|
164
|
-
if(nameExt !== ext) fileName = nameParts.slice(0, -1).join('') + "." + ext;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const res = {
|
|
168
|
-
...type,
|
|
169
|
-
fileName
|
|
170
|
-
}
|
|
171
|
-
if(!res.mime) throw "Could not find mime"
|
|
172
|
-
return res as any;
|
|
158
|
+
return mime;
|
|
173
159
|
}
|
|
174
160
|
|
|
161
|
+
// private async getMIME(
|
|
162
|
+
// file: Buffer | string,
|
|
163
|
+
// fileName: string,
|
|
164
|
+
// allowedExtensions?: Array<ALLOWED_EXTENSION>,
|
|
165
|
+
// dissallowedExtensions?: Array<ALLOWED_EXTENSION>,
|
|
166
|
+
// onlyFromName = true
|
|
167
|
+
// ): Promise<{
|
|
168
|
+
// mime: string;
|
|
169
|
+
// ext: string | ALLOWED_EXTENSION;
|
|
170
|
+
// fileName: string;
|
|
171
|
+
// }> {
|
|
172
|
+
|
|
173
|
+
// const nameParts = fileName.split(".");
|
|
174
|
+
|
|
175
|
+
// const nameExt = nameParts[nameParts.length - 1].toLowerCase(),
|
|
176
|
+
// mime = getKeys(CONTENT_TYPE_TO_EXT).find(k => (CONTENT_TYPE_TO_EXT[k] as readonly string[]).includes(nameExt));
|
|
177
|
+
|
|
178
|
+
// let type = {
|
|
179
|
+
// fileName,
|
|
180
|
+
// mime,
|
|
181
|
+
// ext: nameExt,
|
|
182
|
+
// }
|
|
183
|
+
|
|
184
|
+
// if(onlyFromName && !mime) throw `Invalid file extension: content_type could not be found for extension(${nameExt})`;
|
|
185
|
+
|
|
186
|
+
// if(!mime){
|
|
187
|
+
// /* Set correct/missing extension */
|
|
188
|
+
// if(["xml", "txt", "csv", "tsv"].includes(nameExt)){
|
|
189
|
+
// type = { ...type, mime: ("text/" + nameExt) as any, ext: nameExt };
|
|
190
|
+
// } else if(["svg"].includes(nameExt)){
|
|
191
|
+
// type = { ...type, mime: "image/svg+xml", ext: nameExt };
|
|
192
|
+
// } else {
|
|
193
|
+
// const res = await getFileTypeFromBuffer(file);
|
|
194
|
+
|
|
195
|
+
// type = {
|
|
196
|
+
// ...(res as any),
|
|
197
|
+
// fileName,
|
|
198
|
+
// }
|
|
199
|
+
// }
|
|
200
|
+
// }
|
|
201
|
+
|
|
202
|
+
// if(
|
|
203
|
+
// allowedExtensions &&
|
|
204
|
+
// !allowedExtensions.map(v => v.toLowerCase())?.includes(type.ext)
|
|
205
|
+
// ){
|
|
206
|
+
// throw fileName + " -> File type ( " + type.ext + " ) not allowed. Expecting one of: " + allowedExtensions.map(v => v.toLowerCase()).join(", ");
|
|
207
|
+
|
|
208
|
+
// } else if(
|
|
209
|
+
// dissallowedExtensions &&
|
|
210
|
+
// dissallowedExtensions.map(v => v.toLowerCase())?.includes(type.ext)
|
|
211
|
+
// ){
|
|
212
|
+
// throw fileName + " -> File type ( " + type.ext + " ) not allowed";
|
|
213
|
+
|
|
214
|
+
// }
|
|
215
|
+
|
|
216
|
+
// if(!onlyFromName){
|
|
217
|
+
// let { ext } = type;
|
|
218
|
+
// if(nameExt !== ext) fileName = nameParts.slice(0, -1).join('') + "." + ext;
|
|
219
|
+
// }
|
|
220
|
+
|
|
221
|
+
// const res = {
|
|
222
|
+
// ...type,
|
|
223
|
+
// fileName
|
|
224
|
+
// }
|
|
225
|
+
// if(!res.mime) throw "Could not find mime"
|
|
226
|
+
// return res as any;
|
|
227
|
+
// }
|
|
228
|
+
|
|
175
229
|
// async getUploadURL(fileName: string): Promise<string> {
|
|
176
230
|
// const thisHour = new Date();
|
|
177
231
|
// thisHour.setMilliseconds(0);
|
|
@@ -317,6 +371,19 @@ export default class FileManager {
|
|
|
317
371
|
|
|
318
372
|
private parseSQLIdentifier = async (name: string ) => asSQLIdentifier(name, this.prostgles!.db!);// this.prostgles.dbo.sql<"value">("select format('%I', $1)", [name], { returnType: "value" } )
|
|
319
373
|
|
|
374
|
+
getColInfo = (args: { tableName: string; colName: string }): ValidatedColumnInfo["file"] | undefined => {
|
|
375
|
+
const { colName, tableName } = args;
|
|
376
|
+
const tableConfig = this.prostgles?.opts.fileTable?.referencedTables?.[tableName];
|
|
377
|
+
const isReferencingFileTable = this.dbo[tableName]?.columns?.some(c => c.name === colName && c.references && c.references?.ftable === this.tableName);
|
|
378
|
+
if(isReferencingFileTable){
|
|
379
|
+
if(tableConfig && typeof tableConfig !== "string"){
|
|
380
|
+
return tableConfig.referenceColumns[colName];
|
|
381
|
+
}
|
|
382
|
+
return { acceptedContent: "*" };
|
|
383
|
+
}
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
|
|
320
387
|
init = async (prg: Prostgles) => {
|
|
321
388
|
this.prostgles = prg;
|
|
322
389
|
|
|
@@ -361,64 +428,103 @@ export default class FileManager {
|
|
|
361
428
|
/**
|
|
362
429
|
* 2. Create media lookup tables
|
|
363
430
|
*/
|
|
364
|
-
await Promise.all(
|
|
365
|
-
if(!this.dbo[refTable]) throw `Referenced table (${refTable}) from fileTable.referencedTables
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
await Promise.all(badCols.map(async badCol => {
|
|
393
|
-
console.error(
|
|
394
|
-
`Prostgles: media ${lookupTableName} joining table has lost a reference constraint for column ${badCol.name}.` +
|
|
395
|
-
` This may have been caused by a DROP TABLE ... CASCADE.`
|
|
396
|
-
);
|
|
397
|
-
let q = `
|
|
398
|
-
ALTER TABLE ${asName(lookupTableName)}
|
|
399
|
-
ADD CONSTRAINT ${(lookupTableName + "_" + badCol.name + "_r")} FOREIGN KEY (${badCol.name})
|
|
400
|
-
`;
|
|
401
|
-
console.log("Trying to add the missing constraint back");
|
|
402
|
-
if(badCol.name === "foreign_id"){
|
|
403
|
-
q += `REFERENCES ${asName(refTable)}(${asName(pkField.name)}) `;
|
|
404
|
-
} else if(badCol.name === "media_id"){
|
|
405
|
-
q += `REFERENCES ${asName(tableName)}(id) `;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if(q){
|
|
409
|
-
|
|
431
|
+
await Promise.all(getKeys(referencedTables).map(async refTable => {
|
|
432
|
+
if(!this.dbo[refTable]) throw `Referenced table (${refTable}) from fileTable.referencedTables prostgles init config is missing`;
|
|
433
|
+
const cols = await (this.dbo[refTable] as unknown as TableHandler).getColumns();
|
|
434
|
+
|
|
435
|
+
const tableConfig = referencedTables[refTable];
|
|
436
|
+
if(typeof tableConfig !== "string"){
|
|
437
|
+
|
|
438
|
+
for await (const colName of getKeys(tableConfig.referenceColumns)){
|
|
439
|
+
|
|
440
|
+
const existingCol = cols.find(c => c.name === colName);
|
|
441
|
+
if(existingCol){
|
|
442
|
+
if(existingCol.references?.ftable === tableName){
|
|
443
|
+
// All ok
|
|
444
|
+
} else {
|
|
445
|
+
if(existingCol.udt_name === "uuid"){
|
|
446
|
+
try {
|
|
447
|
+
const query = `ALTER TABLE ${asName(tableName)} ADD CONSTRAINT FOREIGN KEY (${asName(colName)}) REFERENCES ${asName(tableName)} (id);`;
|
|
448
|
+
console.log(`Referenced file column ${refTable} (${colName}) exists but is not referencing file table. Trying to add REFERENCE constraing...\n${query}`);
|
|
449
|
+
await this.db.any(query);
|
|
450
|
+
console.log("SUCCESS: " + query);
|
|
451
|
+
} catch(e){
|
|
452
|
+
throw new Error(`Could not add constraing. Err: ${e instanceof Error? e.message : JSON.stringify(e)}`)
|
|
453
|
+
}
|
|
454
|
+
} else {
|
|
455
|
+
throw new Error(`Referenced file column ${refTable} (${colName}) exists but is not of required type (UUID). Choose a different column name or ALTER the existing column to match the type and the data found in file table ${tableName}(id)`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
} else {
|
|
410
459
|
try {
|
|
411
|
-
|
|
412
|
-
console.log(
|
|
413
|
-
|
|
460
|
+
const query = `ALTER TABLE ${asName(tableName)} ADD COLUMN ${asName(colName)} UUID REFERENCES ${asName(tableName)} (id);`
|
|
461
|
+
console.log(`Creating referenced file column ${refTable} (${colName})...\n${query}`);
|
|
462
|
+
await this.db.any(query);
|
|
463
|
+
console.log("SUCCESS: " + query);
|
|
414
464
|
} catch(e){
|
|
415
|
-
|
|
465
|
+
throw new Error(`FAILED. Err: ${e instanceof Error? e.message : JSON.stringify(e)}`)
|
|
416
466
|
}
|
|
417
467
|
}
|
|
468
|
+
|
|
469
|
+
}
|
|
470
|
+
} else {
|
|
418
471
|
|
|
419
|
-
})
|
|
472
|
+
const lookupTableName = await this.parseSQLIdentifier(`prostgles_lookup_${tableName}_${refTable}`);
|
|
473
|
+
const pKeyFields = cols.filter(f => f.is_pkey);
|
|
474
|
+
|
|
475
|
+
if(pKeyFields.length !== 1) throw `Could not make link table for ${refTable}. ${pKeyFields} must have exactly one primary key column. Current pkeys: ${pKeyFields.map(f => f.name)}`;
|
|
476
|
+
|
|
477
|
+
const pkField = pKeyFields[0];
|
|
478
|
+
const refType = referencedTables[refTable];
|
|
479
|
+
|
|
480
|
+
if(!this.dbo[lookupTableName]){
|
|
481
|
+
// if(!(await dbo[lookupTableName].count())) await db.any(`DROP TABLE IF EXISTS ${lookupTableName};`);
|
|
482
|
+
const action = ` (${tableName} <-> ${refTable}) join table ${lookupTableName}`; // PRIMARY KEY
|
|
483
|
+
const query = `
|
|
484
|
+
CREATE TABLE ${lookupTableName} (
|
|
485
|
+
foreign_id ${pkField.udt_name} ${refType === "one"? " PRIMARY KEY " : ""} REFERENCES ${asName(refTable)}(${asName(pkField.name)}),
|
|
486
|
+
media_id UUID NOT NULL REFERENCES ${asName(tableName)}(id)
|
|
487
|
+
)
|
|
488
|
+
`;
|
|
489
|
+
console.log(`Creating ${action} ...`, lookupTableName);
|
|
490
|
+
await this.db.any(query);
|
|
491
|
+
console.log(`Created ${action}`);
|
|
492
|
+
|
|
493
|
+
} else {
|
|
494
|
+
const cols = await this.dbo[lookupTableName].getColumns!();
|
|
495
|
+
const badCols = cols.filter(c => !c.references);
|
|
496
|
+
await Promise.all(badCols.map(async badCol => {
|
|
497
|
+
console.error(
|
|
498
|
+
`Prostgles: media ${lookupTableName} joining table has lost a reference constraint for column ${badCol.name}.` +
|
|
499
|
+
` This may have been caused by a DROP TABLE ... CASCADE.`
|
|
500
|
+
);
|
|
501
|
+
let q = `
|
|
502
|
+
ALTER TABLE ${asName(lookupTableName)}
|
|
503
|
+
ADD CONSTRAINT ${(lookupTableName + "_" + badCol.name + "_r")} FOREIGN KEY (${badCol.name})
|
|
504
|
+
`;
|
|
505
|
+
console.log("Trying to add the missing constraint back");
|
|
506
|
+
if(badCol.name === "foreign_id"){
|
|
507
|
+
q += `REFERENCES ${asName(refTable)}(${asName(pkField.name)}) `;
|
|
508
|
+
} else if(badCol.name === "media_id"){
|
|
509
|
+
q += `REFERENCES ${asName(tableName)}(id) `;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
if(q){
|
|
513
|
+
|
|
514
|
+
try {
|
|
515
|
+
await this.db.any(q)
|
|
516
|
+
console.log("Added missing constraint back");
|
|
517
|
+
|
|
518
|
+
} catch(e){
|
|
519
|
+
console.error("Failed to add missing constraint", e)
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
}));
|
|
524
|
+
}
|
|
420
525
|
}
|
|
421
526
|
|
|
527
|
+
|
|
422
528
|
await prg.refreshDBO();
|
|
423
529
|
return true;
|
|
424
530
|
}));
|
|
@@ -493,76 +599,51 @@ export default class FileManager {
|
|
|
493
599
|
}
|
|
494
600
|
}
|
|
495
601
|
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
"
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
"application/x-javascript": ["js"],
|
|
516
|
-
"application/atom+xml": ["atom"],
|
|
517
|
-
"application/rss+xml": ["rss"],
|
|
518
|
-
"application/java-archive": ["jar", "war", "ear"],
|
|
519
|
-
"application/mac-binhex40": ["hqx"],
|
|
520
|
-
"application/msword": ["doc", "docx"],
|
|
521
|
-
"application/pdf": ["pdf"],
|
|
522
|
-
"application/postscript": ["ps", "eps", "ai"],
|
|
523
|
-
"application/rtf": ["rtf"],
|
|
524
|
-
"application/vnd.ms-excel": ["xls", "xlsx"],
|
|
525
|
-
"application/vnd.ms-powerpoint": ["ppt", "pptx"],
|
|
526
|
-
"application/vnd.wap.wmlc": ["wmlc"],
|
|
527
|
-
"application/vnd.google-earth.kml+xml": ["kml"],
|
|
528
|
-
"application/vnd.google-earth.kmz": ["kmz"],
|
|
529
|
-
"application/x-7z-compressed": ["7z"],
|
|
530
|
-
"application/x-cocoa": ["cco"],
|
|
531
|
-
"application/x-java-archive-diff": ["jardiff"],
|
|
532
|
-
"application/x-java-jnlp-file": ["jnlp"],
|
|
533
|
-
"application/x-makeself": ["run"],
|
|
534
|
-
"application/x-perl": ["pl", "pm"],
|
|
535
|
-
"application/x-pilot": ["prc", "pdb"],
|
|
536
|
-
"application/x-rar-compressed": ["rar"],
|
|
537
|
-
"application/x-redhat-package-manager": ["rpm"],
|
|
538
|
-
"application/x-sea": ["sea"],
|
|
539
|
-
"application/x-shockwave-flash": ["swf"],
|
|
540
|
-
"application/x-stuffit": ["sit"],
|
|
541
|
-
"application/x-tcl": ["tcl", "tk"],
|
|
542
|
-
"application/x-x509-ca-cert": ["der", "pem", "crt"],
|
|
543
|
-
"application/x-xpinstall": ["xpi"],
|
|
544
|
-
"application/xhtml+xml": ["xhtml"],
|
|
545
|
-
"application/zip": ["zip"],
|
|
546
|
-
"application/octet-stream": ["bin", "exe", "dll", "deb", "dmg", "eot", "iso", "img", "msi", "msp", "msm"],
|
|
547
|
-
"audio/midi": ["mid", "midi", "kar"],
|
|
548
|
-
"audio/mpeg": ["mp3"],
|
|
549
|
-
"audio/ogg": ["ogg"],
|
|
550
|
-
"audio/x-realaudio": ["ra"],
|
|
551
|
-
"video/3gpp": ["3gpp", "3gp"],
|
|
552
|
-
"video/mpeg": ["mpeg", "mpg"],
|
|
553
|
-
"video/quicktime": ["mov"],
|
|
554
|
-
"video/x-flv": ["flv"],
|
|
555
|
-
"video/x-mng": ["mng"],
|
|
556
|
-
"video/x-ms-asf": ["asx", "asf"],
|
|
557
|
-
"video/x-ms-wmv": ["wmv"],
|
|
558
|
-
"video/x-msvideo": ["avi"],
|
|
559
|
-
"video/mp4": ["m4v", "mp4"],
|
|
560
|
-
"video/webm": ["webm"],
|
|
561
|
-
} as const;
|
|
562
|
-
|
|
563
|
-
export type ALLOWED_CONTENT_TYPE = keyof typeof CONTENT_TYPE_TO_EXT;
|
|
564
|
-
export type ALLOWED_EXTENSION = (typeof CONTENT_TYPE_TO_EXT)[ALLOWED_CONTENT_TYPE][number];
|
|
602
|
+
export const getFileTypeFromFilename = (fileName: string): { mime: ALLOWED_CONTENT_TYPE; ext: ALLOWED_EXTENSION } | undefined => {
|
|
603
|
+
|
|
604
|
+
const nameParts = fileName.split(".");
|
|
605
|
+
|
|
606
|
+
if(!nameParts.length) return undefined;
|
|
607
|
+
|
|
608
|
+
const nameExt = nameParts[nameParts.length - 1].toLowerCase(),
|
|
609
|
+
mime = getKeys(CONTENT_TYPE_TO_EXT).find(k => (CONTENT_TYPE_TO_EXT[k] as readonly string[]).includes(nameExt));
|
|
610
|
+
|
|
611
|
+
if(!mime) return undefined;
|
|
612
|
+
|
|
613
|
+
return {
|
|
614
|
+
mime,
|
|
615
|
+
ext: nameExt as ALLOWED_EXTENSION,
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// const fileType = require("file-type");
|
|
620
|
+
// const res = await fileType.fromBuffer(typeof file === "string"? Buffer.from(file, 'utf8') : file);
|
|
565
621
|
|
|
622
|
+
export const getFileType = async (file: Buffer | string, fileName: string): Promise<{ mime: ALLOWED_CONTENT_TYPE; ext: ALLOWED_EXTENSION }> => {
|
|
623
|
+
|
|
624
|
+
const { fileTypeFromBuffer } = await (eval('import("file-type")') as Promise<typeof import('file-type')>);
|
|
625
|
+
|
|
626
|
+
const fileNameMime = getFileTypeFromFilename(fileName);
|
|
627
|
+
if(!fileNameMime?.ext) throw new Error("File name must contain extenions")
|
|
628
|
+
const res = await fileTypeFromBuffer(typeof file === "string"? Buffer.from(file, 'utf8') : file);
|
|
629
|
+
|
|
630
|
+
if(!res) {
|
|
631
|
+
|
|
632
|
+
/* Set correct/missing extension */
|
|
633
|
+
const nameExt = fileNameMime?.ext;
|
|
634
|
+
if(["xml", "txt", "csv", "tsv", "svg"].includes(nameExt)){
|
|
635
|
+
return fileNameMime
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
throw new Error("Could not get the file type from file buffer");
|
|
639
|
+
} else {
|
|
640
|
+
|
|
641
|
+
if(!res.ext || fileNameMime?.ext.toLowerCase() !== res.ext.toLowerCase()){
|
|
642
|
+
throw new Error(`There is a mismatch between file name extension and actual buffer extension: ${fileNameMime?.ext } vs ${res.ext}`)
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return res as any;
|
|
646
|
+
}
|
|
566
647
|
|
|
567
648
|
|
|
568
649
|
/**
|
package/lib/Prostgles.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import TableConfigurator, { TableConfig } from "./TableConfig";
|
|
|
7
7
|
import { DboBuilder, DBHandlerServer, PRGLIOSocket } from "./DboBuilder";
|
|
8
8
|
export { DBHandlerServer };
|
|
9
9
|
export declare type PGP = pgPromise.IMain<{}, pg.IClient>;
|
|
10
|
-
import { AnyObject } from "prostgles-types";
|
|
10
|
+
import { AnyObject, FileColumnConfig } from "prostgles-types";
|
|
11
11
|
import { Publish, PublishMethods, PublishParams, PublishParser } from "./PublishParser";
|
|
12
12
|
import { DBEventsManager } from "./DBEventsManager";
|
|
13
13
|
export declare type DB = pgPromise.IDatabase<{}, pg.IClient>;
|
|
@@ -76,7 +76,18 @@ export declare type FileTableConfig = {
|
|
|
76
76
|
localConfig?: LocalConfig;
|
|
77
77
|
expressApp: ExpressApp;
|
|
78
78
|
referencedTables?: {
|
|
79
|
-
[tableName: string]: "one" | "many"
|
|
79
|
+
[tableName: string]: "one" | "many"
|
|
80
|
+
/**
|
|
81
|
+
* If defined then will try to create (if necessary) a column in the files table which will reference this table's primary key (must have one)
|
|
82
|
+
* */
|
|
83
|
+
/**
|
|
84
|
+
* If defined then will try to create (if necessary) this column which will reference files_table(id)
|
|
85
|
+
* Prostgles UI will use these hints (obtained through tableHandler.getInfo())
|
|
86
|
+
* */
|
|
87
|
+
| {
|
|
88
|
+
type: "column";
|
|
89
|
+
referenceColumns: Record<string, FileColumnConfig>;
|
|
90
|
+
};
|
|
80
91
|
};
|
|
81
92
|
imageOptions?: ImageOptions;
|
|
82
93
|
};
|
package/lib/Prostgles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prostgles.d.ts","sourceRoot":"","sources":["Prostgles.ts"],"names":[],"mappings":";AAMA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,GAAG,QAAQ,iCAAiC,CAAC,CAAC;AAC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B,GAAG,EAAE,EAAE,CAAC;QACR,GAAG,EAAE,GAAG,CAAC;QACT,EAAE,CAAC,EAAE,GAAG,CAAC;QACT,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC;IAuJI,UAAU,CAAC,QAAQ,EAAE,MAAM;IA0BjC,gBAAgB,EAAE,GAAG,EAAE,CAAM;IACvB,eAAe;IAsGrB,gBAAgB,WAAkB,GAAG,mBAkFpC;CACF;AAqCD,wBAAsB,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1D"}
|
package/lib/Prostgles.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { PubSubManager, DEFAULT_SYNC_BATCH_SIZE, asValue } from "./PubSubManager
|
|
|
21
21
|
export { DBHandlerServer }
|
|
22
22
|
export type PGP = pgPromise.IMain<{}, pg.IClient>;
|
|
23
23
|
|
|
24
|
-
import { SQLRequest, TableSchemaForClient, CHANNELS, AnyObject, ClientSchema, getKeys, DBSchemaTable, DBSchema } from "prostgles-types";
|
|
24
|
+
import { SQLRequest, TableSchemaForClient, CHANNELS, AnyObject, ClientSchema, getKeys, DBSchemaTable, DBSchema, FileColumnConfig } from "prostgles-types";
|
|
25
25
|
import { Publish, PublishMethods, PublishParams, PublishParser } from "./PublishParser";
|
|
26
26
|
import { DBEventsManager } from "./DBEventsManager";
|
|
27
27
|
|
|
@@ -172,7 +172,7 @@ export type FileTableConfig = {
|
|
|
172
172
|
* If defined then will try to create (if necessary) this column which will reference files_table(id)
|
|
173
173
|
* Prostgles UI will use these hints (obtained through tableHandler.getInfo())
|
|
174
174
|
* */
|
|
175
|
-
|
|
175
|
+
| { type: "column", referenceColumns: Record<string, FileColumnConfig> }
|
|
176
176
|
},
|
|
177
177
|
imageOptions?: ImageOptions
|
|
178
178
|
};
|
package/lib/TableConfig.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AnyObject, TableInfo } from "prostgles-types";
|
|
1
|
+
import { AnyObject, TableInfo, ALLOWED_EXTENSION, ALLOWED_CONTENT_TYPE } from "prostgles-types";
|
|
2
2
|
import { JoinInfo } from "./DboBuilder";
|
|
3
|
-
import { ALLOWED_EXTENSION, ALLOWED_CONTENT_TYPE } from "./FileManager";
|
|
4
3
|
import { DB, DBHandlerServer, Prostgles } from "./Prostgles";
|
|
5
4
|
declare type ColExtraInfo = {
|
|
6
5
|
min?: string | number;
|
package/lib/TableConfig.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableConfig.d.ts","sourceRoot":"","sources":["TableConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableConfig.d.ts","sourceRoot":"","sources":["TableConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAE,SAAS,EAAG,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAClH,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,eAAe,EAAS,SAAS,EAAE,MAAM,aAAa,CAAC;AAGpE,aAAK,YAAY,GAAG;IAClB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,WAAW,CAAC,QAAQ,IAAI;KACjC,OAAO,IAAI,MAAM,QAAQ,GAAG,MAAM;CACpC,CAAA;AAED,eAAO,MAAM,SAAS;;;;;kBAiBrB,CAAA;AAED,aAAK,mBAAmB,CAAC,QAAQ,GAAG,SAAS,IAAI;IAC/C,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;KACxC,CAAA;IACD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,C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B,MAAM,eAAe,MAAM,KAAG,QAAQ,GAAG,SAAS,CA2B7E;IAEK,IAAI;CAyIX"}
|
package/lib/TableConfig.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DboBuilder, isPlainObject, JoinInfo } from "./DboBuilder";
|
|
4
|
-
import { ALLOWED_EXTENSION, ALLOWED_CONTENT_TYPE } from "./FileManager";
|
|
1
|
+
import { getKeys, asName, AnyObject, TableInfo, ALLOWED_EXTENSION, ALLOWED_CONTENT_TYPE } from "prostgles-types";
|
|
2
|
+
import { isPlainObject, JoinInfo } from "./DboBuilder";
|
|
5
3
|
import { DB, DBHandlerServer, Joins, Prostgles } from "./Prostgles";
|
|
6
4
|
import { asValue } from "./PubSubManager";
|
|
7
5
|
|