sumba 2.22.1 → 2.24.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/bajo/hook/bajo.extend@after-read-config.js +13 -0
- package/extend/bajo/hook/dobo.sumba-route-guard@after-transaction.js +6 -0
- package/extend/bajo/hook/dobo@before-count-record.js +3 -3
- package/extend/bajo/hook/dobo@before-driver-create-record.js +17 -0
- package/extend/bajo/hook/dobo@before-driver-find-all-record.js +13 -0
- package/extend/bajo/hook/dobo@before-driver-find-record.js +96 -0
- package/extend/bajo/hook/dobo@before-driver-get-record.js +22 -0
- package/extend/bajo/hook/dobo@before-driver-remove-record.js +10 -0
- package/extend/bajo/hook/dobo@before-driver-update-record.js +10 -0
- package/extend/bajo/hook/waibu-mpa@pre-parsing.js +5 -4
- package/extend/bajo/hook/waibu-rest-api@pre-parsing.js +5 -4
- package/extend/bajo/hook/waibu-static@pre-parsing.js +5 -4
- package/extend/bajo/hook/waibu@after-app-boot.js +5 -23
- package/extend/bajo/hook/waibu@pre-parsing.js +0 -5
- package/extend/bajo/intl/en-US.json +13 -6
- package/extend/bajo/intl/id.json +14 -2
- package/extend/dobo/feature/team-ids.js +20 -0
- package/extend/dobo/fixture/route-guard.js +26 -0
- package/extend/dobo/model/attrib-guard.js +36 -0
- package/extend/dobo/model/model-guard.js +37 -0
- package/extend/dobo/model/route-guard.js +45 -0
- package/extend/waibuDb/schema/attrib-guard.js +15 -0
- package/extend/waibuDb/schema/model-guard.js +15 -0
- package/extend/waibuDb/schema/route-guard.js +15 -0
- package/extend/waibuDb/schema/user.js +19 -26
- package/extend/waibuMpa/extend/waibuAdmin/route/all-sites/@action.js +1 -1
- package/extend/waibuMpa/extend/waibuAdmin/route/attrib-guard/@action.js +11 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/cache/@action.js +1 -1
- package/extend/waibuMpa/extend/waibuAdmin/route/model-guard/@action.js +11 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/reset-user-password.js +2 -1
- package/extend/waibuMpa/extend/waibuAdmin/route/route-guard/@action.js +11 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/session/@action.js +1 -1
- package/extend/waibuRestApi/route/manage/route-guard/model-builder.json +4 -0
- package/index.js +37 -47
- package/lib/get-user.js +4 -4
- package/lib/util.js +53 -74
- package/package.json +1 -1
- package/wiki/CHANGES.md +11 -0
- package/extend/bajo/hook/dobo@before-create-record.js +0 -17
- package/extend/bajo/hook/dobo@before-find-record.js +0 -63
- package/extend/bajo/hook/dobo@before-get-record.js +0 -23
- package/extend/bajo/hook/dobo@before-remove-record.js +0 -10
- package/extend/bajo/hook/dobo@before-update-record.js +0 -10
- package/extend/sumba/route-guard/anonymous.json +0 -10
- package/extend/sumba/route-guard/secure.json +0 -8
- package/lib/collect.js +0 -52
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { checker } from './dobo@before-get-record.js'
|
|
2
|
-
|
|
3
|
-
const doboBeforeRemoveRecord = {
|
|
4
|
-
level: 1000,
|
|
5
|
-
handler: async function (modelName, id, options = {}) {
|
|
6
|
-
await checker.call(this, modelName, id, options.req)
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default doboBeforeRemoveRecord
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { checker } from './dobo@before-get-record.js'
|
|
2
|
-
|
|
3
|
-
const doboBeforeUpdateRecord = {
|
|
4
|
-
level: 1000,
|
|
5
|
-
handler: async function (modelName, id, body, options = {}) {
|
|
6
|
-
await checker.call(this, modelName, id, options)
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default doboBeforeUpdateRecord
|
package/lib/collect.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export async function collect ({ type = '', handler, container, file, ns, dir }) {
|
|
2
|
-
const { readConfig } = this.app.bajo
|
|
3
|
-
const { parseRouteGuard } = this
|
|
4
|
-
const { camelCase, find, isEmpty } = this.app.lib._
|
|
5
|
-
let items = await readConfig(file, { ns, baseNs: this.ns, defValue: [] })
|
|
6
|
-
if (isEmpty(items)) items = []
|
|
7
|
-
for (let item of items) {
|
|
8
|
-
item = parseRouteGuard(item)
|
|
9
|
-
if (!item) continue
|
|
10
|
-
if (handler) await handler.call(this, item)
|
|
11
|
-
const guards = this[camelCase(`${type} ${item.reverse ? 'Neg' : ''} ${container}`)]
|
|
12
|
-
delete item.reverse
|
|
13
|
-
if (find(guards, { path: item.path })) continue
|
|
14
|
-
guards.push(item)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function collectHandler (item, keys = []) {
|
|
19
|
-
const { isString } = this.app.lib._
|
|
20
|
-
for (const k of keys) {
|
|
21
|
-
item[k] = item[k] ?? []
|
|
22
|
-
if (isString(item[k])) item[k] = item[k].split(',')
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function collectRoutes (type) {
|
|
27
|
-
const { eachPlugins } = this.app.bajo
|
|
28
|
-
const me = this
|
|
29
|
-
|
|
30
|
-
function handler (item) {
|
|
31
|
-
collectHandler.call(this, item, ['methods'])
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
await eachPlugins(async function ({ file, dir }) {
|
|
35
|
-
const { ns } = this
|
|
36
|
-
await collect.call(me, { type, container: 'Routes', handler, file, ns, dir })
|
|
37
|
-
}, { glob: `route-guard/${type}.*`, prefix: this.ns })
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function collectTeam () {
|
|
41
|
-
const { eachPlugins } = this.app.bajo
|
|
42
|
-
const me = this
|
|
43
|
-
|
|
44
|
-
function handler (item) {
|
|
45
|
-
collectHandler.call(this, item, ['methods', 'teams', 'features'])
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
await eachPlugins(async function ({ file, dir }) {
|
|
49
|
-
const { ns } = this
|
|
50
|
-
await collect.call(me, { type: 'team', container: 'Routes', handler, file, ns, dir })
|
|
51
|
-
}, { glob: 'route-guard/team.*', prefix: this.ns })
|
|
52
|
-
}
|