sm-utility 2.2.14 → 2.2.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.
@@ -21,7 +21,7 @@ class ExcelParser {
21
21
  try {
22
22
  logger_1.logger.info("ExcelParser initiated", { context: data });
23
23
  const filePath = path_1.default.resolve(data.uploadFolderPath, `${data.filename}`);
24
- const sheets = node_xlsx_1.default.parse(filePath);
24
+ const sheets = node_xlsx_1.default.parse(filePath, data.options);
25
25
  const parsedResult = sheets.map((sheet) => new sheetExcelParser_1.SheetExcelParser().parse(sheet));
26
26
  await this.deleteFile(filePath);
27
27
  logger_1.logger.info("ExcelParser finished", { context: data });
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ import xlsx from 'node-xlsx';
2
3
  import { ExcelFormat, ExcelType } from "./enums";
3
4
  export interface ISpreadSheet<T> {
4
5
  name: string;
@@ -19,9 +20,11 @@ export interface IFormatStructure {
19
20
  options?: string[];
20
21
  customFormatCallback?: string;
21
22
  }
23
+ declare type parseOptions = Parameters<typeof xlsx.parse>['1'];
22
24
  export interface IExcelParserData {
23
25
  filename: string;
24
26
  uploadFolderPath: string;
27
+ options: parseOptions;
25
28
  }
26
29
  export interface IExcelSheet {
27
30
  name: string;
@@ -34,3 +37,4 @@ export declare type IWorkerSuccessResult = {
34
37
  export declare type IWorkerFailedResult = {
35
38
  error: Error;
36
39
  };
40
+ export {};
@@ -2,3 +2,4 @@ export declare function pipe(...fns: Array<Function>): any;
2
2
  export declare function randomSixDigitNumber(): number;
3
3
  export declare function timeout(ms: number): Promise<any>;
4
4
  export declare function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any>;
5
+ export declare function shortUniqueId(): string;
package/general/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeDeep = exports.timeout = exports.randomSixDigitNumber = exports.pipe = void 0;
3
+ exports.shortUniqueId = exports.mergeDeep = exports.timeout = exports.randomSixDigitNumber = exports.pipe = void 0;
4
+ const nanoid_1 = require("nanoid");
4
5
  function pipe(...fns) {
5
6
  return (x) => fns.reduce((v, f) => f(v), x);
6
7
  }
@@ -36,3 +37,9 @@ function mergeDeep(target, source) {
36
37
  return target;
37
38
  }
38
39
  exports.mergeDeep = mergeDeep;
40
+ function shortUniqueId() {
41
+ const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
42
+ const nanoid = nanoid_1.customAlphabet(alphabet, 8);
43
+ return nanoid();
44
+ }
45
+ exports.shortUniqueId = shortUniqueId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sm-utility",
3
- "version": "2.2.14",
3
+ "version": "2.2.16",
4
4
  "description": "reusable utility codes for sm projects",
5
5
  "main": "index.js",
6
6
  "types": "./index.d.ts",
@@ -30,6 +30,7 @@
30
30
  "aws-sdk": "^2.1134.0",
31
31
  "axios": "^0.23.0",
32
32
  "express-winston": "^4.1.0",
33
+ "nanoid": "^3.3.6",
33
34
  "node-xlsx": "^0.23.0",
34
35
  "redis": "^4.1.0",
35
36
  "ts-node": "^10.9.1",