@cellaware/utils 5.0.2 → 5.0.4

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,9 +1,9 @@
1
1
  import { Readable } from "stream";
2
2
  export declare const AZURE_HEADER_FUNCTION_KEY = "x-functions-key";
3
3
  export declare const AZURE_HEADER_PRINCIPAL = "x-ms-client-principal";
4
- export declare function functionFetchJson(url: string, method: string, key: string, principal: string, body?: any): Promise<any>;
5
- export declare function functionFetchJsonWithText(url: string, method: string, key: string, principal: string, text: string): Promise<any>;
6
- export declare function functionFetchText(url: string, method: string, key: string, principal: string, body?: any): Promise<any>;
4
+ export declare function functionFetchJson(url: string, method: string, key: string, principal: string, body?: any): Promise<Response>;
5
+ export declare function functionFetchJsonWithText(url: string, method: string, key: string, principal: string, text: string): Promise<Response>;
6
+ export declare function functionFetchText(url: string, method: string, key: string, principal: string, body?: any): Promise<Response>;
7
7
  export declare function functionStreamJson(url: string, method: string, key: string, principal: string, body: any, errorBody: any): Promise<{
8
8
  headers: {
9
9
  "Content-Type": string;
@@ -7,8 +7,7 @@ const STATUS_SERVICE_UNAVAILABLE = 503;
7
7
  const RETRY_SLEEP_MS = 3000;
8
8
  const MAX_RETRIES = 3;
9
9
  async function functionFetch(url, req) {
10
- let res;
11
- let status = STATUS_SERVICE_UNAVAILABLE;
10
+ let res = new Response(null, { status: STATUS_SERVICE_UNAVAILABLE });
12
11
  let retryNum = 0;
13
12
  do {
14
13
  if (retryNum > 0) {
@@ -16,7 +15,6 @@ async function functionFetch(url, req) {
16
15
  }
17
16
  try {
18
17
  res = await fetch(url, req);
19
- status = res.status;
20
18
  }
21
19
  catch (err) {
22
20
  // if at max retries throw the error
@@ -26,7 +24,7 @@ async function functionFetch(url, req) {
26
24
  }
27
25
  retryNum++;
28
26
  } while (retryNum < MAX_RETRIES &&
29
- (status === STATUS_INTERNAL_SERVER_ERROR || status === STATUS_SERVICE_UNAVAILABLE));
27
+ (res.status === STATUS_INTERNAL_SERVER_ERROR || res.status === STATUS_SERVICE_UNAVAILABLE));
30
28
  return res;
31
29
  }
32
30
  async function functionStream(url, req, errorBody) {
@@ -1,5 +1,5 @@
1
- export declare function chatwmsFunctionFetch(path: string, method: string, principal: string, body?: any): Promise<any>;
2
- export declare function chatwmsFunctionFetchText(path: string, method: string, principal: string, body?: any): Promise<any>;
1
+ export declare function chatwmsFunctionFetch(path: string, method: string, principal: string, body?: any): Promise<Response>;
2
+ export declare function chatwmsFunctionFetchText(path: string, method: string, principal: string, body?: any): Promise<Response>;
3
3
  export declare function chatwmsFunctionStream(path: string, method: string, principal: string, body?: any): Promise<{
4
4
  headers: {
5
5
  "Content-Type": string;
@@ -8,9 +8,9 @@ export declare function chatwmsFunctionStream(path: string, method: string, prin
8
8
  };
9
9
  body: import("stream").Readable;
10
10
  }>;
11
- export declare function chatwmsGatewayFunctionFetch(url: string, method: string, key: string, principal: string, body?: any): Promise<any>;
12
- export declare function chatwmsGatewayFunctionFetchWithText(url: string, method: string, key: string, principal: string, text: string): Promise<any>;
13
- export declare function chatwmsGatewayFunctionFetchText(url: string, method: string, key: string, principal: string, body?: any): Promise<any>;
11
+ export declare function chatwmsGatewayFunctionFetch(url: string, method: string, key: string, principal: string, body?: any): Promise<Response>;
12
+ export declare function chatwmsGatewayFunctionFetchWithText(url: string, method: string, key: string, principal: string, text: string): Promise<Response>;
13
+ export declare function chatwmsGatewayFunctionFetchText(url: string, method: string, key: string, principal: string, body?: any): Promise<Response>;
14
14
  export declare function chatwmsGatewayFunctionStream(url: string, method: string, key: string, principal: string, body?: any): Promise<{
15
15
  headers: {
16
16
  "Content-Type": string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",