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.
Files changed (153) 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/LICENSE +1 -1
  5. package/README.md +38 -19
  6. package/docs/Dobo.html +26 -0
  7. package/docs/data/search.json +1 -0
  8. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  9. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  10. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  11. package/docs/global.html +7 -0
  12. package/docs/index.html +3 -0
  13. package/docs/index.js.html +578 -0
  14. package/docs/lib_collect-connections.js.html +39 -0
  15. package/docs/lib_collect-drivers.js.html +52 -0
  16. package/docs/lib_collect-features.js.html +36 -0
  17. package/docs/lib_collect-schemas.js.html +94 -0
  18. package/docs/lib_index.js.html +6 -0
  19. package/docs/method_model_create.js.html +35 -0
  20. package/docs/method_model_drop.js.html +34 -0
  21. package/docs/method_model_exists.js.html +40 -0
  22. package/docs/method_record_count.js.html +69 -0
  23. package/docs/method_record_create.js.html +114 -0
  24. package/docs/method_record_find-all.js.html +44 -0
  25. package/docs/method_record_find-one.js.html +73 -0
  26. package/docs/method_record_find.js.html +118 -0
  27. package/docs/method_record_get.js.html +92 -0
  28. package/docs/method_record_remove.js.html +75 -0
  29. package/docs/method_record_update.js.html +107 -0
  30. package/docs/method_record_upsert.js.html +54 -0
  31. package/docs/method_sanitize_body.js.html +88 -0
  32. package/docs/method_sanitize_date.js.html +30 -0
  33. package/docs/method_sanitize_id.js.html +20 -0
  34. package/docs/method_validate.js.html +249 -0
  35. package/docs/module-Lib.html +3 -0
  36. package/docs/scripts/core.js +726 -0
  37. package/docs/scripts/core.min.js +23 -0
  38. package/docs/scripts/resize.js +90 -0
  39. package/docs/scripts/search.js +265 -0
  40. package/docs/scripts/search.min.js +6 -0
  41. package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
  42. package/docs/scripts/third-party/fuse.js +9 -0
  43. package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
  44. package/docs/scripts/third-party/hljs-line-num.js +1 -0
  45. package/docs/scripts/third-party/hljs-original.js +5171 -0
  46. package/docs/scripts/third-party/hljs.js +1 -0
  47. package/docs/scripts/third-party/popper.js +5 -0
  48. package/docs/scripts/third-party/tippy.js +1 -0
  49. package/docs/scripts/third-party/tocbot.js +672 -0
  50. package/docs/scripts/third-party/tocbot.min.js +1 -0
  51. package/docs/static/bitcoin.jpeg +0 -0
  52. package/docs/static/home.md +25 -0
  53. package/docs/static/logo-ecosystem.png +0 -0
  54. package/docs/static/logo.png +0 -0
  55. package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
  56. package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
  57. package/docs/styles/clean-jsdoc-theme-light.css +482 -0
  58. package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  59. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  60. package/docs/styles/clean-jsdoc-theme.min.css +1 -0
  61. package/{bajo → extend/bajo}/intl/en-US.json +3 -2
  62. package/{bajo → extend/bajo}/intl/id.json +3 -2
  63. package/{bajoCli → extend/bajoCli}/applet/connection.js +5 -5
  64. package/extend/bajoCli/applet/lib/post-process.js +53 -0
  65. package/extend/bajoCli/applet/model-clear.js +11 -0
  66. package/{bajoCli → extend/bajoCli}/applet/model-rebuild.js +13 -13
  67. package/{bajoCli → extend/bajoCli}/applet/record-create.js +10 -8
  68. package/{bajoCli → extend/bajoCli}/applet/record-find.js +6 -5
  69. package/{bajoCli → extend/bajoCli}/applet/record-get.js +5 -5
  70. package/{bajoCli → extend/bajoCli}/applet/record-remove.js +5 -5
  71. package/{bajoCli → extend/bajoCli}/applet/record-update.js +9 -9
  72. package/{bajoCli → extend/bajoCli}/applet/schema.js +4 -4
  73. package/{bajoCli → extend/bajoCli}/applet/stat-count.js +4 -4
  74. package/{dobo → extend/dobo}/feature/created-at.js +1 -1
  75. package/{dobo → extend/dobo}/feature/removed-at.js +3 -3
  76. package/{dobo → extend/dobo}/feature/updated-at.js +2 -2
  77. package/{waibuMpa → extend/waibuMpa}/route/attachment/@model/@id/@field/@file.js +3 -3
  78. package/index.js +230 -72
  79. package/lib/add-fixtures.js +7 -6
  80. package/lib/build-bulk-action.js +2 -2
  81. package/lib/check-unique.js +2 -2
  82. package/lib/collect-connections.js +15 -4
  83. package/lib/collect-drivers.js +15 -6
  84. package/lib/{collect-feature.js → collect-features.js} +13 -4
  85. package/lib/collect-schemas.js +22 -12
  86. package/lib/exec-feature-hook.js +1 -1
  87. package/lib/exec-validation.js +5 -5
  88. package/lib/generic-prop-sanitizer.js +6 -5
  89. package/lib/handle-attachment-upload.js +2 -2
  90. package/lib/index.js +3 -0
  91. package/lib/mem-db/conn-sanitizer.js +1 -1
  92. package/lib/mem-db/instantiate.js +4 -4
  93. package/lib/mem-db/method/record/find.js +1 -1
  94. package/lib/mem-db/method/record/get.js +1 -1
  95. package/lib/mem-db/method/record/remove.js +1 -1
  96. package/lib/mem-db/method/record/update.js +1 -1
  97. package/lib/mem-db/start.js +1 -1
  98. package/lib/merge-attachment-info.js +2 -2
  99. package/lib/multi-rel-rows.js +2 -2
  100. package/lib/resolve-method.js +3 -3
  101. package/lib/sanitize-schema.js +8 -7
  102. package/lib/single-rel-rows.js +2 -2
  103. package/{plugin-method → method}/attachment/copy-uploaded.js +2 -2
  104. package/{plugin-method → method}/attachment/create.js +3 -3
  105. package/{plugin-method → method}/attachment/find.js +2 -2
  106. package/{plugin-method → method}/attachment/get-path.js +3 -3
  107. package/{plugin-method → method}/attachment/get.js +1 -1
  108. package/{plugin-method → method}/attachment/pre-check.js +1 -1
  109. package/{plugin-method → method}/attachment/remove.js +1 -1
  110. package/{plugin-method → method}/bulk/create.js +6 -6
  111. package/{plugin-method → method}/model/clear.js +5 -5
  112. package/method/model/create.js +32 -0
  113. package/method/model/drop.js +31 -0
  114. package/method/model/exists.js +37 -0
  115. package/{plugin-method → method}/record/clear.js +5 -5
  116. package/{plugin-method → method}/record/count.js +27 -5
  117. package/{plugin-method → method}/record/create.js +46 -6
  118. package/{plugin-method → method}/record/find-all.js +16 -0
  119. package/{plugin-method → method}/record/find-one.js +20 -6
  120. package/method/record/find.js +115 -0
  121. package/method/record/get.js +89 -0
  122. package/method/record/remove.js +72 -0
  123. package/{plugin-method → method}/record/update.js +47 -6
  124. package/{plugin-method → method}/record/upsert.js +18 -2
  125. package/{plugin-method → method}/sanitize/body.js +18 -3
  126. package/method/sanitize/date.js +27 -0
  127. package/{plugin-method → method}/sanitize/id.js +10 -0
  128. package/{plugin-method → method}/stat/aggregate.js +4 -4
  129. package/{plugin-method → method}/stat/histogram.js +4 -4
  130. package/{plugin-method → method}/validate.js +96 -7
  131. package/package.json +41 -36
  132. package/wiki/APPLETS.md +57 -0
  133. package/wiki/CONFIG.md +25 -0
  134. package/wiki/CONTRIBUTING.md +5 -0
  135. package/wiki/DEV-GUIDE.md +1 -0
  136. package/wiki/ECOSYSTEM.md +20 -0
  137. package/wiki/GETTING-STARTED.md +166 -0
  138. package/wiki/USER-GUIDE.md +1 -0
  139. package/bajoCli/applet/lib/post-process.js +0 -47
  140. package/bajoCli/applet/model-clear.js +0 -11
  141. package/plugin-method/model/create.js +0 -19
  142. package/plugin-method/model/drop.js +0 -19
  143. package/plugin-method/model/exists.js +0 -24
  144. package/plugin-method/record/find.js +0 -52
  145. package/plugin-method/record/get.js +0 -47
  146. package/plugin-method/record/remove.js +0 -41
  147. package/plugin-method/sanitize/date.js +0 -14
  148. /package/{bajoCli → extend/bajoCli}/applet.js +0 -0
  149. /package/{dobo → extend/dobo}/feature/dt.js +0 -0
  150. /package/{dobo → extend/dobo}/feature/int-id.js +0 -0
  151. /package/{waibuStatic → extend/waibuStatic}/virtual.json +0 -0
  152. /package/{plugin-method → method}/attachment/update.js +0 -0
  153. /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