@vesperjs/nuxt 0.1.3 → 0.1.5
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/app/composables/backend/api/create-fetch.ts +1 -1
- package/app/composables/backend/api/create-request-fetch.ts +1 -1
- package/app/composables/backend/api/use-api-constants.ts +1 -1
- package/app/composables/backend/api/use-http-headers.ts +1 -1
- package/app/composables/backend/api/use-mutation-api.ts +2 -2
- package/app/composables/backend/api/use-ofetch.ts +2 -2
- package/app/composables/backend/api/use-query-api.ts +4 -1
- package/app/composables/backend/error/use-backend-error-info.ts +1 -1
- package/app/composables/backend/error/use-external-errors.ts +1 -1
- package/app/composables/backend/use-alert.ts +1 -1
- package/app/composables/use-datetime-local.ts +1 -1
- package/app/composables/use-entity.ts +2 -2
- package/app/composables/use-flash.ts +1 -1
- package/app/composables/use-locale.ts +1 -1
- package/app/composables/use-more-scroll.ts +1 -1
- package/app/composables/use-referer.ts +1 -1
- package/app/composables/use-time-zone.ts +1 -1
- package/app/composables/util/use-date.ts +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { useRuntimeConfig } from 'nuxt/app'
|
|
|
2
2
|
|
|
3
3
|
import { computed } from '@vue/reactivity'
|
|
4
4
|
|
|
5
|
-
export const useApiConstants = ()
|
|
5
|
+
export const useApiConstants = function () {
|
|
6
6
|
const runtimeConfig = useRuntimeConfig()
|
|
7
7
|
|
|
8
8
|
const baseOrigin = computed<string | undefined>(() => {
|
|
@@ -3,7 +3,7 @@ import { computed, type Ref } from '@vue/reactivity'
|
|
|
3
3
|
import { useLocale } from '../../use-locale'
|
|
4
4
|
import { useTimeZone } from '../../use-time-zone'
|
|
5
5
|
|
|
6
|
-
export const useHttpHeaders = ()
|
|
6
|
+
export const useHttpHeaders = function () {
|
|
7
7
|
const { locale } = useLocale()
|
|
8
8
|
const { timeZone } = useTimeZone()
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ interface MutationAPIOptions {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// eslint-disable-next-line
|
|
18
|
-
export const useMutationApi = async <T = unknown, E = any>(
|
|
18
|
+
export const useMutationApi = async function <T = unknown, E = any>(
|
|
19
19
|
url: string,
|
|
20
20
|
{ method, body = {}, token = null, onRequestError, onResponseError }: MutationAPIOptions,
|
|
21
21
|
): Promise<{
|
|
@@ -23,7 +23,7 @@ export const useMutationApi = async <T = unknown, E = any>(
|
|
|
23
23
|
data: T | undefined
|
|
24
24
|
error: FetchError<E> | undefined
|
|
25
25
|
pending: boolean
|
|
26
|
-
}>
|
|
26
|
+
}> {
|
|
27
27
|
const { commonHeaders } = useHttpHeaders()
|
|
28
28
|
const { baseURL } = useApiConstants()
|
|
29
29
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { $Fetch, FetchOptions, FetchError } from 'ofetch'
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line
|
|
4
|
-
export const useOFetch = async <T = unknown, E = any>(
|
|
4
|
+
export const useOFetch = async function <T = unknown, E = any>(
|
|
5
5
|
url: string,
|
|
6
6
|
options?: FetchOptions<'json'>,
|
|
7
|
-
)
|
|
7
|
+
) {
|
|
8
8
|
const { $api } = useNuxtApp()
|
|
9
9
|
|
|
10
10
|
const pending = ref<boolean>(true)
|
|
@@ -26,7 +26,10 @@ export type QueryAPIOptions = {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
export const useQueryApi = async <T = unknown, E = any>(
|
|
29
|
+
export const useQueryApi = async function <T = unknown, E = any>(
|
|
30
|
+
url: string,
|
|
31
|
+
options?: QueryAPIOptions,
|
|
32
|
+
) {
|
|
30
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
34
|
const { $api } = useNuxtApp() as any
|
|
32
35
|
const { commonHeaders } = useHttpHeaders()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BackendErrorInfo } from '../../../../interfaces'
|
|
2
2
|
|
|
3
|
-
export function
|
|
3
|
+
export const useBackendErrorInfo = function <R extends object>() {
|
|
4
4
|
const info = ref<BackendErrorInfo<R>>({})
|
|
5
5
|
|
|
6
6
|
const backendErrorInfo = computed<BackendErrorInfo<R>>(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Flash } from '../../../../interfaces'
|
|
2
2
|
import type { ErrorMessages } from '../../../../types'
|
|
3
3
|
|
|
4
|
-
export function
|
|
4
|
+
export const useExternalErrors = function <P extends string>({ flash }: { flash: Ref<Flash> }) {
|
|
5
5
|
const errors = ref<ErrorMessages<P>>({})
|
|
6
6
|
|
|
7
7
|
const externalErrors = computed<ErrorMessages<P>>({
|
|
@@ -25,7 +25,7 @@ interface UseAlertCallerType {
|
|
|
25
25
|
clearAccount?: () => void
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function
|
|
28
|
+
export const useAlert = function <BER extends object = BackendErrorResource>({
|
|
29
29
|
flash,
|
|
30
30
|
caller,
|
|
31
31
|
}: UseAlertOptions): {
|
|
@@ -2,7 +2,7 @@ import { parse, format } from '@formkit/tempo'
|
|
|
2
2
|
|
|
3
3
|
import { useLocale } from './use-locale'
|
|
4
4
|
|
|
5
|
-
export const useDatetimeLocal = ()
|
|
5
|
+
export const useDatetimeLocal = function () {
|
|
6
6
|
const { locale } = useLocale()
|
|
7
7
|
|
|
8
8
|
const parseDT = (datetime: string, format: string): Date => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function
|
|
2
|
-
const create = ({ from }: { from: R }): M => {
|
|
1
|
+
export const useEntity = function <M extends object, R extends object = M>() {
|
|
2
|
+
const create = ({ from }: { from: R | M }): M => {
|
|
3
3
|
const model: Partial<M> = {}
|
|
4
4
|
Object.assign(model, from)
|
|
5
5
|
return model as M
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useNuxtApp } from 'nuxt/app'
|
|
2
2
|
import { useBrowserLocale } from '#i18n'
|
|
3
3
|
|
|
4
|
-
export const useLocale = ()
|
|
4
|
+
export const useLocale = function () {
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
6
|
const { $i18n } = useNuxtApp() as any
|
|
7
7
|
const { locale, availableLocales, fallbackLocale } = $i18n
|
|
@@ -17,7 +17,7 @@ interface TZOptions {
|
|
|
17
17
|
value: string
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const useTimeZone = ()
|
|
20
|
+
export const useTimeZone = function () {
|
|
21
21
|
const runtimeConfig = useRuntimeConfig()
|
|
22
22
|
const { locale } = useLocale()
|
|
23
23
|
const { toISO8601, formatHTML } = useDatetimeLocal()
|