164 lines
2.8 KiB
Markdown
164 lines
2.8 KiB
Markdown
# Identity Migration Status
|
|
|
|
## Patrón final de middleware
|
|
|
|
Rutas tenant-scoped:
|
|
|
|
```ts
|
|
import { requireIdentityTenant } from "@erp/identity/api";
|
|
|
|
router.use(...requireIdentityTenant(params));
|
|
```
|
|
|
|
Rutas autenticadas sin tenant:
|
|
|
|
```ts
|
|
import { requireIdentityAuthenticated } from "@erp/identity/api";
|
|
|
|
router.use(...requireIdentityAuthenticated(params));
|
|
```
|
|
|
|
## Migrado a `identity`
|
|
|
|
### `modules/catalogs`
|
|
|
|
Routers migrados:
|
|
|
|
```txt
|
|
payment-methods.routes.ts
|
|
payment-terms.routes.ts
|
|
tax-regimes.routes.ts
|
|
tax-definitions.routes.ts
|
|
```
|
|
|
|
Estado:
|
|
|
|
```txt
|
|
sin @erp/auth/api
|
|
sin mockUser
|
|
sin helpers locales de auth
|
|
usa requireIdentityTenant(params)
|
|
```
|
|
|
|
### `modules/customers`
|
|
|
|
Router migrado:
|
|
|
|
```txt
|
|
customers.routes.ts
|
|
```
|
|
|
|
Estado:
|
|
|
|
```txt
|
|
sin @erp/auth/api
|
|
sin mockUser
|
|
sin helpers locales de auth
|
|
usa requireIdentityTenant(params)
|
|
```
|
|
|
|
### `modules/customer-invoices`
|
|
|
|
Routers migrados:
|
|
|
|
```txt
|
|
proformas.routes.ts
|
|
issued-invoices.routes.ts
|
|
```
|
|
|
|
Estado:
|
|
|
|
```txt
|
|
sin @erp/auth/api
|
|
sin mockUser
|
|
sin helpers locales de auth
|
|
usa requireIdentityTenant(params)
|
|
```
|
|
|
|
Notas:
|
|
|
|
- `companySlug` ya no debe venir de `req.user`.
|
|
- La deuda documental de `companySlug: "rodax"` queda fuera del diseño de auth.
|
|
|
|
### `modules/factuges`
|
|
|
|
Router migrado:
|
|
|
|
```txt
|
|
factuges.routes.ts
|
|
```
|
|
|
|
Estado:
|
|
|
|
```txt
|
|
sin @erp/auth/api
|
|
sin mockUser
|
|
usa requireIdentityTenant(params)
|
|
```
|
|
|
|
Nota:
|
|
|
|
- La carpeta sigue llamándose `infraestructure`; no se ha corregido en esta migración.
|
|
|
|
## Pendiente backend
|
|
|
|
### `modules/supplier`
|
|
|
|
Sigue usando:
|
|
|
|
```ts
|
|
import { mockUser, requireAuthenticated, requireCompanyContext } from "@erp/auth/api";
|
|
```
|
|
|
|
Archivo:
|
|
|
|
```txt
|
|
modules/supplier/src/api/infrastructure/express/suppliers.routes.ts
|
|
```
|
|
|
|
Decisión actual:
|
|
|
|
```txt
|
|
No migrar supplier por ahora.
|
|
```
|
|
|
|
## Legacy documentado
|
|
|
|
`modules/auth` queda documentado como legacy.
|
|
|
|
Uso backend nuevo recomendado:
|
|
|
|
```ts
|
|
import { requireIdentityTenant, requireIdentityAuthenticated } from "@erp/identity/api";
|
|
```
|
|
|
|
`@erp/auth/api` se mantiene temporalmente solo por `supplier`.
|
|
|
|
## Frontend legacy pendiente
|
|
|
|
Todavía existen imports de `@erp/auth/client` en:
|
|
|
|
```txt
|
|
apps/web/src/register-modules.tsx
|
|
apps/web/src/app.tsx
|
|
```
|
|
|
|
Esto impide retirar completamente `modules/auth` aunque el backend acabe limpio.
|
|
|
|
## Búsquedas útiles de control
|
|
|
|
```powershell
|
|
rg -n -F "@erp/auth/api" modules apps packages
|
|
rg -n -F "mockUser" modules apps packages
|
|
rg -n -F "IdentityInternalDeps" modules apps packages
|
|
rg -n -F 'getInternal("identity")' modules apps packages
|
|
rg -n -F "getInternal('identity')" modules apps packages
|
|
```
|
|
|
|
Resultado esperado actual:
|
|
|
|
- `@erp/auth/api`: solo `supplier` y documentación/exports legacy.
|
|
- `mockUser`: solo `supplier` y `modules/auth`.
|
|
- `IdentityInternalDeps`: no debe aparecer en módulos consumidores.
|
|
- `getInternal("identity")`: no debe aparecer en módulos consumidores.
|