@quvel-kit/core 1.3.16 → 1.3.17
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/auth/boot/defineAuthGuard.d.ts +2 -7
- package/dist/auth/boot/defineAuthGuard.d.ts.map +1 -1
- package/dist/auth/boot/defineAuthGuard.js +2 -7
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +0 -2
- package/dist/boot/quvel.d.ts.map +1 -1
- package/dist/boot/quvel.js +0 -4
- package/dist/config/quvel.d.ts.map +1 -1
- package/dist/config/quvel.js +1 -2
- package/dist/config/quvel.types.d.ts +0 -10
- package/dist/config/quvel.types.d.ts.map +1 -1
- package/dist/types/app.types.d.ts +0 -11
- package/dist/types/app.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/auth/stores/sessionStore.d.ts +0 -71
- package/dist/auth/stores/sessionStore.d.ts.map +0 -1
- package/dist/auth/stores/sessionStore.js +0 -125
|
@@ -27,19 +27,14 @@ export interface DefineAuthGuardConfig extends AuthGuardConfig {
|
|
|
27
27
|
* @example
|
|
28
28
|
* ```ts
|
|
29
29
|
* import { defineAuthGuard } from '@quvel-kit/core/auth';
|
|
30
|
-
* import { useSessionStore } from '
|
|
30
|
+
* import { useSessionStore } from 'src/stores/sessionStore';
|
|
31
31
|
*
|
|
32
32
|
* export default boot(defineAuthGuard({
|
|
33
33
|
* requireAuthByDefault: true,
|
|
34
34
|
* loginRoute: 'login',
|
|
35
35
|
* successRoute: 'dashboard',
|
|
36
36
|
* isAuthenticated: () => useSessionStore().isAuthenticated,
|
|
37
|
-
* ensureSessionInitialized: async () =>
|
|
38
|
-
* const store = useSessionStore();
|
|
39
|
-
* if (!store.isInitialized) {
|
|
40
|
-
* await store.fetchSession();
|
|
41
|
-
* }
|
|
42
|
-
* },
|
|
37
|
+
* ensureSessionInitialized: async () => await useSessionStore().fetchSession(),
|
|
43
38
|
* }));
|
|
44
39
|
* ```
|
|
45
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineAuthGuard.d.ts","sourceRoot":"","sources":["../../../src/auth/boot/defineAuthGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D;;;OAGG;IACH,eAAe,EAAE,MAAM,OAAO,CAAC;IAE/B;;;OAGG;IACH,wBAAwB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED
|
|
1
|
+
{"version":3,"file":"defineAuthGuard.d.ts","sourceRoot":"","sources":["../../../src/auth/boot/defineAuthGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D;;;OAGG;IACH,eAAe,EAAE,MAAM,OAAO,CAAC;IAE/B;;;OAGG;IACH,wBAAwB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,IAC7C,+BAA+B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC5D,mBAyDF"}
|
|
@@ -11,19 +11,14 @@ import { AuthGuard } from '../services/AuthGuard.js';
|
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
13
|
* import { defineAuthGuard } from '@quvel-kit/core/auth';
|
|
14
|
-
* import { useSessionStore } from '
|
|
14
|
+
* import { useSessionStore } from 'src/stores/sessionStore';
|
|
15
15
|
*
|
|
16
16
|
* export default boot(defineAuthGuard({
|
|
17
17
|
* requireAuthByDefault: true,
|
|
18
18
|
* loginRoute: 'login',
|
|
19
19
|
* successRoute: 'dashboard',
|
|
20
20
|
* isAuthenticated: () => useSessionStore().isAuthenticated,
|
|
21
|
-
* ensureSessionInitialized: async () =>
|
|
22
|
-
* const store = useSessionStore();
|
|
23
|
-
* if (!store.isInitialized) {
|
|
24
|
-
* await store.fetchSession();
|
|
25
|
-
* }
|
|
26
|
-
* },
|
|
21
|
+
* ensureSessionInitialized: async () => await useSessionStore().fetchSession(),
|
|
27
22
|
* }));
|
|
28
23
|
* ```
|
|
29
24
|
*/
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -10,5 +10,4 @@ export type { DefineAuthGuardConfig } from './boot/defineAuthGuard.js';
|
|
|
10
10
|
export type { AuthMeta } from './types/index.js';
|
|
11
11
|
export { createAuthMeta, createGuestOnlyAuth, createProtectedAuth, createPublicAuth, createSkipAuth, } from './utils/auth-meta.js';
|
|
12
12
|
export { AuthStatus } from './enums/AuthStatusEnum.js';
|
|
13
|
-
export { useSessionStore } from './stores/sessionStore.js';
|
|
14
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,yBAAyB,EACzB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGvE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,yBAAyB,EACzB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGvE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/auth/index.js
CHANGED
|
@@ -11,5 +11,3 @@ export { defineAuthGuard } from './boot/defineAuthGuard.js';
|
|
|
11
11
|
export { createAuthMeta, createGuestOnlyAuth, createProtectedAuth, createPublicAuth, createSkipAuth, } from './utils/auth-meta.js';
|
|
12
12
|
// Enums
|
|
13
13
|
export { AuthStatus } from './enums/AuthStatusEnum.js';
|
|
14
|
-
// Stores
|
|
15
|
-
export { useSessionStore } from './stores/sessionStore.js';
|
package/dist/boot/quvel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quvel.d.ts","sourceRoot":"","sources":["../../src/boot/quvel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,IAC9C,qBAAqB;IAC3B,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;CACV,
|
|
1
|
+
{"version":3,"file":"quvel.d.ts","sourceRoot":"","sources":["../../src/boot/quvel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,IAC9C,qBAAqB;IAC3B,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;CACV,UAoBF"}
|
package/dist/boot/quvel.js
CHANGED
|
@@ -25,10 +25,6 @@ export function defineQuvelBoot(quvelConfig) {
|
|
|
25
25
|
serviceMap.set(name, ServiceCls);
|
|
26
26
|
}
|
|
27
27
|
const container = createContainer(ssrContext, serviceMap);
|
|
28
|
-
// Apply config from QuvelConfig
|
|
29
|
-
if (quvelConfig.userFactory) {
|
|
30
|
-
container.config.userFactory = quvelConfig.userFactory;
|
|
31
|
-
}
|
|
32
28
|
if (ssrContext) {
|
|
33
29
|
ssrContext.$quvel = container;
|
|
34
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quvel.d.ts","sourceRoot":"","sources":["../../src/config/quvel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAItE,OAAO,EAAqB,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAI7F;;GAEG;AACH,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAErF;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"quvel.d.ts","sourceRoot":"","sources":["../../src/config/quvel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAItE,OAAO,EAAqB,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAI7F;;GAEG;AACH,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAErF;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW,CA4CvE"}
|
package/dist/config/quvel.js
CHANGED
|
@@ -36,7 +36,7 @@ export { DEFAULT_LOCALE_MAPPING };
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export function defineQuvelConfig(config) {
|
|
39
|
-
const { modules = [], localeMapping, core = true,
|
|
39
|
+
const { modules = [], localeMapping, core = true, } = config;
|
|
40
40
|
const allModules = [];
|
|
41
41
|
if (core) {
|
|
42
42
|
const coreOptions = typeof core === 'object' ? core : {};
|
|
@@ -55,7 +55,6 @@ export function defineQuvelConfig(config) {
|
|
|
55
55
|
modules: allModules,
|
|
56
56
|
messages,
|
|
57
57
|
localeMapping: resolvedLocaleMapping,
|
|
58
|
-
userFactory,
|
|
59
58
|
getRoutes() {
|
|
60
59
|
return getRoutes(allModules);
|
|
61
60
|
},
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { RouteRecordRaw } from 'vue-router';
|
|
7
7
|
import type { Module, ServiceRegistry } from '../modules/types.js';
|
|
8
|
-
import type { UserFactory } from '../types/user.types.js';
|
|
9
8
|
/**
|
|
10
9
|
* Locale mapping configuration for validation
|
|
11
10
|
* Maps i18n locale codes to Zod locale codes
|
|
@@ -39,11 +38,6 @@ export interface QuvelConfigInput {
|
|
|
39
38
|
*/
|
|
40
39
|
includeI18n?: boolean;
|
|
41
40
|
};
|
|
42
|
-
/**
|
|
43
|
-
* User factory function for creating user instances
|
|
44
|
-
* Override to use a custom user model
|
|
45
|
-
*/
|
|
46
|
-
userFactory?: UserFactory;
|
|
47
41
|
}
|
|
48
42
|
/**
|
|
49
43
|
* Resolved Quvel configuration
|
|
@@ -62,10 +56,6 @@ export interface QuvelConfig {
|
|
|
62
56
|
* Locale mapping for validation
|
|
63
57
|
*/
|
|
64
58
|
localeMapping: LocaleMapping;
|
|
65
|
-
/**
|
|
66
|
-
* User factory function for creating user instances
|
|
67
|
-
*/
|
|
68
|
-
userFactory?: UserFactory;
|
|
69
59
|
/**
|
|
70
60
|
* Get all routes from modules
|
|
71
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quvel.types.d.ts","sourceRoot":"","sources":["../../src/config/quvel.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"quvel.types.d.ts","sourceRoot":"","sources":["../../src/config/quvel.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG;QACf;;;WAGG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAElD;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACH,SAAS,IAAI,cAAc,EAAE,CAAC;IAE9B;;OAEG;IACH,WAAW,IAAI,eAAe,CAAC;IAE/B;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1D"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Dynamic server-side configuration for the Quasar app
|
|
5
5
|
*/
|
|
6
|
-
import type { UserFactory } from './user.types';
|
|
7
6
|
import type { TraceInfo } from './logging.types';
|
|
8
7
|
/**
|
|
9
8
|
* CSS asset configuration for dynamic injection
|
|
@@ -179,16 +178,6 @@ export interface AppConfig {
|
|
|
179
178
|
* Defaults to 'user-locale' if not specified
|
|
180
179
|
*/
|
|
181
180
|
i18nCookie?: string;
|
|
182
|
-
/**
|
|
183
|
-
* User factory function for creating user instances
|
|
184
|
-
*
|
|
185
|
-
* Override this to use a custom user model:
|
|
186
|
-
* @example
|
|
187
|
-
* ```typescript
|
|
188
|
-
* userFactory: (data) => new CustomUser(data)
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
userFactory?: UserFactory;
|
|
192
181
|
/**
|
|
193
182
|
* Trace information for request/response tracking
|
|
194
183
|
* Populated by SSRTraceService and tenant resolution hooks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.types.d.ts","sourceRoot":"","sources":["../../src/types/app.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"app.types.d.ts","sourceRoot":"","sources":["../../src/types/app.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;IAC9C,QAAQ,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS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E;QACR,gCAAgC;QAChC,GAAG,EAAE,MAAM,CAAC;QACZ,mEAAmE;QACnE,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IAEF;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;OAEG;IACH,GAAG,CAAC,EAAE,YAAY,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAElC;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { IUser, QuvelTypes } from '@quvel-kit/core';
|
|
2
|
-
/**
|
|
3
|
-
* Type for the authenticated user.
|
|
4
|
-
* Uses QuvelTypes['User'] which can be augmented by consuming applications.
|
|
5
|
-
*/
|
|
6
|
-
type StateUser = QuvelTypes['User'] | null;
|
|
7
|
-
/**
|
|
8
|
-
* Interface defining the structure of the session state.
|
|
9
|
-
*/
|
|
10
|
-
interface SessionState {
|
|
11
|
-
user: StateUser;
|
|
12
|
-
initialized: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Interface defining getters for the session store.
|
|
16
|
-
*/
|
|
17
|
-
type SessionGetters = {
|
|
18
|
-
isAuthenticated: (state: SessionState) => boolean;
|
|
19
|
-
isInitialized: (state: SessionState) => boolean;
|
|
20
|
-
getUser: (state: SessionState) => StateUser;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Interface defining actions for the session store.
|
|
24
|
-
*/
|
|
25
|
-
interface SessionActions {
|
|
26
|
-
setSession(data: IUser): void;
|
|
27
|
-
clearSession(): void;
|
|
28
|
-
markInitialized(): void;
|
|
29
|
-
fetchSession(): Promise<void>;
|
|
30
|
-
getUserFactory(): (data: IUser) => QuvelTypes['User'];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Pinia store for managing user session state.
|
|
34
|
-
*
|
|
35
|
-
* This is a generic session store that can be extended with auth-specific
|
|
36
|
-
* actions (login, signup, etc.) in your application.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* // Use in a component
|
|
41
|
-
* const session = useSessionStore();
|
|
42
|
-
*
|
|
43
|
-
* // Check auth status
|
|
44
|
-
* if (session.isAuthenticated) {
|
|
45
|
-
* console.log(session.user?.name);
|
|
46
|
-
* }
|
|
47
|
-
*
|
|
48
|
-
* // Set session (typically after login)
|
|
49
|
-
* session.setSession(userData);
|
|
50
|
-
*
|
|
51
|
-
* // Clear session (typically after logout)
|
|
52
|
-
* session.clearSession();
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* // Extend with custom actions
|
|
58
|
-
* export const useAuthStore = defineStore('auth', {
|
|
59
|
-
* ...useSessionStore(),
|
|
60
|
-
* actions: {
|
|
61
|
-
* async login(email: string, password: string) {
|
|
62
|
-
* const response = await authService.login(email, password);
|
|
63
|
-
* this.setSession(response.user);
|
|
64
|
-
* }
|
|
65
|
-
* }
|
|
66
|
-
* });
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
export declare const useSessionStore: import("pinia").StoreDefinition<"session", SessionState, SessionGetters, SessionActions>;
|
|
70
|
-
export {};
|
|
71
|
-
//# sourceMappingURL=sessionStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessionStore.d.ts","sourceRoot":"","sources":["../../../src/auth/stores/sessionStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGzD;;;GAGG;AACH,KAAK,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAE3C;;GAEG;AACH,UAAU,YAAY;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,KAAK,cAAc,GAAG;IACpB,eAAe,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;IAClD,aAAa,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;IAChD,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,SAAS,CAAC;CAC7C,CAAC;AAEF;;GAEG;AACH,UAAU,cAAc;IACtB,UAAU,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IAC9B,YAAY,IAAI,IAAI,CAAC;IACrB,eAAe,IAAI,IAAI,CAAC;IACxB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,cAAc,IAAI,CAAC,IAAI,EAAE,KAAK,KAAK,UAAU,CAAC,MAAM,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,eAAe,0FAiG1B,CAAC"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { acceptHMRUpdate, defineStore } from 'pinia';
|
|
2
|
-
import { AuthService } from '../services/AuthService.js';
|
|
3
|
-
/**
|
|
4
|
-
* Pinia store for managing user session state.
|
|
5
|
-
*
|
|
6
|
-
* This is a generic session store that can be extended with auth-specific
|
|
7
|
-
* actions (login, signup, etc.) in your application.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // Use in a component
|
|
12
|
-
* const session = useSessionStore();
|
|
13
|
-
*
|
|
14
|
-
* // Check auth status
|
|
15
|
-
* if (session.isAuthenticated) {
|
|
16
|
-
* console.log(session.user?.name);
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* // Set session (typically after login)
|
|
20
|
-
* session.setSession(userData);
|
|
21
|
-
*
|
|
22
|
-
* // Clear session (typically after logout)
|
|
23
|
-
* session.clearSession();
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* // Extend with custom actions
|
|
29
|
-
* export const useAuthStore = defineStore('auth', {
|
|
30
|
-
* ...useSessionStore(),
|
|
31
|
-
* actions: {
|
|
32
|
-
* async login(email: string, password: string) {
|
|
33
|
-
* const response = await authService.login(email, password);
|
|
34
|
-
* this.setSession(response.user);
|
|
35
|
-
* }
|
|
36
|
-
* }
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export const useSessionStore = defineStore('session', {
|
|
41
|
-
state: () => ({
|
|
42
|
-
user: null,
|
|
43
|
-
initialized: false,
|
|
44
|
-
}),
|
|
45
|
-
getters: {
|
|
46
|
-
/**
|
|
47
|
-
* Determines if a user is authenticated.
|
|
48
|
-
*/
|
|
49
|
-
isAuthenticated: (state) => state.user !== null && state.user !== undefined,
|
|
50
|
-
/**
|
|
51
|
-
* Determines if the session store has been initialized.
|
|
52
|
-
*/
|
|
53
|
-
isInitialized: (state) => state.initialized,
|
|
54
|
-
/**
|
|
55
|
-
* Retrieves the authenticated user.
|
|
56
|
-
*/
|
|
57
|
-
getUser: (state) => state.user,
|
|
58
|
-
},
|
|
59
|
-
actions: {
|
|
60
|
-
/**
|
|
61
|
-
* Gets the user factory function from config or returns default.
|
|
62
|
-
* This allows users to provide custom user models.
|
|
63
|
-
*/
|
|
64
|
-
getUserFactory() {
|
|
65
|
-
// Default factory just returns the data as-is (IUser compatible)
|
|
66
|
-
const defaultFactory = (data) => data;
|
|
67
|
-
try {
|
|
68
|
-
return this.$quvel.config.userFactory || defaultFactory;
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return defaultFactory;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* Sets the user session using the configured user factory.
|
|
76
|
-
*
|
|
77
|
-
* @param data - Raw user data from API
|
|
78
|
-
*/
|
|
79
|
-
setSession(data) {
|
|
80
|
-
const factory = this.getUserFactory();
|
|
81
|
-
this.user = factory(data);
|
|
82
|
-
this.initialized = true;
|
|
83
|
-
this.$quvel.api.markSessionExists();
|
|
84
|
-
},
|
|
85
|
-
/**
|
|
86
|
-
* Clears the user session.
|
|
87
|
-
*/
|
|
88
|
-
clearSession() {
|
|
89
|
-
this.user = null;
|
|
90
|
-
this.$quvel.api.markSessionCleared();
|
|
91
|
-
},
|
|
92
|
-
/**
|
|
93
|
-
* Marks the session store as initialized without setting a user.
|
|
94
|
-
* Used when a session check is complete but no user is authenticated.
|
|
95
|
-
*/
|
|
96
|
-
markInitialized() {
|
|
97
|
-
this.initialized = true;
|
|
98
|
-
},
|
|
99
|
-
/**
|
|
100
|
-
* Fetches the current session from the API using AuthService.
|
|
101
|
-
* Sets the session if a user is authenticated, otherwise marks as initialized.
|
|
102
|
-
*/
|
|
103
|
-
async fetchSession() {
|
|
104
|
-
if (this.initialized) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
const userData = await this.$quvel.get(AuthService).fetchSession();
|
|
109
|
-
if (userData) {
|
|
110
|
-
this.setSession(userData);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.markInitialized();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
this.markInitialized();
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
if (import.meta.hot) {
|
|
124
|
-
import.meta.hot.accept(acceptHMRUpdate(useSessionStore, import.meta.hot));
|
|
125
|
-
}
|