@data-fair/lib-vue 1.2.1 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vue",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Composables and other utilities for Vue applications in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -105,7 +105,7 @@ export const useBooleanSearchParam = (key, options = {}) => {
105
105
  const defaultValue = typeof options === 'boolean' ? options : (options.default ?? false)
106
106
  const strings = (typeof options !== 'boolean' && options.strings) || ['1', '0']
107
107
  return computed({
108
- get: () => key in reactiveSearchParams ? reactiveSearchParams[key] === strings[0] : defaultValue,
108
+ get: () => key in reactiveSearchParams ? (reactiveSearchParams[key] === strings[0] || reactiveSearchParams[key] === 'true') : defaultValue,
109
109
  set: (value) => {
110
110
  if (value === defaultValue) { delete reactiveSearchParams[key] } else { reactiveSearchParams[key] = value ? strings[0] : strings[1] }
111
111
  }
package/session.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type IncomingMessage } from 'node:http';
2
- import { type Ref, App } from 'vue';
2
+ import { type Ref, type ComputedRef, type App } from 'vue';
3
3
  import { type RouteLocation } from 'vue-router';
4
4
  import { type fetch } from 'ofetch';
5
5
  import { type SessionState, type SessionStateAuthenticated } from '@data-fair/lib-common-types/session/index.js';
@@ -20,6 +20,12 @@ export interface SessionOptions {
20
20
  }
21
21
  export interface Session {
22
22
  state: SessionState;
23
+ user: ComputedRef<SessionState['user']>;
24
+ organization: ComputedRef<SessionState['organization']>;
25
+ account: ComputedRef<SessionState['account']>;
26
+ accountRole: ComputedRef<SessionState['accountRole']>;
27
+ lang: ComputedRef<SessionState['lang']>;
28
+ dark: ComputedRef<SessionState['dark']>;
23
29
  loginUrl: (redirect?: string, extraParams?: Record<string, string>, immediateRedirect?: true) => string;
24
30
  login: (redirect?: string, extraParams?: Record<string, string>, immediateRedirect?: true) => void;
25
31
  logout: (redirect?: string) => Promise<void>;
@@ -41,6 +47,12 @@ export declare const sessionKey: unique symbol;
41
47
  export declare function createSession(initOptions: Partial<SessionOptions>): Promise<{
42
48
  install(app: App): void;
43
49
  state: SessionState;
50
+ user: ComputedRef<SessionState["user"]>;
51
+ organization: ComputedRef<SessionState["organization"]>;
52
+ account: ComputedRef<SessionState["account"]>;
53
+ accountRole: ComputedRef<SessionState["accountRole"]>;
54
+ lang: ComputedRef<SessionState["lang"]>;
55
+ dark: ComputedRef<SessionState["dark"]>;
44
56
  loginUrl: (redirect?: string, extraParams?: Record<string, string>, immediateRedirect?: true) => string;
45
57
  login: (redirect?: string, extraParams?: Record<string, string>, immediateRedirect?: true) => void;
46
58
  logout: (redirect?: string) => Promise<void>;
package/session.js CHANGED
@@ -218,6 +218,12 @@ export async function getSession (initOptions) {
218
218
  }
219
219
  const session = {
220
220
  state,
221
+ organization: computed(() => state.organization),
222
+ user: computed(() => state.user),
223
+ account: computed(() => state.account),
224
+ accountRole: computed(() => state.accountRole),
225
+ dark: computed(() => state.dark),
226
+ lang: computed(() => state.lang),
221
227
  loginUrl,
222
228
  login,
223
229
  logout,