@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/Connect.d.ts
CHANGED
|
@@ -1,173 +1,177 @@
|
|
|
1
|
-
import type { ReactiveControllerHost } from
|
|
2
|
-
import { type ActionOnLostSubscription, FluxConnection, type FluxSubscriptionStateChangeEvent } from
|
|
1
|
+
import type { ReactiveControllerHost } from "@lit/reactive-element";
|
|
2
|
+
import { type ActionOnLostSubscription, FluxConnection, type FluxSubscriptionStateChangeEvent } from "./FluxConnection.js";
|
|
3
|
+
export declare const BODY_PART_NAME = "hilla_body_part";
|
|
3
4
|
export type MaybePromise<T> = Promise<T> | T;
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
* Represents the connection to and endpoint returning a subscription rather than a value.
|
|
7
|
+
*/
|
|
7
8
|
export interface Subscription<T> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
/** Cancels the subscription. No values are made available after calling this. */
|
|
10
|
+
cancel(): void;
|
|
11
|
+
context(context: ReactiveControllerHost): Subscription<T>;
|
|
12
|
+
/** Called when the subscription has completed. No values are made available after calling this. */
|
|
13
|
+
onComplete(callback: () => void): Subscription<T>;
|
|
14
|
+
/** Called when an exception occured in the subscription. */
|
|
15
|
+
onError(callback: (message: string) => void): Subscription<T>;
|
|
16
|
+
/** Called when a new value is available. */
|
|
17
|
+
onNext(callback: (value: T) => void): Subscription<T>;
|
|
18
|
+
/** Called when the subscription state changes. */
|
|
19
|
+
onConnectionStateChange(callback: (event: FluxSubscriptionStateChangeEvent) => void): Subscription<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Called when the connection is restored, but there's no longer a valid subscription. If the callback returns
|
|
22
|
+
* `ActionOnLostSubscription.RESUBSCRIBE`, the subscription will be re-established by connecting to the same
|
|
23
|
+
* server method again. If the callback returns `ActionOnLostSubscription.REMOVE`, the subscription will be
|
|
24
|
+
* forgotten. This is also the default behavior if the callback is not set or if it returns `undefined`.
|
|
25
|
+
*/
|
|
26
|
+
onSubscriptionLost(callback: () => ActionOnLostSubscription | void): Subscription<T>;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
* The `ConnectClient` constructor options.
|
|
30
|
+
*/
|
|
30
31
|
export interface ConnectClientOptions {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The `middlewares` property value.
|
|
34
|
+
*/
|
|
35
|
+
middlewares?: Middleware[];
|
|
36
|
+
/**
|
|
37
|
+
* The `prefix` property value.
|
|
38
|
+
*/
|
|
39
|
+
prefix?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The Atmosphere options for the FluxConnection.
|
|
42
|
+
*/
|
|
43
|
+
atmosphereOptions?: Partial<Atmosphere.Request>;
|
|
43
44
|
}
|
|
44
45
|
export interface EndpointCallMetaInfo {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The endpoint name.
|
|
48
|
+
*/
|
|
49
|
+
endpoint: string;
|
|
50
|
+
/**
|
|
51
|
+
* The method name to call on in the endpoint class.
|
|
52
|
+
*/
|
|
53
|
+
method: string;
|
|
54
|
+
/**
|
|
55
|
+
* Optional object with method call arguments.
|
|
56
|
+
*/
|
|
57
|
+
params?: Record<string, unknown>;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
* An object with the call arguments and the related Request instance.
|
|
61
|
+
* See also {@link ConnectClient.call | the call() method in ConnectClient}.
|
|
62
|
+
*/
|
|
62
63
|
export interface MiddlewareContext extends EndpointCallMetaInfo {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The Fetch API Request object reflecting the other properties.
|
|
66
|
+
*/
|
|
67
|
+
request: Request;
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
* An async middleware callback that invokes the next middleware in the chain
|
|
71
|
+
* or makes the actual request.
|
|
72
|
+
* @param context - The information about the call and request
|
|
73
|
+
*/
|
|
73
74
|
export type MiddlewareNext = (context: MiddlewareContext) => MaybePromise<Response>;
|
|
74
75
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
* An interface that allows defining a middleware as a class.
|
|
77
|
+
*/
|
|
77
78
|
export interface MiddlewareClass {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
/**
|
|
80
|
+
* @param context - The information about the call and request
|
|
81
|
+
* @param next - Invokes the next in the call chain
|
|
82
|
+
*/
|
|
83
|
+
invoke(context: MiddlewareContext, next: MiddlewareNext): MaybePromise<Response>;
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
* An async callback function that can intercept the request and response
|
|
87
|
+
* of a call.
|
|
88
|
+
*/
|
|
88
89
|
export type MiddlewareFunction = (context: MiddlewareContext, next: MiddlewareNext) => MaybePromise<Response>;
|
|
89
90
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
* An async callback that can intercept the request and response
|
|
92
|
+
* of a call, could be either a function or a class.
|
|
93
|
+
*/
|
|
93
94
|
export type Middleware = MiddlewareClass | MiddlewareFunction;
|
|
94
95
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
* A list of parameters supported by {@link ConnectClient.call | the call() method in ConnectClient}.
|
|
97
|
+
*/
|
|
97
98
|
export interface EndpointRequestInit {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
/**
|
|
100
|
+
* An AbortSignal to set request's signal.
|
|
101
|
+
*/
|
|
102
|
+
signal?: AbortSignal | null;
|
|
103
|
+
/**
|
|
104
|
+
* If set to true, the connection state will not be updated during the request.
|
|
105
|
+
*/
|
|
106
|
+
mute?: boolean;
|
|
102
107
|
}
|
|
103
108
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
109
|
+
* A low-level network calling utility. It stores
|
|
110
|
+
* a prefix and facilitates remote calls to endpoint class methods
|
|
111
|
+
* on the Hilla backend.
|
|
112
|
+
*
|
|
113
|
+
* Example usage:
|
|
114
|
+
*
|
|
115
|
+
* ```js
|
|
116
|
+
* const client = new ConnectClient();
|
|
117
|
+
* const responseData = await client.call('MyEndpoint', 'myMethod');
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* ### Prefix
|
|
121
|
+
*
|
|
122
|
+
* The client supports an `prefix` constructor option:
|
|
123
|
+
* ```js
|
|
124
|
+
* const client = new ConnectClient({prefix: '/my-connect-prefix'});
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* The default prefix is '/connect'.
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
125
130
|
export declare class ConnectClient {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
131
|
+
#private;
|
|
132
|
+
/**
|
|
133
|
+
* The array of middlewares that are invoked during a call.
|
|
134
|
+
*/
|
|
135
|
+
middlewares: Middleware[];
|
|
136
|
+
/**
|
|
137
|
+
* The Hilla endpoint prefix
|
|
138
|
+
*/
|
|
139
|
+
prefix: string;
|
|
140
|
+
/**
|
|
141
|
+
* The Atmosphere options for the FluxConnection.
|
|
142
|
+
*/
|
|
143
|
+
atmosphereOptions: Partial<Atmosphere.Request>;
|
|
144
|
+
/**
|
|
145
|
+
* @param options - Constructor options.
|
|
146
|
+
*/
|
|
147
|
+
constructor(options?: ConnectClientOptions);
|
|
148
|
+
/**
|
|
149
|
+
* Gets a representation of the underlying persistent network connection used for subscribing to Flux type endpoint
|
|
150
|
+
* methods.
|
|
151
|
+
*/
|
|
152
|
+
get fluxConnection(): FluxConnection;
|
|
153
|
+
/**
|
|
154
|
+
* Calls the given endpoint method defined using the endpoint and method
|
|
155
|
+
* parameters with the parameters given as params.
|
|
156
|
+
* Asynchronously returns the parsed JSON response data.
|
|
157
|
+
*
|
|
158
|
+
* @param endpoint - Endpoint name.
|
|
159
|
+
* @param method - Method name to call in the endpoint class.
|
|
160
|
+
* @param params - Optional parameters to pass to the method.
|
|
161
|
+
* @param init - Optional parameters for the request
|
|
162
|
+
* @returns Decoded JSON response data.
|
|
163
|
+
*/
|
|
164
|
+
call(endpoint: string, method: string, params?: Record<string, unknown>, init?: EndpointRequestInit): Promise<any>;
|
|
165
|
+
/**
|
|
166
|
+
* Subscribes to the given method defined using the endpoint and method
|
|
167
|
+
* parameters with the parameters given as params. The method must return a
|
|
168
|
+
* compatible type such as a Flux.
|
|
169
|
+
* Returns a subscription that is used to fetch values as they become available.
|
|
170
|
+
*
|
|
171
|
+
* @param endpoint - Endpoint name.
|
|
172
|
+
* @param method - Method name to call in the endpoint class.
|
|
173
|
+
* @param params - Optional parameters to pass to the method.
|
|
174
|
+
* @returns A subscription used to handles values as they become available.
|
|
175
|
+
*/
|
|
176
|
+
subscribe(endpoint: string, method: string, params?: any): Subscription<any>;
|
|
172
177
|
}
|
|
173
|
-
//# sourceMappingURL=Connect.d.ts.map
|