ffc-pay-etl-framework 1.1.0-alpha.3 → 1.1.0-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.
- package/dist/cjs/destinations/postgresDestination.js +12 -11
- package/dist/cjs/lib/index.js +4 -0
- package/dist/cjs/types/destinations/postgresDestination.d.ts.map +1 -1
- package/dist/cjs/types/lib/index.d.ts.map +1 -1
- package/dist/esm/destinations/postgresDestination.js +12 -11
- package/dist/esm/lib/index.js +4 -0
- package/dist/esm/types/destinations/postgresDestination.d.ts.map +1 -1
- package/dist/esm/types/lib/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,9 @@ function isKeyWord(column) {
|
|
|
6
6
|
return ['USER'].includes(column.toUpperCase());
|
|
7
7
|
}
|
|
8
8
|
function getMappingForColumn(mapping, column) {
|
|
9
|
+
if (mapping.length === 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
9
12
|
const [map] = mapping.filter(m => m.column === column);
|
|
10
13
|
return map;
|
|
11
14
|
}
|
|
@@ -13,34 +16,31 @@ function hasReturningColumns(mapping) {
|
|
|
13
16
|
return mapping.filter(m => m.returning === true).length > 0;
|
|
14
17
|
}
|
|
15
18
|
function getReturningColumns(mapping) {
|
|
16
|
-
return mapping.filter(m => m.returning === true).map(m => m.targetColumn);
|
|
19
|
+
return mapping.filter(m => m.returning === true).map(m => m === null || m === void 0 ? void 0 : m.targetColumn);
|
|
17
20
|
}
|
|
18
21
|
function writeInsertStatement(columnMapping, table, chunk) {
|
|
19
22
|
let statement = `INSERT INTO ${table} (${chunk._columns.map(column => {
|
|
20
23
|
const mapping = getMappingForColumn(columnMapping, column);
|
|
21
|
-
return mapping.targetColumn
|
|
24
|
+
return (mapping === null || mapping === void 0 ? void 0 : mapping.targetColumn)
|
|
22
25
|
?
|
|
23
26
|
isKeyWord(mapping.targetColumn)
|
|
24
27
|
? `"${mapping.targetColumn}"`
|
|
25
28
|
: mapping.targetColumn
|
|
26
29
|
: isKeyWord(column)
|
|
27
|
-
? `"${mapping.column}"`
|
|
28
|
-
: mapping.column;
|
|
30
|
+
? `"${mapping === null || mapping === void 0 ? void 0 : mapping.column}"`
|
|
31
|
+
: mapping === null || mapping === void 0 ? void 0 : mapping.column;
|
|
29
32
|
})
|
|
30
33
|
.join(",")}) VALUES (${chunk._columns.map((column, index) => {
|
|
31
34
|
const mapping = getMappingForColumn(columnMapping, column);
|
|
32
|
-
if (
|
|
33
|
-
debug('Mapping not found for column %s', column);
|
|
34
|
-
}
|
|
35
|
-
if (mapping.targetType === "number" && (isNaN(chunk[index]) || chunk[index] === '')) {
|
|
35
|
+
if ((mapping === null || mapping === void 0 ? void 0 : mapping.targetType) === "number" && (isNaN(chunk[index]) || chunk[index] === '')) {
|
|
36
36
|
debug('Source data is not a number');
|
|
37
37
|
return 0;
|
|
38
38
|
}
|
|
39
|
-
if (mapping.targetType === "varchar" || mapping.targetType === "char") {
|
|
39
|
+
if ((mapping === null || mapping === void 0 ? void 0 : mapping.targetType) === "varchar" || (mapping === null || mapping === void 0 ? void 0 : mapping.targetType) === "char") {
|
|
40
40
|
return `'${chunk[index]}'`;
|
|
41
41
|
}
|
|
42
|
-
if (mapping.targetType === "date") {
|
|
43
|
-
return `to_date('${chunk[index]}','${mapping.format}')`;
|
|
42
|
+
if ((mapping === null || mapping === void 0 ? void 0 : mapping.targetType) === "date") {
|
|
43
|
+
return `to_date('${chunk[index]}','${mapping === null || mapping === void 0 ? void 0 : mapping.format}')`;
|
|
44
44
|
}
|
|
45
45
|
return chunk[index] ? chunk[index] : 'null';
|
|
46
46
|
})})`;
|
|
@@ -108,6 +108,7 @@ function PostgresDestination(options) {
|
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
Object.assign(Transform.prototype, {
|
|
111
|
+
type: 'PostgresDestination',
|
|
111
112
|
setConnection: function (connection) {
|
|
112
113
|
this.connection = connection;
|
|
113
114
|
}.bind(transform),
|
package/dist/cjs/lib/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const EventEmitter = require('node:events');
|
|
|
3
3
|
const util = require('node:util');
|
|
4
4
|
const { RowMetaData } = require("./rowMetaData");
|
|
5
5
|
const { compose } = require("node:stream");
|
|
6
|
+
const { Destinations } = require('..');
|
|
6
7
|
/**
|
|
7
8
|
* @typedef {Object} Etl
|
|
8
9
|
* @function loader
|
|
@@ -65,6 +66,9 @@ function Etl() {
|
|
|
65
66
|
if (connection) {
|
|
66
67
|
destination.setConnection(connection);
|
|
67
68
|
}
|
|
69
|
+
else if (destination.type === 'PostgresDestination') {
|
|
70
|
+
throw new Error(`No connection could be found with name ${connectionname}`);
|
|
71
|
+
}
|
|
68
72
|
if (tasks) {
|
|
69
73
|
for (const task of tasks) {
|
|
70
74
|
task.setETL(self);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAuDA;;;;;;;;GAQG;AACH;IAN2B,KAAK;IACL,cAAc;IACd,OAAO;IACP,aAAa;cAgEvC;AAtGD,yFA8BC;AAhDD,gDAEC;AAED,oEAIC;AAED,2DAEC;AAED,uDAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/index.js"],"names":[],"mappings":";AAOA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,4BAgFC;;IA7EG,aAAe;IACf,qBAAuB;IACvB,sBAAwB;IACxB,qBAAuB;IACvB,0BAA4B;IAC5B,uBAAyB;IAEzB,6BAGC;IAED,gBAgBC;IAED,sCAUC;IAED,qCAGC;IAED,mCAGC;IAED,wDAiBC;IAED,mCAGC"}
|
|
@@ -8,6 +8,9 @@ function isKeyWord(column) {
|
|
|
8
8
|
return ['USER'].includes(column.toUpperCase());
|
|
9
9
|
}
|
|
10
10
|
function getMappingForColumn(mapping, column) {
|
|
11
|
+
if (mapping.length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
11
14
|
const [map] = mapping.filter(m => m.column === column);
|
|
12
15
|
return map;
|
|
13
16
|
}
|
|
@@ -15,34 +18,31 @@ function hasReturningColumns(mapping) {
|
|
|
15
18
|
return mapping.filter(m => m.returning === true).length > 0;
|
|
16
19
|
}
|
|
17
20
|
function getReturningColumns(mapping) {
|
|
18
|
-
return mapping.filter(m => m.returning === true).map(m => m
|
|
21
|
+
return mapping.filter(m => m.returning === true).map(m => m?.targetColumn);
|
|
19
22
|
}
|
|
20
23
|
function writeInsertStatement(columnMapping, table, chunk) {
|
|
21
24
|
let statement = `INSERT INTO ${table} (${chunk._columns.map(column => {
|
|
22
25
|
const mapping = getMappingForColumn(columnMapping, column);
|
|
23
|
-
return mapping
|
|
26
|
+
return mapping?.targetColumn
|
|
24
27
|
?
|
|
25
28
|
isKeyWord(mapping.targetColumn)
|
|
26
29
|
? `"${mapping.targetColumn}"`
|
|
27
30
|
: mapping.targetColumn
|
|
28
31
|
: isKeyWord(column)
|
|
29
|
-
? `"${mapping
|
|
30
|
-
: mapping
|
|
32
|
+
? `"${mapping?.column}"`
|
|
33
|
+
: mapping?.column;
|
|
31
34
|
})
|
|
32
35
|
.join(",")}) VALUES (${chunk._columns.map((column, index) => {
|
|
33
36
|
const mapping = getMappingForColumn(columnMapping, column);
|
|
34
|
-
if (
|
|
35
|
-
debug('Mapping not found for column %s', column);
|
|
36
|
-
}
|
|
37
|
-
if (mapping.targetType === "number" && (isNaN(chunk[index]) || chunk[index] === '')) {
|
|
37
|
+
if (mapping?.targetType === "number" && (isNaN(chunk[index]) || chunk[index] === '')) {
|
|
38
38
|
debug('Source data is not a number');
|
|
39
39
|
return 0;
|
|
40
40
|
}
|
|
41
|
-
if (mapping
|
|
41
|
+
if (mapping?.targetType === "varchar" || mapping?.targetType === "char") {
|
|
42
42
|
return `'${chunk[index]}'`;
|
|
43
43
|
}
|
|
44
|
-
if (mapping
|
|
45
|
-
return `to_date('${chunk[index]}','${mapping
|
|
44
|
+
if (mapping?.targetType === "date") {
|
|
45
|
+
return `to_date('${chunk[index]}','${mapping?.format}')`;
|
|
46
46
|
}
|
|
47
47
|
return chunk[index] ? chunk[index] : 'null';
|
|
48
48
|
})})`;
|
|
@@ -109,6 +109,7 @@ function PostgresDestination(options) {
|
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
Object.assign(Transform.prototype, {
|
|
112
|
+
type: 'PostgresDestination',
|
|
112
113
|
setConnection: function (connection) {
|
|
113
114
|
this.connection = connection;
|
|
114
115
|
}.bind(transform),
|
package/dist/esm/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const EventEmitter = require('node:events');
|
|
|
5
5
|
const util = require('node:util');
|
|
6
6
|
const { RowMetaData } = require("./rowMetaData");
|
|
7
7
|
const { compose } = require("node:stream");
|
|
8
|
+
const { Destinations } = require('..');
|
|
8
9
|
/**
|
|
9
10
|
* @typedef {Object} Etl
|
|
10
11
|
* @function loader
|
|
@@ -67,6 +68,9 @@ function Etl() {
|
|
|
67
68
|
if (connection) {
|
|
68
69
|
destination.setConnection(connection);
|
|
69
70
|
}
|
|
71
|
+
else if (destination.type === 'PostgresDestination') {
|
|
72
|
+
throw new Error(`No connection could be found with name ${connectionname}`);
|
|
73
|
+
}
|
|
70
74
|
if (tasks) {
|
|
71
75
|
for (const task of tasks) {
|
|
72
76
|
task.setETL(self);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAuDA;;;;;;;;GAQG;AACH;IAN2B,KAAK;IACL,cAAc;IACd,OAAO;IACP,aAAa;cAgEvC;AAtGD,yFA8BC;AAhDD,gDAEC;AAED,oEAIC;AAED,2DAEC;AAED,uDAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/index.js"],"names":[],"mappings":";AAOA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,4BAgFC;;IA7EG,aAAe;IACf,qBAAuB;IACvB,sBAAwB;IACxB,qBAAuB;IACvB,0BAA4B;IAC5B,uBAAyB;IAEzB,6BAGC;IAED,gBAgBC;IAED,sCAUC;IAED,qCAGC;IAED,mCAGC;IAED,wDAiBC;IAED,mCAGC"}
|