@smess/networking 1.0.9 → 1.0.12
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/README.md +26 -20
- package/dist/core/axios.d.ts +3 -3
- package/dist/core/axios.js +2 -2
- package/dist/core/axios.observable.d.ts +3 -3
- package/dist/core/axios.observable.js +7 -7
- package/dist/core/base.provider.advanced.test.js +15 -15
- package/dist/core/base.provider.d.ts +1 -1
- package/dist/core/base.provider.js +2 -2
- package/dist/core/base.provider.test.js +22 -18
- package/dist/core/base.service.wrapper.advanced.test.js +16 -13
- package/dist/core/base.service.wrapper.d.ts +2 -2
- package/dist/core/base.service.wrapper.js +1 -1
- package/dist/core/base.service.wrapper.test.js +14 -14
- package/dist/core/rx.http.service.d.ts +3 -3
- package/dist/core/rx.http.service.js +2 -2
- package/dist/index.d.ts +13 -13
- package/dist/index.js +15 -15
- package/dist/services/auth.service.d.ts +6 -5
- package/dist/services/auth.service.js +50 -28
- package/dist/services/auth.service.test.js +67 -51
- package/dist/services/cache.service.d.ts +1 -1
- package/dist/services/cache.service.js +7 -7
- package/dist/services/cache.service.test.d.ts +1 -1
- package/dist/services/cache.service.test.js +37 -37
- package/dist/services/customer.service.d.ts +4 -4
- package/dist/services/customer.service.js +19 -17
- package/dist/services/customer.service.test.js +38 -34
- package/dist/services/logger.service.js +11 -11
- package/dist/services/logger.service.test.js +12 -12
- package/dist/services/order.service.d.ts +5 -4
- package/dist/services/order.service.js +32 -30
- package/dist/services/order.service.test.js +47 -47
- package/dist/services/product.service.d.ts +4 -4
- package/dist/services/product.service.js +8 -8
- package/dist/services/product.service.test.js +27 -19
- package/dist/services/smess.service.d.ts +2 -2
- package/dist/services/smess.service.js +19 -19
- package/dist/services/smess.service.test.js +36 -32
- package/dist/services/store.service.d.ts +4 -4
- package/dist/services/store.service.js +70 -50
- package/dist/services/store.service.test.d.ts +1 -1
- package/dist/services/store.service.test.js +161 -85
- package/dist/services/user.service.d.ts +3 -3
- package/dist/services/user.service.js +11 -8
- package/dist/services/user.service.test.js +23 -17
- package/dist/types/types.js +3 -3
- package/dist/types/types.test.js +8 -8
- package/dist/utils/cache-import.d.ts +1 -1
- package/dist/utils/cache-import.js +1 -1
- package/dist/utils/networking-import.d.ts +3 -3
- package/dist/utils/networking-import.js +2 -2
- package/dist/utils/rxjs-import.d.ts +2 -2
- package/dist/utils/rxjs-import.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# SMESS Networking Package
|
|
2
2
|
|
|
3
3
|
## Features
|
|
4
|
+
|
|
4
5
|
- Per-instance configuration (no global config)
|
|
5
6
|
- RxJS-based HTTP services
|
|
6
7
|
- Extensible provider/service architecture
|
|
@@ -16,24 +17,26 @@ npm install @smess/networking
|
|
|
16
17
|
## Usage
|
|
17
18
|
|
|
18
19
|
### 1. Define your config
|
|
20
|
+
|
|
19
21
|
```typescript
|
|
20
22
|
const configA = {
|
|
21
|
-
baseUrl:
|
|
23
|
+
baseUrl: "https://api-a",
|
|
22
24
|
isProd: false,
|
|
23
|
-
clientId:
|
|
24
|
-
apiKey:
|
|
25
|
+
clientId: "A",
|
|
26
|
+
apiKey: "keyA",
|
|
25
27
|
};
|
|
26
28
|
const configB = {
|
|
27
|
-
baseUrl:
|
|
29
|
+
baseUrl: "https://api-b",
|
|
28
30
|
isProd: true,
|
|
29
|
-
clientId:
|
|
30
|
-
apiKey:
|
|
31
|
+
clientId: "B",
|
|
32
|
+
apiKey: "keyB",
|
|
31
33
|
};
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
### 2. Create providers/services with config
|
|
37
|
+
|
|
35
38
|
```typescript
|
|
36
|
-
import { ProductService, UserService, AuthService } from
|
|
39
|
+
import { ProductService, UserService, AuthService } from "@smess/networking";
|
|
37
40
|
|
|
38
41
|
const productServiceA = new ProductService(configA);
|
|
39
42
|
const productServiceB = new ProductService(configB);
|
|
@@ -42,6 +45,7 @@ const authServiceA = new AuthService(configA);
|
|
|
42
45
|
```
|
|
43
46
|
|
|
44
47
|
### 3. Use services independently
|
|
48
|
+
|
|
45
49
|
```typescript
|
|
46
50
|
// Using RxJS Observables
|
|
47
51
|
productServiceA.fetchAllProducts().subscribe(...);
|
|
@@ -55,14 +59,15 @@ const products = await productServiceA.fetchAllProducts().toPromise();
|
|
|
55
59
|
```
|
|
56
60
|
|
|
57
61
|
### 4. Example: Custom Provider
|
|
62
|
+
|
|
58
63
|
```typescript
|
|
59
|
-
import { BaseProvider, SmessService } from
|
|
64
|
+
import { BaseProvider, SmessService } from "@smess/networking";
|
|
60
65
|
|
|
61
66
|
const config = {
|
|
62
|
-
baseUrl:
|
|
67
|
+
baseUrl: "https://custom-api",
|
|
63
68
|
isProd: false,
|
|
64
|
-
clientId:
|
|
65
|
-
apiKey:
|
|
69
|
+
clientId: "custom-client",
|
|
70
|
+
apiKey: "custom-key",
|
|
66
71
|
};
|
|
67
72
|
|
|
68
73
|
class ExampleProvider extends BaseProvider {
|
|
@@ -70,16 +75,16 @@ class ExampleProvider extends BaseProvider {
|
|
|
70
75
|
super({
|
|
71
76
|
config,
|
|
72
77
|
path: `/resource/${resourceId}`,
|
|
73
|
-
method:
|
|
74
|
-
headers: {
|
|
78
|
+
method: "GET",
|
|
79
|
+
headers: { "Custom-Header": "value" },
|
|
75
80
|
getPath: () => `/resource/${resourceId}`,
|
|
76
81
|
});
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
const provider = new ExampleProvider(config,
|
|
85
|
+
const provider = new ExampleProvider(config, "123");
|
|
81
86
|
const service = new SmessService(provider);
|
|
82
|
-
service.request().subscribe(result => {
|
|
87
|
+
service.request().subscribe((result) => {
|
|
83
88
|
// handle result
|
|
84
89
|
});
|
|
85
90
|
```
|
|
@@ -89,18 +94,19 @@ service.request().subscribe(result => {
|
|
|
89
94
|
This package is designed to work seamlessly with modern bundlers:
|
|
90
95
|
|
|
91
96
|
- **Webpack** ✅
|
|
92
|
-
- **Vite** ✅
|
|
97
|
+
- **Vite** ✅
|
|
93
98
|
- **Rollup** ✅
|
|
94
99
|
- **Parcel** ✅
|
|
95
100
|
|
|
96
101
|
The package uses **extensionless imports** in TypeScript source code, which bundlers handle automatically. No `.js` extensions needed in your imports!
|
|
97
102
|
|
|
98
103
|
### Example with Webpack/Vite
|
|
104
|
+
|
|
99
105
|
```typescript
|
|
100
106
|
// ✅ This works perfectly with bundlers
|
|
101
|
-
import { UserService, ProductService } from
|
|
107
|
+
import { UserService, ProductService } from "@smess/networking";
|
|
102
108
|
|
|
103
|
-
const config = { baseUrl:
|
|
109
|
+
const config = { baseUrl: "https://api.example.com", isProd: false };
|
|
104
110
|
const userService = new UserService(config);
|
|
105
111
|
const productService = new ProductService(config);
|
|
106
112
|
```
|
|
@@ -108,7 +114,7 @@ const productService = new ProductService(config);
|
|
|
108
114
|
## Available Services
|
|
109
115
|
|
|
110
116
|
- `UserService` - User management operations
|
|
111
|
-
- `ProductService` - Product CRUD operations
|
|
117
|
+
- `ProductService` - Product CRUD operations
|
|
112
118
|
- `AuthService` - Authentication (login, logout, password reset)
|
|
113
119
|
- `CustomerService` - Customer registration and profile management
|
|
114
120
|
- `OrderService` - Order management
|
|
@@ -138,4 +144,4 @@ See [SETUP.md](./SETUP.md) for instructions on using this package as a private d
|
|
|
138
144
|
|
|
139
145
|
---
|
|
140
146
|
|
|
141
|
-
MIT License
|
|
147
|
+
MIT License
|
package/dist/core/axios.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from
|
|
2
|
-
import type { AxiosInterceptorManager } from
|
|
3
|
-
import { AxiosObservable } from
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "../utils/networking-import";
|
|
2
|
+
import type { AxiosInterceptorManager } from "axios";
|
|
3
|
+
import { AxiosObservable } from "./axios.observable";
|
|
4
4
|
export interface Axiosable {
|
|
5
5
|
request<T = unknown>(config: AxiosRequestConfig): AxiosObservable<T>;
|
|
6
6
|
get<T = unknown>(url: string, config?: AxiosRequestConfig): AxiosObservable<T>;
|
package/dist/core/axios.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any -- Required for axios compatibility */
|
|
2
|
-
import { axios, } from
|
|
3
|
-
import { createObservable } from
|
|
2
|
+
import { axios, } from "../utils/networking-import";
|
|
3
|
+
import { createObservable } from "./axios.observable";
|
|
4
4
|
class Axios {
|
|
5
5
|
constructor(axiosInstance) {
|
|
6
6
|
this.axiosInstance = axiosInstance;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AxiosResponse } from
|
|
2
|
-
import type { AxiosPromise } from
|
|
3
|
-
import { Observable } from
|
|
1
|
+
import { AxiosResponse } from "../utils/networking-import";
|
|
2
|
+
import type { AxiosPromise } from "axios";
|
|
3
|
+
import { Observable } from "../utils/rxjs-import";
|
|
4
4
|
export type AxiosObservable<T> = Observable<AxiosResponse<T>>;
|
|
5
5
|
interface ObservableOptions {
|
|
6
6
|
retry?: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any -- Required for axios compatibility */
|
|
2
|
-
import { axios, } from
|
|
3
|
-
import { Observable, timeout as rxTimeout, retry as rxRetry, shareReplay, catchError, throwError, } from
|
|
4
|
-
import { $logger } from
|
|
2
|
+
import { axios, } from "../utils/networking-import";
|
|
3
|
+
import { Observable, timeout as rxTimeout, retry as rxRetry, shareReplay, catchError, throwError, } from "../utils/rxjs-import";
|
|
4
|
+
import { $logger } from "../services/logger.service";
|
|
5
5
|
export function createObservable(promiseFactory, args, options = {}) {
|
|
6
6
|
let config = args[args.length - 1];
|
|
7
|
-
if (config && typeof config ===
|
|
7
|
+
if (config && typeof config === "object" && !Array.isArray(config)) {
|
|
8
8
|
config = { ...config };
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
@@ -14,7 +14,7 @@ export function createObservable(promiseFactory, args, options = {}) {
|
|
|
14
14
|
let cancelSource = null;
|
|
15
15
|
const hasCancelToken = !!config.cancelToken;
|
|
16
16
|
if (!hasCancelToken) {
|
|
17
|
-
$logger.warn(
|
|
17
|
+
$logger.warn("[Networking] You can omit cancelToken — unsubscribing cancels the request automatically.", undefined, "axios.observable");
|
|
18
18
|
}
|
|
19
19
|
let source$ = new Observable((subscriber) => {
|
|
20
20
|
if (!hasCancelToken) {
|
|
@@ -33,7 +33,7 @@ export function createObservable(promiseFactory, args, options = {}) {
|
|
|
33
33
|
});
|
|
34
34
|
return () => {
|
|
35
35
|
if (cancelSource) {
|
|
36
|
-
cancelSource.cancel(
|
|
36
|
+
cancelSource.cancel("Request canceled via unsubscribe.");
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
});
|
|
@@ -51,7 +51,7 @@ export function createObservable(promiseFactory, args, options = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
// Optional: Log or catch errors globally
|
|
53
53
|
source$ = source$.pipe(catchError((err) => {
|
|
54
|
-
$logger.error(
|
|
54
|
+
$logger.error("[createObservable error]:", err, "axios.observable");
|
|
55
55
|
return throwError(() => err);
|
|
56
56
|
}));
|
|
57
57
|
return source$;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { BaseProvider } from
|
|
2
|
-
describe(
|
|
1
|
+
import { BaseProvider } from "./base.provider";
|
|
2
|
+
describe("BaseProvider Advanced", () => {
|
|
3
3
|
const config = {
|
|
4
|
-
baseUrl:
|
|
4
|
+
baseUrl: "https://api.example.com",
|
|
5
5
|
isProd: false,
|
|
6
|
-
clientId:
|
|
7
|
-
apiKey:
|
|
6
|
+
clientId: "test-client",
|
|
7
|
+
apiKey: "test-key",
|
|
8
8
|
};
|
|
9
|
-
it(
|
|
9
|
+
it("should support dynamic getPath for multiple params", () => {
|
|
10
10
|
const provider = new BaseProvider({
|
|
11
11
|
config,
|
|
12
|
-
path:
|
|
13
|
-
method:
|
|
12
|
+
path: "/resource/:id/:action",
|
|
13
|
+
method: "GET",
|
|
14
14
|
headers: {},
|
|
15
15
|
getPath: (id, action) => `/resource/${id}/${action}`,
|
|
16
16
|
});
|
|
17
|
-
expect(provider.getPath(
|
|
17
|
+
expect(provider.getPath("42", "edit")).toBe("/resource/42/edit");
|
|
18
18
|
});
|
|
19
|
-
it(
|
|
19
|
+
it("should allow dynamic headers and method", () => {
|
|
20
20
|
const provider = new BaseProvider({
|
|
21
21
|
config,
|
|
22
|
-
path:
|
|
23
|
-
method:
|
|
24
|
-
headers: { Authorization:
|
|
22
|
+
path: "/resource",
|
|
23
|
+
method: "PATCH",
|
|
24
|
+
headers: { Authorization: "Bearer token" },
|
|
25
25
|
});
|
|
26
|
-
expect(provider.method).toBe(
|
|
27
|
-
expect(provider.headers.Authorization).toBe(
|
|
26
|
+
expect(provider.method).toBe("PATCH");
|
|
27
|
+
expect(provider.headers.Authorization).toBe("Bearer token");
|
|
28
28
|
});
|
|
29
29
|
});
|
|
@@ -5,8 +5,8 @@ export class BaseProvider {
|
|
|
5
5
|
this.method = method;
|
|
6
6
|
this.headers = {
|
|
7
7
|
...headers,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
"X-Client-Id": config.clientId,
|
|
9
|
+
"X-Api-Key": config.apiKey,
|
|
10
10
|
};
|
|
11
11
|
this.getPath = getPath || (() => path);
|
|
12
12
|
}
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
import { BaseProvider } from
|
|
2
|
-
describe(
|
|
1
|
+
import { BaseProvider } from "./base.provider";
|
|
2
|
+
describe("BaseProvider", () => {
|
|
3
3
|
const config = {
|
|
4
|
-
baseUrl:
|
|
4
|
+
baseUrl: "https://api.example.com",
|
|
5
5
|
isProd: false,
|
|
6
|
-
clientId:
|
|
7
|
-
apiKey:
|
|
6
|
+
clientId: "test-client",
|
|
7
|
+
apiKey: "test-key",
|
|
8
8
|
};
|
|
9
|
-
it(
|
|
9
|
+
it("should construct with required fields", () => {
|
|
10
10
|
const provider = new BaseProvider({
|
|
11
11
|
config,
|
|
12
|
-
path:
|
|
13
|
-
method:
|
|
14
|
-
headers: { foo:
|
|
12
|
+
path: "/resource",
|
|
13
|
+
method: "GET",
|
|
14
|
+
headers: { foo: "bar" },
|
|
15
15
|
});
|
|
16
|
-
expect(provider.baseURL).toBe(
|
|
17
|
-
expect(provider.path).toBe(
|
|
18
|
-
expect(provider.method).toBe(
|
|
19
|
-
expect(provider.headers).toEqual({
|
|
20
|
-
|
|
16
|
+
expect(provider.baseURL).toBe("https://api.example.com");
|
|
17
|
+
expect(provider.path).toBe("/resource");
|
|
18
|
+
expect(provider.method).toBe("GET");
|
|
19
|
+
expect(provider.headers).toEqual({
|
|
20
|
+
foo: "bar",
|
|
21
|
+
"X-Client-Id": "test-client",
|
|
22
|
+
"X-Api-Key": "test-key",
|
|
23
|
+
});
|
|
24
|
+
expect(provider.getPath()).toBe("/resource");
|
|
21
25
|
});
|
|
22
|
-
it(
|
|
26
|
+
it("should use custom getPath if provided", () => {
|
|
23
27
|
const provider = new BaseProvider({
|
|
24
28
|
config,
|
|
25
|
-
path:
|
|
26
|
-
method:
|
|
29
|
+
path: "/resource/:id",
|
|
30
|
+
method: "GET",
|
|
27
31
|
headers: {},
|
|
28
32
|
getPath: (id) => `/resource/${id}`,
|
|
29
33
|
});
|
|
30
|
-
expect(provider.getPath(
|
|
34
|
+
expect(provider.getPath("123")).toBe("/resource/123");
|
|
31
35
|
});
|
|
32
36
|
});
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import { BaseServiceWrapper } from
|
|
2
|
-
import { NetworkingUIEventWrapped } from
|
|
3
|
-
import { of } from
|
|
4
|
-
import { map } from
|
|
5
|
-
describe(
|
|
1
|
+
import { BaseServiceWrapper } from "./base.service.wrapper";
|
|
2
|
+
import { NetworkingUIEventWrapped } from "../types/types";
|
|
3
|
+
import { of } from "rxjs";
|
|
4
|
+
import { map } from "rxjs/operators";
|
|
5
|
+
describe("BaseServiceWrapper Advanced", () => {
|
|
6
6
|
const mockProvider = {
|
|
7
|
-
baseURL:
|
|
8
|
-
path:
|
|
9
|
-
method:
|
|
7
|
+
baseURL: "https://api.example.com",
|
|
8
|
+
path: "/resource",
|
|
9
|
+
method: "GET",
|
|
10
10
|
headers: {},
|
|
11
|
-
getPath: () =>
|
|
11
|
+
getPath: () => "/resource",
|
|
12
12
|
};
|
|
13
|
-
it(
|
|
13
|
+
it("should allow use of RxJS operators", (done) => {
|
|
14
14
|
const wrapper = new BaseServiceWrapper(mockProvider);
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Required for test compatibility
|
|
16
16
|
wrapper.request = (() => of(NetworkingUIEventWrapped.succeeded({ foo: 1 })));
|
|
17
|
-
wrapper
|
|
17
|
+
wrapper
|
|
18
|
+
.request()
|
|
19
|
+
.pipe(map((r) => r.response))
|
|
20
|
+
.subscribe((val) => {
|
|
18
21
|
expect(val).toEqual({ foo: 1 });
|
|
19
22
|
done();
|
|
20
23
|
});
|
|
21
24
|
});
|
|
22
|
-
it(
|
|
25
|
+
it("should handle multiple concurrent requests", (done) => {
|
|
23
26
|
const wrapper = new BaseServiceWrapper(mockProvider);
|
|
24
27
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Required for test compatibility
|
|
25
28
|
wrapper.request = ((payload) => of(NetworkingUIEventWrapped.succeeded({ foo: payload })));
|
|
26
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Required for test compatibility
|
|
27
30
|
const results = [];
|
|
28
|
-
wrapper.request(1).subscribe(r => {
|
|
31
|
+
wrapper.request(1).subscribe((r) => {
|
|
29
32
|
results.push(r.response);
|
|
30
33
|
if (results.length === 1) {
|
|
31
34
|
expect(results[0]).toEqual({ foo: 1 });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ProviderType, NetworkingUIEventWrapped } from
|
|
2
|
-
import { Observable } from
|
|
1
|
+
import { ProviderType, NetworkingUIEventWrapped } from "../types/types";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
3
|
export declare class BaseServiceWrapper<T extends ProviderType> {
|
|
4
4
|
protected provider: T;
|
|
5
5
|
constructor(provider: T);
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { BaseServiceWrapper } from
|
|
2
|
-
import { NetworkingUIEventWrapped } from
|
|
3
|
-
import { of } from
|
|
1
|
+
import { BaseServiceWrapper } from "./base.service.wrapper";
|
|
2
|
+
import { NetworkingUIEventWrapped } from "../types/types";
|
|
3
|
+
import { of } from "rxjs";
|
|
4
4
|
// Mock SmessService for testing
|
|
5
|
-
jest.mock(
|
|
5
|
+
jest.mock("../services/smess.service", () => ({
|
|
6
6
|
SmessService: jest.fn().mockImplementation(() => ({
|
|
7
|
-
request: jest.fn(() => of(NetworkingUIEventWrapped.succeeded({ foo:
|
|
8
|
-
}))
|
|
7
|
+
request: jest.fn(() => of(NetworkingUIEventWrapped.succeeded({ foo: "bar" }))),
|
|
8
|
+
})),
|
|
9
9
|
}));
|
|
10
|
-
describe(
|
|
10
|
+
describe("BaseServiceWrapper", () => {
|
|
11
11
|
const mockProvider = {
|
|
12
|
-
baseURL:
|
|
13
|
-
path:
|
|
14
|
-
method:
|
|
12
|
+
baseURL: "https://api.example.com",
|
|
13
|
+
path: "/resource",
|
|
14
|
+
method: "GET",
|
|
15
15
|
headers: {},
|
|
16
|
-
getPath: () =>
|
|
16
|
+
getPath: () => "/resource",
|
|
17
17
|
};
|
|
18
|
-
it(
|
|
18
|
+
it("should delegate request to SmessService", (done) => {
|
|
19
19
|
const wrapper = new BaseServiceWrapper(mockProvider);
|
|
20
|
-
wrapper.request().subscribe(result => {
|
|
21
|
-
expect(result.response).toEqual({ foo:
|
|
20
|
+
wrapper.request().subscribe((result) => {
|
|
21
|
+
expect(result.response).toEqual({ foo: "bar" });
|
|
22
22
|
done();
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from
|
|
2
|
-
import type { AxiosInterceptorManager } from
|
|
3
|
-
import { AxiosObservable } from
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "../utils/networking-import";
|
|
2
|
+
import type { AxiosInterceptorManager } from "axios";
|
|
3
|
+
import { AxiosObservable } from "./axios.observable";
|
|
4
4
|
export interface Axiosable {
|
|
5
5
|
request<T = unknown>(config: AxiosRequestConfig): AxiosObservable<T>;
|
|
6
6
|
get<T = unknown>(url: string, config?: AxiosRequestConfig): AxiosObservable<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any -- Required for axios compatibility */
|
|
2
|
-
import { axios, } from
|
|
3
|
-
import { createObservable } from
|
|
2
|
+
import { axios, } from "../utils/networking-import";
|
|
3
|
+
import { createObservable } from "./axios.observable";
|
|
4
4
|
class HttpService {
|
|
5
5
|
constructor(axiosInstance) {
|
|
6
6
|
this.axiosInstance = axiosInstance;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export { $logger } from
|
|
1
|
+
export * from "./services/user.service";
|
|
2
|
+
export * from "./services/product.service";
|
|
3
|
+
export * from "./services/auth.service";
|
|
4
|
+
export * from "./services/store.service";
|
|
5
|
+
export * from "./services/customer.service";
|
|
6
|
+
export * from "./services/order.service";
|
|
7
|
+
export * from "./services/cache.service";
|
|
8
|
+
export * from "./services/smess.service";
|
|
9
|
+
export * from "./core/base.provider";
|
|
10
|
+
export * from "./core/base.service.wrapper";
|
|
11
|
+
export * from "./core/axios.observable";
|
|
12
|
+
export * from "./types/types";
|
|
13
|
+
export { $logger } from "./services/logger.service";
|
|
14
14
|
export declare const baseURL: () => string;
|
|
15
15
|
export declare const apiVersion: () => string;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export { $logger } from
|
|
1
|
+
export * from "./services/user.service";
|
|
2
|
+
export * from "./services/product.service";
|
|
3
|
+
export * from "./services/auth.service";
|
|
4
|
+
export * from "./services/store.service";
|
|
5
|
+
export * from "./services/customer.service";
|
|
6
|
+
export * from "./services/order.service";
|
|
7
|
+
export * from "./services/cache.service";
|
|
8
|
+
export * from "./services/smess.service";
|
|
9
|
+
export * from "./core/base.provider";
|
|
10
|
+
export * from "./core/base.service.wrapper";
|
|
11
|
+
export * from "./core/axios.observable";
|
|
12
|
+
export * from "./types/types";
|
|
13
|
+
export { $logger } from "./services/logger.service";
|
|
14
14
|
export const baseURL = () => {
|
|
15
|
-
return
|
|
15
|
+
return "";
|
|
16
16
|
};
|
|
17
17
|
export const apiVersion = () => {
|
|
18
|
-
return
|
|
18
|
+
return "api/v1";
|
|
19
19
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from
|
|
2
|
-
import { SmessService } from
|
|
1
|
+
import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from "../types/types";
|
|
2
|
+
import { SmessService } from "./smess.service";
|
|
3
3
|
import { BehaviorSubject, Observable } from "rxjs";
|
|
4
4
|
export interface AuthLoginRequest {
|
|
5
5
|
identifier: string;
|
|
@@ -22,7 +22,7 @@ export type AuthLoginResponse = {
|
|
|
22
22
|
token: unknown;
|
|
23
23
|
refresh_token: unknown;
|
|
24
24
|
};
|
|
25
|
-
export type AuthTarget =
|
|
25
|
+
export type AuthTarget = "login" | "logout" | "change-password" | "password-forgot" | "reset-password" | "verify-reset-password-token";
|
|
26
26
|
export declare class AuthProvider implements ProviderType {
|
|
27
27
|
private readonly config;
|
|
28
28
|
private readonly target;
|
|
@@ -45,8 +45,9 @@ export interface AuthServiceType {
|
|
|
45
45
|
}
|
|
46
46
|
export declare class AuthService implements AuthServiceType {
|
|
47
47
|
private readonly config;
|
|
48
|
-
|
|
49
|
-
constructor(config: NetworkingConfig
|
|
48
|
+
readonly $authToken: BehaviorSubject<string | null>;
|
|
49
|
+
constructor(config: NetworkingConfig);
|
|
50
|
+
get currentAuthToken(): string | null;
|
|
50
51
|
provider(target: AuthTarget): SmessService<AuthProvider>;
|
|
51
52
|
login(payload: AuthLoginRequest): Observable<NetworkingUIEventWrapped<AuthLoginResponse>>;
|
|
52
53
|
logout(): Observable<NetworkingUIEventWrapped<void>>;
|