helios-utilities-sdk 1.0.4 → 1.0.6
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 +8 -0
- package/build/helpers/ApiHelpers.d.ts.map +1 -0
- package/build/helpers/ApiHelpers.js +21 -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/Poster.d.ts +4 -0
- package/build/helpers/Poster.d.ts.map +1 -0
- package/build/helpers/Poster.js +23 -0
- package/build/helpers/Poster.js.map +1 -0
- package/build/helpers/index.d.ts +4 -0
- package/build/helpers/index.d.ts.map +1 -0
- package/build/helpers/index.js +4 -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 -21
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const buildHeaders: () => Headers;
|
|
2
|
+
export declare const buildUrl: (url: string) => URL;
|
|
3
|
+
export declare const normalizeFetcherData: (fetcherData: FetcherData) => FetcherData;
|
|
4
|
+
export interface FetcherData {
|
|
5
|
+
data?: unknown;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ApiHelpers.d.ts.map
|
|
@@ -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,eAAO,MAAM,oBAAoB,GAAI,aAAa,WAAW,gBAI5D,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
export const normalizeFetcherData = (fetcherData) => {
|
|
17
|
+
if (fetcherData.data?.data)
|
|
18
|
+
fetcherData.data = fetcherData.data.data;
|
|
19
|
+
return fetcherData;
|
|
20
|
+
};
|
|
21
|
+
//# 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;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,WAAwB,EAAE,EAAE;IAC/D,IAAK,WAAW,CAAC,IAAY,EAAE,IAAI;QACjC,WAAW,CAAC,IAAI,GAAI,WAAW,CAAC,IAAY,CAAC,IAAI,CAAC;IACpD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fetcher.d.ts","sourceRoot":"","sources":["../../src/helpers/Fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAC;AAEzB,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, normalizeFetcherData, } 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.json();
|
|
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 normalizeFetcherData(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,EAEL,YAAY,EACZ,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,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,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Poster.d.ts","sourceRoot":"","sources":["../../src/helpers/Poster.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAC;AAEzB,QAAA,MAAM,MAAM,GAAU,KAAK,MAAM,GAAG,GAAG,EAAE,MAAM,GAAG,KAAG,OAAO,CAAC,WAAW,CAqBvE,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { buildHeaders, normalizeFetcherData, } from "./ApiHelpers.js";
|
|
2
|
+
const poster = async (url, body) => {
|
|
3
|
+
const payload = {};
|
|
4
|
+
try {
|
|
5
|
+
const headers = buildHeaders();
|
|
6
|
+
const response = await fetch(url.toString(), {
|
|
7
|
+
method: "POST",
|
|
8
|
+
headers: headers,
|
|
9
|
+
body: body,
|
|
10
|
+
});
|
|
11
|
+
if (response.status == 401)
|
|
12
|
+
throw new Error("Unauthorized");
|
|
13
|
+
payload.data = await response.json();
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
const errorMessage = err instanceof Error ? err.message : "Unknown error occured";
|
|
17
|
+
console.log("Error getting auth: " + errorMessage);
|
|
18
|
+
payload.error = errorMessage;
|
|
19
|
+
}
|
|
20
|
+
return normalizeFetcherData(payload);
|
|
21
|
+
};
|
|
22
|
+
export default poster;
|
|
23
|
+
//# sourceMappingURL=Poster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Poster.js","sourceRoot":"","sources":["../../src/helpers/Poster.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,GAAG,KAAK,EAAE,GAAiB,EAAE,IAAS,EAAwB,EAAE;IAC1E,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;YAC3C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QACH,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,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,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
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "helios-utilities-sdk",
|
|
3
|
-
"version": "1.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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "helios-utilities-sdk",
|
|
3
|
+
"version": "1.0.6",
|
|
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
|
+
}
|