prostgles-server 2.0.172 → 2.0.175

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.
Files changed (64) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/dist/AuthHandler.d.ts +13 -12
  3. package/dist/AuthHandler.d.ts.map +1 -1
  4. package/dist/AuthHandler.js +5 -2
  5. package/dist/AuthHandler.js.map +1 -1
  6. package/dist/DBSchemaBuilder.d.ts +11 -0
  7. package/dist/DBSchemaBuilder.d.ts.map +1 -0
  8. package/dist/DBSchemaBuilder.js +56 -0
  9. package/dist/DBSchemaBuilder.js.map +1 -0
  10. package/dist/DboBuilder.d.ts +24 -23
  11. package/dist/DboBuilder.d.ts.map +1 -1
  12. package/dist/DboBuilder.js +48 -63
  13. package/dist/DboBuilder.js.map +1 -1
  14. package/dist/FileManager.d.ts +2 -2
  15. package/dist/FileManager.d.ts.map +1 -1
  16. package/dist/Filtering.d.ts.map +1 -1
  17. package/dist/Filtering.js.map +1 -1
  18. package/dist/Prostgles.d.ts +25 -257
  19. package/dist/Prostgles.d.ts.map +1 -1
  20. package/dist/Prostgles.js +12 -376
  21. package/dist/Prostgles.js.map +1 -1
  22. package/dist/PubSubManager.d.ts +6 -5
  23. package/dist/PubSubManager.d.ts.map +1 -1
  24. package/dist/PubSubManager.js.map +1 -1
  25. package/dist/PublishParser.d.ts +262 -0
  26. package/dist/PublishParser.d.ts.map +1 -0
  27. package/dist/PublishParser.js +391 -0
  28. package/dist/PublishParser.js.map +1 -0
  29. package/dist/QueryBuilder.d.ts +20 -4
  30. package/dist/QueryBuilder.d.ts.map +1 -1
  31. package/dist/QueryBuilder.js.map +1 -1
  32. package/dist/TableConfig.d.ts +6 -3
  33. package/dist/TableConfig.d.ts.map +1 -1
  34. package/dist/TableConfig.js +28 -1
  35. package/dist/TableConfig.js.map +1 -1
  36. package/dist/index.d.ts +3 -3
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +4 -0
  39. package/dist/index.js.map +1 -1
  40. package/lib/AuthHandler.ts +25 -19
  41. package/lib/DBSchemaBuilder.ts +91 -0
  42. package/lib/DboBuilder.ts +94 -99
  43. package/lib/FileManager.ts +2 -2
  44. package/lib/Filtering.ts +3 -3
  45. package/lib/Prostgles.ts +33 -704
  46. package/lib/PubSubManager.ts +6 -5
  47. package/lib/PublishParser.ts +723 -0
  48. package/lib/QueryBuilder.ts +6 -5
  49. package/lib/TableConfig.ts +36 -5
  50. package/lib/index.ts +4 -4
  51. package/package.json +2 -2
  52. package/tests/client/PID.txt +1 -1
  53. package/tests/client/index.js +2 -2
  54. package/tests/client/index.ts +2 -2
  55. package/tests/client/package-lock.json +15 -15
  56. package/tests/client/package.json +1 -1
  57. package/tests/client_only_queries.js +24 -1
  58. package/tests/client_only_queries.ts +23 -1
  59. package/tests/isomorphic_queries.js +3 -0
  60. package/tests/isomorphic_queries.ts +5 -2
  61. package/tests/server/DBoGenerated.d.ts +428 -286
  62. package/tests/server/index.js +1 -14
  63. package/tests/server/index.ts +5 -19
  64. 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 interface TxHandler {
46
- [key: string]: TableHandler | ViewHandler;
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 TxCB = {
49
- (t: TxHandler, _t: pgPromise.ITask<{}>): (any | void);
49
+ export type TX<DBO extends TablesAndViewHandlers = TablesAndViewHandlers> = {
50
+ (t: TxCB<DBO>): Promise<(any | void)>;
50
51
  }
51
- export type TX = {
52
- (t: TxCB): Promise<(any | void)>;
52
+
53
+ type TablesAndViewHandlers = {
54
+ [key: string]: Partial<TableHandler> | TableHandler;
53
55
  }
54
- export type DbHandler = {
55
- [key: string]: Partial<TableHandler>;
56
- } &
57
- DbJoinMaker &
58
- {
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
- DB, TableRule, SelectRule, InsertRule, UpdateRule, DeleteRule, SyncRule, Joins, Join, Prostgles, PublishParser, ValidateRow, ValidateUpdateRow
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?: DbHandler;
152
+ localDBTX?: DBHandlerServer;
150
153
 
151
154
  returnQuery?: boolean;
152
155
 
@@ -165,27 +168,35 @@ function capitalizeFirstLetter(string: string, nonalpha_replacement?: string) :
165
168
 
166
169
  function snakify(str: string, capitalize = false) : string {
167
170
 
168
- return str.split("").map((c, i)=> {
171
+ return str.split("").map((c, i)=> {
169
172
 
170
- if(!i) {
171
- if(capitalize) c = c.toUpperCase();
172
- if(c.match(/[^a-z_A-Z]/)){
173
- return ((capitalize)? "D_" : "_") + c.charCodeAt(0);
174
- }
175
- } else {
176
- if(c.match(/[^a-zA-Z_0-9]/)){
177
- return "_" + c.charCodeAt(0);
178
- }
179
- }
180
-
181
- return c;
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;
185
+
186
+ }).join("");
187
+ }
182
188
 
183
- }).join("");
189
+ function canBeUsedAsIsInTypescript(str: string): boolean {
190
+ if(!str) return false;
191
+ const isAlphaNumericOrUnderline = str.match(/^[a-z0-9_]+$/i);
192
+ const startsWithCharOrUnderscore = str[0].match(/^[a-z_]+$/i);
193
+ return Boolean(isAlphaNumericOrUnderline && startsWithCharOrUnderscore);
184
194
  }
185
195
 
186
- function escapeTSNames(str: string, capitalize = true): string {
196
+ export function escapeTSNames(str: string, capitalize = false): string {
187
197
  let res = str;
188
198
  res = (capitalize? str[0].toUpperCase() : str[0]) + str.slice(1);
199
+ if(canBeUsedAsIsInTypescript(res)) return res;
189
200
  return JSON.stringify(res);
190
201
  }
191
202
 
@@ -259,12 +270,12 @@ export type CommonTableRules = {
259
270
  /**
260
271
  * True by default. Allows clients to get column information on any columns that are allowed in (select, insert, update) field rules.
261
272
  */
262
- getColumns?: boolean;
273
+ getColumns?: PublishAllOrNothing;
263
274
 
264
275
  /**
265
276
  * True by default. Allows clients to get table information (oid, comment, label, has_media).
266
277
  */
267
- getInfo?: boolean | null;
278
+ getInfo?: PublishAllOrNothing
268
279
  }
269
280
 
270
281
  export type ValidatedTableRules = CommonTableRules & {
@@ -509,7 +520,7 @@ export class ViewHandler {
509
520
  // if(this.tsDataName === "T") this.tsDataName = this.tsDataName + "_";
510
521
  // this.tsDataDef = `export type ${this.tsDataName} = {\n`;
511
522
  this.columnsForTypes.map(({ name, udt_name, is_nullable }) => {
512
- this.tsColumnDefs.push(`${escapeTSNames(name, false)}?: ${postgresToTsType(udt_name) as string} ${is_nullable? " | null " : ""};`);
523
+ this.tsColumnDefs.push(`${escapeTSNames(name)}?: ${postgresToTsType(udt_name) as string} ${is_nullable? " | null " : ""};`);
513
524
  });
514
525
  // this.tsDataDef += "};";
515
526
  // this.tsDataDef += "\n";
@@ -760,7 +771,13 @@ export class ViewHandler {
760
771
 
761
772
  // TODO: fix renamed table trigger problem
762
773
 
763
- async getColumns(lang?: string, params?: { rule: "update", filter: AnyObject, data: AnyObject }, param3?: never, tableRules?: TableRule, localParams?: LocalParams): Promise<ValidatedColumnInfo[]> {
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[]> {
764
781
 
765
782
  try {
766
783
  const p = this.getValidatedRules(tableRules, localParams);
@@ -795,21 +812,6 @@ export class ViewHandler {
795
812
 
796
813
  let label = c.comment || capitalizeFirstLetter(c.name, " ");
797
814
 
798
- /**
799
- * Get labels from TableConfig if specified
800
- */
801
- const tblConfig = this.dboBuilder.prostgles?.opts?.tableConfig?.[this.name];
802
- if(tblConfig && "columns" in tblConfig){
803
- const lbl = tblConfig?.columns[c.name]?.label;
804
- if(["string", "object"].includes(typeof lbl)){
805
- if(typeof lbl === "string") {
806
- label = lbl
807
- } else if(lang) {
808
- label = (lbl?.[lang as "en"]) || lbl?.en || label;
809
- }
810
- }
811
- }
812
-
813
815
  const select = c.privileges.some(p => p.privilege_type === "SELECT"),
814
816
  insert = c.privileges.some(p => p.privilege_type === "INSERT"),
815
817
  update = c.privileges.some(p => p.privilege_type === "UPDATE"),
@@ -825,7 +827,7 @@ export class ViewHandler {
825
827
  filter: Boolean(p.select && p.select.filterFields && p.select.filterFields.includes(c.name)),
826
828
  update: update && Boolean(p.update && p.update.fields && p.update.fields.includes(c.name)),
827
829
  delete: _delete && Boolean(p.delete && p.delete.filterFields && p.delete.filterFields.includes(c.name)),
828
- ...(this.dboBuilder?.prostgles?.tableConfigurator?.getColInfo({ table: this.name, col: c.name}) || {})
830
+ ...(this.dboBuilder?.prostgles?.tableConfigurator?.getColInfo({ table: this.name, col: c.name, lang }) || {})
829
831
  }
830
832
 
831
833
  if(dynamicUpdateFields){
@@ -2677,7 +2679,7 @@ export class TableHandler extends ViewHandler {
2677
2679
  }
2678
2680
  };
2679
2681
 
2680
- prepareReturning = async (returning: Select<AnyObject>, allowedFields: string[]): Promise<SelectItem[]> => {
2682
+ prepareReturning = async (returning: Select | undefined, allowedFields: string[]): Promise<SelectItem[]> => {
2681
2683
  let result: SelectItem[] = [];
2682
2684
  if(returning){
2683
2685
  let sBuilder = new SelectItemBuilder({
@@ -2899,6 +2901,7 @@ export class TableHandler extends ViewHandler {
2899
2901
 
2900
2902
  import { JOIN_TYPES } from "./Prostgles";
2901
2903
  import { BasicSession } from "./AuthHandler";
2904
+ import { getDBSchema } from "./DBSchemaBuilder";
2902
2905
 
2903
2906
  export class DboBuilder {
2904
2907
  tablesOrViews?: TableSchema[]; //TableSchema TableOrViewInfo
@@ -2910,8 +2913,8 @@ export class DboBuilder {
2910
2913
  db: DB;
2911
2914
  schema: string = "public";
2912
2915
 
2913
- // dbo: DbHandler | DbHandlerTX;
2914
- dbo: DbHandler;
2916
+ // dbo: DBHandlerServer | DBHandlerServerTX;
2917
+ dbo: DBHandlerServer;
2915
2918
  _pubSubManager?: PubSubManager;
2916
2919
 
2917
2920
  getPubSubManager = async () : Promise<PubSubManager> => {
@@ -2932,7 +2935,7 @@ export class DboBuilder {
2932
2935
  this._pubSubManager = await PubSubManager.create({
2933
2936
  dboBuilder: this,
2934
2937
  db: this.db,
2935
- dbo: this.dbo as unknown as DbHandler,
2938
+ dbo: this.dbo as unknown as DBHandlerServer,
2936
2939
  onSchemaChange
2937
2940
  });
2938
2941
  } else {
@@ -2962,7 +2965,7 @@ export class DboBuilder {
2962
2965
  if(!this.prostgles.db) throw "db missing"
2963
2966
  this.db = this.prostgles.db;
2964
2967
  this.schema = this.prostgles.opts.schema || "public";
2965
- this.dbo = { } as unknown as DbHandler;
2968
+ this.dbo = { } as unknown as DBHandlerServer;
2966
2969
  // this.joins = this.prostgles.joins;
2967
2970
 
2968
2971
  }
@@ -3100,7 +3103,7 @@ export class DboBuilder {
3100
3103
 
3101
3104
  }
3102
3105
 
3103
- async build(): Promise<DbHandler>{
3106
+ async build(): Promise<DBHandlerServer>{
3104
3107
 
3105
3108
  // await this.pubSubManager.init()
3106
3109
 
@@ -3108,37 +3111,30 @@ export class DboBuilder {
3108
3111
  // console.log(this.tablesOrViews.map(t => `${t.name} (${t.columns.map(c => c.name).join(", ")})`))
3109
3112
 
3110
3113
  this.constraints = await getConstraints(this.db);
3114
+ await this.parseJoins();
3111
3115
 
3112
- const common_types =
3113
- `
3116
+ // const common_types =
3117
+ // `
3114
3118
 
3115
- import { ViewHandler, TableHandler, JoinMaker } from "prostgles-types";
3119
+ // import { ViewHandler, TableHandler, JoinMaker } from "prostgles-types";
3116
3120
 
3117
- export type TxCB = {
3118
- (t: DBObj): (any | void | Promise<(any | void)>)
3119
- };
3121
+ // export type TxCB = {
3122
+ // (t: DBObj): (any | void | Promise<(any | void)>)
3123
+ // };
3120
3124
 
3121
- `
3122
- this.dboDefinition = `export type DBObj = {\n`;
3125
+ // `
3126
+ // this.dboDefinition = `export type DBObj = {\n`;
3123
3127
 
3124
- await this.parseJoins();
3125
3128
 
3126
- let joinTableNames: string[] = [];
3129
+ // let joinTableNames: string[] = [];
3127
3130
 
3128
- let allDataDefs = "";
3129
- let i18nDef = "type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; }; \n"
3130
- i18nDef += "export type I18N_DBO_CONFIG<LANG_IDS = { en: 1, fr: 1 }> = { \n";
3131
- i18nDef += " fallbackLang: keyof LANG_IDS; \n";
3132
- i18nDef += " column_labels?: DeepPartial<{ \n";
3131
+ // let allDataDefs = "";
3133
3132
 
3134
3133
 
3135
3134
 
3136
3135
  this.tablesOrViews.map(tov => {
3137
3136
  const columnsForTypes = tov.columns.slice(0).sort((a, b) => a.name.localeCompare(b.name));
3138
3137
 
3139
- i18nDef += ` ${JSON.stringify(tov.name)}: { \n`;
3140
- i18nDef += ` [key in ${columnsForTypes.map(c => JSON.stringify(c.name)).join(" | ")}]: { [lang_id in keyof LANG_IDS]: string }; \n`;
3141
- i18nDef += ` }; \n`;
3142
3138
 
3143
3139
  const filterKeywords = Object.values(this.prostgles.keywords);
3144
3140
  const $filterCol = columnsForTypes.find(c => filterKeywords.includes(c.name));
@@ -3149,24 +3145,24 @@ export type TxCB = {
3149
3145
  }
3150
3146
 
3151
3147
  const TSTableDataName = snakify(tov.name, true);
3152
- const TSTableHandlerName = JSON.stringify(tov.name)
3148
+ const TSTableHandlerName = escapeTSNames(tov.name)
3153
3149
  if(tov.is_view){
3154
3150
  this.dbo[tov.name] = new ViewHandler(this.db, tov, this, undefined, undefined, this.joinPaths);
3155
- this.dboDefinition += ` ${TSTableHandlerName}: ViewHandler<${TSTableDataName}> \n`;
3151
+ // this.dboDefinition += ` ${TSTableHandlerName}: ViewHandler<${TSTableDataName}> \n`;
3156
3152
  } else {
3157
3153
  this.dbo[tov.name] = new TableHandler(this.db, tov, this, undefined, undefined, this.joinPaths);
3158
- this.dboDefinition += ` ${TSTableHandlerName}: TableHandler<${TSTableDataName}> \n`;
3154
+ // this.dboDefinition += ` ${TSTableHandlerName}: TableHandler<${TSTableDataName}> \n`;
3159
3155
  }
3160
- allDataDefs += `export type ${TSTableDataName} = { \n` +
3161
- (this.dbo[tov.name] as ViewHandler).tsColumnDefs.map(str => ` ` + str).join("\n") +
3162
- `\n}\n`;
3156
+ // allDataDefs += `export type ${TSTableDataName} = { \n` +
3157
+ // (this.dbo[tov.name] as ViewHandler).tsColumnDefs.map(str => ` ` + str).join("\n") +
3158
+ // `\n}\n`;
3163
3159
 
3164
3160
  // this.dboDefinition += ` ${escapeTSNames(tov.name, false)}: ${(this.dbo[tov.name] as TableHandler).tsDboName};\n`;
3165
3161
 
3166
3162
  if(this.joinPaths && this.joinPaths.find(jp => [jp.t1, jp.t2].includes(tov.name))){
3167
3163
 
3168
3164
  let table = tov.name;
3169
- joinTableNames.push(table);
3165
+ // joinTableNames.push(table);
3170
3166
 
3171
3167
  const makeJoin = (
3172
3168
  isLeft = true,
@@ -3199,20 +3195,18 @@ export type TxCB = {
3199
3195
  }
3200
3196
  }
3201
3197
  });
3202
- i18nDef += " }> \n";
3203
- i18nDef += "} \n";
3204
-
3205
- let joinBuilderDef = "";
3206
- if(joinTableNames.length){
3207
- joinBuilderDef += "export type JoinMakerTables = {\n";
3208
- joinTableNames.map(tname => {
3209
- joinBuilderDef += ` ${JSON.stringify(tname)}: JoinMaker<${snakify(tname, true)}>;\n`
3210
- })
3211
- joinBuilderDef += "};\n";
3212
- ["leftJoin", "innerJoin", "leftJoinOne", "innerJoinOne"].map(joinType => {
3213
- this.dboDefinition += ` ${joinType}: JoinMakerTables;\n`;
3214
- });
3215
- }
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
+ // }
3216
3210
 
3217
3211
 
3218
3212
  if(this.prostgles.opts.transactions){
@@ -3330,14 +3324,14 @@ export type TxCB = {
3330
3324
  this.dboDefinition += "};\n";
3331
3325
 
3332
3326
  this.tsTypesDefinition = [
3333
- common_types,
3327
+ // common_types,
3334
3328
  `/* SCHEMA DEFINITON. Table names have been altered to work with Typescript */`,
3335
- allDataDefs,
3336
- joinBuilderDef,
3329
+ // allDataDefs,
3330
+ // joinBuilderDef,
3337
3331
 
3338
3332
  `/* DBO Definition. Isomorphic */`,
3339
3333
  this.dboDefinition,
3340
- i18nDef,
3334
+ getDBSchema(this)
3341
3335
  ].join("\n");
3342
3336
 
3343
3337
  return this.dbo;
@@ -3372,7 +3366,7 @@ export type TxCB = {
3372
3366
 
3373
3367
 
3374
3368
 
3375
- // export async function makeDBO(db: DB): Promise<DbHandler> {
3369
+ // export async function makeDBO(db: DB): Promise<DBHandlerServer> {
3376
3370
  // return await DBO.build(db, "public");
3377
3371
  // }
3378
3372
 
@@ -3576,6 +3570,7 @@ async function getTablesForSchemaPostgresSQL(db: DB, schema: string = "public"):
3576
3570
  if(col.has_default){
3577
3571
  col.column_default = (col.udt_name !== "uuid" && !col.is_pkey && !col.column_default.startsWith("nextval("))? col.column_default : null;
3578
3572
  }
3573
+
3579
3574
  return col;
3580
3575
 
3581
3576
  })//.slice(0).sort((a, b) => a.name.localeCompare(b.name))
@@ -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, DbHandler, Prostgles } from './Prostgles';
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(): DbHandler {
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, ColumnInfo } from "prostgles-types";
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