@merkaly/nuxt 0.6.6 → 0.7.0
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 +1 -1
- package/dist/module.mjs +124 -79
- package/dist/runtime/adapters/create.auth.session.d.ts +1 -1
- package/dist/runtime/adapters/create.auth.session.js +6 -13
- package/dist/runtime/components/input/InputAddress.d.vue.ts +1 -1
- package/dist/runtime/components/input/InputAddress.vue.d.ts +1 -1
- package/dist/runtime/composables/useAuth.d.ts +1 -2
- package/dist/runtime/composables/useAuth.js +1 -3
- package/dist/runtime/composables/useTenant.d.ts +5 -0
- package/dist/runtime/composables/useTenant.js +12 -0
- package/dist/runtime/middleware/auth.d.ts +1 -1
- package/dist/runtime/plugins/api.global.d.ts +1 -1
- package/dist/runtime/plugins/api.global.js +6 -2
- package/dist/runtime/plugins/auth0.client.d.ts +2 -2
- package/dist/runtime/plugins/auth0.client.js +4 -1
- package/dist/runtime/plugins/sentry.global.d.ts +1 -1
- package/dist/runtime/plugins/sentry.global.js +5 -7
- package/dist/runtime/types/nuxt.d.ts +8 -3
- package/package.json +32 -35
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { defineNuxtModule, useLogger, createResolver, addPlugin, addServerHandler, addRouteMiddleware, addImportsDir, addComponentsDir, addTypeTemplate, addTemplate } from '@nuxt/kit';
|
|
2
|
-
import { defu } from 'defu';
|
|
3
|
-
import { createJiti } from 'jiti';
|
|
4
2
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
5
3
|
import { resolve, dirname } from 'node:path';
|
|
4
|
+
import { defu } from 'defu';
|
|
5
|
+
import { createJiti } from 'jiti';
|
|
6
6
|
import svgLoader from 'vite-svg-loader';
|
|
7
7
|
import 'reflect-metadata';
|
|
8
8
|
|
|
9
|
+
const MODULE_NAME = "@merkaly/nuxt";
|
|
10
|
+
const MERKALY_ORG = "merkaly";
|
|
11
|
+
const PLAUSIBLE_API_HOST = "https://analytics.merkaly.io";
|
|
12
|
+
const FONT_AWESOME_KIT_URL = "https://kit.fontawesome.com/55a4b2f4e1.js";
|
|
9
13
|
const defaultOptions = {
|
|
10
14
|
api: {
|
|
11
15
|
url: "/",
|
|
@@ -34,11 +38,48 @@ const defaultOptions = {
|
|
|
34
38
|
token: ""
|
|
35
39
|
}
|
|
36
40
|
};
|
|
41
|
+
function hasI18nConfig(options) {
|
|
42
|
+
return Boolean(
|
|
43
|
+
options.i18n?.defaultLocale && options.i18n.locales.length > 0
|
|
44
|
+
);
|
|
45
|
+
}
|
|
37
46
|
function hasPlausibleConfig(options) {
|
|
38
47
|
return Boolean(options.plausible?.domain);
|
|
39
48
|
}
|
|
49
|
+
function hasSentryBuildConfig(options) {
|
|
50
|
+
return Boolean(options.sentry.project && options.sentry.token);
|
|
51
|
+
}
|
|
52
|
+
function resolveModuleOptions(nuxt) {
|
|
53
|
+
return defu(nuxt.options.merkaly || {}, defaultOptions);
|
|
54
|
+
}
|
|
55
|
+
function buildModuleDependencies(nuxt, options) {
|
|
56
|
+
const dependencies = {
|
|
57
|
+
"@bootstrap-vue-next/nuxt": {},
|
|
58
|
+
"@nuxt/eslint": {},
|
|
59
|
+
"@nuxt/fonts": {},
|
|
60
|
+
"@nuxt/image": {},
|
|
61
|
+
"@sentry/nuxt/module": {},
|
|
62
|
+
"@vueuse/nuxt": {},
|
|
63
|
+
"notivue/nuxt": {}
|
|
64
|
+
};
|
|
65
|
+
if (hasI18nConfig(options)) {
|
|
66
|
+
dependencies["@nuxtjs/i18n"] = {
|
|
67
|
+
overrides: configureI18n(nuxt, options)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (hasPlausibleConfig(options)) {
|
|
71
|
+
dependencies["@nuxtjs/plausible"] = {};
|
|
72
|
+
}
|
|
73
|
+
const logger = useLogger(MODULE_NAME);
|
|
74
|
+
Object.keys(dependencies).forEach((dependency) => {
|
|
75
|
+
logger.info(`Loaded ${dependency} module`);
|
|
76
|
+
});
|
|
77
|
+
return dependencies;
|
|
78
|
+
}
|
|
40
79
|
function configureI18n(nuxt, options) {
|
|
41
|
-
if (!options
|
|
80
|
+
if (!hasI18nConfig(options)) {
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
42
83
|
const writeTemplate = (filename, contents) => {
|
|
43
84
|
const template = addTemplate({
|
|
44
85
|
filename,
|
|
@@ -49,7 +90,7 @@ function configureI18n(nuxt, options) {
|
|
|
49
90
|
writeFileSync(template.dst, contents);
|
|
50
91
|
return template.dst;
|
|
51
92
|
};
|
|
52
|
-
nuxt.options.alias
|
|
93
|
+
nuxt.options.alias.i18n = resolve(nuxt.options.buildDir, "i18n");
|
|
53
94
|
const vueI18n = writeTemplate(
|
|
54
95
|
"i18n/config.mjs",
|
|
55
96
|
`export default defineI18nConfig(() => (${JSON.stringify({
|
|
@@ -60,15 +101,17 @@ function configureI18n(nuxt, options) {
|
|
|
60
101
|
}, null, 2)}))
|
|
61
102
|
`
|
|
62
103
|
);
|
|
63
|
-
nuxt.hook("i18n:registerModule", (register) =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
104
|
+
nuxt.hook("i18n:registerModule", (register) => {
|
|
105
|
+
register({
|
|
106
|
+
langDir: nuxt.options.rootDir,
|
|
107
|
+
locales: options.i18n.locales.map((locale) => ({
|
|
108
|
+
code: locale.code,
|
|
109
|
+
file: locale.file,
|
|
110
|
+
language: locale.language,
|
|
111
|
+
name: locale.name
|
|
112
|
+
}))
|
|
113
|
+
});
|
|
114
|
+
});
|
|
72
115
|
return {
|
|
73
116
|
defaultLocale: options.i18n.defaultLocale,
|
|
74
117
|
detectBrowserLanguage: { useCookie: true },
|
|
@@ -77,51 +120,47 @@ function configureI18n(nuxt, options) {
|
|
|
77
120
|
vueI18n
|
|
78
121
|
};
|
|
79
122
|
}
|
|
80
|
-
function buildModuleDependencies(nuxt, options) {
|
|
81
|
-
const dependencies = {
|
|
82
|
-
"@bootstrap-vue-next/nuxt": {},
|
|
83
|
-
"@nuxt/eslint": {},
|
|
84
|
-
"@nuxt/fonts": {},
|
|
85
|
-
"@nuxt/image": {},
|
|
86
|
-
"@nuxtjs/i18n": { overrides: configureI18n(nuxt, options) },
|
|
87
|
-
"@sentry/nuxt/module": {},
|
|
88
|
-
"@vueuse/nuxt": {},
|
|
89
|
-
"notivue/nuxt": {}
|
|
90
|
-
};
|
|
91
|
-
if (hasPlausibleConfig(options)) {
|
|
92
|
-
dependencies["@nuxtjs/plausible"] = {};
|
|
93
|
-
}
|
|
94
|
-
const logger = useLogger("@merkaly/nuxt");
|
|
95
|
-
Object.keys(dependencies).forEach((it) => logger.info(`Loaded ${it} module`));
|
|
96
|
-
return dependencies;
|
|
97
|
-
}
|
|
98
123
|
function configureRuntimeConfig(nuxt, options) {
|
|
124
|
+
nuxt.options.runtimeConfig.merkaly = defu({
|
|
125
|
+
sentry: {
|
|
126
|
+
token: options.sentry.token
|
|
127
|
+
}
|
|
128
|
+
}, nuxt.options.runtimeConfig.merkaly || {});
|
|
99
129
|
nuxt.options.runtimeConfig.public.merkaly = defu(
|
|
100
|
-
|
|
130
|
+
{
|
|
131
|
+
api: options.api,
|
|
132
|
+
auth0: options.auth0,
|
|
133
|
+
i18n: options.i18n,
|
|
134
|
+
plausible: options.plausible,
|
|
135
|
+
sentry: {
|
|
136
|
+
dsn: options.sentry.dsn,
|
|
137
|
+
project: options.sentry.project
|
|
138
|
+
}
|
|
139
|
+
},
|
|
101
140
|
nuxt.options.runtimeConfig.public.merkaly || {}
|
|
102
141
|
);
|
|
103
142
|
}
|
|
104
143
|
function configurePlausible(nuxt, options) {
|
|
105
|
-
nuxt.options.plausible = defu(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// @ts-expect-error plausible not defined
|
|
115
|
-
nuxt.options.plausible || {}
|
|
116
|
-
);
|
|
144
|
+
nuxt.options.plausible = defu({
|
|
145
|
+
apiHost: PLAUSIBLE_API_HOST,
|
|
146
|
+
domain: options.plausible?.domain,
|
|
147
|
+
enableAutoOutboundTracking: true,
|
|
148
|
+
enableAutoPageviews: true,
|
|
149
|
+
enabled: process.env.NODE_ENV === "production" && hasPlausibleConfig(options),
|
|
150
|
+
ignoredHostnames: ["localhost", options.plausible?.localhost].filter(Boolean)
|
|
151
|
+
// @ts-expect-error Plausible module options aren't typed in Nuxt options
|
|
152
|
+
}, nuxt.options.plausible || {});
|
|
117
153
|
}
|
|
118
154
|
function configureSentry(nuxt, options) {
|
|
119
155
|
nuxt.options.sentry = defu({
|
|
120
156
|
authToken: options.sentry.token,
|
|
121
|
-
org:
|
|
157
|
+
org: MERKALY_ORG,
|
|
122
158
|
project: options.sentry.project
|
|
123
|
-
});
|
|
124
|
-
nuxt.options.sourcemap = {
|
|
159
|
+
}, nuxt.options.sentry || {});
|
|
160
|
+
nuxt.options.sourcemap = {
|
|
161
|
+
client: "hidden",
|
|
162
|
+
server: true
|
|
163
|
+
};
|
|
125
164
|
}
|
|
126
165
|
function configureBootstrapVueNext(nuxt, components) {
|
|
127
166
|
nuxt.options.bootstrapVueNext = defu(
|
|
@@ -129,7 +168,7 @@ function configureBootstrapVueNext(nuxt, components) {
|
|
|
129
168
|
{ plugin: { components } }
|
|
130
169
|
);
|
|
131
170
|
}
|
|
132
|
-
function
|
|
171
|
+
function configureNotivue(nuxt) {
|
|
133
172
|
nuxt.options.css.push("notivue/notification.css");
|
|
134
173
|
nuxt.options.css.push("notivue/animations.css");
|
|
135
174
|
nuxt.options.css.push("notivue/notification-progress.css");
|
|
@@ -143,21 +182,30 @@ function configureNotiVue(nuxt) {
|
|
|
143
182
|
position: "top-right"
|
|
144
183
|
};
|
|
145
184
|
}
|
|
146
|
-
function
|
|
147
|
-
nuxt.options.app
|
|
185
|
+
function configureFontAwesome(nuxt) {
|
|
186
|
+
nuxt.options.app.head ||= {};
|
|
187
|
+
nuxt.options.app.head.script ||= [];
|
|
188
|
+
nuxt.options.app.head.script.push({
|
|
148
189
|
crossorigin: "anonymous",
|
|
149
|
-
src:
|
|
190
|
+
src: FONT_AWESOME_KIT_URL
|
|
150
191
|
});
|
|
151
192
|
}
|
|
152
193
|
function configureVite(nuxt) {
|
|
153
|
-
nuxt.options.vite = defu(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
plugins: [svgLoader()]
|
|
157
|
-
}
|
|
158
|
-
);
|
|
194
|
+
nuxt.options.vite = defu(nuxt.options.vite || {}, {
|
|
195
|
+
plugins: [svgLoader()]
|
|
196
|
+
});
|
|
159
197
|
}
|
|
160
|
-
function
|
|
198
|
+
function configureNuxtOptions(nuxt, options) {
|
|
199
|
+
configureNotivue(nuxt);
|
|
200
|
+
configureRuntimeConfig(nuxt, options);
|
|
201
|
+
configurePlausible(nuxt, options);
|
|
202
|
+
if (hasSentryBuildConfig(options)) {
|
|
203
|
+
configureSentry(nuxt, options);
|
|
204
|
+
}
|
|
205
|
+
configureFontAwesome(nuxt);
|
|
206
|
+
configureVite(nuxt);
|
|
207
|
+
}
|
|
208
|
+
function registerRuntimeFeatures(options, resolver) {
|
|
161
209
|
addPlugin({ src: resolver.resolve("./runtime/plugins/api.global") });
|
|
162
210
|
addPlugin({ src: resolver.resolve("./runtime/plugins/auth0.client") });
|
|
163
211
|
addPlugin({ src: resolver.resolve("./runtime/plugins/sentry.global") });
|
|
@@ -192,36 +240,33 @@ async function loadBootstrapConfig(nuxt) {
|
|
|
192
240
|
const imported = await jiti.import(bootstrapConfigPath).catch(() => ({}));
|
|
193
241
|
return imported.default || {};
|
|
194
242
|
}
|
|
195
|
-
|
|
243
|
+
async function configureExternalIntegrations(nuxt, logger) {
|
|
244
|
+
const bootstrapComponentsConfig = await loadBootstrapConfig(nuxt);
|
|
245
|
+
if (Object.keys(bootstrapComponentsConfig).length > 0) {
|
|
246
|
+
logger.success("Loading bootstrap.config.ts");
|
|
247
|
+
}
|
|
248
|
+
configureBootstrapVueNext(nuxt, bootstrapComponentsConfig);
|
|
249
|
+
}
|
|
250
|
+
const module$1 = defineNuxtModule({
|
|
196
251
|
defaults: defaultOptions,
|
|
197
252
|
meta: {
|
|
198
|
-
name:
|
|
253
|
+
name: MODULE_NAME,
|
|
199
254
|
configKey: "merkaly",
|
|
200
|
-
compatibility: {
|
|
255
|
+
compatibility: {
|
|
256
|
+
nuxt: ">=3.14.0"
|
|
257
|
+
}
|
|
201
258
|
},
|
|
202
259
|
moduleDependencies(nuxt) {
|
|
203
|
-
const options =
|
|
204
|
-
nuxt.options.merkaly || {},
|
|
205
|
-
defaultOptions
|
|
206
|
-
);
|
|
260
|
+
const options = resolveModuleOptions(nuxt);
|
|
207
261
|
return buildModuleDependencies(nuxt, options);
|
|
208
262
|
},
|
|
209
263
|
async setup(options, nuxt) {
|
|
210
|
-
const logger = useLogger(
|
|
264
|
+
const logger = useLogger(MODULE_NAME);
|
|
211
265
|
const resolver = createResolver(import.meta.url);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
configureSentry(nuxt, options);
|
|
216
|
-
const bootstrapComponentsConfig = await loadBootstrapConfig(nuxt);
|
|
217
|
-
if (Object.keys(bootstrapComponentsConfig).length > 0) {
|
|
218
|
-
logger.success("Loading bootstrap.config.ts");
|
|
219
|
-
}
|
|
220
|
-
configureBootstrapVueNext(nuxt, bootstrapComponentsConfig);
|
|
221
|
-
configureAppHead(nuxt);
|
|
222
|
-
registerRuntimeFeatures(nuxt, options, resolver);
|
|
223
|
-
configureVite(nuxt);
|
|
266
|
+
configureNuxtOptions(nuxt, options);
|
|
267
|
+
await configureExternalIntegrations(nuxt, logger);
|
|
268
|
+
registerRuntimeFeatures(options, resolver);
|
|
224
269
|
}
|
|
225
270
|
});
|
|
226
271
|
|
|
227
|
-
export { module as default };
|
|
272
|
+
export { module$1 as default };
|
|
@@ -5,5 +5,5 @@ interface AuthSessionData {
|
|
|
5
5
|
role: string;
|
|
6
6
|
userId: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const createAuthSession: (args?: ((args: object) => import("
|
|
8
|
+
export declare const createAuthSession: (args?: ((args: object) => import("../utils/withAdapter.js").AdapterArgs<AuthSessionData, Record<string, unknown>, object>) | undefined) => import("../composables/useApi.js").UseApiReturn<AuthSessionData, Record<string, unknown>, object>;
|
|
9
9
|
export {};
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { useAuth } from "#imports";
|
|
2
1
|
import { withAdapter } from "../utils/withAdapter.js";
|
|
3
|
-
export const createAuthSession = withAdapter(() => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
authorization: token.value ? `Bearer ${token.value}` : ""
|
|
10
|
-
},
|
|
11
|
-
method: "POST",
|
|
12
|
-
uri: "/session"
|
|
13
|
-
};
|
|
14
|
-
});
|
|
2
|
+
export const createAuthSession = withAdapter(() => ({
|
|
3
|
+
default: () => ({}),
|
|
4
|
+
global: true,
|
|
5
|
+
method: "POST",
|
|
6
|
+
uri: "/session"
|
|
7
|
+
}));
|
|
@@ -81,8 +81,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
81
81
|
}>, {
|
|
82
82
|
mode: PlaceTypes;
|
|
83
83
|
disabled: boolean;
|
|
84
|
-
countries: string[];
|
|
85
84
|
placeholder: string;
|
|
85
|
+
countries: string[];
|
|
86
86
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
87
87
|
declare const _default: typeof __VLS_export;
|
|
88
88
|
export default _default;
|
|
@@ -81,8 +81,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
81
81
|
}>, {
|
|
82
82
|
mode: PlaceTypes;
|
|
83
83
|
disabled: boolean;
|
|
84
|
-
countries: string[];
|
|
85
84
|
placeholder: string;
|
|
85
|
+
countries: string[];
|
|
86
86
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
87
87
|
declare const _default: typeof __VLS_export;
|
|
88
88
|
export default _default;
|
|
@@ -2,7 +2,6 @@ import type { User } from '@auth0/auth0-spa-js';
|
|
|
2
2
|
export declare const useAuth: () => {
|
|
3
3
|
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
4
4
|
isLoading: import("vue").Ref<boolean, boolean>;
|
|
5
|
-
tenant: import("vue").ComputedRef<any>;
|
|
6
5
|
token: import("vue").Ref<string | null, string | null>;
|
|
7
|
-
user: import("vue").Ref<User |
|
|
6
|
+
user: import("vue").Ref<User | undefined, User | undefined>;
|
|
8
7
|
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { useState } from "#imports";
|
|
3
3
|
export const useAuth = () => {
|
|
4
|
-
const user = useState("auth:user", () =>
|
|
4
|
+
const user = useState("auth:user", () => void 0);
|
|
5
5
|
const token = useState("auth:token", () => null);
|
|
6
6
|
const isLoading = useState("auth:loading", () => true);
|
|
7
|
-
const tenant = computed(() => user.value?.org_id);
|
|
8
7
|
const isAuthenticated = computed(() => Boolean(user.value?.sub));
|
|
9
8
|
return {
|
|
10
9
|
isAuthenticated,
|
|
11
10
|
isLoading,
|
|
12
|
-
tenant,
|
|
13
11
|
token,
|
|
14
12
|
user
|
|
15
13
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useState } from "#imports";
|
|
3
|
+
export const useTenant = () => {
|
|
4
|
+
const tenant = useState("tenant:id", () => "");
|
|
5
|
+
const isReady = computed(() => Boolean(tenant.value));
|
|
6
|
+
const setTenant = (value) => tenant.value = value;
|
|
7
|
+
return {
|
|
8
|
+
isReady,
|
|
9
|
+
setTenant,
|
|
10
|
+
tenant
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("
|
|
1
|
+
declare const _default: import("nuxt/app").RouteMiddleware;
|
|
2
2
|
export default _default;
|
|
@@ -46,5 +46,5 @@ export interface ParamsOptions {
|
|
|
46
46
|
export type ApiOptions<TData = unknown, TMeta = Record<string, unknown>, TParams = object> = ParamsOptions & HooksOptions<TData, TMeta, TParams> & RefOptions & {
|
|
47
47
|
params?: TParams;
|
|
48
48
|
};
|
|
49
|
-
declare const _default: import("
|
|
49
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
50
50
|
export default _default;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { defineNuxtPlugin } from "#app";
|
|
2
|
-
import { useAuth } from "#imports";
|
|
2
|
+
import { useAuth, useTenant } from "#imports";
|
|
3
3
|
const GLOBAL_API_HEADER = "x-merkaly-global";
|
|
4
4
|
export default defineNuxtPlugin(({ provide }) => provide("api", async (url, options = {}) => {
|
|
5
|
-
const {
|
|
5
|
+
const { token } = useAuth();
|
|
6
|
+
const { tenant } = useTenant();
|
|
7
|
+
if (!tenant.value && !options.global) {
|
|
8
|
+
throw new Error(`Missing tenant context for: ${url}`);
|
|
9
|
+
}
|
|
6
10
|
await $fetch(url, {
|
|
7
11
|
baseURL: "/api",
|
|
8
12
|
body: options?.body,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare const _default: import("
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<{
|
|
2
2
|
auth0: import("@auth0/auth0-spa-js").Auth0Client;
|
|
3
|
-
}> & import("
|
|
3
|
+
}> & import("nuxt/app").ObjectPlugin<{
|
|
4
4
|
auth0: import("@auth0/auth0-spa-js").Auth0Client;
|
|
5
5
|
}>;
|
|
6
6
|
export default _default;
|
|
@@ -54,7 +54,10 @@ export default defineNuxtPlugin(async ({ callHook, hook }) => {
|
|
|
54
54
|
};
|
|
55
55
|
const isAuthCallback = window.location.pathname === callbackPath;
|
|
56
56
|
if (!isAuthCallback) {
|
|
57
|
-
await Promise.allSettled([auth0.getUser(), auth0.getTokenSilently()]).then(() => hook("app:created",
|
|
57
|
+
await Promise.allSettled([auth0.getUser(), auth0.getTokenSilently()]).then(() => hook("app:created", async () => {
|
|
58
|
+
await callHook("merkaly:tenant", user.value);
|
|
59
|
+
await callHook("merkaly:auth", user.value);
|
|
60
|
+
})).catch(() => void 0);
|
|
58
61
|
}
|
|
59
62
|
isLoading.value = false;
|
|
60
63
|
return { provide: { auth0 } };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { defineNuxtPlugin } from "#app";
|
|
2
2
|
import { setUser } from "@sentry/nuxt";
|
|
3
3
|
export default defineNuxtPlugin(async ({ hook }) => {
|
|
4
|
-
hook("merkaly:auth", (user) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} : null);
|
|
10
|
-
});
|
|
4
|
+
hook("merkaly:auth", (user) => setUser(user ? {
|
|
5
|
+
id: user.sub,
|
|
6
|
+
email: user.email,
|
|
7
|
+
username: user.name
|
|
8
|
+
} : null));
|
|
11
9
|
});
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
+
import type { HookResult } from '@nuxt/schema';
|
|
1
2
|
import type { Auth0Client, User } from '@auth0/auth0-spa-js';
|
|
2
3
|
import type { ApiOptions } from '../plugins/api.global';
|
|
3
4
|
|
|
4
5
|
declare module '#app' {
|
|
5
6
|
interface NuxtApp {
|
|
6
7
|
$auth0: Auth0Client;
|
|
7
|
-
$api: (url: string, options?: ApiOptions) => Promise<
|
|
8
|
+
$api: <T = unknown>(url: string, options?: ApiOptions) => Promise<T>;
|
|
8
9
|
$gmap: never;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
interface RuntimeNuxtHooks {
|
|
12
|
-
'merkaly:auth': (user
|
|
13
|
+
'merkaly:auth': (user?: User) => HookResult;
|
|
14
|
+
'merkaly:tenant': (user?: User) => HookResult;
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
declare module 'vue' {
|
|
17
19
|
interface ComponentCustomProperties {
|
|
18
20
|
$auth0: Auth0Client;
|
|
19
|
-
$api: (url: string, options?: ApiOptions) => Promise<
|
|
21
|
+
$api: <T = unknown>(url: string, options?: ApiOptions) => Promise<T>;
|
|
22
|
+
$gmap: never;
|
|
20
23
|
}
|
|
21
24
|
}
|
|
25
|
+
|
|
26
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkaly/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/merkaly-io/nuxt.git"
|
|
@@ -27,28 +27,18 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "nuxt-module-build build",
|
|
32
|
-
"build:stub": "nuxt-module-build build --stub",
|
|
33
|
-
"lint": "eslint .",
|
|
34
|
-
"prepack": "pnpm build",
|
|
35
|
-
"prepare": "nuxt-module-build prepare",
|
|
36
|
-
"test": "vitest run",
|
|
37
|
-
"test:types": "vue-tsc --noEmit",
|
|
38
|
-
"test:watch": "vitest watch"
|
|
39
|
-
},
|
|
40
30
|
"dependencies": {
|
|
41
|
-
"@auth0/auth0-spa-js": "^2.
|
|
42
|
-
"@bootstrap-vue-next/nuxt": "^0.45.
|
|
43
|
-
"@nuxt/devtools": "^3.2.
|
|
44
|
-
"@nuxt/eslint": "1.
|
|
45
|
-
"@nuxt/eslint-config": "^1.
|
|
31
|
+
"@auth0/auth0-spa-js": "^2.21.1",
|
|
32
|
+
"@bootstrap-vue-next/nuxt": "^0.45.5",
|
|
33
|
+
"@nuxt/devtools": "^3.2.4",
|
|
34
|
+
"@nuxt/eslint": "1.16.0",
|
|
35
|
+
"@nuxt/eslint-config": "^1.16.0",
|
|
46
36
|
"@nuxt/fonts": "0.14.0",
|
|
47
37
|
"@nuxt/image": "^2.0.0",
|
|
48
|
-
"@nuxt/kit": "^4.4.
|
|
38
|
+
"@nuxt/kit": "^4.4.8",
|
|
49
39
|
"@nuxtjs/i18n": "^10.4.0",
|
|
50
|
-
"@nuxtjs/plausible": "^3.0.
|
|
51
|
-
"@sentry/nuxt": "^10.
|
|
40
|
+
"@nuxtjs/plausible": "^3.0.2",
|
|
41
|
+
"@sentry/nuxt": "^10.57.0",
|
|
52
42
|
"@types/node": "latest",
|
|
53
43
|
"@types/vue-select": "^3.16.8",
|
|
54
44
|
"@vueuse/components": "^14.3.0",
|
|
@@ -56,38 +46,45 @@
|
|
|
56
46
|
"@vueuse/integrations": "^14.3.0",
|
|
57
47
|
"@vueuse/nuxt": "^14.3.0",
|
|
58
48
|
"bootstrap": "^5.3.8",
|
|
59
|
-
"bootstrap-vue-next": "^0.45.
|
|
60
|
-
"change-case": "^5",
|
|
49
|
+
"bootstrap-vue-next": "^0.45.5",
|
|
50
|
+
"change-case": "^5.4.4",
|
|
61
51
|
"class-transformer": "^0.5.1",
|
|
62
52
|
"class-validator": "^0.15.1",
|
|
63
|
-
"eslint": "^
|
|
64
|
-
"filesize": "^11.0.
|
|
53
|
+
"eslint": "^10.4.1",
|
|
54
|
+
"filesize": "^11.0.17",
|
|
65
55
|
"gsap": "^3.15.0",
|
|
66
56
|
"notivue": "^2.4.5",
|
|
67
|
-
"nuxt": "^4.4.
|
|
57
|
+
"nuxt": "^4.4.8",
|
|
68
58
|
"reflect-metadata": "^0.2.2",
|
|
69
59
|
"sass": "^1.100.0",
|
|
70
60
|
"typescript": "~5.9.3",
|
|
71
|
-
"v-money3": "^3.26.
|
|
72
|
-
"vite-svg-loader": "^5.1.
|
|
73
|
-
"vue": "^3.5.
|
|
61
|
+
"v-money3": "^3.26.1",
|
|
62
|
+
"vite-svg-loader": "^5.1.1",
|
|
63
|
+
"vue": "^3.5.35",
|
|
74
64
|
"vue-router": "^5.1.0",
|
|
75
65
|
"vue-select": "4.0.0-beta.6"
|
|
76
66
|
},
|
|
77
67
|
"devDependencies": {
|
|
78
68
|
"@nuxt/module-builder": "^1.0.2",
|
|
79
|
-
"@nuxt/schema": "^4.4.
|
|
80
|
-
"@nuxt/test-utils": "^4.0.
|
|
69
|
+
"@nuxt/schema": "^4.4.8",
|
|
70
|
+
"@nuxt/test-utils": "^4.0.3",
|
|
81
71
|
"changelogen": "^0.6.2",
|
|
82
|
-
"eslint-plugin-storybook": "^10.
|
|
83
|
-
"vitest": "^4.1.
|
|
84
|
-
"vue-tsc": "^3.3.
|
|
72
|
+
"eslint-plugin-storybook": "^10.4.3",
|
|
73
|
+
"vitest": "^4.1.8",
|
|
74
|
+
"vue-tsc": "^3.3.4"
|
|
85
75
|
},
|
|
86
76
|
"optionalDependencies": {
|
|
87
|
-
"defu": "^6.1.
|
|
77
|
+
"defu": "^6.1.7"
|
|
88
78
|
},
|
|
89
|
-
"packageManager": "pnpm@10.28.2",
|
|
90
79
|
"engines": {
|
|
91
80
|
"node": ">=24"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "nuxt-module-build build",
|
|
84
|
+
"build:stub": "nuxt-module-build build --stub",
|
|
85
|
+
"lint": "eslint .",
|
|
86
|
+
"test": "vitest run",
|
|
87
|
+
"test:types": "vue-tsc --noEmit",
|
|
88
|
+
"test:watch": "vitest watch"
|
|
92
89
|
}
|
|
93
|
-
}
|
|
90
|
+
}
|