waibu-db 1.1.23 → 1.2.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/index.js ADDED
@@ -0,0 +1,30 @@
1
+ async function factory (pkgName) {
2
+ const me = this
3
+
4
+ return class WaibuDb extends this.lib.BajoPlugin {
5
+ constructor () {
6
+ super(pkgName, me.app)
7
+ this.alias = 'wdb'
8
+ this.dependencies = ['dobo', 'waibu']
9
+ this.config = {
10
+ waibu: {
11
+ prefix: 'db',
12
+ title: 'dbModels'
13
+ },
14
+ waibuAdmin: {
15
+ menuCollapsible: true,
16
+ menuHandler: 'waibuDb:adminMenu'
17
+ },
18
+ waibuMpa: {
19
+ icon: 'database'
20
+ },
21
+ dbModel: {
22
+ count: false,
23
+ patchEnabled: false
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ export default factory
@@ -1,8 +1,9 @@
1
1
  async function addHandler ({ req, reply, model, params = {}, template, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html' } = {}) {
2
- const { pascalCase } = this.app.bajo
2
+ const { pascalCase } = this.lib.aneka
3
3
  const { recordCreate, recordGet, getSchemaExt } = this.app.waibuDb
4
4
  const { buildUrl } = this.app.waibuMpa
5
- const { pick, map, merge, defaultsDeep, omit, isEmpty } = this.lib._
5
+ const { defaultsDeep } = this.lib.aneka
6
+ const { pick, map, merge, omit, isEmpty } = this.lib._
6
7
  const options = {}
7
8
  model = model ?? pascalCase(req.params.model)
8
9
  const { schema } = await getSchemaExt(model, 'add', { params })
@@ -1,5 +1,5 @@
1
1
  async function deleteHandler ({ req, reply, model, params = {}, templateDisabled = 'waibuDb.template:/disabled.html' } = {}) {
2
- const { pascalCase } = this.app.bajo
2
+ const { pascalCase } = this.lib.aneka
3
3
  const { recordRemove, getSchemaExt } = this.app.waibuDb
4
4
  const { buildUrl } = this.app.waibuMpa
5
5
  const { reduce } = this.lib._
@@ -1,7 +1,7 @@
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' } = {}) {
4
- const { pascalCase } = this.app.bajo
4
+ const { pascalCase } = this.lib.aneka
5
5
  const { recordGet, getSchemaExt } = this.app.waibuDb
6
6
  const { merge } = this.lib._
7
7
  const options = {}
@@ -1,11 +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' } = {}) {
4
- const { pascalCase, getPluginDataDir } = this.app.bajo
4
+ const { pascalCase } = this.lib.aneka
5
+ const { getPluginDataDir } = this.app.bajo
5
6
  const { recordUpdate, recordGet, getSchemaExt } = this.app.waibuDb
6
7
  const { buildUrl } = this.app.waibuMpa
7
8
  const { fs } = this.lib
8
- const { merge, defaultsDeep, isEmpty, omit } = this.lib._
9
+ const { defaultsDeep } = this.lib.aneka
10
+ const { merge, isEmpty, omit } = this.lib._
9
11
  const options = {}
10
12
  let error
11
13
  let resp
@@ -1,5 +1,5 @@
1
1
  async function exportHandler ({ req, reply, model, params = {}, templateDisabled = 'waibuDb.template:/disabled.html' } = {}) {
2
- const { pascalCase } = this.app.bajo
2
+ const { pascalCase } = this.lib.aneka
3
3
  const { getSchemaExt } = this.app.waibuDb
4
4
  const { buildUrl } = this.app.waibuMpa
5
5
  const options = {}
@@ -1,5 +1,5 @@
1
1
  async function listHandler ({ req, reply, model, template, params = {}, addOnsHandler, templateDisabled = 'waibuDb.template:/disabled.html' } = {}) {
2
- const { pascalCase } = this.app.bajo
2
+ const { pascalCase } = this.lib.aneka
3
3
  const { recordFind, getSchemaExt } = this.app.waibuDb
4
4
  const { get, merge, isArray, upperFirst } = this.lib._
5
5
  const qsKey = this.app.waibu.config.qsKey
package/lib/prep-crud.js CHANGED
@@ -1,6 +1,6 @@
1
1
  function prepCrud ({ model, body, id, req, reply, options = {}, args }) {
2
2
  const { parseFilter } = this.app.waibu
3
- const { pascalCase } = this.app.bajo
3
+ const { pascalCase } = this.lib.aneka
4
4
  const { cloneDeep, has } = this.lib._
5
5
  const cfgWeb = this.app.waibu.getConfig()
6
6
  const opts = cloneDeep(options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "1.1.23",
3
+ "version": "1.2.0",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  function modelsMenu (locals, req) {
2
2
  const { getPluginPrefix } = this.app.waibu
3
- const { pascalCase } = this.app.bajo
3
+ const { pascalCase } = this.lib.aneka
4
4
  const { getAppTitle } = this.app.waibuMpa
5
5
  const { camelCase, map, pick, groupBy, keys, kebabCase, filter, get } = this.lib._
6
6
 
@@ -5,7 +5,7 @@ const defReadonly = ['id', 'createdAt', 'updatedAt']
5
5
  const defFormatter = {}
6
6
 
7
7
  function getCommons (action, schema, ext, opts = {}) {
8
- const { defaultsDeep } = this.app.bajo
8
+ const { defaultsDeep } = this.lib.aneka
9
9
  const { merge, map, get, set, without, uniq, pull } = this.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', []))
@@ -69,7 +69,7 @@ function autoLayout ({ action, schema, ext, layout }) {
69
69
  }
70
70
 
71
71
  function customLayout ({ action, schema, ext, layout, readonly }) {
72
- const { defaultsDeep } = this.app.bajo
72
+ const { defaultsDeep } = this.lib.aneka
73
73
  const { isEmpty } = this.lib._
74
74
  const items = [...layout]
75
75
  for (const item of items) {
@@ -87,7 +87,7 @@ function customLayout ({ action, schema, ext, layout, readonly }) {
87
87
  }
88
88
 
89
89
  function applyLayout (action, schema, ext) {
90
- const { defaultsDeep } = this.app.bajo
90
+ const { defaultsDeep } = this.lib.aneka
91
91
  const { set, get, isEmpty, find } = this.lib._
92
92
  const { fields, card, calcFields } = getCommons.call(this, action, schema, ext)
93
93
  const layout = get(ext, `view.${action}.layout`, get(ext, 'common.layout', []))
@@ -160,7 +160,8 @@ const handler = {
160
160
  }
161
161
 
162
162
  async function getSchemaExt (model, view, opts = {}) {
163
- const { readConfig, defaultsDeep } = this.app.bajo
163
+ const { readConfig } = this.app.bajo
164
+ const { defaultsDeep } = this.lib.aneka
164
165
  const { getSchema } = this.app.dobo
165
166
  const { pick } = this.lib._
166
167
 
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function count ({ model, req, reply, options = {} }) {
4
4
  const { recordCount } = this.app.dobo
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function create ({ model, req, reply, body, options = {} }) {
4
4
  const { recordCreate, attachmentFind } = this.app.dobo
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function find ({ model, req, reply, options = {} }) {
4
4
  const { recordFindOne, attachmentFind } = this.app.dobo
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function find ({ model, req, reply, options = {} }) {
4
4
  const { recordFind, attachmentFind } = this.app.dobo
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function get ({ model, req, reply, id, options = {} }) {
4
4
  const { recordFindOne } = this.app.dobo
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function remove ({ model, req, reply, id, options = {} }) {
4
4
  const { recordRemove } = this.app.dobo
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function update ({ model, req, reply, id, body, options = {} }) {
4
4
  const { recordUpdate, attachmentFind } = this.app.dobo
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function aggregate ({ model, req, reply, options = {} }) {
4
4
  const { statAggregate } = this.app.dobo
@@ -1,4 +1,4 @@
1
- import prepCrud from '../../../lib/prep-crud.js'
1
+ import prepCrud from '../../lib/prep-crud.js'
2
2
 
3
3
  async function histogram ({ model, req, reply, options = {} }) {
4
4
  const { statHistogram } = this.app.dobo
package/plugin/.alias DELETED
@@ -1 +0,0 @@
1
- wdb
@@ -1,2 +0,0 @@
1
- dobo
2
- waibu
@@ -1,17 +0,0 @@
1
- {
2
- "waibu": {
3
- "prefix": "db",
4
- "title": "dbModels"
5
- },
6
- "waibuAdmin": {
7
- "menuCollapsible": true,
8
- "menuHandler": "waibuDb:adminMenu"
9
- },
10
- "waibuMpa": {
11
- "icon": "database"
12
- },
13
- "dbModel": {
14
- "count": false,
15
- "patchEnabled": false
16
- }
17
- }
File without changes
File without changes