dobo 1.1.17 → 1.1.19
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/bajo/intl/en-US.json +1 -0
- package/bajo/intl/id.json +1 -0
- package/dobo/feature/created-at.js +2 -1
- package/dobo/feature/updated-at.js +4 -2
- package/lib/check-unique.js +1 -1
- package/lib/collect-schemas.js +2 -1
- package/lib/multi-rel-rows.js +1 -1
- package/lib/sanitize-schema.js +2 -1
- package/lib/single-rel-rows.js +1 -1
- package/package.json +1 -1
- package/plugin/factory.js +11 -5
- package/plugin/method/attachment/get-path.js +2 -1
- package/plugin/method/attachment/pre-check.js +2 -1
- package/plugin/method/bulk/create.js +2 -1
- package/plugin/method/record/create.js +2 -1
- package/plugin/method/record/find-one.js +2 -1
- package/plugin/method/record/find.js +2 -1
- package/plugin/method/record/get.js +2 -1
- package/plugin/method/record/update.js +2 -1
- package/plugin/method/sanitize/body.js +3 -1
- package/plugin/method/validate.js +1 -1
- package/waibuMpa/route/attachment/@model/@id/@field/@file.js +1 -1
package/bajo/intl/en-US.json
CHANGED
package/bajo/intl/id.json
CHANGED
|
@@ -8,8 +8,9 @@ async function createdAt (opts = {}) {
|
|
|
8
8
|
},
|
|
9
9
|
hook: {
|
|
10
10
|
beforeCreate: async function ({ body }) {
|
|
11
|
+
const { isSet } = this.lib.aneka
|
|
11
12
|
const now = new Date()
|
|
12
|
-
if (opts.overwrite || !
|
|
13
|
+
if (opts.overwrite || !isSet(body[opts.fieldName])) body[opts.fieldName] = now
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -9,12 +9,14 @@ async function updatedAt (opts = {}) {
|
|
|
9
9
|
},
|
|
10
10
|
hook: {
|
|
11
11
|
beforeCreate: async function ({ body }) {
|
|
12
|
+
const { isSet } = this.lib.aneka
|
|
12
13
|
const now = new Date()
|
|
13
|
-
if (opts.overwrite || !
|
|
14
|
+
if (opts.overwrite || !isSet(body[opts.fieldName])) body[opts.fieldName] = now
|
|
14
15
|
},
|
|
15
16
|
beforeUpdate: async function ({ body }) {
|
|
17
|
+
const { isSet } = this.lib.aneka
|
|
16
18
|
const now = new Date()
|
|
17
|
-
if (opts.overwrite || !
|
|
19
|
+
if (opts.overwrite || !isSet(body[opts.fieldName])) body[opts.fieldName] = now
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
}
|
package/lib/check-unique.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
async function checkUnique ({ schema, body, id }) {
|
|
2
|
-
const { isSet } = this.
|
|
2
|
+
const { isSet } = this.lib.aneka
|
|
3
3
|
const { filter, map, set } = this.lib._
|
|
4
4
|
const singles = map(filter(schema.properties, p => (p.index ?? {}).type === 'unique'), 'name')
|
|
5
5
|
const opts = { noHook: true, noCache: true, thrownNotFound: false, forceNoHidden: true }
|
package/lib/collect-schemas.js
CHANGED
|
@@ -2,7 +2,8 @@ import path from 'path'
|
|
|
2
2
|
import sanitizeSchema from './sanitize-schema.js'
|
|
3
3
|
|
|
4
4
|
async function handler ({ file, alias, ns }) {
|
|
5
|
-
const { readConfig,
|
|
5
|
+
const { readConfig, eachPlugins } = this.app.bajo
|
|
6
|
+
const { pascalCase } = this.lib.aneka
|
|
6
7
|
const { get, isPlainObject, each, find, has, isArray, forOwn, isString, merge } = this.lib._
|
|
7
8
|
const { fastGlob } = this.lib
|
|
8
9
|
|
package/lib/multi-rel-rows.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
async function multiRelRows ({ schema, records, options = {} }) {
|
|
2
|
-
const { isSet } = this.
|
|
2
|
+
const { isSet } = this.lib.aneka
|
|
3
3
|
const { uniq, find, map } = this.lib._
|
|
4
4
|
const props = schema.properties.filter(p => isSet(p.rel) && !(options.hidden ?? []).includes(p.name))
|
|
5
5
|
// const props = schema.properties.filter(p => isSet(p.rel))
|
package/lib/sanitize-schema.js
CHANGED
|
@@ -37,7 +37,8 @@ async function sanitizeFullText (item) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async function sanitizeSchema (items) {
|
|
40
|
-
const {
|
|
40
|
+
const { defaultsDeep } = this.lib.aneka
|
|
41
|
+
const { freeze, fatal, importModule, join, breakNsPath, runHook } = this.app.bajo
|
|
41
42
|
const { isEmpty, orderBy, map, keys, findIndex, find, each, isString, get, isPlainObject, camelCase, uniq, filter } = this.lib._
|
|
42
43
|
const propTypes = keys(this.propType)
|
|
43
44
|
const schemas = []
|
package/lib/single-rel-rows.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
async function singleRelRows ({ schema, record, options = {} }) {
|
|
2
|
-
const { isSet } = this.
|
|
2
|
+
const { isSet } = this.lib.aneka
|
|
3
3
|
const { find } = this.lib._
|
|
4
4
|
const props = schema.properties.filter(p => isSet(p.rel) && !(options.hidden ?? []).includes(p.name))
|
|
5
5
|
const rels = {}
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -267,17 +267,22 @@ async function factory (pkgName) {
|
|
|
267
267
|
buildQuery = async ({ filter, schema, options = {} } = {}) => {
|
|
268
268
|
const { trim, isString, isPlainObject } = this.lib._
|
|
269
269
|
let query = {}
|
|
270
|
+
if (schema.name === 'SeatrackVessel') this.app.dump(filter)
|
|
270
271
|
if (isString(filter.query)) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
try {
|
|
273
|
+
filter.oquery = filter.query
|
|
274
|
+
if (trim(filter.query).startsWith('{')) query = JSON.parse(filter.query)
|
|
275
|
+
else query = nql(filter.query).parse()
|
|
276
|
+
} catch (err) {
|
|
277
|
+
this.error('invalidQuery', { orgMessage: err.message })
|
|
278
|
+
}
|
|
274
279
|
} else if (isPlainObject(filter.query)) query = filter.query
|
|
275
280
|
return this.sanitizeQuery(query, schema)
|
|
276
281
|
}
|
|
277
282
|
|
|
278
283
|
sanitizeQuery = (query, schema, parent) => {
|
|
279
284
|
const { cloneDeep, isPlainObject, isArray, find } = this.lib._
|
|
280
|
-
const { isSet } = this.
|
|
285
|
+
const { isSet } = this.lib.aneka
|
|
281
286
|
const { dayjs } = this.lib
|
|
282
287
|
const obj = cloneDeep(query)
|
|
283
288
|
const keys = Object.keys(obj)
|
|
@@ -336,8 +341,9 @@ async function factory (pkgName) {
|
|
|
336
341
|
|
|
337
342
|
getSchema = (input, cloned = true) => {
|
|
338
343
|
const { find, isPlainObject, cloneDeep } = this.lib._
|
|
344
|
+
const { pascalCase } = this.lib.aneka
|
|
339
345
|
let name = isPlainObject(input) ? input.name : input
|
|
340
|
-
name =
|
|
346
|
+
name = pascalCase(name)
|
|
341
347
|
const schema = find(this.schemas, { name })
|
|
342
348
|
if (!schema) throw this.error('unknownModelSchema%s', name)
|
|
343
349
|
return cloned ? cloneDeep(schema) : schema
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
async function getPath (name, id, field, file, options = {}) {
|
|
2
|
-
const {
|
|
2
|
+
const { getPluginDataDir } = this.app.bajo
|
|
3
|
+
const { pascalCase } = this.lib.aneka
|
|
3
4
|
const { fs } = this.lib
|
|
4
5
|
const dir = `${getPluginDataDir(this.name)}/attachment/${pascalCase(name)}/${id}`
|
|
5
6
|
if (options.dirOnly) return dir
|
|
@@ -3,7 +3,8 @@ import execValidation from '../../../lib/exec-validation.js'
|
|
|
3
3
|
import execFeatureHook from '../../../lib/exec-feature-hook.js'
|
|
4
4
|
|
|
5
5
|
async function create (name, inputs, options) {
|
|
6
|
-
const {
|
|
6
|
+
const { isSet } = this.lib.aneka
|
|
7
|
+
const { generateId, runHook } = this.app.bajo
|
|
7
8
|
const { clearModel } = this.cache ?? {}
|
|
8
9
|
const { find } = this.lib._
|
|
9
10
|
options.dataOnly = options.dataOnly ?? true
|
|
@@ -7,7 +7,8 @@ import execFeatureHook from '../../../lib/exec-feature-hook.js'
|
|
|
7
7
|
import singleRelRows from '../../../lib/single-rel-rows.js'
|
|
8
8
|
|
|
9
9
|
async function create (name, input, opts = {}) {
|
|
10
|
-
const { generateId, runHook
|
|
10
|
+
const { generateId, runHook } = this.app.bajo
|
|
11
|
+
const { isSet } = this.lib.aneka
|
|
11
12
|
const { clearModel } = this.cache ?? {}
|
|
12
13
|
const { find, forOwn, cloneDeep, camelCase, omit, get, pick } = this.lib._
|
|
13
14
|
delete opts.record
|
|
@@ -3,7 +3,8 @@ import singleRelRows from '../../../lib/single-rel-rows.js'
|
|
|
3
3
|
import execFeatureHook from '../../../lib/exec-feature-hook.js'
|
|
4
4
|
|
|
5
5
|
async function findOne (name, filter = {}, opts = {}) {
|
|
6
|
-
const {
|
|
6
|
+
const { isSet } = this.lib.aneka
|
|
7
|
+
const { runHook } = this.app.bajo
|
|
7
8
|
const { get, set } = this.cache ?? {}
|
|
8
9
|
const { cloneDeep, camelCase, omit } = this.lib._
|
|
9
10
|
delete opts.record
|
|
@@ -3,7 +3,8 @@ import multiRelRows from '../../../lib/multi-rel-rows.js'
|
|
|
3
3
|
import execFeatureHook from '../../../lib/exec-feature-hook.js'
|
|
4
4
|
|
|
5
5
|
async function find (name, filter = {}, opts = {}) {
|
|
6
|
-
const {
|
|
6
|
+
const { isSet } = this.lib.aneka
|
|
7
|
+
const { runHook } = this.app.bajo
|
|
7
8
|
const { get, set } = this.cache ?? {}
|
|
8
9
|
const { cloneDeep, camelCase, omit } = this.lib._
|
|
9
10
|
delete opts.records
|
|
@@ -3,7 +3,8 @@ import singleRelRows from '../../../lib/single-rel-rows.js'
|
|
|
3
3
|
import execFeatureHook from '../../../lib/exec-feature-hook.js'
|
|
4
4
|
|
|
5
5
|
async function get (name, id, opts = {}) {
|
|
6
|
-
const {
|
|
6
|
+
const { isSet } = this.lib.aneka
|
|
7
|
+
const { runHook } = this.app.bajo
|
|
7
8
|
const { get, set } = this.cache ?? {}
|
|
8
9
|
const { cloneDeep, camelCase, omit } = this.lib._
|
|
9
10
|
delete opts.record
|
|
@@ -6,7 +6,8 @@ import execFeatureHook from '../../../lib/exec-feature-hook.js'
|
|
|
6
6
|
import singleRelRows from '../../../lib/single-rel-rows.js'
|
|
7
7
|
|
|
8
8
|
async function update (name, id, input, opts = {}) {
|
|
9
|
-
const {
|
|
9
|
+
const { isSet } = this.lib.aneka
|
|
10
|
+
const { runHook } = this.app.bajo
|
|
10
11
|
const { clearModel } = this.cache ?? {}
|
|
11
12
|
const { forOwn, find, cloneDeep, camelCase, omit, get } = this.lib._
|
|
12
13
|
delete opts.record
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
async function sanitizeBody ({ body = {}, schema = {}, partial, strict, extFields = [] }) {
|
|
2
|
-
const { isSet
|
|
2
|
+
const { isSet } = this.lib.aneka
|
|
3
|
+
const { dayjs } = this.lib
|
|
4
|
+
const { callHandler } = this.app.bajo
|
|
3
5
|
const { has, isString, isNumber, concat, isNaN } = this.lib._
|
|
4
6
|
const result = {}
|
|
5
7
|
for (const p of concat(schema.properties, extFields)) {
|
|
@@ -126,7 +126,7 @@ function buildFromDbSchema (schema, { fields = [], rule = {}, extFields = [] } =
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
async function validate (value, joiSchema, { ns, fields, extFields, params } = {}) {
|
|
129
|
-
const { defaultsDeep, isSet } = this.
|
|
129
|
+
const { defaultsDeep, isSet } = this.lib.aneka
|
|
130
130
|
const { isString, forOwn, find } = this.lib._
|
|
131
131
|
|
|
132
132
|
ns = ns ?? [this.name]
|
|
@@ -2,7 +2,7 @@ import path from 'path'
|
|
|
2
2
|
|
|
3
3
|
async function attachment (req, reply) {
|
|
4
4
|
const { isString, isEmpty, find } = this.lib._
|
|
5
|
-
const { pascalCase } = this.
|
|
5
|
+
const { pascalCase } = this.lib.aneka
|
|
6
6
|
const { routePath } = this.app.waibu
|
|
7
7
|
const { fs } = this.lib
|
|
8
8
|
const items = await this.listAttachments({
|