UNPKG

@bitbybit-dev/core

Version:

Bit By Bit Developers Core CAD API to Program Geometry

467 lines (466 loc) 14.8 kB
/* eslint-disable @typescript-eslint/no-namespace */ export var CSV; (function (CSV) { class ParseToArrayDto { constructor(csv, rowSeparator, columnSeparator) { /** * CSV text to parse * @default name,age\nJohn,30 */ this.csv = "name,age\nJohn,30"; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (csv !== undefined) { this.csv = csv; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } } } CSV.ParseToArrayDto = ParseToArrayDto; class ParseToJsonDto { constructor(csv, headerRow, dataStartRow, rowSeparator, columnSeparator, numberColumns) { /** * CSV text to parse * @default name,age\nJohn,30\nJane,25 */ this.csv = "name,age\nJohn,30\nJane,25"; /** * Row index where headers are located * @default 0 * @minimum 0 * @maximum Infinity * @step 1 */ this.headerRow = 0; /** * Row index where data starts * @default 1 * @minimum 0 * @maximum Infinity * @step 1 */ this.dataStartRow = 1; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (csv !== undefined) { this.csv = csv; } if (headerRow !== undefined) { this.headerRow = headerRow; } if (dataStartRow !== undefined) { this.dataStartRow = dataStartRow; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } if (numberColumns !== undefined) { this.numberColumns = numberColumns; } } } CSV.ParseToJsonDto = ParseToJsonDto; class ParseToJsonWithHeadersDto { constructor(csv, headers, dataStartRow, rowSeparator, columnSeparator, numberColumns) { /** * CSV text to parse * @default John,30\nJane,25 */ this.csv = "John,30\nJane,25"; /** * Custom header names to use * @default ["name", "age"] */ this.headers = ["name", "age"]; /** * Row index where data starts * @default 0 * @minimum 0 * @maximum Infinity * @step 1 */ this.dataStartRow = 0; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (csv !== undefined) { this.csv = csv; } if (headers !== undefined) { this.headers = headers; } if (dataStartRow !== undefined) { this.dataStartRow = dataStartRow; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } if (numberColumns !== undefined) { this.numberColumns = numberColumns; } } } CSV.ParseToJsonWithHeadersDto = ParseToJsonWithHeadersDto; class QueryColumnDto { constructor(csv, column, headerRow, dataStartRow, rowSeparator, columnSeparator, asNumber) { /** * CSV text to query * @default name,age\nJohn,30\nJane,25 */ this.csv = "name,age\nJohn,30\nJane,25"; /** * Column name to query * @default name */ this.column = "name"; /** * Row index where headers are located * @default 0 * @minimum 0 * @maximum Infinity * @step 1 */ this.headerRow = 0; /** * Row index where data starts * @default 1 * @minimum 0 * @maximum Infinity * @step 1 */ this.dataStartRow = 1; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; /** * Convert column values to numbers * @default false */ this.asNumber = false; if (csv !== undefined) { this.csv = csv; } if (column !== undefined) { this.column = column; } if (headerRow !== undefined) { this.headerRow = headerRow; } if (dataStartRow !== undefined) { this.dataStartRow = dataStartRow; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } if (asNumber !== undefined) { this.asNumber = asNumber; } } } CSV.QueryColumnDto = QueryColumnDto; class QueryRowsByValueDto { constructor(csv, column, value, headerRow, dataStartRow, rowSeparator, columnSeparator, numberColumns) { /** * CSV text to query * @default name,age\nJohn,30\nJane,25 */ this.csv = "name,age\nJohn,30\nJane,25"; /** * Column name to filter by * @default age */ this.column = "age"; /** * Value to match * @default 30 */ this.value = "30"; /** * Row index where headers are located * @default 0 * @minimum 0 * @maximum Infinity * @step 1 */ this.headerRow = 0; /** * Row index where data starts * @default 1 * @minimum 0 * @maximum Infinity * @step 1 */ this.dataStartRow = 1; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (csv !== undefined) { this.csv = csv; } if (column !== undefined) { this.column = column; } if (value !== undefined) { this.value = value; } if (headerRow !== undefined) { this.headerRow = headerRow; } if (dataStartRow !== undefined) { this.dataStartRow = dataStartRow; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } if (numberColumns !== undefined) { this.numberColumns = numberColumns; } } } CSV.QueryRowsByValueDto = QueryRowsByValueDto; class ArrayToCsvDto { constructor(array, rowSeparator, columnSeparator) { /** * 2D array to convert * @default [["name", "age"], ["John", "30"]] */ this.array = [["name", "age"], ["John", "30"]]; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (array !== undefined) { this.array = array; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } } } CSV.ArrayToCsvDto = ArrayToCsvDto; class JsonToCsvDto { constructor(json, headers, includeHeaders, rowSeparator, columnSeparator) { /** * Array of JSON objects to convert * @default [{"name": "John", "age": "30"}] */ this.json = [{ "name": "John", "age": "30" }]; /** * Headers to use (in order) * @default ["name", "age"] */ this.headers = ["name", "age"]; /** * Whether to include headers in output * @default true */ this.includeHeaders = true; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (json !== undefined) { this.json = json; } if (headers !== undefined) { this.headers = headers; } if (includeHeaders !== undefined) { this.includeHeaders = includeHeaders; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } } } CSV.JsonToCsvDto = JsonToCsvDto; class JsonToCsvAutoDto { constructor(json, includeHeaders, rowSeparator, columnSeparator) { /** * Array of JSON objects to convert * @default [{"name": "John", "age": "30"}] */ this.json = [{ "name": "John", "age": "30" }]; /** * Whether to include headers in output * @default true */ this.includeHeaders = true; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (json !== undefined) { this.json = json; } if (includeHeaders !== undefined) { this.includeHeaders = includeHeaders; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } } } CSV.JsonToCsvAutoDto = JsonToCsvAutoDto; class GetHeadersDto { constructor(csv, headerRow, rowSeparator, columnSeparator) { /** * CSV text to get headers from * @default name,age\nJohn,30 */ this.csv = "name,age\nJohn,30"; /** * Row index where headers are located * @default 0 * @minimum 0 * @maximum Infinity * @step 1 */ this.headerRow = 0; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (csv !== undefined) { this.csv = csv; } if (headerRow !== undefined) { this.headerRow = headerRow; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } } } CSV.GetHeadersDto = GetHeadersDto; class GetRowCountDto { constructor(csv, hasHeaders, dataStartRow, rowSeparator, columnSeparator) { /** * CSV text to count rows * @default name,age\nJohn,30\nJane,25 */ this.csv = "name,age\nJohn,30\nJane,25"; /** * Whether CSV has headers * @default true */ this.hasHeaders = true; /** * Row separator (newline character) * @default \n */ this.rowSeparator = "\n"; /** * Column separator (delimiter) * @default , */ this.columnSeparator = ","; if (csv !== undefined) { this.csv = csv; } if (hasHeaders !== undefined) { this.hasHeaders = hasHeaders; } if (dataStartRow !== undefined) { this.dataStartRow = dataStartRow; } if (rowSeparator !== undefined) { this.rowSeparator = rowSeparator; } if (columnSeparator !== undefined) { this.columnSeparator = columnSeparator; } } } CSV.GetRowCountDto = GetRowCountDto; })(CSV || (CSV = {}));