ffc-pay-etl-framework 0.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.
- package/LICENSE.md +24 -0
- package/README.md +55 -0
- package/dist/cjs/destinations/consoleDestination.js +21 -0
- package/dist/cjs/destinations/csvFileDestination.js +48 -0
- package/dist/cjs/destinations/index.js +11 -0
- package/dist/cjs/destinations/postgresDestination.js +67 -0
- package/dist/cjs/destinations/sqlFileDestination.js +64 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/lib/index.js +46 -0
- package/dist/cjs/lib/rowMetaData.js +23 -0
- package/dist/cjs/loaders/csvloader.js +31 -0
- package/dist/cjs/loaders/index.js +4 -0
- package/dist/cjs/transformers/fakerTransformer.js +39 -0
- package/dist/cjs/transformers/index.js +6 -0
- package/dist/cjs/transformers/toUpperCaseTransformer.js +24 -0
- package/dist/cjs/types/destinations/consoleDestination.d.ts +11 -0
- package/dist/cjs/types/destinations/consoleDestination.d.ts.map +1 -0
- package/dist/cjs/types/destinations/csvFileDestination.d.ts +17 -0
- package/dist/cjs/types/destinations/csvFileDestination.d.ts.map +1 -0
- package/dist/cjs/types/destinations/index.d.ts +7 -0
- package/dist/cjs/types/destinations/index.d.ts.map +1 -0
- package/dist/cjs/types/destinations/postgresDestination.d.ts +23 -0
- package/dist/cjs/types/destinations/postgresDestination.d.ts.map +1 -0
- package/dist/cjs/types/destinations/sqlFileDestination.d.ts +24 -0
- package/dist/cjs/types/destinations/sqlFileDestination.d.ts.map +1 -0
- package/dist/cjs/types/index.d.ts +7 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/lib/index.d.ts +25 -0
- package/dist/cjs/types/lib/index.d.ts.map +1 -0
- package/dist/cjs/types/lib/rowMetaData.d.ts +3 -0
- package/dist/cjs/types/lib/rowMetaData.d.ts.map +1 -0
- package/dist/cjs/types/loaders/csvloader.d.ts +11 -0
- package/dist/cjs/types/loaders/csvloader.d.ts.map +1 -0
- package/dist/cjs/types/loaders/index.d.ts +3 -0
- package/dist/cjs/types/loaders/index.d.ts.map +1 -0
- package/dist/cjs/types/transformers/fakerTransformer.d.ts +37 -0
- package/dist/cjs/types/transformers/fakerTransformer.d.ts.map +1 -0
- package/dist/cjs/types/transformers/index.d.ts +4 -0
- package/dist/cjs/types/transformers/index.d.ts.map +1 -0
- package/dist/cjs/types/transformers/toUpperCaseTransformer.d.ts +23 -0
- package/dist/cjs/types/transformers/toUpperCaseTransformer.d.ts.map +1 -0
- package/dist/cjs/types/validators/index.d.ts +5 -0
- package/dist/cjs/types/validators/index.d.ts.map +1 -0
- package/dist/cjs/types/validators/multiToolValidator.d.ts +23 -0
- package/dist/cjs/types/validators/multiToolValidator.d.ts.map +1 -0
- package/dist/cjs/types/validators/requiredValidator.d.ts +13 -0
- package/dist/cjs/types/validators/requiredValidator.d.ts.map +1 -0
- package/dist/cjs/types/validators/uniqueValidator.d.ts +29 -0
- package/dist/cjs/types/validators/uniqueValidator.d.ts.map +1 -0
- package/dist/cjs/validators/index.js +8 -0
- package/dist/cjs/validators/multiToolValidator.js +48 -0
- package/dist/cjs/validators/requiredValidator.js +33 -0
- package/dist/cjs/validators/uniqueValidator.js +40 -0
- package/dist/esm/destinations/consoleDestination.js +22 -0
- package/dist/esm/destinations/csvFileDestination.js +49 -0
- package/dist/esm/destinations/index.js +12 -0
- package/dist/esm/destinations/postgresDestination.js +68 -0
- package/dist/esm/destinations/sqlFileDestination.js +65 -0
- package/dist/esm/index.mjs +13 -0
- package/dist/esm/lib/index.js +47 -0
- package/dist/esm/lib/rowMetaData.js +24 -0
- package/dist/esm/loaders/csvloader.js +32 -0
- package/dist/esm/loaders/index.js +5 -0
- package/dist/esm/transformers/fakerTransformer.js +40 -0
- package/dist/esm/transformers/index.js +7 -0
- package/dist/esm/transformers/toUpperCaseTransformer.js +25 -0
- package/dist/esm/types/destinations/consoleDestination.d.ts +11 -0
- package/dist/esm/types/destinations/consoleDestination.d.ts.map +1 -0
- package/dist/esm/types/destinations/csvFileDestination.d.ts +17 -0
- package/dist/esm/types/destinations/csvFileDestination.d.ts.map +1 -0
- package/dist/esm/types/destinations/index.d.ts +7 -0
- package/dist/esm/types/destinations/index.d.ts.map +1 -0
- package/dist/esm/types/destinations/postgresDestination.d.ts +23 -0
- package/dist/esm/types/destinations/postgresDestination.d.ts.map +1 -0
- package/dist/esm/types/destinations/sqlFileDestination.d.ts +24 -0
- package/dist/esm/types/destinations/sqlFileDestination.d.ts.map +1 -0
- package/dist/esm/types/index.d.ts +7 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/lib/index.d.ts +25 -0
- package/dist/esm/types/lib/index.d.ts.map +1 -0
- package/dist/esm/types/lib/rowMetaData.d.ts +3 -0
- package/dist/esm/types/lib/rowMetaData.d.ts.map +1 -0
- package/dist/esm/types/loaders/csvloader.d.ts +11 -0
- package/dist/esm/types/loaders/csvloader.d.ts.map +1 -0
- package/dist/esm/types/loaders/index.d.ts +3 -0
- package/dist/esm/types/loaders/index.d.ts.map +1 -0
- package/dist/esm/types/transformers/fakerTransformer.d.ts +37 -0
- package/dist/esm/types/transformers/fakerTransformer.d.ts.map +1 -0
- package/dist/esm/types/transformers/index.d.ts +4 -0
- package/dist/esm/types/transformers/index.d.ts.map +1 -0
- package/dist/esm/types/transformers/toUpperCaseTransformer.d.ts +23 -0
- package/dist/esm/types/transformers/toUpperCaseTransformer.d.ts.map +1 -0
- package/dist/esm/types/validators/index.d.ts +5 -0
- package/dist/esm/types/validators/index.d.ts.map +1 -0
- package/dist/esm/types/validators/multiToolValidator.d.ts +23 -0
- package/dist/esm/types/validators/multiToolValidator.d.ts.map +1 -0
- package/dist/esm/types/validators/requiredValidator.d.ts +13 -0
- package/dist/esm/types/validators/requiredValidator.d.ts.map +1 -0
- package/dist/esm/types/validators/uniqueValidator.d.ts +29 -0
- package/dist/esm/types/validators/uniqueValidator.d.ts.map +1 -0
- package/dist/esm/validators/index.js +9 -0
- package/dist/esm/validators/multiToolValidator.js +49 -0
- package/dist/esm/validators/requiredValidator.js +34 -0
- package/dist/esm/validators/uniqueValidator.js +41 -0
- package/package.json +56 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { Transform } = require("node:stream");
|
|
3
|
+
const { faker } = require("@faker-js/faker");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} options
|
|
7
|
+
* @param {Array} options.columns {
|
|
8
|
+
* columns: [
|
|
9
|
+
* {
|
|
10
|
+
* name: "column-name",
|
|
11
|
+
* faker: "company.name"
|
|
12
|
+
* }
|
|
13
|
+
* ]
|
|
14
|
+
* }
|
|
15
|
+
* @returns StreamReader
|
|
16
|
+
*/
|
|
17
|
+
function FakerTransformer(options) {
|
|
18
|
+
let self = this;
|
|
19
|
+
self.columns = options.columns;
|
|
20
|
+
function getFaker(fakerType) {
|
|
21
|
+
return fakerType.split('.').reduce((a, b) => {
|
|
22
|
+
return Object.keys(a).length === 0 ? faker[b] : a[b];
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
return new Transform({
|
|
26
|
+
readableObjectMode: true,
|
|
27
|
+
writableObjectMode: true,
|
|
28
|
+
transform(chunk, _, callback) {
|
|
29
|
+
const { _columns } = chunk;
|
|
30
|
+
self.columns.forEach(column => {
|
|
31
|
+
const colIndex = _columns.indexOf(column.name);
|
|
32
|
+
chunk[colIndex] = getFaker(column.faker)();
|
|
33
|
+
});
|
|
34
|
+
callback(null, chunk);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
module.exports = {
|
|
39
|
+
FakerTransformer
|
|
40
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { Transform } = require("node:stream");
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} options
|
|
6
|
+
* @param {String} options.column
|
|
7
|
+
* @returns Writable
|
|
8
|
+
*/
|
|
9
|
+
function ToUpperCaseTransformer(options) {
|
|
10
|
+
let self = this;
|
|
11
|
+
self.column = options.column;
|
|
12
|
+
return new Transform({
|
|
13
|
+
readableObjectMode: true,
|
|
14
|
+
writableObjectMode: true,
|
|
15
|
+
transform(chunk, _, callback) {
|
|
16
|
+
const { _columns } = chunk;
|
|
17
|
+
const colIndex = _columns.indexOf(self.column);
|
|
18
|
+
chunk[colIndex] = chunk[colIndex].toUpperCase();
|
|
19
|
+
callback(null, chunk);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
module.exports = {
|
|
24
|
+
ToUpperCaseTransformer
|
|
25
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {String} options.includeErrors
|
|
5
|
+
* @returns Writable
|
|
6
|
+
*/
|
|
7
|
+
export function ConsoleDestination(options: {
|
|
8
|
+
includeErrors: string;
|
|
9
|
+
}): Writable;
|
|
10
|
+
import { Writable } from "stream";
|
|
11
|
+
//# sourceMappingURL=consoleDestination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/consoleDestination.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,4CAHG;IAAwB,aAAa;CACrC,YAYF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {String} options.fileName
|
|
5
|
+
* @param {Boolean} options.headers
|
|
6
|
+
* @param {Boolean} options.includeErrors
|
|
7
|
+
* @param {Boolean} options.quotationMarks
|
|
8
|
+
* @returns Writable
|
|
9
|
+
*/
|
|
10
|
+
export function CSVFileDestination(options: {
|
|
11
|
+
fileName: string;
|
|
12
|
+
headers: boolean;
|
|
13
|
+
includeErrors: boolean;
|
|
14
|
+
quotationMarks: boolean;
|
|
15
|
+
}): Writable;
|
|
16
|
+
import { Writable } from "stream";
|
|
17
|
+
//# sourceMappingURL=csvFileDestination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csvFileDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/csvFileDestination.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,4CANG;IAAwB,QAAQ;IACP,OAAO;IACP,aAAa;IACb,cAAc;CACvC,YAkCF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConsoleDestination } from "./consoleDestination";
|
|
2
|
+
import { SQLFileDestination } from "./sqlFileDestination";
|
|
3
|
+
import { SQL_MODE } from "./sqlFileDestination";
|
|
4
|
+
import { CSVFileDestination } from "./csvFileDestination";
|
|
5
|
+
import { PostgresDestination } from "./postgresDestination";
|
|
6
|
+
export { ConsoleDestination, SQLFileDestination, SQL_MODE, CSVFileDestination, PostgresDestination };
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/destinations/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {Object} options.table
|
|
5
|
+
* @param {Object} options.username
|
|
6
|
+
* @param {Object} options.password
|
|
7
|
+
* @param {Object} options.database
|
|
8
|
+
* @param {Object} options.host
|
|
9
|
+
* @param {Object} options.mapping
|
|
10
|
+
* @param {Object} options.includeErrors
|
|
11
|
+
* @returns Transform
|
|
12
|
+
*/
|
|
13
|
+
export function PostgresDestination(options: {
|
|
14
|
+
table: any;
|
|
15
|
+
username: any;
|
|
16
|
+
password: any;
|
|
17
|
+
database: any;
|
|
18
|
+
host: any;
|
|
19
|
+
mapping: any;
|
|
20
|
+
includeErrors: any;
|
|
21
|
+
}): Transform;
|
|
22
|
+
import { Transform } from "stream";
|
|
23
|
+
//# sourceMappingURL=postgresDestination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgresDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/postgresDestination.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,6CATG;IAAwB,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,IAAI;IACJ,OAAO;IACP,aAAa;CACrC,aAuDF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {String} options.fileName
|
|
5
|
+
* @param {SQL_MODE} options.mode
|
|
6
|
+
* @param {String} options.table
|
|
7
|
+
* @param {Array} options.mapping
|
|
8
|
+
* @param {Boolean} options.includeErrors
|
|
9
|
+
* @returns Transform
|
|
10
|
+
*/
|
|
11
|
+
export function SQLFileDestination(options: {
|
|
12
|
+
fileName: string;
|
|
13
|
+
mode: SQL_MODE;
|
|
14
|
+
table: string;
|
|
15
|
+
mapping: any[];
|
|
16
|
+
includeErrors: boolean;
|
|
17
|
+
}): Writable;
|
|
18
|
+
export type SQL_MODE = number;
|
|
19
|
+
export namespace SQL_MODE {
|
|
20
|
+
let INSERT_MODE: number;
|
|
21
|
+
let UPDATE_MODE: number;
|
|
22
|
+
}
|
|
23
|
+
import { Writable } from "stream";
|
|
24
|
+
//# sourceMappingURL=sqlFileDestination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlFileDestination.d.ts","sourceRoot":"","sources":["../../../../src/destinations/sqlFileDestination.js"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AACH,4CAPG;IAAwB,QAAQ;IACN,IAAI,EAAtB,QAAQ;IACQ,KAAK;IACN,OAAO;IACL,aAAa;CACtC,YA4CF;uBA3DS,MAAM"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Etl = require("./lib");
|
|
2
|
+
import Validators = require("./validators");
|
|
3
|
+
import Transformers = require("./transformers");
|
|
4
|
+
import Loaders = require("./loaders");
|
|
5
|
+
import Destinations = require("./destinations");
|
|
6
|
+
export { Etl, Validators, Transformers, Loaders, Destinations };
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type Etl = any;
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} Etl
|
|
4
|
+
* @function loader
|
|
5
|
+
* @function pump
|
|
6
|
+
* @function validator
|
|
7
|
+
* @function destination
|
|
8
|
+
* @function transform
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @returns Etl
|
|
13
|
+
*/
|
|
14
|
+
export function Etl(): void;
|
|
15
|
+
export class Etl {
|
|
16
|
+
validatorList: any[];
|
|
17
|
+
transformationList: any[];
|
|
18
|
+
destinationList: any[];
|
|
19
|
+
loader: (loader: any) => this;
|
|
20
|
+
pump: () => void;
|
|
21
|
+
validator: (validator: any) => this;
|
|
22
|
+
destination: (destination: any) => this;
|
|
23
|
+
transform: (transform: any) => this;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/index.js"],"names":[],"mappings":";AAIA;;;;;;;GAOG;AAEH;;;GAGG;AACH,4BAwCC;;IAtCG,qBAAuB;IACvB,0BAA4B;IAC5B,uBAAyB;IAEzB,8BAGC;IAED,iBAWC;IAED,oCAGC;IAED,wCAGC;IAED,oCAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowMetaData.d.ts","sourceRoot":"","sources":["../../../../src/lib/rowMetaData.js"],"names":[],"mappings":"AAIA,qDAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,mCAHG;IAAwB,IAAI;CAC5B,iBAmBF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/loaders/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {Array} options.columns {
|
|
5
|
+
* columns: [
|
|
6
|
+
* {
|
|
7
|
+
* name: "column-name",
|
|
8
|
+
* faker: "company.name"
|
|
9
|
+
* }
|
|
10
|
+
* ]
|
|
11
|
+
* }
|
|
12
|
+
* @returns StreamReader
|
|
13
|
+
*/
|
|
14
|
+
export function FakerTransformer(options: {
|
|
15
|
+
columns: any[];
|
|
16
|
+
}): Transform;
|
|
17
|
+
export class FakerTransformer {
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} options
|
|
21
|
+
* @param {Array} options.columns {
|
|
22
|
+
* columns: [
|
|
23
|
+
* {
|
|
24
|
+
* name: "column-name",
|
|
25
|
+
* faker: "company.name"
|
|
26
|
+
* }
|
|
27
|
+
* ]
|
|
28
|
+
* }
|
|
29
|
+
* @returns StreamReader
|
|
30
|
+
*/
|
|
31
|
+
constructor(options: {
|
|
32
|
+
columns: any[];
|
|
33
|
+
});
|
|
34
|
+
columns: any[];
|
|
35
|
+
}
|
|
36
|
+
import { Transform } from "stream";
|
|
37
|
+
//# sourceMappingURL=fakerTransformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakerTransformer.d.ts","sourceRoot":"","sources":["../../../../src/transformers/fakerTransformer.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,0CAVG;IAAuB,OAAO;CAQ9B,aAsBF;;IAjCD;;;;;;;;;;;;OAYG;IACH,qBAVG;QAAuB,OAAO;KAQ9B,EAsBF;IAlBG,eAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transformers/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {String} options.column
|
|
5
|
+
* @returns Writable
|
|
6
|
+
*/
|
|
7
|
+
export function ToUpperCaseTransformer(options: {
|
|
8
|
+
column: string;
|
|
9
|
+
}): Transform;
|
|
10
|
+
export class ToUpperCaseTransformer {
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} options
|
|
14
|
+
* @param {String} options.column
|
|
15
|
+
* @returns Writable
|
|
16
|
+
*/
|
|
17
|
+
constructor(options: {
|
|
18
|
+
column: string;
|
|
19
|
+
});
|
|
20
|
+
column: string;
|
|
21
|
+
}
|
|
22
|
+
import { Transform } from "stream";
|
|
23
|
+
//# sourceMappingURL=toUpperCaseTransformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toUpperCaseTransformer.d.ts","sourceRoot":"","sources":["../../../../src/transformers/toUpperCaseTransformer.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,gDAHG;IAAwB,MAAM;CAC9B,aAgBF;;IApBD;;;;;OAKG;IACH,qBAHG;QAAwB,MAAM;KAC9B,EAgBF;IAZG,eAA4B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RequiredValidator } from "./requiredValidator";
|
|
2
|
+
import { UniqueValidator } from "./uniqueValidator";
|
|
3
|
+
import { MultiToolValidator } from "./multiToolValidator";
|
|
4
|
+
export { RequiredValidator, UniqueValidator, MultiToolValidator };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/validators/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {Array} options.columns { columns: [
|
|
5
|
+
* {
|
|
6
|
+
* name: "column-name",
|
|
7
|
+
* validator: "isAlphanumeric",
|
|
8
|
+
* args: {
|
|
9
|
+
* locale: "en-GB",
|
|
10
|
+
* options: {
|
|
11
|
+
* ignore: "-;%/ "
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ]
|
|
16
|
+
* }
|
|
17
|
+
* @returns Writable
|
|
18
|
+
*/
|
|
19
|
+
export function MultiToolValidator(options: {
|
|
20
|
+
columns: any[];
|
|
21
|
+
}): Transform;
|
|
22
|
+
import { Transform } from "stream";
|
|
23
|
+
//# sourceMappingURL=multiToolValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiToolValidator.d.ts","sourceRoot":"","sources":["../../../../src/validators/multiToolValidator.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AACH,4CAfG;IAAuB,OAAO;CAa9B,aAyBF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {String} options.message
|
|
5
|
+
* @param {Array} options.columns
|
|
6
|
+
* @returns Transform
|
|
7
|
+
*/
|
|
8
|
+
export function RequiredValidator(options: {
|
|
9
|
+
message: string;
|
|
10
|
+
columns: any[];
|
|
11
|
+
}): Transform;
|
|
12
|
+
import { Transform } from "stream";
|
|
13
|
+
//# sourceMappingURL=requiredValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiredValidator.d.ts","sourceRoot":"","sources":["../../../../src/validators/requiredValidator.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,2CAJG;IAAwB,OAAO;IACR,OAAO;CAC9B,aAsBF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {String} options.message
|
|
5
|
+
* @param {String} options.column
|
|
6
|
+
* @returns Transform
|
|
7
|
+
*/
|
|
8
|
+
export function UniqueValidator(options: {
|
|
9
|
+
message: string;
|
|
10
|
+
column: string;
|
|
11
|
+
}): Transform;
|
|
12
|
+
export class UniqueValidator {
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} options
|
|
16
|
+
* @param {String} options.message
|
|
17
|
+
* @param {String} options.column
|
|
18
|
+
* @returns Transform
|
|
19
|
+
*/
|
|
20
|
+
constructor(options: {
|
|
21
|
+
message: string;
|
|
22
|
+
column: string;
|
|
23
|
+
});
|
|
24
|
+
column: string;
|
|
25
|
+
message: string;
|
|
26
|
+
uniqueColumnRows: any[];
|
|
27
|
+
}
|
|
28
|
+
import { Transform } from "stream";
|
|
29
|
+
//# sourceMappingURL=uniqueValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniqueValidator.d.ts","sourceRoot":"","sources":["../../../../src/validators/uniqueValidator.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,yCAJG;IAAwB,OAAO;IACP,MAAM;CAC9B,aA6BF;;IAlCD;;;;;;OAMG;IACH,qBAJG;QAAwB,OAAO;QACP,MAAM;KAC9B,EA6BF;IAzBG,eAA4B;IAC5B,gBAAwF;IACxF,wBAA0B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { RequiredValidator } = require("./requiredValidator");
|
|
3
|
+
const { UniqueValidator } = require("./uniqueValidator");
|
|
4
|
+
const { MultiToolValidator } = require("./multiToolValidator");
|
|
5
|
+
module.exports = {
|
|
6
|
+
RequiredValidator,
|
|
7
|
+
UniqueValidator,
|
|
8
|
+
MultiToolValidator
|
|
9
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
const { Transform } = require("stream");
|
|
4
|
+
const validator = require('validator');
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} options
|
|
8
|
+
* @param {Array} options.columns { columns: [
|
|
9
|
+
* {
|
|
10
|
+
* name: "column-name",
|
|
11
|
+
* validator: "isAlphanumeric",
|
|
12
|
+
* args: {
|
|
13
|
+
* locale: "en-GB",
|
|
14
|
+
* options: {
|
|
15
|
+
* ignore: "-;%/ "
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ]
|
|
20
|
+
* }
|
|
21
|
+
* @returns Writable
|
|
22
|
+
*/
|
|
23
|
+
function MultiToolValidator(options) {
|
|
24
|
+
function getValidator(validatorType) {
|
|
25
|
+
return validator[validatorType];
|
|
26
|
+
}
|
|
27
|
+
return new Transform({
|
|
28
|
+
readableObjectMode: true,
|
|
29
|
+
writableObjectMode: true,
|
|
30
|
+
decodeStrings: false,
|
|
31
|
+
construct(callback) {
|
|
32
|
+
this.columns = options.columns;
|
|
33
|
+
callback();
|
|
34
|
+
},
|
|
35
|
+
transform(chunk, _, callback) {
|
|
36
|
+
const { _columns } = chunk;
|
|
37
|
+
this.columns.forEach(column => {
|
|
38
|
+
const colIndex = _columns.indexOf(column.name);
|
|
39
|
+
const vtr = getValidator(column.validator);
|
|
40
|
+
if (!vtr(chunk[colIndex], ...Object.values(column.args)))
|
|
41
|
+
chunk.errors.push(`${column.validator} returned invalid status in column ${colIndex}`);
|
|
42
|
+
});
|
|
43
|
+
callback(null, chunk);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
module.exports = {
|
|
48
|
+
MultiToolValidator
|
|
49
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
const { Transform } = require("stream");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} options
|
|
7
|
+
* @param {String} options.message
|
|
8
|
+
* @param {Array} options.columns
|
|
9
|
+
* @returns Transform
|
|
10
|
+
*/
|
|
11
|
+
function RequiredValidator(options) {
|
|
12
|
+
return new Transform({
|
|
13
|
+
readableObjectMode: true,
|
|
14
|
+
writableObjectMode: true,
|
|
15
|
+
decodeStrings: false,
|
|
16
|
+
construct(callback) {
|
|
17
|
+
this.message = options.message ? options.message : "Required value is null";
|
|
18
|
+
this.requiredColumns = options.columns;
|
|
19
|
+
callback();
|
|
20
|
+
},
|
|
21
|
+
transform(chunk, _, callback) {
|
|
22
|
+
this.requiredColumns.forEach(column => {
|
|
23
|
+
let requiredVal = chunk[column];
|
|
24
|
+
if (requiredVal === undefined || requiredVal === '') {
|
|
25
|
+
chunk.errors.push(`${this.message} in column ${column}`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
callback(null, chunk);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
module.exports = {
|
|
33
|
+
RequiredValidator
|
|
34
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { Transform } = require("node:stream");
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} options
|
|
6
|
+
* @param {String} options.message
|
|
7
|
+
* @param {String} options.column
|
|
8
|
+
* @returns Transform
|
|
9
|
+
*/
|
|
10
|
+
function UniqueValidator(options) {
|
|
11
|
+
let self = this;
|
|
12
|
+
self.column = options.column;
|
|
13
|
+
self.message = options.message ? options.message : "Expected unique value is not unique";
|
|
14
|
+
self.uniqueColumnRows = [];
|
|
15
|
+
function checkIsUnique(data) {
|
|
16
|
+
return self.uniqueColumnRows.indexOf(data) === -1;
|
|
17
|
+
}
|
|
18
|
+
return new Transform({
|
|
19
|
+
readableObjectMode: true,
|
|
20
|
+
writableObjectMode: true,
|
|
21
|
+
decodeStrings: false,
|
|
22
|
+
construct(callback) {
|
|
23
|
+
callback();
|
|
24
|
+
},
|
|
25
|
+
transform(chunk, _, callback) {
|
|
26
|
+
const { _columns } = chunk;
|
|
27
|
+
const colIndex = _columns.indexOf(self.column);
|
|
28
|
+
const uniqueValue = chunk[colIndex];
|
|
29
|
+
if (checkIsUnique(uniqueValue)) {
|
|
30
|
+
self.uniqueColumnRows.push(uniqueValue);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
chunk.errors.push(`${self.message} ${self.column}`);
|
|
34
|
+
}
|
|
35
|
+
callback(null, chunk);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
module.exports = {
|
|
40
|
+
UniqueValidator
|
|
41
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ffc-pay-etl-framework",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"publisher": "Defra",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"private": false,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"test:watch": "jest --watchAll",
|
|
10
|
+
"dev": "nodemon src/index.js",
|
|
11
|
+
"clean": "rm -rf ./dist",
|
|
12
|
+
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
13
|
+
"build:esm": "tsc -p ./tsconfig.esm.json && mv dist/esm/index.js dist/esm/index.mjs",
|
|
14
|
+
"build:cjs": "tsc -p ./tsconfig.cjs.json",
|
|
15
|
+
"prepack": "npm run build",
|
|
16
|
+
"example": "node ./src/examples/csv-multi-tool-validator.js"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"ETL"
|
|
20
|
+
],
|
|
21
|
+
"author": "Charlie Benger-Stevenson",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"description": "A framework for creating ETL pipelines in node",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"jest": "^29.7.0",
|
|
26
|
+
"nodemon": "^3.1.4",
|
|
27
|
+
"prettier": "3.3.3"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@faker-js/faker": "^8.4.1",
|
|
31
|
+
"csv": "^6.3.9",
|
|
32
|
+
"mariadb": "^3.3.1",
|
|
33
|
+
"mysql2": "^3.10.3",
|
|
34
|
+
"oracledb": "^6.5.1",
|
|
35
|
+
"pg": "^8.12.0",
|
|
36
|
+
"pg-hstore": "^2.3.4",
|
|
37
|
+
"sequelize": "^6.37.3",
|
|
38
|
+
"sqlite3": "^5.1.7",
|
|
39
|
+
"tedious": "^18.2.4",
|
|
40
|
+
"typescript": "^5.5.3",
|
|
41
|
+
"validator": "^13.12.0"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"/dist/**/*"
|
|
45
|
+
],
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"import": {
|
|
49
|
+
"default": "./dist/esm/index.js"
|
|
50
|
+
},
|
|
51
|
+
"require": {
|
|
52
|
+
"default": "./dist/cjs/index.js"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|