ffc-pay-etl-framework 1.1.10 → 1.1.11-alpha.2
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 +5 -3
- package/dist/cjs/loaders/csvloader.js +9 -5
- package/dist/cjs/types/destinations/postgresDestination.d.ts +3 -1
- package/dist/cjs/types/destinations/postgresDestination.d.ts.map +1 -1
- package/dist/cjs/types/loaders/csvloader.d.ts +2 -0
- package/dist/cjs/types/loaders/csvloader.d.ts.map +1 -1
- package/dist/esm/destinations/postgresDestination.js +5 -3
- package/dist/esm/loaders/csvloader.js +8 -4
- package/dist/esm/types/destinations/postgresDestination.d.ts +3 -1
- package/dist/esm/types/destinations/postgresDestination.d.ts.map +1 -1
- package/dist/esm/types/loaders/csvloader.d.ts +2 -0
- package/dist/esm/types/loaders/csvloader.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -18,8 +18,8 @@ function hasReturningColumns(mapping) {
|
|
|
18
18
|
function getReturningColumns(mapping) {
|
|
19
19
|
return mapping.filter(m => m.returning === true).map(m => m === null || m === void 0 ? void 0 : m.targetColumn);
|
|
20
20
|
}
|
|
21
|
-
function writeInsertStatement(columnMapping, table, chunk) {
|
|
22
|
-
let statement = `INSERT INTO "${table}" (${chunk._columns.map(column => {
|
|
21
|
+
function writeInsertStatement(columnMapping, table, chunk, schema) {
|
|
22
|
+
let statement = `INSERT INTO ${schema !== null && schema !== void 0 ? schema : 'public'}."${table}" (${chunk._columns.map(column => {
|
|
23
23
|
const mapping = getMappingForColumn(columnMapping, column);
|
|
24
24
|
return (mapping === null || mapping === void 0 ? void 0 : mapping.targetColumn) ? `"${mapping.targetColumn}"` : `"${mapping === null || mapping === void 0 ? void 0 : mapping.column}"`;
|
|
25
25
|
})
|
|
@@ -52,6 +52,7 @@ function writeInsertStatement(columnMapping, table, chunk) {
|
|
|
52
52
|
* @param {Object} options.connectionname
|
|
53
53
|
* @param {Object} options.mapping
|
|
54
54
|
* @param {Object} options.includeErrors
|
|
55
|
+
* @param {String} [options.schema]
|
|
55
56
|
* @returns Transform
|
|
56
57
|
*/
|
|
57
58
|
function PostgresDestination(options) {
|
|
@@ -60,6 +61,7 @@ function PostgresDestination(options) {
|
|
|
60
61
|
const connectionname = options.connectionname;
|
|
61
62
|
const mapping = options.mapping;
|
|
62
63
|
const includeErrors = options.includeErrors;
|
|
64
|
+
const schema = options.schema;
|
|
63
65
|
let lastChunk;
|
|
64
66
|
const transform = new Transform({
|
|
65
67
|
objectMode: true,
|
|
@@ -73,7 +75,7 @@ function PostgresDestination(options) {
|
|
|
73
75
|
let insertStatement;
|
|
74
76
|
// @ts-ignore
|
|
75
77
|
if (chunk.errors.length === 0 || options.includeErrors) {
|
|
76
|
-
insertStatement = writeInsertStatement(mapping, table, chunk);
|
|
78
|
+
insertStatement = writeInsertStatement(mapping, table, chunk, schema);
|
|
77
79
|
debug('Insert statement: [%s]', insertStatement);
|
|
78
80
|
// @ts-ignore
|
|
79
81
|
this.connection.db.query(insertStatement)
|
|
@@ -8,10 +8,11 @@ const { parse } = require("csv-parse");
|
|
|
8
8
|
* @param {String} [options.path]
|
|
9
9
|
* @param {ReadableStream} [options.stream]
|
|
10
10
|
* @param {Number} [options.startingLine]
|
|
11
|
+
* @param {Boolean} [options.relax]
|
|
11
12
|
* @returns StreamReader
|
|
12
13
|
*/
|
|
13
14
|
function CSVLoader(options) {
|
|
14
|
-
var _a;
|
|
15
|
+
var _a, _b;
|
|
15
16
|
let csvLoader;
|
|
16
17
|
if (options.path) {
|
|
17
18
|
csvLoader = fs.createReadStream(options.path);
|
|
@@ -21,11 +22,11 @@ function CSVLoader(options) {
|
|
|
21
22
|
}
|
|
22
23
|
let lineCount = 1;
|
|
23
24
|
const fromLine = (_a = options.startingLine) !== null && _a !== void 0 ? _a : 2;
|
|
25
|
+
const relaxQuotes = (_b = options.relax) !== null && _b !== void 0 ? _b : false;
|
|
24
26
|
csvLoader._columns = options.columns;
|
|
25
27
|
csvLoader.pump = (csvLoader) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.pipe(new Transform({
|
|
28
|
+
const parser = parse({ delimiter: ",", from_line: fromLine, relax_quotes: relaxQuotes });
|
|
29
|
+
const transformer = new Transform({
|
|
29
30
|
readableObjectMode: true,
|
|
30
31
|
writableObjectMode: true,
|
|
31
32
|
emitClose: true,
|
|
@@ -41,7 +42,10 @@ function CSVLoader(options) {
|
|
|
41
42
|
});
|
|
42
43
|
callback(null, chunk);
|
|
43
44
|
}
|
|
44
|
-
})
|
|
45
|
+
});
|
|
46
|
+
return csvLoader
|
|
47
|
+
.pipe(parser)
|
|
48
|
+
.pipe(transformer);
|
|
45
49
|
};
|
|
46
50
|
return csvLoader;
|
|
47
51
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @param {Object} options.connectionname
|
|
6
6
|
* @param {Object} options.mapping
|
|
7
7
|
* @param {Object} options.includeErrors
|
|
8
|
+
* @param {String} [options.schema]
|
|
8
9
|
* @returns Transform
|
|
9
10
|
*/
|
|
10
11
|
export function PostgresDestination(options: {
|
|
@@ -12,8 +13,9 @@ export function PostgresDestination(options: {
|
|
|
12
13
|
connectionname: any;
|
|
13
14
|
mapping: any;
|
|
14
15
|
includeErrors: any;
|
|
16
|
+
schema?: string;
|
|
15
17
|
}): Transform;
|
|
16
|
-
export function writeInsertStatement(columnMapping: any, table: any, chunk: any): string;
|
|
18
|
+
export function writeInsertStatement(columnMapping: any, table: any, chunk: any, schema: any): string;
|
|
17
19
|
export function isKeyWord(column: any): boolean;
|
|
18
20
|
export function getMappingForColumn(mapping: any, column: any): any;
|
|
19
21
|
export function hasReturningColumns(mapping: any): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAmDA
|
|
1
|
+
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAmDA;;;;;;;;;GASG;AACH;IAP2B,KAAK;IACL,cAAc;IACd,OAAO;IACP,aAAa;IACZ,MAAM;cAiEjC;AApGD,sGA0BC;AA5CD,gDAEC;AAED,oEAIC;AAED,2DAEC;AAED,uDAEC"}
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
* @param {String} [options.path]
|
|
6
6
|
* @param {ReadableStream} [options.stream]
|
|
7
7
|
* @param {Number} [options.startingLine]
|
|
8
|
+
* @param {Boolean} [options.relax]
|
|
8
9
|
* @returns StreamReader
|
|
9
10
|
*/
|
|
10
11
|
export function CSVLoader(options: {
|
|
11
12
|
path?: string;
|
|
12
13
|
stream?: ReadableStream;
|
|
13
14
|
startingLine?: number;
|
|
15
|
+
relax?: boolean;
|
|
14
16
|
}): ReadableStream<any> | fs.ReadStream;
|
|
15
17
|
import fs = require("fs");
|
|
16
18
|
//# sourceMappingURL=csvloader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":";AAKA
|
|
1
|
+
{"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":";AAKA;;;;;;;;GAQG;AACH;IAN4B,IAAI;IACI,MAAM,GAA/B,cAAc;IACG,YAAY;IACX,KAAK;wCAyCjC"}
|
|
@@ -20,8 +20,8 @@ function hasReturningColumns(mapping) {
|
|
|
20
20
|
function getReturningColumns(mapping) {
|
|
21
21
|
return mapping.filter(m => m.returning === true).map(m => m?.targetColumn);
|
|
22
22
|
}
|
|
23
|
-
function writeInsertStatement(columnMapping, table, chunk) {
|
|
24
|
-
let statement = `INSERT INTO "${table}" (${chunk._columns.map(column => {
|
|
23
|
+
function writeInsertStatement(columnMapping, table, chunk, schema) {
|
|
24
|
+
let statement = `INSERT INTO ${schema ?? 'public'}."${table}" (${chunk._columns.map(column => {
|
|
25
25
|
const mapping = getMappingForColumn(columnMapping, column);
|
|
26
26
|
return mapping?.targetColumn ? `"${mapping.targetColumn}"` : `"${mapping?.column}"`;
|
|
27
27
|
})
|
|
@@ -54,6 +54,7 @@ function writeInsertStatement(columnMapping, table, chunk) {
|
|
|
54
54
|
* @param {Object} options.connectionname
|
|
55
55
|
* @param {Object} options.mapping
|
|
56
56
|
* @param {Object} options.includeErrors
|
|
57
|
+
* @param {String} [options.schema]
|
|
57
58
|
* @returns Transform
|
|
58
59
|
*/
|
|
59
60
|
function PostgresDestination(options) {
|
|
@@ -62,6 +63,7 @@ function PostgresDestination(options) {
|
|
|
62
63
|
const connectionname = options.connectionname;
|
|
63
64
|
const mapping = options.mapping;
|
|
64
65
|
const includeErrors = options.includeErrors;
|
|
66
|
+
const schema = options.schema;
|
|
65
67
|
let lastChunk;
|
|
66
68
|
const transform = new Transform({
|
|
67
69
|
objectMode: true,
|
|
@@ -75,7 +77,7 @@ function PostgresDestination(options) {
|
|
|
75
77
|
let insertStatement;
|
|
76
78
|
// @ts-ignore
|
|
77
79
|
if (chunk.errors.length === 0 || options.includeErrors) {
|
|
78
|
-
insertStatement = writeInsertStatement(mapping, table, chunk);
|
|
80
|
+
insertStatement = writeInsertStatement(mapping, table, chunk, schema);
|
|
79
81
|
debug('Insert statement: [%s]', insertStatement);
|
|
80
82
|
// @ts-ignore
|
|
81
83
|
this.connection.db.query(insertStatement)
|
|
@@ -10,6 +10,7 @@ const { parse } = require("csv-parse");
|
|
|
10
10
|
* @param {String} [options.path]
|
|
11
11
|
* @param {ReadableStream} [options.stream]
|
|
12
12
|
* @param {Number} [options.startingLine]
|
|
13
|
+
* @param {Boolean} [options.relax]
|
|
13
14
|
* @returns StreamReader
|
|
14
15
|
*/
|
|
15
16
|
function CSVLoader(options) {
|
|
@@ -22,11 +23,11 @@ function CSVLoader(options) {
|
|
|
22
23
|
}
|
|
23
24
|
let lineCount = 1;
|
|
24
25
|
const fromLine = options.startingLine ?? 2;
|
|
26
|
+
const relaxQuotes = options.relax ?? false;
|
|
25
27
|
csvLoader._columns = options.columns;
|
|
26
28
|
csvLoader.pump = (csvLoader) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.pipe(new Transform({
|
|
29
|
+
const parser = parse({ delimiter: ",", from_line: fromLine, relax_quotes: relaxQuotes });
|
|
30
|
+
const transformer = new Transform({
|
|
30
31
|
readableObjectMode: true,
|
|
31
32
|
writableObjectMode: true,
|
|
32
33
|
emitClose: true,
|
|
@@ -42,7 +43,10 @@ function CSVLoader(options) {
|
|
|
42
43
|
});
|
|
43
44
|
callback(null, chunk);
|
|
44
45
|
}
|
|
45
|
-
})
|
|
46
|
+
});
|
|
47
|
+
return csvLoader
|
|
48
|
+
.pipe(parser)
|
|
49
|
+
.pipe(transformer);
|
|
46
50
|
};
|
|
47
51
|
return csvLoader;
|
|
48
52
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @param {Object} options.connectionname
|
|
6
6
|
* @param {Object} options.mapping
|
|
7
7
|
* @param {Object} options.includeErrors
|
|
8
|
+
* @param {String} [options.schema]
|
|
8
9
|
* @returns Transform
|
|
9
10
|
*/
|
|
10
11
|
export function PostgresDestination(options: {
|
|
@@ -12,8 +13,9 @@ export function PostgresDestination(options: {
|
|
|
12
13
|
connectionname: any;
|
|
13
14
|
mapping: any;
|
|
14
15
|
includeErrors: any;
|
|
16
|
+
schema?: string;
|
|
15
17
|
}): Transform;
|
|
16
|
-
export function writeInsertStatement(columnMapping: any, table: any, chunk: any): string;
|
|
18
|
+
export function writeInsertStatement(columnMapping: any, table: any, chunk: any, schema: any): string;
|
|
17
19
|
export function isKeyWord(column: any): boolean;
|
|
18
20
|
export function getMappingForColumn(mapping: any, column: any): any;
|
|
19
21
|
export function hasReturningColumns(mapping: any): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAmDA
|
|
1
|
+
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAmDA;;;;;;;;;GASG;AACH;IAP2B,KAAK;IACL,cAAc;IACd,OAAO;IACP,aAAa;IACZ,MAAM;cAiEjC;AApGD,sGA0BC;AA5CD,gDAEC;AAED,oEAIC;AAED,2DAEC;AAED,uDAEC"}
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
* @param {String} [options.path]
|
|
6
6
|
* @param {ReadableStream} [options.stream]
|
|
7
7
|
* @param {Number} [options.startingLine]
|
|
8
|
+
* @param {Boolean} [options.relax]
|
|
8
9
|
* @returns StreamReader
|
|
9
10
|
*/
|
|
10
11
|
export function CSVLoader(options: {
|
|
11
12
|
path?: string;
|
|
12
13
|
stream?: ReadableStream;
|
|
13
14
|
startingLine?: number;
|
|
15
|
+
relax?: boolean;
|
|
14
16
|
}): ReadableStream<any> | fs.ReadStream;
|
|
15
17
|
import fs = require("fs");
|
|
16
18
|
//# sourceMappingURL=csvloader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":";AAKA
|
|
1
|
+
{"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":";AAKA;;;;;;;;GAQG;AACH;IAN4B,IAAI;IACI,MAAM,GAA/B,cAAc;IACG,YAAY;IACX,KAAK;wCAyCjC"}
|