@mixd-id/web-scaffold 0.1.230406274 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406274",
4
+ "version": "0.1.230406276",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -384,6 +384,8 @@ export default{
384
384
  })
385
385
  break
386
386
  }
387
+
388
+ this.$emit('signal', event, items)
387
389
  },
388
390
 
389
391
  resize(){
@@ -395,7 +397,7 @@ export default{
395
397
 
396
398
  components: {PresetBar, PresetSelector, VirtualGrid, VirtualTable},
397
399
 
398
- emits: [ 'after-load', 'open-preset' ],
400
+ emits: [ 'after-load', 'open-preset', 'signal' ],
399
401
 
400
402
  inject: [ 'socket', 'toast' ],
401
403
 
@@ -53,7 +53,10 @@ export default{
53
53
 
54
54
  placeholder: String,
55
55
  readonly: undefined,
56
- maxlength: [ String, Number ],
56
+ maxlength: {
57
+ type: [ String, Number ],
58
+ default: 255
59
+ },
57
60
  type: String, // text, tel, password, number,
58
61
 
59
62
  itemClass: String
package/src/index.js CHANGED
@@ -188,7 +188,7 @@ const util = {
188
188
  window.addEventListener('mouseup', onMouseUp)
189
189
  },
190
190
 
191
- push: (arr, items, opt = { key }) => {
191
+ push: (arr, items, opt = {}) => {
192
192
  if(!Array.isArray(arr)) return
193
193
  if(!Array.isArray(items)) items = [ items ]
194
194
  if(!opt.key){
@@ -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('reconnect', null, []) : this.emit('connect', null, [])
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)