@8ms/helpers 1.1.92 → 1.1.93

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.
@@ -5,6 +5,7 @@ declare type CreateTable = {
5
5
  };
6
6
  /**
7
7
  * Create a Table if it doesn't already exist.
8
+ * Returns table instance.
8
9
  */
9
10
  declare const createTable: ({ datasetId, options, tableId }: CreateTable) => Promise<void>;
10
11
  export default createTable;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const IsTableExists_1 = __importDefault(require("./IsTableExists"));
7
7
  /**
8
8
  * Create a Table if it doesn't already exist.
9
+ * Returns table instance.
9
10
  */
10
11
  const createTable = async ({ datasetId, options, tableId }) => {
11
12
  const tableExists = await (0, IsTableExists_1.default)({ datasetId, tableId });
@@ -0,0 +1,12 @@
1
+ declare type LoadData = {
2
+ bucket: string;
3
+ key: string;
4
+ datasetId: string;
5
+ tableId: string;
6
+ metadata: object;
7
+ };
8
+ /**
9
+ * Load data into a given table.
10
+ */
11
+ declare const loadData: ({ bucket, datasetId, key, metadata, tableId }: LoadData) => Promise<void>;
12
+ export default loadData;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const IsTableExists_1 = __importDefault(require("./IsTableExists"));
7
+ /**
8
+ * Load data into a given table.
9
+ */
10
+ const loadData = async ({ bucket, datasetId, key, metadata, tableId }) => {
11
+ const tableExists = await (0, IsTableExists_1.default)({ datasetId, tableId });
12
+ if (tableExists) {
13
+ await global.googleBigQueryClient.dataset(datasetId)
14
+ .table(tableId)
15
+ .load(global.googleStorageClient.bucket(bucket).file(key), metadata);
16
+ }
17
+ };
18
+ exports.default = loadData;
@@ -1,12 +1,10 @@
1
1
  declare type CopyToCloud = {
2
2
  bucket: string;
3
- data: any;
4
3
  localFile: string;
5
- key: string;
6
- [options: string]: any;
4
+ options?: object;
7
5
  };
8
6
  /**
9
7
  * Copy a local file to Google Cloud Storage.
10
8
  */
11
- export declare const copyToCloud: ({ bucket, localFile, ...options }: CopyToCloud) => Promise<any>;
9
+ export declare const copyToCloud: ({ bucket, localFile, options }: CopyToCloud) => Promise<any>;
12
10
  export default copyToCloud;
@@ -4,7 +4,7 @@ exports.copyToCloud = void 0;
4
4
  /**
5
5
  * Copy a local file to Google Cloud Storage.
6
6
  */
7
- const copyToCloud = async ({ bucket, localFile, ...options }) => {
7
+ const copyToCloud = async ({ bucket, localFile, options }) => {
8
8
  const bucketInstance = global.googleStorageClient.bucket(bucket);
9
9
  const apiResponse = bucketInstance.upload(localFile, options);
10
10
  return apiResponse;
package/package.json CHANGED
@@ -1,52 +1,52 @@
1
1
  {
2
- "name": "@8ms/helpers",
3
- "license": "UNLICENSED",
4
- "version": "1.1.92",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
8
- },
9
- "main": "index.js",
10
- "types": "index.d.ts",
11
- "scripts": {
12
- "build": "tsc",
13
- "jest": "jest --watch"
14
- },
15
- "dependencies": {
16
- "axios": "0.27.2",
17
- "crypto-js": "4.1.1",
18
- "date-fns": "2.29.3",
19
- "date-fns-tz": "1.3.7",
20
- "lodash": "4.17.21"
21
- },
22
- "devDependencies": {
23
- "@aws-sdk/client-s3": "3.178.0",
24
- "@aws-sdk/client-ses": "3.178.0",
25
- "@aws-sdk/client-sqs": "3.178.0",
26
- "@aws-sdk/client-ssm": "3.178.0",
27
- "@aws-sdk/s3-request-presigner": "3.178.0",
28
- "@babel/preset-env": "7.19.1",
29
- "@babel/preset-flow": "7.18.6",
30
- "@babel/preset-typescript": "7.18.6",
31
- "@google-cloud/bigquery": "6.0.3",
32
- "@google-cloud/storage": "6.5.2",
33
- "@graphql-codegen/cli": "2.12.1",
34
- "@graphql-codegen/typescript-graphql-request": "4.5.5",
35
- "@graphql-codegen/typescript-operations": "2.5.3",
36
- "@prisma/client": "4.3.1",
37
- "@types/jest": "29.0.3",
38
- "@types/lodash": "4.14.185",
39
- "@types/node": "18.7.21",
40
- "babel-jest": "29.0.3",
41
- "graphql": "16.6.0",
42
- "graphql-request": "5.0.0",
43
- "jest": "29.0.3",
44
- "node-fetch": "3.2.10",
45
- "numbro": "2.3.6",
46
- "prisma-query-log": "3.2.0",
47
- "timezone-mock": "1.3.4",
48
- "ts-node": "10.9.1",
49
- "tslib": "2.4.0",
50
- "typescript": "4.8.3"
51
- }
2
+ "name": "@8ms/helpers",
3
+ "license": "UNLICENSED",
4
+ "version": "1.1.93",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
8
+ },
9
+ "main": "index.js",
10
+ "types": "index.d.ts",
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "jest": "jest --watch"
14
+ },
15
+ "dependencies": {
16
+ "axios": "0.27.2",
17
+ "crypto-js": "4.1.1",
18
+ "date-fns": "2.29.3",
19
+ "date-fns-tz": "1.3.7",
20
+ "lodash": "4.17.21"
21
+ },
22
+ "devDependencies": {
23
+ "@aws-sdk/client-s3": "3.178.0",
24
+ "@aws-sdk/client-ses": "3.178.0",
25
+ "@aws-sdk/client-sqs": "3.178.0",
26
+ "@aws-sdk/client-ssm": "3.178.0",
27
+ "@aws-sdk/s3-request-presigner": "3.178.0",
28
+ "@babel/preset-env": "7.19.1",
29
+ "@babel/preset-flow": "7.18.6",
30
+ "@babel/preset-typescript": "7.18.6",
31
+ "@google-cloud/bigquery": "6.0.3",
32
+ "@google-cloud/storage": "6.5.2",
33
+ "@graphql-codegen/cli": "2.12.1",
34
+ "@graphql-codegen/typescript-graphql-request": "4.5.5",
35
+ "@graphql-codegen/typescript-operations": "2.5.3",
36
+ "@prisma/client": "4.3.1",
37
+ "@types/jest": "29.0.3",
38
+ "@types/lodash": "4.14.185",
39
+ "@types/node": "18.7.21",
40
+ "babel-jest": "29.0.3",
41
+ "graphql": "16.6.0",
42
+ "graphql-request": "5.0.0",
43
+ "jest": "29.0.3",
44
+ "node-fetch": "3.2.10",
45
+ "numbro": "2.3.6",
46
+ "prisma-query-log": "3.2.0",
47
+ "timezone-mock": "1.3.4",
48
+ "ts-node": "10.9.1",
49
+ "tslib": "2.4.0",
50
+ "typescript": "4.8.3"
51
+ }
52
52
  }