sumba 2.32.4 → 2.33.1

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.
@@ -40,8 +40,13 @@ async function applyModelGuard ({ model, q, teamIds, options }) {
40
40
  for (const field of fields) {
41
41
  if (!model.getNonVirtualProperties(true).includes(field)) continue // or, should it throws exception instead?
42
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])))
43
+ for (const op of ['in', 'nin', 'inOrNull']) {
44
+ if (isEmpty(opValue[op]) || !isArray(opValue[op])) continue
45
+ if (op === 'inOrNull') {
46
+ const val = set({}, field, set({}, '$in', opValue[op]))
47
+ const nl = set({}, field, { $eq: null })
48
+ results.push({ $or: [val, nl] })
49
+ } else results.push(set({}, field, set({}, '$' + op, opValue[op])))
45
50
  }
46
51
  const prop = model.getProperty(field)
47
52
  const items = rules.filter(item => item.field === field)
@@ -175,7 +175,8 @@
175
175
  "siteIds": "Sites",
176
176
  "allTeams": "All Teams?",
177
177
  "condition": "Condition",
178
- "hiddenFields": "Hide Fields"
178
+ "hiddenFields": "Hide Fields",
179
+ "_immutable": "Immutable"
179
180
  },
180
181
  "validation": {
181
182
  "password": {
@@ -181,7 +181,8 @@
181
181
  "siteIds": "Situs",
182
182
  "allTeams": "Semua Tim?",
183
183
  "condition": "Kondisi",
184
- "hiddenFields": "Sembunyikan Kolom"
184
+ "hiddenFields": "Sembunyikan Kolom",
185
+ "_immutable": "Immutable"
185
186
  },
186
187
  "validation": {
187
188
  "password": {
@@ -7,7 +7,7 @@ async function country (opts = {}) {
7
7
  type: 'string',
8
8
  maxLength: 2,
9
9
  index: opts.index ?? true,
10
- required: opts.required,
10
+ required: opts.required ?? true,
11
11
  values: 'sumba:getCountriesValues',
12
12
  rules: opts.enforceRule ? ['uppercase', { rule: 'length', params: 2 }] : [],
13
13
  rulesMsg: opts.enforceRule ? { 'any.only': 'validCountryCodeRequired' } : undefined
@@ -5,10 +5,11 @@ async function siteId (opts = {}) {
5
5
  type: 'string',
6
6
  maxLength: 50,
7
7
  ref: {
8
- siteDetail: {
8
+ siteId: {
9
9
  model: 'SumbaSite',
10
10
  field: 'id',
11
- type: '1:1'
11
+ searchField: 'hostname',
12
+ fields: ['id', 'hostname']
12
13
  }
13
14
  },
14
15
  index: true
@@ -0,0 +1,15 @@
1
+ async function siteSetting () {
2
+ return {
3
+ common: {
4
+ widget: {
5
+ siteId: {
6
+ attr: {
7
+ url: 'sumba.restapi:/manage/site'
8
+ }
9
+ }
10
+ }
11
+ }
12
+ }
13
+ }
14
+
15
+ export default siteSetting
@@ -0,0 +1,12 @@
1
+ const action = {
2
+ method: ['GET', 'POST'],
3
+ title: 'siteSetting',
4
+ xSite: true,
5
+ handler: async function (req, reply) {
6
+ const { importModule } = this.app.bajo
7
+ const crudSkel = await importModule('waibuAdmin:/lib/crud-skel.js')
8
+ return await crudSkel.call(this, 'SumbaSiteSetting', req, reply)
9
+ }
10
+ }
11
+
12
+ export default action
@@ -29,7 +29,7 @@ const id = {
29
29
  schema.view.format = {
30
30
  createdAt: async function (val, rec) {
31
31
  const message = this.app.bajoMarkdown ? this.app.bajoMarkdown.parseContent(rec.message) : rec.message
32
- const isMe = rec.userId === req.user.id
32
+ const isMe = rec.userId === req.user.id + ''
33
33
  const sentence = `<c:div margin="bottom-3"><c:badge background="color:${isMe ? 'primary' : 'secondary'}" t:content="${isMe ? 'you' : 'us'}" /> <small>${req.format(val, 'datetime')}</small></c:div>`
34
34
  return (await this.component.buildSentence(sentence)) + message
35
35
  }
package/index.js CHANGED
@@ -351,6 +351,7 @@ async function factory (pkgName) {
351
351
  title: 'xSite',
352
352
  children: [
353
353
  { title: 'allSites', href: `waibuAdmin:/${prefix}/x/site/:action`, params },
354
+ { title: 'siteSetting', href: `waibuAdmin:/${prefix}/x/site-setting/:action`, params },
354
355
  sessionMenu
355
356
  ]
356
357
  })
@@ -744,7 +745,6 @@ async function factory (pkgName) {
744
745
  const { merge, isEmpty, camelCase, get } = this.app.lib._
745
746
  const { routePath } = this.app.waibu
746
747
  const userId = get(req, 'session.userId')
747
-
748
748
  const setUser = async () => {
749
749
  if (!userId) return
750
750
  try {
@@ -805,7 +805,8 @@ async function factory (pkgName) {
805
805
  checkXSite = async (req, reply) => {
806
806
  const { get } = this.app.lib._
807
807
  if (!this.config.multiSite.enabled) return
808
- if (!get(req, 'routeOptions.config.xSite')) return
808
+ const config = get(req, 'routeOptions.config')
809
+ if (!get(config, 'xSite') || ['/dashboard'].includes(config.pathSrc)) return
809
810
  if (!get(req, 'user.isXSiteAdmin')) throw this.error('accessDenied', { statusCode: 403 })
810
811
  }
811
812
 
package/lib/get-site.js CHANGED
@@ -23,7 +23,7 @@ async function getSite (input, byId = false) {
23
23
  }
24
24
  site.setting = defaultsDeep({}, nsSetting, defSetting)
25
25
  // additional fields
26
- const country = await this.app.dobo.getModel('CdbCountry').getRecord(site.country, { noHook: true })
26
+ const country = await this.app.dobo.getModel('CdbCountry').getRecord(site.country, { noMagic: true })
27
27
  site.countryName = (country ?? {}).name ?? site.country
28
28
  }
29
29
 
package/lib/get-user.js CHANGED
@@ -2,12 +2,14 @@ export async function mergeTeam (user, req) {
2
2
  const { map, pick } = this.app.lib._
3
3
  const { getModel } = this.app.dobo
4
4
  user.teams = []
5
- const query = { userId: user.id, siteId: user.siteId, status: 'ACTIVE' }
5
+ const query = { userId: user.id + '', siteId: user.siteId, status: 'ACTIVE' }
6
6
  let mdl = getModel('SumbaTeamUser')
7
7
  const userTeam = await mdl.findAllRecord({ query })
8
8
  if (userTeam.length === 0) return
9
9
  delete query.userId
10
- query.id = { $in: map(userTeam, 'teamId') }
10
+ const idProp = mdl.getProperty('id')
11
+ const $in = userTeam.map(item => ['integer', 'smallint'].includes(idProp.type) ? parseInt(item.teamId) : item.teamId)
12
+ query.id = { $in }
11
13
  mdl = getModel('SumbaTeam')
12
14
  const teams = await mdl.findAllRecord({ query })
13
15
  if (teams.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "2.32.4",
3
+ "version": "2.33.1",
4
4
  "description": "Biz Suite for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-06-17
4
+
5
+ - [2.33.0] Add ```Site Setting``` in ```Cross-Site```
6
+ - [2.33.0] Bug fix in ```hook.js```
7
+ - [2.33.0] Bug fix in ```sumba:siteId``` feature
8
+ - [2.33.1] Bug fix in ```checkUser()```, ```checkTeam()``` & ```checkXSite()```
9
+ - [2.33.1] Bug fix in ```sumba:country``` feature
10
+
3
11
  ## 2026-06-15
4
12
 
5
13
  - [2.32.3] Bug fix in ```hook.js```