@8ms/helpers 2.4.20 → 2.4.22

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.
@@ -4,7 +4,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  * Load data into a given table using Google Cloud Storage.
5
5
  */
6
6
  const loadData = async ({ file, googleCloudBigqueryClient, googleCloudStorageClient, table }) => {
7
- if (await googleCloudBigqueryClient.tableExists(table.datasetId, table.tableId)) await googleCloudBigqueryClient.client.dataset(table.datasetId).table(table.tableId).load(googleCloudStorageClient.client.bucket(file.bucket).file(file.key), file.metadata);
7
+ if (await googleCloudBigqueryClient.tableExists(table.datasetId, table.tableId)) await googleCloudBigqueryClient.client.dataset(table.datasetId, { location: table?.region }).table(table.tableId).load(googleCloudStorageClient.client.bucket(file.bucket).file(file.key), {
8
+ ...file?.metadata ?? {},
9
+ location: file?.region
10
+ });
8
11
  };
9
12
  //#endregion
10
13
  exports.loadData = loadData;
@@ -7,10 +7,12 @@ type LoadData = {
7
7
  file: {
8
8
  bucket: string;
9
9
  key: string;
10
- metadata: object;
10
+ metadata?: object;
11
+ region?: string;
11
12
  };
12
13
  table: {
13
14
  datasetId: string;
15
+ region?: string;
14
16
  tableId: string;
15
17
  };
16
18
  };
@@ -7,10 +7,12 @@ type LoadData = {
7
7
  file: {
8
8
  bucket: string;
9
9
  key: string;
10
- metadata: object;
10
+ metadata?: object;
11
+ region?: string;
11
12
  };
12
13
  table: {
13
14
  datasetId: string;
15
+ region?: string;
14
16
  tableId: string;
15
17
  };
16
18
  };
@@ -3,7 +3,10 @@
3
3
  * Load data into a given table using Google Cloud Storage.
4
4
  */
5
5
  const loadData = async ({ file, googleCloudBigqueryClient, googleCloudStorageClient, table }) => {
6
- if (await googleCloudBigqueryClient.tableExists(table.datasetId, table.tableId)) await googleCloudBigqueryClient.client.dataset(table.datasetId).table(table.tableId).load(googleCloudStorageClient.client.bucket(file.bucket).file(file.key), file.metadata);
6
+ if (await googleCloudBigqueryClient.tableExists(table.datasetId, table.tableId)) await googleCloudBigqueryClient.client.dataset(table.datasetId, { location: table?.region }).table(table.tableId).load(googleCloudStorageClient.client.bucket(file.bucket).file(file.key), {
7
+ ...file?.metadata ?? {},
8
+ location: file?.region
9
+ });
7
10
  };
8
11
  //#endregion
9
12
  export { loadData };
@@ -4,17 +4,15 @@ const require_file_server_createDirectory = require("../../file/server/createDir
4
4
  require("../../file/server/index.cjs");
5
5
  let ky = require("ky");
6
6
  ky = require_runtime.__toESM(ky);
7
- let fs_extra = require("fs-extra");
8
7
  let stream = require("stream");
8
+ let fs = require("fs");
9
9
  //#region src/url/server/writeUrlContents.ts
10
10
  /**
11
11
  * Downloads a given URL's contents to a local file.
12
- *
13
- * Requires fs-extra
14
12
  */
15
13
  const writeUrlContents = async (filePath, url) => {
16
14
  await require_file_server_createDirectory.createDirectory(filePath);
17
- const writer = (0, fs_extra.createWriteStream)(filePath);
15
+ const writer = (0, fs.createWriteStream)(filePath);
18
16
  const response = await ky.default.get(url);
19
17
  const stream$1 = stream.Readable.fromWeb(response.body);
20
18
  await new Promise((resolve, reject) => {
@@ -1,8 +1,6 @@
1
1
  //#region src/url/server/writeUrlContents.d.ts
2
2
  /**
3
3
  * Downloads a given URL's contents to a local file.
4
- *
5
- * Requires fs-extra
6
4
  */
7
5
  declare const writeUrlContents: (filePath: string, url: string) => Promise<void>;
8
6
  //#endregion
@@ -1,8 +1,6 @@
1
1
  //#region src/url/server/writeUrlContents.d.ts
2
2
  /**
3
3
  * Downloads a given URL's contents to a local file.
4
- *
5
- * Requires fs-extra
6
4
  */
7
5
  declare const writeUrlContents: (filePath: string, url: string) => Promise<void>;
8
6
  //#endregion
@@ -1,13 +1,11 @@
1
1
  import { createDirectory } from "../../file/server/createDirectory.mjs";
2
2
  import "../../file/server/index.mjs";
3
3
  import ky from "ky";
4
- import { createWriteStream } from "fs-extra";
5
4
  import { Readable } from "stream";
5
+ import { createWriteStream } from "fs";
6
6
  //#region src/url/server/writeUrlContents.ts
7
7
  /**
8
8
  * Downloads a given URL's contents to a local file.
9
- *
10
- * Requires fs-extra
11
9
  */
12
10
  const writeUrlContents = async (filePath, url) => {
13
11
  await createDirectory(filePath);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.4.20",
4
+ "version": "2.4.22",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"