@innertia-solutions/innertia-nuxt 0.1.73 → 0.1.74

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,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/innertia-nuxt",
3
- "version": "0.1.73",
3
+ "version": "0.1.74",
4
4
  "description": "Innertia Solutions — Nuxt layer unificada: core, auth, multitenancy, theme y app contexts",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -11,27 +11,35 @@
11
11
  * el header por-request sin afectar el toggle global.
12
12
  *
13
13
  * Solo activo cuando `mode === 'saas'` (orgs viven dentro de un tenant).
14
+ *
15
+ * Depende de `innertia:vue-query`: useOrganization → useAuth → useQueryClient()
16
+ * necesita el QueryClient instalado. Sin `dependsOn`, el orden alfabético de la
17
+ * capa corre este plugin antes y el cliente cae con "No 'queryClient' found".
14
18
  */
15
- export default defineNuxtPlugin(() => {
16
- const { hasTenant } = useInnertiaMode()
17
- if (!hasTenant()) return
19
+ export default defineNuxtPlugin({
20
+ name: 'innertia:api-organization',
21
+ dependsOn: ['innertia:vue-query'],
22
+ setup() {
23
+ const { hasTenant } = useInnertiaMode()
24
+ if (!hasTenant()) return
18
25
 
19
- const appConfig = useAppConfig()
20
- if (!appConfig.innertia?.organizations?.enabled) return
26
+ const appConfig = useAppConfig()
27
+ if (!appConfig.innertia?.organizations?.enabled) return
21
28
 
22
- const { add } = useRequestInterceptors()
23
- const organizationStore = useOrganizationStore()
24
- const { currentContext } = useOrganization()
29
+ const { add } = useRequestInterceptors()
30
+ const organizationStore = useOrganizationStore()
31
+ const { currentContext } = useOrganization()
25
32
 
26
- add((headers: Record<string, string>) => {
27
- const ctx = currentContext.value
28
- if (!ctx) return
33
+ add((headers: Record<string, string>) => {
34
+ const ctx = currentContext.value
35
+ if (!ctx) return
29
36
 
30
- const slug = organizationStore.currentFor(ctx)
31
- if (slug) headers['X-Organization'] = slug
37
+ const slug = organizationStore.currentFor(ctx)
38
+ if (slug) headers['X-Organization'] = slug
32
39
 
33
- if (organizationStore.consolidated) {
34
- headers['X-Consolidated'] = 'true'
35
- }
36
- })
40
+ if (organizationStore.consolidated) {
41
+ headers['X-Consolidated'] = 'true'
42
+ }
43
+ })
44
+ },
37
45
  })
@@ -1,29 +1,32 @@
1
1
  import type { DehydratedState } from '@tanstack/vue-query'
2
2
  import { VueQueryPlugin, QueryClient, dehydrate, hydrate } from '@tanstack/vue-query'
3
3
 
4
- export default defineNuxtPlugin((nuxtApp) => {
5
- const vueQueryState = useState<DehydratedState | null>('vue-query')
4
+ export default defineNuxtPlugin({
5
+ name: 'innertia:vue-query',
6
+ setup(nuxtApp) {
7
+ const vueQueryState = useState<DehydratedState | null>('vue-query')
6
8
 
7
- const queryClient = new QueryClient({
8
- defaultOptions: {
9
- queries: {
10
- staleTime: 5 * 60 * 1000, // 5 min — datos frescos sin re-fetch
11
- gcTime: 10 * 60 * 1000, // 10 min — cache se limpia si no hay subscribers
12
- retry: 1,
13
- refetchOnWindowFocus: false,
9
+ const queryClient = new QueryClient({
10
+ defaultOptions: {
11
+ queries: {
12
+ staleTime: 5 * 60 * 1000, // 5 min — datos frescos sin re-fetch
13
+ gcTime: 10 * 60 * 1000, // 10 min — cache se limpia si no hay subscribers
14
+ retry: 1,
15
+ refetchOnWindowFocus: false,
16
+ },
14
17
  },
15
- },
16
- })
18
+ })
17
19
 
18
- nuxtApp.vueApp.use(VueQueryPlugin, { queryClient })
20
+ nuxtApp.vueApp.use(VueQueryPlugin, { queryClient })
19
21
 
20
- if (import.meta.server) {
21
- nuxtApp.hooks.hook('app:rendered', () => {
22
- vueQueryState.value = dehydrate(queryClient)
23
- })
24
- }
22
+ if (import.meta.server) {
23
+ nuxtApp.hooks.hook('app:rendered', () => {
24
+ vueQueryState.value = dehydrate(queryClient)
25
+ })
26
+ }
25
27
 
26
- if (import.meta.client) {
27
- hydrate(queryClient, vueQueryState.value)
28
- }
28
+ if (import.meta.client) {
29
+ hydrate(queryClient, vueQueryState.value)
30
+ }
31
+ },
29
32
  })