@opengis/fastify-table 2.5.28 → 2.5.29

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.
@@ -1 +1 @@
1
- {"version":3,"file":"logChanges.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/crud/funcs/utils/logChanges.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAoD5D,wBAA8B,UAAU,CAAC,EACvC,EAAE,EACF,KAAK,EAAE,MAAM,EACb,SAAS,EACT,OAAO,EACP,EAAE,EACF,IAAI,EACJ,GAAO,EACP,IAAI,GACL,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;;;;;;;;;;;;;;;;;;;;UA0MA"}
1
+ {"version":3,"file":"logChanges.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/crud/funcs/utils/logChanges.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA4D5D,wBAA8B,UAAU,CAAC,EACvC,EAAE,EACF,KAAK,EAAE,MAAM,EACb,SAAS,EACT,OAAO,EACP,EAAE,EACF,IAAI,EACJ,GAAO,EACP,IAAI,GACL,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;;;;;;;;;;;;;;;;;;;;UAoNA"}
@@ -39,6 +39,12 @@ function getValue(val, tableName) {
39
39
  if (["crm.files"].includes(tableName)) {
40
40
  return typeof val === "object" ? JSON.stringify(val) : val;
41
41
  }
42
+ if ((process.env.LOG_TABLE_CHANGES_JSON === "true" ||
43
+ config.LOG_TABLE_CHANGES_JSON) &&
44
+ val &&
45
+ typeof val === "object") {
46
+ return JSON.stringify(val);
47
+ }
42
48
  return typeof val === "object"
43
49
  ? null
44
50
  : val?.toString?.()?.substring?.(0, logLength);
@@ -112,23 +118,22 @@ export default async function logChanges({ pg, table: table1, tokenData, referer
112
118
  [curr.name]: pg?.pgType?.[curr.dataTypeID],
113
119
  }), {});
114
120
  if (type !== "DELETE") {
115
- Object.keys(row || {})
121
+ const newObj2 = Object.keys(row || {})
116
122
  .filter((key) => !systemColumns.includes(key))
117
- .reduce((acc, curr) => {
118
- Object.assign(newObj1, {
119
- [titles[curr] || curr]: columnTypes[curr] === "geometry"
120
- ? {}
121
- : {
122
- value: getValue(row[curr], table),
123
- hash: typeof row[curr] === "boolean" || row[curr]
124
- ? createHash("md5")
125
- .update(JSON.stringify(row[curr]))
126
- .digest("hex")
127
- : null,
128
- },
129
- });
130
- return acc;
131
- });
123
+ .reduce((acc, curr) => ({
124
+ ...acc,
125
+ [titles[curr] || curr]: columnTypes[curr] === "geometry"
126
+ ? {}
127
+ : {
128
+ value: getValue(row[curr], table),
129
+ hash: typeof row[curr] === "boolean" || row[curr]
130
+ ? createHash("md5")
131
+ .update(JSON.stringify(row[curr]))
132
+ .digest("hex")
133
+ : null,
134
+ },
135
+ }), {});
136
+ Object.assign(newObj1, newObj2);
132
137
  }
133
138
  await Promise.all(Object.keys(row || {})
134
139
  .filter((key) => row[key] && columnTypes[key] === "geometry")
@@ -192,7 +197,7 @@ export default async function logChanges({ pg, table: table1, tokenData, referer
192
197
  };
193
198
  }
194
199
  catch (err) {
195
- console.error("logChanges error", type, table, id, data, err.toString());
200
+ console.error("logChanges error", type, table, id, data, err.toString(), err.stack);
196
201
  return {
197
202
  error: err.toString(),
198
203
  entity_type: table,
@@ -1,19 +1,20 @@
1
1
  import { beforeEach, afterEach, afterAll } from "vitest";
2
2
  import { build, teardown } from "./helper.js";
3
+ const timeoutMs = process.platform === "win32" ? 500000 : 5000;
3
4
  beforeEach(async () => {
4
5
  if (process.env.trace === "true")
5
6
  console.log("build after each bun test start...");
6
7
  await build();
7
8
  if (process.env.trace === "true")
8
9
  console.log("build after each bun test finished");
9
- });
10
+ }, timeoutMs);
10
11
  afterEach(async () => {
11
12
  if (process.env.trace === "true")
12
13
  console.log("teardown after each bun test start...");
13
14
  // await teardown();
14
15
  if (process.env.trace === "true")
15
16
  console.log("teardown after each bun test finished");
16
- });
17
+ }, timeoutMs);
17
18
  afterAll(async () => {
18
19
  console.log("teardown after all bun test start...");
19
20
  await teardown();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.5.28",
3
+ "version": "2.5.29",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [