waibu-db 2.0.0 → 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/README.md +31 -9
- package/docs/WaibuDb.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 +116 -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 +23 -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/waibuBootstrap/theme/component/factory/btn-add.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/btn-back.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/btn-clone.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/btn-columns.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/btn-delete.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/btn-details.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/btn-edit.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/btn-export.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/echarts-bar.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/echarts-pie.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/echarts.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/form.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/pagination.js +2 -2
- package/extend/waibuBootstrap/theme/component/factory/query.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/recs-info.js +1 -1
- package/extend/waibuBootstrap/theme/component/factory/table.js +4 -4
- package/extend/waibuRestApi/route/@model/find.js +1 -1
- package/index.js +22 -8
- package/lib/crud/add-handler.js +3 -3
- package/lib/crud/all-handler.js +1 -1
- package/lib/crud/delete-handler.js +2 -2
- package/lib/crud/details-handler.js +2 -2
- package/lib/crud/edit-handler.js +4 -4
- package/lib/crud/export-handler.js +4 -4
- package/lib/crud/helper/add-ons-handler.js +1 -1
- package/lib/crud/helper/build-params.js +1 -1
- package/lib/crud/list-handler.js +2 -2
- package/lib/prep-crud.js +2 -2
- package/method/format-record.js +2 -2
- package/method/get-lookup-data.js +1 -1
- package/method/get-params.js +1 -1
- package/method/get-schema-ext.js +10 -10
- package/package.json +8 -3
- package/wiki/CONFIG.md +3 -0
- package/wiki/CONTRIBUTING.md +5 -0
|
@@ -28,7 +28,7 @@ async function echarts () {
|
|
|
28
28
|
|
|
29
29
|
_build = ({ setting = {}, onLoad = [] } = {}) => {
|
|
30
30
|
const { jsonStringify } = this.plugin.app.waibuMpa
|
|
31
|
-
const { merge, isArray } = this.
|
|
31
|
+
const { merge, isArray } = this.app.lib._
|
|
32
32
|
if (!isArray(onLoad)) onLoad = [onLoad]
|
|
33
33
|
const option = merge({}, this.defSetting, this.setting, setting)
|
|
34
34
|
this.component.addScriptBlock('alpineInit', `
|
|
@@ -5,7 +5,7 @@ async function form () {
|
|
|
5
5
|
|
|
6
6
|
return class WdbForm extends WdbBase {
|
|
7
7
|
build = async () => {
|
|
8
|
-
const { get, find, filter, forOwn, isEmpty } = this.
|
|
8
|
+
const { get, find, filter, forOwn, isEmpty } = this.app.lib._
|
|
9
9
|
const { base64JsonEncode } = this.plugin.app.waibuMpa
|
|
10
10
|
const schema = get(this, 'component.locals.schema', {})
|
|
11
11
|
const body = []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import wdbBase from '../wdb-base.js'
|
|
2
2
|
|
|
3
3
|
export function getUrlOpts (params = {}) {
|
|
4
|
-
const { get } = this.
|
|
4
|
+
const { get } = this.app.lib._
|
|
5
5
|
return {
|
|
6
6
|
params,
|
|
7
7
|
excludes: [
|
|
@@ -18,7 +18,7 @@ async function pagination () {
|
|
|
18
18
|
build = async () => {
|
|
19
19
|
const { req } = this.component
|
|
20
20
|
const { attrToObject, paginationLayout, groupAttrs } = this.plugin.app.waibuMpa
|
|
21
|
-
const { get, isNumber } = this.
|
|
21
|
+
const { get, isNumber } = this.app.lib._
|
|
22
22
|
const schema = get(this, 'component.locals.schema', {})
|
|
23
23
|
if (schema.view.disabled.includes('find')) {
|
|
24
24
|
this.params.html = ''
|
|
@@ -7,7 +7,7 @@ async function query () {
|
|
|
7
7
|
build = async () => {
|
|
8
8
|
const { generateId } = this.plugin.app.bajo
|
|
9
9
|
const { jsonStringify } = this.plugin.app.waibuMpa
|
|
10
|
-
const { find, get, without, isEmpty, filter, upperFirst } = this.
|
|
10
|
+
const { find, get, without, isEmpty, filter, upperFirst } = this.app.lib._
|
|
11
11
|
const qsKey = this.plugin.app.waibu.config.qsKey
|
|
12
12
|
const schema = get(this, 'component.locals.schema', {})
|
|
13
13
|
if (schema.view.disabled.includes('find')) {
|
|
@@ -8,7 +8,7 @@ async function recsInfo () {
|
|
|
8
8
|
build = async () => {
|
|
9
9
|
const { req } = this.component
|
|
10
10
|
const { attrToObject, groupAttrs, attrToArray } = this.plugin.app.waibuMpa
|
|
11
|
-
const { get, isEmpty, omit, merge } = this.
|
|
11
|
+
const { get, isEmpty, omit, merge } = this.app.lib._
|
|
12
12
|
const schema = get(this, 'component.locals.schema', {})
|
|
13
13
|
if (schema.view.disabled.includes('find')) {
|
|
14
14
|
this.params.html = ''
|
|
@@ -5,7 +5,7 @@ async function table () {
|
|
|
5
5
|
|
|
6
6
|
return class WdbTable extends WdbBase {
|
|
7
7
|
isRightAligned = (field, schema) => {
|
|
8
|
-
const { get, find } = this.
|
|
8
|
+
const { get, find } = this.app.lib._
|
|
9
9
|
const prop = find(schema.properties, { name: field })
|
|
10
10
|
if (!prop) return false
|
|
11
11
|
let value = get(schema, 'view.alignEnd', []).includes(field)
|
|
@@ -15,12 +15,12 @@ async function table () {
|
|
|
15
15
|
|
|
16
16
|
isNoWrap = (field, schema, bodyNowrap) => {
|
|
17
17
|
if (bodyNowrap) return true
|
|
18
|
-
const { get } = this.
|
|
18
|
+
const { get } = this.app.lib._
|
|
19
19
|
return get(schema, 'view.noWrap', []).includes(field)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
_defFormatter = async ({ req, key, value, data, schema }) => {
|
|
23
|
-
const { get, find } = this.
|
|
23
|
+
const { get, find } = this.app.lib._
|
|
24
24
|
const { escape } = this.plugin.app.waibu
|
|
25
25
|
const prop = find(schema.properties, { name: key })
|
|
26
26
|
if (!prop) return value
|
|
@@ -38,7 +38,7 @@ async function table () {
|
|
|
38
38
|
const { escape } = this.plugin.app.waibu
|
|
39
39
|
const { formatRecord } = this.plugin.app.waibuDb
|
|
40
40
|
const { attrToArray, groupAttrs } = this.plugin.app.waibuMpa
|
|
41
|
-
const { get, omit, set, find, isEmpty, without, merge } = this.
|
|
41
|
+
const { get, omit, set, find, isEmpty, without, merge } = this.app.lib._
|
|
42
42
|
const group = groupAttrs(this.params.attr, ['body', 'head', 'foot'])
|
|
43
43
|
this.params.attr = group._
|
|
44
44
|
const prettyUrl = this.params.attr.prettyUrl
|
package/index.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin factory
|
|
3
|
+
*
|
|
4
|
+
* @param {string} pkgName - NPM package name
|
|
5
|
+
* @returns {class}
|
|
6
|
+
*/
|
|
1
7
|
async function factory (pkgName) {
|
|
2
8
|
const me = this
|
|
3
9
|
|
|
4
|
-
|
|
10
|
+
/**
|
|
11
|
+
* WaibuDb class
|
|
12
|
+
*
|
|
13
|
+
* @class
|
|
14
|
+
*/
|
|
15
|
+
class WaibuDb extends this.app.pluginClass.base {
|
|
16
|
+
static alias = 'wdb'
|
|
17
|
+
static dependencies = ['dobo', 'waibu', 'bajo-queue', 'dobo-extra']
|
|
18
|
+
|
|
5
19
|
constructor () {
|
|
6
20
|
super(pkgName, me.app)
|
|
7
|
-
this.alias = 'wdb'
|
|
8
|
-
this.dependencies = ['dobo', 'waibu', 'bajo-queue', 'dobo-extra']
|
|
9
21
|
this.config = {
|
|
10
22
|
waibu: {
|
|
11
23
|
prefix: 'db',
|
|
@@ -28,8 +40,8 @@ async function factory (pkgName) {
|
|
|
28
40
|
|
|
29
41
|
exportData = async (params) => {
|
|
30
42
|
const { getPlugin } = this.app.bajo
|
|
31
|
-
const { get } = this.lib._
|
|
32
|
-
const { fs } = this.lib
|
|
43
|
+
const { get } = this.app.lib._
|
|
44
|
+
const { fs } = this.app.lib
|
|
33
45
|
const { recordUpdate } = this.app.dobo
|
|
34
46
|
const { exportTo } = this.app.doboExtra
|
|
35
47
|
const { downloadDir } = getPlugin('sumba')
|
|
@@ -56,11 +68,11 @@ async function factory (pkgName) {
|
|
|
56
68
|
|
|
57
69
|
adminMenu = async (locals, req) => {
|
|
58
70
|
const { getPluginPrefix } = this.app.waibu
|
|
59
|
-
const { pascalCase } = this.lib.aneka
|
|
71
|
+
const { pascalCase } = this.app.lib.aneka
|
|
60
72
|
const { getAppTitle } = this.app.waibuMpa
|
|
61
|
-
const { camelCase, map, pick, groupBy, keys, kebabCase, filter, get } = this.lib._
|
|
73
|
+
const { camelCase, map, pick, groupBy, keys, kebabCase, filter, get } = this.app.lib._
|
|
62
74
|
|
|
63
|
-
const prefix = getPluginPrefix(this.
|
|
75
|
+
const prefix = getPluginPrefix(this.ns)
|
|
64
76
|
const schemas = filter(this.app.dobo.schemas, s => {
|
|
65
77
|
const byModelFind = !s.disabled.includes('find')
|
|
66
78
|
let modelDisabled = get(this, `app.${s.ns}.config.waibuAdmin.modelDisabled`)
|
|
@@ -94,6 +106,8 @@ async function factory (pkgName) {
|
|
|
94
106
|
return menu
|
|
95
107
|
}
|
|
96
108
|
}
|
|
109
|
+
|
|
110
|
+
return WaibuDb
|
|
97
111
|
}
|
|
98
112
|
|
|
99
113
|
export default factory
|
package/lib/crud/add-handler.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
async function addHandler ({ req, reply, model, params = {}, template, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html', options = {} } = {}) {
|
|
2
|
-
const { pascalCase } = this.lib.aneka
|
|
2
|
+
const { pascalCase } = this.app.lib.aneka
|
|
3
3
|
const { recordCreate, recordGet, getSchemaExt } = this.app.waibuDb
|
|
4
4
|
const { buildUrl } = this.app.waibuMpa
|
|
5
|
-
const { defaultsDeep } = this.lib.aneka
|
|
6
|
-
const { pick, map, merge, omit, isEmpty } = this.lib._
|
|
5
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
6
|
+
const { pick, map, merge, omit, isEmpty } = this.app.lib._
|
|
7
7
|
const opts = {}
|
|
8
8
|
model = model ?? pascalCase(req.params.model)
|
|
9
9
|
const { schema } = await getSchemaExt(model, 'add', merge({}, { params }, options))
|
package/lib/crud/all-handler.js
CHANGED
|
@@ -18,7 +18,7 @@ const handler = {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async function allHandler ({ model, action, req, reply, template, params = {}, options = {} }) {
|
|
21
|
-
const { upperFirst, merge, keys } = this.lib._
|
|
21
|
+
const { upperFirst, merge, keys } = this.app.lib._
|
|
22
22
|
if (!keys(handler).includes(action)) throw this.error('_notFound')
|
|
23
23
|
if (['delete', 'export'].includes(action)) {
|
|
24
24
|
if (req.method === 'GET') throw this.error('_notFound')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
async function deleteHandler ({ req, reply, model, params = {}, templateDisabled = 'waibuDb.template:/disabled.html', options = {} } = {}) {
|
|
2
|
-
const { pascalCase } = this.lib.aneka
|
|
2
|
+
const { pascalCase } = this.app.lib.aneka
|
|
3
3
|
const { recordRemove, getSchemaExt } = this.app.waibuDb
|
|
4
4
|
const { buildUrl } = this.app.waibuMpa
|
|
5
|
-
const { reduce, merge } = this.lib._
|
|
5
|
+
const { reduce, merge } = this.app.lib._
|
|
6
6
|
const opts = {}
|
|
7
7
|
model = model ?? pascalCase(req.params.model)
|
|
8
8
|
const { schema } = await getSchemaExt(model, 'add', merge({}, { params }, options))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import attachmentHandler from './helper/attachment-handler.js'
|
|
2
2
|
|
|
3
3
|
async function detailsHandler ({ req, reply, model, params = {}, id, template, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html', options } = {}) {
|
|
4
|
-
const { pascalCase } = this.lib.aneka
|
|
4
|
+
const { pascalCase } = this.app.lib.aneka
|
|
5
5
|
const { recordGet, getSchemaExt } = this.app.waibuDb
|
|
6
|
-
const { merge } = this.lib._
|
|
6
|
+
const { merge } = this.app.lib._
|
|
7
7
|
const opts = { rels: '*' }
|
|
8
8
|
model = model ?? pascalCase(req.params.model)
|
|
9
9
|
const { schema } = await getSchemaExt(model, 'details', merge({}, { params }, options))
|
package/lib/crud/edit-handler.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import attachmentHandler from './helper/attachment-handler.js'
|
|
2
2
|
|
|
3
3
|
async function editHandler ({ req, reply, model, id, params = {}, template, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html', options = {} } = {}) {
|
|
4
|
-
const { pascalCase } = this.lib.aneka
|
|
4
|
+
const { pascalCase } = this.app.lib.aneka
|
|
5
5
|
const { getPluginDataDir } = this.app.bajo
|
|
6
6
|
const { recordUpdate, recordGet, getSchemaExt } = this.app.waibuDb
|
|
7
7
|
const { buildUrl } = this.app.waibuMpa
|
|
8
|
-
const { fs } = this.lib
|
|
9
|
-
const { defaultsDeep } = this.lib.aneka
|
|
10
|
-
const { merge, isEmpty, omit } = this.lib._
|
|
8
|
+
const { fs } = this.app.lib
|
|
9
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
10
|
+
const { merge, isEmpty, omit } = this.app.lib._
|
|
11
11
|
const opts = {}
|
|
12
12
|
let error
|
|
13
13
|
let resp
|
|
@@ -2,9 +2,9 @@ import prepCrud from '../prep-crud.js'
|
|
|
2
2
|
|
|
3
3
|
async function exportHandler ({ req, reply, model, params = {}, templateDisabled = 'waibuDb.template:/disabled.html', options = {} } = {}) {
|
|
4
4
|
const { getPlugin } = this.app.bajo
|
|
5
|
-
const { dayjs } = this.lib
|
|
6
|
-
const { omit, kebabCase, get, merge } = this.lib._
|
|
7
|
-
const { pascalCase } = this.lib.aneka
|
|
5
|
+
const { dayjs } = this.app.lib
|
|
6
|
+
const { omit, kebabCase, get, merge } = this.app.lib._
|
|
7
|
+
const { pascalCase } = this.app.lib.aneka
|
|
8
8
|
const { getSchemaExt } = this.app.waibuDb
|
|
9
9
|
const { buildUrl } = this.app.waibuMpa
|
|
10
10
|
const { pushDownload } = getPlugin('sumba')
|
|
@@ -13,7 +13,7 @@ async function exportHandler ({ req, reply, model, params = {}, templateDisabled
|
|
|
13
13
|
if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
|
|
14
14
|
const data = prepCrud.call(getPlugin('waibuDb'), { model, req, reply, args: ['model'] })
|
|
15
15
|
data.opts = omit(data.opts, ['req', 'reply'])
|
|
16
|
-
const source = `${this.
|
|
16
|
+
const source = `${this.ns}:/export-handler`
|
|
17
17
|
const worker = 'waibuDb:exportData'
|
|
18
18
|
const type = get(data, 'input.ftype', 'json')
|
|
19
19
|
const settings = get(data, 'input.options', '').split(',')
|
|
@@ -2,7 +2,7 @@ async function addOnsHandler ({ req, reply, data, schema, options = {} }) {
|
|
|
2
2
|
const { escape } = this.app.waibu
|
|
3
3
|
const { base64JsonEncode } = this.app.waibuMpa
|
|
4
4
|
const { statAggregate } = this.app.waibuDb
|
|
5
|
-
const { get, map, pick, pullAt } = this.lib._
|
|
5
|
+
const { get, map, pick, pullAt } = this.app.lib._
|
|
6
6
|
const opts = map(get(schema, 'view.stat.aggregate', []), item => {
|
|
7
7
|
const dbOpts = pick(item, ['fields', 'group', 'aggregate'])
|
|
8
8
|
const name = item.name ?? `field.${item.fields[0]}`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function buildParams ({ model, req, reply, action, options = {} }) {
|
|
2
|
-
const { camelCase, kebabCase, map, upperFirst, get } = this.lib._
|
|
2
|
+
const { camelCase, kebabCase, map, upperFirst, get } = this.app.lib._
|
|
3
3
|
const { getSchema } = this.app.dobo
|
|
4
4
|
const [, ...names] = map(kebabCase(model).split('-'), n => upperFirst(n))
|
|
5
5
|
const schema = getSchema(camelCase(model), false)
|
package/lib/crud/list-handler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
async function listHandler ({ req, reply, model, template, params = {}, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html', options = {} } = {}) {
|
|
2
|
-
const { pascalCase } = this.lib.aneka
|
|
2
|
+
const { pascalCase } = this.app.lib.aneka
|
|
3
3
|
const { recordFind, getSchemaExt } = this.app.waibuDb
|
|
4
|
-
const { get, merge, isArray, upperFirst } = this.lib._
|
|
4
|
+
const { get, merge, isArray, upperFirst } = this.app.lib._
|
|
5
5
|
const qsKey = this.app.waibu.config.qsKey
|
|
6
6
|
model = model ?? pascalCase(req.params.model)
|
|
7
7
|
const { schema } = await getSchemaExt(model, 'list', merge({}, { params }, options))
|
package/lib/prep-crud.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function prepCrud ({ model, body, id, req, reply, options = {}, args }) {
|
|
2
2
|
const { parseFilter } = this.app.waibu
|
|
3
3
|
const { buildQuery, getInfo } = this.app.dobo
|
|
4
|
-
const { pascalCase } = this.lib.aneka
|
|
5
|
-
const { cloneDeep, has } = this.lib._
|
|
4
|
+
const { pascalCase } = this.app.lib.aneka
|
|
5
|
+
const { cloneDeep, has } = this.app.lib._
|
|
6
6
|
const cfgWeb = this.app.waibu.getConfig()
|
|
7
7
|
const opts = cloneDeep(options)
|
|
8
8
|
const params = this.getParams(req, ...args)
|
package/method/format-record.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
async function formatRow ({ data, req, schema, options = {} }) {
|
|
2
|
-
const { get, find, isFunction, cloneDeep } = this.lib._
|
|
2
|
+
const { get, find, isFunction, cloneDeep } = this.app.lib._
|
|
3
3
|
const { format, callHandler } = this.app.bajo
|
|
4
4
|
const { escape } = this.app.waibu
|
|
5
5
|
const fields = get(schema, 'view.fields', Object.keys(schema.properties))
|
|
@@ -28,7 +28,7 @@ async function formatRow ({ data, req, schema, options = {} }) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
async function formatRecord ({ data, req, schema, options = {} }) {
|
|
31
|
-
const { isArray } = this.lib._
|
|
31
|
+
const { isArray } = this.app.lib._
|
|
32
32
|
if (!isArray(data)) return await formatRow.call(this, { data, req, schema, options })
|
|
33
33
|
const items = []
|
|
34
34
|
for (const d of data) {
|
package/method/get-params.js
CHANGED
package/method/get-schema-ext.js
CHANGED
|
@@ -5,8 +5,8 @@ const defReadonly = ['id', 'createdAt', 'updatedAt']
|
|
|
5
5
|
const defFormatter = {}
|
|
6
6
|
|
|
7
7
|
function getCommons (action, schema, ext, options = {}) {
|
|
8
|
-
const { defaultsDeep } = this.lib.aneka
|
|
9
|
-
const { merge, map, get, set, without, uniq, pull } = this.lib._
|
|
8
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
9
|
+
const { merge, map, get, set, without, uniq, pull } = this.app.lib._
|
|
10
10
|
const calcFields = get(ext, `view.${action}.calcFields`, get(ext, 'common.calcFields', []))
|
|
11
11
|
const forceVisible = get(ext, `view.${action}.forceVisible`, get(ext, 'common.forceVisible', []))
|
|
12
12
|
const widget = defaultsDeep(get(ext, `view.${action}.widget`), get(ext, 'common.widget', {}))
|
|
@@ -54,7 +54,7 @@ function getCommons (action, schema, ext, options = {}) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function autoLayout ({ action, schema, ext, layout }) {
|
|
57
|
-
const { forOwn, keys } = this.lib._
|
|
57
|
+
const { forOwn, keys } = this.app.lib._
|
|
58
58
|
const matches = ['id', 'createdAt', 'updatedAt']
|
|
59
59
|
const meta = []
|
|
60
60
|
const general = []
|
|
@@ -70,8 +70,8 @@ function autoLayout ({ action, schema, ext, layout }) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
function customLayout ({ action, schema, ext, layout, readonly }) {
|
|
73
|
-
const { defaultsDeep } = this.lib.aneka
|
|
74
|
-
const { isEmpty } = this.lib._
|
|
73
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
74
|
+
const { isEmpty } = this.app.lib._
|
|
75
75
|
const items = [...layout]
|
|
76
76
|
for (const item of items) {
|
|
77
77
|
for (const idx in item.fields) {
|
|
@@ -88,8 +88,8 @@ function customLayout ({ action, schema, ext, layout, readonly }) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
function applyLayout (action, schema, ext) {
|
|
91
|
-
const { defaultsDeep } = this.lib.aneka
|
|
92
|
-
const { set, get, isEmpty, find, kebabCase } = this.lib._
|
|
91
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
92
|
+
const { set, get, isEmpty, find, kebabCase } = this.app.lib._
|
|
93
93
|
const { fields, card, calcFields } = getCommons.call(this, action, schema, ext)
|
|
94
94
|
const layout = get(ext, `view.${action}.layout`, get(ext, 'common.layout', []))
|
|
95
95
|
const readonly = get(ext, `view.${action}.readonly`, get(ext, 'common.readonly', defReadonly))
|
|
@@ -140,7 +140,7 @@ function applyLayout (action, schema, ext) {
|
|
|
140
140
|
|
|
141
141
|
const handler = {
|
|
142
142
|
list: async function (schema, ext, options) {
|
|
143
|
-
const { get, set } = this.lib._
|
|
143
|
+
const { get, set } = this.app.lib._
|
|
144
144
|
const { fields } = getCommons.call(this, 'list', schema, ext, options)
|
|
145
145
|
const qsFields = []
|
|
146
146
|
for (const f of get(schema, 'view.qs.fields', '').split(',')) {
|
|
@@ -169,9 +169,9 @@ const handler = {
|
|
|
169
169
|
|
|
170
170
|
async function getSchemaExt (model, view, options = {}) {
|
|
171
171
|
const { readConfig } = this.app.bajo
|
|
172
|
-
const { defaultsDeep } = this.lib.aneka
|
|
172
|
+
const { defaultsDeep } = this.app.lib.aneka
|
|
173
173
|
const { getSchema } = this.app.dobo
|
|
174
|
-
const { pick } = this.lib._
|
|
174
|
+
const { pick } = this.app.lib._
|
|
175
175
|
|
|
176
176
|
let schema = getSchema(model)
|
|
177
177
|
const base = path.basename(schema.file, path.extname(schema.file))
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waibu-db",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "DB Helper",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"build-doc": "jsdoc -c .jsdoc.conf.json",
|
|
8
|
+
"test": "mocha"
|
|
8
9
|
},
|
|
9
10
|
"type": "module",
|
|
10
11
|
"bajo": {
|
|
@@ -29,5 +30,9 @@
|
|
|
29
30
|
"bugs": {
|
|
30
31
|
"url": "https://github.com/ardhi/waibu-db/issues"
|
|
31
32
|
},
|
|
32
|
-
"homepage": "https://github.com/ardhi/waibu-db#readme"
|
|
33
|
+
"homepage": "https://github.com/ardhi/waibu-db#readme",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"clean-jsdoc-theme": "^4.3.0",
|
|
36
|
+
"jsdoc-plugin-intersection": "^1.0.4"
|
|
37
|
+
}
|
|
33
38
|
}
|
package/wiki/CONFIG.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks very much to everyone who wants to join as a contributor, but I have committed to devoting 100% of my time to this project. Therefore, I'm currently unable to accept pull requests from anyone until the project is large enough for me to manage it independently.
|
|
4
|
+
|
|
5
|
+
However, I am available if you encounter any bugs that require immediate fixes. Please report your issues in a GitHub issue, and I'll try to address them promptly. I'm also open to criticism and suggestions for improvements or requests for new features.
|