jsf.js_next_gen 4.0.0-beta-23 → 4.0.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/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
- package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
- package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
- package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/README.md +7 -22
- package/dist/docs/assets/main.js +56 -52
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/assets/style.css +23 -0
- package/dist/docs/functions/faces.ajax.addOnError.html +6 -4
- package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
- package/dist/docs/functions/faces.ajax.request.html +7 -7
- package/dist/docs/functions/faces.ajax.response.html +0 -1
- package/dist/docs/functions/faces.push.close.html +4 -2
- package/dist/docs/functions/faces.push.init.html +19 -7
- package/dist/docs/functions/faces.push.open.html +4 -2
- package/dist/docs/functions/faces.util.chain.html +3 -3
- package/dist/docs/functions/myfaces.ab.html +9 -4
- package/dist/docs/functions/myfaces.onOnDomReady.html +72 -0
- package/dist/docs/index.html +7 -18
- package/dist/docs/modules/myfaces.html +3 -1
- package/dist/docs/variables/myfaces.oam.html +2 -1
- package/dist/window/faces-development.js +2147 -1779
- package/dist/window/faces-development.js.br +0 -0
- package/dist/window/faces-development.js.gz +0 -0
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.LICENSE.txt +17 -2
- package/dist/window/faces.js.br +0 -0
- package/dist/window/faces.js.gz +0 -0
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +2156 -1777
- package/dist/window/jsf-development.js.br +0 -0
- package/dist/window/jsf-development.js.gz +0 -0
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.LICENSE.txt +17 -2
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/dist/window/jsf.js.map +1 -1
- package/package.json +19 -18
- package/pom.xml +1 -1
- package/src/main/test.xml +23 -0
- package/src/main/typescript/@types/definitions/index.d.ts +24 -7
- package/src/main/typescript/api/_api.ts +79 -37
- package/src/main/typescript/api/jsf.ts +18 -0
- package/src/main/typescript/impl/AjaxImpl.ts +168 -78
- package/src/main/typescript/impl/PushImpl.ts +63 -38
- package/src/main/typescript/impl/core/Const.ts +52 -39
- package/src/main/typescript/impl/util/Assertions.ts +16 -8
- package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
- package/src/main/typescript/impl/util/AsyncRunnable.ts +4 -4
- package/src/main/typescript/impl/util/ExtDomQuery.ts +58 -45
- package/src/main/typescript/impl/util/FileUtils.ts +104 -0
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +89 -0
- package/src/main/typescript/impl/util/Lang.ts +30 -31
- package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +25 -11
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +78 -32
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +10 -10
- package/src/main/typescript/impl/xhrCore/Response.ts +66 -49
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +202 -131
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +79 -166
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +80 -68
- package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +19 -22
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +108 -1
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
- package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
- package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
- package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
- package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
- package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +242 -11
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +373 -35
- package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
- package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +109 -0
- package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
- package/src/main/typescript/test.xml +6 -0
- package/src/main/typescript/tsconfig.json +1 -1
- package/src/test/resources/jsf-development.js +1 -1
- package/src/tmp/test.html +12 -88
- package/target/api/_api.js +72 -31
- package/target/api/_api.js.map +1 -1
- package/target/api/jsf.js +11 -0
- package/target/api/jsf.js.map +1 -1
- package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
- package/target/impl/AjaxImpl.js +144 -59
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/PushImpl.js +66 -35
- package/target/impl/PushImpl.js.map +1 -1
- package/target/impl/core/Const.js +51 -38
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/core/Context.js +10 -0
- package/target/impl/core/Context.js.map +1 -0
- package/target/impl/util/Assertions.js +12 -7
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +58 -40
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/FileUtils.js +96 -0
- package/target/impl/util/FileUtils.js.map +1 -0
- package/target/impl/util/HiddenElementBuilder.js +7 -0
- package/target/impl/util/HiddenElementBuilder.js.map +1 -0
- package/target/impl/util/HiddenInputBuilder.js +79 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/impl/util/Lang.js +29 -30
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/util/URLCodec.js +77 -0
- package/target/impl/util/URLCodec.js.map +1 -0
- package/target/impl/util/XhrQueueController.js +82 -0
- package/target/impl/util/XhrQueueController.js.map +1 -0
- package/target/impl/xhrCore/ErrorData.js +10 -8
- package/target/impl/xhrCore/ErrorData.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +1 -1
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/RequestContext.js +11 -0
- package/target/impl/xhrCore/RequestContext.js.map +1 -0
- package/target/impl/xhrCore/RequestDataResolver.js +70 -23
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +9 -9
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +44 -29
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +182 -116
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +68 -156
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrQueHandler.js +11 -0
- package/target/impl/xhrCore/XhrQueHandler.js.map +1 -0
- package/target/impl/xhrCore/XhrQueueController.js +62 -0
- package/target/impl/xhrCore/XhrQueueController.js.map +1 -0
- package/target/impl/xhrCore/XhrRequest.js +68 -59
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +23 -14
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +16 -16
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js +76 -0
- package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js.map +1 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +925 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +1 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +112 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +1 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +100 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +2 -2
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/ImplTest_23.spec.js +2 -2
- package/target/test/impl/ImplTest_23.spec.js.map +1 -1
- package/target/test/myfaces/OnLoadSpec.js +57 -0
- package/target/test/myfaces/OnLoadSpec.js.map +1 -0
- package/target/test/xhrCore/EventTests.spec.js +1 -1
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/FileUploadTest.spec.js +2 -1
- package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
- package/target/test/xhrCore/RequestParamsTest.spec.js +142 -10
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +217 -9
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +34 -2
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +308 -24
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +38 -8
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js +128 -0
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -0
- package/target/test/xhrCore/XhrFormDataTest.spec.js +57 -34
- package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
- package/target/test-classes/.gz +0 -0
- package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
- package/target/test-classes/fileuploadtest.html +24 -0
- package/target/test-classes/jsf-development.js +3559 -0
- package/target/test-classes/jsf-development.js.br +0 -0
- package/target/test-classes/jsf-development.js.gz +0 -0
- package/target/test-classes/jsf-development.js.map +1 -0
- package/target/test-classes/jsf.js +3 -0
- package/target/test-classes/jsf.js.br +0 -0
- package/target/test-classes/jsf.js.gz +0 -0
- package/tmp.xml +36 -0
- package/.nyc_output/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
- package/.nyc_output/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
- package/.nyc_output/processinfo/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
- package/.nyc_output/processinfo/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
- package/target/types/index.js +0 -18
- package/target/types/index.js.map +0 -1
|
@@ -39,9 +39,12 @@ const IS_FACES_SOURCE = (source?: string): boolean => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* namespace myfaces
|
|
43
|
-
* tests, those will be handled similarly to faces.js
|
|
44
|
-
* reload blocking on ajax requests
|
|
42
|
+
* namespace myfaces\.testscripts can be used as extension point for internal
|
|
43
|
+
* tests, those will be handled similarly to faces.js, in regard
|
|
44
|
+
* to reload blocking on ajax requests
|
|
45
|
+
*
|
|
46
|
+
* Note: atm not used, used to be used in the old implementation
|
|
47
|
+
* but still is reserved for now
|
|
45
48
|
*
|
|
46
49
|
* @param source the source to check
|
|
47
50
|
* @constructor
|
|
@@ -55,21 +58,21 @@ const ATTR_SRC = 'src';
|
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
60
|
* Extension which adds implementation specific
|
|
58
|
-
* meta
|
|
61
|
+
* meta-data to our dom query
|
|
59
62
|
*
|
|
60
63
|
* Usage
|
|
61
64
|
* el = new ExtDQ(oldReference)
|
|
62
65
|
* nonce = el.nonce
|
|
63
66
|
* windowId = el.getWindowId
|
|
64
67
|
*/
|
|
65
|
-
export class
|
|
68
|
+
export class ExtDomQuery extends DQ {
|
|
66
69
|
|
|
67
70
|
static get windowId() {
|
|
68
|
-
return new
|
|
71
|
+
return new ExtDomQuery(document.body).windowId;
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
static get nonce(): string {
|
|
72
|
-
return new
|
|
75
|
+
return new ExtDomQuery(document.body).nonce;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
get windowId(): string | null {
|
|
@@ -112,7 +115,7 @@ export class ExtDomquery extends DQ {
|
|
|
112
115
|
let curScript = new DQ(document.currentScript);
|
|
113
116
|
//since our baseline atm is ie11 we cannot use document.currentScript globally
|
|
114
117
|
if (!!this.extractNonce(curScript)) {
|
|
115
|
-
//
|
|
118
|
+
// fast-path for modern browsers
|
|
116
119
|
return this.extractNonce(curScript);
|
|
117
120
|
}
|
|
118
121
|
// fallback if the currentScript method fails, we just search the jsf tags for nonce, this is
|
|
@@ -130,26 +133,20 @@ export class ExtDomquery extends DQ {
|
|
|
130
133
|
return null;
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
private extractNonce(curScript: DomQuery) {
|
|
136
|
-
return (curScript.getAsElem(0).value as HTMLElement)?.nonce ?? curScript.attr("nonce").value;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
136
|
static searchJsfJsFor(item: RegExp): Optional<String> {
|
|
140
|
-
return new
|
|
137
|
+
return new ExtDomQuery(document).searchJsfJsFor(item);
|
|
141
138
|
}
|
|
142
139
|
|
|
143
140
|
/**
|
|
144
|
-
* searches the embedded faces.js for items like separator char etc
|
|
141
|
+
* searches the embedded faces.js for items like separator char etc.
|
|
145
142
|
* expects a match as variable under position 1 in the result match
|
|
146
|
-
* @param
|
|
143
|
+
* @param regExp
|
|
147
144
|
*/
|
|
148
|
-
searchJsfJsFor(
|
|
145
|
+
searchJsfJsFor(regExp: RegExp): Optional<string> {
|
|
149
146
|
//perfect application for lazy stream
|
|
150
147
|
return DQ.querySelectorAll("script[src], link[src]").lazyStream
|
|
151
148
|
.filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))
|
|
152
|
-
.map(item => item.attr(ATTR_SRC).value.match(
|
|
149
|
+
.map(item => item.attr(ATTR_SRC).value.match(regExp))
|
|
153
150
|
.filter(item => item != null && item.length > 1)
|
|
154
151
|
.map((result: string[]) => {
|
|
155
152
|
return decodeURIComponent(result[1]);
|
|
@@ -157,22 +154,24 @@ export class ExtDomquery extends DQ {
|
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
globalEval(code: string, nonce ?: string): DQ {
|
|
160
|
-
return new
|
|
157
|
+
return new ExtDomQuery(super.globalEval(code, nonce ?? this.nonce));
|
|
161
158
|
}
|
|
162
159
|
|
|
160
|
+
// called from base class runScripts, do not delete
|
|
161
|
+
// noinspection JSUnusedGlobalSymbols
|
|
163
162
|
globalEvalSticky(code: string, nonce ?: string): DQ {
|
|
164
|
-
return new
|
|
163
|
+
return new ExtDomQuery(super.globalEvalSticky(code, nonce ?? this.nonce));
|
|
165
164
|
}
|
|
166
165
|
|
|
167
166
|
/**
|
|
168
167
|
* decorated run scripts which takes our jsf extensions into consideration
|
|
169
168
|
* (standard DomQuery will let you pass anything)
|
|
170
169
|
* @param sticky if set to true the internally generated element for the script is left in the dom
|
|
171
|
-
* @param
|
|
170
|
+
* @param whiteListed
|
|
172
171
|
*/
|
|
173
|
-
runScripts(sticky = false,
|
|
172
|
+
runScripts(sticky = false, whiteListed?: (src: string) => boolean): DomQuery {
|
|
174
173
|
const whitelistFunc = (src: string): boolean => {
|
|
175
|
-
return (
|
|
174
|
+
return (whiteListed?.(src) ?? true) && !IS_FACES_SOURCE(src) && !IS_INTERNAL_SOURCE(src);
|
|
176
175
|
};
|
|
177
176
|
return super.runScripts(sticky, whitelistFunc);
|
|
178
177
|
}
|
|
@@ -183,7 +182,7 @@ export class ExtDomquery extends DQ {
|
|
|
183
182
|
* @param suppressDoubleIncludes checks for existing elements in the head before running the insert
|
|
184
183
|
*/
|
|
185
184
|
runHeadInserts(suppressDoubleIncludes = true): void {
|
|
186
|
-
let head =
|
|
185
|
+
let head = ExtDomQuery.byId(document.head);
|
|
187
186
|
//automated nonce handling
|
|
188
187
|
let processedScripts = [];
|
|
189
188
|
|
|
@@ -197,12 +196,13 @@ export class ExtDomquery extends DQ {
|
|
|
197
196
|
}
|
|
198
197
|
const tagName = element.tagName.value;
|
|
199
198
|
if(!tagName) {
|
|
200
|
-
//
|
|
199
|
+
// text node they do not have tag names, so we can process them as they are without
|
|
200
|
+
// any further ado
|
|
201
201
|
return true;
|
|
202
202
|
}
|
|
203
203
|
let reference = element.attr("href")
|
|
204
|
-
.
|
|
205
|
-
.
|
|
204
|
+
.orElseLazy(() => element.attr("src").value)
|
|
205
|
+
.orElseLazy(() => element.attr("rel").value);
|
|
206
206
|
|
|
207
207
|
if (!reference.isPresent()) {
|
|
208
208
|
return true;
|
|
@@ -217,14 +217,14 @@ export class ExtDomquery extends DQ {
|
|
|
217
217
|
.each(element => {
|
|
218
218
|
if(element.tagName.value != "SCRIPT") {
|
|
219
219
|
//we need to run runScripts properly to deal with the rest
|
|
220
|
-
new
|
|
220
|
+
new ExtDomQuery(...processedScripts).runScripts(true);
|
|
221
221
|
processedScripts = [];
|
|
222
222
|
head.append(element);
|
|
223
223
|
} else {
|
|
224
224
|
processedScripts.push(element);
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
|
-
new
|
|
227
|
+
new ExtDomQuery(...processedScripts).runScripts(true);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
|
|
@@ -235,15 +235,21 @@ export class ExtDomquery extends DQ {
|
|
|
235
235
|
* @param deep whether the search should go into embedded shadow dom elements
|
|
236
236
|
* @return a DomQuery containing the found elements
|
|
237
237
|
*/
|
|
238
|
-
static byId(selector: string | DomQuery | Element, deep = false):
|
|
238
|
+
static byId(selector: string | DomQuery | Element, deep = false): ExtDomQuery {
|
|
239
239
|
const ret = DomQuery.byId(selector, deep);
|
|
240
|
-
return new
|
|
240
|
+
return new ExtDomQuery(ret);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
private extractNonce(curScript: DomQuery) {
|
|
244
|
+
return (curScript.getAsElem(0).value as HTMLElement)?.nonce ?? curScript.attr("nonce").value;
|
|
245
|
+
}
|
|
243
246
|
|
|
247
|
+
filter(func: (item: DomQuery) => boolean): ExtDomQuery {
|
|
248
|
+
return new ExtDomQuery(super.filter(func));
|
|
249
|
+
}
|
|
244
250
|
}
|
|
245
251
|
|
|
246
|
-
export const ExtDQ =
|
|
252
|
+
export const ExtDQ = ExtDomQuery;
|
|
247
253
|
|
|
248
254
|
/**
|
|
249
255
|
* in order to reduce the number of interception points for the fallbacks we add
|
|
@@ -251,18 +257,20 @@ export const ExtDQ = ExtDomquery;
|
|
|
251
257
|
*/
|
|
252
258
|
export class ExtConfig extends Config {
|
|
253
259
|
|
|
260
|
+
$nspEnabled = true;
|
|
261
|
+
|
|
254
262
|
constructor(root: any) {
|
|
255
263
|
super(root);
|
|
256
264
|
}
|
|
257
265
|
|
|
258
266
|
assignIf(condition: boolean, ...accessPath): IValueHolder<any> {
|
|
259
|
-
const
|
|
260
|
-
return super.assignIf(condition, ...
|
|
267
|
+
const accessPathMapped = this.remap(accessPath);
|
|
268
|
+
return super.assignIf(condition, ...accessPathMapped);
|
|
261
269
|
}
|
|
262
270
|
|
|
263
271
|
assign(...accessPath): IValueHolder<any> {
|
|
264
|
-
const
|
|
265
|
-
return super.assign(...
|
|
272
|
+
const accessPathMapped = this.remap(accessPath);
|
|
273
|
+
return super.assign(...accessPathMapped);
|
|
266
274
|
}
|
|
267
275
|
|
|
268
276
|
append(...accessPath): IValueHolder<any> {
|
|
@@ -270,13 +278,13 @@ export class ExtConfig extends Config {
|
|
|
270
278
|
}
|
|
271
279
|
|
|
272
280
|
appendIf(condition: boolean, ...accessPath): IValueHolder<any> {
|
|
273
|
-
const
|
|
274
|
-
return super.appendIf(condition, ...
|
|
281
|
+
const accessPathMapped = this.remap(accessPath);
|
|
282
|
+
return super.appendIf(condition, ...accessPathMapped);
|
|
275
283
|
}
|
|
276
284
|
|
|
277
285
|
getIf(...accessPath): Config {
|
|
278
|
-
const
|
|
279
|
-
return super.getIf(...
|
|
286
|
+
const accessPathMapped = this.remap(accessPath);
|
|
287
|
+
return super.getIf(...accessPathMapped);
|
|
280
288
|
}
|
|
281
289
|
|
|
282
290
|
get(defaultVal: any): Config {
|
|
@@ -315,10 +323,15 @@ export class ExtConfig extends Config {
|
|
|
315
323
|
return new ExtConfig(super.deepCopy$());
|
|
316
324
|
}
|
|
317
325
|
|
|
318
|
-
|
|
319
|
-
|
|
326
|
+
/**
|
|
327
|
+
* helper to remap the namespaces of an array of access paths
|
|
328
|
+
* @param accessPath the access paths to be remapped
|
|
329
|
+
* @private returns an array of access paths with version remapped namespaces
|
|
330
|
+
*/
|
|
331
|
+
private remap(accessPath: string[]): string[] {
|
|
332
|
+
if(!this.$nspEnabled) {
|
|
333
|
+
return accessPath;
|
|
334
|
+
}
|
|
320
335
|
return Stream.of(...accessPath).map(key => $nsp(key)).collect(new ArrayCollector());
|
|
321
336
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
337
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {ArrayCollector, Config, DomQuery, DQ, LazyStream, Stream} from "mona-dish";
|
|
2
|
+
import {ExtDomQuery} from "./ExtDomQuery";
|
|
3
|
+
import {$faces, EMPTY_STR} from "../core/Const";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* various routines for encoding and decoding url parameters
|
|
7
|
+
* into configs and vice versa
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* encodes a given form data into a url encoded string
|
|
13
|
+
* @param formData the form data config object
|
|
14
|
+
* @param paramsMapper the params mapper
|
|
15
|
+
* @param defaultStr a default string if nothing comes out of it
|
|
16
|
+
*/
|
|
17
|
+
export function encodeFormData(formData: Config,
|
|
18
|
+
paramsMapper = (inStr, inVal) => [inStr, inVal],
|
|
19
|
+
defaultStr = EMPTY_STR): string {
|
|
20
|
+
if (formData.isAbsent()) {
|
|
21
|
+
return defaultStr;
|
|
22
|
+
}
|
|
23
|
+
const assocValues = formData.value;
|
|
24
|
+
|
|
25
|
+
const expandValueArrAndRename = key => Stream.of(...assocValues[key]).map(val => paramsMapper(key, val));
|
|
26
|
+
const isPropertyKey = key => assocValues.hasOwnProperty(key);
|
|
27
|
+
const isNotFile = ([, value]) => !(value instanceof ExtDomQuery.global().File);
|
|
28
|
+
const mapIntoUrlParam = keyVal => `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
|
|
29
|
+
|
|
30
|
+
const entries = LazyStream.of(...Object.keys(assocValues))
|
|
31
|
+
.filter(isPropertyKey)
|
|
32
|
+
.flatMap(expandValueArrAndRename)
|
|
33
|
+
//we cannot encode file elements that is handled by multipart requests anyway
|
|
34
|
+
.filter(isNotFile)
|
|
35
|
+
.map(mapIntoUrlParam)
|
|
36
|
+
.collect(new ArrayCollector());
|
|
37
|
+
|
|
38
|
+
return entries.join("&")
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* splits and decodes encoded values into strings containing of key=value
|
|
43
|
+
* @param encoded encoded string
|
|
44
|
+
*/
|
|
45
|
+
export function decodeEncodedValues(encoded: string): Stream<string[]> {
|
|
46
|
+
const filterBlanks = item => !!(item || '').replace(/\s+/g, '');
|
|
47
|
+
const splitKeyValuePair = line => {
|
|
48
|
+
let index = line.indexOf("=");
|
|
49
|
+
if (index == -1) {
|
|
50
|
+
return [line];
|
|
51
|
+
}
|
|
52
|
+
return [line.substring(0, index), line.substring(index + 1)];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
let requestParamEntries = decodeURIComponent(encoded).split(/&/gi);
|
|
56
|
+
return Stream.of(...requestParamEntries)
|
|
57
|
+
.filter(filterBlanks)
|
|
58
|
+
.map(splitKeyValuePair)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* gets all the input files and their corresponding file objects
|
|
64
|
+
* @param dataSource
|
|
65
|
+
*/
|
|
66
|
+
export function resolveFiles(dataSource: DQ): Stream<[string, File]> {
|
|
67
|
+
|
|
68
|
+
const expandFilesArr = ([key, files]) => Stream.of(...files).map(file => [key, file]);
|
|
69
|
+
const remapFileInput = fileInput => [fileInput.name.value || fileInput.id.value, fileInput.filesFromElem(0)];
|
|
70
|
+
return dataSource
|
|
71
|
+
.querySelectorAllDeep("input[type='file']")
|
|
72
|
+
.stream
|
|
73
|
+
.map(remapFileInput)
|
|
74
|
+
.flatMap(expandFilesArr);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
export function fixEmmptyParameters(keyVal: any[]): [string, any] {
|
|
79
|
+
return (keyVal.length < 3 ? [keyVal?.[0] ?? [], keyVal?.[1] ?? []] : keyVal) as [string, any];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* returns the decoded viewState from parentItem
|
|
84
|
+
* @param parentItem
|
|
85
|
+
*/
|
|
86
|
+
function resolveViewState(parentItem: DomQuery): Stream<string[] | [string, File]> {
|
|
87
|
+
const viewStateStr = $faces().getViewState(parentItem.getAsElem(0).value);
|
|
88
|
+
|
|
89
|
+
// we now need to decode it and then merge it into the target buf
|
|
90
|
+
// which hosts already our overrides (aka do not override what is already there(
|
|
91
|
+
// after that we need to deal with form elements on a separate level
|
|
92
|
+
return decodeEncodedValues(viewStateStr);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* gets all the inputs under the form parentItem
|
|
97
|
+
* as stream
|
|
98
|
+
* @param parentItem
|
|
99
|
+
*/
|
|
100
|
+
export function getFormInputsAsStream(parentItem: DomQuery): Stream<string[] | [string, File]> {
|
|
101
|
+
const standardInputs = resolveViewState(parentItem);
|
|
102
|
+
const fileInputs = resolveFiles(parentItem);
|
|
103
|
+
return standardInputs.concat(fileInputs as any)
|
|
104
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*! Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
3
|
+
* this work for additional information regarding copyright ownership.
|
|
4
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
5
|
+
* (the "License"); you may not use this file except in compliance with
|
|
6
|
+
* the License. You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {DomQuery, DQ, DQ$} from "mona-dish";
|
|
19
|
+
import {$faces, $nsp, HTML_CLIENT_WINDOW, HTML_VIEWSTATE, P_CLIENT_WINDOW, P_VIEWSTATE} from "../core/Const";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builder for hidden inputs.
|
|
23
|
+
* ATM only ViewState and Client window
|
|
24
|
+
* are supported (per spec)
|
|
25
|
+
*
|
|
26
|
+
* Improves readability in the response processor!
|
|
27
|
+
*/
|
|
28
|
+
export class HiddenInputBuilder {
|
|
29
|
+
private namingContainerId?: string;
|
|
30
|
+
private parent?: DomQuery;
|
|
31
|
+
private namedViewRoot: boolean = false;
|
|
32
|
+
private readonly name: string;
|
|
33
|
+
private readonly template: string;
|
|
34
|
+
|
|
35
|
+
constructor(private selector: string) {
|
|
36
|
+
const isViewState = selector.indexOf($nsp(P_VIEWSTATE)) != -1;
|
|
37
|
+
this.name = isViewState ? P_VIEWSTATE : P_CLIENT_WINDOW
|
|
38
|
+
this.template = isViewState ? HTML_VIEWSTATE : HTML_CLIENT_WINDOW
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
withNamingContainerId(namingContainer: string): HiddenInputBuilder {
|
|
42
|
+
this.namingContainerId = namingContainer;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
withParent(parent: DomQuery): HiddenInputBuilder {
|
|
47
|
+
this.parent = parent;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
withNamedViewRoot(namedViewRoot: boolean): HiddenInputBuilder {
|
|
52
|
+
this.namedViewRoot = namedViewRoot;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
build(): DomQuery {
|
|
58
|
+
const SEP = $faces().separatorchar;
|
|
59
|
+
|
|
60
|
+
let existingStates = DQ$(`[name*='${$nsp(this.name)}']`);
|
|
61
|
+
let cnt = existingStates.stream.map(state => {
|
|
62
|
+
let ident: string = state.id.orElse("-1").value;
|
|
63
|
+
ident = ident.substring(ident.lastIndexOf(SEP)+1);
|
|
64
|
+
return parseInt(ident);
|
|
65
|
+
})
|
|
66
|
+
.filter(item => !isNaN(item))
|
|
67
|
+
.reduce((item1, item2) => Math.max(item1, item2), -1).value;
|
|
68
|
+
//the maximum new ident is the current max + 1
|
|
69
|
+
cnt++;
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
const newElement = DQ.fromMarkup($nsp(this.template));
|
|
73
|
+
newElement.id.value = ((this.namingContainerId?.length) ?
|
|
74
|
+
[this.namingContainerId, $nsp(this.name), cnt]:
|
|
75
|
+
[$nsp(this.name), cnt]).join(SEP);
|
|
76
|
+
|
|
77
|
+
//name must be prefixed with the naming container id as well according to the jsdocs
|
|
78
|
+
if(this.namedViewRoot) {
|
|
79
|
+
newElement.name.value = (this.namingContainerId?.length) ?
|
|
80
|
+
[this.namingContainerId, $nsp(this.name)].join(SEP): $nsp(this.name);
|
|
81
|
+
} else {
|
|
82
|
+
newElement.name.value = $nsp(this.name);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
this?.parent?.append(newElement);
|
|
87
|
+
return newElement;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -13,13 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*
|
|
16
|
-
* todo replace singleton with module definition
|
|
17
|
-
*
|
|
18
16
|
*/
|
|
19
17
|
|
|
20
18
|
import {Lang as LangBase, Config, Optional, DomQuery, DQ, Stream} from "mona-dish";
|
|
21
19
|
import {Messages} from "../i18n/Messages";
|
|
22
|
-
import {EMPTY_STR,
|
|
20
|
+
import {EMPTY_STR, HTML_TAG_FORM} from "../core/Const";
|
|
23
21
|
import {getEventTarget} from "../xhrCore/RequestDataResolver";
|
|
24
22
|
|
|
25
23
|
|
|
@@ -38,11 +36,11 @@ export module ExtLang {
|
|
|
38
36
|
|
|
39
37
|
//should be in lang, but for now here to avoid recursive imports, not sure if typescript still has a problem with those
|
|
40
38
|
/**
|
|
41
|
-
* helper function to
|
|
39
|
+
* helper function to safely resolve anything
|
|
42
40
|
* this is not an elvis operator, it resolves
|
|
43
41
|
* a value without exception in a tree and if
|
|
44
42
|
* it is not resolvable then an optional of
|
|
45
|
-
* a default value is restored or Optional
|
|
43
|
+
* a default value is restored or Optional\.empty
|
|
46
44
|
* if none is given
|
|
47
45
|
*
|
|
48
46
|
* usage
|
|
@@ -51,7 +49,7 @@ export module ExtLang {
|
|
|
51
49
|
* </code>
|
|
52
50
|
*
|
|
53
51
|
* @param resolverProducer a lambda which can produce the value
|
|
54
|
-
* @param defaultValue an optional default value if the producer
|
|
52
|
+
* @param defaultValue an optional default value if the producer fails to produce anything
|
|
55
53
|
* @returns an Optional of the produced value
|
|
56
54
|
*/
|
|
57
55
|
export function failSaveResolve<T>(resolverProducer: () => T, defaultValue: T = null): Optional<T> {
|
|
@@ -75,10 +73,10 @@ export module ExtLang {
|
|
|
75
73
|
* returns a given localized message upon a given key
|
|
76
74
|
* basic java log like templating functionality is included
|
|
77
75
|
*
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
76
|
+
* @param key the key for the message
|
|
77
|
+
* @param defaultMessage optional default message if none was found
|
|
80
78
|
*
|
|
81
|
-
* Additionally you can pass additional arguments, which are used
|
|
79
|
+
* Additionally, you can pass additional arguments, which are used
|
|
82
80
|
* in the same way java log templates use the params
|
|
83
81
|
*
|
|
84
82
|
* @param templateParams the param list to be filled in
|
|
@@ -106,15 +104,15 @@ export module ExtLang {
|
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
/**
|
|
109
|
-
* creates an
|
|
107
|
+
* creates an exception with additional internal parameters
|
|
110
108
|
* for extra information
|
|
111
109
|
*
|
|
112
110
|
* @param error
|
|
113
|
-
* @param
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
111
|
+
* @param title the exception title
|
|
112
|
+
* @param name the exception name
|
|
113
|
+
* @param callerCls the caller class
|
|
114
|
+
* @param callFunc the caller function
|
|
115
|
+
* @param message the message for the exception
|
|
118
116
|
*/
|
|
119
117
|
export function makeException(error: Error, title: string, name: string, callerCls: string, callFunc: string, message: string): Error {
|
|
120
118
|
|
|
@@ -124,14 +122,14 @@ export module ExtLang {
|
|
|
124
122
|
|
|
125
123
|
/**
|
|
126
124
|
* fetches a global config entry
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
125
|
+
* @param configName the name of the configuration entry
|
|
126
|
+
* @param defaultValue
|
|
129
127
|
*
|
|
130
128
|
* @return either the config entry or if none is given the default value
|
|
131
129
|
*/
|
|
132
130
|
export function getGlobalConfig(configName: string, defaultValue: any): any {
|
|
133
131
|
/**
|
|
134
|
-
* note we could use exists but this is
|
|
132
|
+
* note we could use exists but this is a heavy operation, since the config name usually
|
|
135
133
|
* given this function here is called very often
|
|
136
134
|
* is a single entry without . in between we can do the lighter shortcut
|
|
137
135
|
*/
|
|
@@ -139,7 +137,7 @@ export module ExtLang {
|
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
/**
|
|
142
|
-
* fetches the form in
|
|
140
|
+
* fetches the form in a fuzzy manner depending
|
|
143
141
|
* on an element or event target.
|
|
144
142
|
*
|
|
145
143
|
* The idea is that according to the jsf spec
|
|
@@ -148,7 +146,7 @@ export module ExtLang {
|
|
|
148
146
|
* This is fine, but since then html5 came into the picture with the form attribute the element
|
|
149
147
|
* can be anywhere referencing its parent form.
|
|
150
148
|
*
|
|
151
|
-
* Also theoretically you can have the case of an issuing element enclosing a set of forms
|
|
149
|
+
* Also, theoretically you can have the case of an issuing element enclosing a set of forms
|
|
152
150
|
* (not really often used, but theoretically it could be input button allows to embed html for instance)
|
|
153
151
|
*
|
|
154
152
|
* So the idea is not to limit the issuing form determination to the spec case
|
|
@@ -160,25 +158,25 @@ export module ExtLang {
|
|
|
160
158
|
export function getForm(elem: Element, event ?: Event): DQ | never {
|
|
161
159
|
|
|
162
160
|
let queryElem = new DQ(elem);
|
|
163
|
-
let eventTarget = new DQ(getEventTarget(event));
|
|
161
|
+
let eventTarget = (event) ? new DQ(getEventTarget(event)) : DomQuery.absent;
|
|
164
162
|
|
|
165
|
-
if (queryElem.isTag(
|
|
163
|
+
if (queryElem.isTag(HTML_TAG_FORM)) {
|
|
166
164
|
return queryElem;
|
|
167
165
|
}
|
|
168
166
|
|
|
169
167
|
//html 5 for handling
|
|
170
|
-
if (queryElem.attr(
|
|
171
|
-
let formId = queryElem.attr(
|
|
168
|
+
if (queryElem.attr(HTML_TAG_FORM).isPresent()) {
|
|
169
|
+
let formId = queryElem.attr(HTML_TAG_FORM).value;
|
|
172
170
|
let foundForm = DQ.byId(formId, true);
|
|
173
171
|
if (foundForm.isPresent()) {
|
|
174
172
|
return foundForm;
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
let form = queryElem.
|
|
179
|
-
.orElseLazy(() => queryElem.byTagName(
|
|
180
|
-
.orElseLazy(() => eventTarget.
|
|
181
|
-
.orElseLazy(() => eventTarget.byTagName(
|
|
176
|
+
let form = queryElem.firstParent(HTML_TAG_FORM)
|
|
177
|
+
.orElseLazy(() => queryElem.byTagName(HTML_TAG_FORM, true))
|
|
178
|
+
.orElseLazy(() => eventTarget.firstParent(HTML_TAG_FORM))
|
|
179
|
+
.orElseLazy(() => eventTarget.byTagName(HTML_TAG_FORM))
|
|
182
180
|
.first();
|
|
183
181
|
|
|
184
182
|
assertFormExists(form);
|
|
@@ -190,10 +188,11 @@ export module ExtLang {
|
|
|
190
188
|
* gets the local or global options with local ones having higher priority
|
|
191
189
|
* if no local or global one was found then the default value is given back
|
|
192
190
|
*
|
|
193
|
-
* @param
|
|
194
|
-
* @param
|
|
191
|
+
* @param configName the name of the configuration entry
|
|
192
|
+
* @param localOptions the local options root for the configuration myfaces as default marker is added
|
|
193
|
+
* implicitly
|
|
195
194
|
*
|
|
196
|
-
* @param
|
|
195
|
+
* @param defaultValue
|
|
197
196
|
*
|
|
198
197
|
* @return either the config entry or if none is given the default value
|
|
199
198
|
*/
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import {
|
|
17
|
-
EMPTY_STR,
|
|
17
|
+
EMPTY_STR, ERROR,
|
|
18
18
|
ERROR_MESSAGE,
|
|
19
19
|
ERROR_NAME,
|
|
20
20
|
RESPONSE_TEXT,
|
|
21
|
-
RESPONSE_XML,
|
|
21
|
+
RESPONSE_XML, SERVER_ERROR,
|
|
22
22
|
SOURCE,
|
|
23
23
|
STATUS,
|
|
24
24
|
UNKNOWN
|
|
@@ -49,7 +49,8 @@ export enum ErrorType {
|
|
|
49
49
|
export class ErrorData extends EventData implements IErrorData {
|
|
50
50
|
|
|
51
51
|
type: string = "error";
|
|
52
|
-
source:
|
|
52
|
+
source: HTMLElement;
|
|
53
|
+
sourceId: string;
|
|
53
54
|
errorName: string;
|
|
54
55
|
errorMessage: string;
|
|
55
56
|
|
|
@@ -63,12 +64,14 @@ export class ErrorData extends EventData implements IErrorData {
|
|
|
63
64
|
serverErrorMessage: string;
|
|
64
65
|
message: string;
|
|
65
66
|
|
|
66
|
-
constructor(source: string, errorName: string, errorMessage: string, responseText: string = null, responseXML: any = null, responseCode: string = "200", status: string = "
|
|
67
|
+
constructor(source: string, errorName: string, errorMessage: string, responseText: string = null, responseXML: any = null, responseCode: string = "200", status: string = "", type = ErrorType.CLIENT_ERROR) {
|
|
67
68
|
super();
|
|
68
|
-
this.source = source;
|
|
69
|
-
this.
|
|
69
|
+
this.source = document.getElementById(source);
|
|
70
|
+
this.sourceId = source;
|
|
71
|
+
this.type = ERROR;
|
|
70
72
|
this.errorName = errorName;
|
|
71
|
-
|
|
73
|
+
//tck requires that the type is prefixed to the message itself (jsdoc also) in case of a server error
|
|
74
|
+
this.message = this.errorMessage = (type == SERVER_ERROR) ? type + ": " + errorMessage : errorMessage;
|
|
72
75
|
this.responseCode = responseCode;
|
|
73
76
|
this.responseText = responseText;
|
|
74
77
|
this.status = status;
|
|
@@ -81,10 +84,10 @@ export class ErrorData extends EventData implements IErrorData {
|
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
static fromClient(e: Error): ErrorData {
|
|
84
|
-
return new ErrorData("client", e?.name ??
|
|
87
|
+
return new ErrorData((e as any)?.source ?? "client", e?.name ?? EMPTY_STR, e?.message ?? EMPTY_STR, e?.stack ?? EMPTY_STR);
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
static fromHttpConnection(source: any, name: string, message: string, responseText, responseCode: number, status: string =
|
|
90
|
+
static fromHttpConnection(source: any, name: string, message: string, responseText, responseCode: number, status: string = EMPTY_STR): ErrorData {
|
|
88
91
|
return new ErrorData(source, name, message, responseText, responseCode, `${responseCode}`, status, ErrorType.HTTP_ERROR);
|
|
89
92
|
}
|
|
90
93
|
|
|
@@ -98,11 +101,13 @@ export class ErrorData extends EventData implements IErrorData {
|
|
|
98
101
|
let status = getMsg(context, STATUS);
|
|
99
102
|
let responseText = getMsg(context, RESPONSE_TEXT);
|
|
100
103
|
let responseXML = getMsg(context, RESPONSE_XML);
|
|
104
|
+
|
|
105
|
+
|
|
101
106
|
return new ErrorData(source, errorName, errorMessage, responseText, responseXML, errorCode + EMPTY_STR, status, errorType);
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
private static getMsg(context, param) {
|
|
105
|
-
return getMessage(context.getIf(param).orElse(
|
|
110
|
+
return getMessage(context.getIf(param).orElse(EMPTY_STR).value);
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
static fromServerError(context: Config): ErrorData {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import {Config, DQ} from "mona-dish";
|
|
17
|
-
import {BEGIN,
|
|
17
|
+
import {BEGIN, CTX_PARAM_REQ_PASS_THR, EVENT, P_PARTIAL_SOURCE, SOURCE} from "../core/Const";
|
|
18
18
|
|
|
19
19
|
export class EventData implements IEventData{
|
|
20
20
|
type: string;
|
|
@@ -33,7 +33,7 @@ export class EventData implements IEventData{
|
|
|
33
33
|
|
|
34
34
|
let sourceId: string = context.getIf(SOURCE)
|
|
35
35
|
.orElseLazy(() => context.getIf(P_PARTIAL_SOURCE).value)
|
|
36
|
-
.orElseLazy(() => context.getIf(
|
|
36
|
+
.orElseLazy(() => context.getIf(CTX_PARAM_REQ_PASS_THR, P_PARTIAL_SOURCE).value)
|
|
37
37
|
.value;
|
|
38
38
|
if (sourceId) {
|
|
39
39
|
eventData.source = DQ.byId(sourceId, true).first().value.value;
|