prostgles-server 2.0.17 → 2.0.21

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/lib/DboBuilder.ts CHANGED
@@ -2909,7 +2909,7 @@ export type TxCB = {
2909
2909
 
2910
2910
 
2911
2911
  /* UTILS */
2912
- function getTablesForSchemaPostgresSQL(db: DB, schema: string = "public"): Promise<{
2912
+ export type TableSchema = {
2913
2913
  schema: string;
2914
2914
  name: string;
2915
2915
  oid: number;
@@ -2917,7 +2917,8 @@ function getTablesForSchemaPostgresSQL(db: DB, schema: string = "public"): Promi
2917
2917
  columns: ColumnInfo[];
2918
2918
  is_view: boolean;
2919
2919
  parent_tables: string[];
2920
- }[]>{
2920
+ }
2921
+ async function getTablesForSchemaPostgresSQL(db: DB, schema: string = "public"): Promise<TableSchema[]>{
2921
2922
  const query =
2922
2923
  `
2923
2924
  SELECT t.table_schema as schema, t.table_name as name
@@ -2933,7 +2934,8 @@ function getTablesForSchemaPostgresSQL(db: DB, schema: string = "public"): Promi
2933
2934
  cc.ordinal_position,
2934
2935
  cc.is_nullable = 'YES' as is_nullable,
2935
2936
  cc.references,
2936
- cc.has_default
2937
+ cc.has_default,
2938
+ cc.column_default
2937
2939
  ) as x) ORDER BY cc.ordinal_position ) as columns
2938
2940
 
2939
2941
  , t.table_type = 'VIEW' as is_view
@@ -2954,6 +2956,7 @@ function getTablesForSchemaPostgresSQL(db: DB, schema: string = "public"): Promi
2954
2956
  ) as is_pkey
2955
2957
  , c.ordinal_position
2956
2958
  , c.column_default IS NOT NULL as has_default
2959
+ , c.column_default
2957
2960
  , format('%I.%I', c.table_schema, c.table_name)::regclass::oid AS table_oid
2958
2961
  , c.is_nullable
2959
2962
  FROM information_schema.columns c
@@ -2998,7 +3001,30 @@ function getTablesForSchemaPostgresSQL(db: DB, schema: string = "public"): Promi
2998
3001
  ORDER BY schema, name
2999
3002
  `;
3000
3003
  // console.log(pgp.as.format(query, { schema }), schema);
3001
- return db.any(query, { schema });
3004
+ let res: TableSchema[] = await db.any(query, { schema });
3005
+
3006
+ // res = await Promise.all(res.map(async tbl => {
3007
+ // tbl.columns = await Promise.all(tbl.columns.map(async col => {
3008
+ // if(col.has_default){
3009
+ // col.column_default = !col.column_default.startsWith("nextval(")? (await db.oneOrNone(`SELECT ${col.column_default} as val`)).val : null;
3010
+ // }
3011
+ // return col;
3012
+ // }))
3013
+
3014
+ // return tbl;
3015
+ // }))
3016
+ res = res.map(tbl => {
3017
+ tbl.columns = tbl.columns.map(col => {
3018
+ if(col.has_default){
3019
+ col.column_default = (col.udt_name !== "uuid" && !col.is_pkey && !col.column_default.startsWith("nextval("))? col.column_default : null;
3020
+ }
3021
+ return col;
3022
+ })
3023
+
3024
+ return tbl;
3025
+ })
3026
+
3027
+ return res;
3002
3028
  }
3003
3029
 
3004
3030
  /**
@@ -2,6 +2,7 @@ import { AnyObject, asName } from "prostgles-types";
2
2
  import { LocalParams } from "./DboBuilder";
3
3
  import { asSQLIdentifier } from "./FileManager";
4
4
  import { DB, DbHandler, Prostgles } from "./Prostgles";
5
+ import { asValue } from "./PubSubManager";
5
6
 
6
7
  type ColExtraInfo = {
7
8
  min?: string | number;
@@ -26,6 +27,7 @@ export type TableConfig<LANG_IDS = { en: 1, ro: 1 }> = {
26
27
  */
27
28
  lookupValues?: {
28
29
  nullable?: boolean;
30
+ firstValueAsDefault?: boolean;
29
31
  values: {
30
32
  id: string;
31
33
  i18n?: {
@@ -78,11 +80,11 @@ export default class TableConfigurator {
78
80
 
79
81
  await Promise.all(Object.keys(tConf).map(async colName => {
80
82
  const colConf = tConf[colName];
81
- const lookupConf = colConf.lookupValues;
82
- const rows = lookupConf?.values;
83
- if(rows?.length){
83
+ const { firstValueAsDefault, values, nullable } = colConf.lookupValues || {}
84
+
85
+ if(values?.length){
84
86
 
85
- const keys = Object.keys(rows?.[0]?.i18n || {})
87
+ const keys = Object.keys(values[0]?.i18n || {})
86
88
  const lookup_table_name = await asSQLIdentifier(`lookup_${tableName}_${colName}`, this.db)
87
89
  // const lookup_table_name = asName(`lookup_${tableName}_${colName}`);
88
90
 
@@ -92,7 +94,12 @@ export default class TableConfigurator {
92
94
  )`);
93
95
 
94
96
  if(!tCols.find(c => c.name === colName)){
95
- await this.db.any(`ALTER TABLE ${asName(tableName)} ADD COLUMN ${asName(colName)} TEXT ${!lookupConf.nullable? " NOT NULL " : ""} REFERENCES ${lookup_table_name} (id)`)
97
+ await this.db.any(`
98
+ ALTER TABLE ${asName(tableName)}
99
+ ADD COLUMN ${asName(colName)} TEXT ${!nullable? " NOT NULL " : ""}
100
+ ${firstValueAsDefault? ` DEFAULT ${asValue(values[0].id)} ` : "" }
101
+ REFERENCES ${lookup_table_name} (id)
102
+ `)
96
103
  };
97
104
 
98
105
  await this.prostgles.refreshDBO();
@@ -105,7 +112,7 @@ export default class TableConfigurator {
105
112
  }
106
113
 
107
114
  await this.dbo[lookup_table_name].insert(
108
- rows.map(r => ({ id: r.id, ...r.i18n })),
115
+ values.map(r => ({ id: r.id, ...r.i18n })),
109
116
  { onConflictDoNothing: true }
110
117
  );
111
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "2.0.17",
3
+ "version": "2.0.21",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "bluebird": "^3.7.2",
30
30
  "file-type": "^16.5.3",
31
31
  "pg-promise": "^10.9.5",
32
- "prostgles-types": "^1.5.103",
32
+ "prostgles-types": "^1.5.104",
33
33
  "sharp": "^0.29.1"
34
34
  },
35
35
  "devDependencies": {
@@ -72,7 +72,6 @@ export type Items4_pub = {
72
72
  export type Items_m1 = {
73
73
  "id"?: number;
74
74
  "name"?: string;
75
- "name_type"?: string;
76
75
  }
77
76
  export type Items_with_media = {
78
77
  "id"?: number;
@@ -222,7 +221,6 @@ export type JoinMakerTables = {
222
221
  "items_with_media": JoinMaker<Items_with_media>;
223
222
  "items_with_one_media": JoinMaker<Items_with_one_media>;
224
223
  "lookup_experience_types": JoinMaker<Lookup_experience_types>;
225
- "lookup_items_m1_name_type": JoinMaker<Lookup_items_m1_name_type>;
226
224
  "lookup_status": JoinMaker<Lookup_status>;
227
225
  "media": JoinMaker<Media>;
228
226
  "prostgles_lookup_media_items_m1": JoinMaker<Prostgles_lookup_media_items_m1>;
@@ -327,7 +325,7 @@ export type I18N_DBO_CONFIG<LANG_IDS = { en: 1, fr: 1 }> = {
327
325
  [key in "id" | "public" | "name" | "added"]: { [lang_id in keyof LANG_IDS]: string };
328
326
  };
329
327
  "items_m1": {
330
- [key in "id" | "name" | "name_type"]: { [lang_id in keyof LANG_IDS]: string };
328
+ [key in "id" | "name"]: { [lang_id in keyof LANG_IDS]: string };
331
329
  };
332
330
  "items_with_media": {
333
331
  [key in "id" | "name"]: { [lang_id in keyof LANG_IDS]: string };
@@ -110,13 +110,12 @@ const log = (msg, extra) => {
110
110
  },
111
111
  transactions: true,
112
112
  tableConfig: {
113
- items_m1: {
114
- lookupColumns: {
115
- name_type: {
116
- values: [
117
- { id: "type 1", i18n: { en: "hehe", ro: "hihi" } },
118
- { id: "type 2" }
119
- ]
113
+ uuid_text: {
114
+ name: {
115
+ info: {
116
+ min: 1,
117
+ max: 3,
118
+ hint: "hiint"
120
119
  }
121
120
  }
122
121
  }
@@ -152,10 +151,7 @@ const log = (msg, extra) => {
152
151
  // console.log(await await db.items_with_one_media.find())
153
152
  // console.log(await await db.media.find());
154
153
  // throw items_with_one_media;
155
- const r = await db.uuid_text.insert({ id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' }, { returning: "*" });
156
- await db.uuid_text.update({ id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' }, { id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' });
157
- console.log(await db.uuid_text.find({ "id.$ilike": 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' }));
158
- throw r;
154
+ console.log(await db.uuid_text.getColumns());
159
155
  }
160
156
  catch (e) {
161
157
  console.error(e);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAEA,eAAe;AACf,gDAAwB;AACxB,sDAA8B;AAC9B,wEAAyC;AAEzC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;IAC7C,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAC;AAEH,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AACtB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AACxB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAChD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AACrC,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE;IACpC,IAAI,EAAE,UAAU;IAChB,mCAAmC;CACpC,CAAC,CAAC;AACH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;AAEvC,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,KAAW,EAAE,EAAE;IACvC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAA;AAMD,8BAA8B;AAC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aAE7C;YAAC,OAAM,CAAC,EAAC;gBACR,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;QAEH,CAAC,EAAE,IAAI,CAAC,CAAA;QAER,oBAAoB;QACpB,sBAAsB;QACtB,sCAAsC;QACtC,KAAK;QAEL,IAAI;SAEH;QAAC,OAAM,CAAC,EAAE;YACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;SACjB;IACH,CAAC;CACF,CAAC,CAAC"}
@@ -117,16 +117,13 @@ prostgles<DBObj>({
117
117
  },
118
118
  transactions: true,
119
119
  tableConfig: {
120
- items_m1: {
121
- lookupColumns:{
122
-
123
- name_type: {
124
- values: [
125
- { id: "type 1", i18n: { en: "hehe", ro: "hihi" } },
126
- { id: "type 2" }
127
- ]
120
+ uuid_text: {
121
+ name: {
122
+ info: {
123
+ min: 1,
124
+ max: 3,
125
+ hint: "hiint"
128
126
  }
129
-
130
127
  }
131
128
  }
132
129
  },
@@ -172,12 +169,7 @@ prostgles<DBObj>({
172
169
 
173
170
  // throw items_with_one_media;
174
171
 
175
- const r = await db.uuid_text.insert({id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' }, { returning: "*"});
176
- await db.uuid_text.update({ id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e'}, { id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e'});
177
- console.log(
178
- await db.uuid_text.find({ "id.$ilike": 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e' })
179
- )
180
- throw r;
172
+ console.log(await db.uuid_text.getColumns())
181
173
 
182
174
  } catch(e){
183
175
  console.error(e)
@@ -84,6 +84,7 @@ async function isomorphic(db) {
84
84
  "element_type": null,
85
85
  "element_udt_name": null,
86
86
  "is_pkey": true,
87
+ "column_default": null,
87
88
  "comment": null,
88
89
  "ordinal_position": 1,
89
90
  "is_nullable": false,
@@ -104,6 +105,7 @@ async function isomorphic(db) {
104
105
  "element_type": null,
105
106
  "element_udt_name": null,
106
107
  "is_pkey": false,
108
+ "column_default": null,
107
109
  "comment": null,
108
110
  "ordinal_position": 2,
109
111
  "is_nullable": true,
@@ -132,6 +134,7 @@ async function isomorphic(db) {
132
134
  "element_type": null,
133
135
  "element_udt_name": null,
134
136
  "is_pkey": false,
137
+ "column_default": null,
135
138
  "comment": null,
136
139
  "ordinal_position": 3,
137
140
  "is_nullable": true,
@@ -152,6 +155,7 @@ async function isomorphic(db) {
152
155
  "element_type": null,
153
156
  "element_udt_name": null,
154
157
  "is_pkey": false,
158
+ "column_default": null,
155
159
  "comment": null,
156
160
  "ordinal_position": 4,
157
161
  "is_nullable": true,
@@ -77,6 +77,7 @@ export default async function isomorphic(db: Partial<DbHandler> | Partial<DBHand
77
77
  "element_type": null,
78
78
  "element_udt_name": null,
79
79
  "is_pkey": true,
80
+ "column_default": null,
80
81
  "comment": null,
81
82
  "ordinal_position": 1,
82
83
  "is_nullable": false,
@@ -97,6 +98,7 @@ export default async function isomorphic(db: Partial<DbHandler> | Partial<DBHand
97
98
  "element_type": null,
98
99
  "element_udt_name": null,
99
100
  "is_pkey": false,
101
+ "column_default": null,
100
102
  "comment": null,
101
103
  "ordinal_position": 2,
102
104
  "is_nullable": true,
@@ -125,6 +127,7 @@ export default async function isomorphic(db: Partial<DbHandler> | Partial<DBHand
125
127
  "element_type": null,
126
128
  "element_udt_name": null,
127
129
  "is_pkey": false,
130
+ "column_default": null,
128
131
  "comment": null,
129
132
  "ordinal_position": 3,
130
133
  "is_nullable": true,
@@ -145,6 +148,7 @@ export default async function isomorphic(db: Partial<DbHandler> | Partial<DBHand
145
148
  "element_type": null,
146
149
  "element_udt_name": null,
147
150
  "is_pkey": false,
151
+ "column_default": null,
148
152
  "comment": null,
149
153
  "ordinal_position": 4,
150
154
  "is_nullable": true,
@@ -72,7 +72,6 @@ export type Items4_pub = {
72
72
  export type Items_m1 = {
73
73
  "id"?: number;
74
74
  "name"?: string;
75
- "name_type"?: string;
76
75
  }
77
76
  export type Items_with_media = {
78
77
  "id"?: number;
@@ -102,6 +101,12 @@ export type Lookup_status = {
102
101
  "en"?: string;
103
102
  "fr"?: string;
104
103
  }
104
+ export type Lookup_uuid_text_col1 = {
105
+ "id"?: string;
106
+ }
107
+ export type Lookup_uuid_text_col2 = {
108
+ "id"?: string;
109
+ }
105
110
  export type Media = {
106
111
  "id"?: string;
107
112
  "name"?: string;
@@ -197,6 +202,8 @@ export type Usr = {
197
202
  export type Uuid_text = {
198
203
  "id"?: string;
199
204
  "name"?: string;
205
+ "col1"?: string;
206
+ "col2"?: string;
200
207
  }
201
208
  export type V_items = {
202
209
  "id"?: number;
@@ -222,8 +229,9 @@ export type JoinMakerTables = {
222
229
  "items_with_media": JoinMaker<Items_with_media>;
223
230
  "items_with_one_media": JoinMaker<Items_with_one_media>;
224
231
  "lookup_experience_types": JoinMaker<Lookup_experience_types>;
225
- "lookup_items_m1_name_type": JoinMaker<Lookup_items_m1_name_type>;
226
232
  "lookup_status": JoinMaker<Lookup_status>;
233
+ "lookup_uuid_text_col1": JoinMaker<Lookup_uuid_text_col1>;
234
+ "lookup_uuid_text_col2": JoinMaker<Lookup_uuid_text_col2>;
227
235
  "media": JoinMaker<Media>;
228
236
  "prostgles_lookup_media_items_m1": JoinMaker<Prostgles_lookup_media_items_m1>;
229
237
  "prostgles_lookup_media_items_with_media": JoinMaker<Prostgles_lookup_media_items_with_media>;
@@ -236,6 +244,7 @@ export type JoinMakerTables = {
236
244
  "tt": JoinMaker<Tt>;
237
245
  "tt1": JoinMaker<Tt1>;
238
246
  "usr": JoinMaker<Usr>;
247
+ "uuid_text": JoinMaker<Uuid_text>;
239
248
  };
240
249
 
241
250
  /* DBO Definition. Isomorphic */
@@ -258,6 +267,8 @@ export type DBObj = {
258
267
  "lookup_items_m1_name_type": TableHandler<Lookup_items_m1_name_type>
259
268
  "lookup_settled_status": TableHandler<Lookup_settled_status>
260
269
  "lookup_status": TableHandler<Lookup_status>
270
+ "lookup_uuid_text_col1": TableHandler<Lookup_uuid_text_col1>
271
+ "lookup_uuid_text_col2": TableHandler<Lookup_uuid_text_col2>
261
272
  "media": TableHandler<Media>
262
273
  "planes": TableHandler<Planes>
263
274
  "prgll": TableHandler<Prgll>
@@ -325,7 +336,7 @@ export type I18N_DBO_CONFIG<LANG_IDS = { en: 1, fr: 1 }> = {
325
336
  [key in "id" | "public" | "name" | "added"]: { [lang_id in keyof LANG_IDS]: string };
326
337
  };
327
338
  "items_m1": {
328
- [key in "id" | "name" | "name_type"]: { [lang_id in keyof LANG_IDS]: string };
339
+ [key in "id" | "name"]: { [lang_id in keyof LANG_IDS]: string };
329
340
  };
330
341
  "items_with_media": {
331
342
  [key in "id" | "name"]: { [lang_id in keyof LANG_IDS]: string };
@@ -345,6 +356,12 @@ export type I18N_DBO_CONFIG<LANG_IDS = { en: 1, fr: 1 }> = {
345
356
  "lookup_status": {
346
357
  [key in "id" | "en" | "fr"]: { [lang_id in keyof LANG_IDS]: string };
347
358
  };
359
+ "lookup_uuid_text_col1": {
360
+ [key in "id"]: { [lang_id in keyof LANG_IDS]: string };
361
+ };
362
+ "lookup_uuid_text_col2": {
363
+ [key in "id"]: { [lang_id in keyof LANG_IDS]: string };
364
+ };
348
365
  "media": {
349
366
  [key in "id" | "name" | "extension" | "content_type" | "url" | "original_name" | "description" | "s3_url" | "signed_url" | "signed_url_expires" | "etag"]: { [lang_id in keyof LANG_IDS]: string };
350
367
  };
@@ -400,7 +417,7 @@ export type I18N_DBO_CONFIG<LANG_IDS = { en: 1, fr: 1 }> = {
400
417
  [key in "id" | "status" | "msg" | "added" | "is_active" | "age"]: { [lang_id in keyof LANG_IDS]: string };
401
418
  };
402
419
  "uuid_text": {
403
- [key in "id" | "name"]: { [lang_id in keyof LANG_IDS]: string };
420
+ [key in "id" | "name" | "col1" | "col2"]: { [lang_id in keyof LANG_IDS]: string };
404
421
  };
405
422
  "v_items": {
406
423
  [key in "id" | "name"]: { [lang_id in keyof LANG_IDS]: string };
@@ -68,6 +68,30 @@ const dbConnection = {
68
68
  transactions: true,
69
69
  // DEBUG_MODE: true,
70
70
  // onNotice: console.log,
71
+ tableConfig: {
72
+ uuid_text: {
73
+ col1: {
74
+ lookupValues: {
75
+ values: [
76
+ { id: "a" },
77
+ { id: "b" }
78
+ ],
79
+ nullable: true,
80
+ firstValueAsDefault: true
81
+ }
82
+ },
83
+ col2: {
84
+ lookupValues: {
85
+ values: [
86
+ { id: "a" },
87
+ { id: "b" }
88
+ ],
89
+ nullable: true,
90
+ firstValueAsDefault: false
91
+ }
92
+ }
93
+ }
94
+ },
71
95
  fileTable: {
72
96
  // awsS3Config: {
73
97
  // accessKeyId: process.env.S3_KEY,
@@ -84,7 +84,30 @@ const dbConnection = {
84
84
 
85
85
  // DEBUG_MODE: true,
86
86
  // onNotice: console.log,
87
-
87
+ tableConfig: {
88
+ uuid_text: {
89
+ col1: {
90
+ lookupValues: {
91
+ values: [
92
+ {id: "a"},
93
+ {id: "b"}
94
+ ],
95
+ nullable: true,
96
+ firstValueAsDefault: true
97
+ }
98
+ },
99
+ col2: {
100
+ lookupValues: {
101
+ values: [
102
+ {id: "a"},
103
+ {id: "b"}
104
+ ],
105
+ nullable: true,
106
+ firstValueAsDefault: false
107
+ }
108
+ }
109
+ }
110
+ },
88
111
  fileTable: {
89
112
  // awsS3Config: {
90
113
  // accessKeyId: process.env.S3_KEY,
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "../..": {
24
24
  "name": "prostgles-server",
25
- "version": "2.0.16",
25
+ "version": "2.0.20",
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
28
  "@aws-sdk/client-s3": "^3.32.0",
@@ -30,7 +30,7 @@
30
30
  "bluebird": "^3.7.2",
31
31
  "file-type": "^16.5.3",
32
32
  "pg-promise": "^10.9.5",
33
- "prostgles-types": "^1.5.103",
33
+ "prostgles-types": "^1.5.104",
34
34
  "sharp": "^0.29.1"
35
35
  },
36
36
  "devDependencies": {
@@ -1165,7 +1165,7 @@
1165
1165
  "bluebird": "^3.7.2",
1166
1166
  "file-type": "^16.5.3",
1167
1167
  "pg-promise": "^10.9.5",
1168
- "prostgles-types": "^1.5.103",
1168
+ "prostgles-types": "^1.5.104",
1169
1169
  "sharp": "^0.29.1",
1170
1170
  "typescript": "^3.9.7"
1171
1171
  }