sumba 2.33.2 → 2.33.4

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.
@@ -127,6 +127,7 @@ async function rebuildFilter (model, filter = {}, options = {}) {
127
127
  const fields = keys(req.getSetting('sumba:modelGuard', {}))
128
128
  const results = []
129
129
  for (const field of fields) {
130
+ if (!model.hasProperty(field)) continue
130
131
  const inSetting = filterModelFromSetting.call(this, { model, field, options })
131
132
  if (inSetting.results.length > 0) results.push(...inSetting.results)
132
133
  }
@@ -140,6 +140,7 @@
140
140
  "xSiteAdminArea": "Cross-Site Admin Area",
141
141
  "x": "Cross-Site",
142
142
  "misc": "Miscellaneous",
143
+ "populateRouteGuard": "Populate route guard",
143
144
  "field": {
144
145
  "currentPassword": "Current Password",
145
146
  "newPassword": "New Password",
@@ -146,6 +146,7 @@
146
146
  "xSiteAdminArea": "Area Admin Antar Situs",
147
147
  "x": "Antar Situs",
148
148
  "misc": "Lain-lain",
149
+ "populateRouteGuard": "Isikan pelindung rute",
149
150
  "field": {
150
151
  "currentPassword": "Kata Sandi Saat Ini",
151
152
  "newPassword": "Kata Sandi Baru",
package/index.js CHANGED
@@ -190,19 +190,19 @@ async function factory (pkgName) {
190
190
  }
191
191
  if (this.config.xSiteAdmins.length === 0) {
192
192
  const site = await getModel('SumbaSite').findOneRecord({ query: { alias: 'default' } }, { noMagic: true })
193
- const user = await getModel('SumbaUser').findOneRecord({ query: { username: 'admin', siteId: site.id } }, { noMagic: true })
193
+ const user = await getModel('SumbaUser').findOneRecord({ query: { username: 'admin', siteId: site.id + '' } }, { noMagic: true })
194
194
  this.config.xSiteAdmins.push(`${site.alias}:${user.username}`)
195
195
  }
196
196
  }
197
197
 
198
- populateRouteGuards = async () => {
198
+ populateRouteGuards = async (sites) => {
199
199
  const { isString, get, difference } = this.app.lib._
200
200
  const { pascalCase } = this.app.lib.aneka
201
201
  const { eachPlugins, readConfig, breakNsPath } = this.app.bajo
202
202
  const { getModel } = this.app.dobo
203
203
 
204
204
  const allNs = this.app.getAllNs()
205
- const sites = await getModel('SumbaSite').findAllRecord({ query: { status: 'ACTIVE' } }, { noMagic: true, dataOnly: true, fields: ['id', 'hostname'] })
205
+ if (!sites) sites = await getModel('SumbaSite').findAllRecord({ query: { status: 'ACTIVE' } }, { noMagic: true, dataOnly: true, fields: ['id', 'hostname'] })
206
206
 
207
207
  const sanitize = (item, ns) => {
208
208
  if (isString(item)) item = { path: item }
@@ -257,13 +257,13 @@ async function factory (pkgName) {
257
257
  const paths = routes.map(item => item.path)
258
258
  const model = getModel(pascalCase(`Sumba ${type} Guard`))
259
259
  for (const site of sites) {
260
- const query = { path: { $in: paths }, siteId: site.id }
260
+ const query = { path: { $in: paths }, siteId: site.id + '' }
261
261
  const recs = await model.findAllRecord({ query }, { noMagic: true, dataOnly: true, fields: ['path', 'status'] })
262
262
  const spaths = difference(paths, recs.map(rec => rec.path))
263
263
  for (const path of spaths) {
264
264
  const body = cloneDeep(routes.find(r => r.path === path))
265
265
  body.status = 'ACTIVE'
266
- body.siteId = site.id
266
+ body.siteId = site.id + ''
267
267
  await model.sanitizeFixture({ body, lookupValue: body })
268
268
  try {
269
269
  await model.createRecord(body, { noMagic: true, noReturn: true })
@@ -66,10 +66,12 @@ export async function createRefs (site, data, options, verbose) {
66
66
  const val = f[key]
67
67
  if (isString(val) && val.slice(0, 2) === '?:') f[key] = await mdl._simpleLookup(val.slice(2), lv, options)
68
68
  }
69
- await mdl.createRecord(f, options)
69
+ await mdl.createRecord(f, { ...options, noFlash: true })
70
70
  }
71
71
  if (verbose) this.print.succeed('writingModel%s%s', mdl.name, fixtures.length)
72
72
  }
73
+ if (verbose) this.print.succeed('populateRouteGuard')
74
+ await this.populateRouteGuards([site])
73
75
  }
74
76
 
75
77
  async function createNewSite (alias, hostname, verbose) {
package/lib/get-site.js CHANGED
@@ -12,7 +12,7 @@ async function getSite (input, byId = false) {
12
12
  const names = this.app.getAllNs()
13
13
  const query = {
14
14
  ns: { $in: names },
15
- siteId: site.id
15
+ siteId: site.id + ''
16
16
  }
17
17
  const all = await this.app.dobo.getModel('SumbaSiteSetting').findAllRecord({ query })
18
18
  for (const ns of names) {
package/lib/get-user.js CHANGED
@@ -78,7 +78,7 @@ export async function getUserByUsernamePassword (username = '', password = '', r
78
78
  await model.validate({ username, password }, null, { partial: true, ns: ['sumba', 'dobo'], fields: ['username', 'password'] })
79
79
  const bcrypt = await importPkg('bajoExtra:bcrypt')
80
80
 
81
- const query = { username, provider: 'local', siteId: req.site.id }
81
+ const query = { username, provider: 'local', siteId: req.site.id + '' }
82
82
  const user = await model.findOneRecord({ query }, { req, forceNoHidden: true, noHook: true, noDriverHook: true })
83
83
  if (!user) throw this.error('validationError', { details: [{ field: 'username', error: 'Unknown username' }], statusCode: 401 })
84
84
  if (user.status !== 'ACTIVE') throw this.error('validationError', { details: ['User is inactive or temporarily disabled'], statusCode: 401 })
@@ -7,12 +7,12 @@ export async function removeRefs (site, options, verbose) {
7
7
  }).map(m => m.name)
8
8
  for (const m of models) {
9
9
  const mdl = getModel(m)
10
- const rows = await mdl.findAllRecord({ query: { siteId: site.id } }, { ...options, dataOnly: true })
10
+ const rows = await mdl.findAllRecord({ query: { siteId: site.id + '' } }, { ...options, dataOnly: true })
11
11
  const ids = rows.map(item => item.id)
12
12
  // TODO: backup
13
13
  if (ids.length === 0) continue
14
14
  for (const id of ids) {
15
- await mdl.removeRecord(id, { noReturn: true, ...options })
15
+ await mdl.removeRecord(id, { noReturn: true, ...options, noFlash: true })
16
16
  }
17
17
  if (verbose) this.print.succeed('removedFrom%s%s', mdl.name, ids.length)
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "2.33.2",
3
+ "version": "2.33.4",
4
4
  "description": "Biz Suite for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -3,6 +3,8 @@
3
3
  ## 2026-06-18
4
4
 
5
5
  - [2.33.2] Bug fix in ```hook.js```
6
+ - [2.33.3] Bug fix in ```hook.js```
7
+ - [2.33.4] Bug fix in ```create-new-site.js```
6
8
 
7
9
  ## 2026-06-17
8
10