@riocrypto/common-server 1.0.1231 → 1.0.1233

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.
@@ -3,7 +3,7 @@ declare class cloudVisionAPIClient {
3
3
  private env;
4
4
  googleAuth: any;
5
5
  constructor(env: RioEnv);
6
- getDataFromPDF(bucketName: string, fileName: string, outputPrefix: string): Promise<void>;
6
+ getDataFromPDF(bucketName: string, fileName: string, outputPrefix: string): Promise<any>;
7
7
  }
8
8
  export declare const googleVisionAPIClient: cloudVisionAPIClient;
9
9
  export {};
@@ -51,8 +51,8 @@ class cloudVisionAPIClient {
51
51
  //@ts-ignore
52
52
  const [operation] = yield client.asyncBatchAnnotateFiles(request);
53
53
  const [filesResponse] = yield operation.promise();
54
- const destinationUri = filesResponse.responses[0].outputConfig.gcsDestination.uri;
55
- console.log("Json saved to: " + destinationUri);
54
+ const destinationUri = filesResponse.responses[0].outputConfig.gcsDestination;
55
+ return destinationUri;
56
56
  });
57
57
  }
58
58
  }
@@ -3,5 +3,6 @@ export declare class GCloudStorageClient {
3
3
  _bucket: Bucket;
4
4
  constructor(bucket: string);
5
5
  get bucket(): Bucket;
6
+ downloadJsonFile(filename: string): Promise<any>;
6
7
  }
7
8
  export declare const buildGCloudStorageClient: () => Promise<GCloudStorageClient>;
@@ -22,6 +22,31 @@ class GCloudStorageClient {
22
22
  get bucket() {
23
23
  return this._bucket;
24
24
  }
25
+ downloadJsonFile(filename) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const file = this._bucket.file(filename);
28
+ return new Promise((resolve, reject) => {
29
+ let data = "";
30
+ file
31
+ .createReadStream()
32
+ .on("data", (chunk) => {
33
+ data += chunk.toString();
34
+ })
35
+ .on("end", () => {
36
+ try {
37
+ const jsonData = JSON.parse(data);
38
+ resolve(jsonData);
39
+ }
40
+ catch (error) {
41
+ reject(new Error(`Error parsing JSON file: ${error}`));
42
+ }
43
+ })
44
+ .on("error", (err) => {
45
+ reject(new Error(`Error reading file: ${err.message}`));
46
+ });
47
+ });
48
+ });
49
+ }
25
50
  }
26
51
  exports.GCloudStorageClient = GCloudStorageClient;
27
52
  const buildGCloudStorageClient = () => __awaiter(void 0, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1231",
3
+ "version": "1.0.1233",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",