@cellaware/utils 3.5.1 → 4.0.0

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,15 +1,7 @@
1
1
  import { Readable } from "stream";
2
- export declare function functionStream(url: string, req: any, errorBody: any): Promise<{
3
- headers: {
4
- "Content-Type": string;
5
- "Cache-Control": string;
6
- "Transfer-Encoding": string;
7
- };
8
- body: Readable;
9
- }>;
10
- export declare function functionFetchJson(url: string, method: string, key: string, body?: any): Promise<any>;
11
- export declare function functionFetchText(url: string, method: string, key: string, text: string): Promise<any>;
12
- export declare function functionStreamJson(url: string, method: string, key: string, body: any, errorBody: any): Promise<{
2
+ export declare function functionFetchJson(url: string, method: string, key: string, principal: string, body?: any): Promise<any>;
3
+ export declare function functionFetchText(url: string, method: string, key: string, principal: string, text: string): Promise<any>;
4
+ export declare function functionStreamJson(url: string, method: string, key: string, principal: string, body: any, errorBody: any): Promise<{
13
5
  headers: {
14
6
  "Content-Type": string;
15
7
  "Cache-Control": string;
@@ -27,7 +27,7 @@ async function functionFetch(url, req) {
27
27
  (status === STATUS_INTERNAL_SERVER_ERROR || status === STATUS_SERVICE_UNAVAILABLE));
28
28
  return res;
29
29
  }
30
- export async function functionStream(url, req, errorBody) {
30
+ async function functionStream(url, req, errorBody) {
31
31
  let stream = new Readable();
32
32
  stream._read = () => { };
33
33
  fetch(url, req)
@@ -60,11 +60,12 @@ export async function functionStream(url, req, errorBody) {
60
60
  body: stream
61
61
  };
62
62
  }
63
- export async function functionFetchJson(url, method, key, body) {
63
+ export async function functionFetchJson(url, method, key, principal, body) {
64
64
  const headers = {
65
65
  'Content-Type': 'application/json',
66
66
  'Accept': 'application/json',
67
- 'x-functions-key': key
67
+ 'x-functions-key': key,
68
+ 'x-ms-client-principal': principal
68
69
  };
69
70
  let req = {
70
71
  method,
@@ -75,11 +76,12 @@ export async function functionFetchJson(url, method, key, body) {
75
76
  }
76
77
  return functionFetch(url, req);
77
78
  }
78
- export async function functionFetchText(url, method, key, text) {
79
+ export async function functionFetchText(url, method, key, principal, text) {
79
80
  const headers = {
80
81
  'Content-Type': 'application/text',
81
82
  'Accept': 'application/json',
82
- 'x-functions-key': key
83
+ 'x-functions-key': key,
84
+ 'x-ms-client-principal': principal
83
85
  };
84
86
  let req = {
85
87
  method,
@@ -88,11 +90,12 @@ export async function functionFetchText(url, method, key, text) {
88
90
  };
89
91
  return functionFetch(url, req);
90
92
  }
91
- export async function functionStreamJson(url, method, key, body, errorBody) {
93
+ export async function functionStreamJson(url, method, key, principal, body, errorBody) {
92
94
  const headers = {
93
95
  'Content-Type': 'application/json',
94
96
  'Accept': 'text/event-stream',
95
- 'x-functions-key': key
97
+ 'x-functions-key': key,
98
+ 'x-ms-client-principal': principal
96
99
  };
97
100
  let req = {
98
101
  method,
@@ -1,6 +1,6 @@
1
- export declare function chatwmsFunctionFetch(path: string, method: string, body?: any): Promise<any>;
2
- export declare function chatwmsFunctionQuery(path: string, method: string, query: string): Promise<any>;
3
- export declare function chatwmsFunctionStream(path: string, method: string, body?: any): Promise<{
1
+ export declare function chatwmsFunctionFetch(path: string, method: string, principal: string, body?: any): Promise<any>;
2
+ export declare function chatwmsFunctionQuery(path: string, method: string, principal: string, query: string): Promise<any>;
3
+ export declare function chatwmsFunctionStream(path: string, method: string, principal: string, body?: any): Promise<{
4
4
  headers: {
5
5
  "Content-Type": string;
6
6
  "Cache-Control": string;
@@ -1,17 +1,17 @@
1
1
  import { functionFetchJson, functionFetchText, functionStreamJson } from "../../azure/function.js";
2
- export function chatwmsFunctionFetch(path, method, body) {
2
+ export function chatwmsFunctionFetch(path, method, principal, body) {
3
3
  const url = `${process.env['CHATWMS_URL']}/${path}`;
4
- return functionFetchJson(url, method, process.env['CHATWMS_KEY'] ?? '', body);
4
+ return functionFetchJson(url, method, process.env['CHATWMS_KEY'] ?? '', principal, body);
5
5
  }
6
- export function chatwmsFunctionQuery(path, method, query) {
6
+ export function chatwmsFunctionQuery(path, method, principal, query) {
7
7
  const url = `${process.env['CHATWMS_URL']}/${path}`;
8
- return functionFetchText(url, method, process.env['CHATWMS_KEY'] ?? '', query);
8
+ return functionFetchText(url, method, process.env['CHATWMS_KEY'] ?? '', principal, query);
9
9
  }
10
- export function chatwmsFunctionStream(path, method, body) {
10
+ export function chatwmsFunctionStream(path, method, principal, body) {
11
11
  const url = `${process.env['CHATWMS_URL']}/${path}`;
12
12
  const errorBody = {
13
13
  answer: 'chatwms-unavailable-error',
14
14
  error: 'chatwms-unavailable-error'
15
15
  };
16
- return functionStreamJson(url, method, process.env['CHATWMS_KEY'] ?? '', body, errorBody);
16
+ return functionStreamJson(url, method, process.env['CHATWMS_KEY'] ?? '', principal, body, errorBody);
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "3.5.1",
3
+ "version": "4.0.0",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",