@rws-framework/client 2.22.0 → 2.23.0
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 +160 -872
- package/builder/webpack/loaders/rws_fast_ts_loader.js +14 -21
- package/cfg/build_steps/webpack/_loaders.js +136 -7
- package/package.json +1 -1
- package/src/components/_component.ts +30 -45
- package/src/components/_css_injection.ts +187 -0
- package/src/events.ts +3 -0
- package/src/index.ts +8 -6
- package/src/services/ApiService.ts +11 -8
- package/src/services/DOMService.ts +1 -1
- package/src/services/_api/backend.ts +41 -9
- package/src/types/IRWSViewComponent.ts +2 -2
- package/src/types/IBackendCore.ts +0 -12
- package/src/types/IRWSResource.ts +0 -5
- package/src/types/IReFormerField.ts +0 -5
|
@@ -2,7 +2,7 @@ import { ApiServiceInstance, IBackendRoute, IHTTProute } from "../ApiService";
|
|
|
2
2
|
import { ConfigServiceInstance } from "../ConfigService";
|
|
3
3
|
|
|
4
4
|
export const backend = {
|
|
5
|
-
getBackendUrl(this: ApiServiceInstance, routeName: string, params: {[key: string]: string} = {}): string
|
|
5
|
+
getBackendUrl(this: ApiServiceInstance, routeName: string, params: {[key: string]: string} = {}, queryParams: {[key: string]: string} = {}): string
|
|
6
6
|
{
|
|
7
7
|
const config = this.config;
|
|
8
8
|
const routesPackage = config.get('backendRoutes');
|
|
@@ -43,13 +43,12 @@ export const backend = {
|
|
|
43
43
|
];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
routes = [...routes, ...item.routes.map((subRouteItem: IHTTProute): IHTTProute => {
|
|
47
47
|
const subRoute: IHTTProute = {
|
|
48
|
-
path: item.prefix + subRouteItem.path,
|
|
48
|
+
path: Array.isArray(subRouteItem.path) ? subRouteItem.path.map(subPath => item.prefix + subPath) : item.prefix + subRouteItem.path,
|
|
49
49
|
name: backend.checkPrefixedRouteName(subRouteItem.name, item.controllerName),
|
|
50
50
|
method: subRouteItem.method || 'GET'
|
|
51
|
-
};
|
|
52
|
-
|
|
51
|
+
};
|
|
53
52
|
return subRoute;
|
|
54
53
|
})];
|
|
55
54
|
|
|
@@ -65,15 +64,48 @@ export const backend = {
|
|
|
65
64
|
throw new Error(`Backend route '${routeName}' does not exist.`);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
let apiPath = route.path;
|
|
67
|
+
let apiPath: string | string[] = route.path;
|
|
68
|
+
|
|
69
|
+
if(Array.isArray(apiPath)){
|
|
70
|
+
const paramsLength = Object.keys(params).length;
|
|
71
|
+
if(paramsLength > 0){
|
|
72
|
+
for(const searchedPath of apiPath){
|
|
73
|
+
let foundParams = 0;
|
|
74
|
+
for(const p of Object.keys(params)){
|
|
75
|
+
if(searchedPath.indexOf(`:${p}`) !== -1){
|
|
76
|
+
foundParams++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if(foundParams === paramsLength){
|
|
81
|
+
apiPath = searchedPath;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}else{
|
|
86
|
+
for(const searchedPath of apiPath){
|
|
87
|
+
if(!searchedPath.includes(':')){
|
|
88
|
+
apiPath = searchedPath;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
69
94
|
|
|
70
95
|
Object.keys(params).forEach((paramKey: string) => {
|
|
71
96
|
const paramValue = params[paramKey];
|
|
72
97
|
|
|
73
|
-
apiPath = apiPath.replace(`:${paramKey}`, paramValue);
|
|
74
|
-
});
|
|
98
|
+
apiPath = (apiPath as string).replace(`:${paramKey}`, paramValue);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
let finalUrl = `${config.get('backendUrl')}${config.get('apiPrefix') || ''}${apiPath}`;
|
|
102
|
+
|
|
103
|
+
if(Object.keys(queryParams).length > 0){
|
|
104
|
+
const queryString = new URLSearchParams(queryParams).toString();
|
|
105
|
+
finalUrl += `?${queryString}`;
|
|
106
|
+
}
|
|
75
107
|
|
|
76
|
-
return
|
|
108
|
+
return finalUrl;
|
|
77
109
|
},
|
|
78
110
|
checkPrefixedRouteName(routeName: string, prefixName: string){
|
|
79
111
|
let finalRoute = routeName;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ViewTemplate } from '@microsoft/fast-element';
|
|
1
|
+
import { FASTElement, ViewTemplate } from '@microsoft/fast-element';
|
|
2
2
|
import { DOMOutputType } from '../services/DOMService';
|
|
3
3
|
|
|
4
4
|
type IAssetShowOptions = Record<string, any>;
|
|
5
5
|
|
|
6
|
-
interface IRWSViewComponent extends
|
|
6
|
+
interface IRWSViewComponent extends FASTElement {
|
|
7
7
|
__isLoading: boolean;
|
|
8
8
|
routeParams: Record<string, string>;
|
|
9
9
|
trashIterator: number;
|