@tinya-code/gas-admin-ui 0.1.0-alpha.5 → 0.2.0-alpha.1
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 +584 -116
- package/fesm2022/{tinya-code-gas-admin-ui-calendar-view-r-RXDE37.mjs → tinya-code-gas-admin-ui-calendar-view-CRTEx4f5.mjs} +4 -4
- package/fesm2022/{tinya-code-gas-admin-ui-calendar-view-r-RXDE37.mjs.map → tinya-code-gas-admin-ui-calendar-view-CRTEx4f5.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-condition-evaluator-BBzWUuHl.mjs → tinya-code-gas-admin-ui-condition-evaluator-DL15SFPt.mjs} +2 -2
- package/fesm2022/{tinya-code-gas-admin-ui-condition-evaluator-BBzWUuHl.mjs.map → tinya-code-gas-admin-ui-condition-evaluator-DL15SFPt.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-data-source.service-LD8AM3Rn.mjs → tinya-code-gas-admin-ui-data-source.service-BtZqPzmP.mjs} +2 -3
- package/fesm2022/{tinya-code-gas-admin-ui-data-source.service-LD8AM3Rn.mjs.map → tinya-code-gas-admin-ui-data-source.service-BtZqPzmP.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-error-mapper.service-Ci0UpXtV.mjs → tinya-code-gas-admin-ui-error-mapper.service-pEOAeAzK.mjs} +2 -2
- package/fesm2022/{tinya-code-gas-admin-ui-error-mapper.service-Ci0UpXtV.mjs.map → tinya-code-gas-admin-ui-error-mapper.service-pEOAeAzK.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-file-Dg2N3XQ2.mjs → tinya-code-gas-admin-ui-file-B6_vveO5.mjs} +3 -3
- package/fesm2022/{tinya-code-gas-admin-ui-file-Dg2N3XQ2.mjs.map → tinya-code-gas-admin-ui-file-B6_vveO5.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-form-view-BwGupSbi.mjs → tinya-code-gas-admin-ui-form-view-D1QLZWnG.mjs} +9 -10
- package/fesm2022/{tinya-code-gas-admin-ui-form-view-BwGupSbi.mjs.map → tinya-code-gas-admin-ui-form-view-D1QLZWnG.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-image-Bjw9ImlS.mjs → tinya-code-gas-admin-ui-image-lUe8nrUf.mjs} +3 -3
- package/fesm2022/{tinya-code-gas-admin-ui-image-Bjw9ImlS.mjs.map → tinya-code-gas-admin-ui-image-lUe8nrUf.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-kanban-view-CeGueI57.mjs → tinya-code-gas-admin-ui-kanban-view-B1rUNjlp.mjs} +4 -4
- package/fesm2022/{tinya-code-gas-admin-ui-kanban-view-CeGueI57.mjs.map → tinya-code-gas-admin-ui-kanban-view-B1rUNjlp.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-list-CMzl9MkX.mjs → tinya-code-gas-admin-ui-list-CH7b7dKh.mjs} +2 -2
- package/fesm2022/{tinya-code-gas-admin-ui-list-CMzl9MkX.mjs.map → tinya-code-gas-admin-ui-list-CH7b7dKh.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-multiselect-CuWwAfdY.mjs → tinya-code-gas-admin-ui-multiselect-Bg4cnf6N.mjs} +3 -3
- package/fesm2022/{tinya-code-gas-admin-ui-multiselect-CuWwAfdY.mjs.map → tinya-code-gas-admin-ui-multiselect-Bg4cnf6N.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-relation-B3W3Ynsp.mjs → tinya-code-gas-admin-ui-relation-CDEuUpKU.mjs} +3 -3
- package/fesm2022/{tinya-code-gas-admin-ui-relation-B3W3Ynsp.mjs.map → tinya-code-gas-admin-ui-relation-CDEuUpKU.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-render-registry-B_D5Jhp9.mjs → tinya-code-gas-admin-ui-render-registry-mG0BDGZI.mjs} +10 -10
- package/fesm2022/{tinya-code-gas-admin-ui-render-registry-B_D5Jhp9.mjs.map → tinya-code-gas-admin-ui-render-registry-mG0BDGZI.mjs.map} +1 -1
- package/fesm2022/tinya-code-gas-admin-ui-schema-catalog-Bb0WJRwc.mjs +494 -0
- package/fesm2022/tinya-code-gas-admin-ui-schema-catalog-Bb0WJRwc.mjs.map +1 -0
- package/fesm2022/{tinya-code-gas-admin-ui-seed-CNbQtREA.mjs → tinya-code-gas-admin-ui-seed-C_tWI-Jr.mjs} +2 -2
- package/fesm2022/{tinya-code-gas-admin-ui-seed-CNbQtREA.mjs.map → tinya-code-gas-admin-ui-seed-C_tWI-Jr.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-select-DzaRfHXO.mjs → tinya-code-gas-admin-ui-select-CL2kj7pM.mjs} +3 -3
- package/fesm2022/{tinya-code-gas-admin-ui-select-DzaRfHXO.mjs.map → tinya-code-gas-admin-ui-select-CL2kj7pM.mjs.map} +1 -1
- package/fesm2022/{tinya-code-gas-admin-ui-upload.service-C1g545w5.mjs → tinya-code-gas-admin-ui-upload.service-D700Obgh.mjs} +2 -2
- package/fesm2022/{tinya-code-gas-admin-ui-upload.service-C1g545w5.mjs.map → tinya-code-gas-admin-ui-upload.service-D700Obgh.mjs.map} +1 -1
- package/fesm2022/tinya-code-gas-admin-ui.mjs +65 -11
- package/fesm2022/tinya-code-gas-admin-ui.mjs.map +1 -1
- package/package.json +8 -2
- package/types/tinya-code-gas-admin-ui.d.ts +119 -29
- package/fesm2022/tinya-code-gas-admin-ui-api.service-CZrUeclM.mjs +0 -281
- package/fesm2022/tinya-code-gas-admin-ui-api.service-CZrUeclM.mjs.map +0 -1
- package/fesm2022/tinya-code-gas-admin-ui-schema-catalog-CDrz9pVN.mjs +0 -131
- package/fesm2022/tinya-code-gas-admin-ui-schema-catalog-CDrz9pVN.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinya-code/gas-admin-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-alpha.1",
|
|
4
4
|
"description": "Motor de render Angular para admin CRUD: declará ResourceSchema y el motor dibuja vistas, campos y widgets.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,13 @@
|
|
|
17
17
|
"@angular/platform-browser": "^22.2.0",
|
|
18
18
|
"@angular/router": "^22.2.0",
|
|
19
19
|
"@lucide/angular": "^1.51.0",
|
|
20
|
-
"chart.js": "^4.5.0"
|
|
20
|
+
"chart.js": "^4.5.0",
|
|
21
|
+
"firebase": ">=10.0.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependenciesMeta": {
|
|
24
|
+
"firebase": {
|
|
25
|
+
"optional": true
|
|
26
|
+
}
|
|
21
27
|
},
|
|
22
28
|
"dependencies": {
|
|
23
29
|
"tslib": "^2.3.0"
|
|
@@ -768,6 +768,16 @@ export interface AuthFieldDeclaration {
|
|
|
768
768
|
type: string;
|
|
769
769
|
required?: boolean;
|
|
770
770
|
}
|
|
771
|
+
/** Supported auth providers. Extensible without breaking existing schemas. */
|
|
772
|
+
export type AuthProvider = 'password' | 'google' | (string & {});
|
|
773
|
+
/** Firebase config block — present only when at least one Firebase provider is listed. */
|
|
774
|
+
export interface FirebaseAuthConfig {
|
|
775
|
+
/**
|
|
776
|
+
* The backend endpoint that exchanges a Firebase ID token for the app token.
|
|
777
|
+
* Defaults to '/auth/firebase' when omitted.
|
|
778
|
+
*/
|
|
779
|
+
exchangeEndpoint?: string;
|
|
780
|
+
}
|
|
771
781
|
/**
|
|
772
782
|
* Pantalla de login declarada (auth.md §5.1): **vive sólo en el schema del
|
|
773
783
|
* front** — el back no conoce estas etiquetas ni este layout, sólo declara
|
|
@@ -775,8 +785,8 @@ export interface AuthFieldDeclaration {
|
|
|
775
785
|
* claves de `loginFields` existan en ese `input`.
|
|
776
786
|
*/
|
|
777
787
|
export interface AuthSchema {
|
|
778
|
-
/** Proveedores disponibles
|
|
779
|
-
providers:
|
|
788
|
+
/** Proveedores disponibles: 'password' | 'google' u otros federados. */
|
|
789
|
+
providers: AuthProvider[];
|
|
780
790
|
loginFields: AuthFieldDeclaration[];
|
|
781
791
|
redirectAfterLogin: string;
|
|
782
792
|
/**
|
|
@@ -785,6 +795,27 @@ export interface AuthSchema {
|
|
|
785
795
|
* pestaña. Declarar `true` prometería un storage que nadie usa.
|
|
786
796
|
*/
|
|
787
797
|
rememberMe: boolean;
|
|
798
|
+
/** Configuración de Firebase cuando se usan proveedores federados o Firebase Auth. */
|
|
799
|
+
firebase?: FirebaseAuthConfig;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Narrow surface the library uses from Firebase Auth.
|
|
803
|
+
* Implemented by the consumer app; injected via FIREBASE_AUTH_ADAPTER token.
|
|
804
|
+
* Keeping the interface thin avoids coupling to any specific Firebase version.
|
|
805
|
+
*/
|
|
806
|
+
interface FirebaseAuthAdapter {
|
|
807
|
+
/**
|
|
808
|
+
* Opens a Google sign-in popup and resolves to the Firebase ID token.
|
|
809
|
+
* Rejects on cancellation or error.
|
|
810
|
+
*/
|
|
811
|
+
signInWithGoogle(): Promise<string>;
|
|
812
|
+
/**
|
|
813
|
+
* Signs in with email and password via Firebase and resolves to the ID token.
|
|
814
|
+
* Used when provider === 'password' AND firebase is configured (Firebase email auth).
|
|
815
|
+
*/
|
|
816
|
+
signInWithEmailAndPassword(email: string, password: string): Promise<string>;
|
|
817
|
+
/** Signs out from Firebase (called alongside the app session clear). */
|
|
818
|
+
signOut(): Promise<void>;
|
|
788
819
|
}
|
|
789
820
|
/** Fija el catálogo (uso interno de `provideGasAdmin`; testable directo). */
|
|
790
821
|
export declare function setSchemaCatalog(schemas: readonly ResourceSchema[], auth?: AuthSchema): void;
|
|
@@ -802,6 +833,15 @@ interface GasAdminConfig {
|
|
|
802
833
|
schemas: readonly ResourceSchema[];
|
|
803
834
|
/** Declaración de la pantalla de login (opcional: sin ella, sin `/login`). */
|
|
804
835
|
auth?: AuthSchema;
|
|
836
|
+
/**
|
|
837
|
+
* Driver de transporte HTTP.
|
|
838
|
+
*
|
|
839
|
+
* - `'gas'` (default): tunnel `POST text/plain` con envelope Apps Script.
|
|
840
|
+
* - `'rest'`: verbos HTTP reales con `Authorization: Bearer` en cabeceras.
|
|
841
|
+
*
|
|
842
|
+
* Sin declaración el motor usa `'gas'` — cero impacto en consumidores existentes.
|
|
843
|
+
*/
|
|
844
|
+
driver?: 'gas' | 'rest';
|
|
805
845
|
}
|
|
806
846
|
/**
|
|
807
847
|
* Wiring completo del motor: catálogo + HTTP con el interceptor de
|
|
@@ -812,6 +852,17 @@ interface GasAdminConfig {
|
|
|
812
852
|
* (su environment decide la URL del Web App).
|
|
813
853
|
*/
|
|
814
854
|
export declare function provideGasAdmin(config: GasAdminConfig): (Provider | EnvironmentProviders)[];
|
|
855
|
+
/**
|
|
856
|
+
* Registra una implementación concreta de FirebaseAuthAdapter en el árbol de DI.
|
|
857
|
+
* Usar junto con provideGasAdmin() en app.config.ts al configurar proveedores federados
|
|
858
|
+
* (como 'google') o autenticación por Firebase.
|
|
859
|
+
*
|
|
860
|
+
* @example
|
|
861
|
+
* // app.config.ts
|
|
862
|
+
* provideGasAdmin({ schemas, auth }),
|
|
863
|
+
* provideFirebaseAdapter(new MyFirebaseAuthAdapter(getAuth(firebaseApp))),
|
|
864
|
+
*/
|
|
865
|
+
export declare function provideFirebaseAdapter(adapter: FirebaseAuthAdapter): Provider;
|
|
815
866
|
/**
|
|
816
867
|
* Contrato HTTP con el backend (doc/baseapi.md §8 «Errores»).
|
|
817
868
|
*
|
|
@@ -881,6 +932,28 @@ export declare function renewedTokenOf(body: unknown): string | null;
|
|
|
881
932
|
* `{ provide: API_URL, useValue: 'https://…' }` (Fase 3). Vacío = mismo origen.
|
|
882
933
|
*/
|
|
883
934
|
export declare const API_URL: InjectionToken<string>;
|
|
935
|
+
/**
|
|
936
|
+
* Token DI opcional para el adaptador de Firebase Auth.
|
|
937
|
+
* Proporcionado por la aplicación consumidora cuando usa proveedores federados o Firebase Auth.
|
|
938
|
+
*/
|
|
939
|
+
export declare const FIREBASE_AUTH_ADAPTER: InjectionToken<FirebaseAuthAdapter>;
|
|
940
|
+
/**
|
|
941
|
+
* Driver de transporte HTTP del motor.
|
|
942
|
+
*
|
|
943
|
+
* Vive acá (capa de infraestructura) y NO en `ResourceSchema` (capa de dominio)
|
|
944
|
+
* porque es una decisión de red, no de modelo de datos. Cambiar el driver
|
|
945
|
+
* no debería requerir tocar ningún schema de recursos.
|
|
946
|
+
*
|
|
947
|
+
* - `'gas'` (default): tunnel `POST text/plain` con envelope
|
|
948
|
+
* `{ token, method, path, payload }` — contrato de Google Apps Script.
|
|
949
|
+
* - `'rest'`: verbos HTTP reales (`GET`, `POST`, `PUT`, `DELETE`) con
|
|
950
|
+
* `Authorization: Bearer <token>` en cabeceras y params en la URL (GET/DELETE)
|
|
951
|
+
* o en el body JSON (POST/PUT/PATCH).
|
|
952
|
+
*
|
|
953
|
+
* Se fija en `provideGasAdmin({ driver })`. Sin declaración explícita el
|
|
954
|
+
* motor usa `'gas'` — cero impacto para consumidores existentes.
|
|
955
|
+
*/
|
|
956
|
+
export declare const API_DRIVER: InjectionToken<"gas" | "rest">;
|
|
884
957
|
/**
|
|
885
958
|
* Guards de sesión (auth.md §5.3).
|
|
886
959
|
*
|
|
@@ -937,13 +1010,16 @@ export declare class Login {
|
|
|
937
1010
|
private readonly auth;
|
|
938
1011
|
private readonly router;
|
|
939
1012
|
readonly schema: import("@tinya-code/gas-admin-ui").AuthSchema;
|
|
1013
|
+
readonly providers: import("@tinya-code/gas-admin-ui").AuthProvider[];
|
|
940
1014
|
readonly error: import("@angular/core").WritableSignal<string | null>;
|
|
941
1015
|
readonly loading: import("@angular/core").WritableSignal<boolean>;
|
|
1016
|
+
readonly providerLoading: import("@angular/core").WritableSignal<string | null>;
|
|
942
1017
|
/** Valores por clave: el set lo pinta el `@for` del schema. */
|
|
943
1018
|
private readonly values;
|
|
944
1019
|
label(key: string): string;
|
|
945
1020
|
value(key: string): string;
|
|
946
1021
|
setValue(key: string, next: string): void;
|
|
1022
|
+
loginWithGoogle(): void;
|
|
947
1023
|
submit(event: Event): void;
|
|
948
1024
|
private goAfterLogin;
|
|
949
1025
|
static ɵfac: i0.ɵɵFactoryDeclaration<Login, never>;
|
|
@@ -987,32 +1063,20 @@ export declare class NotificationService {
|
|
|
987
1063
|
/** Métodos que entiende el envelope del backend (baseapi §2.3). */
|
|
988
1064
|
type EnvelopeMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
989
1065
|
/**
|
|
990
|
-
* CRUD genérico sobre el contrato v2 (baseapi §2.3)
|
|
991
|
-
* es un `POST` a `API_URL` con cuerpo `text/plain` y el JSON
|
|
992
|
-
* `{ token, method, path, payload }`. `method: 'GET'` también para lecturas;
|
|
993
|
-
* el token viaja en el cuerpo (nunca en cabeceras: criterio 11 de §17).
|
|
994
|
-
*
|
|
995
|
-
* `text/plain` en lugar de `application/json` evita el preflight CORS
|
|
996
|
-
* (simple request) — criterio 11: sin cabeceras custom.
|
|
997
|
-
*
|
|
998
|
-
* **R2.8 — convención sobre el snippet.** `auth.md` §5.2 llama a las claves
|
|
999
|
-
* `{ route, op, token, payload }`, pero el backend (`parseEnvelope_`) lee
|
|
1000
|
-
* `path` y `method`: el snippet es un esquema a medias, no un contrato.
|
|
1001
|
-
* Mismo precedente que en R2.5 — **la convención del código gana**. Cambiar
|
|
1002
|
-
* el nombre ahora rompería el único transporte que existe.
|
|
1003
|
-
*
|
|
1004
|
-
* **R2.12 — el token sale de `AuthService`, no de configuración.** El
|
|
1005
|
-
* `ADMIN_TOKEN` (D21-C) se retiró: no hay credencial fija, hay sesión.
|
|
1066
|
+
* CRUD genérico sobre el contrato v2 (baseapi §2.3) con soporte dual-driver:
|
|
1006
1067
|
*
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1010
|
-
*
|
|
1068
|
+
* - **`gas` (default)**: TODA llamada a la API es un `POST` a `API_URL` con cuerpo
|
|
1069
|
+
* `text/plain` y el JSON `{ token, method, path, payload }`.
|
|
1070
|
+
* - **`rest`**: Verbos HTTP reales (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`) hacia
|
|
1071
|
+
* `${API_URL}${path}` con `Authorization: Bearer ${token}`. `payload` va como query
|
|
1072
|
+
* params en GET/DELETE (aplanando objetos anidados como `params`) o como body JSON
|
|
1073
|
+
* en POST/PUT/PATCH.
|
|
1011
1074
|
*/
|
|
1012
1075
|
export declare class ApiService {
|
|
1013
1076
|
private readonly http;
|
|
1014
1077
|
private readonly apiUrl;
|
|
1015
1078
|
private readonly auth;
|
|
1079
|
+
private readonly driver;
|
|
1016
1080
|
/**
|
|
1017
1081
|
* Listado. El backend envuelve la respuesta cuando la operación declara
|
|
1018
1082
|
* `shape.envelope: 'list'` (F5) ⇒ `{ items, nextCursor, total }` (R6.4);
|
|
@@ -1040,6 +1104,9 @@ export declare class ApiService {
|
|
|
1040
1104
|
*/
|
|
1041
1105
|
request<T>(method: EnvelopeMethod, path: string | undefined, payload?: Record<string, unknown>): Observable<T>;
|
|
1042
1106
|
private send;
|
|
1107
|
+
private sendGas;
|
|
1108
|
+
private sendRest;
|
|
1109
|
+
private buildUrl;
|
|
1043
1110
|
private withKey;
|
|
1044
1111
|
static ɵfac: i0.ɵɵFactoryDeclaration<ApiService, never>;
|
|
1045
1112
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
@@ -1090,6 +1157,8 @@ export declare class AuthService {
|
|
|
1090
1157
|
private readonly http;
|
|
1091
1158
|
private readonly apiUrl;
|
|
1092
1159
|
private readonly router;
|
|
1160
|
+
private readonly firebaseAdapter;
|
|
1161
|
+
private readonly driver;
|
|
1093
1162
|
/**
|
|
1094
1163
|
* D10-3: **sólo `sessionStorage`.** La opción «recordarme» con
|
|
1095
1164
|
* `localStorage` quedó denegada en §9.3 — muere con la pestaña ⇒ cero
|
|
@@ -1113,6 +1182,21 @@ export declare class AuthService {
|
|
|
1113
1182
|
readonly role: import("@angular/core").Signal<string>;
|
|
1114
1183
|
constructor();
|
|
1115
1184
|
login(email: string, password: string): Observable<SessionUser>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Inicia sesión con Google mediante el adaptador de Firebase y canjea
|
|
1187
|
+
* el ID token contra el backend.
|
|
1188
|
+
*/
|
|
1189
|
+
loginWithGoogle(): Observable<SessionUser>;
|
|
1190
|
+
/**
|
|
1191
|
+
* Inicia sesión con correo y contraseña en Firebase y canjea el ID token
|
|
1192
|
+
* resultante contra el backend.
|
|
1193
|
+
*/
|
|
1194
|
+
loginWithFirebasePassword(email: string, password: string): Observable<SessionUser>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Canjea un token de identidad de Firebase por la sesión propia de la app,
|
|
1197
|
+
* manteniendo idéntico el contrato del envelope y almacenamiento en sessionStorage.
|
|
1198
|
+
*/
|
|
1199
|
+
private exchangeFirebaseToken;
|
|
1116
1200
|
/**
|
|
1117
1201
|
* Revocación best-effort (§9.7): se pide al back que ponga el `sid` en la
|
|
1118
1202
|
* lista de revocados, pero **la sesión local se ciere haya o no respuesta**.
|
|
@@ -1215,14 +1299,20 @@ export declare class AuthService {
|
|
|
1215
1299
|
private clear;
|
|
1216
1300
|
private goLogin;
|
|
1217
1301
|
private currentUrl;
|
|
1302
|
+
private buildUrl;
|
|
1218
1303
|
private envelope;
|
|
1219
1304
|
/**
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1225
|
-
|
|
1305
|
+
* Despacho dual-driver para peticiones de autenticación:
|
|
1306
|
+
*
|
|
1307
|
+
* - **`gas` (default)**: `POST` a `API_URL` con cuerpo `text/plain` y envelope
|
|
1308
|
+
* `{ token, method: 'POST', path, payload }`.
|
|
1309
|
+
* - **`rest`**: llamadas REST reales:
|
|
1310
|
+
* - `/auth/me`: `GET` a `${apiUrl}/auth/me` con `Authorization: Bearer ${token}`.
|
|
1311
|
+
* - resto (`/auth/login`, `/auth/firebase`, `/auth/logout`, etc.): `POST` con
|
|
1312
|
+
* `Content-Type: application/json` y payload directo como body JSON. Si existe
|
|
1313
|
+
* token activo, se adjunta en cabecera `Authorization`.
|
|
1314
|
+
*/
|
|
1315
|
+
private buildAuthRequest;
|
|
1226
1316
|
private post;
|
|
1227
1317
|
static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
|
|
1228
1318
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
@@ -3096,4 +3186,4 @@ export declare function actionsFor(surface: ActionSurface): ActionDescriptor[];
|
|
|
3096
3186
|
export declare function actionType(action: ResourceAction): string;
|
|
3097
3187
|
/** Tipos registrados. Sólo para comprobaciones y tests. */
|
|
3098
3188
|
export declare function actionTypes(): string[];
|
|
3099
|
-
export { type ComponentRenderKind, type GasAdminConfig, type RenderKind, type ResolvedShare, type ValidatorName, get as getRenderDescriptor, isSupported as isRenderSupported, register as registerRenderDescriptor, unregister as unregisterRenderDescriptor };
|
|
3189
|
+
export { type ComponentRenderKind, type FirebaseAuthAdapter, type GasAdminConfig, type RenderKind, type ResolvedShare, type ValidatorName, get as getRenderDescriptor, isSupported as isRenderSupported, register as registerRenderDescriptor, unregister as unregisterRenderDescriptor };
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
import { InjectionToken, Service, computed, inject, signal } from "@angular/core";
|
|
3
|
-
import { HttpClient } from "@angular/common/http";
|
|
4
|
-
import { catchError, map, of, tap, throwError } from "rxjs";
|
|
5
|
-
import { Router } from "@angular/router";
|
|
6
|
-
var ApiError = class extends Error {
|
|
7
|
-
status;
|
|
8
|
-
fieldPath;
|
|
9
|
-
code;
|
|
10
|
-
issues;
|
|
11
|
-
constructor(status, message, fieldPath, code, issues = []) {
|
|
12
|
-
super(message);
|
|
13
|
-
this.name = "ApiError";
|
|
14
|
-
this.status = status;
|
|
15
|
-
this.fieldPath = fieldPath;
|
|
16
|
-
this.code = code;
|
|
17
|
-
this.issues = issues;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
function renewedTokenOf(body) {
|
|
21
|
-
if (body === null || typeof body !== "object") return null;
|
|
22
|
-
const meta = body.meta;
|
|
23
|
-
if (meta === null || typeof meta !== "object") return null;
|
|
24
|
-
const token = meta.renewedToken;
|
|
25
|
-
return typeof token === "string" && token !== "" ? token : null;
|
|
26
|
-
}
|
|
27
|
-
const API_URL = new InjectionToken("API_URL");
|
|
28
|
-
const LOGIN_PATH = "/login";
|
|
29
|
-
const SESSION_TOKEN_KEY = "admin.session.token";
|
|
30
|
-
const SESSION_USER_KEY = "admin.session.user";
|
|
31
|
-
var AuthService = class AuthService {
|
|
32
|
-
http = inject(HttpClient);
|
|
33
|
-
apiUrl = inject(API_URL);
|
|
34
|
-
router = inject(Router);
|
|
35
|
-
storage = sessionStorage;
|
|
36
|
-
_user = signal(null, ...ngDevMode ? [{ debugName: "_user" }] : /* istanbul ignore next */ []);
|
|
37
|
-
_token = signal(null, ...ngDevMode ? [{ debugName: "_token" }] : /* istanbul ignore next */ []);
|
|
38
|
-
_returnUrl = signal(null, ...ngDevMode ? [{ debugName: "_returnUrl" }] : /* istanbul ignore next */ []);
|
|
39
|
-
user = this._user.asReadonly();
|
|
40
|
-
token = this._token.asReadonly();
|
|
41
|
-
returnUrl = this._returnUrl.asReadonly();
|
|
42
|
-
isAuthenticated = computed(() => this._token() !== null && this._user() !== null, ...ngDevMode ? [{ debugName: "isAuthenticated" }] : /* istanbul ignore next */ []);
|
|
43
|
-
role = computed(() => this._user()?.role ?? "", ...ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []);
|
|
44
|
-
constructor() {
|
|
45
|
-
const token = this.storage.getItem(SESSION_TOKEN_KEY);
|
|
46
|
-
if (token !== null && token !== "") this._token.set(token);
|
|
47
|
-
const raw = this.storage.getItem(SESSION_USER_KEY);
|
|
48
|
-
if (raw !== null && raw !== "") try {
|
|
49
|
-
this._user.set(JSON.parse(raw));
|
|
50
|
-
} catch {
|
|
51
|
-
this.storage.removeItem(SESSION_USER_KEY);
|
|
52
|
-
this.storage.removeItem(SESSION_TOKEN_KEY);
|
|
53
|
-
this._token.set(null);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
login(email, password) {
|
|
57
|
-
return this.post("/auth/login", {
|
|
58
|
-
email,
|
|
59
|
-
password
|
|
60
|
-
}).pipe(map((res) => {
|
|
61
|
-
this.open(res.token, res.user);
|
|
62
|
-
const renewed = renewedTokenOf(res);
|
|
63
|
-
if (renewed !== null) this.applyRenewedToken(renewed);
|
|
64
|
-
return res.user;
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
logout() {
|
|
68
|
-
return this.post("/auth/logout").pipe(tap({
|
|
69
|
-
next: () => this.clear(),
|
|
70
|
-
error: () => this.clear()
|
|
71
|
-
}), map(() => void 0));
|
|
72
|
-
}
|
|
73
|
-
logoutAll() {
|
|
74
|
-
return this.post("/auth/logout-all").pipe(tap(() => {
|
|
75
|
-
this.clear();
|
|
76
|
-
this.goLogin();
|
|
77
|
-
}), map((res) => ({ effectiveWithinSeconds: res.effectiveWithinSeconds })));
|
|
78
|
-
}
|
|
79
|
-
restore() {
|
|
80
|
-
if (this._token() === null) return of(void 0);
|
|
81
|
-
return this.post("/auth/me").pipe(tap((res) => {
|
|
82
|
-
this.open(this._token(), res.user);
|
|
83
|
-
}), catchError(() => of(void 0)), map(() => void 0));
|
|
84
|
-
}
|
|
85
|
-
applyRenewedToken(token) {
|
|
86
|
-
if (token === "" || this._token() === null) return;
|
|
87
|
-
this._token.set(token);
|
|
88
|
-
this.storage.setItem(SESSION_TOKEN_KEY, token);
|
|
89
|
-
}
|
|
90
|
-
applyAuthCode(code) {
|
|
91
|
-
switch (code) {
|
|
92
|
-
case "AUTH_EXPIRED":
|
|
93
|
-
this._returnUrl.set(this.currentUrl());
|
|
94
|
-
this.clear();
|
|
95
|
-
this.goLogin();
|
|
96
|
-
break;
|
|
97
|
-
case "AUTH_REQUIRED":
|
|
98
|
-
case "AUTH_INVALID":
|
|
99
|
-
this.clear();
|
|
100
|
-
this.goLogin();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
hasRole(required) {
|
|
104
|
-
if (required === "" || required === "session") return this.isAuthenticated();
|
|
105
|
-
const role = this.role();
|
|
106
|
-
if (role === "admin") return true;
|
|
107
|
-
return role !== "" && role === required;
|
|
108
|
-
}
|
|
109
|
-
canAccess(access) {
|
|
110
|
-
const requires = access?.requires ?? "session";
|
|
111
|
-
if (requires === "public") return true;
|
|
112
|
-
if (!this.isAuthenticated()) return false;
|
|
113
|
-
const role = requires.startsWith("role:") ? requires.slice(5) : "";
|
|
114
|
-
const required = role === "" ? access?.roles ?? [] : [role];
|
|
115
|
-
if (required.length === 0) return true;
|
|
116
|
-
return required.some((one) => this.hasRole(one));
|
|
117
|
-
}
|
|
118
|
-
canDoOperation(schema, operation) {
|
|
119
|
-
const ops = schema.policies?.access?.operations;
|
|
120
|
-
if (ops && ops[operation]) return this.meetsLevel(ops[operation]);
|
|
121
|
-
if (schema.policies?.access) {
|
|
122
|
-
const groupLevel = operation === "create" || operation === "update" || operation === "remove" ? schema.policies.access.write : schema.policies.access.read;
|
|
123
|
-
return this.meetsLevel(groupLevel ?? "admin");
|
|
124
|
-
}
|
|
125
|
-
const perms = schema.permissions;
|
|
126
|
-
if (perms) return {
|
|
127
|
-
list: true,
|
|
128
|
-
get: true,
|
|
129
|
-
create: perms.create,
|
|
130
|
-
update: perms.update,
|
|
131
|
-
remove: perms.remove
|
|
132
|
-
}[operation] !== false;
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
canReadField(field) {
|
|
136
|
-
if (!field.access || !field.access.read) return true;
|
|
137
|
-
return this.meetsLevel(field.access.read);
|
|
138
|
-
}
|
|
139
|
-
canWriteField(field) {
|
|
140
|
-
if (!field.access || !field.access.write) return true;
|
|
141
|
-
return this.meetsLevel(field.access.write);
|
|
142
|
-
}
|
|
143
|
-
meetsLevel(level) {
|
|
144
|
-
if (level === "public") return true;
|
|
145
|
-
if (level === "session") return this.isAuthenticated();
|
|
146
|
-
if (level.startsWith("role:")) {
|
|
147
|
-
const requiredRole = level.slice(5);
|
|
148
|
-
return this.hasRole(requiredRole);
|
|
149
|
-
}
|
|
150
|
-
return this.hasRole("admin");
|
|
151
|
-
}
|
|
152
|
-
open(token, user) {
|
|
153
|
-
if (token !== null && token !== "") this._token.set(token);
|
|
154
|
-
this._user.set(user);
|
|
155
|
-
if (token !== null && token !== "") this.storage.setItem(SESSION_TOKEN_KEY, token);
|
|
156
|
-
if (user !== null) this.storage.setItem(SESSION_USER_KEY, JSON.stringify(user));
|
|
157
|
-
}
|
|
158
|
-
consumeReturnUrl() {
|
|
159
|
-
const url = this._returnUrl();
|
|
160
|
-
this._returnUrl.set(null);
|
|
161
|
-
return url;
|
|
162
|
-
}
|
|
163
|
-
clear() {
|
|
164
|
-
this._token.set(null);
|
|
165
|
-
this._user.set(null);
|
|
166
|
-
this.storage.removeItem(SESSION_TOKEN_KEY);
|
|
167
|
-
this.storage.removeItem(SESSION_USER_KEY);
|
|
168
|
-
}
|
|
169
|
-
goLogin() {
|
|
170
|
-
if (this.currentUrl().startsWith("/login")) return;
|
|
171
|
-
this.router.navigate([LOGIN_PATH]).catch(() => void 0);
|
|
172
|
-
}
|
|
173
|
-
currentUrl() {
|
|
174
|
-
return this.router.url;
|
|
175
|
-
}
|
|
176
|
-
envelope(path, payload = {}) {
|
|
177
|
-
return {
|
|
178
|
-
token: this._token(),
|
|
179
|
-
method: "POST",
|
|
180
|
-
path,
|
|
181
|
-
payload
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
post(path, payload = {}) {
|
|
185
|
-
return this.http.post(this.apiUrl, this.envelope(path, payload), { headers: { "Content-Type": "text/plain" } });
|
|
186
|
-
}
|
|
187
|
-
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
188
|
-
minVersion: "12.0.0",
|
|
189
|
-
version: "22.2.3",
|
|
190
|
-
ngImport: i0,
|
|
191
|
-
type: AuthService,
|
|
192
|
-
deps: [],
|
|
193
|
-
target: i0.ɵɵFactoryTarget.Service
|
|
194
|
-
});
|
|
195
|
-
static ɵprov = i0.ɵɵngDeclareService({
|
|
196
|
-
minVersion: "22.0.0",
|
|
197
|
-
version: "22.2.3",
|
|
198
|
-
ngImport: i0,
|
|
199
|
-
type: AuthService
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
203
|
-
minVersion: "12.0.0",
|
|
204
|
-
version: "22.2.3",
|
|
205
|
-
ngImport: i0,
|
|
206
|
-
type: AuthService,
|
|
207
|
-
decorators: [{ type: Service }],
|
|
208
|
-
ctorParameters: () => []
|
|
209
|
-
});
|
|
210
|
-
var ApiService = class ApiService {
|
|
211
|
-
http = inject(HttpClient);
|
|
212
|
-
apiUrl = inject(API_URL);
|
|
213
|
-
auth = inject(AuthService);
|
|
214
|
-
list(endpoint, payload) {
|
|
215
|
-
return this.send(endpoint.list, "GET", payload).pipe(map((raw) => unwrapList(raw)));
|
|
216
|
-
}
|
|
217
|
-
get(endpoint, key) {
|
|
218
|
-
return this.send(this.withKey(endpoint.get, key), "GET");
|
|
219
|
-
}
|
|
220
|
-
create(endpoint, payload) {
|
|
221
|
-
return this.send(endpoint.create, "POST", payload);
|
|
222
|
-
}
|
|
223
|
-
update(endpoint, key, payload) {
|
|
224
|
-
return this.send(this.withKey(endpoint.update, key), "PUT", payload);
|
|
225
|
-
}
|
|
226
|
-
remove(endpoint, key) {
|
|
227
|
-
return this.send(this.withKey(endpoint.remove, key), "DELETE");
|
|
228
|
-
}
|
|
229
|
-
request(method, path, payload) {
|
|
230
|
-
return this.send(path, method, payload);
|
|
231
|
-
}
|
|
232
|
-
send(path, method, payload) {
|
|
233
|
-
if (!path) return throwError(() => /* @__PURE__ */ new Error("Operación no disponible para este recurso"));
|
|
234
|
-
const body = {
|
|
235
|
-
token: this.auth.token(),
|
|
236
|
-
method,
|
|
237
|
-
path,
|
|
238
|
-
payload: payload ?? {}
|
|
239
|
-
};
|
|
240
|
-
return this.http.post(this.apiUrl, body, { headers: { "Content-Type": "text/plain" } }).pipe(tap((res) => {
|
|
241
|
-
const renewed = renewedTokenOf(res);
|
|
242
|
-
if (renewed !== null) this.auth.applyRenewedToken(renewed);
|
|
243
|
-
}));
|
|
244
|
-
}
|
|
245
|
-
withKey(path, key) {
|
|
246
|
-
if (!path) return;
|
|
247
|
-
return path.includes("{key}") ? path.replace("{key}", encodeURIComponent(key ?? "")) : path;
|
|
248
|
-
}
|
|
249
|
-
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
250
|
-
minVersion: "12.0.0",
|
|
251
|
-
version: "22.2.3",
|
|
252
|
-
ngImport: i0,
|
|
253
|
-
type: ApiService,
|
|
254
|
-
deps: [],
|
|
255
|
-
target: i0.ɵɵFactoryTarget.Service
|
|
256
|
-
});
|
|
257
|
-
static ɵprov = i0.ɵɵngDeclareService({
|
|
258
|
-
minVersion: "22.0.0",
|
|
259
|
-
version: "22.2.3",
|
|
260
|
-
ngImport: i0,
|
|
261
|
-
type: ApiService
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
265
|
-
minVersion: "12.0.0",
|
|
266
|
-
version: "22.2.3",
|
|
267
|
-
ngImport: i0,
|
|
268
|
-
type: ApiService,
|
|
269
|
-
decorators: [{ type: Service }]
|
|
270
|
-
});
|
|
271
|
-
function unwrapList(raw) {
|
|
272
|
-
if (Array.isArray(raw)) return raw;
|
|
273
|
-
if (raw !== null && typeof raw === "object") {
|
|
274
|
-
const items = raw.items;
|
|
275
|
-
if (Array.isArray(items)) return items;
|
|
276
|
-
}
|
|
277
|
-
return [];
|
|
278
|
-
}
|
|
279
|
-
export { SESSION_USER_KEY as a, renewedTokenOf as c, SESSION_TOKEN_KEY as i, AuthService as n, API_URL as o, LOGIN_PATH as r, ApiError as s, ApiService as t };
|
|
280
|
-
|
|
281
|
-
//# sourceMappingURL=tinya-code-gas-admin-ui-api.service-CZrUeclM.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tinya-code-gas-admin-ui-api.service-CZrUeclM.mjs","names":[],"sources":["../../../projects/gas-admin-ui/src/lib/core/models/api.model.ts","../../../projects/gas-admin-ui/src/lib/core/tokens.ts","../../../projects/gas-admin-ui/src/lib/core/services/auth.service.ts","../../../projects/gas-admin-ui/src/lib/core/services/api.service.ts"],"sourcesContent":["/**\n * Contrato HTTP con el backend (doc/baseapi.md §8 «Errores»).\n *\n * El backend responde SIEMPRE HTTP 200; los errores viajan en el body\n * con `{ error: { status, message, errors?: [{ path, message }] } }`.\n * El interceptor (Fase 3) los convierte en `ApiError`.\n */\n\n/**\n * Un error con ruta del422 (auth.md §6): `path` para pintarlo en el campo y\n * `code` MAYUS_SNAKE (`VALIDATION_MIN_LENGTH`) para mapearlo sin leer texto.\n */\nexport interface ApiIssue {\n /** Ruta del campo afectado (`faq[2].answer`, `sku`). */\n path: string;\n /** Mensaje en español, listo para pintar. */\n message: string;\n /** Código estable del validador (B11); el mensaje puede cambiar, el código no. */\n code?: string;\n}\n\n/** Shape del body de error (doc/baseapi.md §8 «Errores»). */\nexport interface ApiErrorBody {\n error: {\n status: number;\n message: string;\n /** Ruta del campo afectado cuando el backend la envía (base.md §10). */\n path?: string;\n /**\n * Código de sesión de §4.5 (R2.9): `AUTH_REQUIRED` · `AUTH_INVALID` ·\n * `AUTH_EXPIRED` · `FORBIDDEN` · `RATE_LIMITED`. Aparece SÓLO en esas\n * cinco respuestas — el sobre de error es aditivo (O7 / D10-5).\n */\n code?: string;\n /**\n * Errores de validación con ruta (base.md §5, guía §10): el 422 los manda\n * ACÁ (`error.errors[]`), no en `path`. Sin modelarlos el form veía\n * «Errores de validación» genérico y ningún campo se pintaba (D42).\n */\n errors?: ApiIssue[];\n };\n}\n\n/** Error de API estandarizado que lanza el interceptor de errores. */\nexport class ApiError extends Error {\n readonly status: number;\n /** Ruta del campo que provocó el error (ej. `faq[2].answer`), si existe. */\n readonly fieldPath?: string;\n /** Código de sesión de §4.5 si el backend lo envió; `undefined` en el resto. */\n readonly code?: string;\n /** Issues con ruta (422); vacío cuando el error no trae `errors[]`. */\n readonly issues: readonly ApiIssue[];\n\n constructor(\n status: number,\n message: string,\n fieldPath?: string,\n code?: string,\n issues: readonly ApiIssue[] = [],\n ) {\n super(message);\n this.name = 'ApiError';\n this.status = status;\n this.fieldPath = fieldPath;\n this.code = code;\n this.issues = issues;\n }\n}\n\n/**\n * `meta.renewedToken` (auth.md §3.2/§3.4): el back lo adjunta a la respuesta\n * cuando la vida del token bajó del umbral de renovación. Es el ÚNICO modo\n * de que el front se entere — el token nuevo no viaja en cabeceras ni en la\n * URL. Devuelve `null` cuando no hay renovación (que es lo normal).\n *\n * Vive acá y no en el `ApiService` porque lo consumen DOS servicios\n * (`ApiService` y `AuthService`) y éste modelo no importa a ninguno de los\n * dos: sin este archivo no hay ciclo de imports.\n */\nexport function renewedTokenOf(body: unknown): string | null {\n if (body === null || typeof body !== 'object') return null;\n const meta = (body as { meta?: unknown }).meta;\n if (meta === null || typeof meta !== 'object') return null;\n const token = (meta as { renewedToken?: unknown }).renewedToken;\n return typeof token === 'string' && token !== '' ? token : null;\n}\n","import { InjectionToken } from '@angular/core';\n\n/**\n * URL base de la API (baseapi §2.3): es la URL directa del Web App de Apps\n * Script; ahí se hace el `POST` del envelope `{ token, method, path, payload }`.\n * OBLIGATORIO proporcionarlo en `app.config.ts`:\n * `{ provide: API_URL, useValue: 'https://…' }` (Fase 3). Vacío = mismo origen.\n */\nexport const API_URL = new InjectionToken<string>('API_URL');\n","import { HttpClient } from '@angular/common/http';\nimport { computed, inject, Service, signal } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { catchError, map, Observable, of, tap } from 'rxjs';\n\nimport type { FieldSchema, ResourceSchema } from '../models/schema.model';\nimport { renewedTokenOf } from '../models/api.model';\nimport { API_URL } from '../tokens';\n\n/**\n * Sesión del admin (auth.md §5.2) — **única dueña** del token y del usuario.\n *\n * Qué vive acá y por qué:\n *\n * - **Señales** `user` / `token` / `isAuthenticated` / `role`: el único\n * estado que el resto de la app lee (guards, menú, interceptor).\n * - **`login()` / `logout()` / `logoutAll()` / `restore()`**: operaciones de sesión.\n * El `AuthService` NO inyecta `ApiService` — sólo `HttpClient` — porque\n * `ApiService` inyecta a éste para leer el token, y un ciclo de DI en\n * Angular es un error en tiempo de arranque, no un warning.\n * - **`applyAuthCode()` (R2.9): EL único intérprete de la tabla de §4.5.**\n * Ningún otro archivo decide qué pasa ante `AUTH_*` o `FORBIDDEN`.\n * - **Almacenamiento (R2.12): `sessionStorage`, siempre.** `rememberMe`\n * no puede usar `localStorage` porque D10-3 lo negó — ver más abajo.\n *\n * La sesión arranca desde el storage y `restore()` la revalida contra\n * `/auth/me` en el initializer: un usuario desactivado mientras la pestaña\n * estaba abierta cae al primer reload, no en mitad de una edición.\n */\n\n/** Usuario tal y como lo sirve `publicUser_` (lista blanca, R2.17). */\nexport interface SessionUser {\n id?: string;\n email?: string;\n name?: string;\n role?: string;\n active?: boolean;\n last_login_at?: string;\n created_at?: string;\n}\n\n/** Los cinco códigos de §4.5. El resto de errores no son de sesión. */\nexport type AuthErrorCode =\n 'AUTH_REQUIRED' | 'AUTH_INVALID' | 'AUTH_EXPIRED' | 'FORBIDDEN' | 'RATE_LIMITED';\n\n/** Ruta de login: fuera del shell para que ningún guard la proteja. */\nexport const LOGIN_PATH = '/login';\n\n/**\n * Claves del `sessionStorage`. Exportadas porque **la sesión se restaura\n * desde ahí en el constructor**: un test que quiera una sesión arrancando\n * tiene que sembrarlas antes de inyectar el servicio, y el que las use con\n * otro nombre quebraría el restore en silencio.\n */\nexport const SESSION_TOKEN_KEY = 'admin.session.token';\nexport const SESSION_USER_KEY = 'admin.session.user';\n\ninterface LoginResponse {\n token: string;\n user: SessionUser;\n}\ninterface MeResponse {\n user: SessionUser;\n}\n\n@Service()\nexport class AuthService {\n private readonly http = inject(HttpClient);\n private readonly apiUrl = inject(API_URL);\n private readonly router = inject(Router);\n\n /**\n * D10-3: **sólo `sessionStorage`.** La opción «recordarme» con\n * `localStorage` quedó denegada en §9.3 — muere con la pestaña ⇒ cero\n * token legible por un XSS futuro. `authSchema.rememberMe` es `false`\n * por la misma razón: declarar `true` sería prometer un storage que\n * este servicio no usa.\n *\n * Nunca en la URL ni en el cuerpo de un GET (§5.4): el token sólo viaja\n * dentro del envelope `{ token, method, path, payload }`.\n */\n private readonly storage: Storage = sessionStorage;\n\n private readonly _user = signal<SessionUser | null>(null);\n private readonly _token = signal<string | null>(null);\n /** Ruta previa a un `AUTH_EXPIRED`, para volver tras reloguear (§4.5). */\n private readonly _returnUrl = signal<string | null>(null);\n\n readonly user = this._user.asReadonly();\n readonly token = this._token.asReadonly();\n readonly returnUrl = this._returnUrl.asReadonly();\n /** Sólo hay sesión con token Y usuario: uno sin el otro es estado corrupto. */\n readonly isAuthenticated = computed(() => this._token() !== null && this._user() !== null);\n readonly role = computed(() => this._user()?.role ?? '');\n\n constructor() {\n const token = this.storage.getItem(SESSION_TOKEN_KEY);\n if (token !== null && token !== '') this._token.set(token);\n const raw = this.storage.getItem(SESSION_USER_KEY);\n if (raw !== null && raw !== '') {\n try {\n this._user.set(JSON.parse(raw) as SessionUser);\n } catch {\n // JSON corrupto ⇒ no hay sesión que restaurar; storage sucio.\n this.storage.removeItem(SESSION_USER_KEY);\n this.storage.removeItem(SESSION_TOKEN_KEY);\n this._token.set(null);\n }\n }\n }\n\n // ── Sesión ───────────────────────────────────────────────────────────────\n\n login(email: string, password: string): Observable<SessionUser> {\n return this.post<LoginResponse>('/auth/login', { email, password }).pipe(\n map((res) => {\n this.open(res.token, res.user);\n const renewed = renewedTokenOf(res);\n if (renewed !== null) this.applyRenewedToken(renewed);\n return res.user;\n }),\n );\n }\n\n /**\n * Revocación best-effort (§9.7): se pide al back que ponga el `sid` en la\n * lista de revocados, pero **la sesión local se ciere haya o no respuesta**.\n * Un logout que «falla» por red y deja al usuario dentro es peor que uno\n * que deja una sesión muerta en el servidor.\n */\n logout(): Observable<void> {\n return this.post<{ loggedOut?: boolean }>('/auth/logout').pipe(\n tap({\n next: () => this.clear(),\n error: () => this.clear(),\n }),\n map(() => undefined),\n );\n }\n\n /** Revoca las sesiones del usuario en todos sus dispositivos. */\n logoutAll(): Observable<{ effectiveWithinSeconds: number }> {\n return this.post<{ sessionsRevoked: boolean; effectiveWithinSeconds: number }>(\n '/auth/logout-all',\n ).pipe(\n tap(() => {\n this.clear();\n this.goLogin();\n }),\n map((res) => ({ effectiveWithinSeconds: res.effectiveWithinSeconds })),\n );\n }\n\n /** Revalida la sesión restaurada contra `/auth/me`; sin token ⇒ sin viaje. */\n restore(): Observable<void> {\n if (this._token() === null) return of(undefined);\n return this.post<MeResponse>('/auth/me').pipe(\n tap((res) => {\n this.open(this._token(), res.user);\n }),\n // El interceptor ya interpretó el `AUTH_*` (R2.9) antes de llegar\n // acá: esto sólo evita que un fallo rompa el arranque de la app.\n catchError(() => of(undefined)),\n map(() => undefined),\n );\n }\n\n /**\n * Renovación deslizante (§3.2): el back manda `meta.renewedToken` cuando\n * la vida del token bajó del umbral. Se persiste el MISMO día que el\n * token original — el `sid` no cambia, sólo se emite una firma nueva.\n */\n applyRenewedToken(token: string): void {\n if (token === '' || this._token() === null) return;\n this._token.set(token);\n this.storage.setItem(SESSION_TOKEN_KEY, token);\n }\n\n // ── R2.9 · la tabla de §4.5, en un solo sitio ───────────────────────────\n\n /**\n * ÚNICO intérprete de los códigos de sesión (auth.md §4.5 / §5.2).\n * El interceptor `apiErrorInterceptor` lo llama y nada más: cualquier\n * archivo que decida «si ve AUTH_EXPIRED hago X» está fuera de contrato.\n *\n * | Código | Qué hace |\n * | --------------- | ------------------------------------------- |\n * | `AUTH_REQUIRED` | limpia sesión y va a login |\n * | `AUTH_INVALID` | limpia sesión y va a login |\n * | `AUTH_EXPIRED` | guarda la ruta previa, limpia, va a login |\n * | `FORBIDDEN` | **no** cierra sesión (el usuario sigue dentro) |\n * | `RATE_LIMITED` | no hace nada: lo espera el formulario |\n */\n applyAuthCode(code: string | undefined): void {\n switch (code) {\n case 'AUTH_EXPIRED':\n // La ruta previa se guarda ANTES de borrar: después de limpiar no\n // queda desde dónde navegar (y `router.url` ya cambió al llegar).\n this._returnUrl.set(this.currentUrl());\n this.clear();\n this.goLogin();\n break;\n case 'AUTH_REQUIRED':\n case 'AUTH_INVALID':\n // «La sesión terminó» — no hay vuelta atrás que conservar.\n this.clear();\n this.goLogin();\n break;\n case 'FORBIDDEN':\n case 'RATE_LIMITED':\n // Decisión explícita de NO tocar la sesión: §4.5 exige que el\n // usuario vea «sin permiso» o «espera» **siguiendo dentro**.\n break;\n default:\n // No es un código de sesión: nada que interpretar.\n break;\n }\n }\n\n // ── Helpers ──────────────────────────────────────────────────────────────\n\n /** ¿El rol de la sesión cubre `required`? (mínimo: admin ≥ staff, §4.4) */\n hasRole(required: string): boolean {\n if (required === '' || required === 'session') return this.isAuthenticated();\n const role = this.role();\n if (role === 'admin') return true;\n return role !== '' && role === required;\n }\n\n /**\n * §5.3 — el ÚNICO criterio de visibilidad del front (menú, rutas y\n * botones). `requires` viene del vocabulario de §4.4: `public` no pide\n * sesión; todo lo demás sí; `roles` estrecha.\n *\n * Es **pura decisión de UI**. El back re-verifica `accessLevel` en cada\n * petición (R2.6), así que filtrar acá no protege nada: sólo evita\n * enseñarle a alguien un botón que le va a devolver 403.\n */\n canAccess(access?: { requires?: string; roles?: string[] }): boolean {\n const requires = access?.requires ?? 'session';\n if (requires === 'public') return true;\n if (!this.isAuthenticated()) return false;\n\n // §4.4 escribe el requerimiento como `role:admin`; §5.3 como\n // `roles: ['admin']`. Se aceptan las dos formas en lugar de elegir una:\n // son el mismo dato visto desde el nivel de acceso y desde el recurso.\n const role = requires.startsWith('role:') ? requires.slice('role:'.length) : '';\n const required = role === '' ? (access?.roles ?? []) : [role];\n if (required.length === 0) return true;\n return required.some((one) => this.hasRole(one));\n }\n\n // ── R7.5 · Consumo de políticas en UI (F10) ───────────────────────────────\n\n /**\n * Evalúa si el usuario puede ejecutar una operación específica según\n * `policies.access.operations` del recurso (B8 · R7.4a).\n *\n * El override por operación tiene prioridad sobre el umbral del grupo.\n * Si no hay override, se usa el umbral `policies.access.read` o\n * `policies.access.write` según la operación.\n *\n * Fallback a `permissions` (legacy) si `policies` no existe: mientras\n * los schemas locales no tengan `policies`, se mantiene compatibilidad.\n *\n * Es **pura decisión de UI**. El back vuelve a verificar en cada petición\n * (24-crud), así que esto sólo evita mostrar botones que darían 403.\n */\n canDoOperation(\n schema: ResourceSchema,\n operation: 'list' | 'get' | 'create' | 'update' | 'remove',\n ): boolean {\n // R7.5: intentar policies primero\n const ops = schema.policies?.access?.operations;\n if (ops && ops[operation]) {\n return this.meetsLevel(ops[operation]);\n }\n\n // Sin override en policies: usar el umbral del grupo\n if (schema.policies?.access) {\n const isWrite = operation === 'create' || operation === 'update' || operation === 'remove';\n const groupLevel = isWrite ? schema.policies.access.write : schema.policies.access.read;\n return this.meetsLevel(groupLevel ?? 'admin');\n }\n\n // Fallback a permissions (legacy, R7.5 transición)\n const perms = schema.permissions;\n if (perms) {\n const permMap: Record<string, boolean | undefined> = {\n list: true, // list no tiene en permissions, siempre true si no hay policies\n get: true,\n create: perms.create,\n update: perms.update,\n remove: perms.remove,\n };\n return permMap[operation] !== false;\n }\n\n // Sin policies ni permissions: UX optimista (§5.3 legacy) — el back es\n // la autoridad y responde 403 si el rol no alcanza.\n return true;\n }\n\n /**\n * Evalúa si el usuario puede leer un campo según `field.access.read`\n * (B8 · R7.4b).\n *\n * Es **pura decisión de UI**. El back vuelve a filtrar la respuesta en\n * cada petición (24-crud), así que esto sólo evita mostrar datos que el\n * usuario no debería ver.\n */\n canReadField(field: FieldSchema): boolean {\n if (!field.access || !field.access.read) return true; // sin restricción ⇒ visible\n return this.meetsLevel(field.access.read);\n }\n\n /**\n * Evalúa si el usuario puede escribir un campo según `field.access.write`\n * (B8 · R7.4b).\n *\n * Es **pura decisión de UI**. El back rechaza la escritura con 422 si el\n * usuario no tiene permiso, así que esto sólo pone el campo en\n * solo-lectura en el frontend.\n */\n canWriteField(field: FieldSchema): boolean {\n if (!field.access || !field.access.write) return true; // sin restricción ⇒ editable\n return this.meetsLevel(field.access.write);\n }\n\n /**\n * Verifica si el rol actual cumple un nivel de acceso dado.\n * Usa la misma jerarquía que `ACCESS_ROLE_RANK` del back (11-auth):\n * admin ≥ staff.\n */\n private meetsLevel(level: string): boolean {\n if (level === 'public') return true;\n if (level === 'session') return this.isAuthenticated();\n if (level.startsWith('role:')) {\n const requiredRole = level.slice('role:'.length);\n return this.hasRole(requiredRole);\n }\n // fallback conservador: nivel desconocido ⇒ sólo admin\n return this.hasRole('admin');\n }\n\n private open(token: string | null, user: SessionUser | null): void {\n if (token !== null && token !== '') this._token.set(token);\n this._user.set(user);\n if (token !== null && token !== '') this.storage.setItem(SESSION_TOKEN_KEY, token);\n if (user !== null) this.storage.setItem(SESSION_USER_KEY, JSON.stringify(user));\n }\n\n /**\n * Borra token **y** usuario (§5.4) — en ese orden de importancia: un token\n * sin usuario no autentica, pero un usuario sin token engaña al menú.\n */\n /**\n * Ruta previa guardada por un `AUTH_EXPIRED` (§4.5), **consumida**: se\n * devuelve una sola vez y se borra. Sin el consume, cada login futuro\n * volvería a la misma URL vieja aunque el usuario hubiera llegado al\n * login desde el menú.\n */\n consumeReturnUrl(): string | null {\n const url = this._returnUrl();\n this._returnUrl.set(null);\n return url;\n }\n\n private clear(): void {\n this._token.set(null);\n this._user.set(null);\n this.storage.removeItem(SESSION_TOKEN_KEY);\n this.storage.removeItem(SESSION_USER_KEY);\n }\n\n private goLogin(): void {\n if (this.currentUrl().startsWith(LOGIN_PATH)) return;\n // Angular rechaza la promesa cuando no hay ruta que empate (NG04002).\n // Navegar es un efecto, no una operación cuyo resultado alguien espere:\n // el catch evita una rejection sin handler en arranques y en tests.\n void this.router.navigate([LOGIN_PATH]).catch(() => undefined);\n }\n\n private currentUrl(): string {\n return this.router.url;\n }\n\n private envelope(path: string, payload: Record<string, unknown> = {}) {\n return { token: this._token(), method: 'POST' as const, path, payload };\n }\n\n /**\n * Mismo transporte que `ApiService` (R2.8): cuerpo JSON con\n * `Content-Type: text/plain` ⇒ **simple request**, sin preflight CORS.\n * Los tres endpoints de sesión pasan por acá — si alguno se saltara el\n * header, el navegador añadiría `application/json` y la llamada empezaría\n * a pedir permiso al servidor con un OPTIONS.\n */\n private post<T>(path: string, payload: Record<string, unknown> = {}): Observable<T> {\n return this.http.post<T>(this.apiUrl, this.envelope(path, payload), {\n headers: { 'Content-Type': 'text/plain' },\n });\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { inject, Service } from '@angular/core';\nimport { map, Observable, tap, throwError } from 'rxjs';\n\nimport { renewedTokenOf } from '../models/api.model';\nimport type { ResourceEndpoints } from '../models/schema.model';\nimport { API_URL } from '../tokens';\nimport { AuthService } from './auth.service';\n\n/** Métodos que entiende el envelope del backend (baseapi §2.3). */\nexport type EnvelopeMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n\n/**\n * CRUD genérico sobre el contrato v2 (baseapi §2.3): TODA llamada a la API\n * es un `POST` a `API_URL` con cuerpo `text/plain` y el JSON\n * `{ token, method, path, payload }`. `method: 'GET'` también para lecturas;\n * el token viaja en el cuerpo (nunca en cabeceras: criterio 11 de §17).\n *\n * `text/plain` en lugar de `application/json` evita el preflight CORS\n * (simple request) — criterio 11: sin cabeceras custom.\n *\n * **R2.8 — convención sobre el snippet.** `auth.md` §5.2 llama a las claves\n * `{ route, op, token, payload }`, pero el backend (`parseEnvelope_`) lee\n * `path` y `method`: el snippet es un esquema a medias, no un contrato.\n * Mismo precedente que en R2.5 — **la convención del código gana**. Cambiar\n * el nombre ahora rompería el único transporte que existe.\n *\n * **R2.12 — el token sale de `AuthService`, no de configuración.** El\n * `ADMIN_TOKEN` (D21-C) se retiró: no hay credencial fija, hay sesión.\n *\n * Devuelve el JSON plano tal cual, sin transformaciones ocultas\n * (base.md §1, principio 4). Los errores del backend (200 + `{ error: {…} }`)\n * los convierte en `ApiError` el interceptor `apiErrorInterceptor`, que es\n * también quien pasa los `AUTH_*` a `AuthService.applyAuthCode` (R2.9).\n */\n@Service()\nexport class ApiService {\n private readonly http = inject(HttpClient);\n private readonly apiUrl = inject(API_URL);\n private readonly auth = inject(AuthService);\n\n /**\n * Listado. El backend envuelve la respuesta cuando la operación declara\n * `shape.envelope: 'list'` (F5) ⇒ `{ items, nextCursor, total }` (R6.4);\n * la UI consume `T[]` en todos lados (F7-3) y este es el ÚNICO punto que\n * habla de listas, así que el desenvolvimiento vive acá. `nextCursor` es\n * el token de la página siguiente y `null` en la última — éste servicio\n * lo descarta hoy porque la lista no pagina todavía (backlog-ui-ux).\n * Un listado sin envelope (arreglo plano, el contrato histórico) pasa\n * tal cual.\n *\n * `payload` sólo lo usa una fuente declarada (F8 · R6.5): `{ view, params }`\n * pide el listado filtrado por una vista y sus parámetros. Sin él, la\n * llamada es la de siempre — la lectura llana del recurso.\n */\n list<T>(endpoint: ResourceEndpoints, payload?: Record<string, unknown>): Observable<T[]> {\n return this.send<unknown>(endpoint.list, 'GET', payload).pipe(map((raw) => unwrapList<T>(raw)));\n }\n\n /** `key` solo aplica a colecciones (`{key}` en la plantilla); los singleton no la llevan. */\n get<T>(endpoint: ResourceEndpoints, key?: string): Observable<T> {\n return this.send<T>(this.withKey(endpoint.get, key), 'GET');\n }\n\n create<T>(endpoint: ResourceEndpoints, payload: Record<string, unknown>): Observable<T> {\n return this.send<T>(endpoint.create, 'POST', payload);\n }\n\n update<T>(\n endpoint: ResourceEndpoints,\n key: string | undefined,\n payload: Record<string, unknown>,\n ): Observable<T> {\n return this.send<T>(this.withKey(endpoint.update, key), 'PUT', payload);\n }\n\n remove(endpoint: ResourceEndpoints, key?: string): Observable<void> {\n return this.send<void>(this.withKey(endpoint.remove, key), 'DELETE');\n }\n\n /**\n * Operación genérica sobre una ruta ya resuelta: reorder de colección\n * (`PUT /admin/x` con `{ reorder: … }`), `/admin/schema`,\n * `/admin/upload-signature`, etc.\n */\n request<T>(\n method: EnvelopeMethod,\n path: string | undefined,\n payload?: Record<string, unknown>,\n ): Observable<T> {\n return this.send<T>(path, method, payload);\n }\n\n private send<T>(\n path: string | undefined,\n method: EnvelopeMethod,\n payload?: Record<string, unknown>,\n ): Observable<T> {\n if (!path) {\n return throwError(() => new Error('Operación no disponible para este recurso'));\n }\n // Token de la SESIÓN, leído en cada petición (R2.8): no hay credencial\n // fija que inyectar en el arranque.\n const body = { token: this.auth.token(), method, path, payload: payload ?? {} };\n return this.http.post<T>(this.apiUrl, body, { headers: { 'Content-Type': 'text/plain' } }).pipe(\n // Renovación deslizante (§3.2): si el back adjuntó `meta.renewedToken`\n // se adopta YA, con lo que la siguiente petición ya va firmada nueva.\n tap((res) => {\n const renewed = renewedTokenOf(res);\n if (renewed !== null) this.auth.applyRenewedToken(renewed);\n }),\n );\n }\n\n private withKey(path: string | undefined, key?: string): string | undefined {\n if (!path) {\n return undefined;\n }\n return path.includes('{key}') ? path.replace('{key}', encodeURIComponent(key ?? '')) : path;\n }\n}\n\n/** `{ items, nextCursor, total }` (F5/R6.4) → `T[]`; arreglo plano → tal cual; otro ⇒ []. */\nfunction unwrapList<T>(raw: unknown): T[] {\n if (Array.isArray(raw)) {\n return raw as T[];\n }\n if (raw !== null && typeof raw === 'object') {\n const items = (raw as { items?: unknown }).items;\n if (Array.isArray(items)) {\n return items as T[];\n }\n }\n return [];\n}\n"],"mappings":";;;;;AA4CA,IAAa,WAAb,cAA8B,MAAK;CACxB;CAEA;CAEA;CAEA;CAET,YACE,QACA,SACA,WACA,MACA,SAA8B,CAAA,GAAE;EAEhC,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK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