typeshi 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,7 +72,7 @@ export declare const DEFAULT_TIMEZONE = "America/Los_Angeles";
72
72
  * @example "2025-04-16T00:00:00.000Z"
73
73
  * @note dateFormat === DateFormatEnum.LOCALE -> use {@link DEFAULT_LOCALE} and {@link DEFAULT_TIMEZONE}
74
74
  */
75
- export declare function getDateFromUnixTimestamp(unixTimestamp: number, dateFormat: DateFormatEnum): string | null;
75
+ export declare function getDateStringFromUnixTimestamp(unixTimestamp: number, dateFormat: DateFormatEnum): string | null;
76
76
  /**
77
77
  * @param ds1 first date `string` `(required)` - must be in {@link DateFormatEnum.ISO} format or {@link DateFormatEnum.LOCALE} format. @TODO test other formats
78
78
  * @param ds2 second date `string` `(optional)` - defaults to current date and time in Pacific Time
@@ -4,7 +4,7 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Milliseconds = exports.DEFAULT_TIMEZONE = exports.DEFAULT_LOCALE = exports.LOCALE_PATTERN = exports.UTC_PATTERN = exports.ISO_PATTERN = exports.TimeUnitEnum = exports.DateFormatEnum = void 0;
7
- exports.getDateFromUnixTimestamp = getDateFromUnixTimestamp;
7
+ exports.getDateStringFromUnixTimestamp = getDateStringFromUnixTimestamp;
8
8
  exports.calculateDifferenceOfDateStrings = calculateDifferenceOfDateStrings;
9
9
  exports.getUnixTimestampFromISO = getUnixTimestampFromISO;
10
10
  exports.localeStringToDate = localeStringToDate;
@@ -79,7 +79,7 @@ exports.DEFAULT_TIMEZONE = 'America/Los_Angeles';
79
79
  * @example "2025-04-16T00:00:00.000Z"
80
80
  * @note dateFormat === DateFormatEnum.LOCALE -> use {@link DEFAULT_LOCALE} and {@link DEFAULT_TIMEZONE}
81
81
  */
82
- function getDateFromUnixTimestamp(unixTimestamp, dateFormat) {
82
+ function getDateStringFromUnixTimestamp(unixTimestamp, dateFormat) {
83
83
  if (!unixTimestamp) {
84
84
  console.error('No unixTimestamp provided');
85
85
  return null;
@@ -9,6 +9,7 @@ import { ILogObj, ILogObjMeta } from "tslog";
9
9
  */
10
10
  export declare function getSourceString(fileName: string, func: string | Function, funcInfo?: any, startLine?: number, endLine?: number): string;
11
11
  /**
12
+ * @deprecated
12
13
  * Auto-formats debug logs at the end of application execution.
13
14
  * Call this function when your main application is finishing.
14
15
  * @param filePaths `string[]` - optional, specific file paths to format.
@@ -17,6 +18,7 @@ export declare function getSourceString(fileName: string, func: string | Functio
17
18
  */
18
19
  export declare function autoFormatLogsOnExit(filePaths?: string[]): void;
19
20
  /**
21
+ * @deprecated
20
22
  * Formats a debug log file from JSON format to a more readable text format.
21
23
  * Removes the numeric keys and properly handles escape sequences.
22
24
  * @param inputPath `string` - path to the input log file (e.g., DEBUG.txt)
@@ -26,6 +28,7 @@ export declare function autoFormatLogsOnExit(filePaths?: string[]): void;
26
28
  */
27
29
  export declare function formatDebugLogFile(inputPath: string, outputPath?: string): void;
28
30
  /**
31
+ * @deprecated
29
32
  * Formats all debug log files in the log directory.
30
33
  * Looks for .txt files and creates .FORMATTED.txt versions.
31
34
  * @param logDirectory `string` - optional, path to the log directory.
@@ -34,6 +37,7 @@ export declare function formatDebugLogFile(inputPath: string, outputPath?: strin
34
37
  */
35
38
  export declare function formatAllDebugLogs(logDirectory: string): void;
36
39
  /**
40
+ * @deprecated
37
41
  * reduce metadata to two entries, then return stringified `logObj`
38
42
  * @param logObj {@link ILogObj}
39
43
  * @returns `string`
@@ -71,6 +71,7 @@ function getSourceString(fileName, func, funcInfo, startLine, endLine) {
71
71
  return `[${fileName}.${funcName}(${(0, typeValidation_1.isNonEmptyString)(funcInfo) ? ` ${funcInfo} ` : ''})${lineNumberText}]`;
72
72
  }
73
73
  /**
74
+ * @deprecated
74
75
  * Auto-formats debug logs at the end of application execution.
75
76
  * Call this function when your main application is finishing.
76
77
  * @param filePaths `string[]` - optional, specific file paths to format.
@@ -99,6 +100,7 @@ function autoFormatLogsOnExit(filePaths) {
99
100
  }
100
101
  }
101
102
  /**
103
+ * @deprecated
102
104
  * Formats a debug log file from JSON format to a more readable text format.
103
105
  * Removes the numeric keys and properly handles escape sequences.
104
106
  * @param inputPath `string` - path to the input log file (e.g., DEBUG.txt)
@@ -125,6 +127,7 @@ function formatDebugLogFile(inputPath, outputPath) {
125
127
  }
126
128
  }
127
129
  /**
130
+ * @deprecated
128
131
  * Formats the content of a debug log file from JSON objects to readable text.
129
132
  * @param content `string` - the raw content of the log file
130
133
  * @returns `string` - the formatted content
@@ -179,6 +182,7 @@ function formatLogContent(content) {
179
182
  return formattedLines.join('\n');
180
183
  }
181
184
  /**
185
+ * @deprecated
182
186
  * Formats a single log entry object into readable text.
183
187
  * @param logObj `Record<string, any>` - the parsed log object
184
188
  * @returns `string` - the formatted log entry
@@ -209,20 +213,7 @@ function formatSingleLogEntry(logObj) {
209
213
  return lines.join(''); // lines.join('\n');
210
214
  }
211
215
  /**
212
- * Unescapes a string by replacing escape sequences with their actual characters.
213
- * @param s `string` - the string with escape sequences
214
- * @returns `string` - the unescaped string
215
- */
216
- function unescapeString(s) {
217
- return String(s) // coerce passed value to string
218
- .replace(/\\n/g, '\n') // Replace \n with actual newlines
219
- .replace(/\\t/g, '\t') // Replace \t with actual tabs
220
- .replace(/\\r/g, '\r') // Replace \r with carriage returns
221
- .replace(/\\"/g, '"') // Replace \" with actual quotes
222
- .replace(/\\\\/g, '\\') // Replace \\ with single backslash
223
- .replace(/\\'/g, "'"); // Replace \' with actual single quotes
224
- }
225
- /**
216
+ * @deprecated
226
217
  * Formats all debug log files in the log directory.
227
218
  * Looks for .txt files and creates .FORMATTED.txt versions.
228
219
  * @param logDirectory `string` - optional, path to the log directory.
@@ -259,6 +250,7 @@ function formatAllDebugLogs(logDirectory) {
259
250
  }
260
251
  }
261
252
  /**
253
+ * @deprecated
262
254
  * reduce metadata to two entries, then return stringified `logObj`
263
255
  * @param logObj {@link ILogObj}
264
256
  * @returns `string`
@@ -279,3 +271,17 @@ function formatLogObj(logObj) {
279
271
  }
280
272
  return JSON.stringify(logObj, null, 4) + "\n";
281
273
  }
274
+ /**
275
+ * Unescapes a string by replacing escape sequences with their actual characters.
276
+ * @param s `string` - the string with escape sequences
277
+ * @returns `string` - the unescaped string
278
+ */
279
+ function unescapeString(s) {
280
+ return String(s) // coerce passed value to string
281
+ .replace(/\\n/g, '\n') // Replace \n with actual newlines
282
+ .replace(/\\t/g, '\t') // Replace \t with actual tabs
283
+ .replace(/\\r/g, '\r') // Replace \r with carriage returns
284
+ .replace(/\\"/g, '"') // Replace \" with actual quotes
285
+ .replace(/\\\\/g, '\\') // Replace \\ with single backslash
286
+ .replace(/\\'/g, "'"); // Replace \' with actual single quotes
287
+ }
@@ -1,4 +1,4 @@
1
- import { DEP_StringCaseOptions, DEP_StringStripOptions, DEP_CleanStringOptions, DEP_StringPadOptions } from "../regex";
1
+ import { StringCleanOptions } from "../regex";
2
2
  import { DirectoryFileOptions, FileData, FileExtension } from "./types/Io";
3
3
  import { DelimiterCharacterEnum } from "./types";
4
4
  /** checks if `pathString (value)` points to an existing directory */
@@ -47,7 +47,7 @@ export declare function readFileToArraySync(filePath: string, separator?: string
47
47
  * @param expectedExtension `string | `{@link FileExtension}
48
48
  * @returns **`validatedFilePath`** `string`
49
49
  */
50
- export declare function coerceFileExtension(filePath: string, expectedExtension: string | FileExtension): string;
50
+ export declare function coerceFileExtension(filePath: string, expectedExtension: FileExtension): string;
51
51
  /**
52
52
  * - {@link getDirectoryFiles}
53
53
  * @param arg1 `Array<`{@link FileData}` | string> | string`
@@ -95,7 +95,7 @@ export declare function getCsvRows(arg1: FileData | string): Promise<Record<stri
95
95
  * @param valueColumn `string` - the column name whose contents will be used as values in the dictionary.
96
96
  * @returns **`dict`** `Record<string, string>`
97
97
  */
98
- export declare function getOneToOneDictionary(arg1: string | Record<string, any>[] | FileData, keyColumn: string, valueColumn: string, keyOptions?: DEP_CleanStringOptions, valueOptions?: DEP_CleanStringOptions, requireIncludeAllRows?: boolean): Promise<Record<string, string>>;
98
+ export declare function getOneToOneDictionary(arg1: string | Record<string, any>[] | FileData, keyColumn: string, valueColumn: string, keyOptions?: StringCleanOptions, valueOptions?: StringCleanOptions, requireIncludeAllRows?: boolean): Promise<Record<string, string>>;
99
99
  /**
100
100
  * @param arg1 `string | FileData | Record<string, any>[]` - the `filePath` to a CSV file or an array of rows.
101
101
  * @param columnName `string` - the column name whose values will be returned.
@@ -159,129 +159,12 @@ export declare function getDirectoryFiles(dir: string, options: DirectoryFileOpt
159
159
  * @param dataSource `string | FileData | Record<string, any>[]`
160
160
  * @param keyColumn `string`
161
161
  * @param valueColumn `string`
162
- * @param keyOptions {@link DEP_CleanStringOptions} `(optional)`
163
- * @param valueOptions {@link DEP_CleanStringOptions}`(optional)`
164
- * @param sheetName `string`
162
+ * @param keyOptions {@link StringCleanOptions} `(optional)`
163
+ * @param valueOptions {@link StringCleanOptions} `(optional)`
164
+ * @param sheetName `string` `(optional)`
165
165
  * @returns **`dict`** `Promise<Record<string, string[]>>`
166
166
  */
167
- export declare function getOneToManyDictionary(dataSource: string | FileData | Record<string, any>[], keyColumn: string, valueColumn: string, keyOptions?: DEP_CleanStringOptions, valueOptions?: DEP_CleanStringOptions, sheetName?: string): Promise<Record<string, string[]>>;
168
- /**
169
- * @deprecated `use `{@link getOneToManyDictionary}
170
- * @param filePath `string`
171
- * @param sheetName `string`
172
- * @param keyColumn `string`
173
- * @param valueColumn `string`
174
- * @param options - {@link ParseOneToManyOptions}
175
- * = `{ keyStripOptions`?: {@link DEP_StringStripOptions}, `valueStripOptions`?: {@link DEP_StringStripOptions}, keyCaseOptions`?: {@link StringCaseOptions}, `valueCaseOptions`?: {@link StringCaseOptions}, `keyPadOptions`?: {@link StringPadOptions}, `valuePadOptions`?: {@link StringPadOptions} `}`
176
- * - {@link DEP_StringStripOptions} = `{ char`: `string`, `escape`?: `boolean`, `stripLeftCondition`?: `(s: string, ...args: any[]) => boolean`, `leftArgs`?: `any[]`, `stripRightCondition`?: `(s: string, ...args: any[]) => boolean`, `rightArgs`?: `any[] }`
177
- * - {@link DEP_StringCaseOptions} = `{ toUpper`?: `boolean`, `toLower`?: `boolean`, `toTitle`?: `boolean }`
178
- * - {@link StringPadOptions} = `{ padLength`: `number`, `padChar`?: `string`, `padLeft`?: `boolean`, `padRight`?: `boolean }`
179
- * @returns **`dict`** `Record<string, Array<string>>` — key-value pairs where key is from `keyColumn` and value is an array of values from `valueColumn`
180
- */
181
- export declare function parseExcelForOneToMany(filePath: string, sheetName: string, keyColumn: string, valueColumn: string, options?: {
182
- keyStripOptions?: DEP_StringStripOptions;
183
- valueStripOptions?: DEP_StringStripOptions;
184
- keyCaseOptions?: DEP_StringCaseOptions;
185
- valueCaseOptions?: DEP_StringCaseOptions;
186
- keyPadOptions?: DEP_StringPadOptions;
187
- valuePadOptions?: DEP_StringPadOptions;
188
- }): Record<string, Array<string>>;
189
- /**
190
- * @deprecated -> use {@link getOneToManyDictionary}
191
- * @param filePath `string`
192
- * @param keyColumn `string`
193
- * @param valueColumn `string`
194
- * @param delimiter {@link DelimiterCharacters} | `string`
195
- * @param options {@link ParseOneToManyOptions}
196
- * = `{ keyCaseOptions`?: {@link DEP_StringCaseOptions}, `valueCaseOptions`?: {@link DEP_StringCaseOptions}, `keyPadOptions`?: {@link StringPadOptions}, `valuePadOptions`?: {@link StringPadOptions} `}`
197
- * - {@link DEP_StringCaseOptions} = `{ toUpper`?: `boolean`, `toLower`?: `boolean`, `toTitle`?: `boolean }`
198
- * - {@link StringPadOptions} = `{ padLength`: `number`, `padChar`?: `string`, `padLeft`?: `boolean`, `padRight`?: `boolean }`
199
- * @returns `Record<string, Array<string>>` - key-value pairs where key is from `keyColumn` and value is an array of values from `valueColumn`
200
- */
201
- export declare function parseCsvForOneToMany(filePath: string, keyColumn: string, valueColumn: string, delimiter?: DelimiterCharacterEnum | string, options?: {
202
- keyStripOptions?: DEP_StringStripOptions;
203
- valueStripOptions?: DEP_StringStripOptions;
204
- keyCaseOptions?: DEP_StringCaseOptions;
205
- valueCaseOptions?: DEP_StringCaseOptions;
206
- keyPadOptions?: DEP_StringPadOptions;
207
- valuePadOptions?: DEP_StringPadOptions;
208
- }): Record<string, Array<string>>;
209
- export interface CsvValidationOptions {
210
- allowEmptyRows?: boolean;
211
- allowInconsistentColumns?: boolean;
212
- maxRowsToCheck?: number;
213
- }
214
- /**
215
- * @notimplemented
216
- * @TODO
217
- * @param arg1
218
- * @param requiredHeaders
219
- * @param options
220
- * @returns
221
- */
222
- export declare function isValidCsv(arg1: string | FileData | Record<string, any>[], requiredHeaders?: string[], options?: CsvValidationOptions): Promise<boolean>;
223
- /**
224
- * @problem has trouble handling case where column value contains a single double quote;
225
- * e.g. when it's used as the inches unit after a number
226
- *
227
- * `sync`
228
- * @param filePath `string` - must be a string to an existing file, otherwise return `false`.
229
- * @param requiredHeaders `string[]` - `optional` array of headers that must be present in the CSV file.
230
- * - If provided, the function checks if all required headers are present in the CSV header row
231
- * @param options `object` - optional configuration
232
- * - `allowEmptyRows`: `boolean` - if true, allows rows with all empty fields (default: true)
233
- * - `allowInconsistentColumns`: `boolean` - if true, allows rows with different column counts (default: false)
234
- * - `maxRowsToCheck`: `number` - maximum number of rows to validate (default: all rows)
235
- * @returns **`isValidCsv`** `boolean`
236
- * - **`true`** `if` the CSV file at `filePath` is valid (proper structure and formatting),
237
- * - **`false`** `otherwise`.
238
- */
239
- export declare function isValidCsvSync(filePath: string, requiredHeaders?: string[], options?: CsvValidationOptions): boolean;
240
- /**
241
- * Analyzes a CSV file and returns detailed validation information
242
- * @param filePath `string` - path to the CSV file
243
- * @param options `object` - validation options
244
- * @returns **`analysis`** `object` - detailed analysis of the CSV file
245
- */
246
- export declare function analyzeCsv(filePath: string, options?: {
247
- sampleSize?: number;
248
- checkEncoding?: boolean;
249
- detectDelimiter?: boolean;
250
- }): {
251
- isValid: boolean;
252
- issues: string[];
253
- warnings: string[];
254
- stats: {
255
- totalRows: number;
256
- headerCount: number;
257
- maxRowLength: number;
258
- minRowLength: number;
259
- emptyRows: number;
260
- encoding: string | null;
261
- detectedDelimiter: string | null;
262
- };
263
- headers: string[];
264
- };
265
- /**
266
- * Attempts to repair common CSV formatting issues
267
- * @param filePath `string` - path to the CSV file to repair
268
- * @param outputPath `string` - path where the repaired CSV will be saved
269
- * @param options `object` - repair options
270
- * @returns **`repairResult`** `object` - result of the repair operation
271
- */
272
- export declare function repairCsv(filePath: string, outputPath: string, options?: {
273
- fixQuoting?: boolean;
274
- removeEmptyRows?: boolean;
275
- standardizeLineEndings?: boolean;
276
- fillMissingColumns?: boolean;
277
- fillValue?: string;
278
- }): {
279
- success: boolean;
280
- repairsMade: string[];
281
- errors: string[];
282
- };
283
- /** paths to folders or files */
284
- export declare function validatePath(...paths: string[]): Promise<void>;
167
+ export declare function getOneToManyDictionary(dataSource: string | FileData | Record<string, any>[], keyColumn: string, valueColumn: string, keyOptions?: StringCleanOptions, valueOptions?: StringCleanOptions, sheetName?: string): Promise<Record<string, string[]>>;
285
168
  /**
286
169
  * @param rowSource `string | Record<string, any>[]`
287
170
  * @param targetColumn `string`