sumba 2.18.0 → 2.19.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/dobo.sumba-site@after-remove-record.js +2 -0
- package/extend/bajo/hook/dobo.sumba-site@after-update-record.js +14 -0
- package/extend/bajo/hook/dobo.sumba-user@after-remove-record.js +7 -0
- package/extend/bajo/hook/dobo.sumba-user@after-update-record.js +14 -0
- package/extend/dobo/model/site.json +2 -1
- package/extend/waibuMpa/extend/waibuAdmin/route/site.js +2 -1
- package/extend/waibuMpa/route/your-stuff/profile/edit.js +1 -1
- package/extend/waibuMpa/route/your-stuff/profile.js +1 -1
- package/lib/get-site.js +2 -2
- package/lib/get-user.js +2 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +12 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { removeRefs } from '../../../lib/remove-site.js'
|
|
2
|
+
import { clearCache } from './dobo.sumba-site@after-update-record.js'
|
|
2
3
|
|
|
3
4
|
async function afterRemoveRecord (id, result, options) {
|
|
4
5
|
await removeRefs.call(this, result.oldData, options)
|
|
6
|
+
await clearCache.call(this, id, result)
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
export default afterRemoveRecord
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function clearCache (id, result) {
|
|
2
|
+
if (!this.app.bajoCache) return
|
|
3
|
+
const { clear } = this.app.bajoCache
|
|
4
|
+
const { get } = this.app.lib._
|
|
5
|
+
await clear({ key: 'dobo|SumbaSite|getSite|default' })
|
|
6
|
+
await clear({ key: `dobo|SumbaSite|getSite|multiSite|${id}` })
|
|
7
|
+
await clear({ key: `dobo|SumbaSite|getSite|multiSite|${get(result, 'data.hostname', get(result, 'oldData.hostname'))}` })
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async function afterUpdateRecord (id, input, result, opts) {
|
|
11
|
+
await clearCache.call(this, id, result)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default afterUpdateRecord
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export async function clearCache (id, result) {
|
|
2
|
+
if (!this.app.bajoCache) return
|
|
3
|
+
const { hash } = this.app.bajoExtra
|
|
4
|
+
const { clear } = this.app.bajoCache
|
|
5
|
+
const { get, isEmpty } = this.app.lib._
|
|
6
|
+
let token = get(result, 'data.token', get(result, 'oldData.token', ''))
|
|
7
|
+
if (!isEmpty(token)) token = await hash(token)
|
|
8
|
+
await clear({ key: `dobo|SumbaUser|getUserById|${id}` })
|
|
9
|
+
await clear({ key: `dobo|SumbaUser|getUserByToken|${token}` })
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
async function afterUpdateRecord (id, body, rec, options = {}) {
|
|
2
13
|
const { data, oldData } = rec
|
|
3
14
|
const { req } = options
|
|
@@ -5,6 +16,9 @@ async function afterUpdateRecord (id, body, rec, options = {}) {
|
|
|
5
16
|
const t = get(req, 't', this.t)
|
|
6
17
|
const to = `${data.firstName} ${data.lastName} <${data.email}>`
|
|
7
18
|
const source = this.ns
|
|
19
|
+
|
|
20
|
+
await clearCache.call(this, id, rec)
|
|
21
|
+
|
|
8
22
|
let subject
|
|
9
23
|
const payload = { to, subject, data }
|
|
10
24
|
|
|
@@ -8,7 +8,7 @@ const profile = {
|
|
|
8
8
|
const { updateRecord, getRecord } = this.app.waibuDb
|
|
9
9
|
const { omit, pick } = this.app.lib._
|
|
10
10
|
const { hash } = this.app.bajoExtra
|
|
11
|
-
const resp = await getRecord({ model: 'SumbaUser', req, id: req.user.id, options: { forceNoHidden: ['token'], noHook: true, noCache: true } })
|
|
11
|
+
const resp = await getRecord({ model: 'SumbaUser', req, id: req.user.id, options: { forceNoHidden: ['token'], noHook: true, noCache: true, formatValue: true, retainOriginalValue: true } })
|
|
12
12
|
let form = defaultsDeep(req.body, omit(resp.data, ['password', 'salt']))
|
|
13
13
|
form.token = await hash(form.token)
|
|
14
14
|
let error
|
|
@@ -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, formatValue: true, retainOriginalValue: 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/lib/get-site.js
CHANGED
|
@@ -31,7 +31,7 @@ async function getSite (input, byId = false) {
|
|
|
31
31
|
|
|
32
32
|
if (!this.config.multiSite.enabled) {
|
|
33
33
|
const filter = { query: { alias: 'default' } }
|
|
34
|
-
const key = 'getSite|default'
|
|
34
|
+
const key = 'dobo|SumbaSite|getSite|default'
|
|
35
35
|
if (getCache) {
|
|
36
36
|
site = await getCache({ key })
|
|
37
37
|
if (site) return site
|
|
@@ -47,7 +47,7 @@ async function getSite (input, byId = false) {
|
|
|
47
47
|
let query
|
|
48
48
|
if (byId) query = { id: input }
|
|
49
49
|
else query = { hostname: input }
|
|
50
|
-
const key = `getSite|multiSite|${input}`
|
|
50
|
+
const key = `dobo|SumbaSite|getSite|multiSite|${input}`
|
|
51
51
|
if (getCache) {
|
|
52
52
|
site = await getCache({ key })
|
|
53
53
|
if (site) return JSON.parse(site)
|
package/lib/get-user.js
CHANGED
|
@@ -39,7 +39,7 @@ export async function mergeTeam (user) {
|
|
|
39
39
|
export async function getUserById (id, req) {
|
|
40
40
|
const { getModel } = this.app.dobo
|
|
41
41
|
const { set: setCache, get: getCache } = this.app.bajoCache ?? {}
|
|
42
|
-
const key = `getUserById|${id}`
|
|
42
|
+
const key = `dobo|SumbaUser|getUserById|${id}`
|
|
43
43
|
let user
|
|
44
44
|
if (getCache) {
|
|
45
45
|
user = await getCache({ key })
|
|
@@ -57,7 +57,7 @@ export async function getUserById (id, req) {
|
|
|
57
57
|
export async function getUserByToken (token, req) {
|
|
58
58
|
const { getModel } = this.app.dobo
|
|
59
59
|
const { set: setCache, get: getCache } = this.app.bajoCache ?? {}
|
|
60
|
-
const key = `getUserByToken|${token}`
|
|
60
|
+
const key = `dobo|SumbaUser|getUserByToken|${token}`
|
|
61
61
|
let user
|
|
62
62
|
if (getCache) {
|
|
63
63
|
user = await getCache({ key })
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-04-16
|
|
4
|
+
|
|
5
|
+
- [2.19.0] Add cache clearing if a site is updated/removed
|
|
6
|
+
- [2.19.0] Add cache clearing if a user is updated/removed
|
|
7
|
+
- [2.19.0] Necessary changes to all routes to support ```formatValue``` & ```retainOriginalValue``` options
|
|
8
|
+
- [2.19.0] Change cache key for ```getUser()```
|
|
9
|
+
- [2.19.0] Change cache key for ```getSite()```
|
|
10
|
+
|
|
11
|
+
## 2026-04-13
|
|
12
|
+
|
|
13
|
+
- [2.18.1] Bug fix on ```SumbaSite``` model
|
|
14
|
+
|
|
3
15
|
## 2026-04-11
|
|
4
16
|
|
|
5
17
|
- [2.18.0] Some major rewrites :/
|