@vaadin/hilla-frontend 24.7.0-alpha9 → 24.7.0-beta2
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/Authentication.d.ts +53 -54
- package/Authentication.js +161 -145
- package/Authentication.js.map +1 -7
- package/Connect.d.ts +150 -146
- package/Connect.js +228 -177
- package/Connect.js.map +1 -7
- package/CookieManager.d.ts +2 -2
- package/CookieManager.js +5 -12
- package/CookieManager.js.map +1 -7
- package/CsrfUtils.d.ts +1 -13
- package/CsrfUtils.js +51 -51
- package/CsrfUtils.js.map +1 -7
- package/EndpointErrors.d.ts +73 -74
- package/EndpointErrors.js +108 -101
- package/EndpointErrors.js.map +1 -7
- package/FluxConnection.d.ts +51 -52
- package/FluxConnection.js +278 -259
- package/FluxConnection.js.map +1 -7
- package/FluxMessages.d.ts +14 -15
- package/FluxMessages.js +3 -6
- package/FluxMessages.js.map +1 -7
- package/index.d.ts +4 -5
- package/index.js +9 -15
- package/index.js.map +1 -7
- package/package.json +8 -28
- package/types.d.ts +17 -0
- package/Authentication.d.ts.map +0 -1
- package/Connect.d.ts.map +0 -1
- package/CookieManager.d.ts.map +0 -1
- package/CsrfUtils.d.ts.map +0 -1
- package/EndpointErrors.d.ts.map +0 -1
- package/FluxConnection.d.ts.map +0 -1
- package/FluxMessages.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
package/CsrfUtils.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
import CookieManager from "./CookieManager.js";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
2
|
+
/** @internal */
|
|
3
|
+
export const VAADIN_CSRF_HEADER = "X-CSRF-Token";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export const VAADIN_CSRF_COOKIE_NAME = "csrfToken";
|
|
6
|
+
/** @internal */
|
|
7
|
+
export const SPRING_CSRF_COOKIE_NAME = "XSRF-TOKEN";
|
|
5
8
|
function extractContentFromMetaTag(element) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
if (element) {
|
|
10
|
+
const value = element.content;
|
|
11
|
+
if (value && value.toLowerCase() !== "undefined") {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
13
16
|
}
|
|
17
|
+
/** @internal */
|
|
14
18
|
function getSpringCsrfHeaderFromMetaTag(doc) {
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
const csrfHeader = doc.head.querySelector("meta[name=\"_csrf_header\"]");
|
|
20
|
+
return extractContentFromMetaTag(csrfHeader);
|
|
17
21
|
}
|
|
22
|
+
/** @internal */
|
|
18
23
|
function getSpringCsrfTokenFromMetaTag(doc) {
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
const csrfToken = doc.head.querySelector("meta[name=\"_csrf\"]");
|
|
25
|
+
return extractContentFromMetaTag(csrfToken);
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
/** @internal */
|
|
28
|
+
export function getSpringCsrfInfo(doc) {
|
|
29
|
+
const csrfHeader = getSpringCsrfHeaderFromMetaTag(doc);
|
|
30
|
+
let csrf = CookieManager.get(SPRING_CSRF_COOKIE_NAME);
|
|
31
|
+
if (!csrf || csrf.length === 0) {
|
|
32
|
+
csrf = getSpringCsrfTokenFromMetaTag(doc);
|
|
33
|
+
}
|
|
34
|
+
const headers = {};
|
|
35
|
+
if (csrf && csrfHeader) {
|
|
36
|
+
headers._csrf = csrf;
|
|
37
|
+
headers._csrf_header = csrfHeader;
|
|
38
|
+
}
|
|
39
|
+
return headers;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
/** @internal */
|
|
42
|
+
export function getSpringCsrfTokenHeadersForAuthRequest(doc) {
|
|
43
|
+
const csrfInfo = getSpringCsrfInfo(doc);
|
|
44
|
+
const headers = {};
|
|
45
|
+
if (csrfInfo._csrf && csrfInfo._csrf_header) {
|
|
46
|
+
headers[csrfInfo._csrf_header] = csrfInfo._csrf;
|
|
47
|
+
}
|
|
48
|
+
return headers;
|
|
42
49
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
/** @internal */
|
|
51
|
+
export function getCsrfTokenHeadersForEndpointRequest(doc) {
|
|
52
|
+
const headers = {};
|
|
53
|
+
const csrfInfo = getSpringCsrfInfo(doc);
|
|
54
|
+
if (csrfInfo._csrf && csrfInfo._csrf_header) {
|
|
55
|
+
headers[csrfInfo._csrf_header] = csrfInfo._csrf;
|
|
56
|
+
} else {
|
|
57
|
+
headers[VAADIN_CSRF_HEADER] = CookieManager.get(VAADIN_CSRF_COOKIE_NAME) ?? "";
|
|
58
|
+
}
|
|
59
|
+
return headers;
|
|
52
60
|
}
|
|
53
|
-
|
|
54
|
-
SPRING_CSRF_COOKIE_NAME,
|
|
55
|
-
VAADIN_CSRF_COOKIE_NAME,
|
|
56
|
-
VAADIN_CSRF_HEADER,
|
|
57
|
-
getCsrfTokenHeadersForEndpointRequest,
|
|
58
|
-
getSpringCsrfInfo,
|
|
59
|
-
getSpringCsrfTokenHeadersForAuthRequest
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=CsrfUtils.js.map
|
|
61
|
+
//# sourceMappingURL=./CsrfUtils.js.map
|
package/CsrfUtils.js.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/CsrfUtils.ts"],
|
|
4
|
-
"sourcesContent": ["import CookieManager from './CookieManager.js';\n\n/** @internal */\nexport const VAADIN_CSRF_HEADER = 'X-CSRF-Token';\n/** @internal */\nexport const VAADIN_CSRF_COOKIE_NAME = 'csrfToken';\n/** @internal */\nexport const SPRING_CSRF_COOKIE_NAME = 'XSRF-TOKEN';\n\nfunction extractContentFromMetaTag(element: HTMLMetaElement | null): string | undefined {\n if (element) {\n const value = element.content;\n if (value && value.toLowerCase() !== 'undefined') {\n return value;\n }\n }\n return undefined;\n}\n\n/** @internal */\nfunction getSpringCsrfHeaderFromMetaTag(doc: Document): string | undefined {\n const csrfHeader = doc.head.querySelector<HTMLMetaElement>('meta[name=\"_csrf_header\"]');\n return extractContentFromMetaTag(csrfHeader);\n}\n\n/** @internal */\nfunction getSpringCsrfTokenFromMetaTag(doc: Document): string | undefined {\n const csrfToken = doc.head.querySelector<HTMLMetaElement>('meta[name=\"_csrf\"]');\n return extractContentFromMetaTag(csrfToken);\n}\n\n/** @internal */\nexport function getSpringCsrfInfo(doc: Document): Record<string, string> {\n const csrfHeader = getSpringCsrfHeaderFromMetaTag(doc);\n let csrf = CookieManager.get(SPRING_CSRF_COOKIE_NAME);\n if (!csrf || csrf.length === 0) {\n csrf = getSpringCsrfTokenFromMetaTag(doc);\n }\n const headers: Record<string, string> = {};\n if (csrf && csrfHeader) {\n headers._csrf = csrf;\n // eslint-disable-next-line camelcase\n headers._csrf_header = csrfHeader;\n }\n return headers;\n}\n\n/** @internal */\nexport function getSpringCsrfTokenHeadersForAuthRequest(doc: Document): Record<string, string> {\n const csrfInfo = getSpringCsrfInfo(doc);\n const headers: Record<string, string> = {};\n if (csrfInfo._csrf && csrfInfo._csrf_header) {\n headers[csrfInfo._csrf_header] = csrfInfo._csrf;\n }\n return headers;\n}\n\n/** @internal */\nexport function getCsrfTokenHeadersForEndpointRequest(doc: Document): Record<string, string> {\n const headers: Record<string, string> = {};\n\n const csrfInfo = getSpringCsrfInfo(doc);\n if (csrfInfo._csrf && csrfInfo._csrf_header) {\n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,WAAW,kBAAkB,IAAI;AACvC,KAAI,SAAS,SAAS,SAAS,cAAc;AAC3C,UAAQ,SAAS,gBAAgB,SAAS;CAC3C,OAAM;AACL,UAAQ,sBAAsB,cAAc,IAAI,wBAAwB,IAAI;CAC7E;AAED,QAAO;AACR","names":["element: HTMLMetaElement | null","doc: Document","headers: Record<string, string>"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/frontend/src/CsrfUtils.ts"],"sourcesContent":["import CookieManager from './CookieManager.js';\n\n/** @internal */\nexport const VAADIN_CSRF_HEADER = 'X-CSRF-Token';\n/** @internal */\nexport const VAADIN_CSRF_COOKIE_NAME = 'csrfToken';\n/** @internal */\nexport const SPRING_CSRF_COOKIE_NAME = 'XSRF-TOKEN';\n\nfunction extractContentFromMetaTag(element: HTMLMetaElement | null): string | undefined {\n if (element) {\n const value = element.content;\n if (value && value.toLowerCase() !== 'undefined') {\n return value;\n }\n }\n return undefined;\n}\n\n/** @internal */\nfunction getSpringCsrfHeaderFromMetaTag(doc: Document): string | undefined {\n const csrfHeader = doc.head.querySelector<HTMLMetaElement>('meta[name=\"_csrf_header\"]');\n return extractContentFromMetaTag(csrfHeader);\n}\n\n/** @internal */\nfunction getSpringCsrfTokenFromMetaTag(doc: Document): string | undefined {\n const csrfToken = doc.head.querySelector<HTMLMetaElement>('meta[name=\"_csrf\"]');\n return extractContentFromMetaTag(csrfToken);\n}\n\n/** @internal */\nexport function getSpringCsrfInfo(doc: Document): Record<string, string> {\n const csrfHeader = getSpringCsrfHeaderFromMetaTag(doc);\n let csrf = CookieManager.get(SPRING_CSRF_COOKIE_NAME);\n if (!csrf || csrf.length === 0) {\n csrf = getSpringCsrfTokenFromMetaTag(doc);\n }\n const headers: Record<string, string> = {};\n if (csrf && csrfHeader) {\n headers._csrf = csrf;\n // eslint-disable-next-line camelcase\n headers._csrf_header = csrfHeader;\n }\n return headers;\n}\n\n/** @internal */\nexport function getSpringCsrfTokenHeadersForAuthRequest(doc: Document): Record<string, string> {\n const csrfInfo = getSpringCsrfInfo(doc);\n const headers: Record<string, string> = {};\n if (csrfInfo._csrf && csrfInfo._csrf_header) {\n headers[csrfInfo._csrf_header] = csrfInfo._csrf;\n }\n return headers;\n}\n\n/** @internal */\nexport function getCsrfTokenHeadersForEndpointRequest(doc: Document): Record<string, string> {\n const headers: Record<string, string> = {};\n\n const csrfInfo = getSpringCsrfInfo(doc);\n if (csrfInfo._csrf && csrfInfo._csrf_header) {\n headers[csrfInfo._csrf_header] = csrfInfo._csrf;\n } else {\n headers[VAADIN_CSRF_HEADER] = CookieManager.get(VAADIN_CSRF_COOKIE_NAME) ?? '';\n }\n\n return headers;\n}\n"],"version":3}
|
package/EndpointErrors.d.ts
CHANGED
|
@@ -1,90 +1,89 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* An exception that gets thrown when the Vaadin backend responds
|
|
3
|
+
* with not ok status.
|
|
4
|
+
*/
|
|
5
5
|
export declare class EndpointError extends Error {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The optional detail object, containing additional information sent
|
|
8
|
+
* from the backend
|
|
9
|
+
*/
|
|
10
|
+
detail?: unknown;
|
|
11
|
+
/**
|
|
12
|
+
* The optional name of the exception that was thrown on a backend
|
|
13
|
+
*/
|
|
14
|
+
type?: string;
|
|
15
|
+
/**
|
|
16
|
+
* @param message - the `message` property value
|
|
17
|
+
* @param type - the `type` property value
|
|
18
|
+
* @param detail - the `detail` property value
|
|
19
|
+
*/
|
|
20
|
+
constructor(message: string, type?: string, detail?: unknown);
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
* An exception that gets thrown if Vaadin endpoint responds
|
|
24
|
+
* with non-ok status and provides additional info
|
|
25
|
+
* on the validation errors occurred.
|
|
26
|
+
*/
|
|
27
27
|
export declare class EndpointValidationError extends EndpointError {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
/**
|
|
29
|
+
* An array of the validation errors.
|
|
30
|
+
*/
|
|
31
|
+
validationErrorData: ValidationErrorData[];
|
|
32
|
+
/**
|
|
33
|
+
* An original validation error message.
|
|
34
|
+
*/
|
|
35
|
+
validationErrorMessage: string;
|
|
36
|
+
/**
|
|
37
|
+
* @param message - the `message` property value
|
|
38
|
+
* @param validationErrorData - the `validationErrorData` property value
|
|
39
|
+
* @param type - the `type` property value
|
|
40
|
+
*/
|
|
41
|
+
constructor(message: string, validationErrorData: ValidationErrorData[], type?: string);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* An exception that gets thrown for unexpected HTTP response.
|
|
45
|
+
*/
|
|
46
46
|
export declare class EndpointResponseError extends EndpointError {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The optional response object, containing the HTTP response error
|
|
49
|
+
*/
|
|
50
|
+
response: Response;
|
|
51
|
+
/**
|
|
52
|
+
* @param message - the `message` property value
|
|
53
|
+
* @param response - the `response` property value
|
|
54
|
+
*/
|
|
55
|
+
constructor(message: string, response: Response);
|
|
56
|
+
/**
|
|
57
|
+
* Convenience property to get the HTTP code status directly
|
|
58
|
+
*/
|
|
59
|
+
get status(): number;
|
|
60
60
|
}
|
|
61
61
|
export declare class UnauthorizedResponseError extends EndpointResponseError {
|
|
62
|
-
|
|
62
|
+
constructor(message: string, response: Response);
|
|
63
63
|
}
|
|
64
64
|
export declare class ForbiddenResponseError extends EndpointResponseError {
|
|
65
|
-
|
|
65
|
+
constructor(message: string, response: Response);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
* An object, containing all data for the particular validation error.
|
|
69
|
+
*/
|
|
70
70
|
export declare class ValidationErrorData {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
/**
|
|
72
|
+
* The validation error message.
|
|
73
|
+
*/
|
|
74
|
+
message: string;
|
|
75
|
+
/**
|
|
76
|
+
* The parameter name that caused the validation error.
|
|
77
|
+
*/
|
|
78
|
+
parameterName?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Validator original message
|
|
81
|
+
*/
|
|
82
|
+
validatorMessage?: string;
|
|
83
|
+
/**
|
|
84
|
+
* @param message - The `message` property value
|
|
85
|
+
* @param parameterName - The `parameterName` property value
|
|
86
|
+
* @param validatorMessage - The `validatorMessage` property value
|
|
87
|
+
*/
|
|
88
|
+
constructor(message: string, parameterName?: string, validatorMessage?: string);
|
|
89
89
|
}
|
|
90
|
-
//# sourceMappingURL=EndpointErrors.d.ts.map
|
package/EndpointErrors.js
CHANGED
|
@@ -1,107 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
/**
|
|
2
|
+
* An exception that gets thrown when the Vaadin backend responds
|
|
3
|
+
* with not ok status.
|
|
4
|
+
*/
|
|
5
|
+
export class EndpointError extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* The optional detail object, containing additional information sent
|
|
8
|
+
* from the backend
|
|
9
|
+
*/
|
|
10
|
+
detail;
|
|
11
|
+
/**
|
|
12
|
+
* The optional name of the exception that was thrown on a backend
|
|
13
|
+
*/
|
|
14
|
+
type;
|
|
15
|
+
/**
|
|
16
|
+
* @param message - the `message` property value
|
|
17
|
+
* @param type - the `type` property value
|
|
18
|
+
* @param detail - the `detail` property value
|
|
19
|
+
*/
|
|
20
|
+
constructor(message, type, detail) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.type = type;
|
|
23
|
+
this.detail = detail;
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
/**
|
|
27
|
+
* An exception that gets thrown if Vaadin endpoint responds
|
|
28
|
+
* with non-ok status and provides additional info
|
|
29
|
+
* on the validation errors occurred.
|
|
30
|
+
*/
|
|
31
|
+
export class EndpointValidationError extends EndpointError {
|
|
32
|
+
/**
|
|
33
|
+
* An array of the validation errors.
|
|
34
|
+
*/
|
|
35
|
+
validationErrorData;
|
|
36
|
+
/**
|
|
37
|
+
* An original validation error message.
|
|
38
|
+
*/
|
|
39
|
+
validationErrorMessage;
|
|
40
|
+
/**
|
|
41
|
+
* @param message - the `message` property value
|
|
42
|
+
* @param validationErrorData - the `validationErrorData` property value
|
|
43
|
+
* @param type - the `type` property value
|
|
44
|
+
*/
|
|
45
|
+
constructor(message, validationErrorData, type) {
|
|
46
|
+
super(message, type, validationErrorData);
|
|
47
|
+
this.validationErrorMessage = message;
|
|
48
|
+
this.detail = null;
|
|
49
|
+
this.validationErrorData = validationErrorData;
|
|
50
|
+
}
|
|
42
51
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
/**
|
|
53
|
+
* An exception that gets thrown for unexpected HTTP response.
|
|
54
|
+
*/
|
|
55
|
+
export class EndpointResponseError extends EndpointError {
|
|
56
|
+
/**
|
|
57
|
+
* The optional response object, containing the HTTP response error
|
|
58
|
+
*/
|
|
59
|
+
response;
|
|
60
|
+
/**
|
|
61
|
+
* @param message - the `message` property value
|
|
62
|
+
* @param response - the `response` property value
|
|
63
|
+
*/
|
|
64
|
+
constructor(message, response) {
|
|
65
|
+
super(message, "EndpointResponseError", response);
|
|
66
|
+
this.response = response;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Convenience property to get the HTTP code status directly
|
|
70
|
+
*/
|
|
71
|
+
get status() {
|
|
72
|
+
return this.response.status;
|
|
73
|
+
}
|
|
62
74
|
}
|
|
63
|
-
class UnauthorizedResponseError extends EndpointResponseError {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
export class UnauthorizedResponseError extends EndpointResponseError {
|
|
76
|
+
constructor(message, response) {
|
|
77
|
+
super(message, response);
|
|
78
|
+
this.type = "UnauthorizedResponseError";
|
|
79
|
+
}
|
|
68
80
|
}
|
|
69
|
-
class ForbiddenResponseError extends EndpointResponseError {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
export class ForbiddenResponseError extends EndpointResponseError {
|
|
82
|
+
constructor(message, response) {
|
|
83
|
+
super(message, response);
|
|
84
|
+
this.type = "ForbiddenResponseError";
|
|
85
|
+
}
|
|
74
86
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
/**
|
|
88
|
+
* An object, containing all data for the particular validation error.
|
|
89
|
+
*/
|
|
90
|
+
export class ValidationErrorData {
|
|
91
|
+
/**
|
|
92
|
+
* The validation error message.
|
|
93
|
+
*/
|
|
94
|
+
message;
|
|
95
|
+
/**
|
|
96
|
+
* The parameter name that caused the validation error.
|
|
97
|
+
*/
|
|
98
|
+
parameterName;
|
|
99
|
+
/**
|
|
100
|
+
* Validator original message
|
|
101
|
+
*/
|
|
102
|
+
validatorMessage;
|
|
103
|
+
/**
|
|
104
|
+
* @param message - The `message` property value
|
|
105
|
+
* @param parameterName - The `parameterName` property value
|
|
106
|
+
* @param validatorMessage - The `validatorMessage` property value
|
|
107
|
+
*/
|
|
108
|
+
constructor(message, parameterName, validatorMessage) {
|
|
109
|
+
this.message = message;
|
|
110
|
+
this.parameterName = parameterName;
|
|
111
|
+
this.validatorMessage = validatorMessage;
|
|
112
|
+
}
|
|
98
113
|
}
|
|
99
|
-
|
|
100
|
-
EndpointError,
|
|
101
|
-
EndpointResponseError,
|
|
102
|
-
EndpointValidationError,
|
|
103
|
-
ForbiddenResponseError,
|
|
104
|
-
UnauthorizedResponseError,
|
|
105
|
-
ValidationErrorData
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=EndpointErrors.js.map
|
|
114
|
+
//# sourceMappingURL=./EndpointErrors.js.map
|
package/EndpointErrors.js.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/EndpointErrors.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * An exception that gets thrown when the Vaadin backend responds\n * with not ok status.\n */\nexport class EndpointError extends Error {\n /**\n * The optional detail object, containing additional information sent\n * from the backend\n */\n detail?: unknown;\n /**\n * The optional name of the exception that was thrown on a backend\n */\n type?: string;\n\n /**\n * @param message - the `message` property value\n * @param type - the `type` property value\n * @param detail - the `detail` property value\n */\n constructor(message: string, type?: string, detail?: unknown) {\n super(message);\n this.type = type;\n this.detail = detail;\n }\n}\n\n/**\n * An exception that gets thrown if Vaadin endpoint responds\n * with non-ok status and provides additional info\n * on the validation errors occurred.\n */\nexport class EndpointValidationError extends EndpointError {\n /**\n * An array of the validation errors.\n */\n validationErrorData: ValidationErrorData[];\n /**\n * An original validation error message.\n */\n validationErrorMessage: string;\n\n /**\n * @param message - the `message` property value\n * @param validationErrorData - the `validationErrorData` property value\n * @param type - the `type` property value\n */\n constructor(message: string, validationErrorData: ValidationErrorData[], type?: string) {\n super(message, type, validationErrorData);\n this.validationErrorMessage = message;\n this.detail = null;\n this.validationErrorData = validationErrorData;\n }\n}\n\n/**\n * An exception that gets thrown for unexpected HTTP response.\n */\nexport class EndpointResponseError extends EndpointError {\n /**\n * The optional response object, containing the HTTP response error\n */\n response: Response;\n\n /**\n * @param message - the `message` property value\n * @param response - the `response` property value\n */\n constructor(message: string, response: Response) {\n super(message, 'EndpointResponseError', response);\n this.response = response;\n }\n\n /**\n * Convenience property to get the HTTP code status directly\n */\n get status(): number {\n return this.response.status;\n }\n}\n\nexport class UnauthorizedResponseError extends EndpointResponseError {\n constructor(message: string, response: Response) {\n super(message, response);\n this.type = 'UnauthorizedResponseError';\n }\n}\n\nexport class ForbiddenResponseError extends EndpointResponseError {\n constructor(message: string, response: Response) {\n super(message, response);\n this.type = 'ForbiddenResponseError';\n }\n}\n\n/**\n * An object, containing all data for the particular validation error.\n */\nexport class ValidationErrorData {\n /**\n * The validation error message.\n */\n message: string;\n\n /**\n * The parameter name that caused the validation error.\n */\n parameterName?: string;\n\n /**\n * Validator original message\n */\n validatorMessage?: string;\n\n /**\n * @param message - The `message` property value\n * @param parameterName - The `parameterName` property value\n * @param validatorMessage - The `validatorMessage` property value\n */\n constructor(message: string, parameterName?: string, validatorMessage?: string) {\n this.message = message;\n this.parameterName = parameterName;\n this.validatorMessage = validatorMessage;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAIO,MAAM,sBAAsB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKvC;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,SAAiB,MAAe,QAAkB;AAC5D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAOO,MAAM,gCAAgC,cAAc;AAAA;AAAA;AAAA;AAAA,EAIzD;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,SAAiB,qBAA4C,MAAe;AACtF,UAAM,SAAS,MAAM,mBAAmB;AACxC,SAAK,yBAAyB;AAC9B,SAAK,SAAS;AACd,SAAK,sBAAsB;AAAA,EAC7B;AACF;AAKO,MAAM,8BAA8B,cAAc;AAAA;AAAA;AAAA;AAAA,EAIvD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY,SAAiB,UAAoB;AAC/C,UAAM,SAAS,yBAAyB,QAAQ;AAChD,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,SAAiB;AACnB,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;AAEO,MAAM,kCAAkC,sBAAsB;AAAA,EAC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AAsB;CAChE,YAAYJ,SAAiBI,UAAoB;AAC/C,QAAM,SAAS,SAAS;AACxB,OAAK,OAAO;CACb;AACF;;;;AAKD,OAAO,MAAM,oBAAoB;;;;CAI/B;;;;CAKA;;;;CAKA;;;;;;CAOA,YAAYJ,SAAiBK,eAAwBC,kBAA2B;AAC9E,OAAK,UAAU;AACf,OAAK,gBAAgB;AACrB,OAAK,mBAAmB;CACzB;AACF","names":["message: string","type?: string","detail?: unknown","validationErrorData: ValidationErrorData[]","response: Response","parameterName?: string","validatorMessage?: string"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/frontend/src/EndpointErrors.ts"],"sourcesContent":["/**\n * An exception that gets thrown when the Vaadin backend responds\n * with not ok status.\n */\nexport class EndpointError extends Error {\n /**\n * The optional detail object, containing additional information sent\n * from the backend\n */\n detail?: unknown;\n /**\n * The optional name of the exception that was thrown on a backend\n */\n type?: string;\n\n /**\n * @param message - the `message` property value\n * @param type - the `type` property value\n * @param detail - the `detail` property value\n */\n constructor(message: string, type?: string, detail?: unknown) {\n super(message);\n this.type = type;\n this.detail = detail;\n }\n}\n\n/**\n * An exception that gets thrown if Vaadin endpoint responds\n * with non-ok status and provides additional info\n * on the validation errors occurred.\n */\nexport class EndpointValidationError extends EndpointError {\n /**\n * An array of the validation errors.\n */\n validationErrorData: ValidationErrorData[];\n /**\n * An original validation error message.\n */\n validationErrorMessage: string;\n\n /**\n * @param message - the `message` property value\n * @param validationErrorData - the `validationErrorData` property value\n * @param type - the `type` property value\n */\n constructor(message: string, validationErrorData: ValidationErrorData[], type?: string) {\n super(message, type, validationErrorData);\n this.validationErrorMessage = message;\n this.detail = null;\n this.validationErrorData = validationErrorData;\n }\n}\n\n/**\n * An exception that gets thrown for unexpected HTTP response.\n */\nexport class EndpointResponseError extends EndpointError {\n /**\n * The optional response object, containing the HTTP response error\n */\n response: Response;\n\n /**\n * @param message - the `message` property value\n * @param response - the `response` property value\n */\n constructor(message: string, response: Response) {\n super(message, 'EndpointResponseError', response);\n this.response = response;\n }\n\n /**\n * Convenience property to get the HTTP code status directly\n */\n get status(): number {\n return this.response.status;\n }\n}\n\nexport class UnauthorizedResponseError extends EndpointResponseError {\n constructor(message: string, response: Response) {\n super(message, response);\n this.type = 'UnauthorizedResponseError';\n }\n}\n\nexport class ForbiddenResponseError extends EndpointResponseError {\n constructor(message: string, response: Response) {\n super(message, response);\n this.type = 'ForbiddenResponseError';\n }\n}\n\n/**\n * An object, containing all data for the particular validation error.\n */\nexport class ValidationErrorData {\n /**\n * The validation error message.\n */\n message: string;\n\n /**\n * The parameter name that caused the validation error.\n */\n parameterName?: string;\n\n /**\n * Validator original message\n */\n validatorMessage?: string;\n\n /**\n * @param message - The `message` property value\n * @param parameterName - The `parameterName` property value\n * @param validatorMessage - The `validatorMessage` property value\n */\n constructor(message: string, parameterName?: string, validatorMessage?: string) {\n this.message = message;\n this.parameterName = parameterName;\n this.validatorMessage = validatorMessage;\n }\n}\n"],"version":3}
|