@rowengine/common 1.1.5 → 1.1.7

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.
@@ -8,5 +8,6 @@ interface UploadFileToGCSResponse {
8
8
  }
9
9
  export declare const uploadFileToGCS: ({ filePath, gcsFilePath, }: UploadFileToGCS) => Promise<UploadFileToGCSResponse>;
10
10
  export declare const uploadFolderToGCS: (folderPath: string, gcsPath: string) => Promise<void>;
11
+ export declare const getFilesFromGCSFolder: (gcsFolderPath: string) => Promise<string[]>;
11
12
  export declare const downloadProjectFileFromGCS: (projectId: string, fileName: string, destinationPath: string) => Promise<string | null>;
12
13
  export {};
package/build/utils/gc.js CHANGED
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.downloadProjectFileFromGCS = exports.uploadFolderToGCS = exports.uploadFileToGCS = void 0;
15
+ exports.downloadProjectFileFromGCS = exports.getFilesFromGCSFolder = exports.uploadFolderToGCS = exports.uploadFileToGCS = void 0;
16
16
  const gc_storage_1 = __importDefault(require("./gc-storage"));
17
17
  const path_1 = __importDefault(require("path"));
18
18
  const fs_1 = __importDefault(require("fs"));
@@ -41,7 +41,7 @@ const uploadFileToGCS = ({ filePath, gcsFilePath, }) => {
41
41
  };
42
42
  exports.uploadFileToGCS = uploadFileToGCS;
43
43
  const uploadFolderToGCS = (folderPath, gcsPath) => __awaiter(void 0, void 0, void 0, function* () {
44
- const limit = (0, p_limit_1.default)(4);
44
+ const limit = (0, p_limit_1.default)(8);
45
45
  const files = fs_1.default.readdirSync(folderPath);
46
46
  let promises = [];
47
47
  for (const file of files) {
@@ -60,6 +60,16 @@ const uploadFolderToGCS = (folderPath, gcsPath) => __awaiter(void 0, void 0, voi
60
60
  const res = yield Promise.all(promises);
61
61
  });
62
62
  exports.uploadFolderToGCS = uploadFolderToGCS;
63
+ const getFilesFromGCSFolder = (gcsFolderPath) => __awaiter(void 0, void 0, void 0, function* () {
64
+ const options = {
65
+ prefix: gcsFolderPath.endsWith('/')
66
+ ? gcsFolderPath
67
+ : gcsFolderPath + '/',
68
+ };
69
+ const [files] = yield gc_storage_1.default.getFiles(options);
70
+ return files.map((file) => file.name);
71
+ });
72
+ exports.getFilesFromGCSFolder = getFilesFromGCSFolder;
63
73
  const downloadProjectFileFromGCS = (projectId, fileName, destinationPath) => __awaiter(void 0, void 0, void 0, function* () {
64
74
  const gcFilePath = `projects/${projectId}/${fileName}`;
65
75
  const gcFile = gc_storage_1.default.file(gcFilePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowengine/common",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "private": false,