@optionfactory/fml 8.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/LICENSE.md +21 -0
- package/README.md +22 -0
- package/dist/client-errors.iife.js +109 -0
- package/dist/client-errors.iife.js.map +1 -0
- package/dist/client-errors.iife.min.js +2 -0
- package/dist/client-errors.iife.min.js.map +1 -0
- package/dist/fml.css +2 -0
- package/dist/fml.css.map +1 -0
- package/dist/fml.d.mts +1241 -0
- package/dist/fml.iife.js +8340 -0
- package/dist/fml.iife.js.map +1 -0
- package/dist/fml.iife.min.js +2 -0
- package/dist/fml.iife.min.js.map +1 -0
- package/dist/fml.min.mjs +2 -0
- package/dist/fml.min.mjs.map +1 -0
- package/dist/fml.mjs +8284 -0
- package/dist/fml.mjs.map +1 -0
- package/dist/ftl.d.mts +361 -0
- package/dist/ftl.iife.js +4719 -0
- package/dist/ftl.iife.js.map +1 -0
- package/dist/ftl.iife.min.js +2 -0
- package/dist/ftl.iife.min.js.map +1 -0
- package/dist/ftl.min.mjs +2 -0
- package/dist/ftl.min.mjs.map +1 -0
- package/dist/ftl.mjs +4700 -0
- package/dist/ftl.mjs.map +1 -0
- package/dist/ful.css +2 -0
- package/dist/ful.css.map +1 -0
- package/dist/ful.d.mts +581 -0
- package/dist/ful.iife.js +2814 -0
- package/dist/ful.iife.js.map +1 -0
- package/dist/ful.iife.min.js +2 -0
- package/dist/ful.iife.min.js.map +1 -0
- package/dist/ful.min.mjs +2 -0
- package/dist/ful.min.mjs.map +1 -0
- package/dist/ful.mjs +2780 -0
- package/dist/ful.mjs.map +1 -0
- package/dist/httpc.d.mts +306 -0
- package/dist/httpc.iife.js +755 -0
- package/dist/httpc.iife.js.map +1 -0
- package/dist/httpc.iife.min.js +2 -0
- package/dist/httpc.iife.min.js.map +1 -0
- package/dist/httpc.min.mjs +2 -0
- package/dist/httpc.min.mjs.map +1 -0
- package/dist/httpc.mjs +743 -0
- package/dist/httpc.mjs.map +1 -0
- package/package.json +72 -0
package/dist/httpc.d.mts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
export type Problem = {
|
|
2
|
+
type: string;
|
|
3
|
+
context: string | null;
|
|
4
|
+
reason: string;
|
|
5
|
+
details: any | null;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {{ type: string; context: string?; reason: string; details: any?; }} Problem
|
|
9
|
+
*/
|
|
10
|
+
declare class Failure extends Error {
|
|
11
|
+
problems: Problem[];
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {string} message
|
|
15
|
+
* @param {Problem[]} problems
|
|
16
|
+
* @param {*} cause
|
|
17
|
+
*/
|
|
18
|
+
constructor(message: string, problems: Problem[], cause: any);
|
|
19
|
+
dropping(prefix: any): Failure;
|
|
20
|
+
static dropProblemsContext(problems: any, prefix: any): any;
|
|
21
|
+
}
|
|
22
|
+
declare class Base64 {
|
|
23
|
+
static encode(arrayBuffer: any, dialect: any): string;
|
|
24
|
+
static decode(str: any, dialect: any): ArrayBuffer;
|
|
25
|
+
}
|
|
26
|
+
declare namespace Base64 {
|
|
27
|
+
var STANDARD: string;
|
|
28
|
+
var URL_SAFE: string;
|
|
29
|
+
}
|
|
30
|
+
declare class Hex {
|
|
31
|
+
static decode(hex: any): Uint8Array<ArrayBuffer>;
|
|
32
|
+
static encode(bytes: any, upper: any): string;
|
|
33
|
+
}
|
|
34
|
+
declare class MediaType {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(type: any, subtype: any);
|
|
37
|
+
get normalized(): string;
|
|
38
|
+
get type(): any;
|
|
39
|
+
get subtype(): any;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param {string|null|undefined} v
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
static parse(v: string | null | undefined): MediaType;
|
|
46
|
+
}
|
|
47
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
48
|
+
export type HttpInterceptor = {
|
|
49
|
+
intercept: (url: URL, init: RequestInit | undefined, chain: HttpInterceptorChain) => Promise<Response>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {Int8Array| Uint8Array| Uint8ClampedArray| Int16Array| Uint16Array| Int32Array| Uint32Array| Float32Array| Float64Array| BigInt64Array| BigUint64Array} TypedArray
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {object} HttpInterceptor
|
|
56
|
+
* @property {(url: URL, init: RequestInit|undefined, chain: HttpInterceptorChain) => Promise<Response>} intercept
|
|
57
|
+
*/
|
|
58
|
+
declare class HttpClientError extends Failure {
|
|
59
|
+
status: number;
|
|
60
|
+
/**
|
|
61
|
+
* @param {string} message
|
|
62
|
+
* @param {number} status
|
|
63
|
+
* @param {{ type: string; context: string?; reason: string; details: any?; }[]} problems
|
|
64
|
+
* @param {Error|undefined} [cause]
|
|
65
|
+
*/
|
|
66
|
+
constructor(message: string, status: number, problems: {
|
|
67
|
+
type: string;
|
|
68
|
+
context: string | null;
|
|
69
|
+
reason: string;
|
|
70
|
+
details: any | null;
|
|
71
|
+
}[], cause?: Error | undefined);
|
|
72
|
+
dropping(prefix: any): HttpClientError;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {string} type
|
|
76
|
+
* @param {any} cause
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
static of(type: string, cause: any): HttpClientError;
|
|
80
|
+
/**
|
|
81
|
+
* Creates an HttpClientError from a Response.
|
|
82
|
+
* @param {Response} response
|
|
83
|
+
* @returns an HttpClientError
|
|
84
|
+
*/
|
|
85
|
+
static fromResponse(response: Response): Promise<HttpClientError>;
|
|
86
|
+
}
|
|
87
|
+
declare class HttpClientBuilder {
|
|
88
|
+
#private;
|
|
89
|
+
constructor();
|
|
90
|
+
withCsrfToken(): this;
|
|
91
|
+
withRedirectOnUnauthorized(redirectUri: any): this;
|
|
92
|
+
/**
|
|
93
|
+
* @param {...HttpInterceptor} interceptors
|
|
94
|
+
*/
|
|
95
|
+
withInterceptors(...interceptors: HttpInterceptor[]): this;
|
|
96
|
+
build(): HttpClient;
|
|
97
|
+
}
|
|
98
|
+
declare class HttpInterceptorChain {
|
|
99
|
+
#private;
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param {HttpInterceptor[]} interceptors
|
|
103
|
+
* @param {number} current
|
|
104
|
+
*/
|
|
105
|
+
constructor(interceptors: HttpInterceptor[], current: number);
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @param {URL} url
|
|
109
|
+
* @param {RequestInit} request
|
|
110
|
+
* @returns {Promise<Response>} the response
|
|
111
|
+
*/
|
|
112
|
+
proceed(url: URL, request: RequestInit): Promise<Response>;
|
|
113
|
+
}
|
|
114
|
+
declare class HttpClient {
|
|
115
|
+
#private;
|
|
116
|
+
/**
|
|
117
|
+
* Creates a builder for an HttpClient.
|
|
118
|
+
* @returns {HttpClientBuilder} the client builder
|
|
119
|
+
*/
|
|
120
|
+
static builder(): HttpClientBuilder;
|
|
121
|
+
/**
|
|
122
|
+
* Creates an HttpClient.
|
|
123
|
+
* @param {HttpInterceptor[]|undefined} interceptors - a list of interceptors to be registered for every request performed by the created client.
|
|
124
|
+
*/
|
|
125
|
+
constructor(interceptors: HttpInterceptor[] | undefined);
|
|
126
|
+
/**
|
|
127
|
+
* Performs an HTTP exchange.
|
|
128
|
+
* @async
|
|
129
|
+
* @param {string} uri - the (possibly relative) request url
|
|
130
|
+
* @param {RequestInit|undefined} options - fetch options
|
|
131
|
+
* @param {HttpInterceptor[]|undefined} interceptors - the HttpInterceptors to be registered for this exchange.
|
|
132
|
+
* @returns {Promise<Response>} the response
|
|
133
|
+
*/
|
|
134
|
+
exchange(uri: string, options: RequestInit | undefined, interceptors: HttpInterceptor[] | undefined): Promise<Response>;
|
|
135
|
+
/**
|
|
136
|
+
* Creates a request builder.
|
|
137
|
+
* @param {string} method - the HTTP method to be used
|
|
138
|
+
* @param {string} uri - the (possibly relative) request url
|
|
139
|
+
* @returns {HttpRequestBuilder} the request builder
|
|
140
|
+
*/
|
|
141
|
+
request(method: string, uri: string): HttpRequestBuilder;
|
|
142
|
+
/**
|
|
143
|
+
* Creates a request builder.
|
|
144
|
+
* @param {string} uri - the (possibly relative) request url
|
|
145
|
+
* @returns {HttpRequestBuilder} the request builder
|
|
146
|
+
*/
|
|
147
|
+
get(uri: string): HttpRequestBuilder;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a request builder.
|
|
150
|
+
* @param {string} uri - the (possibly relative) request url
|
|
151
|
+
* @returns {HttpRequestBuilder} the request builder
|
|
152
|
+
*/
|
|
153
|
+
head(uri: string): HttpRequestBuilder;
|
|
154
|
+
/**
|
|
155
|
+
* Creates a request builder.
|
|
156
|
+
* @param {string} uri - the (possibly relative) request url
|
|
157
|
+
* @returns {HttpRequestBuilder} the request builder
|
|
158
|
+
*/
|
|
159
|
+
post(uri: string): HttpRequestBuilder;
|
|
160
|
+
/**
|
|
161
|
+
* Creates a request builder.
|
|
162
|
+
* @param {string} uri - the (possibly relative) request url
|
|
163
|
+
* @returns {HttpRequestBuilder} the request builder
|
|
164
|
+
*/
|
|
165
|
+
put(uri: string): HttpRequestBuilder;
|
|
166
|
+
/**
|
|
167
|
+
* Creates a request builder.
|
|
168
|
+
* @param {string} uri - the (possibly relative) request url
|
|
169
|
+
* @returns {HttpRequestBuilder} the request builder
|
|
170
|
+
*/
|
|
171
|
+
patch(uri: string): HttpRequestBuilder;
|
|
172
|
+
/**
|
|
173
|
+
* Creates a request builder.
|
|
174
|
+
* @param {string} uri - the (possibly relative) request url
|
|
175
|
+
* @returns {HttpRequestBuilder} the request builder
|
|
176
|
+
*/
|
|
177
|
+
delete(uri: string): HttpRequestBuilder;
|
|
178
|
+
}
|
|
179
|
+
declare class HttpRequestBuilder {
|
|
180
|
+
#private;
|
|
181
|
+
/**
|
|
182
|
+
* Creates an HttpRequestBuilder.
|
|
183
|
+
* @param {HttpClient} client
|
|
184
|
+
* @param {string} method - the HTTP method to be used
|
|
185
|
+
* @param {string} uri - the (possibly relative) request url
|
|
186
|
+
* @returns {HttpRequestBuilder} the builder
|
|
187
|
+
*/
|
|
188
|
+
static create(client: HttpClient, method: string, uri: string): HttpRequestBuilder;
|
|
189
|
+
/**
|
|
190
|
+
* Creates an HttpRequestBuilder.
|
|
191
|
+
* @param {HttpClient} client
|
|
192
|
+
* @param {string} method - the HTTP method to be used
|
|
193
|
+
* @param {string} uri - the (possibly relative) request url
|
|
194
|
+
* @param {URLSearchParams} params
|
|
195
|
+
* @param {Headers} headers
|
|
196
|
+
* @param {any} body
|
|
197
|
+
* @param {Omit<RequestInit,"headers"|"method"|"body">} options
|
|
198
|
+
* @param {HttpInterceptor[]} interceptors
|
|
199
|
+
*/
|
|
200
|
+
constructor(client: HttpClient, method: string, uri: string, params: URLSearchParams, headers: Headers, body: any, options: Omit<RequestInit, "headers" | "method" | "body">, interceptors: HttpInterceptor[]);
|
|
201
|
+
/**
|
|
202
|
+
* Add all passed headers to the request, overriding existing ones if that key already exists. Null and undefined values cause the key to be removed.
|
|
203
|
+
* @param {HeadersInit} hs
|
|
204
|
+
* @returns {HttpRequestBuilder} this builder
|
|
205
|
+
*/
|
|
206
|
+
headers(hs: HeadersInit): HttpRequestBuilder;
|
|
207
|
+
/**
|
|
208
|
+
* Adds an header to the request, overriding it if it already exists. Null and undefined values cause the key to be removed
|
|
209
|
+
* @param {string} k
|
|
210
|
+
* @param {string} v
|
|
211
|
+
* @returns {HttpRequestBuilder} this builder
|
|
212
|
+
*/
|
|
213
|
+
header(k: string, v: string): HttpRequestBuilder;
|
|
214
|
+
/**
|
|
215
|
+
* Add all query parameters to the request, overriding existing ones if that key already exists. Null and undefined values cause the key to be removed
|
|
216
|
+
* @param {URLSearchParams|Record<string,string>|string[][]|string} ps
|
|
217
|
+
* @returns {HttpRequestBuilder} this builder
|
|
218
|
+
*/
|
|
219
|
+
params(ps: URLSearchParams | Record<string, string> | string[][] | string): HttpRequestBuilder;
|
|
220
|
+
/**
|
|
221
|
+
* Adds a query parameter to the request, overriding it if it already exists. Empty vs, or a single null or undefined value cause the key to be removed.
|
|
222
|
+
* @param {string} k
|
|
223
|
+
* @param {...string} vs
|
|
224
|
+
* @returns {HttpRequestBuilder} this builder
|
|
225
|
+
*/
|
|
226
|
+
param(k: string, ...vs: string[]): HttpRequestBuilder;
|
|
227
|
+
/**
|
|
228
|
+
* Sets the request body.
|
|
229
|
+
* `Content-Type: multipart/form-data` header is automatically added by fetch when data is a FormData instance if not explicitly set.
|
|
230
|
+
* `Content-Type: application/x-www-form-urlencoded` header is automatically added by fetch when data is an URLSearchParams instance if not explicitly set.
|
|
231
|
+
* `Content-Type: text/plain` header is automatically added by fetch when data is a string instance if not explicitly set.
|
|
232
|
+
* @param {string|ArrayBuffer|Blob|DataView|File|FormData|TypedArray|URLSearchParams|ReadableStream} data
|
|
233
|
+
* @returns {HttpRequestBuilder} this builder
|
|
234
|
+
*/
|
|
235
|
+
body(data: string | ArrayBuffer | Blob | DataView | File | FormData | TypedArray | URLSearchParams | ReadableStream): HttpRequestBuilder;
|
|
236
|
+
/**
|
|
237
|
+
* Sets the request body that will be serialized as json. Calling this method adds the `Content-Type application/json` header for the request.
|
|
238
|
+
* @param {any} body - the body to be serialized as json
|
|
239
|
+
* @returns {HttpRequestBuilder} this builder
|
|
240
|
+
*/
|
|
241
|
+
json(body: any): HttpRequestBuilder;
|
|
242
|
+
/**
|
|
243
|
+
* Sets the request body as a FormData configured using the callback.
|
|
244
|
+
* `Content-Type: multipart/form-data` header is automatically added by fetch if not explicitly set.
|
|
245
|
+
* @param {function(HttpMultipartRequestCustomizer):void} callback
|
|
246
|
+
*/
|
|
247
|
+
multipart(callback: Function): this;
|
|
248
|
+
/**
|
|
249
|
+
* Sets a fetch options for the request.
|
|
250
|
+
* @param {Omit<RequestInit,"headers"|"method"|"body">} kvs
|
|
251
|
+
* @returns {HttpRequestBuilder} this builder
|
|
252
|
+
*/
|
|
253
|
+
options(kvs: Omit<RequestInit, "headers" | "method" | "body">): HttpRequestBuilder;
|
|
254
|
+
/**
|
|
255
|
+
* Sets a fetch option for the request.
|
|
256
|
+
* @param {keyof Omit<RequestInit,"headers"|"method"|"body">} k
|
|
257
|
+
* @param {*} v
|
|
258
|
+
* @returns {HttpRequestBuilder} this builder
|
|
259
|
+
*/
|
|
260
|
+
option(k: keyof Omit<RequestInit, "headers" | "method" | "body">, v: any): HttpRequestBuilder;
|
|
261
|
+
/**
|
|
262
|
+
* Adds interceptors to the request.
|
|
263
|
+
* @param {[HttpInterceptor]} is - the interceptor to be regisered
|
|
264
|
+
* @returns {HttpRequestBuilder} this builder
|
|
265
|
+
*/
|
|
266
|
+
interceptors(is: [HttpInterceptor]): HttpRequestBuilder;
|
|
267
|
+
/**
|
|
268
|
+
* Adds an interceptor to the request.
|
|
269
|
+
* @param {HttpInterceptor} i - the interceptor to be regisered
|
|
270
|
+
* @returns {HttpRequestBuilder} this builder
|
|
271
|
+
*/
|
|
272
|
+
interceptor(i: HttpInterceptor): HttpRequestBuilder;
|
|
273
|
+
/**
|
|
274
|
+
* Performs an HTTP exchange using the configured client, request and interceptors.
|
|
275
|
+
* @returns {Promise<Response>} the response
|
|
276
|
+
*/
|
|
277
|
+
exchange(): Promise<Response>;
|
|
278
|
+
/**
|
|
279
|
+
* Performs an HTTP exchange using the configured client request, and interceptos throwing a failure when response status is not in the 200-299 range.
|
|
280
|
+
* @returns {Promise<Response>} the response
|
|
281
|
+
*/
|
|
282
|
+
fetch(): Promise<Response>;
|
|
283
|
+
/**
|
|
284
|
+
* Performs an HTTP exchange using the configured client request, and interceptos throwing a failure when response status is not in the 200-299 range.
|
|
285
|
+
* @returns {Promise<string>} the response body, as text
|
|
286
|
+
*/
|
|
287
|
+
fetchText(): Promise<string>;
|
|
288
|
+
/**
|
|
289
|
+
* Performs an HTTP exchange using the configured client request, and interceptos throwing a failure when response status is not in the 200-299 range.
|
|
290
|
+
* @returns {Promise<any>} the response body, deserialized as JSON
|
|
291
|
+
*/
|
|
292
|
+
fetchJson(): Promise<any>;
|
|
293
|
+
/**
|
|
294
|
+
* Performs an HTTP exchange using the configured client request, and interceptos throwing a failure when response status is not in the 200-299 range.
|
|
295
|
+
* @returns {Promise<Blob>} the response body, as a Blob
|
|
296
|
+
*/
|
|
297
|
+
fetchBlob(): Promise<Blob>;
|
|
298
|
+
/**
|
|
299
|
+
* Performs an HTTP exchange using the configured client request, and interceptos throwing a failure when response status is not in the 200-299 range.
|
|
300
|
+
* @returns {Promise<ArrayBuffer>} the response body, as an ArrayBuffer
|
|
301
|
+
*/
|
|
302
|
+
fetchArrayBuffer(): Promise<ArrayBuffer>;
|
|
303
|
+
}
|
|
304
|
+
export { Base64, Failure, Hex, HttpClient, HttpClientError, MediaType };
|
|
305
|
+
|
|
306
|
+
export as namespace httpc;
|