@dynatrace-sdk/app-utils
Advanced tools
Comparing version 0.2.2 to 0.3.1
@@ -5,2 +5,20 @@ # App utils | ||
## 0.3.1 | ||
### Patch Changes | ||
- Fix documentation for functions namespace | ||
## 0.3.0 | ||
### Minor Changes | ||
- BREAKING CHANGE: functions.call second argument now is object that has two optional properties data and abort signal | ||
## 0.2.3 | ||
### Patch Changes | ||
- Update documentation | ||
## 0.2.2 | ||
@@ -10,4 +28,4 @@ | ||
- 2b190962: Update documentation | ||
- 2bd5ee62: Update links | ||
- Update documentation | ||
- Update links | ||
@@ -18,4 +36,4 @@ ## 0.2.1 | ||
- b7f5d3d5: Add description, homepage and keywords to package.json | ||
- fc2cf694: Add docs for function utils packages. | ||
- Add description, homepage and keywords to package.json | ||
- Add docs for function utils packages. | ||
@@ -26,3 +44,3 @@ ## 0.2.0 | ||
- ab40f222: Rename package util-app to app-utils | ||
- Rename package util-app to app-utils | ||
@@ -33,3 +51,3 @@ ## 0.1.1 | ||
- df378695: Improve docs | ||
- Improve docs | ||
@@ -44,2 +62,2 @@ ## 0.1.0 | ||
- Adding docs for util-app and util-serverless. | ||
- Adding docs for util-app and util-serverless. |
@@ -44,17 +44,16 @@ /** | ||
var functions = { | ||
async call(functionName, data) { | ||
const urlToFetch = new URL("/api/" + functionName, location.protocol + "//" + location.host); | ||
const response = await fetch(urlToFetch.toString(), { | ||
method: data ? "POST" : "GET", | ||
body: data ? JSON.stringify(data) : void 0 | ||
}).then((response2) => { | ||
if (!response2.ok) { | ||
throw new Error( | ||
"Function " + functionName + " failed with error-code: " + response2.status + " " + response2.statusText | ||
); | ||
} | ||
return response2; | ||
}).catch((error) => { | ||
throw error; | ||
}); | ||
async call(functionName, options) { | ||
const url = new URL( | ||
`/api/${functionName}`, | ||
`${location.protocol}//${location.host}` | ||
).toString(); | ||
const method = options?.data ? "POST" : "GET"; | ||
const body = options?.data ? JSON.stringify(options.data) : void 0; | ||
const signal = options?.abortSignal; | ||
const response = await fetch(url, { body, method, signal }); | ||
if (!response.ok) { | ||
throw new Error( | ||
`Function ${functionName} failed with error-code: ${response.status} ${response.statusText}` | ||
); | ||
} | ||
return response; | ||
@@ -61,0 +60,0 @@ } |
# App utils | ||
SDK package version **0.2.2** | ||
Utilities for app function executions. | ||
```bash | ||
npm install @dynatrace-sdk/app-utils | ||
``` | ||
import NpmLogo from '@site/static/img/npm-logo.png'; | ||
<div class="row margin-bottom--md"> | ||
<div class="col"> | ||
<a href="https://www.npmjs.com/package/@dynatrace-sdk/app-utils"> | ||
<span class="margin-right--xs">@dynatrace-sdk/app-utils</span> | ||
<img className="no-zoom" width="20px" src={NpmLogo} /> | ||
</a> | ||
</div> | ||
<div class="col" style={{textAlign: 'right'}}> | ||
<a href="https://www.npmjs.com/package/@dynatrace-sdk/app-utils/v/0.3.1">v0.3.1</a> | ||
</div> | ||
</div> | ||
```bash | ||
npm install @dynatrace-sdk/app-utils | ||
``` | ||
@@ -21,7 +33,4 @@ ## Variables | ||
</div> | ||
## Namespaces | ||
@@ -38,3 +47,3 @@ | ||
<div class="padding-bottom--md"> | ||
<strong>call(functionName,data?): <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#response_objects">Promise<Response></a></strong> | ||
<strong>call(functionName,options?): <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#response_objects">Promise<Response></a></strong> | ||
@@ -45,3 +54,2 @@ <div class="padding-left--md"> | ||
**Parameters** | ||
@@ -53,12 +61,18 @@ | ||
<div class="padding-left--md padding-bottom--md"> | ||
<strong>options?</strong>: <a href="https://developer.mozilla.org/en-US/docs/Glossary/Object">Object</a> | ||
<div class="padding-left--md"> | ||
<div class="padding-left--md padding-bottom--md"> | ||
<strong>options.data?</strong>: Any </a> | ||
<div class="padding-left--md"> | ||
<div class="padding-left--md padding-bottom--md"> | ||
<strong>options.abortSignal?</strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal">AbortSignal</a> | ||
<div class="padding-left--md"> | ||
</div> | ||
</div> | ||
#### Returns | ||
@@ -71,10 +85,4 @@ | ||
</div> | ||
</div> |
@@ -19,17 +19,16 @@ /** | ||
var functions = { | ||
async call(functionName, data) { | ||
const urlToFetch = new URL("/api/" + functionName, location.protocol + "//" + location.host); | ||
const response = await fetch(urlToFetch.toString(), { | ||
method: data ? "POST" : "GET", | ||
body: data ? JSON.stringify(data) : void 0 | ||
}).then((response2) => { | ||
if (!response2.ok) { | ||
throw new Error( | ||
"Function " + functionName + " failed with error-code: " + response2.status + " " + response2.statusText | ||
); | ||
} | ||
return response2; | ||
}).catch((error) => { | ||
throw error; | ||
}); | ||
async call(functionName, options) { | ||
const url = new URL( | ||
`/api/${functionName}`, | ||
`${location.protocol}//${location.host}` | ||
).toString(); | ||
const method = options?.data ? "POST" : "GET"; | ||
const body = options?.data ? JSON.stringify(options.data) : void 0; | ||
const signal = options?.abortSignal; | ||
const response = await fetch(url, { body, method, signal }); | ||
if (!response.ok) { | ||
throw new Error( | ||
`Function ${functionName} failed with error-code: ${response.status} ${response.statusText}` | ||
); | ||
} | ||
return response; | ||
@@ -36,0 +35,0 @@ } |
{ | ||
"name": "@dynatrace-sdk/app-utils", | ||
"version": "0.2.2", | ||
"version": "0.3.1", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "description": "Utilities for app function executions.", |
@@ -23,6 +23,11 @@ /** | ||
* @param functionName | ||
* @param data | ||
* @param options Optional options | ||
* @param options.data An Payload of the call | ||
* @param options.abortSignal An AbortSignal to set request's signal | ||
* @returns Response of a fetch call | ||
*/ | ||
call(functionName: string, data?: any): Promise<Response>; | ||
call(functionName: string, options?: { | ||
data?: unknown; | ||
abortSignal?: AbortSignal; | ||
}): Promise<Response>; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19684
10
159