@innertia-solutions/innertia-nuxt 0.1.19 → 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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/innertia-nuxt",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Innertia Solutions — Nuxt layer unificada: core, auth, multitenancy, theme y app contexts",
5
5
  "keywords": [
6
6
  "nuxt",
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
+ })