@cellaware/utils 8.5.10 → 8.6.1

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.
@@ -1,4 +1,5 @@
1
1
  import { BlobServiceClient } from '@azure/storage-blob';
2
+ import { isArrayLike } from '../util.js';
2
3
  function streamToBuffer(stream) {
3
4
  return new Promise((resolve, reject) => {
4
5
  const chunks = [];
@@ -26,7 +27,14 @@ export async function storageBlobUpload(containerClientId, blobId, data) {
26
27
  const blobServiceClient = BlobServiceClient.fromConnectionString(process.env.STORAGE_CONNECTION_STRING ?? '');
27
28
  const containerClient = blobServiceClient.getContainerClient(containerClientId);
28
29
  const blockBlobClient = containerClient.getBlockBlobClient(blobId);
29
- await blockBlobClient.upload(data, data.length);
30
+ let len = 0;
31
+ if (isArrayLike(data)) {
32
+ len = data.length;
33
+ }
34
+ else {
35
+ len = JSON.stringify(data).length;
36
+ }
37
+ await blockBlobClient.upload(data, len);
30
38
  }
31
39
  catch (err) {
32
40
  console.log(`STORAGE: BLOB upload error: ${err.message}`);
@@ -107,4 +107,5 @@ export interface InstanceReportSchedule {
107
107
  popups: Set<string>;
108
108
  emails: Set<string>;
109
109
  excel: boolean;
110
+ parameterValues: ReportParameterValue[];
110
111
  }
package/dist/util.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare function sleep(ms: number): Promise<any>;
6
6
  export declare function reverse(str: string): string;
7
7
  export declare function base64Encode(str: string): string;
8
8
  export declare function base64Decode(str: string): string;
9
+ export declare function isArrayLike(obj: any): boolean;
9
10
  export declare function initDate(timeZone?: string): Date;
10
11
  export declare function convertDateTimeZone(date: Date, timeZone: string): Date;
11
12
  export declare function isDaylightSavingTime(timeZone?: string): boolean;
package/dist/util.js CHANGED
@@ -11,6 +11,12 @@ export function base64Encode(str) {
11
11
  export function base64Decode(str) {
12
12
  return Buffer.from(str, 'base64').toString('utf-8');
13
13
  }
14
+ export function isArrayLike(obj) {
15
+ return (Array.isArray(obj) ||
16
+ (!!obj &&
17
+ obj.hasOwnProperty("length") &&
18
+ typeof obj.length === "number"));
19
+ }
14
20
  // Dates --------------------------------------------------------------------------
15
21
  export function initDate(timeZone) {
16
22
  const date = new Date();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.5.10",
3
+ "version": "8.6.1",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",