sumba 2.46.0 → 2.46.2

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.
@@ -1,9 +1,9 @@
1
1
  async function populateModelWithSite (path, ...args) {
2
2
  const { getModel } = this.app.dobo
3
3
  const { importPkg } = this.app.bajo
4
- const { isArray } = this.app.lib._
4
+ const { isArray, has } = this.app.lib._
5
5
  const confirm = await importPkg('bajoCli:@inquirer/confirm')
6
- let [modelName, alias] = args
6
+ let [modelName, alias, keys] = args
7
7
  if (!modelName) this.print.fatal('modelRequired')
8
8
  if (!alias) this.print.fatal('aliasRequired')
9
9
  const model = getModel(modelName, true)
@@ -15,6 +15,7 @@ async function populateModelWithSite (path, ...args) {
15
15
  this.app.exit()
16
16
  }
17
17
  if (alias.includes(',')) alias = alias.split(',').map(item => item.trim())
18
+ keys = keys ? keys.split(',').map(item => item.trim()) : []
18
19
  await this.app.dobo.start()
19
20
  try {
20
21
  const fixtures = await model.loadFixtures({ ignoreError: false, collectItems: true })
@@ -31,7 +32,11 @@ async function populateModelWithSite (path, ...args) {
31
32
  for (const fixture of fixtures) {
32
33
  const siteId = site.id + ''
33
34
  fixture.siteId = siteId
34
- const results = await model.findAllRecord({ query: { siteId, code: fixture.code } }, { fields: ['id'], trx })
35
+ const query = { siteId }
36
+ for (const key of keys) {
37
+ if (has(fixture, key)) query[key] = fixture[key]
38
+ }
39
+ const results = await model.findAllRecord({ query }, { fields: ['id'], trx })
35
40
  for (const rec of results) {
36
41
  await model.removeRecord(rec.id, { noCache: true, noResult: true, trx, throwNotFound: false })
37
42
  }
package/index.js CHANGED
@@ -615,6 +615,7 @@ async function factory (pkgName) {
615
615
  const { size } = fs.statSync(rec.jobQueue.result.file)
616
616
  await model.updateRecord(rec.id, { size, status: 'COMPLETE', jobQueue: rec.jobQueue })
617
617
  } catch (err) {
618
+ console.log(err)
618
619
  rec.jobQueue.error = err.message
619
620
  await model.updateRecord(rec.id, { status: 'FAIL', jobQueue: rec.jobQueue })
620
621
  }
@@ -1482,6 +1483,7 @@ async function factory (pkgName) {
1482
1483
  }
1483
1484
 
1484
1485
  const rules = orderBy(guards.filter(filterFn), ['field'])
1486
+
1485
1487
  for (const field of fields) {
1486
1488
  if (!model.getNonVirtualProperties(true).includes(field)) continue // or, should it throws exception instead?
1487
1489
  const inSetting = this.filterModelFromSetting({ model, field, options })
@@ -1578,22 +1580,18 @@ async function factory (pkgName) {
1578
1580
  return
1579
1581
  }
1580
1582
  if (hasSiteId) q.$and.push({ siteId: req.site.id + '' })
1581
- if (aliases.includes('administrator')) {
1582
- if (get(req, 'site.alias') === 'default') {
1583
- filter.query = q
1584
- return
1585
- }
1586
- const fields = keys(req.getSetting('sumba:queryGuard', {}))
1587
- const results = []
1588
- for (const field of fields) {
1589
- if (!model.hasProperty(field)) continue
1590
- const inSetting = this.filterModelFromSetting({ model, field, options })
1591
- if (inSetting.results.length > 0) results.push(...inSetting.results)
1592
- }
1593
- if (results.length > 0) q.$and.push(...results)
1583
+ if (aliases.includes('administrator') && (get(req, 'site.alias') === 'default')) {
1594
1584
  filter.query = q
1595
1585
  return
1596
1586
  }
1587
+ const fields = keys(req.getSetting('sumba:queryGuard', {}))
1588
+ const results = []
1589
+ for (const field of fields) {
1590
+ if (!model.hasProperty(field)) continue
1591
+ const inSetting = this.filterModelFromSetting({ model, field, options })
1592
+ if (inSetting.results.length > 0) results.push(...inSetting.results)
1593
+ }
1594
+ if (results.length > 0) q.$and.push(...results)
1597
1595
  if (isEmpty(req.user)) {
1598
1596
  if (q.$and.length === 0 && !allowEmpty) throw this.error('_emptyColumnQuery')
1599
1597
  filter.query = q
@@ -1619,8 +1617,10 @@ async function factory (pkgName) {
1619
1617
  else q.$and.push(condTeamId)
1620
1618
  } else if (hasUserId) q.$and.push(condUserId)
1621
1619
 
1622
- await this.runQueryGuard({ model, q, teamIds, options, allowEmpty })
1623
- await this.runAttribGuard({ model, teamIds, options })
1620
+ if (!aliases.includes('administrator')) {
1621
+ await this.runQueryGuard({ model, q, teamIds, options, allowEmpty })
1622
+ await this.runAttribGuard({ model, teamIds, options })
1623
+ }
1624
1624
  if (q.$and.length === 0 && !allowEmpty) throw this.error('_emptyColumnQuery')
1625
1625
  filter.query = q
1626
1626
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "2.46.0",
3
+ "version": "2.46.2",
4
4
  "description": "Biz Suite for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+
4
+ ## 2026-08-20
5
+
6
+ - [2.46.2] Bug fix in `execDownload()`
7
+
3
8
  ## 2026-08-13
4
9
 
5
10
  - [2.46.0] Add `populateModelWithSite` applet