@punks/backend-core 0.0.15 → 0.0.17

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.
@@ -0,0 +1,9 @@
1
+ export declare const csvParseRaw: (rows: string[], separator: string) => string[][];
2
+ export interface CsvColumnDefinition<T> {
3
+ name: string;
4
+ value: (item: T) => any;
5
+ }
6
+ export type CsvBuildOptions = {
7
+ delimiter?: string;
8
+ };
9
+ export declare const csvBuild: <T>(data: T[], columns: CsvColumnDefinition<T>[], options?: CsvBuildOptions) => string;
@@ -1,4 +1,5 @@
1
1
  export * from "./array";
2
+ export { CsvColumnDefinition as ColumnDefinition, CsvBuildOptions, csvBuild, csvParseRaw, } from "./csv";
2
3
  export { getDirectoryFilePaths } from "./files";
3
4
  export { joinPath, splitPath, ensureDirectory, getDirectoryPath } from "./paths";
4
5
  export * from "./strings";
@@ -6,3 +7,4 @@ export * from "./objects";
6
7
  export * from "./text";
7
8
  export * from "./threading";
8
9
  export * from "./uid";
10
+ export { ExcelSheetDefinition, ExcelKeyTransform, ExcelColumnDefinition as ExcelRowBuilder, ExcelParseOptions, excelBuild, excelParse, } from "./xls";
@@ -5,3 +5,5 @@ export declare const camelToSnakeCase: (str: string) => string;
5
5
  export declare const camelToKebabCase: (str: string) => string;
6
6
  export declare const toCamelCase: (str: string) => string;
7
7
  export declare const toTitleCase: (str: string) => string;
8
+ export declare const ensureTailingSlash: (value: string) => string;
9
+ export declare const ensureStartSlash: (value: string) => string;
@@ -0,0 +1,24 @@
1
+ export interface ExcelColumnDefinition<T> {
2
+ value: (row: T) => any;
3
+ header: string;
4
+ headerSize?: number;
5
+ }
6
+ export type ExcelSheetDefinition<T> = {
7
+ sheetName: string;
8
+ data: T[];
9
+ columns: ExcelColumnDefinition<T>[];
10
+ };
11
+ export declare const excelBuild: <T>(...sheets: ExcelSheetDefinition<T>[]) => ArrayBuffer;
12
+ export declare const parseExcelRaw: (file: string | ArrayBuffer) => {
13
+ name: string;
14
+ data: any[][];
15
+ }[];
16
+ export declare enum ExcelKeyTransform {
17
+ Lower = "lower",
18
+ Upper = "upper"
19
+ }
20
+ export type ExcelParseOptions = {
21
+ keysTransform?: ExcelKeyTransform;
22
+ sheetIndex?: number;
23
+ };
24
+ export declare const excelParse: (file: string | ArrayBuffer, options?: ExcelParseOptions) => any[];
package/dist/index.d.ts CHANGED
@@ -61,6 +61,16 @@ declare const distinctElements: <T>(values: T[], comparer: (value: T) => any) =>
61
61
  declare const jsonDistinct: <T>(values: T[]) => T[];
62
62
  declare const iterate: <T>(values: T[], action: (item: T, next?: T | undefined, prev?: T | undefined) => void) => void;
63
63
 
64
+ declare const csvParseRaw: (rows: string[], separator: string) => string[][];
65
+ interface CsvColumnDefinition<T> {
66
+ name: string;
67
+ value: (item: T) => any;
68
+ }
69
+ type CsvBuildOptions = {
70
+ delimiter?: string;
71
+ };
72
+ declare const csvBuild: <T>(data: T[], columns: CsvColumnDefinition<T>[], options?: CsvBuildOptions) => string;
73
+
64
74
  declare const getDirectoryFilePaths: (directoryPath: string, options?: {
65
75
  recursive?: boolean;
66
76
  }) => Promise<string[]>;
@@ -77,6 +87,8 @@ declare const camelToSnakeCase: (str: string) => string;
77
87
  declare const camelToKebabCase: (str: string) => string;
78
88
  declare const toCamelCase: (str: string) => string;
79
89
  declare const toTitleCase: (str: string) => string;
90
+ declare const ensureTailingSlash: (value: string) => string;
91
+ declare const ensureStartSlash: (value: string) => string;
80
92
 
81
93
  declare const removeUndefinedProps: <T extends Record<string, any>>(obj: T, options?: {
82
94
  recursive?: boolean;
@@ -89,4 +101,25 @@ declare function sleep(ms: number): Promise<unknown>;
89
101
 
90
102
  declare const newUuid: () => string;
91
103
 
92
- export { Dict, ILogger, ILoggerProvider, IResolveServiceOptions, IServiceLocator, Log, LogLevel, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, distinct, distinctElements, ensureDirectory, first, flatten, getDirectoryFilePaths, getDirectoryPath, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, last, newUuid, notNull, notUndefined, pluralize, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, toCamelCase, toDict, toMap, toTitleCase, trim, trimEnd, trimStart };
104
+ interface ExcelColumnDefinition<T> {
105
+ value: (row: T) => any;
106
+ header: string;
107
+ headerSize?: number;
108
+ }
109
+ type ExcelSheetDefinition<T> = {
110
+ sheetName: string;
111
+ data: T[];
112
+ columns: ExcelColumnDefinition<T>[];
113
+ };
114
+ declare const excelBuild: <T>(...sheets: ExcelSheetDefinition<T>[]) => ArrayBuffer;
115
+ declare enum ExcelKeyTransform {
116
+ Lower = "lower",
117
+ Upper = "upper"
118
+ }
119
+ type ExcelParseOptions = {
120
+ keysTransform?: ExcelKeyTransform;
121
+ sheetIndex?: number;
122
+ };
123
+ declare const excelParse: (file: string | ArrayBuffer, options?: ExcelParseOptions) => any[];
124
+
125
+ export { CsvColumnDefinition as ColumnDefinition, CsvBuildOptions, Dict, ExcelKeyTransform, ExcelParseOptions, ExcelColumnDefinition as ExcelRowBuilder, ExcelSheetDefinition, ILogger, ILoggerProvider, IResolveServiceOptions, IServiceLocator, Log, LogLevel, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParseRaw, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, last, newUuid, notNull, notUndefined, pluralize, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, toCamelCase, toDict, toMap, toTitleCase, trim, trimEnd, trimStart };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punks/backend-core",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "WebPunks Backend Core",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -28,6 +28,7 @@
28
28
  "@rollup/plugin-typescript": "^11.0.0",
29
29
  "@types/jest": "^29.5.2",
30
30
  "jest": "^29.4.3",
31
+ "node-xlsx": "^0.23.0",
31
32
  "reflect-metadata": "^0.1.13",
32
33
  "rimraf": "^5.0.1",
33
34
  "rollup": "^2.60.0",