From 772c572c952d2e2bbf60abc855fec28e407023e3 Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Sat, 4 Jan 2025 14:56:06 +0100 Subject: [PATCH] fml --- packages/vue/src/makeClient.ts | 49 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/packages/vue/src/makeClient.ts b/packages/vue/src/makeClient.ts index cd155a675..77e4b890e 100644 --- a/packages/vue/src/makeClient.ts +++ b/packages/vue/src/makeClient.ts @@ -196,9 +196,10 @@ export const makeClient = ( runtime: ShallowRef | undefined>, messages: Record = {} ) => { - const useSafeMutation = makeMutation() - const useSafeQuery = makeQuery(runtime) - const useHandleRequestWithToast = () => { + // making sure names do not collide with auto exports in nuxt apps, please do not rename.. + const _useSafeMutation = makeMutation() + const _useSafeQuery = makeQuery(runtime) + const _useHandleRequestWithToast = () => { const toast = useToast() const { intl } = useIntl() @@ -345,7 +346,7 @@ export const makeClient = ( * Pass a function that returns an Effect, e.g from a client action, give it a name. * Returns a tuple with state ref and execution function which reports success and errors as Toast. */ - const useAndHandleMutation: { + const _useAndHandleMutation: { < I, E extends ResponseErrors, @@ -390,8 +391,8 @@ export const makeClient = ( action: any, options?: Opts ): any => { - const handleRequestWithToast = useHandleRequestWithToast() - const [a, b] = useSafeMutation({ + const handleRequestWithToast = _useHandleRequestWithToast() + const [a, b] = _useSafeMutation({ ...self, handler: Effect.isEffect(self.handler) ? (pipe( @@ -415,7 +416,7 @@ export const makeClient = ( * The same as @see useAndHandleMutation, but does not display any toasts by default. * Messages for success, error and defect toasts can be provided in the Options. */ - const useAndHandleMutationSilently: { + const _useAndHandleMutationSilently: { < I, E extends ResponseErrors, @@ -455,7 +456,7 @@ export const makeClient = ( action: string, options?: Opts ): ActResp - } = makeUseAndHandleMutation({ + } = _makeUseAndHandleMutation({ successMessage: suppressToast, failMessage: suppressToast, defectMessage: suppressToast @@ -465,7 +466,7 @@ export const makeClient = ( * The same as @see useAndHandleMutation, but does not act on success, error or defect by default. * Actions for success, error and defect can be provided in the Options. */ - const useAndHandleMutationCustom: { + const _useAndHandleMutationCustom: { < I, E extends ResponseErrors, @@ -506,7 +507,7 @@ export const makeClient = ( options?: LowOptsOptional ): ActResp } = (self: any, action: string, options: any) => { - const [a, b] = useSafeMutation({ + const [a, b] = _useSafeMutation({ ...self, handler: Effect.isEffect(self.handler) ? (pipe( @@ -531,11 +532,11 @@ export const makeClient = ( ) as any } - function makeUseAndHandleMutation( + function _makeUseAndHandleMutation( defaultOptions?: Opts ) { return ((self: any, action: any, options: any) => { - return useAndHandleMutation( + return _useAndHandleMutation( self, action, { ...defaultOptions, ...options } @@ -582,10 +583,10 @@ export const makeClient = ( } } - const useSafeMutationWithState = ( + const _useSafeMutationWithState = ( self: RequestHandlerWithInput ) => { - const [a, b] = useSafeMutation(self) + const [a, b] = _useSafeMutation(self) return tuple( computed(() => mutationResultToVue(a.value)), @@ -593,7 +594,7 @@ export const makeClient = ( ) } - const buildFormFromSchema = < + const _buildFormFromSchema = < From extends Record, To extends Record, C extends Record, @@ -650,14 +651,14 @@ export const makeClient = ( } return { - useSafeMutationWithState, - useAndHandleMutation, - useAndHandleMutationSilently, - useAndHandleMutationCustom, - makeUseAndHandleMutation, - useHandleRequestWithToast, - buildFormFromSchema, - useSafeQuery, - useSafeMutation + useSafeMutationWithState: _useSafeMutationWithState, + useAndHandleMutation: _useAndHandleMutation, + useAndHandleMutationSilently: _useAndHandleMutationSilently, + useAndHandleMutationCustom: _useAndHandleMutationCustom, + makeUseAndHandleMutation: _makeUseAndHandleMutation, + useHandleRequestWithToast: _useHandleRequestWithToast, + buildFormFromSchema: _buildFormFromSchema, + useSafeQuery: _useSafeQuery, + useSafeMutation: _useSafeMutation } }