@molecule/app-angular 3.0.0 → 3.1.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/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-10-27T23:35:25.792Z
6
+ Generated: 2026-10-31T13:49:31.073Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-angular
@@ -94,7 +94,10 @@ Reactive authentication state snapshot (initialized, authenticated, user, loadin
94
94
  interface AuthState<T = UserProfile> {
95
95
  /**
96
96
  * The session's state as one value — render from this instead of combining
97
- * `initialized`/`authenticated`/`loading`. See {@link AuthStatus}.
97
+ * `initialized`/`authenticated`/`loading`. `'loading'` is undecided, so wait
98
+ * and redirect only on `'unauthenticated'`; `'unavailable'` keeps the candidate
99
+ * for retry and can have a null profile. A restore failure other than 401/403
100
+ * never signs out. See {@link AuthStatus}.
98
101
  */
99
102
  status: AuthStatus
100
103
  /**
@@ -102,11 +105,14 @@ interface AuthState<T = UserProfile> {
102
105
  */
103
106
  initialized: boolean
104
107
  /**
105
- * Whether the user is authenticated.
108
+ * Whether the client has an authenticated session. This is not a server
109
+ * confirmation flag: during `'unavailable'` it can be false for a retained
110
+ * token/cookie-only candidate with no cached profile. Use `status` for redirects.
106
111
  */
107
112
  authenticated: boolean
108
113
  /**
109
- * Current user (if authenticated).
114
+ * Current user, or null when none is cached. In particular, an `'unavailable'`
115
+ * token/cookie-only restore has a retained candidate but no profile yet.
110
116
  */
111
117
  user: T | null
112
118
  /**
@@ -160,12 +166,23 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
160
166
  * Updates the cached user object (state + persistent storage) without
161
167
  * hitting the network. Intended for local refreshes after a per-app
162
168
  * mutation (e.g., the user just PATCHed their own profile and the
163
- * server returned the canonical row). Does NOT change tokens.
169
+ * server returned the canonical row). A non-null profile does NOT change
170
+ * tokens or sign the client in: `authenticated` and `status` are unchanged,
171
+ * so an anonymous client stays anonymous. Use {@link login} /
172
+ * {@link register} for a credential exchange, or {@link setSession} when
173
+ * the token was issued outside the client.
164
174
  *
165
- * This does not sign the client in: `authenticated` and `status` are
166
- * unchanged, so an anonymous client stays anonymous. Use
167
- * {@link login} / {@link register} for a credential exchange, or
168
- * {@link setSession} when the token was issued outside the client.
175
+ * Passing `null` on a signed-in client, or while any session operation is
176
+ * pending, ends the local session: it clears the access token, refresh token
177
+ * and cached user, stops automatic refresh, and settles `authenticated: false`
178
+ * with `status: 'unauthenticated'` in one notification. Every older operation
179
+ * loses session ownership, and a persistent sign-out marker prevents a reload
180
+ * from restoring its credentials or a late cookie. A late credential exchange
181
+ * is revoked best-effort when a logout endpoint is configured, without blocking
182
+ * the caller. This method does not otherwise call the server for a settled
183
+ * session; use {@link logout} for explicit server revocation. On a settled
184
+ * anonymous client, `null` only clears the cached profile and leaves tokens
185
+ * and auth state unchanged.
169
186
  */
170
187
  setUser(user: T | null): void;
171
188
  /**
@@ -180,10 +197,13 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
180
197
  * which would violate the storage contract and make a stored bearer token
181
198
  * JS-readable (XSS-exfiltratable). Pass `null` to clear it.
182
199
  *
183
- * This changes token storage only; it does not sign the client in
184
- * (`authenticated` and `status` are unchanged). Use {@link login} /
185
- * {@link register} for a credential exchange, or call {@link setSession}
186
- * with the token and the user to establish an already-issued session.
200
+ * This changes token storage only: passing `null` does not by itself sign a
201
+ * signed-in client out, and a non-null token does not sign an anonymous
202
+ * client in (`authenticated` and `status` are unchanged). Use {@link logout}
203
+ * to end a session, or {@link setUser} with `null` for local-only sign-out.
204
+ * Use {@link login} / {@link register} for a credential exchange, or call
205
+ * {@link setSession} with the token and user to establish an already-issued
206
+ * session.
187
207
  */
188
208
  setAccessToken(token: string | null): void;
189
209
  /**
@@ -208,7 +228,16 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
208
228
  */
209
229
  login(credentials: LoginCredentials): Promise<AuthResult<T>>;
210
230
  /**
211
- * Logs out the current user.
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.
212
241
  */
213
242
  logout(): Promise<void>;
214
243
  /**
@@ -260,37 +289,6 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
260
289
  * until the cookie restore decides.
261
290
  *
262
291
  * Do not put this call (or a `/me` request of your own) in front of the first
263
- * render, and do not render a loading screen over a session it just restored:
264
- * `whenRestored()` already resolves as soon as the restore has settled, and the
265
- * HTTP gate built on it holds requests for exactly that window.
266
- */
267
- initialize(): Promise<void>;
268
- /**
269
- * Re-checks a restored session against the server, in the background — the
270
- * boot-time validation an app with a stored token needs when a revoked or
271
- * expired token must sign the user out. Call it AFTER the first render
272
- * (`initialize()` restores synchronously from storage; this costs one request).
273
- *
274
- * - The server confirms the user: the session is refreshed and {@link AuthState.status}
275
- * stays `'authenticated'`.
276
- * - The server answers 401 or 403: the token is dead — the stored session is
277
- * cleared and the status becomes `'unauthenticated'`.
278
- * - The server cannot confirm the session — a network failure, a 5xx, or a 404
279
- * from a misconfigured {@link AuthClientConfig.currentUserEndpoint}: the
280
- * session (token AND user) is KEPT and the status becomes `'unavailable'`, so
281
- * the app can retry instead of signing the user out over a bad connection or a
282
- * route that does not exist. The 404 error names `currentUserEndpoint`.
283
- *
284
- * Do not hand-write this beside the client: a parallel token/user store for a
285
- * "validating"/"unavailable" flag is the race this method removes.
286
- *
287
- * Optional: a provider with no restorable session has nothing to validate.
288
- */
289
- validateSession?(): Promise<void>;
290
- /**
291
- * Resolves when the session restore started by `initialize()` has settled — the point
292
- * after which the client knows whether this visitor is signed in.
293
- *
294
292
  // … truncated — the full declaration is in node_modules/@molecule/app-angular/dist
295
293
  ```
296
294
 
@@ -379,9 +377,20 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
379
377
  * `defaultValues`, or the values a previous `reset(values)` established.
380
378
  * Passing `values` merges them over the current baseline and makes the
381
379
  * result the new baseline, so a form reset to freshly loaded or saved data
382
- * reads clean (`isDirty === false`).
380
+ * reads clean (`isDirty === false`). A changed non-null `id` replaces the
381
+ * record and cancels a pending submit.
383
382
  */
384
383
  reset(values?: Partial<T>): void
384
+ /**
385
+ * Applies externally loaded values without clearing submission state.
386
+ *
387
+ * The new clean baseline is the original `defaultValues` plus this latest
388
+ * record, never a merge of earlier records. With `keepDirtyValues`, edited
389
+ * fields retain their values while pristine fields take the loaded values.
390
+ * A changed non-null `id` still replaces the record and cancels a pending
391
+ * submit. Equal-content baselines cause no update.
392
+ */
393
+ updateValues(values: Partial<T>, resetOptions?: FormResetOptions): void
385
394
  /**
386
395
  * Handles form submission.
387
396
  */
@@ -415,6 +424,14 @@ interface FormOptions<T extends FormValuesConstraint<T>> {
415
424
  * is created. Mutating this object afterwards does not change the baseline.
416
425
  */
417
426
  defaultValues?: Partial<T>
427
+ /**
428
+ * Externally loaded values, merged over `defaultValues` as the clean
429
+ * baseline. Framework bindings also apply later content changes; use
430
+ * `resetOptions.keepDirtyValues` to preserve edits while pristine fields fill.
431
+ */
432
+ values?: Partial<T>
433
+ /** Controls how framework bindings apply changed `values`. */
434
+ resetOptions?: FormResetOptions
418
435
  /**
419
436
  * Validation mode.
420
437
  */
@@ -1662,9 +1679,9 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
1662
1679
  constructor(private controller: FormController<T>) {
1663
1680
  this.stateSubject = new BehaviorSubject<FormState<T>>(controller.getState())
1664
1681
 
1665
- this.unsubscribe = controller.subscribe((state: FormState<T>) => {
1666
- this.stateSubject.next(state)
1667
- })
1682
+ const refresh = (): void => this.stateSubject.next(controller.getState())
1683
+ this.unsubscribe = controller.subscribe(refresh)
1684
+ refresh()
1668
1685
 
1669
1686
  this.state$ = this.stateSubject.asObservable()
1670
1687
 
@@ -1800,6 +1817,16 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
1800
1817
  return this.controller.handleSubmit(onSubmit, onError)
1801
1818
  }
1802
1819
 
1820
+ /**
1821
+ * Apply a newly loaded record without clearing submission state.
1822
+ *
1823
+ * @param values - The newly loaded record.
1824
+ * @param resetOptions - Set `keepDirtyValues` to retain edits and fill pristine fields.
1825
+ */
1826
+ updateValues(values: Partial<T>, resetOptions: FormResetOptions = {}): void {
1827
+ this.controller.updateValues(values, resetOptions)
1828
+ }
1829
+
1803
1830
  /**
1804
1831
  * Reset the form to initial values.
1805
1832
  *
@@ -1848,12 +1875,15 @@ export class MoleculeFormsService implements OnDestroy {
1848
1875
  * Create a form instance from a provider.
1849
1876
  *
1850
1877
  * @param provider - The form provider that creates form controllers.
1851
- * @param options - Form configuration including default values and validation mode.
1852
- * @returns A new form instance with RxJS observables for reactive state tracking.
1878
+ * @param options - Narrowed `FormOptions` without `values` or `resetOptions`;
1879
+ * includes default values and validation mode.
1880
+ * @returns A new form instance with RxJS observables and explicit
1881
+ * `updateValues(values, { keepDirtyValues })` delivery. The option defaults to
1882
+ * false; pass true to retain edited fields while pristine fields take the record.
1853
1883
  */
1854
1884
  createForm<T extends FormValuesConstraint<T>>(
1855
1885
  provider: FormProvider,
1856
- options: FormOptions<T>,
1886
+ options: AngularFormOptions<T>,
1857
1887
  ): MoleculeFormInstance<T> {
1858
1888
  const controller = provider.createForm(options)
1859
1889
  const instance = new MoleculeFormInstance<T>(controller)
@@ -5,8 +5,16 @@
5
5
  */
6
6
  import { type OnDestroy } from '@angular/core';
7
7
  import { type Observable } from 'rxjs';
8
- import type { FieldRegistration, FormController, FormOptions, FormProvider, FormState, FormValuesConstraint, RegisterOptions } from '@molecule/app-forms';
8
+ import type { FieldRegistration, FormController, FormOptions, FormProvider, FormResetOptions, FormState, FormValuesConstraint, RegisterOptions } from '@molecule/app-forms';
9
9
  import * as i0 from "@angular/core";
10
+ /**
11
+ * Angular form creation options. Unlike `FormOptions`, this narrowed type does
12
+ * not accept `values` or `resetOptions`: signal-backed getters are not observed.
13
+ * Deliver records after creation through the returned instance's
14
+ * `updateValues(values, { keepDirtyValues })` method. The option defaults to
15
+ * false; pass true to retain edited fields while pristine fields take the record.
16
+ */
17
+ type AngularFormOptions<T extends FormValuesConstraint<T>> = Omit<FormOptions<T>, 'values' | 'resetOptions'>;
10
18
  /**
11
19
  * Wrapper around a FormController that provides RxJS observables and
12
20
  * synchronous accessors for use in Angular components.
@@ -150,6 +158,13 @@ export declare class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
150
158
  handleSubmit(onSubmit: (values: T) => void | Promise<void>, onError?: (errors: Partial<Record<keyof T, string>>) => void): (event?: {
151
159
  preventDefault?: () => void;
152
160
  }) => Promise<void>;
161
+ /**
162
+ * Apply a newly loaded record without clearing submission state.
163
+ *
164
+ * @param values - The newly loaded record.
165
+ * @param resetOptions - Set `keepDirtyValues` to retain edits and fill pristine fields.
166
+ */
167
+ updateValues(values: Partial<T>, resetOptions?: FormResetOptions): void;
153
168
  /**
154
169
  * Reset the form to initial values.
155
170
  *
@@ -223,10 +238,13 @@ export declare class MoleculeFormsService implements OnDestroy {
223
238
  * Create a form instance from a provider.
224
239
  *
225
240
  * @param provider - The form provider that creates form controllers.
226
- * @param options - Form configuration including default values and validation mode.
227
- * @returns A new form instance with RxJS observables for reactive state tracking.
241
+ * @param options - Narrowed `FormOptions` without `values` or `resetOptions`;
242
+ * includes default values and validation mode.
243
+ * @returns A new form instance with RxJS observables and explicit
244
+ * `updateValues(values, { keepDirtyValues })` delivery. The option defaults to
245
+ * false; pass true to retain edited fields while pristine fields take the record.
228
246
  */
229
- createForm<T extends FormValuesConstraint<T>>(provider: FormProvider, options: FormOptions<T>): MoleculeFormInstance<T>;
247
+ createForm<T extends FormValuesConstraint<T>>(provider: FormProvider, options: AngularFormOptions<T>): MoleculeFormInstance<T>;
230
248
  /**
231
249
  * Destroy all managed form instances on service destruction.
232
250
  */
@@ -234,4 +252,5 @@ export declare class MoleculeFormsService implements OnDestroy {
234
252
  static ɵfac: i0.ɵɵFactoryDeclaration<MoleculeFormsService, never>;
235
253
  static ɵprov: i0.ɵɵInjectableDeclaration<any>;
236
254
  }
255
+ export {};
237
256
  //# sourceMappingURL=forms.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"forms.service.d.ts","sourceRoot":"","sources":["../../src/services/forms.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAA8C,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAElF,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,eAAe,EAChB,MAAM,qBAAqB,CAAA;;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,oBAAoB,CAAC,CAAC,SAAS,oBAAoB,CAAC,CAAC,CAAC;IA6BrD,OAAO,CAAC,UAAU;IA5B9B,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,WAAW,CAA4B;IAE/C;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAE7B;;OAEG;IACH,QAAQ,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AC;IAO1B;;OAEG;IACH,WAAW,IAAI,IAAI;yCA1BR,oBAAoB;;CAgChC"}
@@ -59,9 +59,9 @@ export class MoleculeFormInstance {
59
59
  this.controller = controller;
60
60
  this.unsubscribe = null;
61
61
  this.stateSubject = new BehaviorSubject(controller.getState());
62
- this.unsubscribe = controller.subscribe((state) => {
63
- this.stateSubject.next(state);
64
- });
62
+ const refresh = () => this.stateSubject.next(controller.getState());
63
+ this.unsubscribe = controller.subscribe(refresh);
64
+ refresh();
65
65
  this.state$ = this.stateSubject.asObservable();
66
66
  this.isValid$ = this.state$.pipe(map((state) => state.isValid), distinctUntilChanged());
67
67
  this.isDirty$ = this.state$.pipe(map((state) => state.isDirty), distinctUntilChanged());
@@ -166,6 +166,15 @@ export class MoleculeFormInstance {
166
166
  handleSubmit(onSubmit, onError) {
167
167
  return this.controller.handleSubmit(onSubmit, onError);
168
168
  }
169
+ /**
170
+ * Apply a newly loaded record without clearing submission state.
171
+ *
172
+ * @param values - The newly loaded record.
173
+ * @param resetOptions - Set `keepDirtyValues` to retain edits and fill pristine fields.
174
+ */
175
+ updateValues(values, resetOptions = {}) {
176
+ this.controller.updateValues(values, resetOptions);
177
+ }
169
178
  /**
170
179
  * Reset the form to initial values.
171
180
  *
@@ -250,8 +259,11 @@ export class MoleculeFormsService {
250
259
  * Create a form instance from a provider.
251
260
  *
252
261
  * @param provider - The form provider that creates form controllers.
253
- * @param options - Form configuration including default values and validation mode.
254
- * @returns A new form instance with RxJS observables for reactive state tracking.
262
+ * @param options - Narrowed `FormOptions` without `values` or `resetOptions`;
263
+ * includes default values and validation mode.
264
+ * @returns A new form instance with RxJS observables and explicit
265
+ * `updateValues(values, { keepDirtyValues })` delivery. The option defaults to
266
+ * false; pass true to retain edited fields while pristine fields take the record.
255
267
  */
256
268
  createForm(provider, options) {
257
269
  const controller = provider.createForm(options);
@@ -1 +1 @@
1
- {"version":3,"file":"forms.service.js","sourceRoot":"","sources":["../../src/services/forms.service.ts"],"names":[],"mappings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;IACH,OAAO;QACL,IAAI,CAAC,WAAW,EAAE,EAAE,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;QACvB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAA;QAC5B,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAA;IAC3B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,MAAM,OAAO,oBAAoB;IAHjC;QAIU,cAAS,GAAoD,EAAE,CAAA;KA+BxE;IA7BC;;;;;;;;;OASG;IACH,UAAU,CACR,QAAsB,EACtB,OAA8B;QAE9B,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QAC/C,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CAAI,UAAU,CAAC,CAAA;QACxD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAyD,CAAC,CAAA;QAC9E,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;OAEG;IACH,WAAW;QACT,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,QAAQ,CAAC,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;IACrB,CAAC;qHA/BU,oBAAoB;uEAApB,oBAAoB,WAApB,oBAAoB,mBAFnB,MAAM;;iFAEP,oBAAoB;cAHhC,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-angular",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Angular framework bindings for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",