@8ms/helpers 1.2.15 → 1.2.17

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/global/read.js CHANGED
@@ -18,7 +18,7 @@ const read = async ({ key }) => {
18
18
  // Exists (0 is determined as forever)
19
19
  else if (0 != global['ems_cache'][key].expires) {
20
20
  // https://ui.dev/get-current-timestamp-javascript
21
- const expiresAt = Math.floor(global['ems_cache'][key].insertedAt / 1000) + global[key].expires;
21
+ const expiresAt = Math.floor(global['ems_cache'][key].insertedAt / 1000) + global['ems_cache'][key].expires;
22
22
  const now = Math.floor(Date.now() / 1000);
23
23
  // If we are now beyond the expiry date, update the data
24
24
  if (now > expiresAt) {
@@ -1,12 +1,16 @@
1
1
  type LoadData = {
2
- bucket: string;
3
- key: string;
4
- datasetId: string;
5
- tableId: string;
6
- metadata: object;
2
+ file: {
3
+ bucket: string;
4
+ key: string;
5
+ metadata: object;
6
+ };
7
+ table: {
8
+ datasetId: string;
9
+ tableId: string;
10
+ };
7
11
  };
8
12
  /**
9
13
  * Load data into a given table.
10
14
  */
11
- declare const loadData: ({ bucket, datasetId, key, metadata, tableId }: LoadData) => Promise<void>;
15
+ declare const loadData: ({ file, table }: LoadData) => Promise<void>;
12
16
  export default loadData;
@@ -7,12 +7,16 @@ const IsTableExists_1 = __importDefault(require("./IsTableExists"));
7
7
  /**
8
8
  * Load data into a given table.
9
9
  */
10
- const loadData = async ({ bucket, datasetId, key, metadata, tableId }) => {
11
- const tableExists = await (0, IsTableExists_1.default)({ datasetId, tableId });
10
+ const loadData = async ({ file, table }) => {
11
+ const tableExists = await (0, IsTableExists_1.default)({
12
+ datasetId: table.datasetId,
13
+ tableId: table.tableId,
14
+ });
12
15
  if (tableExists) {
13
- await global.googleBigQueryClient.dataset(datasetId)
14
- .table(tableId)
15
- .load(global.googleStorageClient.bucket(bucket).file(key), metadata);
16
+ await global.googleBigQueryClient.dataset(table.datasetId)
17
+ .table(table.tableId)
18
+ .load(global.googleStorageClient.bucket(file.bucket)
19
+ .file(file.key), file.metadata);
16
20
  }
17
21
  };
18
22
  exports.default = loadData;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.2.15",
4
+ "version": "1.2.17",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"