@carbonorm/carbonnode 6.0.4 → 6.0.5

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 (56) hide show
  1. package/dist/handlers/ExpressHandler.d.ts +3 -2
  2. package/dist/index.cjs.js +33 -2
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +33 -2
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/__tests__/sakila-db/C6.js +1 -1
  8. package/src/__tests__/sakila-db/C6.mysqldump.json +1 -1
  9. package/src/__tests__/sakila-db/C6.mysqldump.sql +1 -1
  10. package/src/__tests__/sakila-db/C6.ts +1 -1
  11. package/src/__tests__/sakila-db/sqlResponses/C6.actor.post.json +3 -3
  12. package/src/__tests__/sakila-db/sqlResponses/C6.actor.post.latest.json +3 -3
  13. package/src/__tests__/sakila-db/sqlResponses/C6.actor.put.json +1 -1
  14. package/src/__tests__/sakila-db/sqlResponses/C6.actor.put.lookup.json +3 -3
  15. package/src/__tests__/sakila-db/sqlResponses/C6.address.post.json +5 -5
  16. package/src/__tests__/sakila-db/sqlResponses/C6.address.post.latest.json +5 -5
  17. package/src/__tests__/sakila-db/sqlResponses/C6.address.put.json +1 -1
  18. package/src/__tests__/sakila-db/sqlResponses/C6.address.put.lookup.json +5 -5
  19. package/src/__tests__/sakila-db/sqlResponses/C6.category.post.json +2 -2
  20. package/src/__tests__/sakila-db/sqlResponses/C6.category.post.latest.json +2 -2
  21. package/src/__tests__/sakila-db/sqlResponses/C6.category.put.json +1 -1
  22. package/src/__tests__/sakila-db/sqlResponses/C6.category.put.lookup.json +2 -2
  23. package/src/__tests__/sakila-db/sqlResponses/C6.city.post.json +2 -2
  24. package/src/__tests__/sakila-db/sqlResponses/C6.city.post.latest.json +2 -2
  25. package/src/__tests__/sakila-db/sqlResponses/C6.city.put.json +1 -1
  26. package/src/__tests__/sakila-db/sqlResponses/C6.city.put.lookup.json +2 -2
  27. package/src/__tests__/sakila-db/sqlResponses/C6.country.post.json +2 -2
  28. package/src/__tests__/sakila-db/sqlResponses/C6.country.post.latest.json +2 -2
  29. package/src/__tests__/sakila-db/sqlResponses/C6.country.put.json +1 -1
  30. package/src/__tests__/sakila-db/sqlResponses/C6.country.put.lookup.json +2 -2
  31. package/src/__tests__/sakila-db/sqlResponses/C6.customer.post.json +5 -5
  32. package/src/__tests__/sakila-db/sqlResponses/C6.customer.post.latest.json +5 -5
  33. package/src/__tests__/sakila-db/sqlResponses/C6.customer.put.json +1 -1
  34. package/src/__tests__/sakila-db/sqlResponses/C6.customer.put.lookup.json +5 -5
  35. package/src/__tests__/sakila-db/sqlResponses/C6.film.post.json +2 -2
  36. package/src/__tests__/sakila-db/sqlResponses/C6.film.post.latest.json +2 -2
  37. package/src/__tests__/sakila-db/sqlResponses/C6.film.put.json +1 -1
  38. package/src/__tests__/sakila-db/sqlResponses/C6.film.put.lookup.json +2 -2
  39. package/src/__tests__/sakila-db/sqlResponses/C6.inventory.post.json +1 -1
  40. package/src/__tests__/sakila-db/sqlResponses/C6.inventory.post.latest.json +1 -1
  41. package/src/__tests__/sakila-db/sqlResponses/C6.inventory.put.json +1 -1
  42. package/src/__tests__/sakila-db/sqlResponses/C6.inventory.put.lookup.json +1 -1
  43. package/src/__tests__/sakila-db/sqlResponses/C6.language.post.json +2 -2
  44. package/src/__tests__/sakila-db/sqlResponses/C6.language.post.latest.json +2 -2
  45. package/src/__tests__/sakila-db/sqlResponses/C6.language.put.json +1 -1
  46. package/src/__tests__/sakila-db/sqlResponses/C6.language.put.lookup.json +2 -2
  47. package/src/__tests__/sakila-db/sqlResponses/C6.payment.post.json +2 -2
  48. package/src/__tests__/sakila-db/sqlResponses/C6.payment.post.latest.json +2 -2
  49. package/src/__tests__/sakila-db/sqlResponses/C6.payment.put.lookup.json +2 -2
  50. package/src/__tests__/sakila-db/sqlResponses/C6.rental.post.json +3 -3
  51. package/src/__tests__/sakila-db/sqlResponses/C6.rental.post.latest.json +3 -3
  52. package/src/__tests__/sakila-db/sqlResponses/C6.rental.put.json +1 -1
  53. package/src/__tests__/sakila-db/sqlResponses/C6.rental.put.lookup.json +3 -3
  54. package/src/executors/HttpExecutor.ts +2 -1
  55. package/src/executors/SqlExecutor.ts +34 -1
  56. package/src/handlers/ExpressHandler.ts +4 -1
@@ -1,8 +1,9 @@
1
1
  import type { Request, Response, NextFunction } from "express";
2
2
  import type { Pool } from "mysql2/promise";
3
- import type { iC6Object } from "../types/ormInterfaces";
4
- export declare function ExpressHandler({ C6, mysqlPool, sqlAllowListPath, }: {
3
+ import type { iC6Object, tWebsocketBroadcast } from "../types/ormInterfaces";
4
+ export declare function ExpressHandler({ C6, mysqlPool, sqlAllowListPath, websocketBroadcast, }: {
5
5
  C6: iC6Object;
6
6
  mysqlPool: Pool;
7
7
  sqlAllowListPath?: string;
8
+ websocketBroadcast?: tWebsocketBroadcast;
8
9
  }): (req: Request, res: Response, next: NextFunction) => Promise<void>;
package/dist/index.cjs.js CHANGED
@@ -3354,17 +3354,40 @@ var SqlExecutor = /** @class */ (function (_super) {
3354
3354
  switch (_f.label) {
3355
3355
  case 0:
3356
3356
  broadcast = this.config.websocketBroadcast;
3357
- if (!broadcast || this.config.requestMethod === C6Constants.GET)
3357
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 broadcastWebsocketIfConfigured start", {
3358
+ method: this.config.requestMethod,
3359
+ hasBroadcast: Boolean(broadcast),
3360
+ });
3361
+ if (!broadcast || this.config.requestMethod === C6Constants.GET) {
3362
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 websocket broadcast skipped", {
3363
+ reason: !broadcast ? "no broadcast configured" : "GET request",
3364
+ });
3358
3365
  return [2 /*return*/];
3366
+ }
3359
3367
  normalizedRequest = this.normalizeRequestPayload(this.extractRequestBody());
3360
3368
  pkShorts = (_c = this.config.restModel.PRIMARY_SHORT) !== null && _c !== void 0 ? _c : [];
3361
3369
  columns = this.config.restModel.COLUMNS;
3362
3370
  validColumns = new Set(Object.values(columns));
3363
3371
  responseRest = response === null || response === void 0 ? void 0 : response.rest;
3364
3372
  responsePrimaryKey = this.extractPrimaryKeyValuesFromData(responseRest);
3373
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 websocket request payload", {
3374
+ normalizedRequest: normalizedRequest,
3375
+ requestPrimaryKey: this.extractPrimaryKeyValues(),
3376
+ pkShorts: pkShorts,
3377
+ });
3378
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 websocket response payload", {
3379
+ responseRest: responseRest,
3380
+ responsePrimaryKey: responsePrimaryKey,
3381
+ });
3365
3382
  if ((responseRest === null || (Array.isArray(responseRest) && responseRest.length === 0))
3366
3383
  && this.config.requestMethod === C6Constants.POST) {
3384
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 response rest empty, attempting synthesize", {
3385
+ responseRest: responseRest,
3386
+ });
3367
3387
  insertId = response === null || response === void 0 ? void 0 : response.insertId;
3388
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 POST insertId lookup", {
3389
+ insertId: insertId,
3390
+ });
3368
3391
  if (insertId !== undefined && pkShorts.length === 1) {
3369
3392
  synthesizedRequest = tslib.__assign({}, normalizedRequest);
3370
3393
  now = new Date().toISOString();
@@ -3383,6 +3406,10 @@ var SqlExecutor = /** @class */ (function (_super) {
3383
3406
  responsePrimaryKey = (_b = {},
3384
3407
  _b[pkShorts[0]] = insertId,
3385
3408
  _b);
3409
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 synthesized response payload", {
3410
+ synthesized: synthesized,
3411
+ responsePrimaryKey: responsePrimaryKey,
3412
+ });
3386
3413
  }
3387
3414
  }
3388
3415
  payload = {
@@ -3396,12 +3423,15 @@ var SqlExecutor = /** @class */ (function (_super) {
3396
3423
  RESPONSE_PRIMARY_KEY: responsePrimaryKey,
3397
3424
  },
3398
3425
  };
3426
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 websocket payload ready", payload);
3399
3427
  _f.label = 1;
3400
3428
  case 1:
3401
3429
  _f.trys.push([1, 3, , 4]);
3430
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 websocket broadcast dispatch start");
3402
3431
  return [4 /*yield*/, broadcast(payload)];
3403
3432
  case 2:
3404
3433
  _f.sent();
3434
+ this.config.verbose && console.log("[SQL EXECUTOR] 📣 websocket broadcast dispatch complete");
3405
3435
  return [3 /*break*/, 4];
3406
3436
  case 3:
3407
3437
  error_1 = _f.sent();
@@ -3512,7 +3542,7 @@ var SqlExecutor$1 = /*#__PURE__*/Object.freeze({
3512
3542
  // note sure how it would help anyone actually...
3513
3543
  function ExpressHandler(_a) {
3514
3544
  var _this = this;
3515
- var C6 = _a.C6, mysqlPool = _a.mysqlPool, sqlAllowListPath = _a.sqlAllowListPath;
3545
+ var C6 = _a.C6, mysqlPool = _a.mysqlPool, sqlAllowListPath = _a.sqlAllowListPath, websocketBroadcast = _a.websocketBroadcast;
3516
3546
  return function (req, res, next) { return tslib.__awaiter(_this, void 0, void 0, function () {
3517
3547
  var incomingMethod, table, primary, methodOverrideRaw, methodOverride, treatAsGet, method, payload, restModel, primaryKeys_1, primaryShortKeys_1, columnMap_1, resolveShortKey_1, hasPrimaryKeyValues, primaryKeyName, response, err_1;
3518
3548
  var _a, _b, _c, _d, _e, _f, _g;
@@ -3599,6 +3629,7 @@ function ExpressHandler(_a) {
3599
3629
  C6: C6,
3600
3630
  mysqlPool: mysqlPool,
3601
3631
  sqlAllowListPath: sqlAllowListPath,
3632
+ websocketBroadcast: websocketBroadcast,
3602
3633
  requestMethod: method,
3603
3634
  restModel: C6.TABLES[table]
3604
3635
  })(payload)];