@mixd-id/web-scaffold 0.1.230406275 → 0.1.230406276
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 +1 -1
- package/src/utils/preset-selector.js +78 -4
- package/src/utils/wss.mjs +5 -1
package/package.json
CHANGED
|
@@ -342,9 +342,6 @@ const getValue = (filter, opt) => {
|
|
|
342
342
|
break
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
|
|
346
|
-
console.log('getValue', filter, key, type, operator, util.inspect(whereObj, false, null, true /* enable colors */))
|
|
347
|
-
|
|
348
345
|
return whereObj
|
|
349
346
|
}
|
|
350
347
|
|
|
@@ -366,6 +363,8 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
366
363
|
|
|
367
364
|
const { key, value, operator } = filter
|
|
368
365
|
|
|
366
|
+
if(key.indexOf('.') >= 0) continue
|
|
367
|
+
|
|
369
368
|
if(Array.isArray(value) && !operator){
|
|
370
369
|
const { modifier = 'and' } = filter
|
|
371
370
|
|
|
@@ -393,7 +392,6 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
393
392
|
...getValue(filter, opt)
|
|
394
393
|
}
|
|
395
394
|
}
|
|
396
|
-
|
|
397
395
|
}
|
|
398
396
|
|
|
399
397
|
return {
|
|
@@ -808,6 +806,81 @@ const sortsToSequelizeWhere = async (sorts, opt) => {
|
|
|
808
806
|
}
|
|
809
807
|
}
|
|
810
808
|
|
|
809
|
+
const filtersToSequelizeInclude = async(filters, opt, includes) => {
|
|
810
|
+
if(!Array.isArray(filters) || filters.length < 1){
|
|
811
|
+
return includes
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// TODO: Test on 2 level or more level includes
|
|
815
|
+
|
|
816
|
+
// Generate where object
|
|
817
|
+
let whereObj = {}
|
|
818
|
+
for(let filter of filters) {
|
|
819
|
+
if (filter.enabled === false) continue
|
|
820
|
+
|
|
821
|
+
const {key, value, operator} = filter
|
|
822
|
+
|
|
823
|
+
if(key.indexOf('.') < 0) continue
|
|
824
|
+
|
|
825
|
+
if(Array.isArray(value) && !operator){
|
|
826
|
+
const { modifier = 'and' } = filter
|
|
827
|
+
|
|
828
|
+
if(![ 'and', 'or' ].includes(modifier)) continue
|
|
829
|
+
|
|
830
|
+
const opModifierValue = []
|
|
831
|
+
for(let v of value){
|
|
832
|
+
opModifierValue.push(getValue({ ...v, key }, {
|
|
833
|
+
...opt,
|
|
834
|
+
withoutKey: true
|
|
835
|
+
}))
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
whereObj = {
|
|
839
|
+
...whereObj,
|
|
840
|
+
[key]: {
|
|
841
|
+
[Op[modifier]]: opModifierValue
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
else{
|
|
846
|
+
whereObj = {
|
|
847
|
+
...whereObj,
|
|
848
|
+
...getValue(filter, opt)
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
//console.log('whereObj', whereObj)
|
|
853
|
+
|
|
854
|
+
// Apply where to includes
|
|
855
|
+
for(let key in whereObj){
|
|
856
|
+
|
|
857
|
+
const keyParts = key.split('.')
|
|
858
|
+
if(keyParts.length < 2) continue
|
|
859
|
+
|
|
860
|
+
// Walk through the includes to find the correct include
|
|
861
|
+
let include
|
|
862
|
+
for(let i = 0 ; i < keyParts.length - 1 ; i++){
|
|
863
|
+
const as = keyParts[i]
|
|
864
|
+
include = !include ? includes.find(_ => _.as === as) : include.includes ?? []
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// If include is not found, skip
|
|
868
|
+
if(!include){
|
|
869
|
+
continue
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// Generate where object for the correct include
|
|
873
|
+
const currentKey = keyParts[keyParts.length - 1]
|
|
874
|
+
if(!include.where){
|
|
875
|
+
include.where = { [Op.and]: [] }
|
|
876
|
+
}
|
|
877
|
+
include.where[Op.and].push({ [currentKey]: whereObj[key] })
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
//console.log('includes', includes)
|
|
881
|
+
return includes
|
|
882
|
+
}
|
|
883
|
+
|
|
811
884
|
module.exports = {
|
|
812
885
|
filtersToSequelizeWhere,
|
|
813
886
|
afterItemToSequelizeWhere,
|
|
@@ -815,4 +888,5 @@ module.exports = {
|
|
|
815
888
|
chartToSequelizeWhere,
|
|
816
889
|
pivotToSequelizeWhere,
|
|
817
890
|
sortsToSequelizeWhere,
|
|
891
|
+
filtersToSequelizeInclude,
|
|
818
892
|
}
|
package/src/utils/wss.mjs
CHANGED
|
@@ -77,6 +77,8 @@ class WSS extends EventEmitter2{
|
|
|
77
77
|
|
|
78
78
|
async connect(reconnect = false){
|
|
79
79
|
|
|
80
|
+
console.log('connect', this._opt.token)
|
|
81
|
+
|
|
80
82
|
this._instance = new WebSocket(this._opt.url, [ this._opt.token ])
|
|
81
83
|
|
|
82
84
|
this._instance.binaryType = 'arraybuffer';
|
|
@@ -93,7 +95,9 @@ class WSS extends EventEmitter2{
|
|
|
93
95
|
else if(auth){
|
|
94
96
|
this._instance.isAuth = auth
|
|
95
97
|
|
|
96
|
-
reconnect ? this.emit('
|
|
98
|
+
reconnect ? this.emit('connect', true, []) : this.emit('connect', false, [])
|
|
99
|
+
|
|
100
|
+
console.log('pendingSend', this._pendingSend)
|
|
97
101
|
|
|
98
102
|
for(let sendParams of this._pendingSend){
|
|
99
103
|
this.sendSync(sendParams.path, sendParams.params, sendParams.cb, sendParams.err)
|