una-nuxt-module 3.0.26 → 3.0.28

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/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "una-nuxt-module",
3
- "version": "3.0.26",
3
+ "version": "3.0.28",
4
4
  "configKey": "unaxt",
5
5
  "compatibility": {
6
6
  "nuxt": ">=4.0.0"
package/dist/module.mjs CHANGED
@@ -167,7 +167,7 @@ function addTemplates() {
167
167
  }
168
168
 
169
169
  const name = "una-nuxt-module";
170
- const version = "3.0.26";
170
+ const version = "3.0.28";
171
171
 
172
172
  const module$1 = defineNuxtModule({
173
173
  meta: {
@@ -180,6 +180,7 @@ const module$1 = defineNuxtModule({
180
180
  },
181
181
  defaults: {
182
182
  components: true,
183
+ repositoryPattern: true,
183
184
  auth: {
184
185
  enabled: true,
185
186
  sso: {
@@ -368,6 +369,21 @@ const module$1 = defineNuxtModule({
368
369
  );
369
370
  }
370
371
  }
372
+ function setupRepositoryPattern() {
373
+ if (options.repositoryPattern) {
374
+ addImportsDir(
375
+ ["composables", "types"].map(
376
+ (dir) => resolve(`./runtime/repository-pattern/${dir}`)
377
+ )
378
+ );
379
+ addPlugin({
380
+ name: "auth",
381
+ src: resolve("./runtime/repository-pattern/plugins/api-fetch"),
382
+ mode: "client"
383
+ });
384
+ logger.ready(green("Patron repositorio inicializado"));
385
+ }
386
+ }
371
387
  try {
372
388
  console.log(banner);
373
389
  console.log(yellow(bold(`\u279C v${version}
@@ -377,6 +393,7 @@ const module$1 = defineNuxtModule({
377
393
  setupAutoImports();
378
394
  setupAuth();
379
395
  setupComponents();
396
+ setupRepositoryPattern();
380
397
  await setupTailwindPlugin();
381
398
  addTemplates();
382
399
  setupI18n();
@@ -2,6 +2,6 @@ import type { VariantProps } from "class-variance-authority";
2
2
  export { default as Button } from "./Button.vue.js";
3
3
  export declare const buttonVariants: (props?: ({
4
4
  variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
5
- size?: "default" | "icon" | "sm" | "lg" | "icon-sm" | "icon-lg" | null | undefined;
5
+ size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
6
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
7
  export type ButtonVariants = VariantProps<typeof buttonVariants>;
@@ -0,0 +1,2 @@
1
+ import { createUseAsyncData } from "#imports";
2
+ export const useAPI = createUseAsyncData();
@@ -0,0 +1,4 @@
1
+ import { createUseAsyncData } from "#imports";
2
+ export const useLazyAPI = createUseAsyncData({
3
+ lazy: true
4
+ });
@@ -0,0 +1,12 @@
1
+ import type { IApiResponse } from '#unaxt/types';
2
+ type ApiFetch = <T>(_request: Parameters<typeof $fetch>[0], _options?: Parameters<typeof $fetch>[1]) => Promise<IApiResponse<T>>;
3
+ declare const _default: import("#app").Plugin<{
4
+ api: {
5
+ fetch: ApiFetch;
6
+ };
7
+ }> & import("#app").ObjectPlugin<{
8
+ api: {
9
+ fetch: ApiFetch;
10
+ };
11
+ }>;
12
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import { defineNuxtPlugin, useNuxtApp, useRuntimeConfig } from "#app";
2
+ import { useAuthStore } from "#imports";
3
+ export default defineNuxtPlugin((nuxtApp) => {
4
+ const fetch = $fetch.create({
5
+ baseURL: nuxtApp.$config.public.apiBaseUrl,
6
+ onRequest({ options }) {
7
+ const runtimeConfig = useRuntimeConfig();
8
+ if (!runtimeConfig.public.unaxt.auth.enabled) {
9
+ return;
10
+ }
11
+ const { $pinia } = useNuxtApp();
12
+ const authStore = useAuthStore($pinia);
13
+ if (!authStore.isAuthenticated) {
14
+ return;
15
+ }
16
+ options.headers.set("Authorization", `Bearer ${authStore.token}`);
17
+ }
18
+ });
19
+ return {
20
+ provide: {
21
+ api: {
22
+ fetch
23
+ }
24
+ }
25
+ };
26
+ });
@@ -0,0 +1,6 @@
1
+ import type { NitroFetchOptions, NitroFetchRequest } from 'nitropack';
2
+ export type GetFetchOptions = NitroFetchOptions<NitroFetchRequest, 'get'>;
3
+ export type PutFetchOptions = NitroFetchOptions<NitroFetchRequest, 'put'>;
4
+ export type PostFetchOptions = NitroFetchOptions<NitroFetchRequest, 'post'>;
5
+ export type PatchFetchOptions = NitroFetchOptions<NitroFetchRequest, 'patch'>;
6
+ export type DeleteFetchOptions = NitroFetchOptions<NitroFetchRequest, 'delete'>;
File without changes
@@ -42,6 +42,7 @@ interface ISSOConfig {
42
42
  */
43
43
  export interface IUnaxtModuleOptions {
44
44
  components?: boolean;
45
+ repositoryPattern?: boolean;
45
46
  auth: {
46
47
  /**
47
48
  * Activa o desactiva SSO.
@@ -71,10 +72,10 @@ export interface IUnaxtModuleOptions {
71
72
  * Paginas a usar.
72
73
  */
73
74
  pages?: {
74
- '/401': boolean;
75
- '/403': boolean;
76
- '/auth/sso/login': boolean;
77
- '/auth/sso/logout': boolean;
75
+ '/401'?: boolean;
76
+ '/403'?: boolean;
77
+ '/auth/sso/login'?: boolean;
78
+ '/auth/sso/logout'?: boolean;
78
79
  };
79
80
  };
80
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "una-nuxt-module",
3
- "version": "3.0.26",
3
+ "version": "3.0.28",
4
4
  "description": "Módulo Nuxt para desarrollo CGI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,6 +42,24 @@
42
42
  ".nuxt/templates.css",
43
43
  "dist"
44
44
  ],
45
+ "scripts": {
46
+ "prepack": "nuxt-module-build build",
47
+ "dev": "pnpm run dev:prepare && nuxi dev playground",
48
+ "dev:https": "pnpm run dev:prepare && cd playground && pnpm run dev:https",
49
+ "dev:build": "nuxi build playground",
50
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
51
+ "release:prepare:major": "pnpm run test && pnpm run prepack && changelogen --release --major",
52
+ "release:prepare:minor": "pnpm run test && pnpm run prepack && changelogen --release --minor",
53
+ "release:prepare:patch": "pnpm run test && pnpm run prepack && changelogen --release --patch",
54
+ "release": "pnpm publish && git push --follow-tags",
55
+ "prepare": "husky",
56
+ "format": "prettier --write .",
57
+ "lint": "eslint .",
58
+ "lint:fix": "eslint . --fix",
59
+ "test": "vitest run",
60
+ "test:watch": "vitest watch",
61
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
62
+ },
45
63
  "dependencies": {
46
64
  "@asgardeo/auth-spa": "3.5.0",
47
65
  "@nuxt/a11y": "1.0.0-alpha.1",
@@ -114,21 +132,5 @@
114
132
  "bugs": {
115
133
  "url": "https://github.com/una-cgi/una-nuxt-module/issues"
116
134
  },
117
- "homepage": "https://github.com/una-cgi/una-nuxt-module#readme",
118
- "scripts": {
119
- "dev": "pnpm run dev:prepare && nuxi dev playground",
120
- "dev:https": "pnpm run dev:prepare && cd playground && pnpm run dev:https",
121
- "dev:build": "nuxi build playground",
122
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
123
- "release:prepare:major": "pnpm run test && pnpm run prepack && changelogen --release --major",
124
- "release:prepare:minor": "pnpm run test && pnpm run prepack && changelogen --release --minor",
125
- "release:prepare:patch": "pnpm run test && pnpm run prepack && changelogen --release --patch",
126
- "release": "pnpm publish && git push --follow-tags",
127
- "format": "prettier --write .",
128
- "lint": "eslint .",
129
- "lint:fix": "eslint . --fix",
130
- "test": "vitest run",
131
- "test:watch": "vitest watch",
132
- "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
133
- }
134
- }
135
+ "homepage": "https://github.com/una-cgi/una-nuxt-module#readme"
136
+ }