From 2879aa5a75caa0ba9a4469f69ab9a29279b7ba33 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 14 Apr 2023 11:37:15 -0500 Subject: [PATCH 1/5] fix: use csv parser via normal dependency --- csvtojson/CSVError.d.ts | 18 -- csvtojson/CSVError.js | 46 ---- csvtojson/CSVError.js.map | 1 - csvtojson/Converter.d.ts | 43 ---- csvtojson/Converter.js | 197 ---------------- csvtojson/Converter.js.map | 1 - csvtojson/Parameters.d.ts | 97 -------- csvtojson/Parameters.js | 47 ---- csvtojson/Parameters.js.map | 1 - csvtojson/ParseRuntime.d.ts | 63 ------ csvtojson/ParseRuntime.js | 36 --- csvtojson/ParseRuntime.js.map | 1 - csvtojson/ProcessFork.d.ts | 37 --- csvtojson/ProcessFork.js | 158 ------------- csvtojson/ProcessFork.js.map | 1 - csvtojson/Processor.d.ts | 21 -- csvtojson/Processor.js | 16 -- csvtojson/Processor.js.map | 1 - csvtojson/ProcessorLocal.d.ts | 26 --- csvtojson/ProcessorLocal.js | 314 -------------------------- csvtojson/ProcessorLocal.js.map | 1 - csvtojson/README.md | 1 - csvtojson/Result.d.ts | 22 -- csvtojson/Result.js | 168 -------------- csvtojson/Result.js.map | 1 - csvtojson/dataClean.d.ts | 13 -- csvtojson/dataClean.js | 76 ------- csvtojson/dataClean.js.map | 1 - csvtojson/fileline.d.ts | 20 -- csvtojson/fileline.js | 26 --- csvtojson/fileline.js.map | 1 - csvtojson/getEol.d.ts | 6 - csvtojson/getEol.js | 31 --- csvtojson/getEol.js.map | 1 - csvtojson/index.d.ts | 10 - csvtojson/index.js | 13 -- csvtojson/index.js.map | 1 - csvtojson/lineToJson.d.ts | 9 - csvtojson/lineToJson.js | 216 ------------------ csvtojson/lineToJson.js.map | 1 - csvtojson/rowSplit.d.ts | 38 ---- csvtojson/rowSplit.js | 234 ------------------- csvtojson/rowSplit.js.map | 1 - csvtojson/util.d.ts | 10 - csvtojson/util.js | 43 ---- csvtojson/util.js.map | 1 - csvtojson/worker.d.ts | 3 - csvtojson/worker.js | 76 ------- csvtojson/worker.js.map | 1 - package.json | 4 +- src/commands/cmdt/generate/records.ts | 70 +++--- test/nuts/generate.nut.ts | 2 - yarn.lock | 10 +- 53 files changed, 43 insertions(+), 2193 deletions(-) delete mode 100644 csvtojson/CSVError.d.ts delete mode 100644 csvtojson/CSVError.js delete mode 100644 csvtojson/CSVError.js.map delete mode 100644 csvtojson/Converter.d.ts delete mode 100644 csvtojson/Converter.js delete mode 100644 csvtojson/Converter.js.map delete mode 100644 csvtojson/Parameters.d.ts delete mode 100644 csvtojson/Parameters.js delete mode 100644 csvtojson/Parameters.js.map delete mode 100644 csvtojson/ParseRuntime.d.ts delete mode 100644 csvtojson/ParseRuntime.js delete mode 100644 csvtojson/ParseRuntime.js.map delete mode 100644 csvtojson/ProcessFork.d.ts delete mode 100644 csvtojson/ProcessFork.js delete mode 100644 csvtojson/ProcessFork.js.map delete mode 100644 csvtojson/Processor.d.ts delete mode 100644 csvtojson/Processor.js delete mode 100644 csvtojson/Processor.js.map delete mode 100644 csvtojson/ProcessorLocal.d.ts delete mode 100644 csvtojson/ProcessorLocal.js delete mode 100644 csvtojson/ProcessorLocal.js.map delete mode 100644 csvtojson/README.md delete mode 100644 csvtojson/Result.d.ts delete mode 100644 csvtojson/Result.js delete mode 100644 csvtojson/Result.js.map delete mode 100644 csvtojson/dataClean.d.ts delete mode 100644 csvtojson/dataClean.js delete mode 100644 csvtojson/dataClean.js.map delete mode 100644 csvtojson/fileline.d.ts delete mode 100644 csvtojson/fileline.js delete mode 100644 csvtojson/fileline.js.map delete mode 100644 csvtojson/getEol.d.ts delete mode 100644 csvtojson/getEol.js delete mode 100644 csvtojson/getEol.js.map delete mode 100644 csvtojson/index.d.ts delete mode 100644 csvtojson/index.js delete mode 100644 csvtojson/index.js.map delete mode 100644 csvtojson/lineToJson.d.ts delete mode 100644 csvtojson/lineToJson.js delete mode 100644 csvtojson/lineToJson.js.map delete mode 100644 csvtojson/rowSplit.d.ts delete mode 100644 csvtojson/rowSplit.js delete mode 100644 csvtojson/rowSplit.js.map delete mode 100644 csvtojson/util.d.ts delete mode 100644 csvtojson/util.js delete mode 100644 csvtojson/util.js.map delete mode 100644 csvtojson/worker.d.ts delete mode 100644 csvtojson/worker.js delete mode 100644 csvtojson/worker.js.map diff --git a/csvtojson/CSVError.d.ts b/csvtojson/CSVError.d.ts deleted file mode 100644 index 10ba977d..00000000 --- a/csvtojson/CSVError.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -export default class CSVError extends Error { - err: string; - line: number; - extra: string | undefined; - static column_mismatched(index: number, extra?: string): CSVError; - static unclosed_quote(index: number, extra?: string): CSVError; - static fromJSON(obj: any): CSVError; - constructor(err: string, line: number, extra?: string | undefined); - toJSON(): { - err: string; - line: number; - extra: string | undefined; - }; -} diff --git a/csvtojson/CSVError.js b/csvtojson/CSVError.js deleted file mode 100644 index 0e0f7890..00000000 --- a/csvtojson/CSVError.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var CSVError = /** @class */ (function (_super) { - __extends(CSVError, _super); - function CSVError(err, line, extra) { - var _this = _super.call(this, "Error: " + err + ". JSON Line number: " + line + (extra ? " near: " + extra : "")) || this; - _this.err = err; - _this.line = line; - _this.extra = extra; - _this.name = "CSV Parse Error"; - return _this; - } - CSVError.column_mismatched = function (index, extra) { - return new CSVError("column_mismatched", index, extra); - }; - CSVError.unclosed_quote = function (index, extra) { - return new CSVError("unclosed_quote", index, extra); - }; - CSVError.fromJSON = function (obj) { - return new CSVError(obj.err, obj.line, obj.extra); - }; - CSVError.prototype.toJSON = function () { - return { - err: this.err, - line: this.line, - extra: this.extra - }; - }; - return CSVError; -}(Error)); -exports.default = CSVError; -//# sourceMappingURL=CSVError.js.map \ No newline at end of file diff --git a/csvtojson/CSVError.js.map b/csvtojson/CSVError.js.map deleted file mode 100644 index 98ace86d..00000000 --- a/csvtojson/CSVError.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"CSVError.js","sourceRoot":"","sources":["../src/CSVError.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;IAAsC,4BAAK;IAUzC,kBACS,GAAW,EACX,IAAY,EACZ,KAAc;QAHvB,YAKE,kBAAM,SAAS,GAAG,GAAG,GAAG,sBAAsB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAE1F;QANQ,SAAG,GAAH,GAAG,CAAQ;QACX,UAAI,GAAJ,IAAI,CAAQ;QACZ,WAAK,GAAL,KAAK,CAAS;QAGrB,KAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;;IAChC,CAAC;IAhBM,0BAAiB,GAAxB,UAAyB,KAAa,EAAE,KAAc;QACpD,OAAO,IAAI,QAAQ,CAAC,mBAAmB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IACM,uBAAc,GAArB,UAAsB,KAAa,EAAE,KAAc;QACjD,OAAO,IAAI,QAAQ,CAAC,gBAAgB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IACM,iBAAQ,GAAf,UAAgB,GAAG;QACjB,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IASD,yBAAM,GAAN;QACE,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAEH,eAAC;AAAD,CAAC,AA1BD,CAAsC,KAAK,GA0B1C"} \ No newline at end of file diff --git a/csvtojson/Converter.d.ts b/csvtojson/Converter.d.ts deleted file mode 100644 index 31b91707..00000000 --- a/csvtojson/Converter.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -import { Transform, TransformOptions, Readable } from "stream"; -import { CSVParseParam } from "./Parameters"; -import { ParseRuntime } from "./ParseRuntime"; -import CSVError from "./CSVError"; -export declare class Converter extends Transform implements PromiseLike { - options: TransformOptions; - preRawData(onRawData: PreRawDataCallback): Converter; - preFileLine(onFileLine: PreFileLineCallback): Converter; - subscribe(onNext?: (data: any, lineNumber: number) => void | PromiseLike, onError?: (err: CSVError) => void, onCompleted?: () => void): Converter; - fromFile(filePath: string, options?: string | CreateReadStreamOption | undefined): Converter; - fromStream(readStream: Readable): Converter; - fromString(csvString: string): Converter; - then(onfulfilled?: (value: any[]) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): PromiseLike; - readonly parseParam: CSVParseParam; - readonly parseRuntime: ParseRuntime; - private params; - private runtime; - private processor; - private result; - constructor(param?: Partial, options?: TransformOptions); - _transform(chunk: any, encoding: string, cb: Function): void; - _flush(cb: Function): void; - private processEnd(cb); - readonly parsedLineNumber: number; -} -export interface CreateReadStreamOption { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - end?: number; - highWaterMark?: number; -} -export declare type CallBack = (err: Error, data: Array) => void; -export declare type PreFileLineCallback = (line: string, lineNumber: number) => string | PromiseLike; -export declare type PreRawDataCallback = (csvString: string) => string | PromiseLike; diff --git a/csvtojson/Converter.js b/csvtojson/Converter.js deleted file mode 100644 index aa06c8be..00000000 --- a/csvtojson/Converter.js +++ /dev/null @@ -1,197 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var stream_1 = require("stream"); -var Parameters_1 = require("./Parameters"); -var ParseRuntime_1 = require("./ParseRuntime"); -var bluebird_1 = __importDefault(require("bluebird")); -// import { ProcessorFork } from "./ProcessFork"; -var ProcessorLocal_1 = require("./ProcessorLocal"); -var Result_1 = require("./Result"); -var Converter = /** @class */ (function (_super) { - __extends(Converter, _super); - function Converter(param, options) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, options) || this; - _this.options = options; - _this.params = Parameters_1.mergeParams(param); - _this.runtime = ParseRuntime_1.initParseRuntime(_this); - _this.result = new Result_1.Result(_this); - // if (this.params.fork) { - // this.processor = new ProcessorFork(this); - // } else { - _this.processor = new ProcessorLocal_1.ProcessorLocal(_this); - // } - _this.once("error", function (err) { - // console.log("BBB"); - //wait for next cycle to emit the errors. - setImmediate(function () { - _this.result.processError(err); - _this.emit("done", err); - }); - }); - _this.once("done", function () { - _this.processor.destroy(); - }); - return _this; - } - Converter.prototype.preRawData = function (onRawData) { - this.runtime.preRawDataHook = onRawData; - return this; - }; - Converter.prototype.preFileLine = function (onFileLine) { - this.runtime.preFileLineHook = onFileLine; - return this; - }; - Converter.prototype.subscribe = function (onNext, onError, onCompleted) { - this.parseRuntime.subscribe = { - onNext: onNext, - onError: onError, - onCompleted: onCompleted - }; - return this; - }; - Converter.prototype.fromFile = function (filePath, options) { - var _this = this; - var fs = require("fs"); - // var rs = null; - // this.wrapCallback(cb, function () { - // if (rs && rs.destroy) { - // rs.destroy(); - // } - // }); - fs.exists(filePath, function (exist) { - if (exist) { - var rs = fs.createReadStream(filePath, options); - rs.pipe(_this); - } - else { - _this.emit('error', new Error("File does not exist. Check to make sure the file path to your csv is correct.")); - } - }); - return this; - }; - Converter.prototype.fromStream = function (readStream) { - readStream.pipe(this); - return this; - }; - Converter.prototype.fromString = function (csvString) { - var csv = csvString.toString(); - var read = new stream_1.Readable(); - var idx = 0; - read._read = function (size) { - if (idx >= csvString.length) { - this.push(null); - } - else { - var str = csvString.substr(idx, size); - this.push(str); - idx += size; - } - }; - return this.fromStream(read); - }; - Converter.prototype.then = function (onfulfilled, onrejected) { - var _this = this; - return new bluebird_1.default(function (resolve, reject) { - _this.parseRuntime.then = { - onfulfilled: function (value) { - if (onfulfilled) { - resolve(onfulfilled(value)); - } - else { - resolve(value); - } - }, - onrejected: function (err) { - if (onrejected) { - resolve(onrejected(err)); - } - else { - reject(err); - } - } - }; - }); - }; - Object.defineProperty(Converter.prototype, "parseParam", { - get: function () { - return this.params; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Converter.prototype, "parseRuntime", { - get: function () { - return this.runtime; - }, - enumerable: true, - configurable: true - }); - Converter.prototype._transform = function (chunk, encoding, cb) { - var _this = this; - this.processor.process(chunk) - .then(function (result) { - // console.log(result); - if (result.length > 0) { - _this.runtime.started = true; - return _this.result.processResult(result); - } - }) - .then(function () { - _this.emit("drained"); - cb(); - }, function (error) { - _this.runtime.hasError = true; - _this.runtime.error = error; - _this.emit("error", error); - cb(); - }); - }; - Converter.prototype._flush = function (cb) { - var _this = this; - this.processor.flush() - .then(function (data) { - if (data.length > 0) { - return _this.result.processResult(data); - } - }) - .then(function () { - _this.processEnd(cb); - }, function (err) { - _this.emit("error", err); - cb(); - }); - }; - Converter.prototype.processEnd = function (cb) { - this.result.endProcess(); - this.emit("done"); - cb(); - }; - Object.defineProperty(Converter.prototype, "parsedLineNumber", { - get: function () { - return this.runtime.parsedLineNumber; - }, - enumerable: true, - configurable: true - }); - return Converter; -}(stream_1.Transform)); -exports.Converter = Converter; -//# sourceMappingURL=Converter.js.map \ No newline at end of file diff --git a/csvtojson/Converter.js.map b/csvtojson/Converter.js.map deleted file mode 100644 index 4e1f317b..00000000 --- a/csvtojson/Converter.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Converter.js","sourceRoot":"","sources":["../src/Converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAA+D;AAC/D,2CAA0D;AAC1D,+CAAgE;AAChE,sDAAyB;AAOzB,iDAAiD;AACjD,mDAAkD;AAClD,mCAAkC;AAMlC;IAA+B,6BAAS;IAuFtC,mBAAY,KAA8B,EAAS,OAA8B;QAA9B,wBAAA,EAAA,YAA8B;QAAjF,YACE,kBAAM,OAAO,CAAC,SAuBf;QAxBkD,aAAO,GAAP,OAAO,CAAuB;QAE/E,KAAI,CAAC,MAAM,GAAG,wBAAW,CAAC,KAAK,CAAC,CAAC;QACjC,KAAI,CAAC,OAAO,GAAG,+BAAgB,CAAC,KAAI,CAAC,CAAC;QACtC,KAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,KAAI,CAAC,CAAC;QAC/B,0BAA0B;QAC1B,8CAA8C;QAC9C,WAAW;QACX,KAAI,CAAC,SAAS,GAAG,IAAI,+BAAc,CAAC,KAAI,CAAC,CAAC;QAC1C,IAAI;QACJ,KAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAC,GAAQ;YAC1B,sBAAsB;YACtB,yCAAyC;YACzC,YAAY,CAAC;gBACX,KAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;gBAC9B,KAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;QAEL,CAAC,CAAC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AAG,CAAC,CAAC;YACxB,EAAE,EAAE,CAAC;QACP,CAAC,CAAC,CAAA;IACN,CAAC;IACO,8BAAU,GAAlB,UAAmB,EAAE;QACnB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,EAAE,EAAE,CAAC;IACP,CAAC;IACD,sBAAI,uCAAgB;aAApB;YACE,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACvC,CAAC;;;OAAA;IACH,gBAAC;AAAD,CAAC,AA3JD,CAA+B,kBAAS,GA2JvC;AA3JY,8BAAS"} \ No newline at end of file diff --git a/csvtojson/Parameters.d.ts b/csvtojson/Parameters.d.ts deleted file mode 100644 index 472977aa..00000000 --- a/csvtojson/Parameters.d.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -export interface CSVParseParam { - /** - * delimiter used for seperating columns. Use "auto" if delimiter is unknown in advance, in this case, delimiter will be auto-detected (by best attempt). Use an array to give a list of potential delimiters e.g. [",","|","$"]. default: "," - */ - delimiter: string | string[]; - /** - * This parameter instructs the parser to ignore columns as specified by the regular expression. Example: /(name|age)/ will ignore columns whose header contains "name" or "age" - */ - ignoreColumns?: RegExp; - /** - * This parameter instructs the parser to include only those columns as specified by the regular expression. Example: /(name|age)/ will parse and include columns whose header contains "name" or "age" - */ - includeColumns?: RegExp; - /** - * If a column contains delimiter, it is able to use quote character to surround the column content. e.g. "hello, world" wont be split into two columns while parsing. Set to "off" will ignore all quotes. default: " (double quote) - */ - quote: string; - /** - * Indicate if parser trim off spaces surrounding column content. e.g. " content " will be trimmed to "content". Default: true - */ - trim: boolean; - /** - * This parameter turns on and off whether check field type. Default is false. - */ - checkType: boolean; - /** - * Ignore the empty value in CSV columns. If a column value is not given, set this to true to skip them. Default: false. - */ - ignoreEmpty: boolean; - /** - * Delegate parsing work to another process. - */ - /** - * Indicating csv data has no header row and first row is data row. Default is false. - */ - noheader: boolean; - /** - * An array to specify the headers of CSV data. If --noheader is false, this value will override CSV header row. Default: null. Example: ["my field","name"]. - */ - headers?: string[]; - /** - * Don't interpret dots (.) and square brackets in header fields as nested object or array identifiers at all (treat them like regular characters for JSON field identifiers). Default: false. - */ - flatKeys: boolean; - /** - * the max character a csv row could have. 0 means infinite. If max number exceeded, parser will emit "error" of "row_exceed". if a possibly corrupted csv data provided, give it a number like 65535 so the parser wont consume memory. default: 0 - */ - maxRowLength: number; - /** - * whether check column number of a row is the same as headers. If column number mismatched headers number, an error of "mismatched_column" will be emitted.. default: false - */ - checkColumn: boolean; - /** - * escape character used in quoted column. Default is double quote (") according to RFC4108. Change to back slash (\) or other chars for your own case. - */ - escape: string; - /** - * Allows override parsing logic for a specific column. It accepts a JSON object with fields like: headName: . e.g. {field1:'number'} will use built-in number parser to convert value of the field1 column to number. Another example {"name":nameProcessFunc} will use specified function to parse the value. - */ - colParser: { - [key: string]: string | CellParser | ColumnParam; - }; - /** - * End of line character. If omitted, parser will attempt to retrieve it from the first chunks of CSV data - */ - eol?: string; - /** - * Always interpret each line (as defined by eol) as a row. This will prevent eol characters from being used within a row (even inside a quoted field). Default is false. Change to true if you are confident no inline line breaks (like line break in a cell which has multi line text) - */ - alwaysSplitAtEOL: boolean; - /** - * The format to be converted to. "json" (default) -- convert csv to json. "csv" -- convert csv to csv row array. "line" -- convert csv to csv line string - */ - output: "json" | "csv" | "line"; - /** - * Convert string "null" to null object in JSON outputs. Default is false. - */ - nullObject: boolean; - /** - * Define the format required by downstream (this parameter does not work if objectMode is on). `line` -- json is emitted in a single line separated by a line breake like "json1\njson2" . `array` -- downstream requires array format like "[json1,json2]". Default is line. - */ - downstreamFormat: "line" | "array"; - /** - * Define whether .then(callback) returns all JSON data in its callback. Default is true. Change to false to save memory if subscribing json lines. - */ - needEmitAll: boolean; -} -export declare type CellParser = (item: string, head: string, resultRow: any, row: string[], columnIndex: number) => any; -export interface ColumnParam { - flat?: boolean; - cellParser?: string | CellParser; -} -export declare function mergeParams(params?: Partial): CSVParseParam; diff --git a/csvtojson/Parameters.js b/csvtojson/Parameters.js deleted file mode 100644 index 14a9018a..00000000 --- a/csvtojson/Parameters.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function mergeParams(params) { - var defaultParam = { - delimiter: ',', - ignoreColumns: undefined, - includeColumns: undefined, - quote: '"', - trim: true, - checkType: false, - ignoreEmpty: false, - // fork: false, - noheader: false, - headers: undefined, - flatKeys: false, - maxRowLength: 0, - checkColumn: false, - escape: '"', - colParser: {}, - eol: undefined, - alwaysSplitAtEOL: false, - output: "json", - nullObject: false, - downstreamFormat: "line", - needEmitAll: true - }; - if (!params) { - params = {}; - } - for (var key in params) { - if (params.hasOwnProperty(key)) { - if (Array.isArray(params[key])) { - defaultParam[key] = [].concat(params[key]); - } - else { - defaultParam[key] = params[key]; - } - } - } - return defaultParam; -} -exports.mergeParams = mergeParams; -//# sourceMappingURL=Parameters.js.map \ No newline at end of file diff --git a/csvtojson/Parameters.js.map b/csvtojson/Parameters.js.map deleted file mode 100644 index 6526008e..00000000 --- a/csvtojson/Parameters.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Parameters.js","sourceRoot":"","sources":["../src/Parameters.ts"],"names":[],"mappings":";;AAiGA,qBAA4B,MAA+B;IACzD,IAAM,YAAY,GAAkB;QAClC,SAAS,EAAE,GAAG;QACd,aAAa,EAAE,SAAS;QACxB,cAAc,EAAE,SAAS;QACzB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,KAAK;QAClB,eAAe;QACf,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,KAAK;QACf,YAAY,EAAE,CAAC;QACf,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,GAAG;QACX,SAAS,EAAE,EAAE;QACb,GAAG,EAAE,SAAS;QACd,gBAAgB,EAAE,KAAK;QACvB,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,KAAK;QACjB,gBAAgB,EAAC,MAAM;QACvB,WAAW,EAAC,IAAI;KACjB,CAAA;IACD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,GAAG,EAAE,CAAC;KACb;IACD,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;QACtB,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;YAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC9B,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;aAC5C;iBAAM;gBACL,YAAY,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;aACjC;SACF;KACF;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AArCD,kCAqCC"} \ No newline at end of file diff --git a/csvtojson/ParseRuntime.d.ts b/csvtojson/ParseRuntime.d.ts deleted file mode 100644 index 61c2da9b..00000000 --- a/csvtojson/ParseRuntime.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -import { CellParser } from "./Parameters"; -import { Converter, PreRawDataCallback, PreFileLineCallback } from "./Converter"; -import CSVError from "./CSVError"; -export interface ParseRuntime { - /** - * If need convert ignoreColumn from column name(string) to column index (number). Parser needs column index. - */ - needProcessIgnoreColumn: boolean; - /** - * If need convert includeColumn from column name(string) to column index (number). Parser needs column index. - */ - needProcessIncludeColumn: boolean; - /** - * the indexes of columns to reserve, undefined means reserve all, [] means hide all - */ - selectedColumns?: number[]; - ended: boolean; - hasError: boolean; - error?: Error; - /** - * Inferred delimiter - */ - delimiter: string | string[]; - /** - * Inferred eol - */ - eol?: string; - /** - * Converter function for a column. Populated at runtime. - */ - columnConv: (CellParser | null)[]; - headerType: any[]; - headerTitle: string[]; - headerFlag: any[]; - /** - * Inferred headers - */ - headers?: any[]; - csvLineBuffer?: Buffer; - /** - * after first chunk of data being processed and emitted, started will become true. - */ - started: boolean; - preRawDataHook?: PreRawDataCallback; - preFileLineHook?: PreFileLineCallback; - parsedLineNumber: number; - columnValueSetter: Function[]; - subscribe?: { - onNext?: (data: any, lineNumber: number) => void | PromiseLike; - onError?: (err: CSVError) => void; - onCompleted?: () => void; - }; - then?: { - onfulfilled: (value: any[]) => any; - onrejected: (err: Error) => any; - }; -} -export declare function initParseRuntime(converter: Converter): ParseRuntime; diff --git a/csvtojson/ParseRuntime.js b/csvtojson/ParseRuntime.js deleted file mode 100644 index 8ba8a37a..00000000 --- a/csvtojson/ParseRuntime.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function initParseRuntime(converter) { - var params = converter.parseParam; - var rtn = { - needProcessIgnoreColumn: false, - needProcessIncludeColumn: false, - selectedColumns: undefined, - ended: false, - hasError: false, - error: undefined, - delimiter: converter.parseParam.delimiter, - eol: converter.parseParam.eol, - columnConv: [], - headerType: [], - headerTitle: [], - headerFlag: [], - headers: undefined, - started: false, - parsedLineNumber: 0, - columnValueSetter: [], - }; - if (params.ignoreColumns) { - rtn.needProcessIgnoreColumn = true; - } - if (params.includeColumns) { - rtn.needProcessIncludeColumn = true; - } - return rtn; -} -exports.initParseRuntime = initParseRuntime; -//# sourceMappingURL=ParseRuntime.js.map \ No newline at end of file diff --git a/csvtojson/ParseRuntime.js.map b/csvtojson/ParseRuntime.js.map deleted file mode 100644 index 286e7ae7..00000000 --- a/csvtojson/ParseRuntime.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ParseRuntime.js","sourceRoot":"","sources":["../src/ParseRuntime.ts"],"names":[],"mappings":";;AA8DA,0BAAiC,SAAoB;IACnD,IAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC;IACpC,IAAM,GAAG,GAAiB;QACxB,uBAAuB,EAAE,KAAK;QAC9B,wBAAwB,EAAE,KAAK;QAC/B,eAAe,EAAE,SAAS;QAC1B,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,SAAS;QAChB,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS;QACzC,GAAG,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG;QAC7B,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;QACd,WAAW,EAAE,EAAE;QACf,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,SAAS;QAClB,OAAO,EAAE,KAAK;QACd,gBAAgB,EAAE,CAAC;QACnB,iBAAiB,EAAE,EAAE;KACtB,CAAA;IACD,IAAI,MAAM,CAAC,aAAa,EAAE;QACxB,GAAG,CAAC,uBAAuB,GAAG,IAAI,CAAC;KACpC;IACD,IAAI,MAAM,CAAC,cAAc,EAAE;QACzB,GAAG,CAAC,wBAAwB,GAAG,IAAI,CAAC;KACrC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AA3BD,4CA2BC"} \ No newline at end of file diff --git a/csvtojson/ProcessFork.d.ts b/csvtojson/ProcessFork.d.ts deleted file mode 100644 index 23cdf762..00000000 --- a/csvtojson/ProcessFork.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -/// -import { Processor, ProcessLineResult } from "./Processor"; -import P from "bluebird"; -import { Converter } from "./Converter"; -import { ChildProcess } from "child_process"; -export declare class ProcessorFork extends Processor { - protected converter: Converter; - flush(): P; - destroy(): P; - childProcess: ChildProcess; - inited: boolean; - private resultBuf; - private leftChunk; - private finalChunk; - private next?; - constructor(converter: Converter); - private prepareParam(param); - private initWorker(); - private flushResult(); - private appendBuf(data); - process(chunk: Buffer): P; -} -export interface Message { - cmd: string; -} -export interface InitMessage extends Message { - params: any; -} -export interface StringMessage extends Message { - value: string; -} -export declare const EOM = "\u0003"; diff --git a/csvtojson/ProcessFork.js b/csvtojson/ProcessFork.js deleted file mode 100644 index c2018ff7..00000000 --- a/csvtojson/ProcessFork.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Processor_1 = require("./Processor"); -var bluebird_1 = __importDefault(require("bluebird")); -var Parameters_1 = require("./Parameters"); -var CSVError_1 = __importDefault(require("./CSVError")); -var ProcessorFork = /** @class */ (function (_super) { - __extends(ProcessorFork, _super); - function ProcessorFork(converter) { - var _this = _super.call(this, converter) || this; - _this.converter = converter; - _this.inited = false; - _this.resultBuf = []; - _this.leftChunk = ""; - _this.finalChunk = false; - _this.childProcess = require("child_process").spawn(process.execPath, [__dirname + "/../v2/worker.js"], { - stdio: ["pipe", "pipe", "pipe", "ipc"] - }); - _this.initWorker(); - return _this; - } - ProcessorFork.prototype.flush = function () { - var _this = this; - return new bluebird_1.default(function (resolve, reject) { - // console.log("flush"); - _this.finalChunk = true; - _this.next = resolve; - _this.childProcess.stdin.end(); - // this.childProcess.stdout.on("end",()=>{ - // // console.log("!!!!"); - // this.flushResult(); - // }) - }); - }; - ProcessorFork.prototype.destroy = function () { - this.childProcess.kill(); - return bluebird_1.default.resolve(); - }; - ProcessorFork.prototype.prepareParam = function (param) { - var clone = Parameters_1.mergeParams(param); - if (clone.ignoreColumns) { - clone.ignoreColumns = { - source: clone.ignoreColumns.source, - flags: clone.ignoreColumns.flags - }; - } - if (clone.includeColumns) { - clone.includeColumns = { - source: clone.includeColumns.source, - flags: clone.includeColumns.flags - }; - } - return clone; - }; - ProcessorFork.prototype.initWorker = function () { - var _this = this; - this.childProcess.on("exit", function () { - _this.flushResult(); - }); - this.childProcess.send({ - cmd: "init", - params: this.prepareParam(this.converter.parseParam) - }); - this.childProcess.on("message", function (msg) { - if (msg.cmd === "inited") { - _this.inited = true; - } - else if (msg.cmd === "eol") { - if (_this.converter.listeners("eol").length > 0) { - _this.converter.emit("eol", msg.value); - } - } - else if (msg.cmd === "header") { - if (_this.converter.listeners("header").length > 0) { - _this.converter.emit("header", msg.value); - } - } - else if (msg.cmd === "done") { - // this.flushResult(); - } - }); - this.childProcess.stdout.on("data", function (data) { - // console.log("stdout", data.toString()); - var res = data.toString(); - // console.log(res); - _this.appendBuf(res); - }); - this.childProcess.stderr.on("data", function (data) { - // console.log("stderr", data.toString()); - _this.converter.emit("error", CSVError_1.default.fromJSON(JSON.parse(data.toString()))); - }); - }; - ProcessorFork.prototype.flushResult = function () { - // console.log("flush result", this.resultBuf.length); - if (this.next) { - this.next(this.resultBuf); - } - this.resultBuf = []; - }; - ProcessorFork.prototype.appendBuf = function (data) { - var res = this.leftChunk + data; - var list = res.split("\n"); - var counter = 0; - var lastBit = list[list.length - 1]; - if (lastBit !== "") { - this.leftChunk = list.pop() || ""; - } - else { - this.leftChunk = ""; - } - this.resultBuf = this.resultBuf.concat(list); - // while (list.length) { - // let item = list.shift() || ""; - // if (item.length === 0 ) { - // continue; - // } - // // if (this.params.output !== "line") { - // // item = JSON.parse(item); - // // } - // this.resultBuf.push(item); - // counter++; - // } - // console.log("buf length",this.resultBuf.length); - }; - ProcessorFork.prototype.process = function (chunk) { - var _this = this; - return new bluebird_1.default(function (resolve, reject) { - // console.log("chunk", chunk.length); - _this.next = resolve; - // this.appendReadBuf(chunk); - _this.childProcess.stdin.write(chunk, function () { - // console.log("chunk callback"); - _this.flushResult(); - }); - }); - }; - return ProcessorFork; -}(Processor_1.Processor)); -exports.ProcessorFork = ProcessorFork; -exports.EOM = "\x03"; -//# sourceMappingURL=ProcessFork.js.map \ No newline at end of file diff --git a/csvtojson/ProcessFork.js.map b/csvtojson/ProcessFork.js.map deleted file mode 100644 index 4a7ee239..00000000 --- a/csvtojson/ProcessFork.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ProcessFork.js","sourceRoot":"","sources":["../src/ProcessFork.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA2D;AAC3D,sDAAwB;AAGxB,2CAA0D;AAI1D,wDAAkC;AAElC;IAAmC,iCAAS;IAuB1C,uBAAsB,SAAoB;QAA1C,YACE,kBAAM,SAAS,CAAC,SAKjB;QANqB,eAAS,GAAT,SAAS,CAAW;QAL1C,YAAM,GAAY,KAAK,CAAC;QAChB,eAAS,GAAwB,EAAE,CAAC;QACpC,eAAS,GAAW,EAAE,CAAC;QACvB,gBAAU,GAAY,KAAK,CAAC;QAIlC,KAAI,CAAC,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,SAAS,GAAG,kBAAkB,CAAC,EAAE;YACrG,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;SACvC,CAAC,CAAC;QACH,KAAI,CAAC,UAAU,EAAE,CAAC;;IACpB,CAAC;IA5BD,6BAAK,GAAL;QAAA,iBAWC;QAVC,OAAO,IAAI,kBAAC,CAAC,UAAC,OAAO,EAAE,MAAM;YAC3B,wBAAwB;YACxB,KAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,KAAI,CAAC,IAAI,GAAG,OAAO,CAAC;YACpB,KAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAA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leted file mode 100644 index 7089fb75..00000000 --- a/csvtojson/Processor.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -/// -import { Converter } from "./Converter"; -import P from "bluebird"; -import { JSONResult } from "./lineToJson"; -import { CSVParseParam } from "./Parameters"; -import { ParseRuntime } from "./ParseRuntime"; -export declare abstract class Processor { - protected converter: Converter; - protected params: CSVParseParam; - protected runtime: ParseRuntime; - constructor(converter: Converter); - abstract process(chunk: Buffer, finalChunk?: boolean): P; - abstract destroy(): P; - abstract flush(): P; -} -export declare type ProcessLineResult = string | string[] | JSONResult; diff --git a/csvtojson/Processor.js b/csvtojson/Processor.js deleted file mode 100644 index 3da2b371..00000000 --- a/csvtojson/Processor.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Processor = /** @class */ (function () { - function Processor(converter) { - this.converter = converter; - this.params = converter.parseParam; - this.runtime = converter.parseRuntime; - } - return Processor; -}()); -exports.Processor = Processor; -//# sourceMappingURL=Processor.js.map \ No newline at end of file diff --git a/csvtojson/Processor.js.map b/csvtojson/Processor.js.map deleted file mode 100644 index 39c52dfd..00000000 --- a/csvtojson/Processor.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Processor.js","sourceRoot":"","sources":["../src/Processor.ts"],"names":[],"mappings":";;AAMA;IAGE,mBAAsB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QACxC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC;IACxC,CAAC;IAIH,gBAAC;AAAD,CAAC,AAVD,IAUC;AAVqB,8BAAS"} \ No newline at end of file diff --git a/csvtojson/ProcessorLocal.d.ts b/csvtojson/ProcessorLocal.d.ts deleted file mode 100644 index 2f31bc40..00000000 --- a/csvtojson/ProcessorLocal.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -/// -import { Processor, ProcessLineResult } from "./Processor"; -import P from "bluebird"; -export declare class ProcessorLocal extends Processor { - flush(): P; - destroy(): P; - private rowSplit; - private eolEmitted; - private _needEmitEol?; - private readonly needEmitEol; - private headEmitted; - private _needEmitHead?; - private readonly needEmitHead; - process(chunk: Buffer, finalChunk?: boolean): P; - private processCSV(csv, finalChunk); - private processDataWithHead(lines); - private filterHeader(); - private processCSVBody(lines); - private prependLeftBuf(buf); - private runPreLineHook(lines); -} diff --git a/csvtojson/ProcessorLocal.js b/csvtojson/ProcessorLocal.js deleted file mode 100644 index 758a3fe2..00000000 --- a/csvtojson/ProcessorLocal.js +++ /dev/null @@ -1,314 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Processor_1 = require("./Processor"); -var bluebird_1 = __importDefault(require("bluebird")); -var dataClean_1 = require("./dataClean"); -var getEol_1 = __importDefault(require("./getEol")); -var fileline_1 = require("./fileline"); -var util_1 = require("./util"); -var rowSplit_1 = require("./rowSplit"); -var lineToJson_1 = __importDefault(require("./lineToJson")); -var CSVError_1 = __importDefault(require("./CSVError")); -var ProcessorLocal = /** @class */ (function (_super) { - __extends(ProcessorLocal, _super); - function ProcessorLocal() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.rowSplit = new rowSplit_1.RowSplit(_this.converter); - _this.eolEmitted = false; - _this._needEmitEol = undefined; - _this.headEmitted = false; - _this._needEmitHead = undefined; - return _this; - } - ProcessorLocal.prototype.flush = function () { - var _this = this; - if (this.runtime.csvLineBuffer && this.runtime.csvLineBuffer.length > 0) { - var buf = this.runtime.csvLineBuffer; - this.runtime.csvLineBuffer = undefined; - return this.process(buf, true) - .then(function (res) { - if (_this.runtime.csvLineBuffer && _this.runtime.csvLineBuffer.length > 0) { - return bluebird_1.default.reject(CSVError_1.default.unclosed_quote(_this.runtime.parsedLineNumber, _this.runtime.csvLineBuffer.toString())); - } - else { - return bluebird_1.default.resolve(res); - } - }); - } - else { - return bluebird_1.default.resolve([]); - } - }; - ProcessorLocal.prototype.destroy = function () { - return bluebird_1.default.resolve(); - }; - Object.defineProperty(ProcessorLocal.prototype, "needEmitEol", { - get: function () { - if (this._needEmitEol === undefined) { - this._needEmitEol = this.converter.listeners("eol").length > 0; - } - return this._needEmitEol; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ProcessorLocal.prototype, "needEmitHead", { - get: function () { - if (this._needEmitHead === undefined) { - this._needEmitHead = this.converter.listeners("header").length > 0; - } - return this._needEmitHead; - }, - enumerable: true, - configurable: true - }); - ProcessorLocal.prototype.process = function (chunk, finalChunk) { - var _this = this; - if (finalChunk === void 0) { finalChunk = false; } - var csvString; - if (finalChunk) { - csvString = chunk.toString(); - } - else { - csvString = dataClean_1.prepareData(chunk, this.converter.parseRuntime); - } - return bluebird_1.default.resolve() - .then(function () { - if (_this.runtime.preRawDataHook) { - return _this.runtime.preRawDataHook(csvString); - } - else { - return csvString; - } - }) - .then(function (csv) { - if (csv && csv.length > 0) { - return _this.processCSV(csv, finalChunk); - } - else { - return bluebird_1.default.resolve([]); - } - }); - }; - ProcessorLocal.prototype.processCSV = function (csv, finalChunk) { - var _this = this; - var params = this.params; - var runtime = this.runtime; - if (!runtime.eol) { - getEol_1.default(csv, runtime); - } - if (this.needEmitEol && !this.eolEmitted && runtime.eol) { - this.converter.emit("eol", runtime.eol); - this.eolEmitted = true; - } - // trim csv file has initial blank lines. - if (params.ignoreEmpty && !runtime.started) { - csv = util_1.trimLeft(csv); - } - var stringToLineResult = fileline_1.stringToLines(csv, runtime); - if (!finalChunk) { - this.prependLeftBuf(util_1.bufFromString(stringToLineResult.partial)); - } - else { - stringToLineResult.lines.push(stringToLineResult.partial); - stringToLineResult.partial = ""; - } - if (stringToLineResult.lines.length > 0) { - var prom = void 0; - if (runtime.preFileLineHook) { - prom = this.runPreLineHook(stringToLineResult.lines); - } - else { - prom = bluebird_1.default.resolve(stringToLineResult.lines); - } - return prom.then(function (lines) { - if (!runtime.started - && !_this.runtime.headers) { - return _this.processDataWithHead(lines); - } - else { - return _this.processCSVBody(lines); - } - }); - } - else { - return bluebird_1.default.resolve([]); - } - }; - ProcessorLocal.prototype.processDataWithHead = function (lines) { - if (this.params.noheader) { - if (this.params.headers) { - this.runtime.headers = this.params.headers; - } - else { - this.runtime.headers = []; - } - } - else { - var left = ""; - var headerRow = []; - while (lines.length) { - var line = left + lines.shift(); - var row = this.rowSplit.parse(line); - if (row.closed) { - headerRow = row.cells; - left = ""; - break; - } - else { - left = line + getEol_1.default(line, this.runtime); - } - } - this.prependLeftBuf(util_1.bufFromString(left)); - if (headerRow.length === 0) { - return []; - } - if (this.params.headers) { - this.runtime.headers = this.params.headers; - } - else { - this.runtime.headers = headerRow; - } - } - if (this.runtime.needProcessIgnoreColumn || this.runtime.needProcessIncludeColumn) { - this.filterHeader(); - } - if (this.needEmitHead && !this.headEmitted) { - this.converter.emit("header", this.runtime.headers); - this.headEmitted = true; - } - return this.processCSVBody(lines); - }; - ProcessorLocal.prototype.filterHeader = function () { - this.runtime.selectedColumns = []; - if (this.runtime.headers) { - var headers = this.runtime.headers; - for (var i = 0; i < headers.length; i++) { - if (this.params.ignoreColumns) { - if (this.params.ignoreColumns.test(headers[i])) { - if (this.params.includeColumns && this.params.includeColumns.test(headers[i])) { - this.runtime.selectedColumns.push(i); - } - else { - continue; - } - } - else { - this.runtime.selectedColumns.push(i); - } - } - else if (this.params.includeColumns) { - if (this.params.includeColumns.test(headers[i])) { - this.runtime.selectedColumns.push(i); - } - } - else { - this.runtime.selectedColumns.push(i); - } - // if (this.params.includeColumns && this.params.includeColumns.test(headers[i])){ - // this.runtime.selectedColumns.push(i); - // }else{ - // if (this.params.ignoreColumns && this.params.ignoreColumns.test(headers[i])){ - // continue; - // }else{ - // if (this.params.ignoreColumns && !this.params.includeColumns){ - // this.runtime.selectedColumns.push(i); - // } - // } - // } - } - this.runtime.headers = util_1.filterArray(this.runtime.headers, this.runtime.selectedColumns); - } - }; - ProcessorLocal.prototype.processCSVBody = function (lines) { - if (this.params.output === "line") { - return lines; - } - else { - var result = this.rowSplit.parseMultiLines(lines); - this.prependLeftBuf(util_1.bufFromString(result.partial)); - if (this.params.output === "csv") { - return result.rowsCells; - } - else { - return lineToJson_1.default(result.rowsCells, this.converter); - } - } - // var jsonArr = linesToJson(lines.lines, params, this.recordNum); - // this.processResult(jsonArr); - // this.lastIndex += jsonArr.length; - // this.recordNum += jsonArr.length; - }; - ProcessorLocal.prototype.prependLeftBuf = function (buf) { - if (buf) { - if (this.runtime.csvLineBuffer) { - this.runtime.csvLineBuffer = Buffer.concat([buf, this.runtime.csvLineBuffer]); - } - else { - this.runtime.csvLineBuffer = buf; - } - } - }; - ProcessorLocal.prototype.runPreLineHook = function (lines) { - var _this = this; - return new bluebird_1.default(function (resolve, reject) { - processLineHook(lines, _this.runtime, 0, function (err) { - if (err) { - reject(err); - } - else { - resolve(lines); - } - }); - }); - }; - return ProcessorLocal; -}(Processor_1.Processor)); -exports.ProcessorLocal = ProcessorLocal; -function processLineHook(lines, runtime, offset, cb) { - if (offset >= lines.length) { - cb(); - } - else { - if (runtime.preFileLineHook) { - var line = lines[offset]; - var res = runtime.preFileLineHook(line, runtime.parsedLineNumber + offset); - offset++; - if (res && res.then) { - res.then(function (value) { - lines[offset - 1] = value; - processLineHook(lines, runtime, offset, cb); - }); - } - else { - lines[offset - 1] = res; - while (offset < lines.length) { - lines[offset] = runtime.preFileLineHook(lines[offset], runtime.parsedLineNumber + offset); - offset++; - } - cb(); - } - } - else { - cb(); - } - } -} -//# sourceMappingURL=ProcessorLocal.js.map \ No newline at end of file diff --git a/csvtojson/ProcessorLocal.js.map b/csvtojson/ProcessorLocal.js.map deleted file mode 100644 index e31eee67..00000000 --- a/csvtojson/ProcessorLocal.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ProcessorLocal.js","sourceRoot":"","sources":["../src/ProcessorLocal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA2D;AAC3D,sDAAyB;AACzB,yCAA0C;AAC1C,oDAA8B;AAC9B,uCAA2C;AAC3C,+BAA6D;AAC7D,uCAAsC;AACtC,4DAAsC;AAEtC,wDAAkC;AAIlC;IAAoC,kCAAS;IAA7C;QAAA,qEAmOC;QA/MS,cAAQ,GAAa,IAAI,mBAAQ,CAAC,KAAI,CAAC,SAAS,CAAC,CAAC;QAClD,gBAAU,GAAG,KAAK,CAAC;QACnB,kBAAY,GAAa,SAAS,CAAC;QAOnC,iBAAW,GAAG,KAAK,CAAC;QACpB,mBAAa,GAAa,SAAS,CAAC;;IAqM9C,CAAC;IAlOC,8BAAK,GAAL;QAAA,iBAeC;QAdC,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YACvE,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;YACvC,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;YACvC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC;iBAC3B,IAAI,CAAC,UAAC,GAAG;gBACR,IAAI,KAAI,CAAC,OAAO,CAAC,aAAa,IAAI,KAAI,CAA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 No newline at end of file diff --git a/csvtojson/README.md b/csvtojson/README.md deleted file mode 100644 index 17fa3fea..00000000 --- a/csvtojson/README.md +++ /dev/null @@ -1 +0,0 @@ -Brought in from https://github.com/Keyang/node-csvtojson to fix https://github.com/Keyang/node-csvtojson/issues/393. Can be removed when that issue is fixed. \ No newline at end of file diff --git a/csvtojson/Result.d.ts b/csvtojson/Result.d.ts deleted file mode 100644 index e3b25432..00000000 --- a/csvtojson/Result.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -import { Converter } from "./Converter"; -import { ProcessLineResult } from "./Processor"; -import P from "bluebird"; -import CSVError from "./CSVError"; -export declare class Result { - private converter; - private readonly needEmitLine; - private _needPushDownstream?; - private readonly needPushDownstream; - private readonly needEmitAll; - private finalResult; - constructor(converter: Converter); - processResult(resultLines: ProcessLineResult[]): P; - appendFinalResult(lines: any[]): void; - processError(err: CSVError): void; - endProcess(): void; -} diff --git a/csvtojson/Result.js b/csvtojson/Result.js deleted file mode 100644 index 650026f5..00000000 --- a/csvtojson/Result.js +++ /dev/null @@ -1,168 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var bluebird_1 = __importDefault(require("bluebird")); -var os_1 = require("os"); -var Result = /** @class */ (function () { - function Result(converter) { - this.converter = converter; - this.finalResult = []; - } - Object.defineProperty(Result.prototype, "needEmitLine", { - get: function () { - return !!this.converter.parseRuntime.subscribe && !!this.converter.parseRuntime.subscribe.onNext || this.needPushDownstream; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Result.prototype, "needPushDownstream", { - get: function () { - if (this._needPushDownstream === undefined) { - this._needPushDownstream = this.converter.listeners("data").length > 0 || this.converter.listeners("readable").length > 0; - } - return this._needPushDownstream; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Result.prototype, "needEmitAll", { - get: function () { - return !!this.converter.parseRuntime.then && this.converter.parseParam.needEmitAll; - // return !!this.converter.parseRuntime.then; - }, - enumerable: true, - configurable: true - }); - Result.prototype.processResult = function (resultLines) { - var _this = this; - var startPos = this.converter.parseRuntime.parsedLineNumber; - if (this.needPushDownstream && this.converter.parseParam.downstreamFormat === "array") { - if (startPos === 0) { - pushDownstream(this.converter, "[" + os_1.EOL); - } - } - // let prom: P; - return new bluebird_1.default(function (resolve, reject) { - if (_this.needEmitLine) { - processLineByLine(resultLines, _this.converter, 0, _this.needPushDownstream, function (err) { - if (err) { - reject(err); - } - else { - _this.appendFinalResult(resultLines); - resolve(); - } - }); - // resolve(); - } - else { - _this.appendFinalResult(resultLines); - resolve(); - } - }); - }; - Result.prototype.appendFinalResult = function (lines) { - if (this.needEmitAll) { - this.finalResult = this.finalResult.concat(lines); - } - this.converter.parseRuntime.parsedLineNumber += lines.length; - }; - Result.prototype.processError = function (err) { - if (this.converter.parseRuntime.subscribe && this.converter.parseRuntime.subscribe.onError) { - this.converter.parseRuntime.subscribe.onError(err); - } - if (this.converter.parseRuntime.then && this.converter.parseRuntime.then.onrejected) { - this.converter.parseRuntime.then.onrejected(err); - } - }; - Result.prototype.endProcess = function () { - if (this.converter.parseRuntime.then && this.converter.parseRuntime.then.onfulfilled) { - if (this.needEmitAll) { - this.converter.parseRuntime.then.onfulfilled(this.finalResult); - } - else { - this.converter.parseRuntime.then.onfulfilled([]); - } - } - if (this.converter.parseRuntime.subscribe && this.converter.parseRuntime.subscribe.onCompleted) { - this.converter.parseRuntime.subscribe.onCompleted(); - } - if (this.needPushDownstream && this.converter.parseParam.downstreamFormat === "array") { - pushDownstream(this.converter, "]" + os_1.EOL); - } - }; - return Result; -}()); -exports.Result = Result; -function processLineByLine(lines, conv, offset, needPushDownstream, cb) { - if (offset >= lines.length) { - cb(); - } - else { - if (conv.parseRuntime.subscribe && conv.parseRuntime.subscribe.onNext) { - var hook_1 = conv.parseRuntime.subscribe.onNext; - var nextLine_1 = lines[offset]; - var res = hook_1(nextLine_1, conv.parseRuntime.parsedLineNumber + offset); - offset++; - // if (isAsync === undefined) { - if (res && res.then) { - res.then(function () { - processRecursive(lines, hook_1, conv, offset, needPushDownstream, cb, nextLine_1); - }, cb); - } - else { - // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false); - if (needPushDownstream) { - pushDownstream(conv, nextLine_1); - } - while (offset < lines.length) { - var line = lines[offset]; - hook_1(line, conv.parseRuntime.parsedLineNumber + offset); - offset++; - if (needPushDownstream) { - pushDownstream(conv, line); - } - } - cb(); - } - // } else if (isAsync === true) { - // (res as PromiseLike).then(function () { - // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, true); - // }, cb); - // } else if (isAsync === false) { - // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false); - // } - } - else { - if (needPushDownstream) { - while (offset < lines.length) { - var line = lines[offset++]; - pushDownstream(conv, line); - } - } - cb(); - } - } -} -function processRecursive(lines, hook, conv, offset, needPushDownstream, cb, res) { - if (needPushDownstream) { - pushDownstream(conv, res); - } - processLineByLine(lines, conv, offset, needPushDownstream, cb); -} -function pushDownstream(conv, res) { - if (typeof res === "object" && !conv.options.objectMode) { - var data = JSON.stringify(res); - conv.push(data + (conv.parseParam.downstreamFormat === "array" ? "," + os_1.EOL : os_1.EOL), "utf8"); - } - else { - conv.push(res); - } -} -//# sourceMappingURL=Result.js.map \ No newline at end of file diff --git a/csvtojson/Result.js.map b/csvtojson/Result.js.map deleted file mode 100644 index ec645e7d..00000000 --- a/csvtojson/Result.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Result.js","sourceRoot":"","sources":["../src/Result.ts"],"names":[],"mappings":";;;;;AAEA,sDAAyB;AAEzB,yBAAyB;AACzB;IAgBE,gBAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QADhC,gBAAW,GAAU,EAAE,CAAC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EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;AACjE,CAAC;AACD,wBAAwB,IAAe,EAAE,GAAsB;IAC7D,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;QACvD,IAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,QAAG,CAAC,CAAC,CAAC,QAAG,CAAC,EAAE,MAAM,CAAC,CAAC;KAC5F;SAAM;QACL,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAChB;AACH,CAAC"} \ No newline at end of file diff --git a/csvtojson/dataClean.d.ts b/csvtojson/dataClean.d.ts deleted file mode 100644 index dc90bcd4..00000000 --- a/csvtojson/dataClean.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -import { ParseRuntime } from "./ParseRuntime"; -/** - * For each data chunk coming to parser: - * 1. append the data to the buffer that is left from last chunk - * 2. check if utf8 chars being split, if does, stripe the bytes and add to left buffer. - * 3. stripBom - */ -export declare function prepareData(chunk: Buffer, runtime: ParseRuntime): string; diff --git a/csvtojson/dataClean.js b/csvtojson/dataClean.js deleted file mode 100644 index b72fa8ca..00000000 --- a/csvtojson/dataClean.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var strip_bom_1 = __importDefault(require("strip-bom")); -/** - * For each data chunk coming to parser: - * 1. append the data to the buffer that is left from last chunk - * 2. check if utf8 chars being split, if does, stripe the bytes and add to left buffer. - * 3. stripBom - */ -function prepareData(chunk, runtime) { - var workChunk = concatLeftChunk(chunk, runtime); - runtime.csvLineBuffer = undefined; - var cleanCSVString = cleanUtf8Split(workChunk, runtime).toString("utf8"); - if (runtime.started === false) { - return strip_bom_1.default(cleanCSVString); - } - else { - return cleanCSVString; - } -} -exports.prepareData = prepareData; -/** - * append data to buffer that is left form last chunk - */ -function concatLeftChunk(chunk, runtime) { - if (runtime.csvLineBuffer && runtime.csvLineBuffer.length > 0) { - return Buffer.concat([runtime.csvLineBuffer, chunk]); - } - else { - return chunk; - } -} -/** - * check if utf8 chars being split, if does, stripe the bytes and add to left buffer. - */ -function cleanUtf8Split(chunk, runtime) { - var idx = chunk.length - 1; - /** - * From Keyang: - * The code below is to check if a single utf8 char (which could be multiple bytes) being split. - * If the char being split, the buffer from two chunk needs to be concat - * check how utf8 being encoded to understand the code below. - * If anyone has any better way to do this, please let me know. - */ - if ((chunk[idx] & 1 << 7) != 0) { - while ((chunk[idx] & 3 << 6) === 128) { - idx--; - } - idx--; - } - if (idx != chunk.length - 1) { - runtime.csvLineBuffer = chunk.slice(idx + 1); - return chunk.slice(0, idx + 1); - // var _cb=cb; - // var self=this; - // cb=function(){ - // if (self._csvLineBuffer){ - // self._csvLineBuffer=Buffer.concat([bufFromString(self._csvLineBuffer,"utf8"),left]); - // }else{ - // self._csvLineBuffer=left; - // } - // _cb(); - // } - } - else { - return chunk; - } -} -//# sourceMappingURL=dataClean.js.map \ No newline at end of file diff --git a/csvtojson/dataClean.js.map b/csvtojson/dataClean.js.map deleted file mode 100644 index 0978e831..00000000 --- a/csvtojson/dataClean.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"dataClean.js","sourceRoot":"","sources":["../src/dataClean.ts"],"names":[],"mappings":";;;;;AACA,wDAAiC;AACjC;;;;;GAKG;AACH,qBAA4B,KAAa,EAAE,OAAqB;IAC9D,IAAM,SAAS,GAAG,eAAe,CAAC,KAAK,EAAE,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9B,2FAA2F;QAC3F,WAAW;QACX,gCAAgC;QAChC,MAAM;QACN,WAAW;QACX,IAAI;KACL;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC"} \ No newline at end of file diff --git a/csvtojson/fileline.d.ts b/csvtojson/fileline.d.ts deleted file mode 100644 index 2478c2d6..00000000 --- a/csvtojson/fileline.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -import { ParseRuntime } from "./ParseRuntime"; -/** - * convert data chunk to file lines array - * @param {string} data data chunk as utf8 string - * @param {object} param Converter param object - * @return {Object} {lines:[line1,line2...],partial:String} - */ -export declare function stringToLines(data: string, param: ParseRuntime): StringToLinesResult; -export interface StringToLinesResult { - lines: Fileline[]; - /** - * last line which could be incomplete line. - */ - partial: string; -} -export declare type Fileline = string; diff --git a/csvtojson/fileline.js b/csvtojson/fileline.js deleted file mode 100644 index 6b9665b4..00000000 --- a/csvtojson/fileline.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var getEol_1 = __importDefault(require("./getEol")); -// const getEol = require("./getEol"); -/** - * convert data chunk to file lines array - * @param {string} data data chunk as utf8 string - * @param {object} param Converter param object - * @return {Object} {lines:[line1,line2...],partial:String} - */ -function stringToLines(data, param) { - var eol = getEol_1.default(data, param); - var lines = data.split(eol); - var partial = lines.pop() || ""; - return { lines: lines, partial: partial }; -} -exports.stringToLines = stringToLines; -; -//# sourceMappingURL=fileline.js.map \ No newline at end of file diff --git a/csvtojson/fileline.js.map b/csvtojson/fileline.js.map deleted file mode 100644 index 1d24ef7b..00000000 --- a/csvtojson/fileline.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"fileline.js","sourceRoot":"","sources":["../src/fileline.ts"],"names":[],"mappings":";;;;;AACA,oDAA8B;AAC9B,sCAAsC;AACtC;;;;;GAKG;AACH,uBAA8B,IAAY,EAAE,KAAmB;IAC7D,IAAM,GAAG,GAAG,gBAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChC,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAM,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IAClC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC5C,CAAC;AALD,sCAKC;AAAA,CAAC"} \ No newline at end of file diff --git a/csvtojson/getEol.d.ts b/csvtojson/getEol.d.ts deleted file mode 100644 index 238f8e56..00000000 --- a/csvtojson/getEol.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -import { ParseRuntime } from "./ParseRuntime"; -export default function (data: string, param: ParseRuntime): string; diff --git a/csvtojson/getEol.js b/csvtojson/getEol.js deleted file mode 100644 index 9bf609b3..00000000 --- a/csvtojson/getEol.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//return first eol found from a data chunk. -function default_1(data, param) { - if (!param.eol && data) { - for (var i = 0, len = data.length; i < len; i++) { - if (data[i] === "\r") { - if (data[i + 1] === "\n") { - param.eol = "\r\n"; - break; - } - else if (data[i + 1]) { - param.eol = "\r"; - break; - } - } - else if (data[i] === "\n") { - param.eol = "\n"; - break; - } - } - } - return param.eol || "\n"; -} -exports.default = default_1; -; -//# sourceMappingURL=getEol.js.map \ No newline at end of file diff --git a/csvtojson/getEol.js.map b/csvtojson/getEol.js.map deleted file mode 100644 index 05526268..00000000 --- a/csvtojson/getEol.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"getEol.js","sourceRoot":"","sources":["../src/getEol.ts"],"names":[],"mappings":";;AACA,2CAA2C;AAC3C,mBAAyB,IAAY,EAAE,KAAmB;IACxD,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC/C,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;gBACpB,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;oBACxB,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC;oBACnB,MAAM;iBACP;qBAAM,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE;oBACtB,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC;oBACjB,MAAM;iBACP;aACF;iBAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;gBAC3B,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC;gBACjB,MAAM;aACP;SACF;KACF;IACD,OAAO,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;AAC3B,CAAC;AAlBD,4BAkBC;AAAA,CAAC"} \ No newline at end of file diff --git a/csvtojson/index.d.ts b/csvtojson/index.d.ts deleted file mode 100644 index 462edf43..00000000 --- a/csvtojson/index.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -import { TransformOptions } from "stream"; -import { CSVParseParam } from "./Parameters"; -import { Converter } from "./Converter"; -declare const helper: (param?: Partial | undefined, options?: TransformOptions | undefined) => Converter; -export = helper; diff --git a/csvtojson/index.js b/csvtojson/index.js deleted file mode 100644 index 15a8fbb1..00000000 --- a/csvtojson/index.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var Converter_1 = require("./Converter"); -var helper = function (param, options) { - return new Converter_1.Converter(param, options); -}; -helper["csv"] = helper; -helper["Converter"] = Converter_1.Converter; -module.exports = helper; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/csvtojson/index.js.map b/csvtojson/index.js.map deleted file mode 100644 index 59978750..00000000 --- a/csvtojson/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,yCAAwC;AAExC,IAAM,MAAM,GAAG,UAAU,KAA8B,EAAE,OAA0B;IACjF,OAAO,IAAI,qBAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC,CAAA;AACD,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;AACvB,MAAM,CAAC,WAAW,CAAC,GAAG,qBAAS,CAAC;AAChC,iBAAQ,MAAM,CAAC"} \ No newline at end of file diff --git a/csvtojson/lineToJson.d.ts b/csvtojson/lineToJson.d.ts deleted file mode 100644 index d0f3e62a..00000000 --- a/csvtojson/lineToJson.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -import { Converter } from "./Converter"; -export default function (csvRows: string[][], conv: Converter): JSONResult[]; -export declare type JSONResult = { - [key: string]: any; -}; diff --git a/csvtojson/lineToJson.js b/csvtojson/lineToJson.js deleted file mode 100644 index eaa500b3..00000000 --- a/csvtojson/lineToJson.js +++ /dev/null @@ -1,216 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var CSVError_1 = __importDefault(require("./CSVError")); -var set_1 = __importDefault(require("lodash/set")); -var numReg = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/; -function default_1(csvRows, conv) { - var res = []; - for (var i = 0, len = csvRows.length; i < len; i++) { - var r = processRow(csvRows[i], conv, i); - if (r) { - res.push(r); - } - } - return res; -} -exports.default = default_1; -; -function processRow(row, conv, index) { - if (conv.parseParam.checkColumn && conv.parseRuntime.headers && row.length !== conv.parseRuntime.headers.length) { - throw (CSVError_1.default.column_mismatched(conv.parseRuntime.parsedLineNumber + index)); - } - var headRow = conv.parseRuntime.headers || []; - var resultRow = convertRowToJson(row, headRow, conv); - if (resultRow) { - return resultRow; - } - else { - return null; - } -} -function convertRowToJson(row, headRow, conv) { - var hasValue = false; - var resultRow = {}; - for (var i = 0, len = row.length; i < len; i++) { - var item = row[i]; - if (conv.parseParam.ignoreEmpty && item === '') { - continue; - } - hasValue = true; - var head = headRow[i]; - if (!head || head === "") { - head = headRow[i] = "field" + (i + 1); - } - var convFunc = getConvFunc(head, i, conv); - if (convFunc) { - var convRes = convFunc(item, head, resultRow, row, i); - if (convRes !== undefined) { - setPath(resultRow, head, convRes, conv, i); - } - } - else { - // var flag = getFlag(head, i, param); - // if (flag === 'omit') { - // continue; - // } - if (conv.parseParam.checkType) { - var convertFunc = checkType(item, head, i, conv); - item = convertFunc(item); - } - if (item !== undefined) { - setPath(resultRow, head, item, conv, i); - } - } - } - if (hasValue) { - return resultRow; - } - else { - return null; - } -} -var builtInConv = { - "string": stringType, - "number": numberType, - "omit": function () { } -}; -function getConvFunc(head, i, conv) { - if (conv.parseRuntime.columnConv[i] !== undefined) { - return conv.parseRuntime.columnConv[i]; - } - else { - var flag = conv.parseParam.colParser[head]; - if (flag === undefined) { - return conv.parseRuntime.columnConv[i] = null; - } - if (typeof flag === "object") { - flag = flag.cellParser || "string"; - } - if (typeof flag === "string") { - flag = flag.trim().toLowerCase(); - var builtInFunc = builtInConv[flag]; - if (builtInFunc) { - return conv.parseRuntime.columnConv[i] = builtInFunc; - } - else { - return conv.parseRuntime.columnConv[i] = null; - } - } - else if (typeof flag === "function") { - return conv.parseRuntime.columnConv[i] = flag; - } - else { - return conv.parseRuntime.columnConv[i] = null; - } - } -} -function setPath(resultJson, head, value, conv, headIdx) { - if (!conv.parseRuntime.columnValueSetter[headIdx]) { - if (conv.parseParam.flatKeys) { - conv.parseRuntime.columnValueSetter[headIdx] = flatSetter; - } - else { - if (head.indexOf(".") > -1) { - var headArr = head.split("."); - var jsonHead = true; - while (headArr.length > 0) { - var headCom = headArr.shift(); - if (headCom.length === 0) { - jsonHead = false; - break; - } - } - if (!jsonHead || conv.parseParam.colParser[head] && conv.parseParam.colParser[head].flat) { - conv.parseRuntime.columnValueSetter[headIdx] = flatSetter; - } - else { - conv.parseRuntime.columnValueSetter[headIdx] = jsonSetter; - } - } - else { - conv.parseRuntime.columnValueSetter[headIdx] = flatSetter; - } - } - } - if (conv.parseParam.nullObject === true && value === "null") { - value = null; - } - conv.parseRuntime.columnValueSetter[headIdx](resultJson, head, value); - // flatSetter(resultJson, head, value); -} -function flatSetter(resultJson, head, value) { - resultJson[head] = value; -} -function jsonSetter(resultJson, head, value) { - set_1.default(resultJson, head, value); -} -function checkType(item, head, headIdx, conv) { - if (conv.parseRuntime.headerType[headIdx]) { - return conv.parseRuntime.headerType[headIdx]; - } - else if (head.indexOf('number#!') > -1) { - return conv.parseRuntime.headerType[headIdx] = numberType; - } - else if (head.indexOf('string#!') > -1) { - return conv.parseRuntime.headerType[headIdx] = stringType; - } - else if (conv.parseParam.checkType) { - return conv.parseRuntime.headerType[headIdx] = dynamicType; - } - else { - return conv.parseRuntime.headerType[headIdx] = stringType; - } -} -function numberType(item) { - var rtn = parseFloat(item); - if (isNaN(rtn)) { - return item; - } - return rtn; -} -function stringType(item) { - return item.toString(); -} -function dynamicType(item) { - var trimed = item.trim(); - if (trimed === "") { - return stringType(item); - } - if (numReg.test(trimed)) { - return numberType(item); - } - else if (trimed.length === 5 && trimed.toLowerCase() === "false" || trimed.length === 4 && trimed.toLowerCase() === "true") { - return booleanType(item); - } - else if (trimed[0] === "{" && trimed[trimed.length - 1] === "}" || trimed[0] === "[" && trimed[trimed.length - 1] === "]") { - return jsonType(item); - } - else { - return stringType(item); - } -} -function booleanType(item) { - var trimed = item.trim(); - if (trimed.length === 5 && trimed.toLowerCase() === "false") { - return false; - } - else { - return true; - } -} -function jsonType(item) { - try { - return JSON.parse(item); - } - catch (e) { - return item; - } -} -//# sourceMappingURL=lineToJson.js.map \ No newline at end of file diff --git a/csvtojson/lineToJson.js.map b/csvtojson/lineToJson.js.map deleted file mode 100644 index 05d58c49..00000000 --- a/csvtojson/lineToJson.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"lineToJson.js","sourceRoot":"","sources":["../src/lineToJson.ts"],"names":[],"mappings":";;;;;AACA,wDAAkC;AAElC,mDAA6B;AAG7B,IAAI,MAAM,GAAG,0CAA0C,CAAC;AAExD,mBAAyB,OAAmB,EAAE,IAAe;IAC3D,IAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAClD,IAAM,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,EAAE;YACL,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AATD,4BASC;AAAA,CAAC;AAKF,oBAAoB,GAAa,EAAE,IAAe,EAAE,KAAK;IAEvD,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE;QAC/G,MAAM,CAAC,kBAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC,C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I,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;QAC3H,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;KACvB;SAAM;QACL,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;KACzB;AACH,CAAC;AAED,qBAAqB,IAAI;IACvB,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACzB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE;QAC3D,OAAO,KAAK,CAAC;KACd;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,kBAAkB,IAAI;IACpB,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACzB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,IAAI,CAAC;KACb;AACH,CAAC"} \ No newline at end of file diff --git a/csvtojson/rowSplit.d.ts b/csvtojson/rowSplit.d.ts deleted file mode 100644 index d1d401e9..00000000 --- a/csvtojson/rowSplit.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -import { Converter } from "./Converter"; -import { Fileline } from "./fileline"; -export declare class RowSplit { - private conv; - private quote; - private trim; - private escape; - private cachedRegExp; - private delimiterEmitted; - private _needEmitDelimiter?; - private readonly needEmitDelimiter; - constructor(conv: Converter); - parse(fileline: Fileline): RowSplitResult; - private toCSVRow(rowArr, trim, quote, delimiter); - private getDelimiter(fileline); - private isQuoteOpen(str); - private isQuoteClose(str); - private escapeQuote(segment); - parseMultiLines(lines: Fileline[]): MultipleRowResult; -} -export interface MultipleRowResult { - rowsCells: string[][]; - partial: string; -} -export interface RowSplitResult { - /** - * csv row array. ["a","b","c"] - */ - cells: string[]; - /** - * if the passed fileline is a complete row - */ - closed: boolean; -} diff --git a/csvtojson/rowSplit.js b/csvtojson/rowSplit.js deleted file mode 100644 index d5e7d058..00000000 --- a/csvtojson/rowSplit.js +++ /dev/null @@ -1,234 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var getEol_1 = __importDefault(require("./getEol")); -var util_1 = require("./util"); -var defaulDelimiters = [",", "|", "\t", ";", ":"]; -var RowSplit = /** @class */ (function () { - function RowSplit(conv) { - this.conv = conv; - this.cachedRegExp = {}; - this.delimiterEmitted = false; - this._needEmitDelimiter = undefined; - this.quote = conv.parseParam.quote; - this.trim = conv.parseParam.trim; - this.escape = conv.parseParam.escape; - } - Object.defineProperty(RowSplit.prototype, "needEmitDelimiter", { - get: function () { - if (this._needEmitDelimiter === undefined) { - this._needEmitDelimiter = this.conv.listeners("delimiter").length > 0; - } - return this._needEmitDelimiter; - }, - enumerable: true, - configurable: true - }); - RowSplit.prototype.parse = function (fileline) { - if (fileline.length === 0 || (this.conv.parseParam.ignoreEmpty && fileline.trim().length === 0)) { - return { cells: [], closed: true }; - } - var quote = this.quote; - var trim = this.trim; - var escape = this.escape; - if (this.conv.parseRuntime.delimiter instanceof Array || this.conv.parseRuntime.delimiter.toLowerCase() === "auto") { - this.conv.parseRuntime.delimiter = this.getDelimiter(fileline); - } - if (this.needEmitDelimiter && !this.delimiterEmitted) { - this.conv.emit("delimiter", this.conv.parseRuntime.delimiter); - this.delimiterEmitted = true; - } - var delimiter = this.conv.parseRuntime.delimiter; - var rowArr = fileline.split(delimiter); - if (quote === "off") { - if (trim) { - for (var i = 0; i < rowArr.length; i++) { - rowArr[i] = rowArr[i].trim(); - } - } - return { cells: rowArr, closed: true }; - } - else { - return this.toCSVRow(rowArr, trim, quote, delimiter); - } - }; - RowSplit.prototype.toCSVRow = function (rowArr, trim, quote, delimiter) { - var row = []; - var inquote = false; - var quoteBuff = ''; - for (var i = 0, rowLen = rowArr.length; i < rowLen; i++) { - var e = rowArr[i]; - if (!inquote && trim) { - e = util_1.trimLeft(e); - } - var len = e.length; - if (!inquote) { - if (len === 2 && e === this.quote + this.quote) { - row.push(""); - continue; - } - else if (this.isQuoteOpen(e)) { //quote open - e = e.substr(1); - if (this.isQuoteClose(e)) { //quote close - e = e.substring(0, e.lastIndexOf(quote)); - e = this.escapeQuote(e); - row.push(e); - continue; - } - else if (e.indexOf(quote) !== -1) { - var count = 0; - var prev = ""; - for (var _i = 0, e_1 = e; _i < e_1.length; _i++) { - var c = e_1[_i]; - // count quotes only if previous character is not escape char - if (c === quote && prev !== this.escape) { - count++; - prev = ""; - } - else { - // save previous char to temp variable - prev = c; - } - } - if (count % 2 === 1) { - if (trim) { - e = util_1.trimRight(e); - } - row.push(quote + e); - continue; - } - else { - inquote = true; - quoteBuff += e; - continue; - } - } - else { - inquote = true; - quoteBuff += e; - continue; - } - } - else { - if (trim) { - e = util_1.trimRight(e); - } - row.push(e); - continue; - } - } - else { //previous quote not closed - if (this.isQuoteClose(e)) { //close double quote - inquote = false; - e = e.substr(0, len - 1); - quoteBuff += delimiter + e; - quoteBuff = this.escapeQuote(quoteBuff); - if (trim) { - quoteBuff = util_1.trimRight(quoteBuff); - } - row.push(quoteBuff); - quoteBuff = ""; - } - else { - quoteBuff += delimiter + e; - } - } - } - // if (!inquote && param._needFilterRow) { - // row = filterRow(row, param); - // } - return { cells: row, closed: !inquote }; - }; - RowSplit.prototype.getDelimiter = function (fileline) { - var checker; - if (this.conv.parseParam.delimiter === "auto") { - checker = defaulDelimiters; - } - else if (this.conv.parseParam.delimiter instanceof Array) { - checker = this.conv.parseParam.delimiter; - } - else { - return this.conv.parseParam.delimiter; - } - var count = 0; - var rtn = ","; - checker.forEach(function (delim) { - var delimCount = fileline.split(delim).length; - if (delimCount > count) { - rtn = delim; - count = delimCount; - } - }); - return rtn; - }; - RowSplit.prototype.isQuoteOpen = function (str) { - var quote = this.quote; - var escape = this.escape; - return str[0] === quote && (str[1] !== quote || - str[1] === escape && (str[2] === quote || str.length === 2)); - }; - RowSplit.prototype.isQuoteClose = function (str) { - var quote = this.quote; - var escape = this.escape; - if (this.conv.parseParam.trim) { - str = util_1.trimRight(str); - } - var count = 0; - var idx = str.length - 1; - while (str[idx] === quote || str[idx] === escape) { - idx--; - count++; - } - return count % 2 !== 0; - }; - // private twoDoubleQuote(str: string): string { - // var twoQuote = this.quote + this.quote; - // var curIndex = -1; - // while ((curIndex = str.indexOf(twoQuote, curIndex)) > -1) { - // str = str.substring(0, curIndex) + str.substring(++curIndex); - // } - // return str; - // } - RowSplit.prototype.escapeQuote = function (segment) { - var key = "es|" + this.quote + "|" + this.escape; - if (this.cachedRegExp[key] === undefined) { - this.cachedRegExp[key] = new RegExp('\\' + this.escape + '\\' + this.quote, 'g'); - } - var regExp = this.cachedRegExp[key]; - // console.log(regExp,segment); - return segment.replace(regExp, this.quote); - }; - RowSplit.prototype.parseMultiLines = function (lines) { - var csvLines = []; - var left = ""; - while (lines.length) { - var line = left + lines.shift(); - var row = this.parse(line); - if (row.cells.length === 0 && this.conv.parseParam.ignoreEmpty) { - continue; - } - if (row.closed || this.conv.parseParam.alwaysSplitAtEOL) { - if (this.conv.parseRuntime.selectedColumns) { - csvLines.push(util_1.filterArray(row.cells, this.conv.parseRuntime.selectedColumns)); - } - else { - csvLines.push(row.cells); - } - left = ""; - } - else { - left = line + (getEol_1.default(line, this.conv.parseRuntime) || "\n"); - } - } - return { rowsCells: csvLines, partial: left }; - }; - return RowSplit; -}()); -exports.RowSplit = RowSplit; -//# sourceMappingURL=rowSplit.js.map \ No newline at end of file diff --git a/csvtojson/rowSplit.js.map b/csvtojson/rowSplit.js.map deleted file mode 100644 index 19f8091c..00000000 --- a/csvtojson/rowSplit.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"rowSplit.js","sourceRoot":"","sources":["../src/rowSplit.ts"],"names":[],"mappings":";;;;;AAGA,oDAA8B;AAC9B,+BAA0D;AAE1D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,CAAC;QAChC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,OAAO,KAAK,CAAC,MAAM,EAAE;YACnB,IAAM,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAClC,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE;gBAC9D,SAAS;aACV;YACD,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE;gBACvD,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE;oBAC1C,QAAQ,CAAC,IAAI,CAAC,kBAAW,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC;iBAC/E;qBAAM;oBACL,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;iBAC1B;gBAED,IAAI,GAAG,EAAE,CAAC;aACX;iBAAM;gBACL,IAAI,GAAG,IAAI,GAAG,CAAC,gBAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,CAAC;aAC9D;SACF;QACD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAChD,CAAC;IACH,eAAC;AAAD,CAAC,AApND,IAoNC;AApNY,4BAAQ"} \ No newline at end of file diff --git a/csvtojson/util.d.ts b/csvtojson/util.d.ts deleted file mode 100644 index 975539a0..00000000 --- a/csvtojson/util.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -/// -export declare function bufFromString(str: string): Buffer; -export declare function emptyBuffer(): Buffer; -export declare function filterArray(arr: any[], filter: number[]): any[]; -export declare const trimLeft: (str: string) => string; -export declare const trimRight: (str: string) => string; diff --git a/csvtojson/util.js b/csvtojson/util.js deleted file mode 100644 index af96d32a..00000000 --- a/csvtojson/util.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function bufFromString(str) { - var length = Buffer.byteLength(str); - var buffer = Buffer.allocUnsafe - ? Buffer.allocUnsafe(length) - : new Buffer(length); - buffer.write(str); - return buffer; -} -exports.bufFromString = bufFromString; -function emptyBuffer() { - var buffer = Buffer.allocUnsafe - ? Buffer.allocUnsafe(0) - : new Buffer(0); - return buffer; -} -exports.emptyBuffer = emptyBuffer; -function filterArray(arr, filter) { - var rtn = []; - for (var i = 0; i < arr.length; i++) { - if (filter.indexOf(i) > -1) { - rtn.push(arr[i]); - } - } - return rtn; -} -exports.filterArray = filterArray; -exports.trimLeft = String.prototype.trimLeft ? function trimLeftNative(str) { - return str.trimLeft(); -} : function trimLeftRegExp(str) { - return str.replace(/^\s+/, ""); -}; -exports.trimRight = String.prototype.trimRight ? function trimRightNative(str) { - return str.trimRight(); -} : function trimRightRegExp(str) { - return str.replace(/\s+$/, ""); -}; -//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/csvtojson/util.js.map b/csvtojson/util.js.map deleted file mode 100644 index 6e2d530e..00000000 --- a/csvtojson/util.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAAA,uBAA8B,GAAW;IACvC,IAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACtC,IAAM,MAAM,GAAG,MAAM,CAAC,WAAW;QAC/B,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC;QAC5B,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,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ker.d.ts deleted file mode 100644 index f03040c6..00000000 --- a/csvtojson/worker.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ \ No newline at end of file diff --git a/csvtojson/worker.js b/csvtojson/worker.js deleted file mode 100644 index 4b28df6f..00000000 --- a/csvtojson/worker.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * MIT license brought in by https://github.com/Keyang/node-csvtojson - * */ - -"use strict"; -// import { Converter } from "./Converter"; -// import { Message, InitMessage, EOM } from "./ProcessFork"; -// import CSVError from "./CSVError"; -// import { CSVParseParam } from "./Parameters"; -// process.on("message", processMsg); -// let conv: Converter; -// function processMsg(msg: Message) { -// if (msg.cmd === "init") { -// const param = prepareParams((msg as InitMessage).params); -// param.fork = false; -// conv = new Converter(param); -// process.stdin.pipe(conv).pipe(process.stdout); -// conv.on("error", (err) => { -// if ((err as CSVError).line) { -// process.stderr.write(JSON.stringify({ -// err: (err as CSVError).err, -// line: (err as CSVError).line, -// extra: (err as CSVError).extra -// })) -// } else { -// process.stderr.write(JSON.stringify({ -// err: err.message, -// line: -1, -// extra: "Unknown error" -// })); -// } -// }); -// conv.on("eol", (eol) => { -// // console.log("eol!!!",eol); -// if (process.send) -// process.send({ cmd: "eol", "value": eol }); -// }) -// conv.on("header", (header) => { -// if (process.send) -// process.send({ cmd: "header", "value": header }); -// }) -// conv.on("done", () => { -// const drained = process.stdout.write("", () => { -// if (drained) { -// gracelyExit(); -// } -// }); -// if (!drained) { -// process.stdout.on("drain", gracelyExit) -// } -// // process.stdout.write(EOM); -// }) -// if (process.send) { -// process.send({ cmd: "inited" }); -// } -// } -// } -// function gracelyExit(){ -// setTimeout(()=>{ -// conv.removeAllListeners(); -// process.removeAllListeners(); -// },50); -// } -// function prepareParams(p: any): CSVParseParam { -// if (p.ignoreColumns) { -// p.ignoreColumns = new RegExp(p.ignoreColumns.source, p.ignoreColumns.flags) -// } -// if (p.includeColumns) { -// p.includeColumns = new RegExp(p.includeColumns.source, p.includeColumns.flags) -// } -// return p; -// } -// process.on("disconnect", () => { -// process.exit(-1); -// }); -//# sourceMappingURL=worker.js.map \ No newline at end of file diff --git a/csvtojson/worker.js.map b/csvtojson/worker.js.map deleted file mode 100644 index 0ac09766..00000000 --- a/csvtojson/worker.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,6DAA6D;AAC7D,qCAAqC;AACrC,gDAAgD;AAChD,qCAAqC;AACrC,uBAAuB;AACvB,sCAAsC;AACtC,8BAA8B;AAC9B,gEAAgE;AAChE,0BAA0B;AAC1B,mCAAmC;AACnC,qDAAqD;AACrD,kCAAkC;AAClC,sCAAsC;AACtC,gDAAgD;AAChD,wCAAwC;AACxC,0CAA0C;AAC1C,2CAA2C;AAC3C,cAAc;AACd,iBAAiB;AACjB,gDAAgD;AAChD,8BAA8B;AAC9B,sBAAsB;AACtB,mCAAmC;AACnC,eAAe;AACf,UAAU;AAEV,UAAU;AACV,gCAAgC;AAChC,sCAAsC;AACtC,0BAA0B;AAC1B,sDAAsD;AACtD,SAAS;AACT,sCAAsC;AACtC,0BAA0B;AAC1B,4DAA4D;AAC5D,SAAS;AACT,8BAA8B;AAC9B,yDAAyD;AACzD,yBAAyB;AACzB,2BAA2B;AAC3B,YAAY;AACZ,YAAY;AACZ,wBAAwB;AACxB,kDAAkD;AAClD,UAAU;AAGV,sCAAsC;AACtC,SAAS;AACT,0BAA0B;AAC1B,yCAAyC;AACzC,QAAQ;AAGR,MAAM;AACN,IAAI;AACJ,0BAA0B;AAC1B,qBAAqB;AACrB,iCAAiC;AACjC,oCAAoC;AACpC,WAAW;AACX,IAAI;AACJ,kDAAkD;AAClD,2BAA2B;AAC3B,kFAAkF;AAClF,MAAM;AACN,4BAA4B;AAC5B,qFAAqF;AACrF,MAAM;AACN,cAAc;AACd,IAAI;AAEJ,mCAAmC;AACnC,sBAAsB;AACtB,MAAM"} \ No newline at end of file diff --git a/package.json b/package.json index 5fc0820a..5e134434 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@salesforce/core": "^3.34.6", "@salesforce/sf-plugins-core": "^2.2.5", "@salesforce/ts-types": "^1.7.3", + "csv-parse": "^5.3.6", "fast-xml-parser": "^4.1.3", "tslib": "^2" }, @@ -60,7 +61,6 @@ "@swc/core": "^1.3.37", "@typescript-eslint/eslint-plugin": "^5.57.0", "@typescript-eslint/parser": "^5.57.1", - "bluebird": "3.7.2", "chai": "^4.3.7", "eslint": "^8.36.0", "eslint-config-prettier": "^8.8.0", @@ -245,4 +245,4 @@ "output": [] } } -} \ No newline at end of file +} diff --git a/src/commands/cmdt/generate/records.ts b/src/commands/cmdt/generate/records.ts index 2f79e93d..ac71e284 100644 --- a/src/commands/cmdt/generate/records.ts +++ b/src/commands/cmdt/generate/records.ts @@ -9,7 +9,7 @@ import * as path from 'path'; import { Flags, loglevel, SfCommand } from '@salesforce/sf-plugins-core'; import { Messages, SfError } from '@salesforce/core'; import { Record } from 'jsforce'; -import * as csv from '../../../../csvtojson'; +import { parse } from 'csv-parse/sync'; import { getFieldNames, appendDirectorySuffix, createRecord, getFileData } from '../../../shared/helpers/createUtil'; import { CreateConfig, CreateConfigs } from '../../../shared/interfaces/createConfig'; @@ -69,43 +69,35 @@ export default class Insert extends SfCommand { await fs.promises.mkdir(flags['output-directory'], { recursive: true }); const fileData = await getFileData(fieldDirPath, fileNames); - const csvDataAry = (await csv().fromFile(flags.csv)) as Record[]; - const metadataTypeFields = getFieldNames(fileData, flags['name-column']); - if (csvDataAry.length > 0) { - const record = csvDataAry[0]; - for (const key in record) { - if (!metadataTypeFields.includes(key)) { - throw new SfError(messages.getMessage('fieldNotFoundError', [key, flags['type-name']])); - } - } - } + + const parsedRecords = parse(await fs.promises.readFile(flags.csv), { + columns: (header: string[]) => columnValidation(metadataTypeFields, header, flags['type-name']), + }) as Record[]; + + const recordConfigs: CreateConfig[] = parsedRecords.map((record) => ({ + typename: flags['type-name'], + recordname: (record[flags['name-column']] as string).replace(' ', '_'), + label: record[flags['name-column']] as string, + inputdir: flags['input-directory'], + outputdir: flags['output-directory'], + protected: false, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + varargs: Object.fromEntries( + // TODO: throw an error if any of the fields in the csvDataAry do not exist in the fileData + fileData.map((file) => { + if (file.fullName) { + return record[file.fullName] ? [file.fullName, record[file.fullName]] : []; + } else { + throw new SfError('No fullName found in fileData'); + } + }) + ), + fileData, + })); // find the cmdt in the inputdir. // loop through files and create records that match fields - - const recordConfigs = csvDataAry.map( - (record): CreateConfig => ({ - typename: flags['type-name'], - recordname: (record[flags['name-column']] as string).replace(' ', '_'), - label: record[flags['name-column']] as string, - inputdir: flags['input-directory'], - outputdir: flags['output-directory'], - protected: false, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - varargs: Object.fromEntries( - // TODO: throw an error if any of the fields in the csvDataAry do not exist in the fileData - fileData.map((file) => { - if (file.fullName) { - return record[file.fullName] ? [file.fullName, record[file.fullName]] : []; - } else { - throw new SfError('No fullName found in fileData'); - } - }) - ), - fileData, - }) - ); await Promise.all(recordConfigs.map((r) => createRecord(r))); this.log(messages.getMessage('successResponse', [flags.csv, flags['output-directory']])); @@ -113,3 +105,13 @@ export default class Insert extends SfCommand { return recordConfigs; } } + +/** Validate that every column in the CSV has known metadata */ +const columnValidation = (requiredFields: string[], columnList: string[], typeNameFlag: string): string[] => { + columnList.forEach((column) => { + if (!requiredFields.includes(column)) { + throw new SfError(messages.getMessage('fieldNotFoundError', [column, typeNameFlag])); + } + }); + return columnList; +}; diff --git a/test/nuts/generate.nut.ts b/test/nuts/generate.nut.ts index 7dea4ac4..99edcd7a 100644 --- a/test/nuts/generate.nut.ts +++ b/test/nuts/generate.nut.ts @@ -31,9 +31,7 @@ describe('sfdx force:cmdt:generate', () => { }, scratchOrgs: [ { - executable: 'sfdx', config: path.join('config', 'project-scratch-def.json'), - duration: 1, setDefault: true, }, ], diff --git a/yarn.lock b/yarn.lock index 7d8c564d..d1300806 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1845,11 +1845,6 @@ bl@^4.0.3, bl@^4.1.0: inherits "^2.0.4" readable-stream "^3.4.0" -bluebird@3.7.2: - version "3.7.2" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" - integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -2540,6 +2535,11 @@ csv-parse@^4.8.2: resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.16.3.tgz#7ca624d517212ebc520a36873c3478fa66efbaf7" integrity sha512-cO1I/zmz4w2dcKHVvpCr7JVRu8/FymG5OEpmvsZYlccYolPBLoVGKUHgNoc4ZGkFeFlWGEDmMyBM+TTqRdW/wg== +csv-parse@^5.3.6: + version "5.3.6" + resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.3.6.tgz#181d7c12300a60684bb51261ea9a5c3135ba8688" + integrity sha512-WI330GjCuEioK/ii8HM2YE/eV+ynpeLvU+RXw4R8bRU8R0laK5zO3fDsc4gH8s472e3Ga38rbIjCAiQh+tEHkw== + csv-stringify@^5.3.4: version "5.6.5" resolved "https://registry.yarnpkg.com/csv-stringify/-/csv-stringify-5.6.5.tgz#c6d74badda4b49a79bf4e72f91cce1e33b94de00" From d86913cb722f787cbd99e8f4b617fefa80cf3669 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 14 Apr 2023 11:39:05 -0500 Subject: [PATCH 2/5] chore: remove csvtojson from pjson.files --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 5e134434..8f2e60f0 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,6 @@ "node": ">=14.0.0" }, "files": [ - "/csvtojson", "/lib", "/messages", "/oclif.manifest.json", From 2663e10c4ca7ee00e2298b7ea582bac51f931e73 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 14 Apr 2023 11:49:10 -0500 Subject: [PATCH 3/5] test: remove sfdx requirements --- test/nuts/generate.nut.ts | 7 +++---- test/nuts/local/createCMDT.nut.ts | 2 +- test/nuts/local/createField.nut.ts | 2 +- test/nuts/local/createRecord.nut.ts | 6 +++--- test/nuts/local/insertRecord.nut.ts | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/nuts/generate.nut.ts b/test/nuts/generate.nut.ts index 99edcd7a..7203e4c5 100644 --- a/test/nuts/generate.nut.ts +++ b/test/nuts/generate.nut.ts @@ -23,7 +23,7 @@ let metadataFolder: string; let session: TestSession; -describe('sfdx force:cmdt:generate', () => { +describe('force:cmdt:generate', () => { before(async () => { session = await TestSession.create({ project: { @@ -38,11 +38,10 @@ describe('sfdx force:cmdt:generate', () => { devhubAuthStrategy: 'AUTO', }); // we rely on their being some custom object and records - execCmd('force:source:push', { ensureExitCode: 0, cli: 'sfdx' }); - execCmd('force:user:permset:assign -n dreamhouse', { ensureExitCode: 0, cli: 'sfdx' }); + execCmd('force:source:push', { ensureExitCode: 0 }); + execCmd('force:user:permset:assign -n dreamhouse', { ensureExitCode: 0 }); execCmd(`force:data:tree:import -p ${path.join('data', 'sample-data-plan.json')}`, { ensureExitCode: 0, - cli: 'sfdx', }); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion mainFolder = path.join(session.project.dir, 'force-app', 'main', 'default'); diff --git a/test/nuts/local/createCMDT.nut.ts b/test/nuts/local/createCMDT.nut.ts index 7841a5ca..4b9a519d 100644 --- a/test/nuts/local/createCMDT.nut.ts +++ b/test/nuts/local/createCMDT.nut.ts @@ -13,7 +13,7 @@ import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit'; let session: TestSession; let projDir: string; -describe('sfdx force:cmdt:create', () => { +describe('force:cmdt:create', () => { before(async () => { session = await TestSession.create({ project: { diff --git a/test/nuts/local/createField.nut.ts b/test/nuts/local/createField.nut.ts index 87b63a91..5f719473 100644 --- a/test/nuts/local/createField.nut.ts +++ b/test/nuts/local/createField.nut.ts @@ -17,7 +17,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-custom-metadata', 'fi let session: TestSession; let projDir: string; -describe('sfdx force:cmdt:field:create', () => { +describe('force:cmdt:field:create', () => { before(async () => { session = await TestSession.create({ project: { diff --git a/test/nuts/local/createRecord.nut.ts b/test/nuts/local/createRecord.nut.ts index 43873e4b..392aadc5 100644 --- a/test/nuts/local/createRecord.nut.ts +++ b/test/nuts/local/createRecord.nut.ts @@ -36,7 +36,7 @@ describe('cmdt record create', () => { await session.clean(); }); - describe('sfdx force:cmdt:record:create error handling', () => { + describe('force:cmdt:record:create error handling', () => { it('runs force:cmdt:record:create and throws an error if the API name is invalid', () => { execCmd('force:cmdt:create --typename Bad_Dev_Name --outputdir badDevNameDir', { ensureExitCode: 0 }); const badType = 'pbwbFgJM4GyDOaNZn60NjAy3Ciks791y_dKLsPmXS6'; @@ -99,7 +99,7 @@ describe('cmdt record create', () => { }); }); - describe('sfdx force:cmdt:record:create', () => { + describe('force:cmdt:record:create', () => { it('runs force:cmdt:record:create with long flags', () => { const fieldDirPath = 'createWithLongFlags'; const outputDir = path.join(fieldDirPath, 'Long_Flags_Create_Test__mdt'); @@ -175,7 +175,7 @@ describe('cmdt record create', () => { }); }); - describe('sfdx force:cmdt:record:create test contents of record file created', () => { + describe('force:cmdt:record:create test contents of record file created', () => { it('should create records without optional flags', async () => { const testDir = 'outputTestDir'; const fieldDirPath = path.join(testDir, 'Output_Test__mdt', 'fields'); diff --git a/test/nuts/local/insertRecord.nut.ts b/test/nuts/local/insertRecord.nut.ts index ae0e12b4..2f995cc8 100644 --- a/test/nuts/local/insertRecord.nut.ts +++ b/test/nuts/local/insertRecord.nut.ts @@ -18,7 +18,7 @@ config.truncateThreshold = 0; let session: TestSession; let projDir: string; -describe('sfdx force:cmdt:record:insert', () => { +describe('force:cmdt:record:insert', () => { before(async () => { session = await TestSession.create({ project: { From 027596dd72d37dfbcb6edf63d66be3ba4e6abf1d Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 14 Apr 2023 12:06:30 -0500 Subject: [PATCH 4/5] Revert "test: remove sfdx requirements" This reverts commit 2663e10c4ca7ee00e2298b7ea582bac51f931e73. --- test/nuts/generate.nut.ts | 7 ++++--- test/nuts/local/createCMDT.nut.ts | 2 +- test/nuts/local/createField.nut.ts | 2 +- test/nuts/local/createRecord.nut.ts | 6 +++--- test/nuts/local/insertRecord.nut.ts | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/nuts/generate.nut.ts b/test/nuts/generate.nut.ts index 7203e4c5..99edcd7a 100644 --- a/test/nuts/generate.nut.ts +++ b/test/nuts/generate.nut.ts @@ -23,7 +23,7 @@ let metadataFolder: string; let session: TestSession; -describe('force:cmdt:generate', () => { +describe('sfdx force:cmdt:generate', () => { before(async () => { session = await TestSession.create({ project: { @@ -38,10 +38,11 @@ describe('force:cmdt:generate', () => { devhubAuthStrategy: 'AUTO', }); // we rely on their being some custom object and records - execCmd('force:source:push', { ensureExitCode: 0 }); - execCmd('force:user:permset:assign -n dreamhouse', { ensureExitCode: 0 }); + execCmd('force:source:push', { ensureExitCode: 0, cli: 'sfdx' }); + execCmd('force:user:permset:assign -n dreamhouse', { ensureExitCode: 0, cli: 'sfdx' }); execCmd(`force:data:tree:import -p ${path.join('data', 'sample-data-plan.json')}`, { ensureExitCode: 0, + cli: 'sfdx', }); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion mainFolder = path.join(session.project.dir, 'force-app', 'main', 'default'); diff --git a/test/nuts/local/createCMDT.nut.ts b/test/nuts/local/createCMDT.nut.ts index 4b9a519d..7841a5ca 100644 --- a/test/nuts/local/createCMDT.nut.ts +++ b/test/nuts/local/createCMDT.nut.ts @@ -13,7 +13,7 @@ import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit'; let session: TestSession; let projDir: string; -describe('force:cmdt:create', () => { +describe('sfdx force:cmdt:create', () => { before(async () => { session = await TestSession.create({ project: { diff --git a/test/nuts/local/createField.nut.ts b/test/nuts/local/createField.nut.ts index 5f719473..87b63a91 100644 --- a/test/nuts/local/createField.nut.ts +++ b/test/nuts/local/createField.nut.ts @@ -17,7 +17,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-custom-metadata', 'fi let session: TestSession; let projDir: string; -describe('force:cmdt:field:create', () => { +describe('sfdx force:cmdt:field:create', () => { before(async () => { session = await TestSession.create({ project: { diff --git a/test/nuts/local/createRecord.nut.ts b/test/nuts/local/createRecord.nut.ts index 392aadc5..43873e4b 100644 --- a/test/nuts/local/createRecord.nut.ts +++ b/test/nuts/local/createRecord.nut.ts @@ -36,7 +36,7 @@ describe('cmdt record create', () => { await session.clean(); }); - describe('force:cmdt:record:create error handling', () => { + describe('sfdx force:cmdt:record:create error handling', () => { it('runs force:cmdt:record:create and throws an error if the API name is invalid', () => { execCmd('force:cmdt:create --typename Bad_Dev_Name --outputdir badDevNameDir', { ensureExitCode: 0 }); const badType = 'pbwbFgJM4GyDOaNZn60NjAy3Ciks791y_dKLsPmXS6'; @@ -99,7 +99,7 @@ describe('cmdt record create', () => { }); }); - describe('force:cmdt:record:create', () => { + describe('sfdx force:cmdt:record:create', () => { it('runs force:cmdt:record:create with long flags', () => { const fieldDirPath = 'createWithLongFlags'; const outputDir = path.join(fieldDirPath, 'Long_Flags_Create_Test__mdt'); @@ -175,7 +175,7 @@ describe('cmdt record create', () => { }); }); - describe('force:cmdt:record:create test contents of record file created', () => { + describe('sfdx force:cmdt:record:create test contents of record file created', () => { it('should create records without optional flags', async () => { const testDir = 'outputTestDir'; const fieldDirPath = path.join(testDir, 'Output_Test__mdt', 'fields'); diff --git a/test/nuts/local/insertRecord.nut.ts b/test/nuts/local/insertRecord.nut.ts index 2f995cc8..ae0e12b4 100644 --- a/test/nuts/local/insertRecord.nut.ts +++ b/test/nuts/local/insertRecord.nut.ts @@ -18,7 +18,7 @@ config.truncateThreshold = 0; let session: TestSession; let projDir: string; -describe('force:cmdt:record:insert', () => { +describe('sfdx force:cmdt:record:insert', () => { before(async () => { session = await TestSession.create({ project: { From 42d3634b50137704912a14d81125b285b0e14ee8 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 14 Apr 2023 12:07:15 -0500 Subject: [PATCH 5/5] test: put sfdx references back --- test/nuts/generate.nut.ts | 2 +- test/nuts/local/createCMDT.nut.ts | 2 +- test/nuts/local/createField.nut.ts | 2 +- test/nuts/local/createRecord.nut.ts | 2 +- test/nuts/local/insertRecord.nut.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/nuts/generate.nut.ts b/test/nuts/generate.nut.ts index 99edcd7a..0d0d47d5 100644 --- a/test/nuts/generate.nut.ts +++ b/test/nuts/generate.nut.ts @@ -23,7 +23,7 @@ let metadataFolder: string; let session: TestSession; -describe('sfdx force:cmdt:generate', () => { +describe('force:cmdt:generate', () => { before(async () => { session = await TestSession.create({ project: { diff --git a/test/nuts/local/createCMDT.nut.ts b/test/nuts/local/createCMDT.nut.ts index 7841a5ca..4b9a519d 100644 --- a/test/nuts/local/createCMDT.nut.ts +++ b/test/nuts/local/createCMDT.nut.ts @@ -13,7 +13,7 @@ import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit'; let session: TestSession; let projDir: string; -describe('sfdx force:cmdt:create', () => { +describe('force:cmdt:create', () => { before(async () => { session = await TestSession.create({ project: { diff --git a/test/nuts/local/createField.nut.ts b/test/nuts/local/createField.nut.ts index 87b63a91..5f719473 100644 --- a/test/nuts/local/createField.nut.ts +++ b/test/nuts/local/createField.nut.ts @@ -17,7 +17,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-custom-metadata', 'fi let session: TestSession; let projDir: string; -describe('sfdx force:cmdt:field:create', () => { +describe('force:cmdt:field:create', () => { before(async () => { session = await TestSession.create({ project: { diff --git a/test/nuts/local/createRecord.nut.ts b/test/nuts/local/createRecord.nut.ts index 43873e4b..bebffc3a 100644 --- a/test/nuts/local/createRecord.nut.ts +++ b/test/nuts/local/createRecord.nut.ts @@ -36,7 +36,7 @@ describe('cmdt record create', () => { await session.clean(); }); - describe('sfdx force:cmdt:record:create error handling', () => { + describe('force:cmdt:record:create error handling', () => { it('runs force:cmdt:record:create and throws an error if the API name is invalid', () => { execCmd('force:cmdt:create --typename Bad_Dev_Name --outputdir badDevNameDir', { ensureExitCode: 0 }); const badType = 'pbwbFgJM4GyDOaNZn60NjAy3Ciks791y_dKLsPmXS6'; diff --git a/test/nuts/local/insertRecord.nut.ts b/test/nuts/local/insertRecord.nut.ts index ae0e12b4..2f995cc8 100644 --- a/test/nuts/local/insertRecord.nut.ts +++ b/test/nuts/local/insertRecord.nut.ts @@ -18,7 +18,7 @@ config.truncateThreshold = 0; let session: TestSession; let projDir: string; -describe('sfdx force:cmdt:record:insert', () => { +describe('force:cmdt:record:insert', () => { before(async () => { session = await TestSession.create({ project: {