prostgles-server 2.0.173 → 2.0.176
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/.vscode/settings.json +3 -0
- package/dist/AuthHandler.d.ts +13 -12
- package/dist/AuthHandler.d.ts.map +1 -1
- package/dist/AuthHandler.js +5 -2
- package/dist/AuthHandler.js.map +1 -1
- package/dist/DBSchemaBuilder.d.ts +11 -0
- package/dist/DBSchemaBuilder.d.ts.map +1 -0
- package/dist/DBSchemaBuilder.js +56 -0
- package/dist/DBSchemaBuilder.js.map +1 -0
- package/dist/DboBuilder.d.ts +23 -22
- package/dist/DboBuilder.d.ts.map +1 -1
- package/dist/DboBuilder.js +36 -61
- package/dist/DboBuilder.js.map +1 -1
- package/dist/FileManager.d.ts +2 -2
- package/dist/FileManager.d.ts.map +1 -1
- package/dist/Filtering.d.ts.map +1 -1
- package/dist/Filtering.js.map +1 -1
- package/dist/Prostgles.d.ts +25 -257
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +12 -376
- package/dist/Prostgles.js.map +1 -1
- package/dist/PubSubManager.d.ts +6 -5
- package/dist/PubSubManager.d.ts.map +1 -1
- package/dist/PubSubManager.js.map +1 -1
- package/dist/PublishParser.d.ts +262 -0
- package/dist/PublishParser.d.ts.map +1 -0
- package/dist/PublishParser.js +391 -0
- package/dist/PublishParser.js.map +1 -0
- package/dist/QueryBuilder.d.ts +20 -4
- package/dist/QueryBuilder.d.ts.map +1 -1
- package/dist/QueryBuilder.js.map +1 -1
- package/dist/TableConfig.d.ts +6 -3
- package/dist/TableConfig.d.ts.map +1 -1
- package/dist/TableConfig.js +28 -1
- package/dist/TableConfig.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/lib/AuthHandler.ts +25 -19
- package/lib/DBSchemaBuilder.ts +91 -0
- package/lib/DboBuilder.ts +84 -98
- package/lib/FileManager.ts +2 -2
- package/lib/Filtering.ts +3 -3
- package/lib/Prostgles.ts +33 -704
- package/lib/PubSubManager.ts +6 -5
- package/lib/PublishParser.ts +723 -0
- package/lib/QueryBuilder.ts +6 -5
- package/lib/TableConfig.ts +36 -5
- package/lib/index.ts +4 -4
- package/package.json +2 -2
- package/tests/client/PID.txt +1 -1
- package/tests/client/index.js +2 -2
- package/tests/client/index.ts +2 -2
- package/tests/client/package-lock.json +15 -15
- package/tests/client/package.json +1 -1
- package/tests/client_only_queries.js +24 -1
- package/tests/client_only_queries.ts +23 -1
- package/tests/isomorphic_queries.js +3 -0
- package/tests/isomorphic_queries.ts +5 -2
- package/tests/server/DBoGenerated.d.ts +428 -286
- package/tests/server/index.js +1 -14
- package/tests/server/index.ts +5 -19
- package/tests/server/package-lock.json +3 -3
package/lib/DboBuilder.ts
CHANGED
|
@@ -42,23 +42,23 @@ export type Media = {
|
|
|
42
42
|
"etag"?: string;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export
|
|
46
|
-
|
|
45
|
+
export type TxHandler = TablesAndViewHandlers;
|
|
46
|
+
export type TxCB<DBO extends TablesAndViewHandlers = TablesAndViewHandlers> = {
|
|
47
|
+
(t: DBO, _t: pgPromise.ITask<{}>): (any | void);
|
|
47
48
|
}
|
|
48
|
-
export type
|
|
49
|
-
(t:
|
|
49
|
+
export type TX<DBO extends TablesAndViewHandlers = TablesAndViewHandlers> = {
|
|
50
|
+
(t: TxCB<DBO>): Promise<(any | void)>;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
export type DbHandler = {
|
|
52
|
+
|
|
53
|
+
type TablesAndViewHandlers = {
|
|
55
54
|
[key: string]: Partial<TableHandler>;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
}
|
|
56
|
+
export type DBHandlerServer<DBO extends TablesAndViewHandlers = TablesAndViewHandlers>=
|
|
57
|
+
TablesAndViewHandlers &
|
|
58
|
+
DbJoinMaker & {
|
|
59
59
|
sql?: SQLHandler
|
|
60
60
|
} & {
|
|
61
|
-
tx?: TX
|
|
61
|
+
tx?: TX<DBO>
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export const getUpdateFilter = (args: { filter?: AnyObject; forcedFilter?: AnyObject; $and_key: string }): AnyObject => {
|
|
@@ -76,8 +76,11 @@ export const getUpdateFilter = (args: { filter?: AnyObject; forcedFilter?: AnyOb
|
|
|
76
76
|
import { get } from "./utils";
|
|
77
77
|
import { getNewQuery, makeQuery, COMPUTED_FIELDS, SelectItem, FieldSpec, asNameAlias, SelectItemBuilder, FUNCTIONS, parseFunction, parseFunctionObject } from "./QueryBuilder";
|
|
78
78
|
import {
|
|
79
|
-
|
|
79
|
+
Join, Prostgles, DB
|
|
80
80
|
} from "./Prostgles";
|
|
81
|
+
import {
|
|
82
|
+
TableRule, UpdateRule, SyncRule, PublishParser, ValidateRow, ValidateUpdateRow, PublishAllOrNothing
|
|
83
|
+
} from "./PublishParser";
|
|
81
84
|
import { PubSubManager, asValue, BasicCallback, pickKeys, omitKeys } from "./PubSubManager";
|
|
82
85
|
|
|
83
86
|
import { parseFilterItem } from "./Filtering";
|
|
@@ -146,7 +149,7 @@ export type LocalParams = {
|
|
|
146
149
|
dbTX?: TxHandler;
|
|
147
150
|
|
|
148
151
|
// localTX?: pgPromise.ITask<{}>;
|
|
149
|
-
localDBTX?:
|
|
152
|
+
localDBTX?: DBHandlerServer;
|
|
150
153
|
|
|
151
154
|
returnQuery?: boolean;
|
|
152
155
|
|
|
@@ -165,22 +168,22 @@ function capitalizeFirstLetter(string: string, nonalpha_replacement?: string) :
|
|
|
165
168
|
|
|
166
169
|
function snakify(str: string, capitalize = false) : string {
|
|
167
170
|
|
|
168
|
-
|
|
171
|
+
return str.split("").map((c, i)=> {
|
|
169
172
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
173
|
+
if(!i) {
|
|
174
|
+
if(capitalize) c = c.toUpperCase();
|
|
175
|
+
if(c.match(/[^a-z_A-Z]/)){
|
|
176
|
+
return ((capitalize)? "D_" : "_") + c.charCodeAt(0);
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
if(c.match(/[^a-zA-Z_0-9]/)){
|
|
180
|
+
return "_" + c.charCodeAt(0);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return c;
|
|
182
185
|
|
|
183
|
-
|
|
186
|
+
}).join("");
|
|
184
187
|
}
|
|
185
188
|
|
|
186
189
|
function canBeUsedAsIsInTypescript(str: string): boolean {
|
|
@@ -190,7 +193,7 @@ function canBeUsedAsIsInTypescript(str: string): boolean {
|
|
|
190
193
|
return Boolean(isAlphaNumericOrUnderline && startsWithCharOrUnderscore);
|
|
191
194
|
}
|
|
192
195
|
|
|
193
|
-
function escapeTSNames(str: string, capitalize = false): string {
|
|
196
|
+
export function escapeTSNames(str: string, capitalize = false): string {
|
|
194
197
|
let res = str;
|
|
195
198
|
res = (capitalize? str[0].toUpperCase() : str[0]) + str.slice(1);
|
|
196
199
|
if(canBeUsedAsIsInTypescript(res)) return res;
|
|
@@ -267,12 +270,12 @@ export type CommonTableRules = {
|
|
|
267
270
|
/**
|
|
268
271
|
* True by default. Allows clients to get column information on any columns that are allowed in (select, insert, update) field rules.
|
|
269
272
|
*/
|
|
270
|
-
getColumns?:
|
|
273
|
+
getColumns?: PublishAllOrNothing;
|
|
271
274
|
|
|
272
275
|
/**
|
|
273
276
|
* True by default. Allows clients to get table information (oid, comment, label, has_media).
|
|
274
277
|
*/
|
|
275
|
-
getInfo?:
|
|
278
|
+
getInfo?: PublishAllOrNothing
|
|
276
279
|
}
|
|
277
280
|
|
|
278
281
|
export type ValidatedTableRules = CommonTableRules & {
|
|
@@ -768,7 +771,13 @@ export class ViewHandler {
|
|
|
768
771
|
|
|
769
772
|
// TODO: fix renamed table trigger problem
|
|
770
773
|
|
|
771
|
-
async getColumns(
|
|
774
|
+
async getColumns(
|
|
775
|
+
lang?: string,
|
|
776
|
+
params?: { rule: "update", filter: AnyObject, data: AnyObject },
|
|
777
|
+
_param3?: never,
|
|
778
|
+
tableRules?: TableRule,
|
|
779
|
+
localParams?: LocalParams
|
|
780
|
+
): Promise<ValidatedColumnInfo[]> {
|
|
772
781
|
|
|
773
782
|
try {
|
|
774
783
|
const p = this.getValidatedRules(tableRules, localParams);
|
|
@@ -803,21 +812,6 @@ export class ViewHandler {
|
|
|
803
812
|
|
|
804
813
|
let label = c.comment || capitalizeFirstLetter(c.name, " ");
|
|
805
814
|
|
|
806
|
-
/**
|
|
807
|
-
* Get labels from TableConfig if specified
|
|
808
|
-
*/
|
|
809
|
-
const tblConfig = this.dboBuilder.prostgles?.opts?.tableConfig?.[this.name];
|
|
810
|
-
if(tblConfig && "columns" in tblConfig){
|
|
811
|
-
const lbl = tblConfig?.columns[c.name]?.label;
|
|
812
|
-
if(["string", "object"].includes(typeof lbl)){
|
|
813
|
-
if(typeof lbl === "string") {
|
|
814
|
-
label = lbl
|
|
815
|
-
} else if(lang) {
|
|
816
|
-
label = (lbl?.[lang as "en"]) || lbl?.en || label;
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
|
|
821
815
|
const select = c.privileges.some(p => p.privilege_type === "SELECT"),
|
|
822
816
|
insert = c.privileges.some(p => p.privilege_type === "INSERT"),
|
|
823
817
|
update = c.privileges.some(p => p.privilege_type === "UPDATE"),
|
|
@@ -833,7 +827,7 @@ export class ViewHandler {
|
|
|
833
827
|
filter: Boolean(p.select && p.select.filterFields && p.select.filterFields.includes(c.name)),
|
|
834
828
|
update: update && Boolean(p.update && p.update.fields && p.update.fields.includes(c.name)),
|
|
835
829
|
delete: _delete && Boolean(p.delete && p.delete.filterFields && p.delete.filterFields.includes(c.name)),
|
|
836
|
-
...(this.dboBuilder?.prostgles?.tableConfigurator?.getColInfo({ table: this.name, col: c.name}) || {})
|
|
830
|
+
...(this.dboBuilder?.prostgles?.tableConfigurator?.getColInfo({ table: this.name, col: c.name, lang }) || {})
|
|
837
831
|
}
|
|
838
832
|
|
|
839
833
|
if(dynamicUpdateFields){
|
|
@@ -2685,7 +2679,7 @@ export class TableHandler extends ViewHandler {
|
|
|
2685
2679
|
}
|
|
2686
2680
|
};
|
|
2687
2681
|
|
|
2688
|
-
prepareReturning = async (returning: Select
|
|
2682
|
+
prepareReturning = async (returning: Select | undefined, allowedFields: string[]): Promise<SelectItem[]> => {
|
|
2689
2683
|
let result: SelectItem[] = [];
|
|
2690
2684
|
if(returning){
|
|
2691
2685
|
let sBuilder = new SelectItemBuilder({
|
|
@@ -2907,6 +2901,7 @@ export class TableHandler extends ViewHandler {
|
|
|
2907
2901
|
|
|
2908
2902
|
import { JOIN_TYPES } from "./Prostgles";
|
|
2909
2903
|
import { BasicSession } from "./AuthHandler";
|
|
2904
|
+
import { getDBSchema } from "./DBSchemaBuilder";
|
|
2910
2905
|
|
|
2911
2906
|
export class DboBuilder {
|
|
2912
2907
|
tablesOrViews?: TableSchema[]; //TableSchema TableOrViewInfo
|
|
@@ -2918,8 +2913,8 @@ export class DboBuilder {
|
|
|
2918
2913
|
db: DB;
|
|
2919
2914
|
schema: string = "public";
|
|
2920
2915
|
|
|
2921
|
-
// dbo:
|
|
2922
|
-
dbo:
|
|
2916
|
+
// dbo: DBHandlerServer | DBHandlerServerTX;
|
|
2917
|
+
dbo: DBHandlerServer;
|
|
2923
2918
|
_pubSubManager?: PubSubManager;
|
|
2924
2919
|
|
|
2925
2920
|
getPubSubManager = async () : Promise<PubSubManager> => {
|
|
@@ -2940,7 +2935,7 @@ export class DboBuilder {
|
|
|
2940
2935
|
this._pubSubManager = await PubSubManager.create({
|
|
2941
2936
|
dboBuilder: this,
|
|
2942
2937
|
db: this.db,
|
|
2943
|
-
dbo: this.dbo as unknown as
|
|
2938
|
+
dbo: this.dbo as unknown as DBHandlerServer,
|
|
2944
2939
|
onSchemaChange
|
|
2945
2940
|
});
|
|
2946
2941
|
} else {
|
|
@@ -2970,7 +2965,7 @@ export class DboBuilder {
|
|
|
2970
2965
|
if(!this.prostgles.db) throw "db missing"
|
|
2971
2966
|
this.db = this.prostgles.db;
|
|
2972
2967
|
this.schema = this.prostgles.opts.schema || "public";
|
|
2973
|
-
this.dbo = { } as unknown as
|
|
2968
|
+
this.dbo = { } as unknown as DBHandlerServer;
|
|
2974
2969
|
// this.joins = this.prostgles.joins;
|
|
2975
2970
|
|
|
2976
2971
|
}
|
|
@@ -3108,7 +3103,7 @@ export class DboBuilder {
|
|
|
3108
3103
|
|
|
3109
3104
|
}
|
|
3110
3105
|
|
|
3111
|
-
async build(): Promise<
|
|
3106
|
+
async build(): Promise<DBHandlerServer>{
|
|
3112
3107
|
|
|
3113
3108
|
// await this.pubSubManager.init()
|
|
3114
3109
|
|
|
@@ -3116,38 +3111,30 @@ export class DboBuilder {
|
|
|
3116
3111
|
// console.log(this.tablesOrViews.map(t => `${t.name} (${t.columns.map(c => c.name).join(", ")})`))
|
|
3117
3112
|
|
|
3118
3113
|
this.constraints = await getConstraints(this.db);
|
|
3114
|
+
await this.parseJoins();
|
|
3119
3115
|
|
|
3120
|
-
|
|
3121
|
-
`
|
|
3116
|
+
// const common_types =
|
|
3117
|
+
// `
|
|
3122
3118
|
|
|
3123
|
-
import { ViewHandler, TableHandler, JoinMaker } from "prostgles-types";
|
|
3119
|
+
// import { ViewHandler, TableHandler, JoinMaker } from "prostgles-types";
|
|
3124
3120
|
|
|
3125
|
-
export type TxCB = {
|
|
3126
|
-
|
|
3127
|
-
};
|
|
3121
|
+
// export type TxCB = {
|
|
3122
|
+
// (t: DBObj): (any | void | Promise<(any | void)>)
|
|
3123
|
+
// };
|
|
3128
3124
|
|
|
3129
|
-
`
|
|
3130
|
-
this.dboDefinition = `export type DBObj = {\n`;
|
|
3125
|
+
// `
|
|
3126
|
+
// this.dboDefinition = `export type DBObj = {\n`;
|
|
3131
3127
|
|
|
3132
|
-
await this.parseJoins();
|
|
3133
3128
|
|
|
3134
|
-
let joinTableNames: string[] = [];
|
|
3129
|
+
// let joinTableNames: string[] = [];
|
|
3135
3130
|
|
|
3136
|
-
let allDataDefs = "";
|
|
3137
|
-
let i18nDef = "type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; }; \n"
|
|
3138
|
-
i18nDef += "export type I18N_DBO_CONFIG<LANG_IDS = { en: 1, fr: 1 }> = { \n";
|
|
3139
|
-
i18nDef += " fallbackLang: keyof LANG_IDS; \n";
|
|
3140
|
-
i18nDef += " column_labels?: DeepPartial<{ \n";
|
|
3131
|
+
// let allDataDefs = "";
|
|
3141
3132
|
|
|
3142
3133
|
|
|
3143
3134
|
|
|
3144
3135
|
this.tablesOrViews.map(tov => {
|
|
3145
3136
|
const columnsForTypes = tov.columns.slice(0).sort((a, b) => a.name.localeCompare(b.name));
|
|
3146
3137
|
|
|
3147
|
-
i18nDef += ` ${escapeTSNames(tov.name)}: { \n`;
|
|
3148
|
-
// i18nDef += ` [key in ${columnsForTypes.map(c => JSON.stringify(c.name)).join(" | ")}]: { [lang_id in keyof LANG_IDS]: string }; \n`;
|
|
3149
|
-
i18nDef += ` [key in keyof ${snakify(tov.name, true)}]: { [lang_id in keyof LANG_IDS]: string }; \n`;
|
|
3150
|
-
i18nDef += ` }; \n`;
|
|
3151
3138
|
|
|
3152
3139
|
const filterKeywords = Object.values(this.prostgles.keywords);
|
|
3153
3140
|
const $filterCol = columnsForTypes.find(c => filterKeywords.includes(c.name));
|
|
@@ -3161,21 +3148,21 @@ export type TxCB = {
|
|
|
3161
3148
|
const TSTableHandlerName = escapeTSNames(tov.name)
|
|
3162
3149
|
if(tov.is_view){
|
|
3163
3150
|
this.dbo[tov.name] = new ViewHandler(this.db, tov, this, undefined, undefined, this.joinPaths);
|
|
3164
|
-
this.dboDefinition += ` ${TSTableHandlerName}: ViewHandler<${TSTableDataName}> \n`;
|
|
3151
|
+
// this.dboDefinition += ` ${TSTableHandlerName}: ViewHandler<${TSTableDataName}> \n`;
|
|
3165
3152
|
} else {
|
|
3166
3153
|
this.dbo[tov.name] = new TableHandler(this.db, tov, this, undefined, undefined, this.joinPaths);
|
|
3167
|
-
this.dboDefinition += ` ${TSTableHandlerName}: TableHandler<${TSTableDataName}> \n`;
|
|
3154
|
+
// this.dboDefinition += ` ${TSTableHandlerName}: TableHandler<${TSTableDataName}> \n`;
|
|
3168
3155
|
}
|
|
3169
|
-
allDataDefs += `export type ${TSTableDataName} = { \n` +
|
|
3170
|
-
|
|
3171
|
-
|
|
3156
|
+
// allDataDefs += `export type ${TSTableDataName} = { \n` +
|
|
3157
|
+
// (this.dbo[tov.name] as ViewHandler).tsColumnDefs.map(str => ` ` + str).join("\n") +
|
|
3158
|
+
// `\n}\n`;
|
|
3172
3159
|
|
|
3173
3160
|
// this.dboDefinition += ` ${escapeTSNames(tov.name, false)}: ${(this.dbo[tov.name] as TableHandler).tsDboName};\n`;
|
|
3174
3161
|
|
|
3175
3162
|
if(this.joinPaths && this.joinPaths.find(jp => [jp.t1, jp.t2].includes(tov.name))){
|
|
3176
3163
|
|
|
3177
3164
|
let table = tov.name;
|
|
3178
|
-
joinTableNames.push(table);
|
|
3165
|
+
// joinTableNames.push(table);
|
|
3179
3166
|
|
|
3180
3167
|
const makeJoin = (
|
|
3181
3168
|
isLeft = true,
|
|
@@ -3208,20 +3195,18 @@ export type TxCB = {
|
|
|
3208
3195
|
}
|
|
3209
3196
|
}
|
|
3210
3197
|
});
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
});
|
|
3224
|
-
}
|
|
3198
|
+
|
|
3199
|
+
// let joinBuilderDef = "";
|
|
3200
|
+
// if(joinTableNames.length){
|
|
3201
|
+
// joinBuilderDef += "export type JoinMakerTables = {\n";
|
|
3202
|
+
// joinTableNames.map(tname => {
|
|
3203
|
+
// joinBuilderDef += ` ${escapeTSNames(tname)}: JoinMaker<${snakify(tname, true)}>;\n`
|
|
3204
|
+
// })
|
|
3205
|
+
// joinBuilderDef += "};\n";
|
|
3206
|
+
// ["leftJoin", "innerJoin", "leftJoinOne", "innerJoinOne"].map(joinType => {
|
|
3207
|
+
// this.dboDefinition += ` ${joinType}: JoinMakerTables;\n`;
|
|
3208
|
+
// });
|
|
3209
|
+
// }
|
|
3225
3210
|
|
|
3226
3211
|
|
|
3227
3212
|
if(this.prostgles.opts.transactions){
|
|
@@ -3339,14 +3324,14 @@ export type TxCB = {
|
|
|
3339
3324
|
this.dboDefinition += "};\n";
|
|
3340
3325
|
|
|
3341
3326
|
this.tsTypesDefinition = [
|
|
3342
|
-
common_types,
|
|
3327
|
+
// common_types,
|
|
3343
3328
|
`/* SCHEMA DEFINITON. Table names have been altered to work with Typescript */`,
|
|
3344
|
-
allDataDefs,
|
|
3345
|
-
joinBuilderDef,
|
|
3329
|
+
// allDataDefs,
|
|
3330
|
+
// joinBuilderDef,
|
|
3346
3331
|
|
|
3347
3332
|
`/* DBO Definition. Isomorphic */`,
|
|
3348
3333
|
this.dboDefinition,
|
|
3349
|
-
|
|
3334
|
+
getDBSchema(this)
|
|
3350
3335
|
].join("\n");
|
|
3351
3336
|
|
|
3352
3337
|
return this.dbo;
|
|
@@ -3381,7 +3366,7 @@ export type TxCB = {
|
|
|
3381
3366
|
|
|
3382
3367
|
|
|
3383
3368
|
|
|
3384
|
-
// export async function makeDBO(db: DB): Promise<
|
|
3369
|
+
// export async function makeDBO(db: DB): Promise<DBHandlerServer> {
|
|
3385
3370
|
// return await DBO.build(db, "public");
|
|
3386
3371
|
// }
|
|
3387
3372
|
|
|
@@ -3585,6 +3570,7 @@ async function getTablesForSchemaPostgresSQL(db: DB, schema: string = "public"):
|
|
|
3585
3570
|
if(col.has_default){
|
|
3586
3571
|
col.column_default = (col.udt_name !== "uuid" && !col.is_pkey && !col.column_default.startsWith("nextval("))? col.column_default : null;
|
|
3587
3572
|
}
|
|
3573
|
+
|
|
3588
3574
|
return col;
|
|
3589
3575
|
|
|
3590
3576
|
})//.slice(0).sort((a, b) => a.name.localeCompare(b.name))
|
package/lib/FileManager.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as fs from 'fs';
|
|
|
6
6
|
import * as FileType from "file-type";
|
|
7
7
|
import * as sharp from "sharp";
|
|
8
8
|
|
|
9
|
-
import { DB,
|
|
9
|
+
import { DB, DBHandlerServer, Prostgles } from './Prostgles';
|
|
10
10
|
import { asName, getKeys } from 'prostgles-types';
|
|
11
11
|
import { TableHandler } from './DboBuilder';
|
|
12
12
|
|
|
@@ -71,7 +71,7 @@ export default class FileManager {
|
|
|
71
71
|
imageOptions?: ImageOptions;
|
|
72
72
|
|
|
73
73
|
prostgles?: Prostgles;
|
|
74
|
-
get dbo():
|
|
74
|
+
get dbo(): DBHandlerServer {
|
|
75
75
|
if(!this.prostgles?.dbo) throw "this.prostgles.dbo missing"
|
|
76
76
|
return this.prostgles.dbo
|
|
77
77
|
};
|
package/lib/Filtering.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { SelectItem } from "./QueryBuilder";
|
|
4
|
-
import { isEmpty, getKeys, FullFilter, EXISTS_KEYS, FilterDataType, GeomFilterKeys, GeomFilter_Funcs, TextFilter_FullTextSearchFilterKeys
|
|
4
|
+
import { isEmpty, getKeys, FullFilter, EXISTS_KEYS, FilterDataType, GeomFilterKeys, GeomFilter_Funcs, TextFilter_FullTextSearchFilterKeys } from "prostgles-types";
|
|
5
5
|
import { isPlainObject } from "./DboBuilder";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -200,7 +200,7 @@ export const parseFilterItem = (args: ParseFilterItemArgs): string => {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/** st_makeenvelope */
|
|
203
|
-
if(GeomFilterKeys.includes(fOpType) && sOpType && GeomFilter_Funcs.includes(sOpType)){
|
|
203
|
+
if(GeomFilterKeys.includes(fOpType as any) && sOpType && GeomFilter_Funcs.includes(sOpType)){
|
|
204
204
|
/** If leftQ is geography then this err can happen: 'Antipodal (180 degrees long) edge detected!' */
|
|
205
205
|
if(sOpType.toLowerCase() === "st_makeenvelope") leftQ += "::geometry"
|
|
206
206
|
return leftQ + ` ${fOpType} ` + `${sOpType}${parseRightVal(sVal, "csv")}`;
|
|
@@ -277,7 +277,7 @@ export const parseFilterItem = (args: ParseFilterItemArgs): string => {
|
|
|
277
277
|
return leftQ + operand + parseRightVal(fVal, "array");
|
|
278
278
|
|
|
279
279
|
/* FTSQuery */
|
|
280
|
-
} else if(["@@"].includes(fOpType) && TextFilter_FullTextSearchFilterKeys.includes(sOpType!)) {
|
|
280
|
+
} else if(["@@"].includes(fOpType) && TextFilter_FullTextSearchFilterKeys.includes(sOpType! as any)) {
|
|
281
281
|
let lq = `to_tsvector(${leftQ}::text)`;
|
|
282
282
|
if(selItem && selItem.columnPGDataType === "tsvector") lq = leftQ!;
|
|
283
283
|
|