@vesperjs/nuxt 0.1.8 → 0.2.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.
@@ -1,2 +1 @@
1
- export { useExternalErrors } from './use-external-errors'
2
- export { useBackendErrorInfo } from './use-backend-error-info'
1
+ export { useExternalErrors, useBackendErrorInfo } from '@vesperjs/shared'
@@ -10,8 +10,8 @@ import type {
10
10
  BackendErrorInfo,
11
11
  BackendErrorResource,
12
12
  Flash,
13
- } from '../../../interfaces'
14
- import type { ErrorMessages } from '../../../types'
13
+ ErrorMessages,
14
+ } from '../../../types'
15
15
 
16
16
  import { useBackendErrorInfo } from './error'
17
17
 
@@ -1,3 +1,5 @@
1
+ export { useEntity, useFlash } from '@vesperjs/shared'
2
+
1
3
  export type { QueryAPIOptions } from './backend'
2
4
 
3
5
  export { createFetch, createRequestFetch, useOFetch, useMutationApi, useQueryApi } from './backend'
@@ -1 +1 @@
1
- export { useDate } from './use-date'
1
+ export { useDate } from '@vesperjs/shared'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesperjs/nuxt",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "keywords": [
5
5
  "nuxt",
6
6
  "vue.js"
@@ -13,7 +13,6 @@
13
13
  },
14
14
  "files": [
15
15
  "app",
16
- "interfaces",
17
16
  "types",
18
17
  "nuxt.config.ts",
19
18
  "app.config.ts"
@@ -24,11 +23,12 @@
24
23
  "@formkit/tempo": "^1.0.0",
25
24
  "@nuxt/eslint": "latest",
26
25
  "@nuxtjs/i18n": "^10.2.4",
27
- "@types/node": "^24.11.0",
28
- "eslint": "^9.39.3",
26
+ "@types/node": "^24.12.2",
27
+ "@vesperjs/shared": "0.2.0",
28
+ "eslint": "^9.39.4",
29
29
  "nuxt": "^4.3.1",
30
30
  "ofetch": "^1.5.1",
31
- "oxfmt": "^0.42.0",
31
+ "oxfmt": "^0.43.0",
32
32
  "typescript": "^5.9.3",
33
33
  "vue": "^3.6.0-beta.9"
34
34
  },
package/types/index.ts CHANGED
@@ -1 +1,4 @@
1
- export type { ErrorMessages } from './error-messages'
1
+ export type { BackendErrorInfo } from '@vesperjs/shared'
2
+ export type { BackendErrorResource, ErrorsResource } from '@vesperjs/shared'
3
+ export type { Flash } from '@vesperjs/shared'
4
+ export type { ErrorMessages } from '@vesperjs/shared'
@@ -1,15 +0,0 @@
1
- import type { BackendErrorInfo } from '../../../../interfaces'
2
-
3
- export const useBackendErrorInfo = function <R extends object>() {
4
- const info = ref<BackendErrorInfo<R>>({})
5
-
6
- const backendErrorInfo = computed<BackendErrorInfo<R>>(() => {
7
- return info.value as BackendErrorInfo<R>
8
- })
9
-
10
- const clearBackendErrorInfo = (): void => {
11
- info.value = {}
12
- }
13
-
14
- return { backendErrorInfo, clearBackendErrorInfo }
15
- }
@@ -1,42 +0,0 @@
1
- import type { Flash } from '../../../../interfaces'
2
- import type { ErrorMessages } from '../../../../types'
3
-
4
- export const useExternalErrors = function <P extends string>({ flash }: { flash: Ref<Flash> }) {
5
- const errors = ref<ErrorMessages<P>>({})
6
-
7
- const externalErrors = computed<ErrorMessages<P>>({
8
- get() {
9
- return errors.value as ErrorMessages<string>
10
- },
11
- set(value: ErrorMessages<P>) {
12
- if (errors.value) {
13
- for (const key in value) {
14
- ;(errors.value as ErrorMessages<P>)[key] = value[key] ?? []
15
- }
16
- }
17
- },
18
- })
19
-
20
- const clearExternalErrors = (): void => {
21
- externalErrors.value = {}
22
- }
23
-
24
- const isSuccess = (): boolean => {
25
- let result = true
26
-
27
- for (const key in errors.value) {
28
- const error = errors.value as ErrorMessages<string>
29
- if ((error[key] as string[]).length > 0) result = false
30
- }
31
-
32
- if (flash.value.alert) result = false
33
-
34
- return result
35
- }
36
-
37
- return {
38
- externalErrors,
39
- clearExternalErrors,
40
- isSuccess,
41
- }
42
- }
@@ -1,13 +0,0 @@
1
- export const useEntity = function <M extends object, R extends object = M>() {
2
- const create = ({ from }: { from: R | M }): M => {
3
- const model: Partial<M> = {}
4
- Object.assign(model, from)
5
- return model as M
6
- }
7
-
8
- const copy = ({ from, to }: { from: R | M; to: M }): void => {
9
- Object.assign(to, from)
10
- }
11
-
12
- return { create, copy }
13
- }
@@ -1,15 +0,0 @@
1
- import type { Flash } from '../../interfaces'
2
-
3
- import { ref } from 'vue'
4
-
5
- export const useFlash = function () {
6
- const flash = ref<Flash>({})
7
-
8
- const clearFlash = (): void => {
9
- flash.value = {}
10
- }
11
-
12
- return { flash, clearFlash }
13
- }
14
-
15
- export type UseFlashType = ReturnType<typeof useFlash>
@@ -1,7 +0,0 @@
1
- export const useDate = function () {
2
- const isValidDate = (str: string): boolean => {
3
- return !!str && !!str.match(/\d{4}\/\d{2}\/\d{2}/) && !isNaN(Date.parse(str))
4
- }
5
-
6
- return { isValidDate }
7
- }
@@ -1,4 +0,0 @@
1
- export interface BackendErrorInfo<BER> {
2
- error?: BER
3
- status?: number
4
- }
@@ -1 +0,0 @@
1
- export type { BackendErrorInfo } from './backend-error-info'
@@ -1,4 +0,0 @@
1
- export interface Flash {
2
- notice?: string
3
- alert?: string
4
- }
@@ -1,5 +0,0 @@
1
- export type { BackendErrorInfo } from './error'
2
-
3
- export type { BackendErrorResource, ErrorsResource } from './resource'
4
-
5
- export type { Flash } from './flash'
@@ -1,5 +0,0 @@
1
- export interface BackendErrorResource {
2
- source?: string
3
- title: string
4
- errors: string[]
5
- }
@@ -1,3 +0,0 @@
1
- export interface ErrorsResource<T> {
2
- errors: T
3
- }
@@ -1,2 +0,0 @@
1
- export type { ErrorsResource } from './errors-resource'
2
- export type { BackendErrorResource } from './beckend-error-resource'
@@ -1 +0,0 @@
1
- export type ErrorMessages<T extends string> = Partial<Record<T, string[]>>