helios-utilities-sdk 1.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.
- package/build/helpers/ApiHelpers.d.ts +7 -0
- package/build/helpers/ApiHelpers.d.ts.map +1 -0
- package/build/helpers/ApiHelpers.js +16 -0
- package/build/helpers/ApiHelpers.js.map +1 -0
- package/build/helpers/Fetcher.d.ts +4 -0
- package/build/helpers/Fetcher.d.ts.map +1 -0
- package/build/helpers/Fetcher.js +19 -0
- package/build/helpers/Fetcher.js.map +1 -0
- package/build/helpers/index.d.ts +3 -0
- package/build/helpers/index.d.ts.map +1 -0
- package/build/helpers/index.js +3 -0
- package/build/helpers/index.js.map +1 -0
- package/build/hooks/index.d.ts +2 -0
- package/build/hooks/index.d.ts.map +1 -0
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3 -0
- package/build/index.js.map +1 -0
- package/package.json +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/ApiHelpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,QAAO,OAW/B,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,GAEtC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const buildHeaders = () => {
|
|
2
|
+
const headers = new Headers();
|
|
3
|
+
const token = localStorage.getItem("token");
|
|
4
|
+
if (token) {
|
|
5
|
+
headers.append("Content-Type", "application/json");
|
|
6
|
+
headers.append("Authorization", "Bearer " + token);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
headers.append("Content-Type", "application/json");
|
|
10
|
+
}
|
|
11
|
+
return headers;
|
|
12
|
+
};
|
|
13
|
+
export const buildUrl = (url) => {
|
|
14
|
+
return new URL(`${window.location.origin}${url}`);
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=ApiHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiHelpers.js","sourceRoot":"","sources":["../../src/helpers/ApiHelpers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,GAAY,EAAE;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAW,CAAC;IACtD,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QACnD,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,GAAG,KAAK,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAO,EAAE;IAC3C,OAAO,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fetcher.d.ts","sourceRoot":"","sources":["../../src/helpers/Fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,iBAAiB,CAAC;AAEjE,QAAA,MAAM,OAAO,GAAU,KAAK,MAAM,GAAG,GAAG,KAAG,OAAO,CAAC,WAAW,CAiB7D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { buildHeaders } from "./ApiHelpers.js";
|
|
2
|
+
const fetcher = async (url) => {
|
|
3
|
+
const payload = {};
|
|
4
|
+
try {
|
|
5
|
+
const headers = buildHeaders();
|
|
6
|
+
const response = await fetch(url.toString(), { headers: headers });
|
|
7
|
+
if (response.status == 401)
|
|
8
|
+
throw new Error("Unauthorized");
|
|
9
|
+
payload.data = await response.text();
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
const errorMessage = err instanceof Error ? err.message : "Unknown error occured";
|
|
13
|
+
console.log("Error getting auth: " + errorMessage);
|
|
14
|
+
payload.error = errorMessage;
|
|
15
|
+
}
|
|
16
|
+
return payload;
|
|
17
|
+
};
|
|
18
|
+
export default fetcher;
|
|
19
|
+
//# sourceMappingURL=Fetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fetcher.js","sourceRoot":"","sources":["../../src/helpers/Fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,OAAO,GAAG,KAAK,EAAE,GAAiB,EAAwB,EAAE;IAChE,MAAM,OAAO,GAAgB,EAAE,CAAC;IAEhC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;QAE/B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACnE,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACvC,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,YAAY,GAChB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,YAAY,CAAC,CAAC;QACnD,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC;IAC/B,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":""}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "helios-utilities-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "DevClarkMiller",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "build/index.js",
|
|
9
|
+
"types": "build/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"build",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "npx tsc",
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"typescript": "^5.9.3"
|
|
20
|
+
}
|
|
21
|
+
}
|