From 92172e724d985cfc1f502d303a91685f83032017 Mon Sep 17 00:00:00 2001 From: Richard C Date: Tue, 3 Jun 2025 18:29:20 +0100 Subject: [PATCH 1/6] feat: ability for alternative auth in useList & useDoc --- src/data-fetching/useDoc/useDoc.ts | 10 ++++++++++ src/data-fetching/useList/types.ts | 2 ++ src/data-fetching/useList/useList.ts | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/src/data-fetching/useDoc/useDoc.ts b/src/data-fetching/useDoc/useDoc.ts index 7139e94cc..2561df447 100644 --- a/src/data-fetching/useDoc/useDoc.ts +++ b/src/data-fetching/useDoc/useDoc.ts @@ -33,6 +33,8 @@ interface UseDocOptions { doctype: string name: MaybeRefOrGetter baseUrl?: string + headers?: Record + credentials?: string methods?: Record immediate?: boolean transform?: (doc: TDoc & { doctype: string }) => TDoc & { doctype: string } @@ -50,6 +52,11 @@ export function useDoc( transform, } = options + const extraFetchOptions = { + ...(options?.headers && { headers: options.headers }), + ...(options?.credentials && { credentials: options.credentials }), + } + const url = computed( () => `${baseUrl}/api/v2/document/${doctype}/${toValue(name)}`, ) @@ -69,6 +76,9 @@ export function useDoc( const fetchOptions: UseFetchOptions = { immediate, refetch: true, + beforeFetch: ({ options }) => { + Object.assign(options, extraFetchOptions) + }, afterFetch(ctx: AfterFetchContext<{ data: TDoc }>) { if (ctx.data) { let doc = { diff --git a/src/data-fetching/useList/types.ts b/src/data-fetching/useList/types.ts index 133c65a60..8e44ddb96 100644 --- a/src/data-fetching/useList/types.ts +++ b/src/data-fetching/useList/types.ts @@ -38,6 +38,8 @@ export interface UseListOptions { immediate?: boolean refetch?: boolean baseUrl?: string + headers?: Record + credentials?: string url?: `/${string}` transform?: (data: T[]) => T[] onSuccess?: (data: T[]) => void diff --git a/src/data-fetching/useList/useList.ts b/src/data-fetching/useList/useList.ts index 90443edff..9c589c0fc 100644 --- a/src/data-fetching/useList/useList.ts +++ b/src/data-fetching/useList/useList.ts @@ -42,6 +42,11 @@ export function useList( transform, } = options + const extraFetchOptions = { + ...(options?.headers && { headers: options.headers }), + ...(options?.credentials && { credentials: options.credentials }), + } + const _start = ref(start || 0) const _limit = ref(limit || 20) @@ -72,6 +77,9 @@ export function useList( immediate, refetch, initialData: initialData || null, + beforeFetch: ({ options }) => { + Object.assign(options, extraFetchOptions) + }, afterFetch: handleAfterFetch({ ...options, allData, From 7e228a76d04216e93dfe4347bcc6428ae9d0bda2 Mon Sep 17 00:00:00 2001 From: Richard C Date: Wed, 9 Jul 2025 23:32:45 +0100 Subject: [PATCH 2/6] fix: URLencode special characters in useDoc request --- src/data-fetching/useDoc/useDoc.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data-fetching/useDoc/useDoc.ts b/src/data-fetching/useDoc/useDoc.ts index 2561df447..0bf21af6f 100644 --- a/src/data-fetching/useDoc/useDoc.ts +++ b/src/data-fetching/useDoc/useDoc.ts @@ -58,7 +58,8 @@ export function useDoc( } const url = computed( - () => `${baseUrl}/api/v2/document/${doctype}/${toValue(name)}`, + () => + `${baseUrl}/api/v2/document/${encodeURIComponent(doctype)}/${encodeURIComponent(toValue(name))}`, ) type SuccessCallback = (doc: TDoc) => void From 31be074b8c44e3030b6715925a7a242e166d5928 Mon Sep 17 00:00:00 2001 From: Richard C Date: Fri, 11 Jul 2025 01:49:26 +0100 Subject: [PATCH 3/6] feat: add support for updating documents using Auth header credentials --- src/data-fetching/useCall/types.ts | 2 ++ src/data-fetching/useCall/useCall.ts | 8 ++++++++ src/data-fetching/useDoc/useDoc.ts | 14 +++++--------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/data-fetching/useCall/types.ts b/src/data-fetching/useCall/types.ts index 7784c3006..862960af3 100644 --- a/src/data-fetching/useCall/types.ts +++ b/src/data-fetching/useCall/types.ts @@ -14,6 +14,8 @@ export interface UseCallOptions< immediate?: boolean refetch?: boolean baseUrl?: string + headers?: Record + credentials?: string initialData?: TResponse beforeSubmit?: (params?: TParams) => void transform?: (data: TResponse) => TResponse diff --git a/src/data-fetching/useCall/useCall.ts b/src/data-fetching/useCall/useCall.ts index d1523622b..329ec561e 100644 --- a/src/data-fetching/useCall/useCall.ts +++ b/src/data-fetching/useCall/useCall.ts @@ -23,6 +23,11 @@ export function useCall( onError, } = options + const extraFetchOptions = { + ...(options?.headers && { headers: options.headers }), + ...(options?.credentials && { credentials: options.credentials }), + } + let submitParams = ref(null) let resolve: (value?: any) => void @@ -63,6 +68,9 @@ export function useCall( immediate, refetch, initialData, + beforeFetch: ({ options }) => { + Object.assign(options, extraFetchOptions) + }, afterFetch(ctx: AfterFetchContext>) { if (ctx.data) { if (transform) { diff --git a/src/data-fetching/useDoc/useDoc.ts b/src/data-fetching/useDoc/useDoc.ts index 0bf21af6f..a0a817197 100644 --- a/src/data-fetching/useDoc/useDoc.ts +++ b/src/data-fetching/useDoc/useDoc.ts @@ -125,11 +125,7 @@ export function useDoc( refetch: false, method: 'POST', ...option, - baseUrl, - url: computed( - () => - `/api/v2/document/${doctype}/${toValue(name)}/method/${option.name}`, - ), + url: computed(() => `${url.value}/method/${option.name}`), } docMethods[key] = readonly(useCall(callOptions)) @@ -137,9 +133,8 @@ export function useDoc( } let setValue = useCall>({ - url: computed(() => `/api/v2/document/${doctype}/${toValue(name)}`), + url, method: 'PUT', - baseUrl, immediate: false, refetch: false, onSuccess(data) { @@ -150,19 +145,20 @@ export function useDoc( docStore.setDoc(docWithType) listStore.updateRow(doctype, data) }, + ...extraFetchOptions, }) type DeleteResponse = 'ok' const delete_ = useCall({ - url: computed(() => `/api/v2/document/${doctype}/${toValue(name)}`), + url, method: 'DELETE', - baseUrl, immediate: false, refetch: false, onSuccess() { docStore.removeDoc(doctype, toValue(name)) listStore.removeRow(doctype, toValue(name)) }, + ...extraFetchOptions, }) const doc = docStore.getDoc(doctype, name) as Ref From b43f2a4a65fc22efa6b75dd20949bf57de855f06 Mon Sep 17 00:00:00 2001 From: Richard C Date: Mon, 20 Oct 2025 20:01:52 +0100 Subject: [PATCH 4/6] fix: pass call options to extra methods --- src/data-fetching/useDoc/useDoc.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data-fetching/useDoc/useDoc.ts b/src/data-fetching/useDoc/useDoc.ts index a0a817197..8c4a44151 100644 --- a/src/data-fetching/useDoc/useDoc.ts +++ b/src/data-fetching/useDoc/useDoc.ts @@ -126,6 +126,7 @@ export function useDoc( method: 'POST', ...option, url: computed(() => `${url.value}/method/${option.name}`), + ...extraFetchOptions, } docMethods[key] = readonly(useCall(callOptions)) From 203e1d52b5a298a98ba1c7bd8c2ffbd61dec37fc Mon Sep 17 00:00:00 2001 From: Richard C Date: Mon, 27 Oct 2025 15:35:09 +0000 Subject: [PATCH 5/6] feat: lazy-load echarts to reduce build size --- components.d.ts | 6 ------ src/components/Charts/ECharts.vue | 10 +++++++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/components.d.ts b/components.d.ts index 4120db006..8782cd628 100644 --- a/components.d.ts +++ b/components.d.ts @@ -47,7 +47,6 @@ declare module 'vue' { CommandPalette: typeof import('./src/components/CommandPalette/CommandPalette.vue')['default'] CommandPaletteItem: typeof import('./src/components/CommandPalette/CommandPaletteItem.vue')['default'] ConfirmDialog: typeof import('./src/components/ConfirmDialog.vue')['default'] - DateMonthYearPicker: typeof import('./src/components/Calendar/DateMonthYearPicker.vue')['default'] DatePicker: typeof import('./src/components/DatePicker/DatePicker.vue')['default'] 'DatePicker.story': typeof import('./src/components/DatePicker/DatePicker.story.vue')['default'] DateRangePicker: typeof import('./src/components/DatePicker/DateRangePicker.vue')['default'] @@ -121,11 +120,6 @@ declare module 'vue' { 'ListView.story': typeof import('./src/components/ListView/ListView.story.vue')['default'] LoadingIndicator: typeof import('./src/components/LoadingIndicator.vue')['default'] LoadingText: typeof import('./src/components/LoadingText.vue')['default'] - LucideCalendar: typeof import('~icons/lucide/calendar')['default'] - LucideCheck: typeof import('~icons/lucide/check')['default'] - LucideChevronDown: typeof import('~icons/lucide/chevron-down')['default'] - LucideChevronRight: typeof import('~icons/lucide/chevron-right')['default'] - LucideX: typeof import('~icons/lucide/x')['default'] MentionList: typeof import('./src/components/TextEditor/MentionList.vue')['default'] Menu: typeof import('./src/components/TextEditor/Menu.vue')['default'] MonthIcon: typeof import('./src/components/Calendar/Icon/MonthIcon.vue')['default'] diff --git a/src/components/Charts/ECharts.vue b/src/components/Charts/ECharts.vue index 6ee66b3b9..e7051ee20 100644 --- a/src/components/Charts/ECharts.vue +++ b/src/components/Charts/ECharts.vue @@ -1,5 +1,5 @@