ffc-pay-etl-framework 1.1.4-alpha.2 → 1.1.4-alpha.3

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,14 +1,24 @@
1
- // @ts-nocheck
2
1
  const fs = require("fs");
3
2
  const { Transform } = require("stream");
4
3
  const { parse } = require("csv-parse");
4
+ /**
5
+ * @typedef {Object} CSVLoaderOptions
6
+ * @property {string} path The path to the CSV file
7
+ * @property {string[]} columns The columns in the CSV file
8
+ */
9
+ /**
10
+ * @typedef {import('stream').Readable} Readable
11
+ */
12
+ /**
13
+ * @typedef {Readable & {_columns?: string[], pump?: (csvLoader: Readable) => Readable}} CSVLoaderStream
14
+ */
5
15
  /**
6
16
  *
7
- * @param {Object} options
8
- * @param {String} options.path
9
- * @returns StreamReader
17
+ * @param {CSVLoaderOptions} options
18
+ * @returns {CSVLoaderStream}
10
19
  */
11
20
  function CSVLoader(options) {
21
+ /** @type {CSVLoaderStream} */
12
22
  let csvLoader = fs.createReadStream(options.path);
13
23
  let lineCount = 1;
14
24
  csvLoader._columns = options.columns;
@@ -20,13 +30,16 @@ function CSVLoader(options) {
20
30
  writableObjectMode: true,
21
31
  emitClose: true,
22
32
  transform(chunk, _, callback) {
33
+ console.log(`Processing chunk: ${JSON.stringify(chunk)}`);
23
34
  chunk["_columns"] = options.columns;
24
35
  chunk["_linecount"] = lineCount;
25
36
  lineCount += 1;
26
37
  // remove non-printable characters
27
38
  options.columns.forEach((_column, index) => {
28
39
  if (chunk[index]) {
40
+ console.log(`Before: ${chunk[index].split('').map(char => char.charCodeAt(0)).join(', ')}`);
29
41
  chunk[index] = chunk[index].replace(/[\x00-\x1F\x7F-\x9F]/g, '');
42
+ console.log(`After: ${chunk[index].split('').map(char => char.charCodeAt(0)).join(', ')}`);
30
43
  }
31
44
  });
32
45
  callback(null, chunk);
@@ -1,12 +1,34 @@
1
1
  /// <reference types="node" />
2
+ export type CSVLoaderOptions = {
3
+ /**
4
+ * The path to the CSV file
5
+ */
6
+ path: string;
7
+ /**
8
+ * The columns in the CSV file
9
+ */
10
+ columns: string[];
11
+ };
12
+ export type Readable = import('stream').Readable;
13
+ export type CSVLoaderStream = import("stream").Readable & {
14
+ _columns?: string[];
15
+ pump?: (csvLoader: Readable) => Readable;
16
+ };
17
+ /**
18
+ * @typedef {Object} CSVLoaderOptions
19
+ * @property {string} path The path to the CSV file
20
+ * @property {string[]} columns The columns in the CSV file
21
+ */
22
+ /**
23
+ * @typedef {import('stream').Readable} Readable
24
+ */
25
+ /**
26
+ * @typedef {Readable & {_columns?: string[], pump?: (csvLoader: Readable) => Readable}} CSVLoaderStream
27
+ */
2
28
  /**
3
29
  *
4
- * @param {Object} options
5
- * @param {String} options.path
6
- * @returns StreamReader
30
+ * @param {CSVLoaderOptions} options
31
+ * @returns {CSVLoaderStream}
7
32
  */
8
- export function CSVLoader(options: {
9
- path: string;
10
- }): fs.ReadStream;
11
- import fs = require("fs");
33
+ export function CSVLoader(options: CSVLoaderOptions): CSVLoaderStream;
12
34
  //# sourceMappingURL=csvloader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":";AAKA;;;;;GAKG;AACH;IAH2B,IAAI;kBAgC9B"}
1
+ {"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":";;;;;UAMc,MAAM;;;;aACN,MAAM,EAAE;;uBAIT,OAAO,QAAQ,EAAE,QAAQ;;eAIF,MAAM,EAAE;uBAAqB,QAAQ,KAAK,QAAQ;;AAXtF;;;;GAIG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;GAIG;AACH,mCAHW,gBAAgB,GACd,eAAe,CAkC3B"}
@@ -1,16 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
3
  const fs = require("fs");
5
4
  const { Transform } = require("stream");
6
5
  const { parse } = require("csv-parse");
6
+ /**
7
+ * @typedef {Object} CSVLoaderOptions
8
+ * @property {string} path The path to the CSV file
9
+ * @property {string[]} columns The columns in the CSV file
10
+ */
11
+ /**
12
+ * @typedef {import('stream').Readable} Readable
13
+ */
14
+ /**
15
+ * @typedef {Readable & {_columns?: string[], pump?: (csvLoader: Readable) => Readable}} CSVLoaderStream
16
+ */
7
17
  /**
8
18
  *
9
- * @param {Object} options
10
- * @param {String} options.path
11
- * @returns StreamReader
19
+ * @param {CSVLoaderOptions} options
20
+ * @returns {CSVLoaderStream}
12
21
  */
13
22
  function CSVLoader(options) {
23
+ /** @type {CSVLoaderStream} */
14
24
  let csvLoader = fs.createReadStream(options.path);
15
25
  let lineCount = 1;
16
26
  csvLoader._columns = options.columns;
@@ -22,13 +32,16 @@ function CSVLoader(options) {
22
32
  writableObjectMode: true,
23
33
  emitClose: true,
24
34
  transform(chunk, _, callback) {
35
+ console.log(`Processing chunk: ${JSON.stringify(chunk)}`);
25
36
  chunk["_columns"] = options.columns;
26
37
  chunk["_linecount"] = lineCount;
27
38
  lineCount += 1;
28
39
  // remove non-printable characters
29
40
  options.columns.forEach((_column, index) => {
30
41
  if (chunk[index]) {
42
+ console.log(`Before: ${chunk[index].split('').map(char => char.charCodeAt(0)).join(', ')}`);
31
43
  chunk[index] = chunk[index].replace(/[\x00-\x1F\x7F-\x9F]/g, '');
44
+ console.log(`After: ${chunk[index].split('').map(char => char.charCodeAt(0)).join(', ')}`);
32
45
  }
33
46
  });
34
47
  callback(null, chunk);
@@ -1,12 +1,34 @@
1
1
  /// <reference types="node" />
2
+ export type CSVLoaderOptions = {
3
+ /**
4
+ * The path to the CSV file
5
+ */
6
+ path: string;
7
+ /**
8
+ * The columns in the CSV file
9
+ */
10
+ columns: string[];
11
+ };
12
+ export type Readable = import('stream').Readable;
13
+ export type CSVLoaderStream = import("stream").Readable & {
14
+ _columns?: string[];
15
+ pump?: (csvLoader: Readable) => Readable;
16
+ };
17
+ /**
18
+ * @typedef {Object} CSVLoaderOptions
19
+ * @property {string} path The path to the CSV file
20
+ * @property {string[]} columns The columns in the CSV file
21
+ */
22
+ /**
23
+ * @typedef {import('stream').Readable} Readable
24
+ */
25
+ /**
26
+ * @typedef {Readable & {_columns?: string[], pump?: (csvLoader: Readable) => Readable}} CSVLoaderStream
27
+ */
2
28
  /**
3
29
  *
4
- * @param {Object} options
5
- * @param {String} options.path
6
- * @returns StreamReader
30
+ * @param {CSVLoaderOptions} options
31
+ * @returns {CSVLoaderStream}
7
32
  */
8
- export function CSVLoader(options: {
9
- path: string;
10
- }): fs.ReadStream;
11
- import fs = require("fs");
33
+ export function CSVLoader(options: CSVLoaderOptions): CSVLoaderStream;
12
34
  //# sourceMappingURL=csvloader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":";AAKA;;;;;GAKG;AACH;IAH2B,IAAI;kBAgC9B"}
1
+ {"version":3,"file":"csvloader.d.ts","sourceRoot":"","sources":["../../../../src/loaders/csvloader.js"],"names":[],"mappings":";;;;;UAMc,MAAM;;;;aACN,MAAM,EAAE;;uBAIT,OAAO,QAAQ,EAAE,QAAQ;;eAIF,MAAM,EAAE;uBAAqB,QAAQ,KAAK,QAAQ;;AAXtF;;;;GAIG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;GAIG;AACH,mCAHW,gBAAgB,GACd,eAAe,CAkC3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ffc-pay-etl-framework",
3
- "version": "1.1.4-alpha.2",
3
+ "version": "1.1.4-alpha.3",
4
4
  "publisher": "Defra",
5
5
  "main": "dist/cjs/index.js",
6
6
  "private": false,