waibu-db 1.2.12 → 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.
Files changed (111) hide show
  1. package/.github/FUNDING.yml +13 -0
  2. package/.github/workflows/repo-lockdown.yml +24 -0
  3. package/.jsdoc.conf.json +45 -0
  4. package/README.md +31 -9
  5. package/docs/WaibuDb.html +3 -0
  6. package/docs/data/search.json +1 -0
  7. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  8. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  9. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  10. package/docs/global.html +3 -0
  11. package/docs/index.html +3 -0
  12. package/docs/index.js.html +116 -0
  13. package/docs/scripts/core.js +726 -0
  14. package/docs/scripts/core.min.js +23 -0
  15. package/docs/scripts/resize.js +90 -0
  16. package/docs/scripts/search.js +265 -0
  17. package/docs/scripts/search.min.js +6 -0
  18. package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
  19. package/docs/scripts/third-party/fuse.js +9 -0
  20. package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
  21. package/docs/scripts/third-party/hljs-line-num.js +1 -0
  22. package/docs/scripts/third-party/hljs-original.js +5171 -0
  23. package/docs/scripts/third-party/hljs.js +1 -0
  24. package/docs/scripts/third-party/popper.js +5 -0
  25. package/docs/scripts/third-party/tippy.js +1 -0
  26. package/docs/scripts/third-party/tocbot.js +672 -0
  27. package/docs/scripts/third-party/tocbot.min.js +1 -0
  28. package/docs/static/bitcoin.jpeg +0 -0
  29. package/docs/static/home.md +23 -0
  30. package/docs/static/logo-ecosystem.png +0 -0
  31. package/docs/static/logo.png +0 -0
  32. package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
  33. package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
  34. package/docs/styles/clean-jsdoc-theme-light.css +482 -0
  35. package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  36. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  37. package/docs/styles/clean-jsdoc-theme.min.css +1 -0
  38. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/btn-add.js +1 -1
  39. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/btn-back.js +1 -1
  40. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/btn-clone.js +1 -1
  41. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/btn-columns.js +1 -1
  42. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/btn-delete.js +1 -1
  43. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/btn-details.js +1 -1
  44. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/btn-edit.js +1 -1
  45. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/btn-export.js +1 -1
  46. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/echarts-bar.js +1 -1
  47. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/echarts-pie.js +1 -1
  48. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/echarts.js +1 -1
  49. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/form.js +1 -1
  50. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/pagination.js +2 -2
  51. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/query.js +1 -1
  52. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/recs-info.js +1 -1
  53. package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/factory/table.js +4 -4
  54. package/{waibuRestApi → extend/waibuRestApi}/route/@model/find.js +1 -1
  55. package/index.js +22 -8
  56. package/lib/crud/add-handler.js +3 -3
  57. package/lib/crud/all-handler.js +1 -1
  58. package/lib/crud/delete-handler.js +2 -2
  59. package/lib/crud/details-handler.js +2 -2
  60. package/lib/crud/edit-handler.js +4 -4
  61. package/lib/crud/export-handler.js +4 -4
  62. package/lib/crud/helper/add-ons-handler.js +1 -1
  63. package/lib/crud/helper/build-params.js +1 -1
  64. package/lib/crud/list-handler.js +2 -2
  65. package/lib/prep-crud.js +2 -2
  66. package/{plugin-method → method}/format-record.js +2 -2
  67. package/{plugin-method → method}/get-lookup-data.js +1 -1
  68. package/{plugin-method → method}/get-params.js +1 -1
  69. package/{plugin-method → method}/get-schema-ext.js +12 -12
  70. package/package.json +8 -3
  71. package/wiki/CONFIG.md +3 -0
  72. package/wiki/CONTRIBUTING.md +5 -0
  73. /package/{bajo → extend/bajo}/hook/waibu-rest-api@after-init.js +0 -0
  74. /package/{bajo → extend/bajo}/intl/en-US.json +0 -0
  75. /package/{bajo → extend/bajo}/intl/id.json +0 -0
  76. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_add-attachment.html +0 -0
  77. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_add-btns.html +0 -0
  78. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_addons.html +0 -0
  79. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_details-attachment.html +0 -0
  80. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_details-btns.html +0 -0
  81. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_edit-attachment.html +0 -0
  82. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_edit-btns.html +0 -0
  83. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_list-attachment.html +0 -0
  84. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_list-btns.html +0 -0
  85. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/_list-footer.html +0 -0
  86. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/add-handler.html +0 -0
  87. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/details-handler.html +0 -0
  88. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/edit-handler.html +0 -0
  89. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/list-handler.html +0 -0
  90. /package/{bajoTemplate → extend/bajoTemplate}/partial/crud/~echarts-window.html +0 -0
  91. /package/{bajoTemplate → extend/bajoTemplate}/template/crud/add.html +0 -0
  92. /package/{bajoTemplate → extend/bajoTemplate}/template/crud/details.html +0 -0
  93. /package/{bajoTemplate → extend/bajoTemplate}/template/crud/edit.html +0 -0
  94. /package/{bajoTemplate → extend/bajoTemplate}/template/crud/list.html +0 -0
  95. /package/{bajoTemplate → extend/bajoTemplate}/template/disabled.html +0 -0
  96. /package/{waibuBootstrap → extend/waibuBootstrap}/theme/component/wdb-base.js +0 -0
  97. /package/{waibuMpa → extend/waibuMpa}/extend/waibuAdmin/route/@model/@action.js +0 -0
  98. /package/{waibuRestApi → extend/waibuRestApi}/route/@model/@id/get.js +0 -0
  99. /package/{waibuRestApi → extend/waibuRestApi}/route/@model/@id/remove.js +0 -0
  100. /package/{waibuRestApi → extend/waibuRestApi}/route/@model/@id/update.js +0 -0
  101. /package/{waibuRestApi → extend/waibuRestApi}/route/@model/create.js +0 -0
  102. /package/{plugin-method → method}/method-map.js +0 -0
  103. /package/{plugin-method → method}/record/count.js +0 -0
  104. /package/{plugin-method → method}/record/create.js +0 -0
  105. /package/{plugin-method → method}/record/find-one.js +0 -0
  106. /package/{plugin-method → method}/record/find.js +0 -0
  107. /package/{plugin-method → method}/record/get.js +0 -0
  108. /package/{plugin-method → method}/record/remove.js +0 -0
  109. /package/{plugin-method → method}/record/update.js +0 -0
  110. /package/{plugin-method → method}/stat/aggregate.js +0 -0
  111. /package/{plugin-method → method}/stat/histogram.js +0 -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.plugin.app.bajo.lib._
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.plugin.lib._
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.plugin.app.bajo.lib._
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.plugin.app.bajo.lib._
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.plugin.app.bajo.lib._
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.plugin.app.bajo.lib._
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.plugin.app.bajo.lib._
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.plugin.app.bajo.lib._
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.plugin.lib._
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.plugin.lib._
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
@@ -1,5 +1,5 @@
1
1
  async function find (req, reply) {
2
- const { isSet } = this.lib.aneka
2
+ const { isSet } = this.app.lib.aneka
3
3
  const { parseObject } = this.app.bajo
4
4
  let { fields, count } = this.getParams(req)
5
5
  let rels = []
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
- return class WaibuDb extends this.lib.BajoPlugin {
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.name)
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
@@ -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))
@@ -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))
@@ -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.name}:/export-handler`
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)
@@ -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)
@@ -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) {
@@ -1,5 +1,5 @@
1
1
  async function getLookupData ({ model, req, data, id = 'id', field, query }) {
2
- const { set, map } = this.lib._
2
+ const { set, map } = this.app.lib._
3
3
  const $in = map(data, id)
4
4
  const q = query ?? set({}, field, { $in })
5
5
  const options = {
@@ -1,5 +1,5 @@
1
1
  function getParams (req, ...items) {
2
- const { map, trim, get } = this.lib._
2
+ const { map, trim, get } = this.app.lib._
3
3
  let fields
4
4
  req.query = req.query ?? {}
5
5
  req.params = req.params ?? {}
@@ -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,14 +169,14 @@ 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))
178
- let ext = await readConfig(`${schema.ns}:/waibuDb/schema/${base}.*`, { ignoreError: true, options })
179
- const over = await readConfig(`main:/waibuDb/extend/${schema.ns}/schema/${base}.*`, { ignoreError: true, options })
178
+ let ext = await readConfig(`${schema.ns}:/extend/waibuDb/schema/${base}.*`, { ignoreError: true, options })
179
+ const over = await readConfig(`main:/extend/waibuDb/extend/${schema.ns}/schema/${base}.*`, { ignoreError: true, options })
180
180
  ext = defaultsDeep(options.schema ?? {}, over, ext)
181
181
  await handler[view].call(this, schema, ext, options)
182
182
  schema = pick(schema, ['name', 'properties', 'indexes', 'disabled', 'attachment', 'sortables', 'view'])
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "1.2.12",
3
+ "version": "2.0.1",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
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,3 @@
1
+ # Config Object
2
+
3
+ TBD
@@ -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.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes