@molecule/app-angular 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +209 -185
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-08T06:24:39.687Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-angular
|
|
@@ -100,25 +100,30 @@ interface AuthState<T = UserProfile> {
|
|
|
100
100
|
* never signs out. See {@link AuthStatus}.
|
|
101
101
|
*/
|
|
102
102
|
status: AuthStatus
|
|
103
|
+
|
|
103
104
|
/**
|
|
104
105
|
* Whether auth state has been initialized.
|
|
105
106
|
*/
|
|
106
107
|
initialized: boolean
|
|
108
|
+
|
|
107
109
|
/**
|
|
108
110
|
* Whether the client has an authenticated session. This is not a server
|
|
109
111
|
* confirmation flag: during `'unavailable'` it can be false for a retained
|
|
110
112
|
* token/cookie-only candidate with no cached profile. Use `status` for redirects.
|
|
111
113
|
*/
|
|
112
114
|
authenticated: boolean
|
|
115
|
+
|
|
113
116
|
/**
|
|
114
117
|
* Current user, or null when none is cached. In particular, an `'unavailable'`
|
|
115
118
|
* token/cookie-only restore has a retained candidate but no profile yet.
|
|
116
119
|
*/
|
|
117
120
|
user: T | null
|
|
121
|
+
|
|
118
122
|
/**
|
|
119
123
|
* Whether an auth operation is in progress.
|
|
120
124
|
*/
|
|
121
125
|
loading: boolean
|
|
126
|
+
|
|
122
127
|
/**
|
|
123
128
|
* Last auth error (if any).
|
|
124
129
|
*/
|
|
@@ -133,165 +138,89 @@ Provides login/logout/register flows, token management, profile
|
|
|
133
138
|
updates, and auth state subscription.
|
|
134
139
|
|
|
135
140
|
```typescript
|
|
136
|
-
interface AuthClient<
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* signed in immediately.
|
|
216
|
-
*
|
|
217
|
-
* This is the way to seed an OAuth/custom sign-in. Calling
|
|
218
|
-
* {@link setAccessToken} and {@link setUser} instead does NOT sign the
|
|
219
|
-
* client in.
|
|
220
|
-
*/
|
|
221
|
-
setSession(session: AuthSessionSeed<T>): void;
|
|
222
|
-
/**
|
|
223
|
-
* Gets the refresh token.
|
|
224
|
-
*/
|
|
225
|
-
getRefreshToken(): string | null;
|
|
226
|
-
/**
|
|
227
|
-
* Logs in with credentials.
|
|
228
|
-
*/
|
|
229
|
-
login(credentials: LoginCredentials): Promise<AuthResult<T>>;
|
|
230
|
-
/**
|
|
231
|
-
* Logs out the current user. The server request is best-effort: a missing
|
|
232
|
-
* logout route (404), any other HTTP failure, or a network error never makes
|
|
233
|
-
* this method reject. It always clears the access token, refresh token and
|
|
234
|
-
* cached user, stops automatic refresh, and publishes one settled
|
|
235
|
-
* `authenticated: false`, `status: 'unauthenticated'` transition. Every pending
|
|
236
|
-
* session operation loses ownership; a persistent marker prevents reload from
|
|
237
|
-
* restoring an older session, and late credentials are revoked best-effort.
|
|
238
|
-
*
|
|
239
|
-
* When the API has no logout route, set {@link AuthClientConfigOptions.logoutEndpoint}
|
|
240
|
-
* to `null` (or `''`) to skip the request. Local sign-out still happens.
|
|
241
|
-
*/
|
|
242
|
-
logout(): Promise<void>;
|
|
243
|
-
/**
|
|
244
|
-
* Registers a new user. Accepts the base fields plus the app's own fields
|
|
245
|
-
* (`TRegister`) at the top level — see {@link RegisterData}.
|
|
246
|
-
*/
|
|
247
|
-
register(data: RegisterData<TRegister>): Promise<AuthResult<T>>;
|
|
248
|
-
/**
|
|
249
|
-
* Refreshes the access token.
|
|
250
|
-
*/
|
|
251
|
-
refresh(): Promise<AuthResult<T>>;
|
|
252
|
-
/**
|
|
253
|
-
* Requests a password reset.
|
|
254
|
-
*/
|
|
255
|
-
requestPasswordReset(data: PasswordResetRequest): Promise<void>;
|
|
256
|
-
/**
|
|
257
|
-
* Confirms a password reset.
|
|
258
|
-
*/
|
|
259
|
-
confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
|
|
260
|
-
/**
|
|
261
|
-
* Updates the current user's profile.
|
|
262
|
-
* Returns the saved profile: the answer applied onto the signed-in user field
|
|
263
|
-
* by field, with or without an `id` — a field it carries replaces the value
|
|
264
|
-
* (`null` clears it), one it omits or leaves `undefined` is kept, so a field
|
|
265
|
-
* cleared by omission must arrive as `null`. A non-object answer is returned
|
|
266
|
-
* as it came. An answer for a replaced or ended session leaves the current one
|
|
267
|
-
* untouched.
|
|
268
|
-
*/
|
|
269
|
-
updateProfile(data: Partial<T>): Promise<T>;
|
|
270
|
-
/**
|
|
271
|
-
* Changes the current user's password.
|
|
272
|
-
*/
|
|
273
|
-
changePassword(oldPassword: string, newPassword: string): Promise<void>;
|
|
274
|
-
/**
|
|
275
|
-
* Initializes auth state (e.g., from stored tokens).
|
|
276
|
-
*
|
|
277
|
-
* LAZY and IDEMPOTENT: the first read of the state ({@link getState},
|
|
278
|
-
* {@link subscribe}, `useAuth()`) starts this same restore when nobody has called
|
|
279
|
-
* `initialize()`, and every later call shares the one promise instead of sending a
|
|
280
|
-
* second request. An app that keeps the template's explicit call behaves exactly as
|
|
281
|
-
* before; an app that loses that line still restores its session.
|
|
282
|
-
*
|
|
283
|
-
* With a stored token AND a stored user it marks the session `'authenticated'`
|
|
284
|
-
* SYNCHRONOUSLY — before its first `await` — so the first render is the
|
|
285
|
-
* signed-in UI and no page waits on a verification round trip. Any check
|
|
286
|
-
* (a refresh, the cookie-restore probe) settles behind that render, and only an
|
|
287
|
-
* explicit 401/403 ends the session; a network/5xx/404 failure keeps it and
|
|
288
|
-
* reports `'unavailable'`. With no stored user the client stays `'loading'`
|
|
289
|
-
* until the cookie restore decides.
|
|
290
|
-
*
|
|
291
|
-
* Do not put this call (or a `/me` request of your own) in front of the first
|
|
292
|
-
// … truncated — the full declaration is in node_modules/@molecule/app-angular/dist
|
|
141
|
+
interface AuthClient<
|
|
142
|
+
T = UserProfile,
|
|
143
|
+
TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
|
|
144
|
+
> {
|
|
145
|
+
/** Returns the current authentication state snapshot. */
|
|
146
|
+
getState(): AuthState<T>
|
|
147
|
+
|
|
148
|
+
/** Returns whether the user is currently authenticated. */
|
|
149
|
+
isAuthenticated(): boolean
|
|
150
|
+
|
|
151
|
+
/** Gets the current user. */
|
|
152
|
+
getUser(): T | null
|
|
153
|
+
|
|
154
|
+
/** Optional ownership marker for the current session. */
|
|
155
|
+
getSessionRevision?(): number
|
|
156
|
+
|
|
157
|
+
/** Updates the cached user object (state + persistent storage) without hitting the network. */
|
|
158
|
+
setUser(user: T | null): void
|
|
159
|
+
|
|
160
|
+
/** Gets the current access token. */
|
|
161
|
+
getAccessToken(): string | null
|
|
162
|
+
|
|
163
|
+
/** Stores the access token in the configured token storage adapter (in a browser, Web Storage; `'memory'` where no browser store exists). */
|
|
164
|
+
setAccessToken(token: string | null): void
|
|
165
|
+
|
|
166
|
+
/** Adopts a session an out-of-band exchange already established: stores the access token (and the refresh token when given), caches the user, and sets the COMPLET… */
|
|
167
|
+
setSession(session: AuthSessionSeed<T>): void
|
|
168
|
+
|
|
169
|
+
/** Gets the refresh token. */
|
|
170
|
+
getRefreshToken(): string | null
|
|
171
|
+
|
|
172
|
+
/** Logs in with credentials. */
|
|
173
|
+
login(credentials: LoginCredentials): Promise<AuthResult<T>>
|
|
174
|
+
|
|
175
|
+
/** Logs out the current user. */
|
|
176
|
+
logout(): Promise<void>
|
|
177
|
+
|
|
178
|
+
/** Registers a new user. */
|
|
179
|
+
register(data: RegisterData<TRegister>): Promise<AuthResult<T>>
|
|
180
|
+
|
|
181
|
+
/** Refreshes the access token. */
|
|
182
|
+
refresh(): Promise<AuthResult<T>>
|
|
183
|
+
|
|
184
|
+
/** Requests a password reset. */
|
|
185
|
+
requestPasswordReset(data: PasswordResetRequest): Promise<void>
|
|
186
|
+
|
|
187
|
+
/** Confirms a password reset. */
|
|
188
|
+
confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
|
|
189
|
+
|
|
190
|
+
/** Updates the current user's profile. */
|
|
191
|
+
updateProfile(data: Partial<T>): Promise<T>
|
|
192
|
+
|
|
193
|
+
/** Changes the current user's password. */
|
|
194
|
+
changePassword(oldPassword: string, newPassword: string): Promise<void>
|
|
195
|
+
|
|
196
|
+
/** Initializes auth state (e.g., from stored tokens). */
|
|
197
|
+
initialize(): Promise<void>
|
|
198
|
+
|
|
199
|
+
/** Re-checks a restored session against the server, in the background — the boot-time validation an app with a stored token needs when a revoked or expired token… */
|
|
200
|
+
validateSession?(): Promise<void>
|
|
201
|
+
|
|
202
|
+
/** Resolves when the session restore started by `initialize()` has settled — the point after which the client knows whether this visitor is signed in. */
|
|
203
|
+
whenRestored?(): Promise<void>
|
|
204
|
+
|
|
205
|
+
/** Subscribes to auth state changes. */
|
|
206
|
+
subscribe(callback: (state: AuthState<T>) => void): () => void
|
|
207
|
+
|
|
208
|
+
/** Subscribes to auth state changes (alias for subscribe). */
|
|
209
|
+
onAuthChange(callback: (state: AuthState<T>) => void): () => void
|
|
210
|
+
|
|
211
|
+
/** Gets the current access token (alias for getAccessToken). */
|
|
212
|
+
getToken?(): string | null
|
|
213
|
+
|
|
214
|
+
/** Adds an auth event listener. */
|
|
215
|
+
addEventListener(listener: AuthEventListener<T>): () => void
|
|
216
|
+
|
|
217
|
+
/** Destroys the auth client. */
|
|
218
|
+
destroy(): void
|
|
219
|
+
}
|
|
293
220
|
```
|
|
294
221
|
|
|
222
|
+
_(Member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-auth/dist/types.d.ts`.)_
|
|
223
|
+
|
|
295
224
|
#### `FormController`
|
|
296
225
|
|
|
297
226
|
Form controller interface.
|
|
@@ -304,72 +233,77 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
304
233
|
* Gets the current form state.
|
|
305
234
|
*/
|
|
306
235
|
getState(): FormState<T>
|
|
236
|
+
|
|
307
237
|
/**
|
|
308
238
|
* Gets the value of a specific field.
|
|
309
239
|
*/
|
|
310
240
|
getValue(name: string): unknown
|
|
311
241
|
getValue<K extends keyof T>(name: K): T[K]
|
|
242
|
+
|
|
312
243
|
/**
|
|
313
244
|
* Gets all form values.
|
|
314
245
|
*/
|
|
315
246
|
getValues(): T
|
|
247
|
+
|
|
316
248
|
/**
|
|
317
249
|
* Sets the value of a specific field.
|
|
318
250
|
*/
|
|
319
251
|
setValue(
|
|
320
252
|
name: string,
|
|
321
253
|
value: unknown,
|
|
322
|
-
options?: {
|
|
323
|
-
shouldValidate?: boolean
|
|
324
|
-
shouldDirty?: boolean
|
|
325
|
-
shouldTouch?: boolean
|
|
326
|
-
},
|
|
254
|
+
options?: { shouldValidate?: boolean; shouldDirty?: boolean; shouldTouch?: boolean },
|
|
327
255
|
): void
|
|
256
|
+
|
|
328
257
|
/**
|
|
329
258
|
* Sets multiple values at once.
|
|
330
259
|
*/
|
|
331
|
-
setValues(
|
|
332
|
-
|
|
333
|
-
options?: {
|
|
334
|
-
shouldValidate?: boolean
|
|
335
|
-
},
|
|
336
|
-
): void
|
|
260
|
+
setValues(values: Partial<T>, options?: { shouldValidate?: boolean }): void
|
|
261
|
+
|
|
337
262
|
/**
|
|
338
263
|
* Gets the error for a specific field.
|
|
339
264
|
*/
|
|
340
265
|
getError(name: string): string | undefined
|
|
266
|
+
|
|
341
267
|
/**
|
|
342
268
|
* Sets the error for a specific field.
|
|
343
269
|
*/
|
|
344
270
|
setError(name: string, error: string | undefined): void
|
|
271
|
+
|
|
345
272
|
/**
|
|
346
273
|
* Clears the error for a specific field.
|
|
347
274
|
*/
|
|
348
275
|
clearError<K extends keyof T>(name: K): void
|
|
276
|
+
|
|
349
277
|
/**
|
|
350
278
|
* Clears all errors.
|
|
351
279
|
*/
|
|
352
280
|
clearErrors(): void
|
|
281
|
+
|
|
353
282
|
/**
|
|
354
283
|
* Gets the field state for a specific field.
|
|
355
284
|
*/
|
|
356
285
|
getFieldState<K extends keyof T>(name: K): FieldState<T[K]>
|
|
286
|
+
|
|
357
287
|
/**
|
|
358
288
|
* Registers a field for form management.
|
|
359
289
|
*/
|
|
360
290
|
register(nameOrOptions: string | RegisterOptions, options?: RegisterOptions): FieldRegistration
|
|
291
|
+
|
|
361
292
|
/**
|
|
362
293
|
* Unregisters a field.
|
|
363
294
|
*/
|
|
364
295
|
unregister(name: string): void
|
|
296
|
+
|
|
365
297
|
/**
|
|
366
298
|
* Validates a specific field.
|
|
367
299
|
*/
|
|
368
300
|
validateField<K extends keyof T>(name: K): Promise<boolean>
|
|
301
|
+
|
|
369
302
|
/**
|
|
370
303
|
* Validates all fields.
|
|
371
304
|
*/
|
|
372
305
|
validate(): Promise<boolean>
|
|
306
|
+
|
|
373
307
|
/**
|
|
374
308
|
* Resets the form and clears errors, touched fields and submission state.
|
|
375
309
|
*
|
|
@@ -381,6 +315,7 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
381
315
|
* record and cancels a pending submit.
|
|
382
316
|
*/
|
|
383
317
|
reset(values?: Partial<T>): void
|
|
318
|
+
|
|
384
319
|
/**
|
|
385
320
|
* Applies externally loaded values without clearing submission state.
|
|
386
321
|
*
|
|
@@ -391,6 +326,7 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
391
326
|
* submit. Equal-content baselines cause no update.
|
|
392
327
|
*/
|
|
393
328
|
updateValues(values: Partial<T>, resetOptions?: FormResetOptions): void
|
|
329
|
+
|
|
394
330
|
/**
|
|
395
331
|
* Handles form submission.
|
|
396
332
|
*/
|
|
@@ -398,14 +334,17 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
398
334
|
onSubmit: (values: T) => void | Promise<void>,
|
|
399
335
|
onError?: (errors: Partial<Record<keyof T, string>>) => void,
|
|
400
336
|
): (event?: { preventDefault?: () => void }) => Promise<void>
|
|
337
|
+
|
|
401
338
|
/**
|
|
402
339
|
* Sets focus to a field.
|
|
403
340
|
*/
|
|
404
341
|
setFocus(name: keyof T): void
|
|
342
|
+
|
|
405
343
|
/**
|
|
406
344
|
* Subscribes to form state changes.
|
|
407
345
|
*/
|
|
408
346
|
subscribe(callback: (state: FormState<T>) => void): () => void
|
|
347
|
+
|
|
409
348
|
/**
|
|
410
349
|
* Destroys the form controller.
|
|
411
350
|
*/
|
|
@@ -424,26 +363,32 @@ interface FormOptions<T extends FormValuesConstraint<T>> {
|
|
|
424
363
|
* is created. Mutating this object afterwards does not change the baseline.
|
|
425
364
|
*/
|
|
426
365
|
defaultValues?: Partial<T>
|
|
366
|
+
|
|
427
367
|
/**
|
|
428
368
|
* Externally loaded values, merged over `defaultValues` as the clean
|
|
429
369
|
* baseline. Framework bindings also apply later content changes; use
|
|
430
370
|
* `resetOptions.keepDirtyValues` to preserve edits while pristine fields fill.
|
|
431
371
|
*/
|
|
432
372
|
values?: Partial<T>
|
|
373
|
+
|
|
433
374
|
/** Controls how framework bindings apply changed `values`. */
|
|
434
375
|
resetOptions?: FormResetOptions
|
|
376
|
+
|
|
435
377
|
/**
|
|
436
378
|
* Validation mode.
|
|
437
379
|
*/
|
|
438
380
|
mode?: 'onSubmit' | 'onChange' | 'onBlur' | 'all'
|
|
381
|
+
|
|
439
382
|
/**
|
|
440
383
|
* Revalidation mode.
|
|
441
384
|
*/
|
|
442
385
|
reValidateMode?: 'onChange' | 'onBlur' | 'onSubmit'
|
|
386
|
+
|
|
443
387
|
/**
|
|
444
388
|
* Whether to focus the first error field on submit.
|
|
445
389
|
*/
|
|
446
390
|
shouldFocusError?: boolean
|
|
391
|
+
|
|
447
392
|
/**
|
|
448
393
|
* Form-level validation function.
|
|
449
394
|
*/
|
|
@@ -465,54 +410,65 @@ interface HttpClient {
|
|
|
465
410
|
* Base URL for all requests.
|
|
466
411
|
*/
|
|
467
412
|
baseURL: string
|
|
413
|
+
|
|
468
414
|
/**
|
|
469
415
|
* Default headers for all requests.
|
|
470
416
|
*/
|
|
471
417
|
defaultHeaders: Record<string, string>
|
|
418
|
+
|
|
472
419
|
/**
|
|
473
420
|
* Makes a generic HTTP request. `data` is a field of THIS config object — the same body
|
|
474
421
|
* `post(url, data, config)` takes as its second argument.
|
|
475
422
|
*/
|
|
476
423
|
request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
|
|
424
|
+
|
|
477
425
|
/**
|
|
478
426
|
* Makes a GET request.
|
|
479
427
|
*/
|
|
480
428
|
get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
429
|
+
|
|
481
430
|
/**
|
|
482
431
|
* Makes a POST request. `data` is the request BODY, not a config object: the wire body is
|
|
483
432
|
* `data` itself, so `post(url, { data: body })` sends `{"data":body}` — pass `body` directly.
|
|
484
433
|
* A config (headers, params) is the THIRD argument.
|
|
485
434
|
*/
|
|
486
435
|
post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
436
|
+
|
|
487
437
|
/**
|
|
488
438
|
* Makes a PUT request. `data` is the request BODY (second argument) — never `{ data: body }`,
|
|
489
439
|
* which sends `{"data":body}`; a config is the THIRD argument.
|
|
490
440
|
*/
|
|
491
441
|
put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
442
|
+
|
|
492
443
|
/**
|
|
493
444
|
* Makes a PATCH request. `data` is the request BODY (second argument) — never `{ data: body }`,
|
|
494
445
|
* which sends `{"data":body}`; a config is the THIRD argument.
|
|
495
446
|
*/
|
|
496
447
|
patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
448
|
+
|
|
497
449
|
/**
|
|
498
450
|
* Makes a DELETE request.
|
|
499
451
|
*/
|
|
500
452
|
delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
453
|
+
|
|
501
454
|
/**
|
|
502
455
|
* Adds a request interceptor.
|
|
503
456
|
* Returns a function to remove the interceptor.
|
|
504
457
|
*/
|
|
505
458
|
addRequestInterceptor(interceptor: RequestInterceptor): () => void
|
|
459
|
+
|
|
506
460
|
/**
|
|
507
461
|
* Adds a response interceptor.
|
|
508
462
|
* Returns a function to remove the interceptor.
|
|
509
463
|
*/
|
|
510
464
|
addResponseInterceptor(interceptor: ResponseInterceptor): () => void
|
|
465
|
+
|
|
511
466
|
/**
|
|
512
467
|
* Adds an error interceptor.
|
|
513
468
|
* Returns a function to remove the interceptor.
|
|
514
469
|
*/
|
|
515
470
|
addErrorInterceptor(interceptor: ErrorInterceptor): () => void
|
|
471
|
+
|
|
516
472
|
/**
|
|
517
473
|
* Sets the authorization token.
|
|
518
474
|
*
|
|
@@ -524,11 +480,13 @@ interface HttpClient {
|
|
|
524
480
|
* the resolver is removed, the static token is sent again.
|
|
525
481
|
*/
|
|
526
482
|
setAuthToken(token: string | null): void
|
|
483
|
+
|
|
527
484
|
/**
|
|
528
485
|
* Returns the token the client applies to its next request: the resolver's answer when one
|
|
529
486
|
* is registered, else the static token from `setAuthToken`.
|
|
530
487
|
*/
|
|
531
488
|
getAuthToken(): string | null
|
|
489
|
+
|
|
532
490
|
/**
|
|
533
491
|
* Registers the LIVE token resolver every request of this client reads, or clears it with
|
|
534
492
|
* `null`.
|
|
@@ -559,6 +517,7 @@ interface HttpClient {
|
|
|
559
517
|
* @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
|
|
560
518
|
*/
|
|
561
519
|
setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
|
|
520
|
+
|
|
562
521
|
/**
|
|
563
522
|
* Registers a handler for authentication errors (401).
|
|
564
523
|
*
|
|
@@ -580,6 +539,7 @@ interface I18nProvider {
|
|
|
580
539
|
* Gets the current locale.
|
|
581
540
|
*/
|
|
582
541
|
getLocale(): string
|
|
542
|
+
|
|
583
543
|
/**
|
|
584
544
|
* Sets the current locale.
|
|
585
545
|
*
|
|
@@ -594,14 +554,17 @@ interface I18nProvider {
|
|
|
594
554
|
* from a working one until a user notices the wrong language on screen.
|
|
595
555
|
*/
|
|
596
556
|
setLocale(locale: string): Promise<void>
|
|
557
|
+
|
|
597
558
|
/**
|
|
598
559
|
* Gets all available locales.
|
|
599
560
|
*/
|
|
600
561
|
getLocales(): LocaleConfig[]
|
|
562
|
+
|
|
601
563
|
/**
|
|
602
564
|
* Adds a locale.
|
|
603
565
|
*/
|
|
604
566
|
addLocale(config: LocaleConfig): void
|
|
567
|
+
|
|
605
568
|
/**
|
|
606
569
|
* Removes a locale by code, notifying subscribers so language pickers
|
|
607
570
|
* built on `onLocaleChange` re-render their list. If the removed locale
|
|
@@ -613,6 +576,7 @@ interface I18nProvider {
|
|
|
613
576
|
* otherwise.
|
|
614
577
|
*/
|
|
615
578
|
removeLocale(code: string): boolean
|
|
579
|
+
|
|
616
580
|
/**
|
|
617
581
|
* Adds translations to a locale. Auto-creates the locale if it doesn't exist.
|
|
618
582
|
*
|
|
@@ -623,6 +587,7 @@ interface I18nProvider {
|
|
|
623
587
|
* contract on the API side.
|
|
624
588
|
*/
|
|
625
589
|
addTranslations(locale: string, translations: Translations, namespace?: string): void
|
|
590
|
+
|
|
626
591
|
/**
|
|
627
592
|
* Translates a key with optional interpolation values and pluralization.
|
|
628
593
|
*
|
|
@@ -640,11 +605,9 @@ interface I18nProvider {
|
|
|
640
605
|
t(
|
|
641
606
|
key: string,
|
|
642
607
|
values?: InterpolationValues,
|
|
643
|
-
options?: {
|
|
644
|
-
defaultValue?: string
|
|
645
|
-
count?: number
|
|
646
|
-
},
|
|
608
|
+
options?: { defaultValue?: string; count?: number },
|
|
647
609
|
): string
|
|
610
|
+
|
|
648
611
|
/**
|
|
649
612
|
* Checks if a translation key exists.
|
|
650
613
|
*
|
|
@@ -659,46 +622,42 @@ interface I18nProvider {
|
|
|
659
622
|
* @returns `true` if the key has a translation.
|
|
660
623
|
*/
|
|
661
624
|
exists(key: string): boolean
|
|
625
|
+
|
|
662
626
|
/**
|
|
663
627
|
* Formats a number according to the current locale.
|
|
664
628
|
*
|
|
665
629
|
* @returns The locale-formatted number string.
|
|
666
630
|
*/
|
|
667
631
|
formatNumber(value: number, options?: NumberFormatOptions): string
|
|
632
|
+
|
|
668
633
|
/**
|
|
669
634
|
* Formats a date according to the current locale.
|
|
670
635
|
*
|
|
671
636
|
* @returns The locale-formatted date string.
|
|
672
637
|
*/
|
|
673
638
|
formatDate(value: Date | number | string, options?: DateFormatOptions): string
|
|
639
|
+
|
|
674
640
|
/**
|
|
675
641
|
* Formats a relative time (e.g. "2 hours ago").
|
|
676
642
|
*
|
|
677
643
|
* @returns The locale-formatted relative time string.
|
|
678
644
|
*/
|
|
679
|
-
formatRelativeTime(
|
|
680
|
-
|
|
681
|
-
options?: {
|
|
682
|
-
unit?: Intl.RelativeTimeFormatUnit
|
|
683
|
-
},
|
|
684
|
-
): string
|
|
645
|
+
formatRelativeTime(value: Date | number, options?: { unit?: Intl.RelativeTimeFormatUnit }): string
|
|
646
|
+
|
|
685
647
|
/**
|
|
686
648
|
* Formats a list (e.g. "A, B, and C").
|
|
687
649
|
*
|
|
688
650
|
* @returns The locale-formatted list string.
|
|
689
651
|
*/
|
|
690
|
-
formatList(
|
|
691
|
-
|
|
692
|
-
options?: {
|
|
693
|
-
type?: 'conjunction' | 'disjunction' | 'unit'
|
|
694
|
-
},
|
|
695
|
-
): string
|
|
652
|
+
formatList(values: string[], options?: { type?: 'conjunction' | 'disjunction' | 'unit' }): string
|
|
653
|
+
|
|
696
654
|
/**
|
|
697
655
|
* Subscribes to locale changes.
|
|
698
656
|
*
|
|
699
657
|
* @returns An unsubscribe function.
|
|
700
658
|
*/
|
|
701
659
|
onLocaleChange(listener: (locale: string) => void): () => void
|
|
660
|
+
|
|
702
661
|
/**
|
|
703
662
|
* Gets a counter that advances for every change `onLocaleChange` announces:
|
|
704
663
|
* a locale switch, a locale-list change, or translations added for a locale
|
|
@@ -720,24 +679,29 @@ interface I18nProvider {
|
|
|
720
679
|
* @returns The provider's current revision.
|
|
721
680
|
*/
|
|
722
681
|
getRevision?(): number
|
|
682
|
+
|
|
723
683
|
/**
|
|
724
684
|
* Gets the text direction for the current locale.
|
|
725
685
|
*
|
|
726
686
|
* @returns `'ltr'` or `'rtl'`.
|
|
727
687
|
*/
|
|
728
688
|
getDirection(): 'ltr' | 'rtl'
|
|
689
|
+
|
|
729
690
|
/**
|
|
730
691
|
* Checks if a translation key exists (alias for exists).
|
|
731
692
|
*/
|
|
732
693
|
hasKey?(key: string): boolean
|
|
694
|
+
|
|
733
695
|
/**
|
|
734
696
|
* Checks if the provider is ready.
|
|
735
697
|
*/
|
|
736
698
|
isReady?(): boolean
|
|
699
|
+
|
|
737
700
|
/**
|
|
738
701
|
* Registers a callback for when the provider is ready.
|
|
739
702
|
*/
|
|
740
703
|
onReady?(callback: () => void): () => void
|
|
704
|
+
|
|
741
705
|
/**
|
|
742
706
|
* Registers a lazily-loaded content module for automatic reload on locale changes.
|
|
743
707
|
* All registered content is reloaded during `setLocale()` before listeners fire,
|
|
@@ -760,42 +724,52 @@ interface Logger {
|
|
|
760
724
|
* Logs a trace message.
|
|
761
725
|
*/
|
|
762
726
|
trace(message: string, ...args: unknown[]): void
|
|
727
|
+
|
|
763
728
|
/**
|
|
764
729
|
* Logs a debug message.
|
|
765
730
|
*/
|
|
766
731
|
debug(message: string, ...args: unknown[]): void
|
|
732
|
+
|
|
767
733
|
/**
|
|
768
734
|
* Logs an info message.
|
|
769
735
|
*/
|
|
770
736
|
info(message: string, ...args: unknown[]): void
|
|
737
|
+
|
|
771
738
|
/**
|
|
772
739
|
* Logs a warning message.
|
|
773
740
|
*/
|
|
774
741
|
warn(message: string, ...args: unknown[]): void
|
|
742
|
+
|
|
775
743
|
/**
|
|
776
744
|
* Logs an error message.
|
|
777
745
|
*/
|
|
778
746
|
error(message: string | Error, ...args: unknown[]): void
|
|
747
|
+
|
|
779
748
|
/**
|
|
780
749
|
* Sets the log level.
|
|
781
750
|
*/
|
|
782
751
|
setLevel(level: LogLevel): void
|
|
752
|
+
|
|
783
753
|
/**
|
|
784
754
|
* Gets the current log level.
|
|
785
755
|
*/
|
|
786
756
|
getLevel(): LogLevel
|
|
757
|
+
|
|
787
758
|
/**
|
|
788
759
|
* Creates a child logger with a namespace.
|
|
789
760
|
*/
|
|
790
761
|
child(name: string, context?: Record<string, unknown>): Logger
|
|
762
|
+
|
|
791
763
|
/**
|
|
792
764
|
* Adds additional context to the logger.
|
|
793
765
|
*/
|
|
794
766
|
withContext(context: Record<string, unknown>): Logger
|
|
767
|
+
|
|
795
768
|
/**
|
|
796
769
|
* Adds a transport.
|
|
797
770
|
*/
|
|
798
771
|
addTransport(transport: LogTransport): () => void
|
|
772
|
+
|
|
799
773
|
/**
|
|
800
774
|
* Removes a transport.
|
|
801
775
|
*/
|
|
@@ -814,30 +788,37 @@ interface LoggerProvider {
|
|
|
814
788
|
* Gets a logger by name, or the root logger if no name given.
|
|
815
789
|
*/
|
|
816
790
|
getLogger(name?: string): Logger
|
|
791
|
+
|
|
817
792
|
/**
|
|
818
793
|
* Creates a named logger.
|
|
819
794
|
*/
|
|
820
795
|
createLogger(nameOrConfig: string | LoggerConfig, config?: LoggerConfig): Logger
|
|
796
|
+
|
|
821
797
|
/**
|
|
822
798
|
* Sets the global log level.
|
|
823
799
|
*/
|
|
824
800
|
setLevel(level: LogLevel): void
|
|
801
|
+
|
|
825
802
|
/**
|
|
826
803
|
* Gets the global log level.
|
|
827
804
|
*/
|
|
828
805
|
getLevel(): LogLevel
|
|
806
|
+
|
|
829
807
|
/**
|
|
830
808
|
* Adds a global transport.
|
|
831
809
|
*/
|
|
832
810
|
addTransport(transport: LogTransport): () => void
|
|
811
|
+
|
|
833
812
|
/**
|
|
834
813
|
* Enables logging.
|
|
835
814
|
*/
|
|
836
815
|
enable(): void
|
|
816
|
+
|
|
837
817
|
/**
|
|
838
818
|
* Disables logging.
|
|
839
819
|
*/
|
|
840
820
|
disable(): void
|
|
821
|
+
|
|
841
822
|
/**
|
|
842
823
|
* Checks if logging is enabled.
|
|
843
824
|
*
|
|
@@ -857,18 +838,22 @@ interface RouteLocation {
|
|
|
857
838
|
* Current pathname.
|
|
858
839
|
*/
|
|
859
840
|
pathname: string
|
|
841
|
+
|
|
860
842
|
/**
|
|
861
843
|
* Query string (including leading ?).
|
|
862
844
|
*/
|
|
863
845
|
search: string
|
|
846
|
+
|
|
864
847
|
/**
|
|
865
848
|
* Hash (including leading #).
|
|
866
849
|
*/
|
|
867
850
|
hash: string
|
|
851
|
+
|
|
868
852
|
/**
|
|
869
853
|
* State data passed with navigation.
|
|
870
854
|
*/
|
|
871
855
|
state?: unknown
|
|
856
|
+
|
|
872
857
|
/**
|
|
873
858
|
* Unique key for this location.
|
|
874
859
|
*/
|
|
@@ -888,26 +873,32 @@ interface Router {
|
|
|
888
873
|
* Returns the current route location (pathname, search, hash, state).
|
|
889
874
|
*/
|
|
890
875
|
getLocation(): RouteLocation
|
|
876
|
+
|
|
891
877
|
/**
|
|
892
878
|
* Gets the current route params.
|
|
893
879
|
*/
|
|
894
880
|
getParams<T extends RouteParams = RouteParams>(): T
|
|
881
|
+
|
|
895
882
|
/**
|
|
896
883
|
* Gets the current query params.
|
|
897
884
|
*/
|
|
898
885
|
getQuery(): QueryParams
|
|
886
|
+
|
|
899
887
|
/**
|
|
900
888
|
* Gets a specific query parameter.
|
|
901
889
|
*/
|
|
902
890
|
getQueryParam(key: string): string | undefined
|
|
891
|
+
|
|
903
892
|
/**
|
|
904
893
|
* Gets the current hash.
|
|
905
894
|
*/
|
|
906
895
|
getHash(): string
|
|
896
|
+
|
|
907
897
|
/**
|
|
908
898
|
* Navigates to a path.
|
|
909
899
|
*/
|
|
910
900
|
navigate(path: string, options?: NavigateOptions): void
|
|
901
|
+
|
|
911
902
|
/**
|
|
912
903
|
* Navigates to a named route.
|
|
913
904
|
*/
|
|
@@ -917,36 +908,44 @@ interface Router {
|
|
|
917
908
|
query?: QueryParams,
|
|
918
909
|
options?: NavigateOptions,
|
|
919
910
|
): void
|
|
911
|
+
|
|
920
912
|
/**
|
|
921
913
|
* Goes back in history.
|
|
922
914
|
*/
|
|
923
915
|
back(): void
|
|
916
|
+
|
|
924
917
|
/**
|
|
925
918
|
* Goes forward in history.
|
|
926
919
|
*/
|
|
927
920
|
forward(): void
|
|
921
|
+
|
|
928
922
|
/**
|
|
929
923
|
* Goes to a specific point in history.
|
|
930
924
|
*/
|
|
931
925
|
go(delta: number): void
|
|
926
|
+
|
|
932
927
|
/**
|
|
933
928
|
* Updates the current query params.
|
|
934
929
|
*/
|
|
935
930
|
setQuery(params: QueryParams, options?: NavigateOptions): void
|
|
931
|
+
|
|
936
932
|
/**
|
|
937
933
|
* Updates a specific query parameter.
|
|
938
934
|
*/
|
|
939
935
|
setQueryParam(key: string, value: string | undefined, options?: NavigateOptions): void
|
|
936
|
+
|
|
940
937
|
/**
|
|
941
938
|
* Updates the current hash.
|
|
942
939
|
*/
|
|
943
940
|
setHash(hash: string, options?: NavigateOptions): void
|
|
941
|
+
|
|
944
942
|
/**
|
|
945
943
|
* Checks if a path matches the current location.
|
|
946
944
|
*
|
|
947
945
|
* @returns `true` if the path matches the current route.
|
|
948
946
|
*/
|
|
949
947
|
isActive(path: string, exact?: boolean): boolean
|
|
948
|
+
|
|
950
949
|
/**
|
|
951
950
|
* Matches a path pattern against a pathname.
|
|
952
951
|
*/
|
|
@@ -954,26 +953,32 @@ interface Router {
|
|
|
954
953
|
pattern: string,
|
|
955
954
|
pathname: string,
|
|
956
955
|
): RouteMatch<Params> | null
|
|
956
|
+
|
|
957
957
|
/**
|
|
958
958
|
* Generates a URL from a named route.
|
|
959
959
|
*/
|
|
960
960
|
generatePath(name: string, params?: RouteParams, query?: QueryParams): string
|
|
961
|
+
|
|
961
962
|
/**
|
|
962
963
|
* Subscribes to route changes.
|
|
963
964
|
*/
|
|
964
965
|
subscribe(listener: RouteChangeListener): () => void
|
|
966
|
+
|
|
965
967
|
/**
|
|
966
968
|
* Adds a navigation guard.
|
|
967
969
|
*/
|
|
968
970
|
addGuard(guard: NavigationGuard): () => void
|
|
971
|
+
|
|
969
972
|
/**
|
|
970
973
|
* Registers route definitions.
|
|
971
974
|
*/
|
|
972
975
|
registerRoutes(routes: RouteDefinition[]): void
|
|
976
|
+
|
|
973
977
|
/**
|
|
974
978
|
* Gets all registered routes.
|
|
975
979
|
*/
|
|
976
980
|
getRoutes(): RouteDefinition[]
|
|
981
|
+
|
|
977
982
|
/**
|
|
978
983
|
* Destroys the router.
|
|
979
984
|
*/
|
|
@@ -991,10 +996,12 @@ interface StoreConfig<T> {
|
|
|
991
996
|
* Initial state value.
|
|
992
997
|
*/
|
|
993
998
|
initialState: T
|
|
999
|
+
|
|
994
1000
|
/**
|
|
995
1001
|
* Optional name for debugging.
|
|
996
1002
|
*/
|
|
997
1003
|
name?: string
|
|
1004
|
+
|
|
998
1005
|
/**
|
|
999
1006
|
* Optional middleware functions.
|
|
1000
1007
|
*/
|
|
@@ -1014,15 +1021,18 @@ interface Store<T> {
|
|
|
1014
1021
|
* Gets the current state.
|
|
1015
1022
|
*/
|
|
1016
1023
|
getState(): T
|
|
1024
|
+
|
|
1017
1025
|
/**
|
|
1018
1026
|
* Sets the state (partial or via updater function).
|
|
1019
1027
|
*/
|
|
1020
1028
|
setState(partial: Partial<T> | ((state: T) => Partial<T>)): void
|
|
1029
|
+
|
|
1021
1030
|
/**
|
|
1022
1031
|
* Subscribes to state changes.
|
|
1023
1032
|
* Returns an unsubscribe function.
|
|
1024
1033
|
*/
|
|
1025
1034
|
subscribe(listener: StateListener<T>): () => void
|
|
1035
|
+
|
|
1026
1036
|
/**
|
|
1027
1037
|
* Destroys the store and cleans up subscriptions.
|
|
1028
1038
|
*/
|
|
@@ -1056,34 +1066,42 @@ interface StorageProvider {
|
|
|
1056
1066
|
* Gets a value from storage.
|
|
1057
1067
|
*/
|
|
1058
1068
|
get<T = unknown>(key: string): Promise<T | null>
|
|
1069
|
+
|
|
1059
1070
|
/**
|
|
1060
1071
|
* Sets a value in storage.
|
|
1061
1072
|
*/
|
|
1062
1073
|
set<T = unknown>(key: string, value: T): Promise<void>
|
|
1074
|
+
|
|
1063
1075
|
/**
|
|
1064
1076
|
* Removes a value from storage.
|
|
1065
1077
|
*/
|
|
1066
1078
|
remove(key: string): Promise<void>
|
|
1079
|
+
|
|
1067
1080
|
/**
|
|
1068
1081
|
* Clears all values from storage.
|
|
1069
1082
|
*/
|
|
1070
1083
|
clear(): Promise<void>
|
|
1084
|
+
|
|
1071
1085
|
/**
|
|
1072
1086
|
* Gets all keys in storage.
|
|
1073
1087
|
*/
|
|
1074
1088
|
keys(): Promise<string[]>
|
|
1089
|
+
|
|
1075
1090
|
/**
|
|
1076
1091
|
* Gets multiple values from storage.
|
|
1077
1092
|
*/
|
|
1078
1093
|
getMany?<T = unknown>(keys: string[]): Promise<Map<string, T | null>>
|
|
1094
|
+
|
|
1079
1095
|
/**
|
|
1080
1096
|
* Sets multiple values in storage.
|
|
1081
1097
|
*/
|
|
1082
1098
|
setMany?<T = unknown>(entries: Array<[string, T]>): Promise<void>
|
|
1099
|
+
|
|
1083
1100
|
/**
|
|
1084
1101
|
* Removes multiple values from storage.
|
|
1085
1102
|
*/
|
|
1086
1103
|
removeMany?(keys: string[]): Promise<void>
|
|
1104
|
+
|
|
1087
1105
|
/**
|
|
1088
1106
|
* Reads a value synchronously.
|
|
1089
1107
|
*
|
|
@@ -1097,6 +1115,7 @@ interface StorageProvider {
|
|
|
1097
1115
|
* @returns The stored value, or `null` when it is absent, unreadable or corrupt.
|
|
1098
1116
|
*/
|
|
1099
1117
|
getSync?<T = unknown>(key: string): T | null
|
|
1118
|
+
|
|
1100
1119
|
/**
|
|
1101
1120
|
* Subscribes to changes made to a key OUTSIDE this provider instance — for
|
|
1102
1121
|
* example another browser tab's `localStorage` write.
|
|
@@ -1123,16 +1142,19 @@ interface ThemeProvider {
|
|
|
1123
1142
|
* Returns the currently active theme.
|
|
1124
1143
|
*/
|
|
1125
1144
|
getTheme(): Theme
|
|
1145
|
+
|
|
1126
1146
|
/**
|
|
1127
1147
|
* Sets the active theme by reference or by name.
|
|
1128
1148
|
*
|
|
1129
1149
|
* @param theme - A `Theme` object or a theme name string to activate.
|
|
1130
1150
|
*/
|
|
1131
1151
|
setTheme(theme: Theme | string): void
|
|
1152
|
+
|
|
1132
1153
|
/**
|
|
1133
1154
|
* Toggles between light and dark mode for the active theme.
|
|
1134
1155
|
*/
|
|
1135
1156
|
toggleMode(): void
|
|
1157
|
+
|
|
1136
1158
|
/**
|
|
1137
1159
|
* Subscribes to theme changes. The callback fires whenever
|
|
1138
1160
|
* `setTheme()` or `toggleMode()` is called.
|
|
@@ -1141,11 +1163,13 @@ interface ThemeProvider {
|
|
|
1141
1163
|
* @returns An unsubscribe function.
|
|
1142
1164
|
*/
|
|
1143
1165
|
subscribe(callback: (theme: Theme) => void): () => void
|
|
1166
|
+
|
|
1144
1167
|
/**
|
|
1145
1168
|
* Returns all registered themes. Optional — not all providers
|
|
1146
1169
|
* support multiple themes.
|
|
1147
1170
|
*/
|
|
1148
1171
|
getThemes?(): Theme[]
|
|
1172
|
+
|
|
1149
1173
|
/**
|
|
1150
1174
|
* Returns the theme a render WITHOUT a browser produces — a server or
|
|
1151
1175
|
* build-time render, which has no storage and no `prefers-color-scheme`
|