@innertia-solutions/innertia-nuxt 0.1.18 → 0.1.20
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/app.config.ts +8 -1
- package/middleware/04.app-status.global.ts +29 -0
- package/package.json +1 -1
- package/stores/app.js +18 -0
package/app.config.ts
CHANGED
|
@@ -17,8 +17,15 @@ export default defineAppConfig({
|
|
|
17
17
|
* Default por compatibilidad con productos existentes.
|
|
18
18
|
* - 'app' → single-tenant / app interna. No detecta subdomain ni inyecta tenant header.
|
|
19
19
|
* Auth y contextos siguen funcionando igual que en saas.
|
|
20
|
+
*
|
|
21
|
+
* IMPORTANTE: se deja `undefined` a propósito (no hardcodear 'saas' aquí).
|
|
22
|
+
* Nuxt mergea `app.config.ts` de la capa CON MAYOR prioridad que el bloque
|
|
23
|
+
* `appConfig` del `nuxt.config.ts` del producto (defuFn(cfg_capa, inlineConfig)).
|
|
24
|
+
* Si pusiéramos un valor concreto, el producto no podría cambiarlo desde su
|
|
25
|
+
* nuxt.config. Con `undefined`, defu deja pasar el valor del producto y el
|
|
26
|
+
* default real ('saas') lo aplica `useInnertiaMode()` vía `?? 'saas'`.
|
|
20
27
|
*/
|
|
21
|
-
mode:
|
|
28
|
+
mode: undefined as InnertiaMode | undefined,
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* Branding del producto (nombre + versión). Los logos viven en `/public/isologo-light.png`
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// useAppStore + useInnertiaMode auto-importados.
|
|
2
|
+
// Server-only: en app mode hace fetch de /status (branding + features + demo) y
|
|
3
|
+
// puebla useAppStore. Equivalente app-mode de 02.validate-tenant (saas).
|
|
4
|
+
// Solo activo en mode === 'app'.
|
|
5
|
+
export default defineNuxtRouteMiddleware(async () => {
|
|
6
|
+
if (!useInnertiaMode().isApp()) return
|
|
7
|
+
if (!import.meta.server) return
|
|
8
|
+
|
|
9
|
+
const appStore = useAppStore()
|
|
10
|
+
if (appStore.branding?.name) return // ya poblado este request
|
|
11
|
+
|
|
12
|
+
const config = useRuntimeConfig()
|
|
13
|
+
const internalUrl = (config as any).apiInternalUrl || 'http://api:80'
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const data = await $fetch<{
|
|
17
|
+
ok: boolean
|
|
18
|
+
branding?: { name?: string; demo?: { email: string; password: string } | null }
|
|
19
|
+
features?: Record<string, any>
|
|
20
|
+
}>(`${internalUrl}/status`, {
|
|
21
|
+
headers: { Accept: 'application/json' },
|
|
22
|
+
timeout: 5000,
|
|
23
|
+
})
|
|
24
|
+
appStore.setStatus(data)
|
|
25
|
+
} catch (e: any) {
|
|
26
|
+
// No romper la navegación: el login debe funcionar aunque no haya demo.
|
|
27
|
+
console.warn('[app-status] /status no disponible:', e?.message)
|
|
28
|
+
}
|
|
29
|
+
})
|
package/package.json
CHANGED
package/stores/app.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
|
|
3
|
+
// Estado de la app (modo single-tenant). Poblado por el middleware 04.app-status
|
|
4
|
+
// desde GET /status. Equivalente app-mode del tenantStore de saas.
|
|
5
|
+
export const useAppStore = defineStore('app', {
|
|
6
|
+
state: () => ({
|
|
7
|
+
branding: {}, // { name }
|
|
8
|
+
features: {}, // { organizations, teams, oauth }
|
|
9
|
+
demo: null, // { email, password } | null
|
|
10
|
+
}),
|
|
11
|
+
actions: {
|
|
12
|
+
setStatus(status) {
|
|
13
|
+
this.branding = status?.branding ?? {}
|
|
14
|
+
this.features = status?.features ?? {}
|
|
15
|
+
this.demo = status?.branding?.demo ?? null
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
})
|