@rdlabo/ionic-angular-kit 0.0.26 → 21.2.0-4

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/package.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "@rdlabo/ionic-angular-kit",
3
- "version": "0.0.26",
3
+ "version": "21.2.0-4",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/rdlabo-team/ionic-angular-library.git"
7
+ },
4
8
  "peerDependencies": {
5
9
  "@angular/common": "^21.0.0",
6
10
  "@angular/core": "^21.0.0",
@@ -12,6 +12,9 @@ import { BehaviorSubject } from 'rxjs';
12
12
  * palette passes `darkClasses: ['ion-palette-dark'], lightClasses: []`, while an app with an extra
13
13
  * design-system palette adds its own classes (e.g. `darkClasses: ['ion-palette-dark', 'a2ui-dark']`,
14
14
  * `lightClasses: ['a2ui-light']`).
15
+ *
16
+ * Prefer `KIT_THEME_STORAGE_KEY` (from `@rdlabo/ionic-angular-kit`) as `storageKey` so logout
17
+ * clear-preserving lists stay in sync.
15
18
  */
16
19
  interface KitThemeConfig {
17
20
  /** Key under which the chosen theme (`'light'` | `'dark'`) is persisted via `KitStorageService`. */
@@ -35,10 +38,13 @@ declare const KIT_THEME_CONFIG: InjectionToken<KitThemeConfig>;
35
38
  * @returns environment providers to add to the application's provider list
36
39
  * @example
37
40
  * ```ts
41
+ * import { KIT_THEME_STORAGE_KEY } from '@rdlabo/ionic-angular-kit';
42
+ * import { provideKitTheme } from '@rdlabo/ionic-angular-kit/theme';
43
+ *
38
44
  * bootstrapApplication(AppComponent, {
39
45
  * providers: [
40
46
  * provideKitTheme({
41
- * storageKey: StorageKeyEnum.theme,
47
+ * storageKey: KIT_THEME_STORAGE_KEY,
42
48
  * darkClasses: ['ion-palette-dark', 'a2ui-dark'],
43
49
  * lightClasses: ['a2ui-light'],
44
50
  * }),
@@ -130,6 +130,55 @@ declare const kitRecallEmail: (store: KitEmailStore) => Promise<string | null>;
130
130
  */
131
131
  declare const kitForgetEmail: (store: KitEmailStore) => Promise<void>;
132
132
 
133
+ /**
134
+ * Canonical storage keys persisted via {@link KitStorageService} that fleet apps often need to
135
+ * keep across a sign-out `clear()`.
136
+ *
137
+ * @remarks
138
+ * `KIT_LAST_AUTH_EMAIL_KEY` lives in `kit-auth-email-store` and is exported from the package root.
139
+ * Import both keys from `@rdlabo/ionic-angular-kit` alongside {@link kitClearStoragePreservingKeys}.
140
+ */
141
+ /**
142
+ * Light/dark preference for `provideKitTheme` / `KitThemeController`.
143
+ *
144
+ * @remarks
145
+ * Pass this as `provideKitTheme({ storageKey: KIT_THEME_STORAGE_KEY, … })` and include it in
146
+ * {@link kitClearStoragePreservingKeys} so logout does not reset the user's theme.
147
+ */
148
+ declare const KIT_THEME_STORAGE_KEY = "theme";
149
+
150
+ /**
151
+ * Clear a key/value store while restoring selected keys afterward.
152
+ *
153
+ * @remarks
154
+ * Fleet apps often call `storage.clear()` on sign-out to drop session/token state. Values that
155
+ * should survive logout (for example {@link KIT_LAST_AUTH_EMAIL_KEY}) are passed in `keys`.
156
+ * Missing keys are skipped — only non-null values are written back.
157
+ */
158
+ /** Minimal clearable store — structurally satisfied by {@link KitStorageService}. */
159
+ interface KitClearableStore {
160
+ get<T>(key: string): Promise<T | null>;
161
+ set<T>(key: string, value: T): Promise<void>;
162
+ clear(): Promise<void>;
163
+ }
164
+ /**
165
+ * Wipe the store, then restore the given keys to their pre-clear values (when present).
166
+ *
167
+ * @param store - the app's storage (e.g. `KitStorageService`)
168
+ * @param keys - keys whose values should survive the clear
169
+ *
170
+ * @example
171
+ * ```ts
172
+ * import { KIT_LAST_AUTH_EMAIL_KEY, KIT_THEME_STORAGE_KEY, kitClearStoragePreservingKeys } from '@rdlabo/ionic-angular-kit';
173
+ *
174
+ * await kitSignOut(auth, {
175
+ * success: () =>
176
+ * kitClearStoragePreservingKeys(this.storage, [KIT_LAST_AUTH_EMAIL_KEY, KIT_THEME_STORAGE_KEY]),
177
+ * });
178
+ * ```
179
+ */
180
+ declare const kitClearStoragePreservingKeys: (store: KitClearableStore, keys: readonly string[]) => Promise<void>;
181
+
133
182
  /**
134
183
  * User-visible button labels consumed by `KitOverlayController`.
135
184
  *
@@ -542,6 +591,70 @@ declare class KitReloadAlertController {
542
591
  static ɵprov: i0.ɵɵInjectableDeclaration<KitReloadAlertController>;
543
592
  }
544
593
 
594
+ /**
595
+ * Content for {@link KitMaintenanceController.present}.
596
+ */
597
+ interface KitMaintenanceOptions {
598
+ /** Alert header, e.g. "メンテナンス中です". */
599
+ header: string;
600
+ /** Alert body; keep short — the user cannot dismiss until maintenance ends. */
601
+ message: string;
602
+ /**
603
+ * Absolute URL of the fleet maintenance wait SSE (`GET /public/maintenance/wait`).
604
+ *
605
+ * @remarks
606
+ * Typically `environment.api + 'public/maintenance/wait'`. While the overlay is shown the
607
+ * controller opens an {@link EventSource} on this URL and dismisses on `event: ended`.
608
+ */
609
+ waitUrl: string;
610
+ }
611
+ /**
612
+ * Singleton "maintenance lock" overlay: backdrop-locked, no dismiss buttons, auto-clears via SSE.
613
+ *
614
+ * @remarks
615
+ * Mirrors {@link KitReloadAlertController} as a de-duped stateful controller, but the user cannot
616
+ * cancel or reload out of it — only the server `event: ended` on {@link KitMaintenanceOptions.waitUrl}
617
+ * (or an explicit {@link dismiss}) clears it. Uses Ionic's `AlertController` (not a feature modal)
618
+ * so the kit stays free of page components / i18n; all copy is supplied by the caller.
619
+ *
620
+ * Wire from {@link KitHttpConfig.onMaintenance} when the API returns `503` with
621
+ * `error.error?.code === 'MAINTENANCE'`.
622
+ *
623
+ * @example
624
+ * ```ts
625
+ * provideKitHttp(() => {
626
+ * const maintenance = inject(KitMaintenanceController);
627
+ * return {
628
+ * getAuthHeaders: async () => ({}),
629
+ * onMaintenance: () =>
630
+ * void maintenance.present({
631
+ * header: 'メンテナンス中です',
632
+ * message: 'しばらくお待ちください。終了次第、自動で閉じます。',
633
+ * waitUrl: environment.api + 'public/maintenance/wait',
634
+ * }),
635
+ * };
636
+ * });
637
+ * ```
638
+ */
639
+ declare class KitMaintenanceController {
640
+ #private;
641
+ /**
642
+ * Present the lock overlay and start waiting on the maintenance SSE, unless one is already showing.
643
+ *
644
+ * @param options - overlay copy plus the wait SSE URL
645
+ */
646
+ present(options: KitMaintenanceOptions): Promise<void>;
647
+ /**
648
+ * Dismiss the tracked overlay and tear down the wait SSE.
649
+ *
650
+ * @remarks
651
+ * Normally called when the wait stream emits `ended`. A no-op when nothing is showing.
652
+ */
653
+ dismiss(): Promise<void>;
654
+ static ɵfac: i0.ɵɵFactoryDeclaration<KitMaintenanceController, never>;
655
+ static ɵprov: i0.ɵɵInjectableDeclaration<KitMaintenanceController>;
656
+ }
657
+
545
658
  /**
546
659
  * Content for {@link kitPresentAuthFailedAlert}.
547
660
  */
@@ -920,6 +1033,17 @@ declare const kitRequireConfirmingGuard: CanActivateFn;
920
1033
  */
921
1034
  declare const kitRequireAuthorizedGuard: CanActivateFn;
922
1035
 
1036
+ /**
1037
+ * True when the error is the fleet maintenance short-circuit (`503` + body `code: 'MAINTENANCE'`).
1038
+ *
1039
+ * @remarks
1040
+ * Matches Angular `HttpErrorResponse` as `error.error?.code === 'MAINTENANCE'` (body top-level
1041
+ * `code`). Must not be retried and must not fall through to {@link KitHttpConfig.onServerBusy}.
1042
+ *
1043
+ * @param error - The failed response.
1044
+ * @returns Whether this is a maintenance response.
1045
+ */
1046
+ declare const isMaintenanceError: (error: HttpErrorResponse) => boolean;
923
1047
  /**
924
1048
  * Configuration that customizes the behavior of {@link kitAuthInterceptor}, injected through {@link provideKitHttp}.
925
1049
  *
@@ -1041,12 +1165,22 @@ interface KitHttpConfig {
1041
1165
  * @remarks
1042
1166
  * Optional; defaults to a no-op. Distinct from {@link KitHttpConfig.onNetworkError} — the device's
1043
1167
  * connection is fine, the server is momentarily unavailable — so the app can say "server busy, try
1044
- * again shortly" rather than prompt a reload.
1168
+ * again shortly" rather than prompt a reload. **Not** called for fleet maintenance (`503` with
1169
+ * `error.error?.code === 'MAINTENANCE'`) — that uses {@link KitHttpConfig.onMaintenance}.
1045
1170
  *
1046
1171
  * @param status - `502`, `503`, or `504`.
1047
1172
  * @param retryAfterSeconds - The server's `Retry-After` hint in seconds, when provided.
1048
1173
  */
1049
1174
  onServerBusy?(status: number, retryAfterSeconds?: number): void;
1175
+ /**
1176
+ * UX hook for fleet maintenance: HTTP `503` whose body has `code: 'MAINTENANCE'`.
1177
+ *
1178
+ * @remarks
1179
+ * Optional; defaults to a no-op. Fired **without retries** (maintenance is intentional, not
1180
+ * transient). Wire to {@link KitMaintenanceController.present} with the wait SSE URL so the lock
1181
+ * overlay auto-dismisses when maintenance ends.
1182
+ */
1183
+ onMaintenance?(): void;
1050
1184
  /**
1051
1185
  * UX hook for a `429 Too Many Requests` response, fired after retries are exhausted.
1052
1186
  *
@@ -1131,8 +1265,8 @@ declare const provideKitHttp: (configFactory: () => KitHttpConfig) => Environmen
1131
1265
  * When the device is offline it stops retrying immediately.
1132
1266
  * 5. On the final error, `offlineFallback` is consulted first; otherwise the error is classified by
1133
1267
  * status (see {@link dispatchError}): `401`→`onUnauthorized`, `403`→`onForbidden`, `0`→
1134
- * `onNetworkError` (when connected), `429`→`onRateLimited`, `502`/`503`/`504`→`onServerBusy`, and
1135
- * `400`/`422`/`500` with a body message→`onServerError`.
1268
+ * `onNetworkError` (when connected), `429`→`onRateLimited`, maintenance `503`→`onMaintenance`,
1269
+ * other `502`/`503`/`504`→`onServerBusy`, and `400`/`422`/`500` with a body message→`onServerError`.
1136
1270
  *
1137
1271
  * @param request - The outgoing request.
1138
1272
  * @param next - The next handler in the interceptor chain.
@@ -1315,5 +1449,5 @@ declare const kitChangeEventDisabled: (completeEvent: WritableSignal<HTMLIonInfi
1315
1449
  */
1316
1450
  declare const kitCreateDidEnter: (el: ElementRef) => Observable<boolean>;
1317
1451
 
1318
- export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KitAuthInputDirective, KitLoadingController, KitOverlayController, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, kitAuthInterceptor, kitChangeEventDisabled, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
1319
- export type { KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata };
1452
+ export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_THEME_STORAGE_KEY, KitAuthInputDirective, KitLoadingController, KitMaintenanceController, KitOverlayController, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
1453
+ export type { KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitClearableStore, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata };