@rowengine/common 1.1.17 → 1.1.18
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/build/utils/gc.d.ts +3 -2
- package/build/utils/gc.js +15 -1
- package/package.json +1 -1
package/build/utils/gc.d.ts
CHANGED
|
@@ -10,9 +10,10 @@ export declare const getTileFromProjectInGCS: (projectId: string, coordinates: {
|
|
|
10
10
|
export declare const getFileFromProjectInGCS: (projectId: string, fileName: string) => Promise<import("@google-cloud/storage").File | null>;
|
|
11
11
|
export declare const getFileFromProjectFieldInGCS: (projectId: string, fieldId: string, fileName: string) => Promise<import("@google-cloud/storage").File | null>;
|
|
12
12
|
export declare const deleteProjectFromGCS: (projectId: string) => Promise<void>;
|
|
13
|
-
export interface
|
|
13
|
+
export interface File {
|
|
14
14
|
localFilePath: string;
|
|
15
15
|
gcsPath: string;
|
|
16
16
|
}
|
|
17
|
-
export declare const uploadFilesToProjectInGCS: (projectId: string, files:
|
|
17
|
+
export declare const uploadFilesToProjectInGCS: (projectId: string, files: File[]) => Promise<void>;
|
|
18
|
+
export declare const downloadFilesFromProjectInGCS: (projectId: string, files: File[]) => Promise<string[]>;
|
|
18
19
|
export declare const getCompanyLogo: (companyId: string) => Promise<import("@google-cloud/storage").File | null>;
|
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.getCompanyLogo = exports.uploadFilesToProjectInGCS = exports.deleteProjectFromGCS = exports.getFileFromProjectFieldInGCS = exports.getFileFromProjectInGCS = exports.getTileFromProjectInGCS = exports.downloadProjectFileFromGCS = exports.getFilesFromGCSFolder = void 0;
|
|
15
|
+
exports.getCompanyLogo = exports.downloadFilesFromProjectInGCS = exports.uploadFilesToProjectInGCS = exports.deleteProjectFromGCS = exports.getFileFromProjectFieldInGCS = exports.getFileFromProjectInGCS = exports.getTileFromProjectInGCS = exports.downloadProjectFileFromGCS = exports.getFilesFromGCSFolder = void 0;
|
|
16
16
|
exports.uploadFileToGCS = uploadFileToGCS;
|
|
17
17
|
exports.uploadFolderToGCS = uploadFolderToGCS;
|
|
18
18
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
@@ -125,6 +125,20 @@ const uploadFilesToProjectInGCS = (projectId, files) => __awaiter(void 0, void 0
|
|
|
125
125
|
yield Promise.all(files.map(({ localFilePath, gcsPath }) => limit(() => uploadFileToGCS(localFilePath, `projects/${projectId}/${gcsPath}`, fs_1.default.statSync(localFilePath).size))));
|
|
126
126
|
});
|
|
127
127
|
exports.uploadFilesToProjectInGCS = uploadFilesToProjectInGCS;
|
|
128
|
+
const downloadFilesFromProjectInGCS = (projectId, files) => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
+
const limit = (0, p_limit_1.default)(UPLOAD_CONCURRENCY);
|
|
130
|
+
const downloadedFilePaths = yield Promise.all(files.map(({ localFilePath, gcsPath }) => limit(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
|
+
const gcFilePath = `projects/${projectId}/${gcsPath}`;
|
|
132
|
+
const gcFile = gc_storage_1.default.file(gcFilePath);
|
|
133
|
+
const [fileExists] = yield gcFile.exists();
|
|
134
|
+
if (!fileExists)
|
|
135
|
+
return null;
|
|
136
|
+
yield gcFile.download({ destination: localFilePath });
|
|
137
|
+
return localFilePath;
|
|
138
|
+
}))));
|
|
139
|
+
return downloadedFilePaths.filter((filePath) => filePath !== null);
|
|
140
|
+
});
|
|
141
|
+
exports.downloadFilesFromProjectInGCS = downloadFilesFromProjectInGCS;
|
|
128
142
|
const getCompanyLogo = (companyId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
143
|
const logoPath = `companies/${companyId}.png`;
|
|
130
144
|
const gcFile = gc_storage_1.default.file(logoPath);
|