@d-mok/quasar-app-extension-quasar-axe 1.0.39 → 1.0.40

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": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "A Quasar App Extension",
5
5
  "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -4,8 +4,13 @@ import { Constructor } from './type'
4
4
 
5
5
  export function Entity<
6
6
  TBase extends Constructor,
7
+ K extends string & keyof R,
7
8
  R extends InstanceType<TBase> = InstanceType<TBase>
8
- >(RowClass: TBase) {
9
+ >(
10
+ RowClass: TBase,
11
+ tableName: string,
12
+ idKey: K
13
+ ) {
9
14
 
10
15
  class VIEW extends RowClass {
11
16
 
@@ -17,8 +22,11 @@ export function Entity<
17
22
 
18
23
  static _RowClass = RowClass
19
24
 
20
- static _fields: (string & keyof InstanceType<TBase>)[]
21
- = Object.keys(new RowClass()) as any
25
+ static _tableName = tableName
26
+
27
+ static _idKey: K = idKey
28
+
29
+ static _fields: any[] = Object.keys(new RowClass())
22
30
 
23
31
  }
24
32
 
@@ -5,7 +5,12 @@ import { Core } from './core'
5
5
  import { Entity } from './entity'
6
6
 
7
7
 
8
- type imprinted<R extends object> = { _RowClass: Constructor, _fields: (string & keyof R)[] }
8
+ type imprinted<R extends object> = {
9
+ _RowClass: Constructor
10
+ _tableName: string
11
+ _idKey: string & keyof R
12
+ _fields: any[]
13
+ }
9
14
  type EntityClass<T extends R, R extends object> = Constructor<T> & imprinted<R>
10
15
  type RowOf<E extends EntityClass<any, any>> = InstanceType<E['_RowClass']>
11
16
 
@@ -18,15 +23,17 @@ function logCreate(tableName: string, idKey: string, entityName: string) {
18
23
 
19
24
 
20
25
  export function Table<
21
- K extends string & keyof R,
22
26
  ClassT extends EntityClass<T, R>,
23
27
  R extends RowOf<ClassT> = RowOf<ClassT>,
24
28
  T extends R = InstanceType<ClassT>
25
- >(
26
- EntityClass: ClassT,
27
- idKey: K,
28
- tableName: string = EntityClass.name.toLowerCase(),
29
- ) {
29
+ >(
30
+ EntityClass: ClassT,
31
+ ordering: Ordering<InstanceType<ClassT>> = []
32
+ ) {
33
+
34
+ const tableName: string = EntityClass._tableName
35
+ const idKey: ClassT['_idKey'] = EntityClass._idKey
36
+ const fields: any[] = EntityClass._fields
30
37
 
31
38
  logCreate(tableName, idKey, EntityClass.name)
32
39
 
@@ -43,7 +50,7 @@ export function Table<
43
50
  return new Core<T, R>(
44
51
  tableName,
45
52
  idKey,
46
- EntityClass._fields,
53
+ fields,
47
54
  convertor(host)
48
55
  )
49
56
  }
@@ -51,11 +58,9 @@ export function Table<
51
58
 
52
59
  class Base extends Sheet<T> {
53
60
 
54
- /** The default ordering instruction object. */
55
- protected readonly ordering: Readonly<Ordering<T>> = []
56
61
 
57
62
  protected reorder() {
58
- this.order(...this.ordering)
63
+ this.order(...ordering)
59
64
  }
60
65
 
61
66
 
@@ -78,7 +83,7 @@ export function Table<
78
83
  class TableView extends Base {
79
84
 
80
85
  private orderByList<K extends keyof R>(key: K, vals: R[K][]) {
81
- this.ordering.length === 0
86
+ ordering.length === 0
82
87
  ? this.reorder()
83
88
  : this.order({ [key]: vals } as any)
84
89
  }
@@ -153,7 +158,7 @@ export function Table<
153
158
  }
154
159
 
155
160
 
156
- update(idVal: R[K], row: Partial<R>) {
161
+ update(idVal: R[ClassT['_idKey']], row: Partial<R>) {
157
162
  let callback = ($: T[]) => {
158
163
  this.merge($, idKey)
159
164
  this.reorder()
@@ -170,7 +175,7 @@ export function Table<
170
175
  }
171
176
 
172
177
 
173
- delete(idVal: R[K]) {
178
+ delete(idVal: R[ClassT['_idKey']]) {
174
179
  let callback = ($: T[]) => {
175
180
  this.discard({ [idKey]: idVal } as any)
176
181
  this.reorder()
@@ -222,7 +227,7 @@ export function Table<
222
227
 
223
228
 
224
229
 
225
- // class Student extends Entity(StudentRow).EDIT {
230
+ // class Student extends Entity(StudentRow, 'student', 'num').EDIT {
226
231
 
227
232
  // public full = this.class + this.name
228
233
 
@@ -231,14 +236,13 @@ export function Table<
231
236
 
232
237
  // let s = new Student()
233
238
  // // s.ful
234
- // s.update({ num: 1 })
235
239
 
236
240
 
237
241
 
238
242
 
239
- // class StudentsCollection extends Table(Student, 'num').EDIT {
240
243
 
241
- // protected ordering = ['name'] as const
244
+ // class StudentsCollection extends Table(Student,['full']).EDIT {
245
+
242
246
 
243
247
  // protected override onChange() {
244
248
  // return 1
@@ -248,8 +252,8 @@ export function Table<
248
252
 
249
253
 
250
254
  // let ss = new StudentsCollection()
251
- // ss.select().eq('num', 1)
252
- // ss.insert({ nae }).confirm('a')
253
- // ss.delete('f')
255
+ // ss.select().eq('num',)
256
+ // ss.insert()
257
+ // ss.delete(1)
254
258
 
255
259