@rowengine/common 1.1.10 → 1.1.11
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 +6 -0
- package/build/utils/gc.js +20 -1
- package/package.json +1 -1
package/build/utils/gc.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export declare function uploadFolderToGCS(folderPath: string, gcsPath: string): Promise<void>;
|
|
2
2
|
export declare const getFilesFromGCSFolder: (gcsFolderPath: string) => Promise<string[]>;
|
|
3
3
|
export declare const downloadProjectFileFromGCS: (projectId: string, fileName: string, destinationPath: string) => Promise<string | null>;
|
|
4
|
+
export declare const getTileFromProjectInGCS: (projectId: string, coordinates: {
|
|
5
|
+
z: number;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}) => Promise<import("@google-cloud/storage").File | null>;
|
|
9
|
+
export declare const getFileFromProjectFieldInGCS: (projectId: string, fieldFolder: string, fileName: 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.downloadProjectFileFromGCS = exports.getFilesFromGCSFolder = void 0;
|
|
15
|
+
exports.getFileFromProjectFieldInGCS = exports.getTileFromProjectInGCS = exports.downloadProjectFileFromGCS = exports.getFilesFromGCSFolder = void 0;
|
|
16
16
|
exports.uploadFolderToGCS = uploadFolderToGCS;
|
|
17
17
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
18
18
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -84,3 +84,22 @@ const downloadProjectFileFromGCS = (projectId, fileName, destinationPath) => __a
|
|
|
84
84
|
return destinationPath;
|
|
85
85
|
});
|
|
86
86
|
exports.downloadProjectFileFromGCS = downloadProjectFileFromGCS;
|
|
87
|
+
const getTileFromProjectInGCS = (projectId, coordinates) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const { z, x, y } = coordinates;
|
|
89
|
+
const tilePath = `projects/${projectId}/tiles/${z}/${x}/${y}.png`;
|
|
90
|
+
const gcFile = gc_storage_1.default.file(tilePath);
|
|
91
|
+
const [fileExists] = yield gcFile.exists();
|
|
92
|
+
if (!fileExists)
|
|
93
|
+
return null;
|
|
94
|
+
return gcFile;
|
|
95
|
+
});
|
|
96
|
+
exports.getTileFromProjectInGCS = getTileFromProjectInGCS;
|
|
97
|
+
const getFileFromProjectFieldInGCS = (projectId, fieldFolder, fileName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
const filePath = `projects/${projectId}/fields/${fieldFolder}/${fileName}`;
|
|
99
|
+
const gcFile = gc_storage_1.default.file(filePath);
|
|
100
|
+
const [fileExists] = yield gcFile.exists();
|
|
101
|
+
if (!fileExists)
|
|
102
|
+
return null;
|
|
103
|
+
return gcFile;
|
|
104
|
+
});
|
|
105
|
+
exports.getFileFromProjectFieldInGCS = getFileFromProjectFieldInGCS;
|