@punks/backend-core 0.0.14 → 0.0.16
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.
- package/dist/cjs/index.js +28049 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/csv.d.ts +9 -0
- package/dist/cjs/types/utils/index.d.ts +2 -0
- package/dist/cjs/types/utils/objects.d.ts +1 -0
- package/dist/cjs/types/utils/xls.d.ts +24 -0
- package/dist/esm/index.js +28043 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/csv.d.ts +9 -0
- package/dist/esm/types/utils/index.d.ts +2 -0
- package/dist/esm/types/utils/objects.d.ts +1 -0
- package/dist/esm/types/utils/xls.d.ts +24 -0
- package/dist/index.d.ts +33 -1
- package/package.json +3 -2
|
@@ -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";
|
|
@@ -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[]>;
|
|
@@ -81,6 +91,7 @@ declare const toTitleCase: (str: string) => string;
|
|
|
81
91
|
declare const removeUndefinedProps: <T extends Record<string, any>>(obj: T, options?: {
|
|
82
92
|
recursive?: boolean;
|
|
83
93
|
}) => T;
|
|
94
|
+
declare const isNullOrUndefined: (value: any) => boolean;
|
|
84
95
|
|
|
85
96
|
declare const pluralize: (word: string) => string;
|
|
86
97
|
|
|
@@ -88,4 +99,25 @@ declare function sleep(ms: number): Promise<unknown>;
|
|
|
88
99
|
|
|
89
100
|
declare const newUuid: () => string;
|
|
90
101
|
|
|
91
|
-
|
|
102
|
+
interface ExcelColumnDefinition<T> {
|
|
103
|
+
value: (row: T) => any;
|
|
104
|
+
header: string;
|
|
105
|
+
headerSize?: number;
|
|
106
|
+
}
|
|
107
|
+
type ExcelSheetDefinition<T> = {
|
|
108
|
+
sheetName: string;
|
|
109
|
+
data: T[];
|
|
110
|
+
columns: ExcelColumnDefinition<T>[];
|
|
111
|
+
};
|
|
112
|
+
declare const excelBuild: <T>(...sheets: ExcelSheetDefinition<T>[]) => ArrayBuffer;
|
|
113
|
+
declare enum ExcelKeyTransform {
|
|
114
|
+
Lower = "lower",
|
|
115
|
+
Upper = "upper"
|
|
116
|
+
}
|
|
117
|
+
type ExcelParseOptions = {
|
|
118
|
+
keysTransform?: ExcelKeyTransform;
|
|
119
|
+
sheetIndex?: number;
|
|
120
|
+
};
|
|
121
|
+
declare const excelParse: (file: string | ArrayBuffer, options?: ExcelParseOptions) => any[];
|
|
122
|
+
|
|
123
|
+
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, 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.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "WebPunks Backend Core",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
11
|
+
"node": ">=18"
|
|
12
12
|
},
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"scripts": {
|
|
@@ -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",
|