dobo 2.24.0 → 2.25.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/intl/en-US.json +3 -0
- package/extend/bajo/intl/id.json +3 -0
- package/extend/dobo/feature/immutable.js +1 -1
- package/index.js +2 -2
- package/lib/factory/model/_util.js +2 -2
- package/lib/factory/model/load-fixtures.js +6 -1
- package/lib/factory/model/validate.js +7 -2
- package/lib/factory/model.js +6 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +8 -0
package/extend/bajo/intl/id.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
async function beforeRemoveRecord (id, opts, options) {
|
|
2
2
|
const { get } = this.app.lib._
|
|
3
|
-
if (get(options, 'req.user.
|
|
3
|
+
if (get(options, 'req.user.isXSiteAdmin')) return
|
|
4
4
|
const record = await this.driver.getRecord(this, id)
|
|
5
5
|
const immutable = get(record.data, opts.field)
|
|
6
6
|
if (immutable) throw this.plugin.error('recordImmutable%s%s', id, this.name, { statusCode: 423 })
|
package/index.js
CHANGED
|
@@ -188,7 +188,7 @@ export async function getRefs (records = [], options = {}) {
|
|
|
188
188
|
if (!rModel) return
|
|
189
189
|
let matches = []
|
|
190
190
|
for (const rec of records) {
|
|
191
|
-
const items = isValues ? [...rec[prop.name]] : [rec[prop.name]]
|
|
191
|
+
const items = isValues ? [...(rec[prop.name] ?? [])] : (rec[prop.name] ? [rec[prop.name]] : [])
|
|
192
192
|
matches.push(...items.map(item => prop.name === 'id' ? rModel.sanitizeId(item) : item))
|
|
193
193
|
}
|
|
194
194
|
matches = uniq(without(matches, undefined, null, NaN)).map(i => i + '')
|
|
@@ -211,7 +211,7 @@ export async function getRefs (records = [], options = {}) {
|
|
|
211
211
|
for (const i in records) {
|
|
212
212
|
records[i]._ref = records[i]._ref ?? {}
|
|
213
213
|
const rec = records[i]
|
|
214
|
-
let items = isValues ? [...rec[prop.name]] : [rec[prop.name]]
|
|
214
|
+
let items = isValues ? [...(rec[prop.name] ?? [])] : (rec[prop.name] ? [rec[prop.name]] : [])
|
|
215
215
|
items = items.map(item => item + '')
|
|
216
216
|
const res = results.filter(r => items.includes(r[ref.field] + ''))
|
|
217
217
|
if (res.length === 0) records[i]._ref[key] = isValues ? [] : {}
|
|
@@ -27,7 +27,7 @@ async function exec ({ item, spinner, options, result, items } = {}) {
|
|
|
27
27
|
async function loadFixtures ({ spinner, ignoreError = true, collectItems = false, noLookup = false } = {}, options = {}) {
|
|
28
28
|
const { readConfig } = this.app.bajo
|
|
29
29
|
const { resolvePath, isSet } = this.app.lib.aneka
|
|
30
|
-
const { isEmpty, isString, isArray } = this.app.lib._
|
|
30
|
+
const { isEmpty, isString, isArray, pullAt } = this.app.lib._
|
|
31
31
|
if (this.connection.proxy) {
|
|
32
32
|
this.log.warn('proxiedConnBound%s', this.name)
|
|
33
33
|
return
|
|
@@ -39,8 +39,10 @@ async function loadFixtures ({ spinner, ignoreError = true, collectItems = false
|
|
|
39
39
|
const opts = { ...options, noMagic: true }
|
|
40
40
|
for (const item of items) {
|
|
41
41
|
const lv = {}
|
|
42
|
+
const deleted = {}
|
|
42
43
|
for (const key in item) {
|
|
43
44
|
const val = item[key]
|
|
45
|
+
deleted[key] = deleted[key] ?? []
|
|
44
46
|
if (!noLookup) {
|
|
45
47
|
if (isString(val) && val.slice(0, 2) === '?:') {
|
|
46
48
|
item[key] = await this._simpleLookup(val.slice(2), lv, opts)
|
|
@@ -50,11 +52,14 @@ async function loadFixtures ({ spinner, ignoreError = true, collectItems = false
|
|
|
50
52
|
if (isString(val[idx]) && val[idx].slice(0, 2) === '?:') {
|
|
51
53
|
item[key][idx] = await this._simpleLookup(val[idx].slice(2), lv, opts)
|
|
52
54
|
if (isSet(item[key][idx])) item[key][idx] += ''
|
|
55
|
+
else deleted[key].push(idx)
|
|
53
56
|
lv[`${key}.${idx}`] = item[key][idx]
|
|
54
57
|
}
|
|
55
58
|
}
|
|
59
|
+
if (deleted[key].length > 0) pullAt(item[key], deleted[key])
|
|
56
60
|
}
|
|
57
61
|
}
|
|
62
|
+
delete deleted[key]
|
|
58
63
|
if (val === null) item[key] = undefined
|
|
59
64
|
else {
|
|
60
65
|
const prop = this.properties.find(item => item.name === key)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import joi from 'joi'
|
|
2
2
|
|
|
3
|
-
const excludedTypes = ['object'
|
|
3
|
+
const excludedTypes = ['object']
|
|
4
4
|
const excludedNames = []
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -142,7 +142,9 @@ async function buildFromDbModel (opts = {}) {
|
|
|
142
142
|
const resp = await callHandler(prop.values)
|
|
143
143
|
items = resp.map(item => item.value)
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
if (prop.type === 'array') {
|
|
146
|
+
obj = obj.items(joi.string().valid(...items))
|
|
147
|
+
} else obj = obj.valid(...items)
|
|
146
148
|
}
|
|
147
149
|
if (prop.rulesMsg) {
|
|
148
150
|
const msgs = {}
|
|
@@ -185,6 +187,9 @@ async function buildFromDbModel (opts = {}) {
|
|
|
185
187
|
case 'boolean':
|
|
186
188
|
item = await applyFieldRules(p, joi.boolean())
|
|
187
189
|
break
|
|
190
|
+
case 'array':
|
|
191
|
+
item = await applyFieldRules(p, joi.array())
|
|
192
|
+
break
|
|
188
193
|
}
|
|
189
194
|
if (item) {
|
|
190
195
|
if (item.$_root && !p.required) obj[p.name] = item.allow(null, '')
|
package/lib/factory/model.js
CHANGED
|
@@ -96,11 +96,16 @@ async function modelFactory () {
|
|
|
96
96
|
return namesOnly ? items.map(item => item.name) : items
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
getVirtualProperties = (
|
|
99
|
+
getVirtualProperties = (namesOnly) => {
|
|
100
100
|
const items = this.properties.filter(prop => prop.virtual)
|
|
101
101
|
return namesOnly ? items.map(item => item.name) : items
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
getNonVirtualProperties = (namesOnly) => {
|
|
105
|
+
const items = this.properties.filter(prop => !prop.virtual)
|
|
106
|
+
return namesOnly ? items.map(item => item.name) : items
|
|
107
|
+
}
|
|
108
|
+
|
|
104
109
|
getIndexes = () => {
|
|
105
110
|
return this.indexes
|
|
106
111
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-05-22
|
|
4
|
+
|
|
5
|
+
- [2.25.0] Add ```array``` & ```object``` validator handling
|
|
6
|
+
- [2.25.0] Change ```interSite``` definition to ```xSite```
|
|
7
|
+
- [2.25.0] Add ```model.getNonVirtualProperties()```
|
|
8
|
+
- [2.25.0] Bug fix in ```model.loadFixtures()```
|
|
9
|
+
- [2.25.0] Handle ```array``` validation schema
|
|
10
|
+
|
|
3
11
|
## 2026-05-16
|
|
4
12
|
|
|
5
13
|
- [2.24.0] Change ```dobo:immutable``` feature, field no longer hidden
|