@voxpelli/pg-utils 3.0.0 → 3.0.1

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":"csv-folder-to-db.d.ts","sourceRoot":"","sources":["csv-folder-to-db.js"],"names":[],"mappings":"AAiEA,8CALW,MAAM,GAAG,IAAI,QACb,MAAM,GAAG,GAAG,2BACZ,MAAM,EAAE,GAAG,SAAS,GAClB,OAAO,CAAC,IAAI,CAAC,CAwBzB;0BA7EyB,IAAI"}
1
+ {"version":3,"file":"csv-folder-to-db.d.ts","sourceRoot":"","sources":["csv-folder-to-db.js"],"names":[],"mappings":"AAiEA,8CALW,MAAM,GAAG,IAAI,QACb,MAAM,GAAG,GAAG,2BACZ,MAAM,EAAE,GAAG,SAAS,GAClB,OAAO,CAAC,IAAI,CAAC,CA0BzB;0BA/EyB,IAAI"}
@@ -70,19 +70,21 @@ export async function csvFromFolderToDb (connection, path, tablesWithDependencie
70
70
 
71
71
  const client = await pool.connect();
72
72
 
73
- for (const file of files) {
74
- const name = pathModule.basename(file, '.csv');
75
- const dbCopy = client.query(copyFrom(`COPY ${name} FROM STDIN WITH (FORMAT csv, HEADER MATCH)`));
76
-
77
- // eslint-disable-next-line security/detect-non-literal-fs-filename
78
- const csvContent = createReadStream(file);
79
-
80
- try {
81
- await promisedPipeline(csvContent, dbCopy);
82
- } catch (cause) {
83
- throw new Error(`Failed inserting data into "${name}"`, { cause });
73
+ try {
74
+ for (const file of files) {
75
+ const name = pathModule.basename(file, '.csv');
76
+ const dbCopy = client.query(copyFrom(`COPY ${name} FROM STDIN WITH (FORMAT csv, HEADER MATCH)`));
77
+
78
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
79
+ const csvContent = createReadStream(file);
80
+
81
+ try {
82
+ await promisedPipeline(csvContent, dbCopy);
83
+ } catch (cause) {
84
+ throw new Error(`Failed inserting data into "${name}"`, { cause });
85
+ }
84
86
  }
87
+ } finally {
88
+ client.release();
85
89
  }
86
-
87
- client.release();
88
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAsBA,+CAHW,MAAM,GACJ,IAAI,CAOhB;AAMD,0DAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAqB3B;AAMD,wCAHW,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CAUzB;AA4BD,qCAHW,OAAO,GACL,KAAK,IAAI,MAAM,EAAE,CAK7B;AA5BD;IAME,mBAJW,KAAK,WACL,MAAM,YACN,YAAY,EAItB;CACF;0BA5EiC,IAAI;4BAAJ,IAAI"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAqBA,+CAHW,MAAM,GACJ,IAAI,CAOhB;AAMD,0DAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAqB3B;AAMD,wCAHW,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CAUzB;AA4BD,qCAHW,OAAO,GACL,KAAK,IAAI,MAAM,EAAE,CAK7B;AA5BD;IAME,mBAJW,KAAK,WACL,MAAM,YACN,YAAY,EAItB;CACF;0BA3EiC,IAAI;4BAAJ,IAAI"}
package/lib/utils.js CHANGED
@@ -12,7 +12,6 @@ import pg from 'pg';
12
12
  *
13
13
  * @see {@link https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS|PostgreSQL Advisory Lock Functions}
14
14
  * @see {@link https://www.postgresql.org/docs/current/explicit-locking.html#ADVISORY-LOCKS|Advisory Locks Overview}
15
-
16
15
  */
17
16
  const LOCK_ID = 42;
18
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxpelli/pg-utils",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": " My personal database utils / helpers for Postgres",
5
5
  "homepage": "http://github.com/voxpelli/pg-utils",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "build:0": "run-s clean",
29
29
  "build:1-declaration": "tsc -p declaration.tsconfig.json",
30
30
  "build": "run-s build:*",
31
- "check:installed-check": "installed-check",
31
+ "check:installed-check": "installed-check -i installed-check",
32
32
  "check:knip": "knip",
33
33
  "check:lint": "eslint",
34
34
  "check:tsc": "tsc",
@@ -48,7 +48,7 @@
48
48
  "@types/chai": "^4.3.20",
49
49
  "@types/chai-as-promised": "^7.1.8",
50
50
  "@types/mocha": "^10.0.10",
51
- "@types/node": "^20.19.30",
51
+ "@types/node": "^20.19.33",
52
52
  "@types/pg-copy-streams": "^1.2.5",
53
53
  "@types/sinon": "^21.0.0",
54
54
  "@voxpelli/eslint-config": "^23.0.0",
@@ -56,11 +56,11 @@
56
56
  "c8": "^10.1.3",
57
57
  "chai": "^4.5.0",
58
58
  "chai-as-promised": "^7.1.2",
59
- "dotenv": "^17.2.3",
59
+ "dotenv": "^17.3.1",
60
60
  "eslint": "^9.39.2",
61
61
  "husky": "^9.1.7",
62
- "installed-check": "^9.3.0",
63
- "knip": "^5.82.1",
62
+ "installed-check": "^10.0.0",
63
+ "knip": "^5.84.0",
64
64
  "mocha": "^11.7.5",
65
65
  "npm-run-all2": "^8.0.4",
66
66
  "sinon": "^21.0.1",
@@ -69,8 +69,8 @@
69
69
  "validate-conventional-commit": "^1.0.4"
70
70
  },
71
71
  "dependencies": {
72
- "@types/pg": "^8.11.10",
73
- "pg": "^8.13.1",
72
+ "@types/pg": "^8.16.0",
73
+ "pg": "^8.18.0",
74
74
  "pg-copy-streams": "^7.0.0",
75
75
  "umzeption": "^0.4.1",
76
76
  "umzug": "^3.8.2"