@d-mok/quasar-app-extension-quasar-axe 4.0.1 → 4.0.3

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": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "A Quasar App Extension",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -78,7 +78,7 @@ export function ORM<
78
78
 
79
79
  protected onChange(): void {}
80
80
  protected onEdit(): void {}
81
- protected onSanitize<P extends Partial<R>>(row: P): P {
81
+ protected onSanitize(row: Partial<R>): Partial<R> {
82
82
  return row
83
83
  }
84
84
 
@@ -132,13 +132,19 @@ export function ORM<
132
132
  return entities
133
133
  }
134
134
 
135
- async read(query: (q: Filter) => Filter = q => q): Promise<R[]> {
135
+ async read(
136
+ query: ((q: Filter) => Filter) | Partial<R> = q => q
137
+ ): Promise<R[]> {
136
138
  const q = supabase.from(tableName).select(fields)
137
- return await query(q).then(handleError)
139
+ if (typeof query === 'function') {
140
+ return await query(q).then(handleError)
141
+ } else {
142
+ return await q.match(query).then(handleError)
143
+ }
138
144
  }
139
145
 
140
146
  async select(
141
- query: (q: Filter) => Filter = q => q,
147
+ query: ((q: Filter) => Filter) | Partial<R> = q => q,
142
148
  options?: selectOptions
143
149
  ): Promise<void> {
144
150
  await this.wrapper('select', options, async () => {
@@ -257,7 +263,7 @@ export function ORM<
257
263
  conflictKeys: Key<P>[],
258
264
  options?: uiOptions
259
265
  ): Promise<T> {
260
- row = this.onSanitize(row)
266
+ row = this.onSanitize(row) as P
261
267
 
262
268
  let found: R[] = await this.read(q =>
263
269
  q.match(Object.pick(row, conflictKeys))
@@ -298,10 +304,10 @@ if (process.env.DEBUGGING) {
298
304
  type uiOptions = {
299
305
  confirm?: [string, string]
300
306
  notify?: string | false
301
- loading?: boolean
307
+ loading?: false
302
308
  }
303
309
 
304
310
  type selectOptions = {
305
- loading?: boolean
311
+ loading?: false
306
312
  patch?: true
307
313
  }
@@ -58,6 +58,7 @@ let ss = new StudentTable()
58
58
  let x1 = await ss.read()
59
59
 
60
60
  ss.select(q => q.eq('name', 'a').eq('num', 3).limit(100).order('class'))
61
+ ss.select({ name: 'a', num: 3 })
61
62
  // @ts-expect-error
62
63
  ss.select(q => q.eq('isPrefect', 'a'))
63
64
  ss.selectIn('num', [1, 2, 3])
@@ -78,6 +79,7 @@ ss.update('', { name: 0 })
78
79
  ss.update('', { full: 'a' })
79
80
  // @ts-expect-error
80
81
  ss.update(0, { name: 'a' })
82
+ ss.upsert({ name: 'a', num: 3 }, ['num'])
81
83
 
82
84
  let st = ss[0]!
83
85
  st.name