sumba 2.32.2 → 2.32.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.
@@ -21,7 +21,7 @@ async function clearCacheUser (id, result) {
21
21
  }
22
22
 
23
23
  async function applyModelGuard ({ model, q, teamIds, options }) {
24
- const { set, orderBy } = this.app.lib._
24
+ const { set, orderBy, isEmpty, isArray } = this.app.lib._
25
25
  const { includes } = this.app.lib.aneka
26
26
  const { sanitizeByType } = this.app.dobo
27
27
  const { req } = options
@@ -39,13 +39,19 @@ async function applyModelGuard ({ model, q, teamIds, options }) {
39
39
  const rules = orderBy(guards.filter(filterFn), ['field'])
40
40
  for (const field of fields) {
41
41
  if (!model.getNonVirtualProperties(true).includes(field)) continue // or, should it throws exception instead?
42
+ const opValue = req.getSetting(`sumba:modelGuard.${field}`, {})
43
+ for (const op of ['in', 'nin']) {
44
+ if (!isEmpty(opValue[op]) && isArray(opValue[op])) results.push(set({}, field, set({}, '$' + op, opValue[op])))
45
+ }
42
46
  const prop = model.getProperty(field)
43
47
  const items = rules.filter(item => item.field === field)
44
48
  for (const item of items) {
45
- const values = item.value.map(val => {
49
+ let values = item.value.map(val => {
46
50
  return sanitizeByType(val, prop.type, { strict: true, inputFormat: 'string', model: model.name })
47
51
  })
48
52
  const op = item.condition.toLowerCase()
53
+ if (['in', 'nin'].includes(op) && !isEmpty(opValue[op]) && isArray(opValue[op])) values = values.filter(val => opValue[op].includes(val))
54
+ if (isEmpty(values)) continue
49
55
  let value
50
56
  if (['in', 'nin'].includes(op)) value = set({}, '$' + op, values)
51
57
  else if (op === 'between') value = { $gte: values[0], $lte: values[1] }
@@ -86,7 +92,7 @@ async function rebuildFilter (model, filter = {}, options = {}) {
86
92
  const hasTeamId = model.hasProperty('teamId')
87
93
  const teams = get(req, 'user.teams', [])
88
94
  const teamIds = teams.map(team => team.id + '')
89
- const aliases = teams.map(team => team.alias)
95
+ // const aliases = teams.map(team => team.alias)
90
96
  const q = { $and: [] }
91
97
 
92
98
  filter.query = filter.query ?? {}
@@ -99,10 +105,12 @@ async function rebuildFilter (model, filter = {}, options = {}) {
99
105
  return
100
106
  }
101
107
  if (hasSiteId) q.$and.push({ siteId: req.site.id + '' })
108
+ /*
102
109
  if (aliases.includes('administrator')) {
103
110
  filter.query = q
104
111
  return
105
112
  }
113
+ */
106
114
  if (isEmpty(req.user)) {
107
115
  if (q.$and.length === 0 && !allowEmpty) throw this.error('_emptyColumnQuery')
108
116
  filter.query = q
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "2.32.2",
3
+ "version": "2.32.3",
4
4
  "description": "Biz Suite for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 2026-06-12
4
4
 
5
+ - [2.32.3] Bug fix in ```hook.js```
6
+
7
+ ## 2026-06-12
8
+
5
9
  - [2.32.2] Bug fix in ```preRequest``` hook
6
10
 
7
11
  ## 2026-06-12