sumba 2.19.3 → 2.20.0

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.
@@ -0,0 +1,10 @@
1
+ [{
2
+ "path": "sumba:/user/**/*",
3
+ "methods": ["*"]
4
+ }, {
5
+ "path": "sumba:/signin",
6
+ "methods": ["*"]
7
+ }, {
8
+ "path": "sumba.restapi:/user/access-token/**/*",
9
+ "methods": ["*"]
10
+ }]
@@ -0,0 +1,8 @@
1
+ [
2
+ "sumba:/your-stuff/**/*",
3
+ "sumba:/signout",
4
+ "sumba:/help/trouble-tickets/**/*",
5
+ "sumba.restapi:/user/api-key",
6
+ "sumba.restapi:/your-stuff/**/*",
7
+ "sumba.restapi:/manage/**/*"
8
+ ]
package/index.js CHANGED
@@ -472,7 +472,7 @@ async function factory (pkgName) {
472
472
  getCountriesValues = async () => {
473
473
  const { getModel } = this.app.dobo
474
474
  const model = getModel('CdbCountry')
475
- const items = await model.findAllRecord()
475
+ const items = await model.findAllRecord({}, { noMagic: true, dataOnly: true })
476
476
  return items.map(item => ({ value: item.id, text: item.name }))
477
477
  }
478
478
 
@@ -537,6 +537,26 @@ async function factory (pkgName) {
537
537
  return password
538
538
  }
539
539
 
540
+ parseRouteGuard = item => {
541
+ const { routePath, routePathHandlers } = this.app.waibu
542
+ const { isString, isEmpty } = this.app.lib._
543
+ if (isString(item)) {
544
+ let [path, methods] = item.split('|').map(i => i.trim())
545
+ methods = isEmpty(methods) ? ['*'] : methods.split(',').map(i => i.trim())
546
+ item = { path, methods }
547
+ }
548
+ item.methods = item.methods ?? ['*']
549
+ if (item.methods.includes('*')) item.methods = ['*']
550
+ const [, routeHandler] = item.path.split(':')[0].split('.')
551
+ if (!isEmpty(routeHandler) && !routePathHandlers[routeHandler]) return
552
+ const rns = isEmpty(routeHandler) ? 'waibuMpa' : routePathHandlers[routeHandler].ns
553
+ if (!this.app[rns]) return
554
+ item.inverse = item.path[0] === '!'
555
+ if (item.inverse) item.path = item.path.slice(1)
556
+ item.path = routePath(item.path, { defFormat: false })
557
+ return item
558
+ }
559
+
540
560
  createNewSite = createNewSite
541
561
  removeSite = removeSite
542
562
  getSite = getSite
package/lib/collect.js CHANGED
@@ -1,22 +1,15 @@
1
1
  export async function collect ({ type = '', handler, container, file, ns, dir }) {
2
2
  const { readConfig } = this.app.bajo
3
- const { routePath, routePathHandlers } = this.app.waibu
4
- const { camelCase, find, isString, isEmpty } = this.app.lib._
5
- let items = await readConfig(file, { ignoreError: true })
3
+ const { parseRouteGuard } = this
4
+ const { camelCase, find, isEmpty } = this.app.lib._
5
+ let items = await readConfig(file, { ns, baseNs: this.ns, defValue: [] })
6
6
  if (isEmpty(items)) items = []
7
7
  for (let item of items) {
8
- if (isString(item)) item = { path: item }
9
- const routeHandler = item.routeHandler
10
- delete item.routeHandler
11
- if (!isEmpty(routeHandler) && !routePathHandlers[routeHandler]) continue
12
- const rns = routeHandler ? routePathHandlers[routeHandler].ns : 'waibuMpa'
13
- if (!this.app[rns]) continue
14
- const isNeg = item.path[0] === '!'
15
- if (isNeg) item.path = item.path.slice(1)
16
- item.path = routePath(`${ns}${routeHandler ? ('.' + routeHandler) : ''}:${item.path}`, { defFormat: false })
17
- item.methods = item.methods ?? ['*']
8
+ item = parseRouteGuard(item)
9
+ if (!item) continue
18
10
  if (handler) await handler.call(this, item)
19
- const guards = this[camelCase(`${type} ${isNeg ? 'Neg' : ''} ${container}`)]
11
+ const guards = this[camelCase(`${type} ${item.reverse ? 'Neg' : ''} ${container}`)]
12
+ delete item.reverse
20
13
  if (find(guards, { path: item.path })) continue
21
14
  guards.push(item)
22
15
  }
@@ -41,7 +34,7 @@ export async function collectRoutes (type) {
41
34
  await eachPlugins(async function ({ file, dir }) {
42
35
  const { ns } = this
43
36
  await collect.call(me, { type, container: 'Routes', handler, file, ns, dir })
44
- }, { glob: `route/${type}.*`, prefix: this.ns })
37
+ }, { glob: `route-guard/${type}.*`, prefix: this.ns })
45
38
  }
46
39
 
47
40
  export async function collectTeam () {
@@ -32,7 +32,7 @@ export async function getAllFixtures (alias) {
32
32
  const file = `${overrideBase}/${kebabCase(m)}`
33
33
  let fixtures = (await model.loadFixtures({ collectItems: true, noLookup: true })) ?? []
34
34
  if (files.includes(file)) {
35
- const items = await readConfig(file, { ignoreError: true, defValue: [] })
35
+ const items = await readConfig(file, { defValue: [] })
36
36
  if (!isEmpty(items)) fixtures = items
37
37
  }
38
38
  if (!Array.isArray(fixtures)) fixtures = [fixtures]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "2.19.3",
3
+ "version": "2.20.0",
4
4
  "description": "Biz Suite for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-04-23
4
+
5
+ - [2.20.0] Add ```parseRouteGuard()```
6
+ - [2.20.0] Change endpoint ```sumba/route``` to ```sumba/route-guard```
7
+ - [2.20.0] Deep merging of route guards
8
+
9
+ ## 2026-04-21
10
+
11
+ - [2.19.4] Bug fix in ```getCountriesValues()```
12
+
3
13
  ## 2026-04-19
4
14
 
5
15
  - [2.19.3] Update all widgets ```wdb-table``` to ```wdb-data-table```
@@ -1,11 +0,0 @@
1
- [{
2
- "path": "/user/**/*",
3
- "methods": ["*"]
4
- }, {
5
- "path": "/signin",
6
- "methods": ["*"]
7
- }, {
8
- "path": "/user/access-token/**/*",
9
- "routeHandler": "restapi",
10
- "methods": ["*"]
11
- }]
@@ -1,14 +0,0 @@
1
- [
2
- "/your-stuff/**/*",
3
- "/signout",
4
- "/help/trouble-tickets/**/*",
5
- {
6
- "path": "/user/api-key",
7
- "routeHandler": "restapi"
8
- }, {
9
- "path": "/your-stuff/**/*",
10
- "routeHandler": "restapi"
11
- }, {
12
- "path": "/manage/**/*",
13
- "routeHandler": "restapi"
14
- }]