prostgles-server 2.0.270 → 2.0.273

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 (81) hide show
  1. package/dist/AuthHandler.d.ts +11 -3
  2. package/dist/AuthHandler.d.ts.map +1 -1
  3. package/dist/AuthHandler.js +38 -20
  4. package/dist/AuthHandler.js.map +1 -1
  5. package/dist/DBSchemaBuilder.d.ts.map +1 -1
  6. package/dist/DBSchemaBuilder.js +4 -0
  7. package/dist/DBSchemaBuilder.js.map +1 -1
  8. package/dist/DboBuilder/QueryBuilder/QueryBuilder.d.ts +149 -0
  9. package/dist/DboBuilder/QueryBuilder/QueryBuilder.d.ts.map +1 -0
  10. package/{lib → dist/DboBuilder/QueryBuilder}/QueryBuilder.js +4 -223
  11. package/dist/DboBuilder/QueryBuilder/QueryBuilder.js.map +1 -0
  12. package/dist/DboBuilder/QueryBuilder/makeSelectQuery.d.ts +5 -0
  13. package/dist/DboBuilder/QueryBuilder/makeSelectQuery.d.ts.map +1 -0
  14. package/dist/DboBuilder/QueryBuilder/makeSelectQuery.js +225 -0
  15. package/dist/DboBuilder/QueryBuilder/makeSelectQuery.js.map +1 -0
  16. package/dist/DboBuilder/delete.d.ts.map +1 -1
  17. package/dist/DboBuilder/delete.js +6 -1
  18. package/dist/DboBuilder/delete.js.map +1 -1
  19. package/dist/DboBuilder.d.ts +1 -1
  20. package/dist/DboBuilder.d.ts.map +1 -1
  21. package/dist/DboBuilder.js +3 -3
  22. package/dist/DboBuilder.js.map +1 -1
  23. package/dist/FileManager.d.ts +4 -1
  24. package/dist/FileManager.d.ts.map +1 -1
  25. package/dist/FileManager.js +22 -3
  26. package/dist/FileManager.js.map +1 -1
  27. package/dist/Filtering.d.ts +1 -1
  28. package/dist/Filtering.d.ts.map +1 -1
  29. package/dist/Prostgles.d.ts +11 -1
  30. package/dist/Prostgles.d.ts.map +1 -1
  31. package/dist/Prostgles.js +2 -0
  32. package/dist/Prostgles.js.map +1 -1
  33. package/dist/TableConfig.d.ts +4 -1
  34. package/dist/TableConfig.d.ts.map +1 -1
  35. package/dist/TableConfig.js +8 -6
  36. package/dist/TableConfig.js.map +1 -1
  37. package/dist/validation.js +1 -2
  38. package/dist/validation.js.map +1 -1
  39. package/lib/AuthHandler.d.ts +11 -3
  40. package/lib/AuthHandler.d.ts.map +1 -1
  41. package/lib/AuthHandler.js +38 -20
  42. package/lib/AuthHandler.ts +47 -21
  43. package/lib/DBSchemaBuilder.d.ts.map +1 -1
  44. package/lib/DBSchemaBuilder.js +4 -0
  45. package/lib/DBSchemaBuilder.ts +2 -0
  46. package/lib/{QueryBuilder.d.ts → DboBuilder/QueryBuilder/QueryBuilder.d.ts} +2 -3
  47. package/lib/DboBuilder/QueryBuilder/QueryBuilder.d.ts.map +1 -0
  48. package/lib/DboBuilder/QueryBuilder/QueryBuilder.js +1160 -0
  49. package/lib/{QueryBuilder.ts → DboBuilder/QueryBuilder/QueryBuilder.ts} +3 -282
  50. package/lib/DboBuilder/QueryBuilder/makeSelectQuery.d.ts +5 -0
  51. package/lib/DboBuilder/QueryBuilder/makeSelectQuery.d.ts.map +1 -0
  52. package/lib/DboBuilder/QueryBuilder/makeSelectQuery.js +224 -0
  53. package/lib/DboBuilder/QueryBuilder/makeSelectQuery.ts +284 -0
  54. package/lib/DboBuilder/delete.d.ts.map +1 -1
  55. package/lib/DboBuilder/delete.js +6 -1
  56. package/lib/DboBuilder/delete.ts +6 -1
  57. package/lib/DboBuilder.d.ts +1 -1
  58. package/lib/DboBuilder.d.ts.map +1 -1
  59. package/lib/DboBuilder.js +3 -3
  60. package/lib/DboBuilder.ts +3 -3
  61. package/lib/FileManager.d.ts +4 -1
  62. package/lib/FileManager.d.ts.map +1 -1
  63. package/lib/FileManager.js +22 -3
  64. package/lib/FileManager.ts +26 -4
  65. package/lib/Filtering.d.ts +1 -1
  66. package/lib/Filtering.d.ts.map +1 -1
  67. package/lib/Filtering.ts +1 -1
  68. package/lib/Prostgles.d.ts +11 -1
  69. package/lib/Prostgles.d.ts.map +1 -1
  70. package/lib/Prostgles.js +2 -0
  71. package/lib/Prostgles.ts +14 -3
  72. package/lib/TableConfig.d.ts +4 -1
  73. package/lib/TableConfig.d.ts.map +1 -1
  74. package/lib/TableConfig.js +8 -6
  75. package/lib/TableConfig.ts +11 -6
  76. package/lib/validation.js +1 -2
  77. package/lib/validation.ts +2 -2
  78. package/package.json +1 -1
  79. package/tests/client/PID.txt +1 -1
  80. package/tests/server/package-lock.json +1 -1
  81. package/lib/QueryBuilder.d.ts.map +0 -1
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prostgles_types_1 = require("prostgles-types");
4
+ const FileManager_1 = require("./FileManager");
4
5
  class AuthHandler {
5
6
  constructor(prostgles) {
7
+ this.routes = {
8
+ catchAll: "*"
9
+ };
6
10
  this.validateSid = (sid) => {
7
11
  if (!sid)
8
12
  return undefined;
@@ -18,10 +22,10 @@ class AuthHandler {
18
22
  const pubRoutes = [
19
23
  ...this.opts?.expressConfig?.publicRoutes || [],
20
24
  ];
21
- if (this.loginRoute)
22
- pubRoutes.push(this.loginRoute);
23
- if (this.logoutGetPath)
24
- pubRoutes.push(this.logoutGetPath);
25
+ if (this.routes?.login)
26
+ pubRoutes.push(this.routes?.login);
27
+ if (this.routes?.logoutGetPath)
28
+ pubRoutes.push(this.routes?.logoutGetPath);
25
29
  return Boolean(!pubRoutes.find(publicRoute => {
26
30
  return this.matchesRoute(publicRoute, pathname); // publicRoute === pathname || pathname.startsWith(publicRoute) && ["/", "?", "#"].includes(pathname.slice(-1));
27
31
  }));
@@ -41,10 +45,10 @@ class AuthHandler {
41
45
  };
42
46
  const cookieOpts = { ...options, secure: true, sameSite: "strict", ...(this.opts?.expressConfig?.cookieOptions || {}) };
43
47
  const cookieData = sid;
44
- if (!this.sidKeyName || !this.returnURL)
48
+ if (!this.sidKeyName || !this.routes?.returnURL)
45
49
  throw "sidKeyName or returnURL missing";
46
50
  res.cookie(this.sidKeyName, cookieData, cookieOpts);
47
- const successURL = getReturnUrl(req, this.returnURL) || "/";
51
+ const successURL = getReturnUrl(req, this.routes.returnURL) || "/";
48
52
  res.redirect(successURL);
49
53
  }
50
54
  else {
@@ -67,6 +71,11 @@ class AuthHandler {
67
71
  }
68
72
  return undefined;
69
73
  };
74
+ this.destroy = () => {
75
+ const app = this.opts?.expressConfig?.app;
76
+ const { login, logoutGetPath, magicLinks } = this.routes;
77
+ (0, FileManager_1.removeExpressRoute)(app, [login, logoutGetPath, magicLinks?.expressRoute]);
78
+ };
70
79
  this.throttledFunc = (func, throttle = 500) => {
71
80
  return new Promise(async (resolve, reject) => {
72
81
  let interval, result, error, finished = false;
@@ -184,9 +193,17 @@ class AuthHandler {
184
193
  };
185
194
  this.opts = prostgles.opts.auth;
186
195
  if (prostgles.opts.auth?.expressConfig) {
187
- this.returnURL = prostgles.opts.auth?.expressConfig?.returnURL || "returnURL";
188
- this.loginRoute = prostgles.opts.auth?.expressConfig?.loginRoute || "/login";
189
- this.logoutGetPath = prostgles.opts.auth?.expressConfig?.logoutGetPath || "/logout";
196
+ const { magicLinks, returnURL, loginRoute, logoutGetPath } = prostgles.opts.auth.expressConfig;
197
+ this.routes = {
198
+ magicLinks: magicLinks ? {
199
+ expressRoute: `${magicLinks.route}/:id`,
200
+ route: magicLinks.route || "/magic-link"
201
+ } : undefined,
202
+ returnURL: returnURL || "returnURL",
203
+ login: loginRoute || "/login",
204
+ logoutGetPath: logoutGetPath || "/logout",
205
+ catchAll: "*"
206
+ };
190
207
  }
191
208
  if (!prostgles.dbo || !prostgles.db)
192
209
  throw "dbo or db missing";
@@ -214,11 +231,11 @@ class AuthHandler {
214
231
  if (publicRoutes.find(r => typeof r !== "string" || !r)) {
215
232
  throw "Invalid or empty string provided within publicRoutes ";
216
233
  }
217
- if (app && magicLinks) {
218
- const { route = "/magic-link", check } = magicLinks;
234
+ if (app && magicLinks && this.routes.magicLinks) {
235
+ const { check } = magicLinks;
219
236
  if (!check)
220
237
  throw "Check must be defined for magicLinks";
221
- app.get(`${route}/:id`, async (req, res) => {
238
+ app.get(this.routes.magicLinks?.expressRoute, async (req, res) => {
222
239
  const { id } = req.params ?? {};
223
240
  if (typeof id !== "string" || !id) {
224
241
  res.status(404).json({ msg: "Invalid magic-link id. Expecting a string" });
@@ -241,8 +258,9 @@ class AuthHandler {
241
258
  }
242
259
  });
243
260
  }
244
- if (app && this.loginRoute) {
245
- app.post(this.loginRoute, async (req, res) => {
261
+ const loginRoute = this.routes?.login;
262
+ if (app && loginRoute) {
263
+ app.post(loginRoute, async (req, res) => {
246
264
  try {
247
265
  const { sid, expires } = await this.loginThrottled(req.body || {}) || {};
248
266
  if (sid) {
@@ -257,8 +275,8 @@ class AuthHandler {
257
275
  res.status(404).json({ err });
258
276
  }
259
277
  });
260
- if (app && this.logoutGetPath && this.opts.logout) {
261
- app.get(this.logoutGetPath, async (req, res) => {
278
+ if (app && this.routes.logoutGetPath && this.opts.logout) {
279
+ app.get(this.routes.logoutGetPath, async (req, res) => {
262
280
  const sid = this.validateSid(req?.cookies?.[sidKeyName]);
263
281
  if (sid) {
264
282
  try {
@@ -275,11 +293,11 @@ class AuthHandler {
275
293
  }
276
294
  if (app && Array.isArray(publicRoutes)) {
277
295
  /* Redirect if not logged in and requesting non public content */
278
- app.get('*', async (req, res) => {
296
+ app.get(this.routes.catchAll, async (req, res) => {
279
297
  const clientReq = { httpReq: req };
280
298
  const getUser = this.getUser;
281
299
  try {
282
- const returnURL = getReturnUrl(req, this.returnURL);
300
+ const returnURL = getReturnUrl(req, this.routes.returnURL);
283
301
  /**
284
302
  * Requesting a User route
285
303
  */
@@ -287,7 +305,7 @@ class AuthHandler {
287
305
  /* Check auth. Redirect if unauthorized */
288
306
  const u = await getUser(clientReq);
289
307
  if (!u) {
290
- res.redirect(`${this.loginRoute}?returnURL=${encodeURIComponent(req.originalUrl)}`);
308
+ res.redirect(`${loginRoute}?returnURL=${encodeURIComponent(req.originalUrl)}`);
291
309
  return;
292
310
  }
293
311
  /* If authorized and going to returnUrl then redirect. Otherwise serve file */
@@ -297,7 +315,7 @@ class AuthHandler {
297
315
  return;
298
316
  /** If Logged in and requesting login then redirect */
299
317
  }
300
- else if (this.matchesRoute(this.loginRoute, req.path) && (await getUser(clientReq))) {
318
+ else if (this.matchesRoute(loginRoute, req.path) && (await getUser(clientReq))) {
301
319
  res.redirect("/");
302
320
  return;
303
321
  }
@@ -2,6 +2,7 @@ import { Request, Response } from "express";
2
2
  import { AnyObject, AuthGuardLocation, AuthGuardLocationResponse, CHANNELS, DBSchema } from "prostgles-types";
3
3
  import { LocalParams, PRGLIOSocket } from "./DboBuilder";
4
4
  import { DBOFullyTyped } from "./DBSchemaBuilder";
5
+ import { removeExpressRoute } from "./FileManager";
5
6
  import { DB, DBHandlerServer, Prostgles } from "./Prostgles";
6
7
  type Awaitable<T> = T | Promise<T>;
7
8
  type AuthSocketSchema = {
@@ -148,17 +149,35 @@ export default class AuthHandler {
148
149
  dbo: DBHandlerServer;
149
150
  db: DB;
150
151
  sidKeyName?: string;
151
- returnURL?: string;
152
152
 
153
- loginRoute?: string;
154
- logoutGetPath?: string;
153
+ routes: {
154
+ login?: string;
155
+ returnURL?: string;
156
+ logoutGetPath?: string;
157
+ magicLinks?: {
158
+ route: string;
159
+ expressRoute: string;
160
+ }
161
+ readonly catchAll: '*';
162
+ } = {
163
+ catchAll: "*"
164
+ }
155
165
 
156
166
  constructor(prostgles: Prostgles) {
157
167
  this.opts = prostgles.opts.auth as any;
158
168
  if (prostgles.opts.auth?.expressConfig) {
159
- this.returnURL = prostgles.opts.auth?.expressConfig?.returnURL || "returnURL";
160
- this.loginRoute = prostgles.opts.auth?.expressConfig?.loginRoute || "/login";
161
- this.logoutGetPath = prostgles.opts.auth?.expressConfig?.logoutGetPath || "/logout";
169
+ const { magicLinks, returnURL, loginRoute, logoutGetPath } = prostgles.opts.auth.expressConfig;
170
+ this.routes = {
171
+ magicLinks: magicLinks? {
172
+ expressRoute: `${magicLinks.route}/:id`,
173
+ route: magicLinks.route || "/magic-link"
174
+ } : undefined,
175
+ returnURL: returnURL || "returnURL",
176
+ login: loginRoute || "/login",
177
+ logoutGetPath: logoutGetPath || "/logout",
178
+ catchAll: "*"
179
+ }
180
+
162
181
  }
163
182
  if(!prostgles.dbo || !prostgles.db) throw "dbo or db missing";
164
183
  this.dbo = prostgles.dbo;
@@ -182,8 +201,8 @@ export default class AuthHandler {
182
201
  const pubRoutes = [
183
202
  ...this.opts?.expressConfig?.publicRoutes || [],
184
203
  ];
185
- if (this.loginRoute) pubRoutes.push(this.loginRoute);
186
- if (this.logoutGetPath) pubRoutes.push(this.logoutGetPath);
204
+ if (this.routes?.login) pubRoutes.push(this.routes?.login);
205
+ if (this.routes?.logoutGetPath) pubRoutes.push(this.routes?.logoutGetPath);
187
206
 
188
207
  return Boolean(!pubRoutes.find(publicRoute => {
189
208
  return this.matchesRoute(publicRoute, pathname); // publicRoute === pathname || pathname.startsWith(publicRoute) && ["/", "?", "#"].includes(pathname.slice(-1));
@@ -205,9 +224,9 @@ export default class AuthHandler {
205
224
  }
206
225
  const cookieOpts = { ...options, secure: true, sameSite: "strict" as "strict", ...(this.opts?.expressConfig?.cookieOptions || {}) };
207
226
  const cookieData = sid;
208
- if(!this.sidKeyName || !this.returnURL) throw "sidKeyName or returnURL missing"
227
+ if(!this.sidKeyName || !this.routes?.returnURL) throw "sidKeyName or returnURL missing"
209
228
  res.cookie(this.sidKeyName, cookieData, cookieOpts);
210
- const successURL = getReturnUrl(req, this.returnURL) || "/";
229
+ const successURL = getReturnUrl(req, this.routes.returnURL) || "/";
211
230
  res.redirect(successURL);
212
231
 
213
232
  } else {
@@ -254,10 +273,10 @@ export default class AuthHandler {
254
273
  throw "Invalid or empty string provided within publicRoutes "
255
274
  }
256
275
 
257
- if (app && magicLinks) {
258
- const { route = "/magic-link", check } = magicLinks;
276
+ if (app && magicLinks && this.routes.magicLinks) {
277
+ const { check } = magicLinks;
259
278
  if (!check) throw "Check must be defined for magicLinks";
260
- app.get(`${route}/:id`, async (req: ExpressReq, res: ExpressRes) => {
279
+ app.get(this.routes.magicLinks?.expressRoute, async (req: ExpressReq, res: ExpressRes) => {
261
280
  const { id } = req.params ?? {};
262
281
 
263
282
  if (typeof id !== "string" || !id) {
@@ -280,10 +299,11 @@ export default class AuthHandler {
280
299
  });
281
300
  }
282
301
 
283
- if (app && this.loginRoute) {
302
+ const loginRoute = this.routes?.login;
303
+ if (app && loginRoute) {
284
304
 
285
305
 
286
- app.post(this.loginRoute, async (req: ExpressReq, res: ExpressRes) => {
306
+ app.post(loginRoute, async (req: ExpressReq, res: ExpressRes) => {
287
307
  try {
288
308
  const { sid, expires } = await this.loginThrottled(req.body || {}) || {};
289
309
 
@@ -302,8 +322,8 @@ export default class AuthHandler {
302
322
 
303
323
  });
304
324
 
305
- if (app && this.logoutGetPath && this.opts.logout) {
306
- app.get(this.logoutGetPath, async (req: ExpressReq, res: ExpressRes) => {
325
+ if (app && this.routes.logoutGetPath && this.opts.logout) {
326
+ app.get(this.routes.logoutGetPath, async (req: ExpressReq, res: ExpressRes) => {
307
327
  const sid = this.validateSid(req?.cookies?.[sidKeyName]);
308
328
  if (sid) {
309
329
  try {
@@ -322,11 +342,11 @@ export default class AuthHandler {
322
342
  if (app && Array.isArray(publicRoutes)) {
323
343
 
324
344
  /* Redirect if not logged in and requesting non public content */
325
- app.get('*', async (req: ExpressReq, res: ExpressRes) => {
345
+ app.get(this.routes.catchAll, async (req: ExpressReq, res: ExpressRes) => {
326
346
  const clientReq: AuthClientRequest = { httpReq: req }
327
347
  const getUser = this.getUser;
328
348
  try {
329
- const returnURL = getReturnUrl(req, this.returnURL)
349
+ const returnURL = getReturnUrl(req, this.routes.returnURL)
330
350
 
331
351
 
332
352
  /**
@@ -336,7 +356,7 @@ export default class AuthHandler {
336
356
  /* Check auth. Redirect if unauthorized */
337
357
  const u = await getUser(clientReq);
338
358
  if (!u) {
339
- res.redirect(`${this.loginRoute}?returnURL=${encodeURIComponent(req.originalUrl)}`);
359
+ res.redirect(`${loginRoute}?returnURL=${encodeURIComponent(req.originalUrl)}`);
340
360
  return;
341
361
  }
342
362
 
@@ -347,7 +367,7 @@ export default class AuthHandler {
347
367
  return;
348
368
 
349
369
  /** If Logged in and requesting login then redirect */
350
- } else if (this.matchesRoute(this.loginRoute, req.path) && (await getUser(clientReq))) {
370
+ } else if (this.matchesRoute(loginRoute, req.path) && (await getUser(clientReq))) {
351
371
 
352
372
  res.redirect("/");
353
373
  return;
@@ -366,6 +386,12 @@ export default class AuthHandler {
366
386
  }
367
387
  }
368
388
 
389
+ destroy = () => {
390
+ const app = this.opts?.expressConfig?.app;
391
+ const { login, logoutGetPath, magicLinks } = this.routes;
392
+ removeExpressRoute(app, [login, logoutGetPath, magicLinks?.expressRoute]);
393
+ }
394
+
369
395
  throttledFunc = <T>(func: () => Promise<T>, throttle = 500): Promise<T> => {
370
396
 
371
397
  return new Promise(async (resolve, reject) => {
@@ -1 +1 @@
1
- {"version":3,"file":"DBSchemaBuilder.d.ts","sourceRoot":"","sources":["DBSchemaBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGtE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAkD,MAAM,cAAc,CAAC;AAC3G,OAAO,EAAE,mBAAmB,EAAiB,gBAAgB,EAAE,eAAe,EAAI,MAAM,iBAAiB,CAAC;AAI1G,eAAO,MAAM,WAAW,eAAgB,UAAU,KAAG,MAuCpD,CAAA;AAED,aAAK,yBAAyB,CAAC,MAAM,GAAG,IAAI,IAAI,MAAM,SAAS,QAAQ,GAAE;KACtE,QAAQ,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,IAAI,GAClE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC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ED,aAAK,yBAAyB,CAAC,MAAM,GAAG,IAAI,IAAI,MAAM,SAAS,QAAQ,GAAE;KACtE,QAAQ,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,IAAI,GAClE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,GACxC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC;CAC5C,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEjC,oBAAY,aAAa,CAAC,MAAM,GAAG,IAAI,IAAI,MAAM,SAAS,QAAQ,GAAE,CAChE,yBAAyB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,CAC3G,GACD,eAAe,CAAC;AAKlB,oBAAY,iBAAiB,CAAC,MAAM,GAAG,IAAI,IAAI,MAAM,SAAS,QAAQ,GAAE,CACpE,mBAAmB,GACnB;KACC,QAAQ,IAAI,MAAM,OAAO,CAAC,MAAM,CAAC,GAC9B,mBAAmB,GACnB,CACA,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,IAAI,GACtC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,GACpD,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CACxD;CACJ,CACF,GAAG,CACA,mBAAmB,GACnB,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB,GAAG,mBAAmB,CAAC,CAC3E,CAAC"}
@@ -17,9 +17,13 @@ const getDBSchema = (dboBuilder) => {
17
17
  const colConf = dboBuilder.prostgles.tableConfigurator?.getColumnConfig(tov.name, c.name);
18
18
  if (colConf) {
19
19
  if ("jsonbSchema" in colConf) {
20
+ if (!colConf.jsonbSchema)
21
+ throw "colConf.jsonbSchema missing";
20
22
  type = (0, validation_1.getJSONBSchemaTSTypes)(colConf.jsonbSchema, { nullable: colConf.nullable }, " ");
21
23
  }
22
24
  else if ("oneOf" in colConf) {
25
+ if (!colConf.oneOf)
26
+ throw "colConf.oneOf missing";
23
27
  const types = colConf.oneOf.map(t => typeof t === "number" ? t : JSON.stringify(t));
24
28
  if (colConf.nullable) {
25
29
  types.unshift("null");
@@ -18,8 +18,10 @@ export const getDBSchema = (dboBuilder: DboBuilder): string => {
18
18
  const colConf = dboBuilder.prostgles.tableConfigurator?.getColumnConfig(tov.name, c.name);
19
19
  if(colConf){
20
20
  if("jsonbSchema" in colConf){
21
+ if(!colConf.jsonbSchema) throw "colConf.jsonbSchema missing"
21
22
  type = getJSONBSchemaTSTypes(colConf.jsonbSchema, { nullable: colConf.nullable }, " ");
22
23
  } else if("oneOf" in colConf){
24
+ if(!colConf.oneOf) throw "colConf.oneOf missing"
23
25
  const types = colConf.oneOf.map(t => typeof t === "number"? t : JSON.stringify(t));
24
26
  if(colConf.nullable){
25
27
  types.unshift("null")
@@ -1,5 +1,5 @@
1
- import { Filter, LocalParams, TableHandler } from "./DboBuilder";
2
- import { TableRule } from "./PublishParser";
1
+ import { Filter, LocalParams, TableHandler } from "../../DboBuilder";
2
+ import { TableRule } from "../../PublishParser";
3
3
  import { SelectParams, ColumnInfo, PG_COLUMN_UDT_DATA_TYPE, Select } from "prostgles-types";
4
4
  export declare type SelectItem = {
5
5
  type: "column" | "function" | "aggregation" | "joinedColumn" | "computed";
@@ -119,6 +119,5 @@ export declare class SelectItemBuilder {
119
119
  export declare function getNewQuery(_this: TableHandler, filter: Filter, selectParams: (SelectParams & {
120
120
  alias?: string;
121
121
  }), param3_unused: any, tableRules: TableRule | undefined, localParams: LocalParams | undefined, columns: ColumnInfo[]): Promise<NewQuery>;
122
- export declare function makeQuery(_this: TableHandler, q: NewQuery, depth?: number, joinFields?: string[], selectParams?: SelectParams): string;
123
122
  export {};
124
123
  //# sourceMappingURL=QueryBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["QueryBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAO,MAAM,EAAE,WAAW,EAAiB,YAAY,EAAiC,MAAM,kBAAkB,CAAC;AACxH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,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,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,UAAU,EAAE,CAAC;IAErB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAA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