@d-mok/quasar-app-extension-quasar-axe 3.1.68 → 3.1.69
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/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { supabase,
|
|
1
|
+
import { supabase, handleError, PostgrestFilterBuilder } from '../../supabase'
|
|
2
2
|
import { Filter } from '../type'
|
|
3
3
|
|
|
4
4
|
type FilterBuilder = PostgrestFilterBuilder<any, any, any, any>
|
|
5
5
|
|
|
6
6
|
async function send(q: any): Promise<any[]> {
|
|
7
|
-
let data = await q.then(
|
|
7
|
+
let data = await q.then(handleError)
|
|
8
8
|
return Array.isArray(data) ? data : [data]
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { supabase,
|
|
1
|
+
import { supabase, handleError } from '.'
|
|
2
2
|
import { reactive } from 'vue'
|
|
3
3
|
import { FileOptions } from '@supabase/storage-js'
|
|
4
4
|
import { mimeTypesToExt } from './mimeTypesToExt'
|
|
@@ -13,7 +13,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
13
13
|
const data = await supabase.storage
|
|
14
14
|
.from(this.bucketName)
|
|
15
15
|
.list(undefined, { limit: 10000 })
|
|
16
|
-
.then(
|
|
16
|
+
.then(handleError)
|
|
17
17
|
return data.pluck('name')
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
21
21
|
const data = await supabase.storage
|
|
22
22
|
.from(this.bucketName)
|
|
23
23
|
.createSignedUrl(path, 60 * 60 * 24)
|
|
24
|
-
.then(
|
|
24
|
+
.then(handleError)
|
|
25
25
|
return data.signedUrl
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -31,7 +31,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
31
31
|
const data = await supabase.storage
|
|
32
32
|
.from(this.bucketName)
|
|
33
33
|
.createSignedUrls(paths, 60 * 60 * 24)
|
|
34
|
-
.then(
|
|
34
|
+
.then(handleError)
|
|
35
35
|
return data
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -58,7 +58,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
58
58
|
const data = await supabase.storage
|
|
59
59
|
.from(this.bucketName)
|
|
60
60
|
.upload(path, file, fileOptions)
|
|
61
|
-
.then(
|
|
61
|
+
.then(handleError)
|
|
62
62
|
await this.load(path)
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -70,7 +70,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
70
70
|
const data = await supabase.storage
|
|
71
71
|
.from(this.bucketName)
|
|
72
72
|
.update(path, file, fileOptions)
|
|
73
|
-
.then(
|
|
73
|
+
.then(handleError)
|
|
74
74
|
await this.load(path)
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -82,7 +82,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
82
82
|
const data = await supabase.storage
|
|
83
83
|
.from(this.bucketName)
|
|
84
84
|
.upload(path, file, { ...fileOptions, upsert: true })
|
|
85
|
-
.then(
|
|
85
|
+
.then(handleError)
|
|
86
86
|
await this.load(path)
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -90,7 +90,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
90
90
|
const data = await supabase.storage
|
|
91
91
|
.from(this.bucketName)
|
|
92
92
|
.remove([path])
|
|
93
|
-
.then(
|
|
93
|
+
.then(handleError)
|
|
94
94
|
this.delete(path)
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -98,7 +98,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
98
98
|
const data = await supabase.storage
|
|
99
99
|
.from(this.bucketName)
|
|
100
100
|
.copy(fromPath, toPath)
|
|
101
|
-
.then(
|
|
101
|
+
.then(handleError)
|
|
102
102
|
await this.load(toPath)
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -106,7 +106,7 @@ export class SupabaseBucket extends Map<string, string> {
|
|
|
106
106
|
const data = await supabase.storage
|
|
107
107
|
.from(this.bucketName)
|
|
108
108
|
.move(fromPath, toPath)
|
|
109
|
-
.then(
|
|
109
|
+
.then(handleError)
|
|
110
110
|
await this.load(toPath)
|
|
111
111
|
this.delete(fromPath)
|
|
112
112
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createClient,
|
|
3
|
-
PostgrestError,
|
|
4
|
-
SupabaseClient,
|
|
5
|
-
Session,
|
|
6
|
-
} from '@supabase/supabase-js'
|
|
1
|
+
import { PostgrestError, SupabaseClient } from '@supabase/supabase-js'
|
|
7
2
|
import { qDialog } from './dialog'
|
|
8
3
|
|
|
9
4
|
export type {
|
|
@@ -16,7 +11,6 @@ let SUPABASE_KEY = process.env.SUPABASE_KEY ?? ''
|
|
|
16
11
|
|
|
17
12
|
export class MySupabaseClient extends SupabaseClient {
|
|
18
13
|
email: string = 'unauthenticated'
|
|
19
|
-
// session: Session | null = null
|
|
20
14
|
|
|
21
15
|
constructor() {
|
|
22
16
|
super(SUPABASE_URL, SUPABASE_KEY, {
|
|
@@ -24,15 +18,9 @@ export class MySupabaseClient extends SupabaseClient {
|
|
|
24
18
|
// @ts-ignore
|
|
25
19
|
schema: process.env.SUPABASE_SCHEMA ?? 'public',
|
|
26
20
|
},
|
|
27
|
-
// auth: {
|
|
28
|
-
// autoRefreshToken: true,
|
|
29
|
-
// persistSession: true,
|
|
30
|
-
// detectSessionInUrl: true,
|
|
31
|
-
// },
|
|
32
21
|
})
|
|
33
22
|
this.auth.onAuthStateChange((event, session) => {
|
|
34
23
|
console.log('[SUPABASE AUTH]', event, session?.user?.email)
|
|
35
|
-
// this.session = session
|
|
36
24
|
this.email = session?.user?.email ?? 'unauthenticated'
|
|
37
25
|
})
|
|
38
26
|
}
|
|
@@ -52,40 +40,19 @@ export class MySupabaseClient extends SupabaseClient {
|
|
|
52
40
|
}
|
|
53
41
|
|
|
54
42
|
async call<T>(fn: string, params?: object | undefined): Promise<T[]> {
|
|
55
|
-
return await this.rpc<string, any>(fn, params).then(
|
|
43
|
+
return await this.rpc<string, any>(fn, params).then(handleError)
|
|
56
44
|
}
|
|
57
45
|
|
|
58
46
|
async callSingle<T>(fn: string, params?: object | undefined): Promise<T> {
|
|
59
47
|
return (await this.rpc<string, any>(fn, params)
|
|
60
48
|
.single()
|
|
61
|
-
.then(
|
|
49
|
+
.then(handleError)) as T
|
|
62
50
|
}
|
|
63
51
|
|
|
64
|
-
// private async tryRefreshSession() {
|
|
65
|
-
// try {
|
|
66
|
-
// await this.auth.refreshSession()
|
|
67
|
-
// } catch (e) {
|
|
68
|
-
// console.error('[Supabase] Refresh session failed', e)
|
|
69
|
-
// }
|
|
70
|
-
// }
|
|
71
|
-
|
|
72
52
|
async waitForSignin(): Promise<void> {
|
|
73
|
-
// await this.tryRefreshSession()
|
|
74
53
|
await this.auth.initialize()
|
|
75
54
|
const { data } = await this.auth.getClaims()
|
|
76
55
|
if (data === null) this.signIn()
|
|
77
|
-
// setInterval(async () => {
|
|
78
|
-
// if (this.session === null) await this.tryRefreshSession()
|
|
79
|
-
// if (this.session === null) this.signIn()
|
|
80
|
-
// }, 1000)
|
|
81
|
-
// setInterval(async () => {
|
|
82
|
-
// await this.auth.refreshSession()
|
|
83
|
-
// }, 1000 * 60 * 30 * 0.99)
|
|
84
|
-
// await waitFor(
|
|
85
|
-
// () => this.session !== null,
|
|
86
|
-
// '[Wait for SignIn] waiting...',
|
|
87
|
-
// '[Wait for SignIn] DONE!'
|
|
88
|
-
// )
|
|
89
56
|
}
|
|
90
57
|
}
|
|
91
58
|
|
|
@@ -93,7 +60,7 @@ export let supabase: MySupabaseClient
|
|
|
93
60
|
if (SUPABASE_URL !== '' && SUPABASE_KEY !== '')
|
|
94
61
|
supabase = new MySupabaseClient()
|
|
95
62
|
|
|
96
|
-
|
|
63
|
+
function HANDLE_ERROR<T>(
|
|
97
64
|
data: T[] | T | null,
|
|
98
65
|
error: PostgrestError | Error | null
|
|
99
66
|
): asserts data {
|
|
@@ -119,7 +86,7 @@ export function HANDLE_ERROR<T>(
|
|
|
119
86
|
}
|
|
120
87
|
}
|
|
121
88
|
|
|
122
|
-
export function
|
|
89
|
+
export function handleError<D>({
|
|
123
90
|
data,
|
|
124
91
|
error,
|
|
125
92
|
}: {
|
|
@@ -129,22 +96,3 @@ export function handleThrow<D>({
|
|
|
129
96
|
HANDLE_ERROR(data, error)
|
|
130
97
|
return data
|
|
131
98
|
}
|
|
132
|
-
|
|
133
|
-
// async function waitFor(
|
|
134
|
-
// predicate: () => boolean,
|
|
135
|
-
// waitingMsg: string,
|
|
136
|
-
// doneMsg: string
|
|
137
|
-
// ) {
|
|
138
|
-
// return new Promise(resolve => {
|
|
139
|
-
// async function checker() {
|
|
140
|
-
// if (predicate()) {
|
|
141
|
-
// console.log(doneMsg)
|
|
142
|
-
// resolve(true)
|
|
143
|
-
// } else {
|
|
144
|
-
// console.log(waitingMsg)
|
|
145
|
-
// setTimeout(checker, 50)
|
|
146
|
-
// }
|
|
147
|
-
// }
|
|
148
|
-
// checker()
|
|
149
|
-
// })
|
|
150
|
-
// }
|