@quandis/qbo4.ui 4.0.1-CI-20241022-165449 → 4.0.1-CI-20241022-200944
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/qbo/RestApiService.d.ts +1 -1
- package/src/qbo/RestApiService.js +5 -0
- package/src/qbo/RestApiService.ts +7 -1
- package/wwwroot/js/esm/qbo4.ui.js +6 -1
- package/wwwroot/js/esm/qbo4.ui.min.js +1 -1
- package/wwwroot/js/esm/qbo4.ui.min.js.map +1 -1
- package/wwwroot/js/qbo4.ui.js +6 -1
- package/wwwroot/js/qbo4.ui.min.js +1 -1
- package/wwwroot/js/qbo4.ui.min.js.map +1 -1
package/package.json
CHANGED
|
@@ -9,4 +9,4 @@ export declare class RestApiService implements IApiService {
|
|
|
9
9
|
clone(relativePath: string | null): IApiService;
|
|
10
10
|
}
|
|
11
11
|
export declare function registerRestApi(name: string, apiEndpoint: string, headers?: HeadersInit, method?: string | null): void;
|
|
12
|
-
export declare function getApiService(url: string): IApiService;
|
|
12
|
+
export declare function getApiService(url: string | URL): IApiService;
|
|
@@ -8,6 +8,8 @@ export class RestApiService {
|
|
|
8
8
|
this.method = method;
|
|
9
9
|
}
|
|
10
10
|
async fetch(relativePath, payload) {
|
|
11
|
+
if (this.apiEndpoint.indexOf("//") < 1)
|
|
12
|
+
this.apiEndpoint = new URL(this.apiEndpoint, document.location.origin).href;
|
|
11
13
|
const endpoint = substitute(new URL(relativePath ?? this.relativePath, this.apiEndpoint).href, payload);
|
|
12
14
|
const method = this.method ?? (payload ? 'POST' : 'GET');
|
|
13
15
|
const headers = new Headers(this.headers || {});
|
|
@@ -44,6 +46,9 @@ export function registerRestApi(name, apiEndpoint, headers = { 'Content-Type': '
|
|
|
44
46
|
services.container.registerInstance(name, new RestApiService(apiEndpoint, headers, method));
|
|
45
47
|
}
|
|
46
48
|
export function getApiService(url) {
|
|
49
|
+
if (typeof url !== 'string') {
|
|
50
|
+
url = url.href;
|
|
51
|
+
}
|
|
47
52
|
const parts = url.match(/api:\/\/([^/]+)/);
|
|
48
53
|
const name = parts ? parts[1] : url;
|
|
49
54
|
const relativePath = parts ? url.substring(`api://${name}`.length + 1) : '';
|
|
@@ -16,6 +16,9 @@ export class RestApiService implements IApiService {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async fetch(relativePath: string | null, payload?: Record<string, string> | null | undefined): Promise<any> {
|
|
19
|
+
|
|
20
|
+
if (this.apiEndpoint.indexOf("//") < 1)
|
|
21
|
+
this.apiEndpoint = new URL(this.apiEndpoint, document.location.origin).href;
|
|
19
22
|
const endpoint = substitute(new URL(relativePath ?? this.relativePath, this.apiEndpoint).href, payload);
|
|
20
23
|
const method = this.method ?? (payload ? 'POST' : 'GET');
|
|
21
24
|
const headers = new Headers(this.headers || {});
|
|
@@ -57,7 +60,10 @@ export function registerRestApi(name: string, apiEndpoint: string, headers: Head
|
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
|
|
60
|
-
export function getApiService(url: string) {
|
|
63
|
+
export function getApiService(url: string | URL) {
|
|
64
|
+
if (typeof url !== 'string') {
|
|
65
|
+
url = url.href;
|
|
66
|
+
}
|
|
61
67
|
const parts = url.match(/api:\/\/([^/]+)/);
|
|
62
68
|
const name = parts ? parts[1] : url;
|
|
63
69
|
const relativePath = parts ? url.substring(`api://${name}`.length + 1) : '';
|