@d-mok/quasar-app-extension-quasar-axe 2.2.1 → 2.2.2
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
|
@@ -18,7 +18,7 @@ export function ORM<
|
|
|
18
18
|
type R = InstanceType<RBase>
|
|
19
19
|
|
|
20
20
|
class E extends RClass {
|
|
21
|
-
private _hostTable:
|
|
21
|
+
private _hostTable: any
|
|
22
22
|
|
|
23
23
|
constructor(...args: any[]) {
|
|
24
24
|
super()
|
|
@@ -42,163 +42,170 @@ export function ORM<
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
function getTable<EBase extends RBase>(EClass: EBase) {
|
|
46
|
+
type T = InstanceType<EBase>
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function core(host: TableClass) {
|
|
52
|
-
return new Core<T, R>(
|
|
53
|
-
tableName,
|
|
54
|
-
idKey,
|
|
55
|
-
Object.keys(new RClass()) as Key<R>[],
|
|
56
|
-
convertor(host)
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
class TableClass extends Array<T> {
|
|
61
|
-
/** make reactive */
|
|
62
|
-
reactive(): this {
|
|
63
|
-
const rec = reactive(this) as this
|
|
64
|
-
if (process.env.DEBUGGING) {
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
globalThis.TABLES.push(rec)
|
|
67
|
-
}
|
|
68
|
-
return rec
|
|
48
|
+
function convertor(host: TableClass) {
|
|
49
|
+
return ($: R) => new E($, host) as T
|
|
69
50
|
}
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
52
|
+
function core(host: TableClass) {
|
|
53
|
+
return new Core<T, R>(
|
|
54
|
+
tableName,
|
|
55
|
+
idKey,
|
|
56
|
+
Object.keys(new RClass()) as Key<R>[],
|
|
57
|
+
convertor(host)
|
|
58
|
+
)
|
|
75
59
|
}
|
|
76
60
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this
|
|
61
|
+
class TableClass extends Array<InstanceType<EBase>> {
|
|
62
|
+
/** make reactive */
|
|
63
|
+
reactive(): this {
|
|
64
|
+
const rec = reactive(this) as this
|
|
65
|
+
if (process.env.DEBUGGING) {
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
globalThis.TABLES.push(rec)
|
|
68
|
+
}
|
|
69
|
+
return rec
|
|
81
70
|
}
|
|
82
|
-
return new SelectBuilder(core(this), callback)
|
|
83
|
-
}
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
protected onChange(): any {}
|
|
73
|
+
protected onEdit(): any {}
|
|
74
|
+
protected onSanitize(row: Partial<R>): Partial<R> {
|
|
75
|
+
return row
|
|
89
76
|
}
|
|
90
|
-
return new SelectBuilder(core(this), callback)
|
|
91
|
-
}
|
|
92
77
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
78
|
+
select() {
|
|
79
|
+
let callback = ($: T[]) => {
|
|
80
|
+
this.set($)
|
|
81
|
+
this.onChange()
|
|
82
|
+
}
|
|
83
|
+
return new SelectBuilder(core(this), callback)
|
|
98
84
|
}
|
|
99
|
-
return new SelectInBuilder(key, vals, core(this), callback)
|
|
100
|
-
}
|
|
101
85
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
86
|
+
patch() {
|
|
87
|
+
let callback = ($: T[]) => {
|
|
88
|
+
this.absorb($, idKey)
|
|
89
|
+
this.onChange()
|
|
90
|
+
}
|
|
91
|
+
return new SelectBuilder(core(this), callback)
|
|
107
92
|
}
|
|
108
|
-
return new SelectInBuilder(key, vals, core(this), callback)
|
|
109
|
-
}
|
|
110
93
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
94
|
+
selectIn<K extends Key<R>>(key: K, vals: R[K][]) {
|
|
95
|
+
let callback = ($: T[]) => {
|
|
96
|
+
this.set($)
|
|
97
|
+
this.sortBy($ => vals.indexOf($[key]))
|
|
98
|
+
this.onChange()
|
|
99
|
+
}
|
|
100
|
+
return new SelectInBuilder(key, vals, core(this), callback)
|
|
115
101
|
}
|
|
116
|
-
return new SelectRPCBuilder(param, core(this), callback)
|
|
117
|
-
}
|
|
118
102
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
103
|
+
patchIn<K extends Key<R>>(key: K, vals: R[K][]) {
|
|
104
|
+
let callback = ($: T[]) => {
|
|
105
|
+
this.absorb($, idKey)
|
|
106
|
+
this.sortBy($ => vals.indexOf($[key]))
|
|
107
|
+
this.onChange()
|
|
108
|
+
}
|
|
109
|
+
return new SelectInBuilder(key, vals, core(this), callback)
|
|
123
110
|
}
|
|
124
|
-
return new SelectRPCBuilder(param, core(this), callback)
|
|
125
|
-
}
|
|
126
111
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
112
|
+
selectRPC(param: object = {}) {
|
|
113
|
+
let callback = ($: T[]) => {
|
|
114
|
+
this.set($)
|
|
115
|
+
this.onChange()
|
|
116
|
+
}
|
|
117
|
+
return new SelectRPCBuilder(param, core(this), callback)
|
|
118
|
+
}
|
|
133
119
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
this
|
|
120
|
+
patchRPC(param: object = {}) {
|
|
121
|
+
let callback = ($: T[]) => {
|
|
122
|
+
this.absorb($, idKey)
|
|
123
|
+
this.onChange()
|
|
124
|
+
}
|
|
125
|
+
return new SelectRPCBuilder(param, core(this), callback)
|
|
140
126
|
}
|
|
141
|
-
return new InsertBuilder([row], core(this), callback).notify(
|
|
142
|
-
'Created!'
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
127
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.
|
|
128
|
+
selectCustom(rows: R[]) {
|
|
129
|
+
let convert = core(this).convertor
|
|
130
|
+
let entities = rows.map(convert)
|
|
131
|
+
this.set(entities)
|
|
150
132
|
this.onChange()
|
|
151
|
-
this.onEdit()
|
|
152
133
|
}
|
|
153
|
-
return new InsertBuilder(rows, core(this), callback).notify(
|
|
154
|
-
'Created!'
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
134
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
135
|
+
insert(row: Partial<R>) {
|
|
136
|
+
row = this.onSanitize(row)
|
|
137
|
+
let callback = ($: T[]) => {
|
|
138
|
+
this.push(...$)
|
|
139
|
+
this.onChange()
|
|
140
|
+
this.onEdit()
|
|
141
|
+
}
|
|
142
|
+
return new InsertBuilder([row], core(this), callback).notify(
|
|
143
|
+
'Created!'
|
|
144
|
+
)
|
|
164
145
|
}
|
|
165
|
-
return new UpdateBuilder(idVal, row, core(this), callback).notify(
|
|
166
|
-
'Updated!'
|
|
167
|
-
)
|
|
168
|
-
}
|
|
169
146
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
147
|
+
insertMany(rows: Partial<R>[]) {
|
|
148
|
+
rows = rows.map(this.onSanitize)
|
|
149
|
+
let callback = ($: T[]) => {
|
|
150
|
+
this.push(...$)
|
|
151
|
+
this.onChange()
|
|
152
|
+
this.onEdit()
|
|
153
|
+
}
|
|
154
|
+
return new InsertBuilder(rows, core(this), callback).notify(
|
|
155
|
+
'Created!'
|
|
156
|
+
)
|
|
175
157
|
}
|
|
176
|
-
return new DeleteBuilder(idVal, core(this), callback).notify(
|
|
177
|
-
'Deleted!'
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
158
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
159
|
+
update(idVal: R[K], row: Partial<R>) {
|
|
160
|
+
row = this.onSanitize(row)
|
|
161
|
+
let callback = ($: T[]) => {
|
|
162
|
+
this.merge($, idKey)
|
|
163
|
+
this.onChange()
|
|
164
|
+
this.onEdit()
|
|
165
|
+
}
|
|
166
|
+
return new UpdateBuilder(
|
|
167
|
+
idVal,
|
|
168
|
+
row,
|
|
169
|
+
core(this),
|
|
170
|
+
callback
|
|
171
|
+
).notify('Updated!')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
delete(idVal: R[K]) {
|
|
175
|
+
let callback = ($: T[]) => {
|
|
176
|
+
this.remove($ => $[idKey] === idVal)
|
|
177
|
+
this.onChange()
|
|
178
|
+
this.onEdit()
|
|
179
|
+
}
|
|
180
|
+
return new DeleteBuilder(idVal, core(this), callback).notify(
|
|
181
|
+
'Deleted!'
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
upsert(row: Partial<R>, conflictKeys: Key<R>[]) {
|
|
186
|
+
row = this.onSanitize(row)
|
|
187
|
+
let callback = ($: T[]) => {
|
|
188
|
+
this.absorb($, idKey)
|
|
189
|
+
this.onChange()
|
|
190
|
+
this.onEdit()
|
|
191
|
+
}
|
|
192
|
+
return new UpsertBuilder(
|
|
193
|
+
row,
|
|
194
|
+
conflictKeys,
|
|
195
|
+
core(this),
|
|
196
|
+
callback
|
|
197
|
+
).notify('Updated!')
|
|
187
198
|
}
|
|
188
|
-
return new UpsertBuilder(
|
|
189
|
-
row,
|
|
190
|
-
conflictKeys,
|
|
191
|
-
core(this),
|
|
192
|
-
callback
|
|
193
|
-
).notify('Updated!')
|
|
194
199
|
}
|
|
200
|
+
|
|
201
|
+
return TableClass
|
|
195
202
|
}
|
|
196
203
|
|
|
197
204
|
console.dev(
|
|
198
205
|
`Create Table [${tableName}] idKey [${idKey}] entity [${E.name}]`
|
|
199
206
|
)
|
|
200
207
|
|
|
201
|
-
return { Entity: E, Table:
|
|
208
|
+
return { Entity: E, Table: getTable }
|
|
202
209
|
}
|
|
203
210
|
|
|
204
211
|
if (process.env.DEBUGGING) {
|
|
@@ -41,10 +41,14 @@ s.toggle('name')
|
|
|
41
41
|
// @ts-expect-error
|
|
42
42
|
s.toggle('good')
|
|
43
43
|
|
|
44
|
-
class StudentTable extends Table {
|
|
44
|
+
class StudentTable extends Table(Student) {
|
|
45
45
|
protected override onChange() {
|
|
46
46
|
return 1
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
paste() {
|
|
50
|
+
return this.map($ => $.full)
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
let ss = new StudentTable()
|
|
@@ -70,3 +74,7 @@ ss.update('', { name: 0 })
|
|
|
70
74
|
ss.update('', { full: 'a' })
|
|
71
75
|
// @ts-expect-error
|
|
72
76
|
ss.update(0, { name: 'a' })
|
|
77
|
+
|
|
78
|
+
let st = ss[0]
|
|
79
|
+
st.name
|
|
80
|
+
st.full
|