@d-mok/quasar-app-extension-quasar-axe 2.1.48 → 2.1.50

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-mok/quasar-app-extension-quasar-axe",
3
- "version": "2.1.48",
3
+ "version": "2.1.50",
4
4
  "description": "A Quasar App Extension",
5
5
  "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -24,6 +24,14 @@ function extendQuasarConf(conf, prompts) {
24
24
 
25
25
  conf.animations.push('fadeIn', 'fadeOut', 'zoomIn', 'zoomOut')
26
26
  console.log('[QuasarAxe] Config pushed animations')
27
+
28
+ conf.build.viteVuePluginOptions = {
29
+ script: {
30
+ defineModel: true,
31
+ propsDestructure: true,
32
+ },
33
+ }
34
+ console.log('[QuasarAxe] Config pushed viteVuePluginOptions')
27
35
  }
28
36
 
29
37
  module.exports = function (api) {
@@ -21,3 +21,5 @@ export { zipCreate, zipDownload } from './zip'
21
21
  export type { zipFolder } from './zip'
22
22
 
23
23
  export * as gSheet from './gSheet'
24
+
25
+ export { SupbaseBucket } from './storage'
@@ -0,0 +1,104 @@
1
+ import { supabase, HANDLE_ERROR, zipCreate, zipDownload } from '.'
2
+ import { reactive } from 'vue'
3
+ import { FileOptions } from '@supabase/storage-js'
4
+
5
+ export class SupbaseBucket extends Map<string, string> {
6
+ constructor(public bucketName: string) {
7
+ super()
8
+ }
9
+
10
+ private async listPaths(): Promise<string[]> {
11
+ // can only list file in root folder
12
+ const { data, error } = await supabase.storage
13
+ .from(this.bucketName)
14
+ .list(undefined, { limit: 10000 })
15
+ HANDLE_ERROR(data, error)
16
+ return data.pluck('name')
17
+ }
18
+
19
+ private async getUrl(path: string): Promise<string> {
20
+ const { data, error } = await supabase.storage
21
+ .from(this.bucketName)
22
+ .createSignedUrl(path, 60 * 60 * 24)
23
+ HANDLE_ERROR(data, error)
24
+ return data.signedUrl
25
+ }
26
+
27
+ private async getUrls(
28
+ paths: string[]
29
+ ): Promise<{ path: string | null; signedUrl: string }[]> {
30
+ const { data, error } = await supabase.storage
31
+ .from(this.bucketName)
32
+ .createSignedUrls(paths, 60 * 60 * 24)
33
+ HANDLE_ERROR(data, error)
34
+ return data
35
+ }
36
+
37
+ async load(path: string): Promise<void> {
38
+ let url = await this.getUrl(path)
39
+ this.set(path, url)
40
+ }
41
+
42
+ async loadAll(): Promise<void> {
43
+ let paths = await this.listPaths()
44
+ if (paths.length === 0) return
45
+ let urls = await this.getUrls(paths)
46
+ for (let { path, signedUrl } of urls) {
47
+ if (path === null) continue
48
+ this.set(path, signedUrl)
49
+ }
50
+ }
51
+
52
+ async upload(
53
+ path: string,
54
+ file: File | Blob,
55
+ fileOptions?: FileOptions
56
+ ): Promise<void> {
57
+ const { data, error } = await supabase.storage
58
+ .from(this.bucketName)
59
+ .upload(path, file, fileOptions)
60
+ HANDLE_ERROR(data, error)
61
+ await this.load(path)
62
+ }
63
+
64
+ async update(
65
+ path: string,
66
+ file: File | Blob,
67
+ fileOptions?: FileOptions
68
+ ): Promise<void> {
69
+ const { data, error } = await supabase.storage
70
+ .from(this.bucketName)
71
+ .update(path, file, fileOptions)
72
+ HANDLE_ERROR(data, error)
73
+ await this.load(path)
74
+ }
75
+
76
+ async upsert(
77
+ path: string,
78
+ file: File | Blob,
79
+ fileOptions?: FileOptions
80
+ ): Promise<void> {
81
+ const { data, error } = await supabase.storage
82
+ .from(this.bucketName)
83
+ .upload(path, file, { ...fileOptions, upsert: true })
84
+ HANDLE_ERROR(data, error)
85
+ await this.load(path)
86
+ }
87
+
88
+ async remove(path: string): Promise<void> {
89
+ const { data, error } = await supabase.storage
90
+ .from(this.bucketName)
91
+ .remove([path])
92
+ HANDLE_ERROR(data, error)
93
+ this.delete(path)
94
+ }
95
+
96
+ async downloadZip() {
97
+ let zip = await zipCreate(Object.fromEntries(this))
98
+ await zipDownload(this.bucketName, zip)
99
+ }
100
+
101
+ reactive(): this {
102
+ return reactive(this) as this
103
+ }
104
+ }