@rowengine/common 1.1.12 → 1.1.14

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.
@@ -7,4 +7,6 @@ export declare const getTileFromProjectInGCS: (projectId: string, coordinates: {
7
7
  x: number;
8
8
  y: number;
9
9
  }) => Promise<import("@google-cloud/storage").File | null>;
10
- export declare const getFileFromProjectFieldInGCS: (projectId: string, fieldFolder: string, fileName: string) => Promise<import("@google-cloud/storage").File | null>;
10
+ export declare const getFileFromProjectInGCS: (projectId: string, fileName: string) => Promise<import("@google-cloud/storage").File | null>;
11
+ export declare const getFileFromProjectFieldInGCS: (projectId: string, fieldId: string, fileName: string) => Promise<import("@google-cloud/storage").File | null>;
12
+ export declare const deleteProjectFromGCS: (projectId: string) => Promise<void>;
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.getFileFromProjectFieldInGCS = exports.getTileFromProjectInGCS = exports.downloadProjectFileFromGCS = exports.getFilesFromGCSFolder = void 0;
15
+ 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"));
@@ -95,8 +95,17 @@ const getTileFromProjectInGCS = (projectId, coordinates) => __awaiter(void 0, vo
95
95
  return gcFile;
96
96
  });
97
97
  exports.getTileFromProjectInGCS = getTileFromProjectInGCS;
98
- const getFileFromProjectFieldInGCS = (projectId, fieldFolder, fileName) => __awaiter(void 0, void 0, void 0, function* () {
99
- const filePath = `projects/${projectId}/fields/${fieldFolder}/${fileName}`;
98
+ const getFileFromProjectInGCS = (projectId, fileName) => __awaiter(void 0, void 0, void 0, function* () {
99
+ const filePath = `projects/${projectId}/${fileName}`;
100
+ const gcFile = gc_storage_1.default.file(filePath);
101
+ const [fileExists] = yield gcFile.exists();
102
+ if (!fileExists)
103
+ return null;
104
+ return gcFile;
105
+ });
106
+ exports.getFileFromProjectInGCS = getFileFromProjectInGCS;
107
+ const getFileFromProjectFieldInGCS = (projectId, fieldId, fileName) => __awaiter(void 0, void 0, void 0, function* () {
108
+ const filePath = `projects/${projectId}/fields/${fieldId}/${fileName}`;
100
109
  const gcFile = gc_storage_1.default.file(filePath);
101
110
  const [fileExists] = yield gcFile.exists();
102
111
  if (!fileExists)
@@ -104,3 +113,10 @@ const getFileFromProjectFieldInGCS = (projectId, fieldFolder, fileName) => __awa
104
113
  return gcFile;
105
114
  });
106
115
  exports.getFileFromProjectFieldInGCS = getFileFromProjectFieldInGCS;
116
+ const deleteProjectFromGCS = (projectId) => __awaiter(void 0, void 0, void 0, function* () {
117
+ const options = {
118
+ prefix: `projects/${projectId}/`,
119
+ };
120
+ return yield gc_storage_1.default.deleteFiles(options);
121
+ });
122
+ exports.deleteProjectFromGCS = deleteProjectFromGCS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowengine/common",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "private": false,