sumba 2.0.0 → 2.1.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/.github/FUNDING.yml +13 -0
- package/.github/workflows/repo-lockdown.yml +24 -0
- package/.jsdoc.conf.json +45 -0
- package/LICENSE +1 -1
- package/README.md +40 -7
- package/docs/Sumba.html +3 -0
- package/docs/data/search.json +1 -0
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/global.html +3 -0
- package/docs/index.html +3 -0
- package/docs/index.js.html +538 -0
- package/docs/scripts/core.js +726 -0
- package/docs/scripts/core.min.js +23 -0
- package/docs/scripts/resize.js +90 -0
- package/docs/scripts/search.js +265 -0
- package/docs/scripts/search.min.js +6 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/scripts/third-party/fuse.js +9 -0
- package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/scripts/third-party/hljs-original.js +5171 -0
- package/docs/scripts/third-party/hljs.js +1 -0
- package/docs/scripts/third-party/popper.js +5 -0
- package/docs/scripts/third-party/tippy.js +1 -0
- package/docs/scripts/third-party/tocbot.js +672 -0
- package/docs/scripts/third-party/tocbot.min.js +1 -0
- package/docs/static/bitcoin.jpeg +0 -0
- package/docs/static/home.md +25 -0
- package/docs/static/logo-ecosystem.png +0 -0
- package/docs/static/logo.png +0 -0
- package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/styles/clean-jsdoc-theme.min.css +1 -0
- package/extend/bajo/hook/{dobo.sumba-contact-form@after-record-create.js → dobo.sumba-contact-form@after-create-record.js} +3 -3
- package/extend/bajo/hook/{dobo.sumba-contact-form@before-record-create.js → dobo.sumba-contact-form@before-create-record.js} +3 -3
- package/extend/bajo/hook/{dobo.sumba-user@after-record-create.js → dobo.sumba-user@after-create-record.js} +3 -3
- package/extend/bajo/hook/dobo.sumba-user@after-record-validation.js +3 -3
- package/extend/bajo/hook/{dobo.sumba-user@after-record-update.js → dobo.sumba-user@after-update-record.js} +5 -5
- package/extend/bajo/hook/{dobo.sumba-user@before-record-create.js → dobo.sumba-user@before-create-record.js} +2 -2
- package/extend/bajo/hook/dobo.sumba-user@before-record-validation.js +3 -3
- package/extend/bajo/hook/{dobo.sumba-user@before-record-update.js → dobo.sumba-user@before-update-record.js} +2 -2
- package/extend/bajo/hook/dobo@before-count-record.js +8 -0
- package/extend/bajo/hook/{dobo@before-record-create.js → dobo@before-create-record.js} +6 -6
- package/extend/bajo/hook/dobo@before-find-one-record.js +8 -0
- package/extend/bajo/hook/{dobo@before-record-find.js → dobo@before-find-record.js} +10 -10
- package/extend/bajo/hook/dobo@before-get-record.js +23 -0
- package/extend/bajo/hook/dobo@before-remove-record.js +10 -0
- package/extend/bajo/hook/dobo@before-update-record.js +10 -0
- package/extend/bajo/hook/waibu-mpa.sumba@after-build-locals.js +0 -0
- package/extend/bajo/hook/waibu-mpa@pre-parsing.js +0 -0
- package/extend/bajo/hook/waibu-rest-api@pre-parsing.js +0 -0
- package/extend/bajo/hook/waibu-static@pre-parsing.js +0 -0
- package/extend/bajo/hook/waibu@after-app-boot.js +2 -2
- package/extend/bajo/hook/waibu@after-create-context.js +0 -0
- package/extend/bajo/hook/waibu@on-request.js +0 -0
- package/extend/bajo/intl/en-US.json +1 -0
- package/extend/bajo/intl/id.json +0 -0
- package/extend/bajoTemplate/layout/centered.html +0 -0
- package/extend/bajoTemplate/layout/default.html +0 -0
- package/extend/bajoTemplate/layout/error.html +0 -0
- package/extend/bajoTemplate/layout/info.html +0 -0
- package/extend/bajoTemplate/partial/403.html +0 -0
- package/extend/bajoTemplate/partial/_admin/reset-user-password.html +0 -0
- package/extend/bajoTemplate/partial/_mail/help-contact-form.html +0 -0
- package/extend/bajoTemplate/partial/_mail/help-contact-form.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/mystuff-change-password.html +0 -0
- package/extend/bajoTemplate/partial/_mail/mystuff-change-password.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/mystuff-reset-api-key.html +0 -0
- package/extend/bajoTemplate/partial/_mail/mystuff-reset-api-key.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-activation-success.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-activation-success.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-forgot-password-changed.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-forgot-password-changed.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-forgot-password-link.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-forgot-password-link.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-signup-success-active.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-signup-success-active.id.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-signup-success.html +0 -0
- package/extend/bajoTemplate/partial/_mail/user-signup-success.id.html +0 -0
- package/extend/bajoTemplate/partial/api-key-modal.html +0 -0
- package/extend/bajoTemplate/partial/app-launcher.html +0 -0
- package/extend/bajoTemplate/partial/help/contact-form/form.html +0 -0
- package/extend/bajoTemplate/partial/help/contact-form/success.html +0 -0
- package/extend/bajoTemplate/partial/help/trouble-tickets/add.html +0 -0
- package/extend/bajoTemplate/partial/help/trouble-tickets/details.html +0 -0
- package/extend/bajoTemplate/partial/help/trouble-tickets/list.html +0 -0
- package/extend/bajoTemplate/partial/layout/address.html +0 -0
- package/extend/bajoTemplate/partial/layout/breadcrumb.html +0 -0
- package/extend/bajoTemplate/partial/layout/footer.html +0 -0
- package/extend/bajoTemplate/partial/layout/more-info.html +0 -0
- package/extend/bajoTemplate/partial/layout/more-info.id.html +0 -0
- package/extend/bajoTemplate/partial/layout/navbar.html +0 -0
- package/extend/bajoTemplate/partial/layout/sidebar.html +0 -0
- package/extend/bajoTemplate/partial/layout/socmed.html +0 -0
- package/extend/bajoTemplate/partial/list-item/change-password.html +0 -0
- package/extend/bajoTemplate/partial/list-item/forgot-password.html +0 -0
- package/extend/bajoTemplate/partial/list-item/goto-home.html +0 -0
- package/extend/bajoTemplate/partial/list-item/member-links.html +0 -0
- package/extend/bajoTemplate/partial/list-item/oauth-signin.html +0 -0
- package/extend/bajoTemplate/partial/list-item/signin.html +0 -0
- package/extend/bajoTemplate/partial/list-item/signout.html +0 -0
- package/extend/bajoTemplate/partial/list-item/user-signup.html +0 -0
- package/extend/bajoTemplate/partial/list-item/your-profile.html +0 -0
- package/extend/bajoTemplate/partial/signin.html +0 -0
- package/extend/bajoTemplate/partial/signout.html +0 -0
- package/extend/bajoTemplate/partial/user/activation.html +0 -0
- package/extend/bajoTemplate/partial/user/forgot-password-nomail.id.md +0 -0
- package/extend/bajoTemplate/partial/user/forgot-password-nomail.md +0 -0
- package/extend/bajoTemplate/partial/user/forgot-password.html +0 -0
- package/extend/bajoTemplate/partial/user/fpl-invalid.html +0 -0
- package/extend/bajoTemplate/partial/user/fpl-invalid.id.md +0 -0
- package/extend/bajoTemplate/partial/user/fpl-invalid.md +0 -0
- package/extend/bajoTemplate/partial/user/fpl.html +0 -0
- package/extend/bajoTemplate/partial/user/signup/form.html +0 -0
- package/extend/bajoTemplate/partial/user/signup/success-mail.id.md +0 -0
- package/extend/bajoTemplate/partial/user/signup/success-mail.md +0 -0
- package/extend/bajoTemplate/partial/user/signup/success-nomail.id.md +0 -0
- package/extend/bajoTemplate/partial/user/signup/success-nomail.md +0 -0
- package/extend/bajoTemplate/partial/user/signup/success.html +0 -0
- package/extend/bajoTemplate/partial/your-stuff/change-password.html +0 -0
- package/extend/bajoTemplate/partial/your-stuff/profile/edit.html +0 -0
- package/extend/bajoTemplate/partial/your-stuff/profile/view.html +0 -0
- package/extend/bajoTemplate/partial/your-stuff/reset-api-key.html +0 -0
- package/extend/bajoTemplate/template/403.html +0 -0
- package/extend/bajoTemplate/template/_admin/reset-user-password.html +0 -0
- package/extend/bajoTemplate/template/_mail/help-contact-form.html +0 -0
- package/extend/bajoTemplate/template/_mail/mystuff-change-password.html +0 -0
- package/extend/bajoTemplate/template/_mail/mystuff-reset-api-key.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-activation-success.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-forgot-password-changed.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-forgot-password-link.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-signup-success-active.html +0 -0
- package/extend/bajoTemplate/template/_mail/user-signup-success.html +0 -0
- package/extend/bajoTemplate/template/help/contact-form/form.html +0 -0
- package/extend/bajoTemplate/template/help/contact-form/success.html +0 -0
- package/extend/bajoTemplate/template/help/trouble-tickets/add.html +0 -0
- package/extend/bajoTemplate/template/help/trouble-tickets/details.html +0 -0
- package/extend/bajoTemplate/template/help/trouble-tickets/list.html +0 -0
- package/extend/bajoTemplate/template/info/about-us.md +0 -0
- package/extend/bajoTemplate/template/info/cookie-policy.md +0 -0
- package/extend/bajoTemplate/template/info/privacy.md +0 -0
- package/extend/bajoTemplate/template/info/terms-conditions.md +0 -0
- package/extend/bajoTemplate/template/signin.html +0 -0
- package/extend/bajoTemplate/template/signout.html +0 -0
- package/extend/bajoTemplate/template/user/activation.html +0 -0
- package/extend/bajoTemplate/template/user/forgot-password.html +0 -0
- package/extend/bajoTemplate/template/user/fpl-invalid.html +0 -0
- package/extend/bajoTemplate/template/user/fpl.html +0 -0
- package/extend/bajoTemplate/template/user/signup/form.html +0 -0
- package/extend/bajoTemplate/template/user/signup/success.html +0 -0
- package/extend/bajoTemplate/template/your-stuff/change-password.html +0 -0
- package/extend/bajoTemplate/template/your-stuff/profile/edit.html +0 -0
- package/extend/bajoTemplate/template/your-stuff/profile/view.html +0 -0
- package/extend/bajoTemplate/template/your-stuff/reset-api-key.html +0 -0
- package/extend/dobo/feature/address.js +1 -1
- package/extend/dobo/feature/category.js +0 -0
- package/extend/dobo/feature/country.js +1 -1
- package/extend/dobo/feature/email.js +0 -0
- package/extend/dobo/feature/lat-lng.js +3 -3
- package/extend/dobo/feature/lat.js +2 -2
- package/extend/dobo/feature/lng.js +2 -2
- package/extend/dobo/feature/person-in-charge.js +0 -0
- package/extend/dobo/feature/phone.js +0 -0
- package/extend/dobo/feature/site-id.js +3 -3
- package/extend/dobo/feature/slug.js +7 -8
- package/extend/dobo/feature/social.js +0 -0
- package/extend/dobo/feature/status.js +2 -2
- package/extend/dobo/feature/team-id.js +3 -3
- package/extend/dobo/feature/ts.js +0 -0
- package/extend/dobo/feature/url.js +6 -6
- package/extend/dobo/feature/user-id.js +5 -5
- package/extend/dobo/fixture/contact-form-cat.json +0 -0
- package/extend/dobo/fixture/site.json +0 -4
- package/extend/dobo/fixture/team-user.json +0 -0
- package/extend/dobo/fixture/team.json +2 -1
- package/extend/dobo/fixture/ticket-cat.json +0 -0
- package/extend/dobo/fixture/user.json +0 -0
- package/extend/dobo/model/contact-form-cat.json +3 -0
- package/extend/dobo/model/contact-form.json +16 -0
- package/extend/dobo/model/download.json +19 -0
- package/extend/dobo/model/site-setting.json +8 -0
- package/extend/dobo/{schema → model}/site.json +4 -8
- package/extend/dobo/{schema → model}/team-user.json +5 -10
- package/extend/dobo/model/team.json +15 -0
- package/extend/dobo/model/ticket-cat.json +3 -0
- package/extend/dobo/model/ticket-detail.json +7 -0
- package/extend/dobo/model/ticket.json +18 -0
- package/extend/dobo/{schema → model}/user.json +14 -11
- package/extend/masohiSocketIo/middleware/server/auth.js +1 -1
- package/extend/sumba/route/anonymous.json +0 -0
- package/extend/sumba/route/secure.json +0 -0
- package/extend/waibuBootstrap/theme/component/factory/nav-dropdown-user.js +5 -5
- package/extend/waibuDb/schema/contact-form-cat.json +0 -0
- package/extend/waibuDb/schema/contact-form.json +0 -0
- package/extend/waibuDb/schema/download.js +1 -1
- package/extend/waibuDb/schema/site.json +2 -2
- package/extend/waibuDb/schema/team-user.js +2 -2
- package/extend/waibuDb/schema/team.json +0 -0
- package/extend/waibuDb/schema/ticket-cat.json +0 -0
- package/extend/waibuDb/schema/user.json +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/contact-form/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/contact-form-cat/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/download/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/reset-user-password.js +5 -6
- package/extend/waibuMpa/extend/waibuAdmin/route/session/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/site.js +25 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/team/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/team-user/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/ticket/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/ticket-cat/@action.js +0 -0
- package/extend/waibuMpa/extend/waibuAdmin/route/user/@action.js +0 -0
- package/extend/waibuMpa/route/access-token.js +1 -2
- package/extend/waibuMpa/route/help/contact-form.js +5 -5
- package/extend/waibuMpa/route/help/trouble-tickets/add.js +4 -4
- package/extend/waibuMpa/route/help/trouble-tickets/details/@id.js +5 -5
- package/extend/waibuMpa/route/help/trouble-tickets/list.js +2 -2
- package/extend/waibuMpa/route/info/@item.js +0 -0
- package/extend/waibuMpa/route/signin.js +0 -0
- package/extend/waibuMpa/route/signout.js +1 -14
- package/extend/waibuMpa/route/user/activation.js +4 -6
- package/extend/waibuMpa/route/user/forgot-password/@fpl.js +9 -10
- package/extend/waibuMpa/route/user/forgot-password.js +5 -7
- package/extend/waibuMpa/route/user/signup.js +4 -4
- package/extend/waibuMpa/route/your-stuff/change-password.js +5 -6
- package/extend/waibuMpa/route/your-stuff/download/@action.js +0 -0
- package/extend/waibuMpa/route/your-stuff/download/get.js +0 -0
- package/extend/waibuMpa/route/your-stuff/profile/edit.js +5 -5
- package/extend/waibuMpa/route/your-stuff/profile.js +2 -2
- package/extend/waibuMpa/route/your-stuff/reset-api-key.js +8 -9
- package/extend/waibuRestApi/route/info/get.js +2 -2
- package/extend/waibuRestApi/route/manage/team/model-builder.json +0 -0
- package/extend/waibuRestApi/route/manage/user/model-builder.json +0 -0
- package/extend/waibuRestApi/route/user/access-token/@type/create.js +0 -0
- package/extend/waibuRestApi/route/user/api-key/get.js +1 -2
- package/extend/waibuRestApi/route/your-stuff/api-key/get.js +1 -2
- package/extend/waibuRestApi/route/your-stuff/api-key/update.js +5 -6
- package/extend/waibuRestApi/route/your-stuff/change-password/update.js +2 -3
- package/extend/waibuRestApi/route/your-stuff/profile/get.js +2 -2
- package/extend/waibuRestApi/route/your-stuff/profile/update.js +3 -3
- package/extend/waibuSocketIo/middleware/server/auth.js +2 -3
- package/extend/waibuStatic/asset/user-profile.png +0 -0
- package/index.js +78 -54
- package/lib/check-iconset.js +4 -6
- package/lib/check-team.js +1 -1
- package/lib/check-theme.js +4 -7
- package/lib/check-user-id.js +4 -3
- package/lib/collect-redirects.js +0 -0
- package/lib/collect-routes.js +4 -4
- package/lib/collect-team.js +3 -3
- package/lib/lat-lng-hook.js +2 -2
- package/lib/password-rule.js +0 -0
- package/lib/reset-token.js +1 -1
- package/lib/token-schema.js +0 -0
- package/logo.png +0 -0
- package/package.json +41 -34
- package/wiki/CHANGES.md +6 -0
- package/wiki/CONFIG.md +2 -0
- package/wiki/CONTRIBUTING.md +5 -0
- package/wiki/DEV-GUIDE.md +1 -0
- package/wiki/ECOSYSTEM.md +28 -0
- package/wiki/GETTING-STARTED.md +1 -0
- package/wiki/USER-GUIDE.md +1 -0
- package/extend/bajo/hook/dobo@before-record-count.js +0 -8
- package/extend/bajo/hook/dobo@before-record-find-one.js +0 -8
- package/extend/bajo/hook/dobo@before-record-get.js +0 -23
- package/extend/bajo/hook/dobo@before-record-remove.js +0 -10
- package/extend/bajo/hook/dobo@before-record-update.js +0 -10
- package/extend/dobo/schema/contact-form-cat.json +0 -3
- package/extend/dobo/schema/contact-form.json +0 -20
- package/extend/dobo/schema/download.json +0 -24
- package/extend/dobo/schema/site-setting.json +0 -8
- package/extend/dobo/schema/team.json +0 -19
- package/extend/dobo/schema/ticket-cat.json +0 -3
- package/extend/dobo/schema/ticket-detail.json +0 -7
- package/extend/dobo/schema/ticket.json +0 -17
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import resetToken from '../../../lib/reset-token.js'
|
|
2
2
|
|
|
3
|
-
async function
|
|
3
|
+
async function beforeCreateRecord (body, options = {}) {
|
|
4
4
|
const { token, salt } = await resetToken.call(this)
|
|
5
5
|
body.token = token
|
|
6
6
|
body.salt = salt
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export default beforeCreateRecord
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import passwordRule from '../../../lib/password-rule.js'
|
|
2
2
|
|
|
3
|
-
async function
|
|
4
|
-
const { set } = this.lib._
|
|
3
|
+
async function beforeRecordValidation (body, options = {}) {
|
|
4
|
+
const { set } = this.app.lib._
|
|
5
5
|
const password = await passwordRule.call(this, options.req)
|
|
6
6
|
const rule = { password }
|
|
7
7
|
set(options, 'validation.params.rule', rule)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export default
|
|
10
|
+
export default beforeRecordValidation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import resetToken from '../../../lib/reset-token.js'
|
|
2
2
|
|
|
3
|
-
async function
|
|
3
|
+
async function beforeUpdateRecord (id, body, options = {}) {
|
|
4
4
|
if (body.salt) {
|
|
5
5
|
const { token, salt } = await resetToken.call(this, body.salt)
|
|
6
6
|
body.token = token
|
|
@@ -8,4 +8,4 @@ async function beforeRecordUpdate (id, body, options = {}) {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export default
|
|
11
|
+
export default beforeUpdateRecord
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
const
|
|
1
|
+
const doboBeforeCreateRecord = {
|
|
2
2
|
level: 1000,
|
|
3
|
-
handler: async function (
|
|
4
|
-
const { get } = this.lib._
|
|
5
|
-
const { getField } = this.app.dobo
|
|
3
|
+
handler: async function (modelName, body, options = {}) {
|
|
4
|
+
const { get } = this.app.lib._
|
|
6
5
|
const { req } = options
|
|
7
6
|
|
|
8
7
|
if (options.noAutoFilter || !req) return
|
|
9
8
|
const item = { siteId: 'site.id', userId: 'user.id' }
|
|
9
|
+
const model = this.app.dobo.getModel(modelName)
|
|
10
10
|
for (const i in item) {
|
|
11
11
|
const rec = get(req, item[i])
|
|
12
|
-
const field =
|
|
12
|
+
const field = model.getProperty(i)
|
|
13
13
|
if (rec && field) body[i] = field.type === 'string' ? (rec + '') : rec
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export default
|
|
18
|
+
export default doboBeforeCreateRecord
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const useAdmin = ['waibuAdmin']
|
|
2
2
|
|
|
3
|
-
export async function rebuildFilter (
|
|
4
|
-
const { isEmpty, map, find, get } = this.lib._
|
|
5
|
-
const { hasField } = this.app.dobo
|
|
3
|
+
export async function rebuildFilter (modelName, filter, req) {
|
|
4
|
+
const { isEmpty, map, find, get } = this.app.lib._
|
|
6
5
|
filter.query = filter.query ?? {}
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
const model = this.app.dobo.getModel(modelName)
|
|
7
|
+
const hasSiteId = model.hasProperty('siteId')
|
|
8
|
+
const hasUserId = model.hasProperty('userId')
|
|
9
|
+
const hasTeamId = model.hasProperty('teamId')
|
|
10
10
|
const isAdmin = find(get(req, 'user.teams', []), { alias: 'administrator' }) && useAdmin.includes(get(req, 'routeOptions.config.ns'))
|
|
11
11
|
if (!(hasSiteId || hasUserId || hasTeamId)) return filter
|
|
12
12
|
const q = { $and: [] }
|
|
@@ -26,15 +26,15 @@ export async function rebuildFilter (model, filter, req) {
|
|
|
26
26
|
return filter
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export async function handler (
|
|
29
|
+
export async function handler (modelName, filter, options = {}) {
|
|
30
30
|
const { req } = options
|
|
31
31
|
if (options.noAutoFilter || !req) return
|
|
32
|
-
filter = await rebuildFilter.call(this,
|
|
32
|
+
filter = await rebuildFilter.call(this, modelName, filter, req)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const doboBeforeFindRecord = {
|
|
36
36
|
level: 1000,
|
|
37
37
|
handler
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export default
|
|
40
|
+
export default doboBeforeFindRecord
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { rebuildFilter } from './dobo@before-find-record.js'
|
|
2
|
+
|
|
3
|
+
export async function checker (modelName, id, options = {}) {
|
|
4
|
+
const { req } = options
|
|
5
|
+
|
|
6
|
+
const model = this.app.dobo.getModel(modelName)
|
|
7
|
+
if (options.noAutoFilter || !req) return
|
|
8
|
+
const filter = await rebuildFilter.call(this, modelName, {}, req)
|
|
9
|
+
if (filter.query.$and) filter.query.$and.push({ id })
|
|
10
|
+
else filter.query.id = id
|
|
11
|
+
filter.limit = 1
|
|
12
|
+
const rows = await model.findRecord(filter, { count: false })
|
|
13
|
+
if (rows.length === 0) throw this.app.dobo.error('recordNotFound%s%s', id, this.name, { statusCode: 404 })
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const doboBeforeGetRecord = {
|
|
17
|
+
level: 1000,
|
|
18
|
+
handler: async function (modelName, id, options) {
|
|
19
|
+
await checker.call(this, modelName, id, options)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default doboBeforeGetRecord
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,7 @@ import collectTeam from '../../../lib/collect-team.js'
|
|
|
3
3
|
|
|
4
4
|
async function afterAppBoot () {
|
|
5
5
|
const { runHook } = this.app.bajo
|
|
6
|
-
await runHook(`${this.
|
|
6
|
+
await runHook(`${this.ns}:beforeBoot`)
|
|
7
7
|
this.log.trace('collectingRouteGuards')
|
|
8
8
|
await collectRoutes.call(this, 'secure')
|
|
9
9
|
this.log.trace('secureRoutes%d', this.secureRoutes.length)
|
|
@@ -15,7 +15,7 @@ async function afterAppBoot () {
|
|
|
15
15
|
await collectTeam.call(this)
|
|
16
16
|
this.log.trace('teamRoutes%d', this.teamRoutes.length)
|
|
17
17
|
this.log.trace('teamNegRoutes%d', this.teamNegRoutes.length)
|
|
18
|
-
await runHook(`${this.
|
|
18
|
+
await runHook(`${this.ns}:afterBoot`)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export default afterAppBoot
|
|
File without changes
|
|
File without changes
|
package/extend/bajo/intl/id.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import latLngHook from '../../../lib/lat-lng-hook.js'
|
|
2
2
|
|
|
3
3
|
async function latLng (opts = {}) {
|
|
4
|
-
const { merge } = this.lib._
|
|
4
|
+
const { merge } = this.app.lib._
|
|
5
5
|
opts.fieldNameLat = opts.fieldNameLat ?? 'lat'
|
|
6
6
|
opts.fieldNameLng = opts.fieldNameLng ?? 'lng'
|
|
7
7
|
opts.scale = opts.scale ?? 5
|
|
@@ -23,11 +23,11 @@ async function latLng (opts = {}) {
|
|
|
23
23
|
scale: opts.scale
|
|
24
24
|
}],
|
|
25
25
|
hook: {
|
|
26
|
-
beforeCreate: async function (
|
|
26
|
+
beforeCreate: async function (body) {
|
|
27
27
|
await latLngHook.call(this, body, merge({}, opts, { lat: opts.fieldNameLat }))
|
|
28
28
|
await latLngHook.call(this, body, merge({}, opts, { lng: opts.fieldNameLng }))
|
|
29
29
|
},
|
|
30
|
-
beforeUpdate: async function (
|
|
30
|
+
beforeUpdate: async function (body) {
|
|
31
31
|
await latLngHook.call(this, body, merge({}, opts, { lat: opts.fieldNameLat }))
|
|
32
32
|
await latLngHook.call(this, body, merge({}, opts, { lng: opts.fieldNameLng }))
|
|
33
33
|
}
|
|
@@ -14,10 +14,10 @@ async function lat (opts = {}) {
|
|
|
14
14
|
scale: opts.scale
|
|
15
15
|
}],
|
|
16
16
|
hook: {
|
|
17
|
-
beforeCreate: async function (
|
|
17
|
+
beforeCreate: async function (body) {
|
|
18
18
|
await latLngHook.call(this, body, opts)
|
|
19
19
|
},
|
|
20
|
-
beforeUpdate: async function (
|
|
20
|
+
beforeUpdate: async function (body) {
|
|
21
21
|
await latLngHook.call(this, body, opts)
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -14,10 +14,10 @@ async function lng (opts = {}) {
|
|
|
14
14
|
scale: opts.scale
|
|
15
15
|
}],
|
|
16
16
|
hook: {
|
|
17
|
-
beforeCreate: async function (
|
|
17
|
+
beforeCreate: async function (body) {
|
|
18
18
|
await latLngHook.call(this, body, opts)
|
|
19
19
|
},
|
|
20
|
-
beforeUpdate: async function (
|
|
20
|
+
beforeUpdate: async function (body) {
|
|
21
21
|
await latLngHook.call(this, body, opts)
|
|
22
22
|
}
|
|
23
23
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import slug from 'slug'
|
|
2
2
|
|
|
3
|
-
async function autoInc (
|
|
4
|
-
const {
|
|
5
|
-
const { set, last } = this.lib._
|
|
3
|
+
async function autoInc (body, opts) {
|
|
4
|
+
const { set, last } = this.app.lib._
|
|
6
5
|
const query = set({}, opts.fieldName, { $regex: new RegExp('^' + body[opts.fieldName]) })
|
|
7
6
|
const sort = set({}, opts.fieldName, -1)
|
|
8
7
|
const options = { noHook: true, skipCache: true, thrownNotFound: false }
|
|
9
|
-
const resp = await
|
|
8
|
+
const resp = await this.findRecord({ query, limit: 1, sort }, options)
|
|
10
9
|
if (resp.length === 0) return body[opts.fieldName]
|
|
11
10
|
const rslugs = resp[0][opts.fieldName].split('-')
|
|
12
11
|
const slugs = body[opts.fieldName].split('-')
|
|
@@ -23,7 +22,7 @@ async function autoInc ({ schema, body, opts }) {
|
|
|
23
22
|
body[opts.fieldName] = slugs.join('-')
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
return await autoInc.call(this,
|
|
25
|
+
return await autoInc.call(this, body, opts)
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
async function mainFn (opts = {}) {
|
|
@@ -38,9 +37,9 @@ async function mainFn (opts = {}) {
|
|
|
38
37
|
index: 'unique'
|
|
39
38
|
}],
|
|
40
39
|
hook: {
|
|
41
|
-
beforeCreate: async function (
|
|
40
|
+
beforeCreate: async function (body) {
|
|
42
41
|
const { error } = this.app.bajo
|
|
43
|
-
const { isEmpty, isString } = this.lib._
|
|
42
|
+
const { isEmpty, isString } = this.app.lib._
|
|
44
43
|
if (isEmpty(body[opts.fieldName])) {
|
|
45
44
|
if (isString(opts.fieldSource)) opts.fieldSource = [opts.fieldSource]
|
|
46
45
|
const source = []
|
|
@@ -53,7 +52,7 @@ async function mainFn (opts = {}) {
|
|
|
53
52
|
}
|
|
54
53
|
body[opts.fieldName] = slug(source.join(' '))
|
|
55
54
|
}
|
|
56
|
-
if (opts.autoInc) body[opts.fieldName] = await autoInc.call(this,
|
|
55
|
+
if (opts.autoInc) body[opts.fieldName] = await autoInc.call(this, body, opts)
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
}
|
|
File without changes
|