ffc-pay-etl-framework 0.0.5 → 0.0.6-alpha.4
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,5 +1,6 @@
|
|
|
1
1
|
const { Transform } = require('node:stream');
|
|
2
2
|
const { Sequelize } = require('sequelize');
|
|
3
|
+
const debug = require('debug')('destination');
|
|
3
4
|
const DEFAULT_PORT = 5432;
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
@@ -29,7 +30,14 @@ function PostgresDestination(options) {
|
|
|
29
30
|
dialect: 'postgres',
|
|
30
31
|
logging: false
|
|
31
32
|
});
|
|
32
|
-
|
|
33
|
+
try {
|
|
34
|
+
sequelize.authenticate();
|
|
35
|
+
debug('sequelize.authenticate succeeded');
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
debug('sequelize.authenticate failed');
|
|
39
|
+
debug(e);
|
|
40
|
+
}
|
|
33
41
|
function getMappingForColumn(column) {
|
|
34
42
|
const [map] = mapping.filter(m => m.column === column);
|
|
35
43
|
return map;
|
|
@@ -41,6 +49,8 @@ function PostgresDestination(options) {
|
|
|
41
49
|
})
|
|
42
50
|
.join(",")}) VALUES (${chunk._columns.map((column, index) => {
|
|
43
51
|
let mapping = getMappingForColumn(column);
|
|
52
|
+
if (!mapping)
|
|
53
|
+
debug('Mapping not found for column %s', column);
|
|
44
54
|
if (mapping.targetType === "varchar" || mapping.targetType === "char")
|
|
45
55
|
return `'${chunk[index]}'`;
|
|
46
56
|
return chunk[index];
|
|
@@ -54,11 +64,14 @@ function PostgresDestination(options) {
|
|
|
54
64
|
// @ts-ignore
|
|
55
65
|
if (chunk.errors.length === 0 | options.includeErrors) {
|
|
56
66
|
insertStatement = writeInsertStatement(chunk);
|
|
67
|
+
debug('Insert statement: [%s]', insertStatement);
|
|
57
68
|
sequelize.query(insertStatement)
|
|
58
69
|
.then(result => {
|
|
70
|
+
debug('result %o', result);
|
|
59
71
|
chunk._result = result;
|
|
60
72
|
callback(null, chunk);
|
|
61
73
|
}).catch(error => {
|
|
74
|
+
debug('error %o', error);
|
|
62
75
|
chunk.errors.push(error);
|
|
63
76
|
callback(null, chunk);
|
|
64
77
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,6CAVG;IAAwB,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,aAAa;CACrC,
|
|
1
|
+
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,6CAVG;IAAwB,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,aAAa;CACrC,aAkEF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const { Transform } = require('node:stream');
|
|
3
3
|
const { Sequelize } = require('sequelize');
|
|
4
|
+
const debug = require('debug')('destination');
|
|
4
5
|
const DEFAULT_PORT = 5432;
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
@@ -30,7 +31,14 @@ function PostgresDestination(options) {
|
|
|
30
31
|
dialect: 'postgres',
|
|
31
32
|
logging: false
|
|
32
33
|
});
|
|
33
|
-
|
|
34
|
+
try {
|
|
35
|
+
sequelize.authenticate();
|
|
36
|
+
debug('sequelize.authenticate succeeded');
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
debug('sequelize.authenticate failed');
|
|
40
|
+
debug(e);
|
|
41
|
+
}
|
|
34
42
|
function getMappingForColumn(column) {
|
|
35
43
|
const [map] = mapping.filter(m => m.column === column);
|
|
36
44
|
return map;
|
|
@@ -42,6 +50,8 @@ function PostgresDestination(options) {
|
|
|
42
50
|
})
|
|
43
51
|
.join(",")}) VALUES (${chunk._columns.map((column, index) => {
|
|
44
52
|
let mapping = getMappingForColumn(column);
|
|
53
|
+
if (!mapping)
|
|
54
|
+
debug('Mapping not found for column %s', column);
|
|
45
55
|
if (mapping.targetType === "varchar" || mapping.targetType === "char")
|
|
46
56
|
return `'${chunk[index]}'`;
|
|
47
57
|
return chunk[index];
|
|
@@ -55,11 +65,14 @@ function PostgresDestination(options) {
|
|
|
55
65
|
// @ts-ignore
|
|
56
66
|
if (chunk.errors.length === 0 | options.includeErrors) {
|
|
57
67
|
insertStatement = writeInsertStatement(chunk);
|
|
68
|
+
debug('Insert statement: [%s]', insertStatement);
|
|
58
69
|
sequelize.query(insertStatement)
|
|
59
70
|
.then(result => {
|
|
71
|
+
debug('result %o', result);
|
|
60
72
|
chunk._result = result;
|
|
61
73
|
callback(null, chunk);
|
|
62
74
|
}).catch(error => {
|
|
75
|
+
debug('error %o', error);
|
|
63
76
|
chunk.errors.push(error);
|
|
64
77
|
callback(null, chunk);
|
|
65
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,6CAVG;IAAwB,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,aAAa;CACrC,
|
|
1
|
+
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,6CAVG;IAAwB,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,aAAa;CACrC,aAkEF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ffc-pay-etl-framework",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6-alpha.4",
|
|
4
4
|
"publisher": "Defra",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -21,11 +21,18 @@
|
|
|
21
21
|
"author": "Charlie Benger-Stevenson",
|
|
22
22
|
"license": "OGL-UK-3.0",
|
|
23
23
|
"description": "A framework for creating ETL pipelines in node",
|
|
24
|
+
"jest": {
|
|
25
|
+
"setupFiles": [
|
|
26
|
+
"<rootDir>/jest/setEnvVars.js"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
24
29
|
"devDependencies": {
|
|
25
30
|
"all-contributors-cli": "^6.26.1",
|
|
31
|
+
"debug": "^4.3.6",
|
|
26
32
|
"jest": "^29.7.0",
|
|
27
33
|
"nodemon": "^3.1.4",
|
|
28
|
-
"prettier": "3.3.3"
|
|
34
|
+
"prettier": "3.3.3",
|
|
35
|
+
"supports-color": "^9.4.0"
|
|
29
36
|
},
|
|
30
37
|
"dependencies": {
|
|
31
38
|
"@faker-js/faker": "^8.4.1",
|