prostgles-server 4.2.545 → 4.2.547

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 (55) hide show
  1. package/dist/DboBuilder/DboBuilder.js.map +1 -1
  2. package/dist/DboBuilder/QueryBuilder/Functions/Functions.d.ts.map +1 -1
  3. package/dist/DboBuilder/QueryBuilder/Functions/Functions.js +19 -376
  4. package/dist/DboBuilder/QueryBuilder/Functions/Functions.js.map +1 -1
  5. package/dist/DboBuilder/QueryBuilder/Functions/HASHING_FUNCTIONS.d.ts +3 -0
  6. package/dist/DboBuilder/QueryBuilder/Functions/HASHING_FUNCTIONS.d.ts.map +1 -0
  7. package/dist/DboBuilder/QueryBuilder/Functions/HASHING_FUNCTIONS.js +107 -0
  8. package/dist/DboBuilder/QueryBuilder/Functions/HASHING_FUNCTIONS.js.map +1 -0
  9. package/dist/DboBuilder/QueryBuilder/Functions/TEXT_FUNCTIONS.d.ts +3 -0
  10. package/dist/DboBuilder/QueryBuilder/Functions/TEXT_FUNCTIONS.d.ts.map +1 -0
  11. package/dist/DboBuilder/QueryBuilder/Functions/TEXT_FUNCTIONS.js +276 -0
  12. package/dist/DboBuilder/QueryBuilder/Functions/TEXT_FUNCTIONS.js.map +1 -0
  13. package/dist/DboBuilder/QueryBuilder/Functions/utils.d.ts +3 -0
  14. package/dist/DboBuilder/QueryBuilder/Functions/utils.d.ts.map +1 -0
  15. package/dist/DboBuilder/QueryBuilder/Functions/utils.js +6 -0
  16. package/dist/DboBuilder/QueryBuilder/Functions/utils.js.map +1 -0
  17. package/dist/DboBuilder/TableHandler/update.js.map +1 -1
  18. package/dist/DboBuilder/ViewHandler/getExistsCondition.js +5 -5
  19. package/dist/DboBuilder/ViewHandler/getExistsCondition.js.map +1 -1
  20. package/dist/DboBuilder/ViewHandler/parseFieldFilter.js.map +1 -1
  21. package/dist/DboBuilder/runSql/runSQL.js +1 -1
  22. package/dist/DboBuilder/runSql/runSQL.js.map +1 -1
  23. package/dist/FileManager/FileManager.js.map +1 -1
  24. package/dist/Logging.d.ts +1 -1
  25. package/dist/Logging.d.ts.map +1 -1
  26. package/dist/PubSubManager/PubSubManager.d.ts +0 -1
  27. package/dist/PubSubManager/PubSubManager.d.ts.map +1 -1
  28. package/dist/PubSubManager/PubSubManager.js.map +1 -1
  29. package/dist/PubSubManager/SyncReplication/getSyncUtilFunctions.d.ts +7 -2
  30. package/dist/PubSubManager/SyncReplication/getSyncUtilFunctions.d.ts.map +1 -1
  31. package/dist/PubSubManager/SyncReplication/getSyncUtilFunctions.js +21 -16
  32. package/dist/PubSubManager/SyncReplication/getSyncUtilFunctions.js.map +1 -1
  33. package/dist/PubSubManager/SyncReplication/syncData.d.ts.map +1 -1
  34. package/dist/PubSubManager/SyncReplication/syncData.js +9 -15
  35. package/dist/PubSubManager/SyncReplication/syncData.js.map +1 -1
  36. package/dist/TableConfig/TableConfig.js.map +1 -1
  37. package/dist/runClientRequest.js +1 -1
  38. package/dist/runClientRequest.js.map +1 -1
  39. package/lib/DboBuilder/DboBuilder.ts +1 -1
  40. package/lib/DboBuilder/QueryBuilder/Functions/Functions.ts +142 -557
  41. package/lib/DboBuilder/QueryBuilder/Functions/HASHING_FUNCTIONS.ts +120 -0
  42. package/lib/DboBuilder/QueryBuilder/Functions/TEXT_FUNCTIONS.ts +302 -0
  43. package/lib/DboBuilder/QueryBuilder/Functions/utils.ts +3 -0
  44. package/lib/DboBuilder/TableHandler/update.ts +1 -1
  45. package/lib/DboBuilder/ViewHandler/getExistsCondition.ts +4 -4
  46. package/lib/DboBuilder/ViewHandler/parseFieldFilter.ts +1 -1
  47. package/lib/DboBuilder/runSql/runSQL.ts +1 -1
  48. package/lib/FileManager/FileManager.ts +1 -1
  49. package/lib/Logging.ts +1 -1
  50. package/lib/PubSubManager/PubSubManager.ts +0 -1
  51. package/lib/PubSubManager/SyncReplication/getSyncUtilFunctions.ts +28 -19
  52. package/lib/PubSubManager/SyncReplication/syncData.ts +9 -16
  53. package/lib/TableConfig/TableConfig.ts +1 -1
  54. package/lib/runClientRequest.ts +1 -1
  55. package/package.json +2 -2
@@ -59,7 +59,7 @@ export async function syncData(
59
59
  tableName: sync.table_name,
60
60
  sid: sync.sid,
61
61
  source,
62
- ...pickKeys(sync, ["socket_id", "condition", "last_synced", "is_syncing"]),
62
+ ...pickKeys(sync, ["socket_id", "condition", "lr", "is_syncing"]),
63
63
  lr: JSON.stringify(sync.lr),
64
64
  connectedSocketIds: this.dboBuilder.prostgles.connectedSockets.map((s) => s.id),
65
65
  localParams: undefined,
@@ -111,11 +111,13 @@ export async function syncData(
111
111
  sync.is_syncing = true;
112
112
  },
113
113
  onSend: async (data) => {
114
- const res = await upsertData(data);
114
+ const res = await upsertData(data, "WAL");
115
115
  return res;
116
116
  },
117
- onSendEnd: (batch) => {
118
- updateSyncLR(batch);
117
+ onSendEnd: (batch, _, error) => {
118
+ if (error === undefined) {
119
+ updateSyncLR(batch);
120
+ }
119
121
  sync.is_syncing = false;
120
122
 
121
123
  /**
@@ -125,15 +127,6 @@ export async function syncData(
125
127
  },
126
128
  });
127
129
 
128
- /* Debounce sync requests */
129
- if (!sync.wal.isSending() && sync.is_syncing) {
130
- this.syncTimeout ??= setTimeout(() => {
131
- this.syncTimeout = undefined;
132
- void this.syncData(sync, undefined, source);
133
- }, throttle);
134
- return;
135
- }
136
-
137
130
  /**
138
131
  * Express data sent from a client that has already been synced
139
132
  * Add to WAL manager which will sync at the end
@@ -170,8 +163,8 @@ export async function syncData(
170
163
 
171
164
  /* Make sure trigger is not firing on freshly synced data */
172
165
  if (!rowsFullyMatch(sync.lr, s_lr)) {
173
- from_synced = sync.last_synced;
174
- await logSyncData("sync.last_synced");
166
+ from_synced = Number(sync.lr[synced_field]);
167
+ await logSyncData("sync.lr");
175
168
  } else {
176
169
  await logSyncData("rowsFullyMatch");
177
170
  }
@@ -189,7 +182,7 @@ export async function syncData(
189
182
  await logSyncData("nothingToSync");
190
183
  }
191
184
 
192
- await pushData([], true);
185
+ await pushData({ state: "synced" });
193
186
 
194
187
  sync.is_syncing = false;
195
188
  }
@@ -537,7 +537,7 @@ export default class TableConfigurator {
537
537
  ): Promise<AnyObject> => {
538
538
  const tableHook = this.config[tableHandler.name]?.hooks?.getPreInsertRow;
539
539
  if (tableHandler.is_media) {
540
- return uploadFile.bind(tableHandler)(args) as Promise<AnyObject>;
540
+ return uploadFile.bind(tableHandler)(args);
541
541
  }
542
542
  if (tableHook) {
543
543
  return tableHook(args);
@@ -169,7 +169,7 @@ export const clientCanRunSqlRequest = async function (
169
169
  const allowedToRunSQL =
170
170
  publishParams &&
171
171
  (await (
172
- this.opts.publishRawSQL as undefined | ((params: PublishParams) => Awaitable<boolean | "*">)
172
+ this.opts.publishRawSQL
173
173
  )?.(publishParams));
174
174
  return allowedToRunSQL === true || allowedToRunSQL === "*";
175
175
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "4.2.545",
3
+ "version": "4.2.547",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "pg": "^8.21.0",
58
58
  "pg-cursor": "^2.20.0",
59
59
  "pg-promise": "^12.6.2",
60
- "prostgles-types": "^4.0.263"
60
+ "prostgles-types": "^4.0.264"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@eslint/js": "^9.22.0",