webs-sdk 0.1.7 → 0.1.9
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/package.json +1 -1
- package/src/index.ts +12 -2
- package/src/libraries/networking.ts +19 -2
- package/types/index.d.ts +14 -17
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import NetworkingClass from './libraries/networking';
|
|
2
|
+
import AuthManagerClass from './libraries/auth';
|
|
3
|
+
import I18nManagerClass from './libraries/i18n';
|
|
4
|
+
import StorageClass from './libraries/storage';
|
|
5
|
+
import UtilsClass from './libraries/utils';
|
|
6
|
+
import AndromedaClass from './libraries/andromeda';
|
|
2
7
|
|
|
3
8
|
const WebsSDK = {
|
|
4
|
-
|
|
9
|
+
Networking: new NetworkingClass(),
|
|
10
|
+
AuthManager: new AuthManagerClass(),
|
|
11
|
+
I18nManager: new I18nManagerClass(),
|
|
12
|
+
Storage: new StorageClass(),
|
|
13
|
+
Utils: new UtilsClass(),
|
|
14
|
+
Andromeda: new AndromedaClass()
|
|
5
15
|
};
|
|
6
16
|
|
|
7
17
|
export default WebsSDK;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
export class Networking {
|
|
2
|
-
async request(url: string, data?: object) {
|
|
3
|
-
|
|
2
|
+
async request(url: string, data?: object): Promise<object> {
|
|
3
|
+
try {
|
|
4
|
+
const response = await fetch(url, {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
headers: {
|
|
7
|
+
'Content-Type': 'application/json'
|
|
8
|
+
},
|
|
9
|
+
body: JSON.stringify(data)
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
if (!response.ok) {
|
|
13
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return await response.json();
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Networking request failed:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
4
21
|
}
|
|
5
22
|
}
|
|
6
23
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
declare module "webs-sdk" {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
request(url: string, data?: object): Promise<object>;
|
|
5
|
-
}
|
|
6
|
-
interface AuthManager {}
|
|
7
|
-
interface I18nManager {}
|
|
8
|
-
interface Storage {}
|
|
9
|
-
interface Utils {}
|
|
10
|
-
interface Andromeda {}
|
|
2
|
+
interface Networking {
|
|
3
|
+
request(url: string, data?: object): Promise<object>;
|
|
11
4
|
}
|
|
5
|
+
interface AuthManager {}
|
|
6
|
+
interface I18nManager {}
|
|
7
|
+
interface Storage {}
|
|
8
|
+
interface Utils {}
|
|
9
|
+
interface Andromeda {}
|
|
10
|
+
|
|
12
11
|
interface WebsSDK {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Andromeda: Libraries.Andromeda;
|
|
20
|
-
};
|
|
12
|
+
Networking: Networking;
|
|
13
|
+
AuthManager: AuthManager;
|
|
14
|
+
I18nManager: I18nManager;
|
|
15
|
+
Storage: Storage;
|
|
16
|
+
Utils: Utils;
|
|
17
|
+
Andromeda: Andromeda;
|
|
21
18
|
}
|
|
22
19
|
const WebsSDK: WebsSDK;
|
|
23
20
|
export default WebsSDK;
|