sumba 2.19.4 → 2.21.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.
- package/extend/sumba/route-guard/anonymous.json +10 -0
- package/extend/sumba/route-guard/secure.json +8 -0
- package/extend/waibuDb/schema/team-setting.js +0 -5
- package/extend/waibuDb/schema/user-setting.js +0 -8
- package/extend/waibuDb/schema/user.js +0 -6
- package/extend/waibuMpa/extend/waibuAdmin/route/site.js +1 -2
- package/extend/waibuMpa/route/your-stuff/profile/edit.js +1 -1
- package/extend/waibuMpa/route/your-stuff/profile.js +1 -1
- package/index.js +20 -0
- package/lib/collect.js +8 -15
- package/lib/create-new-site.js +1 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +14 -0
- package/extend/sumba/route/anonymous.json +0 -11
- package/extend/sumba/route/secure.json +0 -14
|
@@ -5,14 +5,6 @@ async function teamUser ({ req } = {}) {
|
|
|
5
5
|
{ name: 'meta', fields: ['id', 'userId', 'createdAt', 'updatedAt'] },
|
|
6
6
|
{ name: 'general', fields: ['ns', 'key', 'value'] }
|
|
7
7
|
],
|
|
8
|
-
calcFields: [
|
|
9
|
-
{ name: 'user', type: 'string' }
|
|
10
|
-
],
|
|
11
|
-
formatValue: {
|
|
12
|
-
user: (val, rec) => {
|
|
13
|
-
return rec._ref.user.name
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
8
|
widget: {
|
|
17
9
|
userId: {
|
|
18
10
|
component: 'form-select-ext',
|
|
@@ -7,12 +7,6 @@ async function user ({ req } = {}) {
|
|
|
7
7
|
{ name: 'address', fields: ['address1:12', 'address2:12', 'city:6-md 8-sm', 'zipCode:2-md 4-sm', 'provinceState:4-md', 'country:6-md', 'phone:6-md', 'website:12'] },
|
|
8
8
|
{ name: 'socialMedia', fields: ['socX:3-md 6-sm', 'socInstagram:3-md 6-sm', 'socFacebook:3-md 6-sm', 'socLinkedIn:3-md 6-sm'] }
|
|
9
9
|
],
|
|
10
|
-
formatValue: {
|
|
11
|
-
token: async function (val, rec) {
|
|
12
|
-
const { hash } = this.app.bajoExtra
|
|
13
|
-
return await hash(rec.salt)
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
10
|
widget: {
|
|
17
11
|
token: {
|
|
18
12
|
component: 'form-plaintext'
|
|
@@ -10,7 +10,7 @@ const profile = {
|
|
|
10
10
|
const { omit, pick } = this.app.lib._
|
|
11
11
|
const { hash } = this.app.bajoExtra
|
|
12
12
|
|
|
13
|
-
const options = { forceNoHidden: ['token'], noHook: true, noCache: true,
|
|
13
|
+
const options = { forceNoHidden: ['token'], noHook: true, noCache: true, fmt: true }
|
|
14
14
|
const mdl = this.app.dobo.getModel(model)
|
|
15
15
|
|
|
16
16
|
const { schema } = await getSchemaExt(model, 'edit', { ...options, args: [{ req, model: mdl }] })
|
|
@@ -3,7 +3,7 @@ const profile = {
|
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
4
|
const { hash } = this.app.bajoExtra
|
|
5
5
|
const { getRecord } = this.app.waibuDb
|
|
6
|
-
const options = { forceNoHidden: ['token'], noHook: true, noCache: true, attachment: true, mimeType: true,
|
|
6
|
+
const options = { forceNoHidden: ['token'], noHook: true, noCache: true, attachment: true, mimeType: true, fmt: true }
|
|
7
7
|
const resp = await getRecord({ model: 'SumbaUser', req, id: req.user.id, options })
|
|
8
8
|
const form = resp.data
|
|
9
9
|
form.token = await hash(form.salt)
|
package/index.js
CHANGED
|
@@ -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 {
|
|
4
|
-
const { camelCase, find,
|
|
5
|
-
let items = await readConfig(file, {
|
|
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
|
-
|
|
9
|
-
|
|
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} ${
|
|
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 () {
|
package/lib/create-new-site.js
CHANGED
|
@@ -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, {
|
|
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
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-04-25
|
|
4
|
+
|
|
5
|
+
- [2.21.0] Change options to format value using the new key set by dobo
|
|
6
|
+
- [2.21.0] Remove ```options.retainOriginalValue``` since it is not needed anymore
|
|
7
|
+
- [2.21.0] Remove ```property.formatValue``` from all properties
|
|
8
|
+
- [2.21.0] Remove ```schema.formatValue``` from all schemas
|
|
9
|
+
- [2.21.0] Remove ```schema.calcFields``` from all schemas
|
|
10
|
+
|
|
11
|
+
## 2026-04-23
|
|
12
|
+
|
|
13
|
+
- [2.20.0] Add ```parseRouteGuard()```
|
|
14
|
+
- [2.20.0] Change endpoint ```sumba/route``` to ```sumba/route-guard```
|
|
15
|
+
- [2.20.0] Deep merging of route guards
|
|
16
|
+
|
|
3
17
|
## 2026-04-21
|
|
4
18
|
|
|
5
19
|
- [2.19.4] Bug fix in ```getCountriesValues()```
|
|
@@ -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
|
-
}]
|