@quandis/qbo4.ui 4.0.1-CI-20240429-215003 → 4.0.1-CI-20240429-225952
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/readme.md +0 -1
- package/src/qbo/IApiService.d.ts +1 -0
- package/src/qbo/IApiService.ts +3 -0
- package/src/qbo/Program.js +1 -6
- package/src/qbo/Program.ts +1 -6
- package/src/qbo/RestApiService.d.ts +1 -0
- package/src/qbo/RestApiService.js +5 -0
- package/src/qbo/RestApiService.ts +6 -0
- package/wwwroot/js/qbo4.ui.js +7 -7
- package/wwwroot/js/qbo4.ui.min.js +2 -2
- package/wwwroot/js/qbo4.ui.min.js.map +1 -1
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -69,7 +69,6 @@ In this example, the `qms` is cloned in `getApiService`, and the `relativePath`
|
|
|
69
69
|
You can write your own `IApiService` class, and register it to qbo's DI container:
|
|
70
70
|
|
|
71
71
|
```typescript
|
|
72
|
-
import { services } from "@quandis/qbo4.logging";
|
|
73
72
|
import { services, IApiService } from "@quandis/qbo4.ui";
|
|
74
73
|
|
|
75
74
|
@injectable()
|
package/src/qbo/IApiService.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface IApiService {
|
|
|
13
13
|
* @param payload The payload to send to the API.
|
|
14
14
|
*/
|
|
15
15
|
fetch(relativePath: string | null, payload: Record<string, string> | null): Promise<any>;
|
|
16
|
+
clone(relativePath: string | null): IApiService;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Define a token for the IApiService interface
|
package/src/qbo/IApiService.ts
CHANGED
package/src/qbo/Program.js
CHANGED
|
@@ -116,10 +116,5 @@ export function getApiService(url) {
|
|
|
116
116
|
const service = services.container.isRegistered(name)
|
|
117
117
|
? services.container.resolve(name)
|
|
118
118
|
: new RestApiService(url);
|
|
119
|
-
|
|
120
|
-
const clone = structuredClone(service);
|
|
121
|
-
clone.relativePath = relativePath;
|
|
122
|
-
return clone;
|
|
123
|
-
}
|
|
124
|
-
return service;
|
|
119
|
+
return (relativePath) ? service.clone(relativePath) : service;
|
|
125
120
|
}
|
package/src/qbo/Program.ts
CHANGED
|
@@ -125,10 +125,5 @@ export function getApiService(url: string) {
|
|
|
125
125
|
? services.container.resolve<IApiService>(name)
|
|
126
126
|
: new RestApiService(url);
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
const clone = structuredClone(service);
|
|
130
|
-
clone.relativePath = relativePath;
|
|
131
|
-
return clone;
|
|
132
|
-
}
|
|
133
|
-
return service;
|
|
128
|
+
return (relativePath) ? service.clone(relativePath) : service;
|
|
134
129
|
}
|
|
@@ -6,5 +6,6 @@ export declare class RestApiService implements IApiService {
|
|
|
6
6
|
relativePath: string;
|
|
7
7
|
constructor(apiEndpoint: string, headers?: HeadersInit, method?: string | null);
|
|
8
8
|
fetch(relativePath: string | null, payload?: Record<string, string> | null): Promise<any>;
|
|
9
|
+
clone(relativePath: string | null): IApiService;
|
|
9
10
|
}
|
|
10
11
|
export declare function registerRestApi(name: string, apiEndpoint: string, headers?: HeadersInit, method?: string | null): void;
|
|
@@ -24,6 +24,11 @@ export class RestApiService {
|
|
|
24
24
|
}
|
|
25
25
|
return response.json();
|
|
26
26
|
}
|
|
27
|
+
clone(relativePath) {
|
|
28
|
+
const clone = new RestApiService(this.apiEndpoint, this.headers, this.method);
|
|
29
|
+
clone.relativePath = relativePath ?? '';
|
|
30
|
+
return clone;
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
33
|
// Register a RestApiService with the default name 'default' and the base URL of the current page
|
|
29
34
|
services.container.registerInstance('default', new RestApiService(document.querySelector('base[href]')?.getAttribute('href') || window.location.origin));
|
|
@@ -35,6 +35,12 @@ export class RestApiService implements IApiService {
|
|
|
35
35
|
|
|
36
36
|
return response.json();
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
clone(relativePath: string | null): IApiService {
|
|
40
|
+
const clone = new RestApiService(this.apiEndpoint, this.headers, this.method);
|
|
41
|
+
clone.relativePath = relativePath ?? '';
|
|
42
|
+
return clone;
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
// Register a RestApiService with the default name 'default' and the base URL of the current page
|