Skip to content

Commit ae0cb2b

Browse files
committed
test: async throw
1 parent 0571fc1 commit ae0cb2b

22 files changed

+67
-41
lines changed

src/hooks/data/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './use-delete'
2+
export * from './use-filter'
3+
export * from './use-insert'
4+
export * from './use-select'
5+
export * from './use-update'
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useCallback, useEffect, useRef, useState } from 'react'
22

3-
import { Count, Filter, PostgrestError, Returning } from '../types'
4-
import { useClient } from './use-client'
5-
import { initialState } from './state'
3+
import { Count, Filter, PostgrestError, Returning } from '../../types'
4+
import { initialState } from '../state'
5+
import { useClient } from '../use-client'
66

77
export type UseDeleteState<Data = any> = {
88
count?: number | null
@@ -14,7 +14,7 @@ export type UseDeleteState<Data = any> = {
1414
export type UseDeleteResponse<Data = any> = [
1515
UseDeleteState<Data>,
1616
(
17-
filter: Filter<Data>,
17+
filter?: Filter<Data>,
1818
options?: UseDeleteOptions,
1919
) => Promise<Pick<UseDeleteState<Data>, 'count' | 'data' | 'error'>>,
2020
]
@@ -42,7 +42,7 @@ export function useDelete<Data = any>(
4242
async (filter?: Filter<Data>, options?: UseDeleteOptions) => {
4343
const refine = filter ?? config.filter
4444
if (refine === undefined)
45-
throw Error('update() should always be combined with `filter`')
45+
throw Error('delete() should always be combined with `filter`')
4646

4747
setState({ ...initialState, fetching: true })
4848
const source = client
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback } from 'react'
22

3-
import { Filter } from '../types'
3+
import { Filter } from '../../types'
44

55
export function useFilter<Data = any>(filter: Filter<Data>, deps: any[] = []) {
66
/* eslint-disable react-hooks/exhaustive-deps */
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useCallback, useEffect, useRef, useState } from 'react'
22

3-
import { Count, PostgrestError, Returning } from '../types'
4-
import { useClient } from './use-client'
5-
import { initialState } from './state'
3+
import { Count, PostgrestError, Returning } from '../../types'
4+
import { initialState } from '../state'
5+
import { useClient } from '../use-client'
66

77
export type UseInsertState<Data = any> = {
88
count?: number | null
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
22

3-
import { Count, Filter, PostgrestError } from '../types'
4-
import { useClient } from './use-client'
5-
import { initialState } from './state'
3+
import { Count, Filter, PostgrestError } from '../../types'
4+
import { initialState } from '../state'
5+
import { useClient } from '../use-client'
66

77
export type UseSelectState<Data = any> = {
88
count?: number | null
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useCallback, useEffect, useRef, useState } from 'react'
22

3-
import { Count, Filter, PostgrestError, Returning } from '../types'
4-
import { useClient } from './use-client'
5-
import { initialState } from './state'
3+
import { Count, Filter, PostgrestError, Returning } from '../../types'
4+
import { initialState } from '../state'
5+
import { useClient } from '../use-client'
66

77
export type UseUpdateState<Data = any> = {
88
count?: number | null

src/hooks/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1+
export * from './data'
2+
export * from './realtime'
13
export * from './use-client'
2-
export * from './use-delete'
3-
export * from './use-filter'
4-
export * from './use-insert'
5-
export * from './use-select'
6-
export * from './use-subscription'
7-
export * from './use-update'

src/hooks/realtime/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './use-subscription'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
SupabaseRealtimePayload,
55
} from '@supabase/supabase-js/dist/main/lib/types'
66

7-
import { useClient } from './use-client'
7+
import { useClient } from '../use-client'
88

99
export type UseSubscriptionConfig = {
1010
event?: SupabaseEventTypes

src/hooks/use-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import { Context } from '../context'
66
export const useClient = (): SupabaseClient => {
77
const client = useContext(Context)
88
if (client === undefined)
9-
throw new Error('No client has been specified using Provider.')
9+
throw Error('No client has been specified using Provider.')
1010
return client
1111
}

0 commit comments

Comments
 (0)