waibu-db 2.33.0 → 2.33.2

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 (135) hide show
  1. package/.github/FUNDING.yml +0 -0
  2. package/.github/workflows/repo-lockdown.yml +0 -0
  3. package/.jsdoc.conf.json +0 -0
  4. package/LICENSE +0 -0
  5. package/README.md +0 -0
  6. package/docs/WaibuDb.html +0 -0
  7. package/docs/data/search.json +0 -0
  8. package/docs/external-DoboModel.html +0 -0
  9. package/docs/external-TFilter.html +0 -0
  10. package/docs/external-TOptions.html +0 -0
  11. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  12. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  13. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  14. package/docs/global.html +0 -0
  15. package/docs/index.html +0 -0
  16. package/docs/index.js.html +0 -0
  17. package/docs/lib_config.js.html +0 -0
  18. package/docs/lib_crud_add-handler.js.html +0 -0
  19. package/docs/lib_crud_all-handler.js.html +0 -0
  20. package/docs/lib_crud_delete-handler.js.html +0 -0
  21. package/docs/lib_crud_details-handler.js.html +0 -0
  22. package/docs/lib_crud_edit-handler.js.html +0 -0
  23. package/docs/lib_crud_export-handler.js.html +0 -0
  24. package/docs/lib_crud_helper.js.html +0 -0
  25. package/docs/lib_crud_list-handler.js.html +0 -0
  26. package/docs/lib_util.js.html +0 -0
  27. package/docs/module-CRUDHandler.html +0 -0
  28. package/docs/module-CRUDHandler_Helper.html +0 -0
  29. package/docs/module-Helper.html +0 -0
  30. package/docs/module-Helper_CRUDHandler.html +0 -0
  31. package/docs/scripts/core.js +0 -0
  32. package/docs/scripts/core.min.js +0 -0
  33. package/docs/scripts/resize.js +0 -0
  34. package/docs/scripts/search.js +0 -0
  35. package/docs/scripts/search.min.js +5 -5
  36. package/docs/scripts/third-party/Apache-License-2.0.txt +0 -0
  37. package/docs/scripts/third-party/fuse.js +0 -0
  38. package/docs/scripts/third-party/hljs-line-num-original.js +0 -0
  39. package/docs/scripts/third-party/hljs-line-num.js +0 -0
  40. package/docs/scripts/third-party/hljs-original.js +0 -0
  41. package/docs/scripts/third-party/hljs.js +0 -0
  42. package/docs/scripts/third-party/popper.js +0 -0
  43. package/docs/scripts/third-party/tippy.js +0 -0
  44. package/docs/scripts/third-party/tocbot.js +0 -0
  45. package/docs/scripts/third-party/tocbot.min.js +0 -0
  46. package/docs/static/bitcoin.jpeg +0 -0
  47. package/docs/static/home.md +0 -0
  48. package/docs/static/logo-ecosystem.png +0 -0
  49. package/docs/static/logo.png +0 -0
  50. package/docs/styles/clean-jsdoc-theme-base.css +0 -0
  51. package/docs/styles/clean-jsdoc-theme-dark.css +0 -0
  52. package/docs/styles/clean-jsdoc-theme-light.css +0 -0
  53. package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -0
  54. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
  55. package/docs/styles/clean-jsdoc-theme.min.css +0 -0
  56. package/extend/bajo/hook/waibu-rest-api@after-init.js +0 -0
  57. package/extend/bajo/intl/en-US.json +0 -0
  58. package/extend/bajo/intl/id.json +0 -0
  59. package/extend/bajoTemplate/partial/crud/_add-attachment.html +0 -0
  60. package/extend/bajoTemplate/partial/crud/_add-btns.html +0 -0
  61. package/extend/bajoTemplate/partial/crud/_addons.html +0 -0
  62. package/extend/bajoTemplate/partial/crud/_details-attachment.html +0 -0
  63. package/extend/bajoTemplate/partial/crud/_details-btns.html +0 -0
  64. package/extend/bajoTemplate/partial/crud/_edit-attachment.html +0 -0
  65. package/extend/bajoTemplate/partial/crud/_edit-btns.html +0 -0
  66. package/extend/bajoTemplate/partial/crud/_list-attachment.html +0 -0
  67. package/extend/bajoTemplate/partial/crud/_list-btns.html +0 -0
  68. package/extend/bajoTemplate/partial/crud/_list-footer.html +0 -0
  69. package/extend/bajoTemplate/partial/crud/_list-warnings.html +9 -9
  70. package/extend/bajoTemplate/partial/crud/add-handler.html +0 -0
  71. package/extend/bajoTemplate/partial/crud/details-handler.html +0 -0
  72. package/extend/bajoTemplate/partial/crud/edit-handler.html +0 -0
  73. package/extend/bajoTemplate/partial/crud/list-handler.html +0 -0
  74. package/extend/bajoTemplate/partial/crud/not-found.html +0 -0
  75. package/extend/bajoTemplate/partial/crud/~echarts-window.html +0 -0
  76. package/extend/bajoTemplate/template/crud/add.html +0 -0
  77. package/extend/bajoTemplate/template/crud/details.html +0 -0
  78. package/extend/bajoTemplate/template/crud/edit.html +0 -0
  79. package/extend/bajoTemplate/template/crud/list.html +0 -0
  80. package/extend/bajoTemplate/template/crud/not-found.html +0 -0
  81. package/extend/bajoTemplate/template/disabled.html +0 -0
  82. package/extend/sumba/route/secure.json +3 -3
  83. package/extend/waibuBootstrap/theme/component/wdb-base.js +0 -0
  84. package/extend/waibuBootstrap/theme/component/widget/btn-add.js +0 -0
  85. package/extend/waibuBootstrap/theme/component/widget/btn-back.js +0 -0
  86. package/extend/waibuBootstrap/theme/component/widget/btn-clone.js +0 -0
  87. package/extend/waibuBootstrap/theme/component/widget/btn-columns.js +0 -0
  88. package/extend/waibuBootstrap/theme/component/widget/btn-delete.js +0 -0
  89. package/extend/waibuBootstrap/theme/component/widget/btn-details.js +0 -0
  90. package/extend/waibuBootstrap/theme/component/widget/btn-edit.js +0 -0
  91. package/extend/waibuBootstrap/theme/component/widget/btn-export.js +1 -1
  92. package/extend/waibuBootstrap/theme/component/widget/data-table.js +0 -0
  93. package/extend/waibuBootstrap/theme/component/widget/echarts-bar.js +0 -0
  94. package/extend/waibuBootstrap/theme/component/widget/echarts-pie.js +0 -0
  95. package/extend/waibuBootstrap/theme/component/widget/echarts.js +0 -0
  96. package/extend/waibuBootstrap/theme/component/widget/form.js +0 -0
  97. package/extend/waibuBootstrap/theme/component/widget/lookup-select.js +40 -40
  98. package/extend/waibuBootstrap/theme/component/widget/pagination.js +0 -0
  99. package/extend/waibuBootstrap/theme/component/widget/query.js +0 -0
  100. package/extend/waibuBootstrap/theme/component/widget/recs-info.js +0 -0
  101. package/extend/waibuMpa/extend/waibuAdmin/route/@model/@action.js +0 -0
  102. package/extend/waibuMpa/extend/waibuAdmin/route/index.js +11 -11
  103. package/extend/waibuRestApi/route/@model/@id/get.js +0 -0
  104. package/extend/waibuRestApi/route/@model/@id/remove.js +0 -0
  105. package/extend/waibuRestApi/route/@model/@id/update.js +0 -0
  106. package/extend/waibuRestApi/route/@model/create.js +0 -0
  107. package/extend/waibuRestApi/route/@model/find.js +0 -0
  108. package/extend/waibuRestApi/route/@model/stat/@stat/find.js +0 -0
  109. package/extend/waibuRestApi/route/lookup/@model/model-builder.json +0 -0
  110. package/index.js +0 -0
  111. package/lib/config.js +45 -45
  112. package/lib/crud/add-handler.js +0 -0
  113. package/lib/crud/all-handler.js +0 -0
  114. package/lib/crud/delete-handler.js +0 -0
  115. package/lib/crud/details-handler.js +0 -0
  116. package/lib/crud/edit-handler.js +0 -0
  117. package/lib/crud/export-handler.js +1 -1
  118. package/lib/crud/helper.js +115 -115
  119. package/lib/crud/list-handler.js +0 -0
  120. package/lib/method/aggregate.js +0 -0
  121. package/lib/method/count-record.js +0 -0
  122. package/lib/method/create-record.js +0 -0
  123. package/lib/method/find-all-record.js +0 -0
  124. package/lib/method/find-one-record.js +0 -0
  125. package/lib/method/find-record.js +0 -0
  126. package/lib/method/get-record.js +0 -0
  127. package/lib/method/get-schema-ext.js +1 -1
  128. package/lib/method/histogram.js +0 -0
  129. package/lib/method/remove-record.js +0 -0
  130. package/lib/method/update-record.js +0 -0
  131. package/lib/util.js +1 -1
  132. package/package.json +1 -1
  133. package/wiki/CHANGES.md +357 -347
  134. package/wiki/CONFIG.md +0 -0
  135. package/wiki/CONTRIBUTING.md +0 -0
@@ -1,115 +1,115 @@
1
- /**
2
- * @module CRUDHandler/Helper
3
- */
4
-
5
- /**
6
- * Add-ons handler for generating chart options based on the schema's aggregate settings.
7
- *
8
- * This function retrieves the aggregate settings from the schema and generates chart options for each setting.
9
- * The generated chart options are encoded in base64 and returned as an array of add-ons.
10
- *
11
- * @async
12
- * @memberof module:CRUDHandler/Helper
13
- * @method
14
- * @name addOnsHandler
15
- * @param {object} opts - Options object
16
- * @param {object} opts.req - Request object
17
- * @param {object} opts.reply - Reply object
18
- * @param {object} opts.schema - Schema object
19
- * @returns {Promise<Array>} Array of add-ons with chart options
20
- */
21
- export async function addOnsHandler (opts = {}) {
22
- const { req, reply, schema } = opts
23
- const { escape } = this.app.waibu
24
- const { base64JsonEncode } = this.app.waibu
25
- const { aggregate } = this.app.waibuDb
26
- const { get, map, pick, pullAt } = this.app.lib._
27
- const _opts = map(get(schema, 'view.stat.aggregate', []), item => {
28
- const dbOpts = pick(item, ['fields', 'group', 'aggregate'])
29
- const name = item.name ?? `field.${item.fields[0]}`
30
- return { name, dbOpts }
31
- })
32
- if (_opts.length === 0) return []
33
- const dropped = []
34
- for (const idx in _opts) {
35
- const o = _opts[idx]
36
- try {
37
- const resp = await aggregate({ model: schema.name, req, reply, options: o.dbOpts })
38
- const data = []
39
- for (const d of resp.data) {
40
- const key = o.dbOpts.fields[0]
41
- data.push({
42
- name: escape(d[key]),
43
- value: d[key + 'Count']
44
- })
45
- }
46
- _opts[idx].chartOpts = base64JsonEncode({
47
- tooltip: {
48
- trigger: 'item'
49
- },
50
- series: [{
51
- type: 'pie',
52
- data
53
- }]
54
- })
55
- } catch (err) {
56
- dropped.push(idx)
57
- }
58
- }
59
- if (dropped.length > 0) pullAt(_opts, dropped)
60
- return map(_opts, o => {
61
- return {
62
- data: { setting: o.chartOpts, name: o.name },
63
- resource: 'waibuDb.partial:/crud/~echarts-window.html'
64
- }
65
- })
66
- }
67
-
68
- /**
69
- * Handles attachments for a given schema and ID.
70
- * @async
71
- * @memberof module:CRUDHandler/Helper
72
- * @method
73
- * @name attachmentHandler
74
- * @param {object} opts - Options object
75
- * @param {object} opts.schema - Schema object
76
- * @param {string|number} opts.id - ID of the record
77
- * @returns {Promise<Array>} Array of attachments
78
- */
79
- export async function attachmentHandler (opts = {}) {
80
- const { schema, id } = opts
81
- if (!schema.view.attachment) return []
82
- const model = this.app.dobo.getModel(schema.name)
83
- return await model.listAttachment({ id })
84
- }
85
-
86
- /**
87
- * Builds parameters for a given model and request.
88
- *
89
- * @param {object} opts - Options object
90
- * @param {string} opts.model - Model name
91
- * @param {object} opts.req - Request object
92
- * @returns {object} Parameters including page information
93
- */
94
- export function buildParams (opts = {}) {
95
- const { model, req } = opts
96
- const { camelCase, kebabCase, map, upperFirst, get } = this.app.lib._
97
- const [, ...names] = map(kebabCase(model).split('-'), n => upperFirst(n))
98
- const mdl = this.app.dobo.getModel(model)
99
- const prefix = this.app.waibuMpa ? this.app.waibuMpa.getPluginTitle(mdl.plugin.ns, req) : mdl.plugin.ns
100
- const modelTitle = req.t(prefix) + ': ' + req.t(camelCase(names.join(' ')))
101
- const page = {
102
- title: req.t(get(req, 'routeOptions.config.title', this.app[mdl.plugin.ns].title)),
103
- modelTitle
104
- }
105
- return { page }
106
- }
107
-
108
- /**
109
- * Template path for the "not found" page.
110
- * @name notFoundTpl
111
- * @constant {string}
112
- * @default 'waibuDb.template:/crud/not-found.html'
113
- * @memberof module:CRUDHandler/Helper
114
- */
115
- export const notFoundTpl = 'waibuDb.template:/crud/not-found.html'
1
+ /**
2
+ * @module CRUDHandler/Helper
3
+ */
4
+
5
+ /**
6
+ * Add-ons handler for generating chart options based on the schema's aggregate settings.
7
+ *
8
+ * This function retrieves the aggregate settings from the schema and generates chart options for each setting.
9
+ * The generated chart options are encoded in base64 and returned as an array of add-ons.
10
+ *
11
+ * @async
12
+ * @memberof module:CRUDHandler/Helper
13
+ * @method
14
+ * @name addOnsHandler
15
+ * @param {object} opts - Options object
16
+ * @param {object} opts.req - Request object
17
+ * @param {object} opts.reply - Reply object
18
+ * @param {object} opts.schema - Schema object
19
+ * @returns {Promise<Array>} Array of add-ons with chart options
20
+ */
21
+ export async function addOnsHandler (opts = {}) {
22
+ const { req, reply, schema } = opts
23
+ const { escape } = this.app.waibu
24
+ const { base64JsonEncode } = this.app.waibu
25
+ const { aggregate } = this.app.waibuDb
26
+ const { get, map, pick, pullAt } = this.app.lib._
27
+ const _opts = map(get(schema, 'view.stat.aggregate', []), item => {
28
+ const dbOpts = pick(item, ['fields', 'group', 'aggregate'])
29
+ const name = item.name ?? `field.${item.fields[0]}`
30
+ return { name, dbOpts }
31
+ })
32
+ if (_opts.length === 0) return []
33
+ const dropped = []
34
+ for (const idx in _opts) {
35
+ const o = _opts[idx]
36
+ try {
37
+ const resp = await aggregate({ model: schema.name, req, reply, options: o.dbOpts })
38
+ const data = []
39
+ for (const d of resp.data) {
40
+ const key = o.dbOpts.fields[0]
41
+ data.push({
42
+ name: escape(d[key]),
43
+ value: d[key + 'Count']
44
+ })
45
+ }
46
+ _opts[idx].chartOpts = base64JsonEncode({
47
+ tooltip: {
48
+ trigger: 'item'
49
+ },
50
+ series: [{
51
+ type: 'pie',
52
+ data
53
+ }]
54
+ })
55
+ } catch (err) {
56
+ dropped.push(idx)
57
+ }
58
+ }
59
+ if (dropped.length > 0) pullAt(_opts, dropped)
60
+ return map(_opts, o => {
61
+ return {
62
+ data: { setting: o.chartOpts, name: o.name },
63
+ resource: 'waibuDb.partial:/crud/~echarts-window.html'
64
+ }
65
+ })
66
+ }
67
+
68
+ /**
69
+ * Handles attachments for a given schema and ID.
70
+ * @async
71
+ * @memberof module:CRUDHandler/Helper
72
+ * @method
73
+ * @name attachmentHandler
74
+ * @param {object} opts - Options object
75
+ * @param {object} opts.schema - Schema object
76
+ * @param {string|number} opts.id - ID of the record
77
+ * @returns {Promise<Array>} Array of attachments
78
+ */
79
+ export async function attachmentHandler (opts = {}) {
80
+ const { schema, id } = opts
81
+ if (!schema.view.attachment) return []
82
+ const model = this.app.dobo.getModel(schema.name)
83
+ return await model.listAttachment({ id })
84
+ }
85
+
86
+ /**
87
+ * Builds parameters for a given model and request.
88
+ *
89
+ * @param {object} opts - Options object
90
+ * @param {string} opts.model - Model name
91
+ * @param {object} opts.req - Request object
92
+ * @returns {object} Parameters including page information
93
+ */
94
+ export function buildParams (opts = {}) {
95
+ const { model, req } = opts
96
+ const { camelCase, kebabCase, map, upperFirst, get } = this.app.lib._
97
+ const [, ...names] = map(kebabCase(model).split('-'), n => upperFirst(n))
98
+ const mdl = this.app.dobo.getModel(model)
99
+ const prefix = this.app.waibuMpa ? this.app.waibuMpa.getPluginTitle(mdl.plugin.ns, req) : mdl.plugin.ns
100
+ const modelTitle = req.t(prefix) + ': ' + req.t(camelCase(names.join(' ')))
101
+ const page = {
102
+ title: req.t(get(req, 'routeOptions.config.title', this.app[mdl.plugin.ns].title)),
103
+ modelTitle
104
+ }
105
+ return { page }
106
+ }
107
+
108
+ /**
109
+ * Template path for the "not found" page.
110
+ * @name notFoundTpl
111
+ * @constant {string}
112
+ * @default 'waibuDb.template:/crud/not-found.html'
113
+ * @memberof module:CRUDHandler/Helper
114
+ */
115
+ export const notFoundTpl = 'waibuDb.template:/crud/not-found.html'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -105,7 +105,7 @@ async function applyLayout (action, schema, ext, options) {
105
105
  if (!prop.ref && ['object', 'text'].includes(prop.type)) {
106
106
  result.attr.col = '12'
107
107
  result.component = 'form-textarea'
108
- result.attr.rows = '3'
108
+ result.attr.rows = result.attr.rows ?? '3'
109
109
  }
110
110
  if (action === 'details') {
111
111
  result.component = 'form-plaintext'
File without changes
File without changes
File without changes
package/lib/util.js CHANGED
@@ -147,7 +147,7 @@ export async function processHandler (opts = {}) {
147
147
  if (!(req.method === 'POST' && req.body._action === 'export' && options.allowExport)) return
148
148
  const { importModule } = this.app.bajo
149
149
  const exportHandler = await importModule('waibuDb:/lib/crud/export-handler.js')
150
- await exportHandler.call(this, { model: model.name, req, reply })
150
+ await exportHandler.call(this, { model: model.name, req, reply, options })
151
151
  }
152
152
 
153
153
  function suppressedReturn (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.33.0",
3
+ "version": "2.33.2",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {