prostgles-server 2.0.195 → 2.0.198
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.d.ts +4 -6
- package/dist/DboBuilder.d.ts.map +1 -1
- package/dist/DboBuilder.js +72 -26
- package/dist/DboBuilder.js.map +1 -1
- package/dist/FileManager.d.ts +4 -0
- package/dist/FileManager.d.ts.map +1 -1
- package/dist/FileManager.js +55 -6
- package/dist/FileManager.js.map +1 -1
- package/dist/Prostgles.d.ts +15 -0
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js.map +1 -1
- package/dist/QueryBuilder.d.ts.map +1 -1
- package/dist/QueryBuilder.js +2 -1
- package/dist/QueryBuilder.js.map +1 -1
- package/lib/DboBuilder.d.ts +4 -6
- package/lib/DboBuilder.d.ts.map +1 -1
- package/lib/DboBuilder.js +72 -26
- package/lib/DboBuilder.ts +81 -28
- package/lib/FileManager.d.ts +4 -0
- package/lib/FileManager.d.ts.map +1 -1
- package/lib/FileManager.js +58 -6
- package/lib/FileManager.ts +59 -13
- package/lib/Prostgles.d.ts +15 -0
- package/lib/Prostgles.d.ts.map +1 -1
- package/lib/Prostgles.ts +16 -0
- package/lib/QueryBuilder.d.ts.map +1 -1
- package/lib/QueryBuilder.js +2 -1
- package/lib/QueryBuilder.ts +2 -1
- package/package.json +5 -5
- package/tests/client/PID.txt +1 -1
- package/tests/client/package-lock.json +15 -15
- package/tests/client/package.json +1 -1
- package/tests/server/index.js +0 -1
- package/tests/server/index.ts +0 -1
- package/tests/server/package-lock.json +9 -9
package/lib/DboBuilder.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as Bluebird from "bluebird";
|
|
|
8
8
|
// declare global { export interface Promise<T> extends Bluebird<T> {} }
|
|
9
9
|
|
|
10
10
|
import * as pgPromise from 'pg-promise';
|
|
11
|
-
const {ParameterizedQuery: PQ} = require('pg-promise');
|
|
11
|
+
const { ParameterizedQuery: PQ } = require('pg-promise');
|
|
12
12
|
import pg = require('pg-promise/typescript/pg-subset');
|
|
13
13
|
import {
|
|
14
14
|
ColumnInfo, ValidatedColumnInfo, FieldFilter, SelectParams, SubscribeParams,
|
|
@@ -61,17 +61,21 @@ export type DBHandlerServer =
|
|
|
61
61
|
tx?: TX
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
// export const getFilterFields = (f: Filter | any, $and_key: string, $or_key: string, prevFields: string[] = []): string[] => {
|
|
65
|
+
// if(Array.isArray(f)){
|
|
66
|
+
// return f.flatMap(_f => getFilterFields(_f, $and_key, $or_key, prevFields) );
|
|
67
|
+
// }
|
|
68
|
+
// if($and_key in f && Array.isArray(f[$and_key]) ){
|
|
69
|
+
// return f[$and_key].flatMap((_f: any) => getFilterFields(_f, $and_key, $or_key, prevFields) );
|
|
70
|
+
// } else if($or_key in f && Array.isArray(f[$or_key]) ){
|
|
71
|
+
// return f[$or_key].flatMap((_f: any) => getFilterFields(_f, $and_key, $or_key, prevFields) );
|
|
72
|
+
// } else if(isObject(f)){
|
|
73
|
+
// const filter:
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
// return []
|
|
77
|
+
// }
|
|
72
78
|
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
79
|
|
|
76
80
|
import { get } from "./utils";
|
|
77
81
|
import { getNewQuery, makeQuery, COMPUTED_FIELDS, SelectItem, FieldSpec, asNameAlias, SelectItemBuilder, FUNCTIONS, parseFunction, parseFunctionObject } from "./QueryBuilder";
|
|
@@ -1109,7 +1113,7 @@ export class ViewHandler {
|
|
|
1109
1113
|
return await this.find(filter, { select: "", limit: 0 }, undefined, table_rules, localParams)
|
|
1110
1114
|
.then(async allowed => {
|
|
1111
1115
|
const { filterFields, forcedFilter } = get(table_rules, "select") || {};
|
|
1112
|
-
const where = (await this.prepareWhere({ filter, forcedFilter, filterFields, addKeywords: true, localParams, tableRule: table_rules }));
|
|
1116
|
+
const where = (await this.prepareWhere({ filter, forcedFilter, filterFields, addKeywords: true, localParams, tableRule: table_rules })).where;
|
|
1113
1117
|
let query = "SELECT COUNT(*) FROM " + this.escapedName + " " + where;
|
|
1114
1118
|
return (this.t || this.db).one(query, { _psqlWS_tableName: this.name }).then(({ count }) => +count);
|
|
1115
1119
|
});
|
|
@@ -1213,7 +1217,7 @@ export class ViewHandler {
|
|
|
1213
1217
|
tableAlias?: string,
|
|
1214
1218
|
localParams: LocalParams | undefined,
|
|
1215
1219
|
tableRule: TableRule | undefined
|
|
1216
|
-
}): Promise<string>
|
|
1220
|
+
}): Promise<{ where: string; filter: AnyObject; }>
|
|
1217
1221
|
{
|
|
1218
1222
|
const { filter, select, forcedFilter, filterFields: ff, addKeywords = true, tableAlias, localParams, tableRule } = params;
|
|
1219
1223
|
const { $and: $and_key, $or: $or_key } = this.dboBuilder.prostgles.keywords;
|
|
@@ -1258,7 +1262,17 @@ export class ViewHandler {
|
|
|
1258
1262
|
|
|
1259
1263
|
if(!isPlainObject(filter)) throw "\nInvalid filter\nExpecting an object but got -> " + JSON.stringify(filter);
|
|
1260
1264
|
|
|
1261
|
-
|
|
1265
|
+
const getUpdateFilter = (args: { filter?: AnyObject; forcedFilter?: AnyObject; $and_key: string; }): AnyObject => {
|
|
1266
|
+
const { filter, forcedFilter, $and_key } = args;
|
|
1267
|
+
let result = { ...filter };
|
|
1268
|
+
if(forcedFilter){
|
|
1269
|
+
return {
|
|
1270
|
+
[$and_key]: [forcedFilter, filter].filter(isDefined)
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
return result;
|
|
1275
|
+
}
|
|
1262
1276
|
let _filter = getUpdateFilter({ filter, forcedFilter, $and_key });
|
|
1263
1277
|
|
|
1264
1278
|
// let keys = Object.keys(filter);
|
|
@@ -1266,7 +1280,7 @@ export class ViewHandler {
|
|
|
1266
1280
|
|
|
1267
1281
|
let cond = await parseFullFilter(_filter, null);
|
|
1268
1282
|
if(cond && addKeywords) cond = "WHERE " + cond;
|
|
1269
|
-
return cond || "";
|
|
1283
|
+
return { where: cond || "", filter: _filter };
|
|
1270
1284
|
}
|
|
1271
1285
|
|
|
1272
1286
|
async prepareExistCondition(eConfig: ExistsFilterConfig, localParams: LocalParams | undefined): Promise<string> {
|
|
@@ -1367,7 +1381,7 @@ export class ViewHandler {
|
|
|
1367
1381
|
tableAlias,
|
|
1368
1382
|
localParams,
|
|
1369
1383
|
tableRule: t2Rules //tableRules
|
|
1370
|
-
}))
|
|
1384
|
+
})).where
|
|
1371
1385
|
} catch(err) {
|
|
1372
1386
|
// console.trace(err)
|
|
1373
1387
|
throw "Issue with preparing $exists query for table " + t2 + "\n->" + JSON.stringify(err);
|
|
@@ -1996,7 +2010,8 @@ export class TableHandler extends ViewHandler {
|
|
|
1996
2010
|
}
|
|
1997
2011
|
|
|
1998
2012
|
const { filterFields, forcedFilter } = get(table_rules, "select") || {},
|
|
1999
|
-
|
|
2013
|
+
filterOpts = await this.prepareWhere({ filter, forcedFilter, addKeywords: false, filterFields, tableAlias: undefined, localParams, tableRule: table_rules }),
|
|
2014
|
+
condition = filterOpts.where,
|
|
2000
2015
|
throttle = get(params, "throttle") || 0,
|
|
2001
2016
|
selectParams = omitKeys(params || {}, ["throttle"]);
|
|
2002
2017
|
|
|
@@ -2114,7 +2129,6 @@ export class TableHandler extends ViewHandler {
|
|
|
2114
2129
|
filterFields: FieldFilter | undefined = "*",
|
|
2115
2130
|
fields: FieldFilter = "*";
|
|
2116
2131
|
|
|
2117
|
-
const { $and: $and_key } = this.dboBuilder.prostgles.keywords;
|
|
2118
2132
|
let finalUpdateFilter = { ...filter };
|
|
2119
2133
|
|
|
2120
2134
|
if(tableRules){
|
|
@@ -2125,8 +2139,8 @@ export class TableHandler extends ViewHandler {
|
|
|
2125
2139
|
throw "You are not allowed to return any fields from the update"
|
|
2126
2140
|
}
|
|
2127
2141
|
|
|
2128
|
-
if(!fields) throw ` Invalid update rule
|
|
2129
|
-
finalUpdateFilter =
|
|
2142
|
+
if(!fields) throw ` Invalid update rule fo r ${this.name}. fields missing `;
|
|
2143
|
+
finalUpdateFilter = (await this.prepareWhere({ filter, forcedFilter, filterFields, localParams, tableRule: tableRules })).filter;
|
|
2130
2144
|
if(tableRules.update.dynamicFields?.length){
|
|
2131
2145
|
|
|
2132
2146
|
/**
|
|
@@ -2276,7 +2290,7 @@ export class TableHandler extends ViewHandler {
|
|
|
2276
2290
|
filterFields,
|
|
2277
2291
|
localParams,
|
|
2278
2292
|
tableRule: tableRules
|
|
2279
|
-
}));
|
|
2293
|
+
})).where;
|
|
2280
2294
|
if(onConflictDoNothing) query += " ON CONFLICT DO NOTHING ";
|
|
2281
2295
|
|
|
2282
2296
|
let qType = "none";
|
|
@@ -2395,29 +2409,68 @@ export class TableHandler extends ViewHandler {
|
|
|
2395
2409
|
|
|
2396
2410
|
let queryType: keyof pgPromise.ITask<{}> = 'none';
|
|
2397
2411
|
let _query = "DELETE FROM " + this.escapedName;
|
|
2398
|
-
|
|
2399
|
-
_query += (await this.prepareWhere({
|
|
2412
|
+
const filterOpts = (await this.prepareWhere({
|
|
2400
2413
|
filter,
|
|
2401
2414
|
forcedFilter,
|
|
2402
2415
|
filterFields,
|
|
2403
2416
|
localParams,
|
|
2404
2417
|
tableRule: table_rules
|
|
2405
|
-
}))
|
|
2418
|
+
}))
|
|
2419
|
+
_query += filterOpts.where;
|
|
2406
2420
|
if(validate){
|
|
2407
|
-
const _filter =
|
|
2421
|
+
const _filter = filterOpts.filter;
|
|
2408
2422
|
await validate(_filter);
|
|
2409
2423
|
}
|
|
2410
2424
|
|
|
2425
|
+
let returningQuery = "";
|
|
2411
2426
|
if(returning){
|
|
2412
2427
|
queryType = "any";
|
|
2413
2428
|
if(!returningFields) {
|
|
2414
2429
|
throw "Returning dissallowed";
|
|
2415
2430
|
}
|
|
2416
|
-
|
|
2431
|
+
returningQuery = this.makeReturnQuery(await this.prepareReturning(returning, this.parseFieldFilter(returningFields)));
|
|
2432
|
+
_query += returningQuery
|
|
2417
2433
|
}
|
|
2418
2434
|
|
|
2419
2435
|
if(returnQuery) return _query;
|
|
2420
|
-
|
|
2436
|
+
|
|
2437
|
+
/**
|
|
2438
|
+
* Delete file
|
|
2439
|
+
*/
|
|
2440
|
+
const dbHandler = (this.t || this.db)
|
|
2441
|
+
if(this.is_media && this.dboBuilder.prostgles.fileManager){
|
|
2442
|
+
|
|
2443
|
+
if(this.dboBuilder.prostgles.opts.fileTable?.delayedDelete){
|
|
2444
|
+
return dbHandler[queryType](`UPDATE ${asName(this.name)} SET deleted = now() ${filterOpts.where} ${returningQuery};`)
|
|
2445
|
+
} else {
|
|
2446
|
+
|
|
2447
|
+
const txDelete = async (tbl: TableHandler) => {
|
|
2448
|
+
|
|
2449
|
+
const files = await this.find(filterOpts.filter);
|
|
2450
|
+
for await(const file of files){
|
|
2451
|
+
await tbl.dboBuilder.prostgles.fileManager?.deleteFile(file.name);
|
|
2452
|
+
await tbl.delete({ id: file.id });
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
if(returning){
|
|
2456
|
+
return files.map(f => pickKeys(f, ["id", "name"]));
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
if(localParams?.dbTX){
|
|
2461
|
+
return txDelete(localParams.dbTX[this.name] as TableHandler)
|
|
2462
|
+
} else if(this.t) {
|
|
2463
|
+
return txDelete(this)
|
|
2464
|
+
} else {
|
|
2465
|
+
|
|
2466
|
+
return this.dboBuilder.getTX(tx => {
|
|
2467
|
+
return txDelete(tx[this.name] as any)
|
|
2468
|
+
})
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
return dbHandler[queryType](_query).catch((err: any) => makeErr(err, localParams));
|
|
2421
2474
|
} catch(e){
|
|
2422
2475
|
// console.trace(e)
|
|
2423
2476
|
if(localParams && localParams.testRule) throw e;
|
|
@@ -2504,7 +2557,7 @@ export class TableHandler extends ViewHandler {
|
|
|
2504
2557
|
.then(async isValid => {
|
|
2505
2558
|
|
|
2506
2559
|
const { filterFields, forcedFilter } = get(table_rules, "select") || {};
|
|
2507
|
-
const condition = await this.prepareWhere({ filter, forcedFilter, filterFields, addKeywords: false, localParams, tableRule: table_rules });
|
|
2560
|
+
const condition = (await this.prepareWhere({ filter, forcedFilter, filterFields, addKeywords: false, localParams, tableRule: table_rules })).where;
|
|
2508
2561
|
|
|
2509
2562
|
// let final_filter = getFindFilter(filter, table_rules);
|
|
2510
2563
|
const pubSubManager = await this.dboBuilder.getPubSubManager();
|
package/lib/FileManager.d.ts
CHANGED
|
@@ -51,7 +51,9 @@ export declare type UploadedItem = {
|
|
|
51
51
|
*/
|
|
52
52
|
s3_url?: string;
|
|
53
53
|
};
|
|
54
|
+
import AWS from 'aws-sdk';
|
|
54
55
|
export default class FileManager {
|
|
56
|
+
static testCredentials: (accessKeyId: string, secretAccessKey: string) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.STS.GetCallerIdentityResponse, AWS.AWSError>>;
|
|
55
57
|
s3Client?: S3;
|
|
56
58
|
config: S3Config | LocalConfig;
|
|
57
59
|
imageOptions?: ImageOptions;
|
|
@@ -60,7 +62,9 @@ export default class FileManager {
|
|
|
60
62
|
get db(): DB;
|
|
61
63
|
tableName?: string;
|
|
62
64
|
private fileRoute?;
|
|
65
|
+
private checkInterval?;
|
|
63
66
|
constructor(config: FileManager["config"], imageOptions?: ImageOptions);
|
|
67
|
+
deleteFile(name: string): Promise<true | import("aws-sdk/lib/request").PromiseResult<S3.DeleteObjectOutput, AWS.AWSError>>;
|
|
64
68
|
parseFile(args: {
|
|
65
69
|
file: Buffer | string;
|
|
66
70
|
fileName: string;
|
package/lib/FileManager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["FileManager.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["FileManager.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAO,MAAM,SAAS,CAAC;AAMlC,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAkD,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAK/I,eAAO,MAAM,eAAe,SAAgB,MAAM,aAAW,QAAQ,MAAM,CAE1E,CAAA;AAED,oBAAY,YAAY,GAAG;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC;IACV;;OAEG;IACD;QAAE,MAAM,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAC7C;QAAE,OAAO,EACL;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,GACjB;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KACrB,CAAA;CACN,CAAA;AAED,oBAAY,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAA;AAED,oBAAY,WAAW,GAAG;IACxB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAA;AAED,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,C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CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAG,mBAAmB,CAAC,MAAM,CAAC,GAAG,SAAS,CAWnG;IAED,IAAI,QAAe,SAAS,mBAyN3B;CACF;AAED,eAAO,MAAM,uBAAuB,aAAc,MAAM;UAAW,oBAAoB;SAAO,iBAAiB,GAAG,MAAM;CAevH,CAAA;AAKD,eAAO,MAAM,WAAW,SAAgB,MAAM,GAAG,MAAM,YAAY,MAAM,KAAG,QAAQ;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,GAAG,EAAE,iBAAiB,CAAA;CAAE,CAwBzI,CAAA;AAGD;;;;;;;;;;;;;;;;;;;GAmBG"}
|
package/lib/FileManager.js
CHANGED
|
@@ -22,6 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
var _a;
|
|
25
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
30
|
exports.getFileType = exports.getFileTypeFromFilename = exports.asSQLIdentifier = void 0;
|
|
27
31
|
const aws_sdk_1 = require("aws-sdk");
|
|
@@ -34,6 +38,7 @@ const asSQLIdentifier = async (name, db) => {
|
|
|
34
38
|
return (await db.one("select format('%I', $1) as name", [name]))?.name;
|
|
35
39
|
};
|
|
36
40
|
exports.asSQLIdentifier = asSQLIdentifier;
|
|
41
|
+
const aws_sdk_2 = __importDefault(require("aws-sdk"));
|
|
37
42
|
class FileManager {
|
|
38
43
|
constructor(config, imageOptions) {
|
|
39
44
|
this.uploadAsMedia = async (params) => {
|
|
@@ -271,6 +276,9 @@ class FileManager {
|
|
|
271
276
|
}
|
|
272
277
|
else {
|
|
273
278
|
const pth = `${this.config.localFolderPath}/${media.name}`;
|
|
279
|
+
if (!fs.existsSync(pth)) {
|
|
280
|
+
throw new Error("File not found");
|
|
281
|
+
}
|
|
274
282
|
res.contentType(media.content_type);
|
|
275
283
|
res.sendFile(pth);
|
|
276
284
|
}
|
|
@@ -291,6 +299,21 @@ class FileManager {
|
|
|
291
299
|
credentials: { accessKeyId, secretAccessKey },
|
|
292
300
|
});
|
|
293
301
|
}
|
|
302
|
+
const fullConfig = this.prostgles?.opts.fileTable;
|
|
303
|
+
if (fullConfig?.delayedDelete) {
|
|
304
|
+
this.checkInterval = setInterval(async () => {
|
|
305
|
+
const fTable = fullConfig.tableName;
|
|
306
|
+
const daysDelay = fullConfig.delayedDelete?.deleteAfterNDays ?? 0;
|
|
307
|
+
if (fTable && this.dbo[fTable]?.delete && daysDelay) {
|
|
308
|
+
const files = await this.dbo[fTable]?.find?.({ deleted_from_storage: null, deleted: { ">": Date.now() - (daysDelay * HOUR * 24) } }) ?? [];
|
|
309
|
+
for await (const file of files) {
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
console.error("FileManager checkInterval delayedDelete FAIL: Could not access file table tableHandler.delete()");
|
|
314
|
+
}
|
|
315
|
+
}, Math.max(10000, (fullConfig.delayedDelete.checkIntervalHours || 0) * HOUR));
|
|
316
|
+
}
|
|
294
317
|
}
|
|
295
318
|
get dbo() {
|
|
296
319
|
if (!this.prostgles?.dbo)
|
|
@@ -304,13 +327,27 @@ class FileManager {
|
|
|
304
327
|
return this.prostgles.db;
|
|
305
328
|
}
|
|
306
329
|
;
|
|
330
|
+
async deleteFile(name) {
|
|
331
|
+
if ("bucket" in this.config && this.s3Client) {
|
|
332
|
+
const res = await this.s3Client?.deleteObject({ Bucket: this.config.bucket, Key: name }).promise();
|
|
333
|
+
return res;
|
|
334
|
+
}
|
|
335
|
+
else if ("localFolderPath" in this.config) {
|
|
336
|
+
const path = `${this.config.localFolderPath}/${name}`;
|
|
337
|
+
if (!fs.existsSync(path)) {
|
|
338
|
+
throw `File ${path} could not be found`;
|
|
339
|
+
}
|
|
340
|
+
fs.unlinkSync(path);
|
|
341
|
+
}
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
307
344
|
async parseFile(args) {
|
|
308
345
|
const { file, fileName, tableName, colName } = args;
|
|
309
346
|
const config = this.prostgles?.opts.fileTable;
|
|
310
347
|
if (!config)
|
|
311
348
|
throw new Error("File table config missing");
|
|
312
349
|
const buffer = typeof file === "string" ? Buffer.from(file, 'utf8') : file;
|
|
313
|
-
|
|
350
|
+
let result = await (0, exports.getFileTypeFromFilename)(fileName);
|
|
314
351
|
if (tableName && colName) {
|
|
315
352
|
const tableConfig = config.referencedTables?.[tableName];
|
|
316
353
|
if (tableConfig && (0, prostgles_types_1.isObject)(tableConfig) && tableConfig.referenceColumns[colName]) {
|
|
@@ -321,7 +358,8 @@ class FileManager {
|
|
|
321
358
|
throw new Error(`Provided file is larger than the ${colConfig.maxFileSizeMB}MB limit`);
|
|
322
359
|
}
|
|
323
360
|
}
|
|
324
|
-
if ("acceptedContent" in colConfig && colConfig.acceptedContent) {
|
|
361
|
+
if ("acceptedContent" in colConfig && colConfig.acceptedContent && colConfig.acceptedContent !== "*") {
|
|
362
|
+
const mime = await (0, exports.getFileType)(buffer, fileName);
|
|
325
363
|
const CONTENTS = [
|
|
326
364
|
"image",
|
|
327
365
|
"audio",
|
|
@@ -334,13 +372,15 @@ class FileManager {
|
|
|
334
372
|
throw new Error(`Dissallowed content type provided: ${mime.mime.split("/")[0]}. Allowed content types: ${allowedContent} `);
|
|
335
373
|
}
|
|
336
374
|
}
|
|
337
|
-
else if ("acceptedContentType" in colConfig && colConfig.acceptedContentType) {
|
|
375
|
+
else if ("acceptedContentType" in colConfig && colConfig.acceptedContentType && colConfig.acceptedContentType !== "*") {
|
|
376
|
+
const mime = await (0, exports.getFileType)(buffer, fileName);
|
|
338
377
|
const allowedContentTypes = DboBuilder_1.ViewHandler._parseFieldFilter(colConfig.acceptedContentType, false, (0, prostgles_types_1.getKeys)(prostgles_types_1.CONTENT_TYPE_TO_EXT));
|
|
339
378
|
if (!allowedContentTypes.some(c => c === mime.mime)) {
|
|
340
379
|
throw new Error(`Dissallowed MIME provided: ${mime.mime}. Allowed MIME values: ${allowedContentTypes} `);
|
|
341
380
|
}
|
|
342
381
|
}
|
|
343
|
-
else if ("acceptedFileTypes" in colConfig && colConfig.acceptedFileTypes) {
|
|
382
|
+
else if ("acceptedFileTypes" in colConfig && colConfig.acceptedFileTypes && colConfig.acceptedFileTypes !== "*") {
|
|
383
|
+
const mime = await (0, exports.getFileType)(buffer, fileName);
|
|
344
384
|
const allowedExtensions = DboBuilder_1.ViewHandler._parseFieldFilter(colConfig.acceptedFileTypes, false, Object.values(prostgles_types_1.CONTENT_TYPE_TO_EXT).flat());
|
|
345
385
|
if (!allowedExtensions.some(c => c === mime.ext)) {
|
|
346
386
|
throw new Error(`Dissallowed extension provided: ${mime.ext}. Allowed extension values: ${allowedExtensions} `);
|
|
@@ -348,7 +388,9 @@ class FileManager {
|
|
|
348
388
|
}
|
|
349
389
|
}
|
|
350
390
|
}
|
|
351
|
-
|
|
391
|
+
if (!result?.mime)
|
|
392
|
+
throw `File MIME type not found for the provided extension: ${result?.ext}`;
|
|
393
|
+
return result;
|
|
352
394
|
}
|
|
353
395
|
// async getUploadURL(fileName: string): Promise<string> {
|
|
354
396
|
// const thisHour = new Date();
|
|
@@ -433,6 +475,16 @@ class FileManager {
|
|
|
433
475
|
}
|
|
434
476
|
}
|
|
435
477
|
exports.default = FileManager;
|
|
478
|
+
_a = FileManager;
|
|
479
|
+
FileManager.testCredentials = async (accessKeyId, secretAccessKey) => {
|
|
480
|
+
const sts = new aws_sdk_2.default.STS();
|
|
481
|
+
aws_sdk_2.default.config.credentials = {
|
|
482
|
+
accessKeyId,
|
|
483
|
+
secretAccessKey
|
|
484
|
+
};
|
|
485
|
+
const ident = await sts.getCallerIdentity({}).promise();
|
|
486
|
+
return ident;
|
|
487
|
+
};
|
|
436
488
|
const getFileTypeFromFilename = (fileName) => {
|
|
437
489
|
const nameParts = fileName.split(".");
|
|
438
490
|
if (nameParts.length < 2)
|
|
@@ -457,7 +509,7 @@ const getFileType = async (file, fileName) => {
|
|
|
457
509
|
if (!res) {
|
|
458
510
|
/* Set correct/missing extension */
|
|
459
511
|
const nameExt = fileNameMime?.ext;
|
|
460
|
-
if (["xml", "txt", "csv", "tsv", "svg"].includes(nameExt) && fileNameMime.mime) {
|
|
512
|
+
if (["xml", "txt", "csv", "tsv", "svg", "sql"].includes(nameExt) && fileNameMime.mime) {
|
|
461
513
|
return fileNameMime;
|
|
462
514
|
}
|
|
463
515
|
throw new Error("Could not get the file type from file buffer");
|
package/lib/FileManager.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { S3 } from 'aws-sdk';
|
|
2
|
+
import { S3, IAM } from 'aws-sdk';
|
|
3
3
|
import { ManagedUpload } from 'aws-sdk/clients/s3';
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
|
|
@@ -33,7 +33,6 @@ export type S3Config = {
|
|
|
33
33
|
bucket: string;
|
|
34
34
|
accessKeyId: string;
|
|
35
35
|
secretAccessKey: string;
|
|
36
|
-
// onUploaded?: () => any;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export type LocalConfig = {
|
|
@@ -61,8 +60,19 @@ export type UploadedItem = {
|
|
|
61
60
|
*/
|
|
62
61
|
s3_url?: string;
|
|
63
62
|
};
|
|
64
|
-
|
|
63
|
+
import AWS from 'aws-sdk';
|
|
65
64
|
export default class FileManager {
|
|
65
|
+
|
|
66
|
+
static testCredentials = async (accessKeyId: string, secretAccessKey: string) => {
|
|
67
|
+
const sts = new AWS.STS();
|
|
68
|
+
AWS.config.credentials = {
|
|
69
|
+
accessKeyId,
|
|
70
|
+
secretAccessKey
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const ident = await sts.getCallerIdentity({}).promise();
|
|
74
|
+
return ident;
|
|
75
|
+
}
|
|
66
76
|
|
|
67
77
|
s3Client?: S3;
|
|
68
78
|
|
|
@@ -82,6 +92,7 @@ export default class FileManager {
|
|
|
82
92
|
tableName?: string;
|
|
83
93
|
|
|
84
94
|
private fileRoute?: string;
|
|
95
|
+
private checkInterval?: NodeJS.Timeout;
|
|
85
96
|
|
|
86
97
|
constructor(config: FileManager["config"], imageOptions?: ImageOptions){
|
|
87
98
|
this.config = config;
|
|
@@ -94,6 +105,36 @@ export default class FileManager {
|
|
|
94
105
|
credentials: { accessKeyId, secretAccessKey },
|
|
95
106
|
});
|
|
96
107
|
}
|
|
108
|
+
|
|
109
|
+
const fullConfig = this.prostgles?.opts.fileTable;
|
|
110
|
+
if(fullConfig?.delayedDelete){
|
|
111
|
+
this.checkInterval = setInterval(async () => {
|
|
112
|
+
const fTable = fullConfig.tableName;
|
|
113
|
+
const daysDelay = fullConfig.delayedDelete?.deleteAfterNDays ?? 0;
|
|
114
|
+
if(fTable && this.dbo[fTable]?.delete && daysDelay){
|
|
115
|
+
const files = await this.dbo[fTable]?.find?.({ deleted_from_storage: null, deleted: { ">": Date.now() - (daysDelay * HOUR * 24) } }) ?? [];
|
|
116
|
+
for await(const file of files){
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
console.error("FileManager checkInterval delayedDelete FAIL: Could not access file table tableHandler.delete()")
|
|
121
|
+
}
|
|
122
|
+
}, Math.max(10000, (fullConfig.delayedDelete.checkIntervalHours || 0) * HOUR))
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async deleteFile(name: string) {
|
|
127
|
+
if("bucket" in this.config && this.s3Client){
|
|
128
|
+
const res = await this.s3Client?.deleteObject({ Bucket: this.config.bucket, Key: name }).promise();
|
|
129
|
+
return res;
|
|
130
|
+
} else if("localFolderPath" in this.config){
|
|
131
|
+
const path = `${this.config.localFolderPath}/${name}`;
|
|
132
|
+
if(!fs.existsSync(path)){
|
|
133
|
+
throw `File ${path} could not be found`;
|
|
134
|
+
}
|
|
135
|
+
fs.unlinkSync(path);
|
|
136
|
+
}
|
|
137
|
+
return true
|
|
97
138
|
}
|
|
98
139
|
|
|
99
140
|
async parseFile(args: {
|
|
@@ -113,8 +154,8 @@ export default class FileManager {
|
|
|
113
154
|
if(!config) throw new Error("File table config missing");
|
|
114
155
|
|
|
115
156
|
const buffer = typeof file === "string"? Buffer.from(file, 'utf8') : file;
|
|
116
|
-
const mime = await getFileType(buffer, fileName);
|
|
117
157
|
|
|
158
|
+
let result = await getFileTypeFromFilename(fileName);
|
|
118
159
|
if(tableName && colName){
|
|
119
160
|
const tableConfig = config.referencedTables?.[tableName];
|
|
120
161
|
|
|
@@ -127,7 +168,8 @@ export default class FileManager {
|
|
|
127
168
|
}
|
|
128
169
|
}
|
|
129
170
|
|
|
130
|
-
if("acceptedContent" in colConfig && colConfig.acceptedContent){
|
|
171
|
+
if("acceptedContent" in colConfig && colConfig.acceptedContent && colConfig.acceptedContent !== "*"){
|
|
172
|
+
const mime = await getFileType(buffer, fileName);
|
|
131
173
|
const CONTENTS = [
|
|
132
174
|
"image",
|
|
133
175
|
"audio",
|
|
@@ -139,13 +181,15 @@ export default class FileManager {
|
|
|
139
181
|
if(!allowedContent.some(c => mime.mime.startsWith(c))){
|
|
140
182
|
throw new Error(`Dissallowed content type provided: ${mime.mime.split("/")[0]}. Allowed content types: ${allowedContent} `)
|
|
141
183
|
}
|
|
142
|
-
} else if("acceptedContentType" in colConfig && colConfig.acceptedContentType){
|
|
184
|
+
} else if("acceptedContentType" in colConfig && colConfig.acceptedContentType && colConfig.acceptedContentType !== "*"){
|
|
185
|
+
const mime = await getFileType(buffer, fileName);
|
|
143
186
|
const allowedContentTypes = ViewHandler._parseFieldFilter(colConfig.acceptedContentType, false, getKeys(CONTENT_TYPE_TO_EXT));
|
|
144
187
|
|
|
145
188
|
if(!allowedContentTypes.some(c => c === mime.mime)){
|
|
146
189
|
throw new Error(`Dissallowed MIME provided: ${mime.mime}. Allowed MIME values: ${allowedContentTypes} `)
|
|
147
190
|
}
|
|
148
|
-
} else if("acceptedFileTypes" in colConfig && colConfig.acceptedFileTypes){
|
|
191
|
+
} else if("acceptedFileTypes" in colConfig && colConfig.acceptedFileTypes && colConfig.acceptedFileTypes !== "*"){
|
|
192
|
+
const mime = await getFileType(buffer, fileName);
|
|
149
193
|
const allowedExtensions = ViewHandler._parseFieldFilter(colConfig.acceptedFileTypes, false, Object.values(CONTENT_TYPE_TO_EXT).flat());
|
|
150
194
|
|
|
151
195
|
if(!allowedExtensions.some(c => c === mime.ext)){
|
|
@@ -154,8 +198,8 @@ export default class FileManager {
|
|
|
154
198
|
}
|
|
155
199
|
}
|
|
156
200
|
}
|
|
157
|
-
|
|
158
|
-
return
|
|
201
|
+
if(!result?.mime) throw `File MIME type not found for the provided extension: ${result?.ext}`;
|
|
202
|
+
return result;
|
|
159
203
|
}
|
|
160
204
|
|
|
161
205
|
// async getUploadURL(fileName: string): Promise<string> {
|
|
@@ -176,7 +220,7 @@ export default class FileManager {
|
|
|
176
220
|
// }
|
|
177
221
|
|
|
178
222
|
private async upload(
|
|
179
|
-
file: Buffer |
|
|
223
|
+
file: Buffer | string,
|
|
180
224
|
name: string,
|
|
181
225
|
mime: string
|
|
182
226
|
): Promise<UploadedItem> {
|
|
@@ -520,7 +564,9 @@ export default class FileManager {
|
|
|
520
564
|
|
|
521
565
|
} else {
|
|
522
566
|
const pth = `${(this.config as LocalConfig).localFolderPath}/${media.name}`;
|
|
523
|
-
|
|
567
|
+
if(!fs.existsSync(pth)){
|
|
568
|
+
throw new Error("File not found");
|
|
569
|
+
}
|
|
524
570
|
res.contentType(media.content_type);
|
|
525
571
|
res.sendFile(pth);
|
|
526
572
|
}
|
|
@@ -566,9 +612,9 @@ export const getFileType = async (file: Buffer | string, fileName: string): Prom
|
|
|
566
612
|
|
|
567
613
|
/* Set correct/missing extension */
|
|
568
614
|
const nameExt = fileNameMime?.ext;
|
|
569
|
-
if(["xml", "txt", "csv", "tsv", "svg"].includes(nameExt) && fileNameMime.mime){
|
|
615
|
+
if(["xml", "txt", "csv", "tsv", "svg", "sql"].includes(nameExt) && fileNameMime.mime){
|
|
570
616
|
return fileNameMime as any;
|
|
571
|
-
}
|
|
617
|
+
}
|
|
572
618
|
|
|
573
619
|
throw new Error("Could not get the file type from file buffer");
|
|
574
620
|
} else {
|
package/lib/Prostgles.d.ts
CHANGED
|
@@ -74,6 +74,21 @@ export declare type FileTableConfig = {
|
|
|
74
74
|
fileServeRoute?: string;
|
|
75
75
|
awsS3Config?: S3Config;
|
|
76
76
|
localConfig?: LocalConfig;
|
|
77
|
+
/**
|
|
78
|
+
* If defined the the files will not be deleted immediately
|
|
79
|
+
* Instead, the "deleted" field will be updated to the current timestamp and after the day interval provided in "deleteAfterNDays" the files will be deleted
|
|
80
|
+
* "checkIntervalMinutes" is the frequency in hours at which the files ready for deletion are deleted
|
|
81
|
+
*/
|
|
82
|
+
delayedDelete?: {
|
|
83
|
+
/**
|
|
84
|
+
* Minimum amount of time measured in days for which the files will not be deleted after requesting delete
|
|
85
|
+
*/
|
|
86
|
+
deleteAfterNDays: number;
|
|
87
|
+
/**
|
|
88
|
+
* How freuquently the files will be checked for deletion delay
|
|
89
|
+
*/
|
|
90
|
+
checkIntervalHours?: number;
|
|
91
|
+
};
|
|
77
92
|
expressApp: ExpressApp;
|
|
78
93
|
referencedTables?: {
|
|
79
94
|
[tableName: string]: "one" | "many"
|
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;AACvD,OAAO,WAAW,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIjF,OAAO,WAAW,EAAE,EAAc,IAAI,EAAE,MAAM,eAAe,CAAC;AAG9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AC5B,OAAO,CAAC,MAAM,CAAS;IAEvB,eAAe,CAAC,EAAE,eAAe,CAAC;IAGlC,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAEtC,OAAO,CAAC,SAAS,EAAE,MAAM;gBAIb,MAAM,EAAE,oBAAoB;IA+BxC,SAAS,UAAS;IAEZ,cAAc,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IA+B9D,OAAO;IAIP,aAAa;;;;IAMb,OAAO,CAAC,WAAW;IASnB,aAAa,CAAC,KAAK,UAAQ;IAmB3B,UAAU,iCAUT;IAED,WAAW,UAAS;IACpB,0BAA0B,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;IACtC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,GAAG,OAAO,CAAC;QAChE,EAAE,EAAE,aAAa,CAAC;QAClB,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;IAiKI,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
|
@@ -158,6 +158,22 @@ export type FileTableConfig = {
|
|
|
158
158
|
// accessKeyId: string;
|
|
159
159
|
// secretAccessKey: string;
|
|
160
160
|
// },
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* If defined the the files will not be deleted immediately
|
|
164
|
+
* Instead, the "deleted" field will be updated to the current timestamp and after the day interval provided in "deleteAfterNDays" the files will be deleted
|
|
165
|
+
* "checkIntervalMinutes" is the frequency in hours at which the files ready for deletion are deleted
|
|
166
|
+
*/
|
|
167
|
+
delayedDelete?: {
|
|
168
|
+
/**
|
|
169
|
+
* Minimum amount of time measured in days for which the files will not be deleted after requesting delete
|
|
170
|
+
*/
|
|
171
|
+
deleteAfterNDays: number;
|
|
172
|
+
/**
|
|
173
|
+
* How freuquently the files will be checked for deletion delay
|
|
174
|
+
*/
|
|
175
|
+
checkIntervalHours?: number;
|
|
176
|
+
}
|
|
161
177
|
expressApp: ExpressApp;
|
|
162
178
|
referencedTables?: { // minFiles: number; maxFiles: number;
|
|
163
179
|
[tableName: string]:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["QueryBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAO,MAAM,EAAE,WAAW,EAAiB,YAAY,EAAiC,MAAM,cAAc,CAAC;AACpH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAqE,UAAU,EAAE,uBAAuB,EAAY,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzK,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,GAAG,UAAU,CAAC;IAC1E,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,MAAM,EAAE,GAAG,GAAG,CAAC;IAC5C,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAE1C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,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,CAQd;IAED,OAAO,CAAC,WAAW,CAkBlB;IAED,SAAS,cAAe,MAAM,YAAY,OAAO,UA6BhD;IAED,eAAe,eAAsB,MAAM,oBAAoB,MAAM,OAAO,GAAG,kBAAkB,MAAM,KAAK,GAAG,KAAK,GAAG,oBAiGtH;CAEF;AAED,wBAAsB,WAAW,CAC/B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,CAAC,YAAY,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAO,EACvD,aAAa,KAAO,EACpB,UAAU,EAAE,SAAS,GAAG,SAAS,EACjC,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,OAAO,EAAE,UAAU,EAAE,GACpB,OAAO,CAAC,QAAQ,CAAC,CAsJnB;AAKD,wBAAgB,SAAS,CACvB,KAAK,EAAE,YAAY,EACnB,CAAC,EAAE,QAAQ,EACX,KAAK,GAAE,MAAU,EACjB,UAAU,GAAE,MAAM,EAAO,EACzB,YAAY,GAAE,YAAiB,GAC9B,MAAM,CA8QR"}
|
package/lib/QueryBuilder.js
CHANGED
|
@@ -1106,7 +1106,7 @@ async function getNewQuery(_this, filter, selectParams = {}, param3_unused = nul
|
|
|
1106
1106
|
// const validatedAggAliases = select
|
|
1107
1107
|
// .filter(s => s.type !== "joinedColumn")
|
|
1108
1108
|
// .map(s => s.alias);
|
|
1109
|
-
const
|
|
1109
|
+
const filterOpts = await _this.prepareWhere({
|
|
1110
1110
|
filter,
|
|
1111
1111
|
select,
|
|
1112
1112
|
forcedFilter: (0, utils_1.get)(tableRules, "select.forcedFilter"),
|
|
@@ -1115,6 +1115,7 @@ async function getNewQuery(_this, filter, selectParams = {}, param3_unused = nul
|
|
|
1115
1115
|
localParams,
|
|
1116
1116
|
tableRule: tableRules
|
|
1117
1117
|
});
|
|
1118
|
+
const where = filterOpts.where;
|
|
1118
1119
|
const p = _this.getValidatedRules(tableRules, localParams);
|
|
1119
1120
|
let resQuery = {
|
|
1120
1121
|
allFields: allowedFields,
|