dobo 1.2.10 → 2.0.1
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 +38 -19
- package/docs/Dobo.html +26 -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 +7 -0
- package/docs/index.html +3 -0
- package/docs/index.js.html +578 -0
- package/docs/lib_collect-connections.js.html +39 -0
- package/docs/lib_collect-drivers.js.html +52 -0
- package/docs/lib_collect-features.js.html +36 -0
- package/docs/lib_collect-schemas.js.html +94 -0
- package/docs/lib_index.js.html +6 -0
- package/docs/method_model_create.js.html +35 -0
- package/docs/method_model_drop.js.html +34 -0
- package/docs/method_model_exists.js.html +40 -0
- package/docs/method_record_count.js.html +69 -0
- package/docs/method_record_create.js.html +114 -0
- package/docs/method_record_find-all.js.html +44 -0
- package/docs/method_record_find-one.js.html +73 -0
- package/docs/method_record_find.js.html +118 -0
- package/docs/method_record_get.js.html +92 -0
- package/docs/method_record_remove.js.html +75 -0
- package/docs/method_record_update.js.html +107 -0
- package/docs/method_record_upsert.js.html +54 -0
- package/docs/method_sanitize_body.js.html +88 -0
- package/docs/method_sanitize_date.js.html +30 -0
- package/docs/method_sanitize_id.js.html +20 -0
- package/docs/method_validate.js.html +249 -0
- package/docs/module-Lib.html +3 -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/{bajo → extend/bajo}/intl/en-US.json +3 -2
- package/{bajo → extend/bajo}/intl/id.json +3 -2
- package/{bajoCli → extend/bajoCli}/applet/connection.js +5 -5
- package/extend/bajoCli/applet/lib/post-process.js +53 -0
- package/extend/bajoCli/applet/model-clear.js +11 -0
- package/{bajoCli → extend/bajoCli}/applet/model-rebuild.js +13 -13
- package/{bajoCli → extend/bajoCli}/applet/record-create.js +10 -8
- package/{bajoCli → extend/bajoCli}/applet/record-find.js +6 -5
- package/{bajoCli → extend/bajoCli}/applet/record-get.js +5 -5
- package/{bajoCli → extend/bajoCli}/applet/record-remove.js +5 -5
- package/{bajoCli → extend/bajoCli}/applet/record-update.js +9 -9
- package/{bajoCli → extend/bajoCli}/applet/schema.js +4 -4
- package/{bajoCli → extend/bajoCli}/applet/stat-count.js +4 -4
- package/{dobo → extend/dobo}/feature/created-at.js +1 -1
- package/{dobo → extend/dobo}/feature/removed-at.js +3 -3
- package/{dobo → extend/dobo}/feature/updated-at.js +2 -2
- package/{waibuMpa → extend/waibuMpa}/route/attachment/@model/@id/@field/@file.js +3 -3
- package/index.js +230 -72
- package/lib/add-fixtures.js +7 -6
- package/lib/build-bulk-action.js +2 -2
- package/lib/check-unique.js +2 -2
- package/lib/collect-connections.js +15 -4
- package/lib/collect-drivers.js +15 -6
- package/lib/{collect-feature.js → collect-features.js} +13 -4
- package/lib/collect-schemas.js +22 -12
- package/lib/exec-feature-hook.js +1 -1
- package/lib/exec-validation.js +5 -5
- package/lib/generic-prop-sanitizer.js +6 -5
- package/lib/handle-attachment-upload.js +2 -2
- package/lib/index.js +3 -0
- package/lib/mem-db/conn-sanitizer.js +1 -1
- package/lib/mem-db/instantiate.js +4 -4
- package/lib/mem-db/method/record/find.js +1 -1
- package/lib/mem-db/method/record/get.js +1 -1
- package/lib/mem-db/method/record/remove.js +1 -1
- package/lib/mem-db/method/record/update.js +1 -1
- package/lib/mem-db/start.js +1 -1
- package/lib/merge-attachment-info.js +2 -2
- package/lib/multi-rel-rows.js +2 -2
- package/lib/resolve-method.js +3 -3
- package/lib/sanitize-schema.js +8 -7
- package/lib/single-rel-rows.js +2 -2
- package/{plugin-method → method}/attachment/copy-uploaded.js +2 -2
- package/{plugin-method → method}/attachment/create.js +3 -3
- package/{plugin-method → method}/attachment/find.js +2 -2
- package/{plugin-method → method}/attachment/get-path.js +3 -3
- package/{plugin-method → method}/attachment/get.js +1 -1
- package/{plugin-method → method}/attachment/pre-check.js +1 -1
- package/{plugin-method → method}/attachment/remove.js +1 -1
- package/{plugin-method → method}/bulk/create.js +6 -6
- package/{plugin-method → method}/model/clear.js +5 -5
- package/method/model/create.js +32 -0
- package/method/model/drop.js +31 -0
- package/method/model/exists.js +37 -0
- package/{plugin-method → method}/record/clear.js +5 -5
- package/{plugin-method → method}/record/count.js +27 -5
- package/{plugin-method → method}/record/create.js +46 -6
- package/{plugin-method → method}/record/find-all.js +16 -0
- package/{plugin-method → method}/record/find-one.js +20 -6
- package/method/record/find.js +115 -0
- package/method/record/get.js +89 -0
- package/method/record/remove.js +72 -0
- package/{plugin-method → method}/record/update.js +47 -6
- package/{plugin-method → method}/record/upsert.js +18 -2
- package/{plugin-method → method}/sanitize/body.js +18 -3
- package/method/sanitize/date.js +27 -0
- package/{plugin-method → method}/sanitize/id.js +10 -0
- package/{plugin-method → method}/stat/aggregate.js +4 -4
- package/{plugin-method → method}/stat/histogram.js +4 -4
- package/{plugin-method → method}/validate.js +96 -7
- package/package.json +41 -36
- package/wiki/APPLETS.md +57 -0
- package/wiki/CONFIG.md +25 -0
- package/wiki/CONTRIBUTING.md +5 -0
- package/wiki/DEV-GUIDE.md +1 -0
- package/wiki/ECOSYSTEM.md +20 -0
- package/wiki/GETTING-STARTED.md +166 -0
- package/wiki/USER-GUIDE.md +1 -0
- package/bajoCli/applet/lib/post-process.js +0 -47
- package/bajoCli/applet/model-clear.js +0 -11
- package/plugin-method/model/create.js +0 -19
- package/plugin-method/model/drop.js +0 -19
- package/plugin-method/model/exists.js +0 -24
- package/plugin-method/record/find.js +0 -52
- package/plugin-method/record/get.js +0 -47
- package/plugin-method/record/remove.js +0 -41
- package/plugin-method/sanitize/date.js +0 -14
- /package/{bajoCli → extend/bajoCli}/applet.js +0 -0
- /package/{dobo → extend/dobo}/feature/dt.js +0 -0
- /package/{dobo → extend/dobo}/feature/int-id.js +0 -0
- /package/{waibuStatic → extend/waibuStatic}/virtual.json +0 -0
- /package/{plugin-method → method}/attachment/update.js +0 -0
- /package/{docs/query-language.md → wiki/QUERY-LANGUAGE.md} +0 -0
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import resolveMethod from '../../lib/resolve-method.js'
|
|
2
|
-
|
|
3
|
-
const cache = {}
|
|
4
|
-
|
|
5
|
-
async function exists (name, thrown, options = {}) {
|
|
6
|
-
if (cache[name]) return cache[name]
|
|
7
|
-
const { runHook } = this.app.bajo
|
|
8
|
-
const { camelCase } = this.lib._
|
|
9
|
-
const { handler, schema, driver } = await resolveMethod.call(this, name, 'model-exists', options)
|
|
10
|
-
if (!options.noHook) {
|
|
11
|
-
await runHook(`${this.name}:beforeModelExists`, schema, options)
|
|
12
|
-
await runHook(`${this.name}.${camelCase(name)}:beforeModelExists`, options)
|
|
13
|
-
}
|
|
14
|
-
const exist = await handler.call(this.app[driver.ns], { schema, options })
|
|
15
|
-
if (!options.noHook) {
|
|
16
|
-
await runHook(`${this.name}.${camelCase(name)}:afterModelExists`, exist, options)
|
|
17
|
-
await runHook(`${this.name}:afterModelExists`, schema, exist, options)
|
|
18
|
-
}
|
|
19
|
-
if (!exist && thrown) throw this.error('modelNotExists%s', name)
|
|
20
|
-
cache[name] = exist
|
|
21
|
-
return exist
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default exists
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import resolveMethod from '../../lib/resolve-method.js'
|
|
2
|
-
import multiRelRows from '../../lib/multi-rel-rows.js'
|
|
3
|
-
import execFeatureHook from '../../lib/exec-feature-hook.js'
|
|
4
|
-
|
|
5
|
-
async function find (name, filter = {}, opts = {}) {
|
|
6
|
-
const { isSet } = this.lib.aneka
|
|
7
|
-
const { runHook } = this.app.bajo
|
|
8
|
-
const { get, set } = this.cache ?? {}
|
|
9
|
-
const { cloneDeep, camelCase, omit } = this.lib._
|
|
10
|
-
delete opts.records
|
|
11
|
-
const options = cloneDeep(omit(opts, ['req', 'reply']))
|
|
12
|
-
options.req = opts.req
|
|
13
|
-
options.reply = opts.reply
|
|
14
|
-
options.dataOnly = options.dataOnly ?? true
|
|
15
|
-
let { fields, dataOnly, noHook, noCache, noFeatureHook, hidden, forceNoHidden } = options
|
|
16
|
-
options.count = options.count ?? false
|
|
17
|
-
options.dataOnly = false
|
|
18
|
-
await this.modelExists(name, true)
|
|
19
|
-
const { handler, schema, driver } = await resolveMethod.call(this, name, 'record-find', options)
|
|
20
|
-
if (!schema.cacheable) noCache = true
|
|
21
|
-
filter.query = this.buildQuery({ filter, schema, options }) ?? {}
|
|
22
|
-
if (options.queryHandler) filter.query = await options.queryHandler.call(opts.req ? this.app[opts.req.ns] : this, filter.query, opts.req)
|
|
23
|
-
filter.match = this.buildMatch({ input: filter.match, schema, options }) ?? {}
|
|
24
|
-
if (!noHook) {
|
|
25
|
-
await runHook(`${this.name}:beforeRecordFind`, name, filter, options)
|
|
26
|
-
await runHook(`${this.name}.${camelCase(name)}:beforeRecordFind`, filter, options)
|
|
27
|
-
}
|
|
28
|
-
if (!noFeatureHook) await execFeatureHook.call(this, 'beforeFind', { schema, filter, options })
|
|
29
|
-
if (get && !noCache && !options.records) {
|
|
30
|
-
const cachedResult = await get({ model: name, filter, options })
|
|
31
|
-
if (cachedResult) {
|
|
32
|
-
cachedResult.cached = true
|
|
33
|
-
if (!noFeatureHook) await execFeatureHook.call(this, 'afterFind', { schema, filter, options, records: cachedResult })
|
|
34
|
-
return dataOnly ? cachedResult.data : cachedResult
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const records = options.records ?? (await handler.call(this.app[driver.ns], { schema, filter, options }))
|
|
38
|
-
delete options.records
|
|
39
|
-
if (isSet(options.rels)) await multiRelRows.call(this, { schema, records: records.data, options })
|
|
40
|
-
for (const idx in records.data) {
|
|
41
|
-
records.data[idx] = await this.pickRecord({ record: records.data[idx], fields, schema, hidden, forceNoHidden })
|
|
42
|
-
}
|
|
43
|
-
if (!noHook) {
|
|
44
|
-
await runHook(`${this.name}.${camelCase(name)}:afterRecordFind`, filter, options, records)
|
|
45
|
-
await runHook(`${this.name}:afterRecordFind`, name, filter, options, records)
|
|
46
|
-
}
|
|
47
|
-
if (set && !noCache) await set({ model: name, filter, options, records })
|
|
48
|
-
if (!noFeatureHook) await execFeatureHook.call(this, 'afterFind', { schema, filter, options, records })
|
|
49
|
-
return dataOnly ? records.data : records
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default find
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import resolveMethod from '../../lib/resolve-method.js'
|
|
2
|
-
import singleRelRows from '../../lib/single-rel-rows.js'
|
|
3
|
-
import execFeatureHook from '../../lib/exec-feature-hook.js'
|
|
4
|
-
|
|
5
|
-
async function get (name, id, opts = {}) {
|
|
6
|
-
const { isSet } = this.lib.aneka
|
|
7
|
-
const { runHook } = this.app.bajo
|
|
8
|
-
const { get, set } = this.cache ?? {}
|
|
9
|
-
const { cloneDeep, camelCase, omit } = this.lib._
|
|
10
|
-
delete opts.record
|
|
11
|
-
const options = cloneDeep(omit(opts, ['req', 'reply']))
|
|
12
|
-
options.req = opts.req
|
|
13
|
-
options.reply = opts.reply
|
|
14
|
-
options.dataOnly = options.dataOnly ?? true
|
|
15
|
-
let { fields, dataOnly, noHook, noCache, noFeatureHook, hidden = [], forceNoHidden } = options
|
|
16
|
-
await this.modelExists(name, true)
|
|
17
|
-
const { handler, schema, driver } = await resolveMethod.call(this, name, 'record-get', options)
|
|
18
|
-
if (!schema.cacheable) noCache = true
|
|
19
|
-
id = this.sanitizeId(id, schema)
|
|
20
|
-
options.dataOnly = false
|
|
21
|
-
if (!noHook) {
|
|
22
|
-
await runHook(`${this.name}:beforeRecordGet`, name, id, options)
|
|
23
|
-
await runHook(`${this.name}.${camelCase(name)}:beforeRecordGet`, id, options)
|
|
24
|
-
}
|
|
25
|
-
if (!noFeatureHook) await execFeatureHook.call(this, 'beforeGet', { schema, id, options })
|
|
26
|
-
if (get && !noCache && !options.record) {
|
|
27
|
-
const cachedResult = await get({ model: name, id, options })
|
|
28
|
-
if (cachedResult) {
|
|
29
|
-
cachedResult.cached = true
|
|
30
|
-
if (!noFeatureHook) await execFeatureHook.call(this, 'afterGet', { schema, id, options, record: cachedResult })
|
|
31
|
-
return dataOnly ? cachedResult.data : cachedResult
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const record = options.record ?? (await handler.call(this.app[driver.ns], { schema, id, options }))
|
|
35
|
-
delete options.record
|
|
36
|
-
if (isSet(options.rels)) await singleRelRows.call(this, { schema, record: record.data, options })
|
|
37
|
-
record.data = await this.pickRecord({ record: record.data, fields, schema, hidden, forceNoHidden })
|
|
38
|
-
if (!noHook) {
|
|
39
|
-
await runHook(`${this.name}.${camelCase(name)}:afterRecordGet`, id, options, record)
|
|
40
|
-
await runHook(`${this.name}:afterRecordGet`, name, id, options, record)
|
|
41
|
-
}
|
|
42
|
-
if (set && !noCache) await set({ model: name, id, options, record })
|
|
43
|
-
if (!noFeatureHook) await execFeatureHook.call(this, 'afterGet', { schema, id, options, record })
|
|
44
|
-
return dataOnly ? record.data : record
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default get
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import resolveMethod from '../../lib/resolve-method.js'
|
|
2
|
-
import handleAttachmentUpload from '../../lib/handle-attachment-upload.js'
|
|
3
|
-
import execFeatureHook from '../../lib/exec-feature-hook.js'
|
|
4
|
-
|
|
5
|
-
async function remove (name, id, opts = {}) {
|
|
6
|
-
const { runHook } = this.app.bajo
|
|
7
|
-
const { clearModel } = this.cache ?? {}
|
|
8
|
-
const { cloneDeep, camelCase, omit } = this.lib._
|
|
9
|
-
delete opts.record
|
|
10
|
-
const options = cloneDeep(omit(opts, ['req', 'reply']))
|
|
11
|
-
options.req = opts.req
|
|
12
|
-
options.reply = opts.reply
|
|
13
|
-
options.dataOnly = options.dataOnly ?? true
|
|
14
|
-
const { fields, dataOnly, noHook, noResult, noFeatureHook, hidden, forceNoHidden } = options
|
|
15
|
-
options.dataOnly = false
|
|
16
|
-
await this.modelExists(name, true)
|
|
17
|
-
const { handler, schema, driver } = await resolveMethod.call(this, name, 'record-remove', options)
|
|
18
|
-
id = this.sanitizeId(id, schema)
|
|
19
|
-
if (!noHook) {
|
|
20
|
-
await runHook(`${this.name}:beforeRecordRemove`, name, id, options)
|
|
21
|
-
await runHook(`${this.name}.${camelCase(name)}:beforeRecordRemove`, id, options)
|
|
22
|
-
}
|
|
23
|
-
if (!noFeatureHook) await execFeatureHook.call(this, 'beforeRemove', { schema, id, options })
|
|
24
|
-
const record = options.record ?? (await handler.call(this.app[driver.ns], { schema, id, options }))
|
|
25
|
-
delete options.record
|
|
26
|
-
if (options.req) {
|
|
27
|
-
if (options.req.file) await handleAttachmentUpload.call(this, { name: schema.name, id, options, action: 'remove' })
|
|
28
|
-
if (options.req.flash && !options.noFlash) options.req.flash('notify', options.req.t('recordRemoved'))
|
|
29
|
-
}
|
|
30
|
-
if (clearModel) await clearModel({ model: name, id, options, record })
|
|
31
|
-
if (noResult) return
|
|
32
|
-
record.oldData = options.record ? options.record.oldData : (await this.pickRecord({ record: record.oldData, fields, schema, hidden, forceNoHidden }))
|
|
33
|
-
if (!noHook) {
|
|
34
|
-
await runHook(`${this.name}.${camelCase(name)}:afterRecordRemove`, id, options, record)
|
|
35
|
-
await runHook(`${this.name}:afterRecordRemove`, name, id, options, record)
|
|
36
|
-
}
|
|
37
|
-
if (!noFeatureHook) await execFeatureHook.call(this, 'afterRemove', { schema, id, options, record })
|
|
38
|
-
return dataOnly ? record.oldData : record
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default remove
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function sanitizeDate (value, { input, output, silent = true } = {}) {
|
|
2
|
-
const { dayjs } = this.lib
|
|
3
|
-
if (value === 0) return null
|
|
4
|
-
if (!output) output = input
|
|
5
|
-
const dt = dayjs(value, input)
|
|
6
|
-
if (!dt.isValid()) {
|
|
7
|
-
if (silent) return -1
|
|
8
|
-
throw this.error('invalidDate')
|
|
9
|
-
}
|
|
10
|
-
if (output === 'native' || !output) return dt.toDate()
|
|
11
|
-
return dt.format(output)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default sanitizeDate
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|