dobo-extra 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.
Files changed (47) 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 +33 -7
  6. package/docs/DoboExtra.html +3 -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 +3 -0
  12. package/docs/index.html +3 -0
  13. package/docs/index.js.html +85 -0
  14. package/docs/scripts/core.js +726 -0
  15. package/docs/scripts/core.min.js +23 -0
  16. package/docs/scripts/resize.js +90 -0
  17. package/docs/scripts/search.js +265 -0
  18. package/docs/scripts/search.min.js +6 -0
  19. package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
  20. package/docs/scripts/third-party/fuse.js +9 -0
  21. package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
  22. package/docs/scripts/third-party/hljs-line-num.js +1 -0
  23. package/docs/scripts/third-party/hljs-original.js +5171 -0
  24. package/docs/scripts/third-party/hljs.js +1 -0
  25. package/docs/scripts/third-party/popper.js +5 -0
  26. package/docs/scripts/third-party/tippy.js +1 -0
  27. package/docs/scripts/third-party/tocbot.js +672 -0
  28. package/docs/scripts/third-party/tocbot.min.js +1 -0
  29. package/docs/static/bitcoin.jpeg +0 -0
  30. package/docs/static/home.md +24 -0
  31. package/docs/static/logo-ecosystem.png +0 -0
  32. package/docs/static/logo.png +0 -0
  33. package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
  34. package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
  35. package/docs/styles/clean-jsdoc-theme-light.css +482 -0
  36. package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  37. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  38. package/docs/styles/clean-jsdoc-theme.min.css +1 -0
  39. package/extend/bajoCli/applet/archive.js +4 -4
  40. package/extend/bajoCli/applet/export-to.js +7 -7
  41. package/extend/bajoCli/applet/import-from.js +6 -6
  42. package/index.js +19 -5
  43. package/method/export-to.js +5 -5
  44. package/method/import-from.js +3 -3
  45. package/package.json +45 -40
  46. package/wiki/CONFIG.md +3 -0
  47. package/wiki/CONTRIBUTING.md +5 -0
@@ -3,7 +3,7 @@ import _path from 'path'
3
3
  const batch = 100
4
4
 
5
5
  function makeProgress (spin) {
6
- const { secToHms } = this.lib.aneka
6
+ const { secToHms } = this.app.lib.aneka
7
7
  return async function ({ batchNo, data, batchStart, batchEnd } = {}) {
8
8
  spin.setText('batch%d%s', batchNo, secToHms(batchEnd.toTime() - batchStart.toTime(), true))
9
9
  }
@@ -11,28 +11,28 @@ function makeProgress (spin) {
11
11
 
12
12
  async function importFrom (...args) {
13
13
  const { importPkg } = this.app.bajo
14
- const { isEmpty, map } = this.lib._
14
+ const { isEmpty, map } = this.app.lib._
15
15
  const { getInfo, start } = this.app.dobo
16
16
 
17
17
  const [input, select, confirm] = await importPkg('bajoCli:@inquirer/input',
18
18
  'bajoCli:@inquirer/select', 'bajoCli:@inquirer/confirm')
19
19
  const schemas = map(this.app.dobo.schemas, 'name')
20
- if (isEmpty(schemas)) return this.print.fatal('notFound%s', this.print.write('field.schema'))
20
+ if (isEmpty(schemas)) return this.print.fatal('notFound%s', this.t('field.schema'))
21
21
  let [dest, model] = args
22
22
  if (isEmpty(dest)) {
23
23
  dest = await input({
24
- message: this.print.write('enterSourceFile'),
24
+ message: this.t('enterSourceFile'),
25
25
  validate: (item) => !isEmpty(item)
26
26
  })
27
27
  }
28
28
  if (isEmpty(model)) {
29
29
  model = await select({
30
- message: this.print.write('chooseModel'),
30
+ message: this.t('chooseModel'),
31
31
  choices: map(schemas, s => ({ value: s }))
32
32
  })
33
33
  }
34
34
  const answer = await confirm({
35
- message: this.print.write('aboutToReplaceAllRecords'),
35
+ message: this.t('aboutToReplaceAllRecords'),
36
36
  default: false
37
37
  })
38
38
  if (!answer) return this.print.fatal('aborted')
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 DoboExtra extends this.lib.Plugin {
10
+ /**
11
+ * DoboExtra class
12
+ *
13
+ * @class
14
+ */
15
+ class DoboExtra extends this.app.pluginClass.base {
16
+ static alias = 'dbx'
17
+ static dependencies = ['dobo', 'bajo-extra']
18
+
5
19
  constructor () {
6
20
  super(pkgName, me.app)
7
- this.alias = 'dbx'
8
- this.dependencies = ['dobo', 'bajo-extra']
9
21
  this.config = {
10
22
  export: {
11
23
  maxBatch: 1000,
@@ -33,7 +45,7 @@ async function factory (pkgName) {
33
45
  async function handler ({ item }) {
34
46
  const { join } = this.app.bajo
35
47
  const { getSchema } = this.app.dobo
36
- const { has } = this.lib._
48
+ const { has } = this.app.lib._
37
49
  for (const f of ['source', 'destination']) {
38
50
  if (!has(item, f)) throw this.error('taskMustHaveModel%s', f)
39
51
  const key = `${f}Field`
@@ -47,7 +59,7 @@ async function factory (pkgName) {
47
59
  item.maxAge = item.maxAge ?? 1 // in days, less then 1 is ignored
48
60
  }
49
61
 
50
- this.archivers = await buildCollections({ ns: this.name, handler, container: 'archive.tasks', dupChecks: ['source'], useDefaultName: false })
62
+ this.archivers = await buildCollections({ ns: this.ns, handler, container: 'archive.tasks', dupChecks: ['source'], useDefaultName: false })
51
63
  }
52
64
 
53
65
  start = async () => {
@@ -63,6 +75,8 @@ async function factory (pkgName) {
63
75
  }, this.config.archive.checkInterval * 60 * 1000)
64
76
  }
65
77
  }
78
+
79
+ return DoboExtra
66
80
  }
67
81
 
68
82
  export default factory
@@ -9,12 +9,12 @@ const { json, ndjson, csv, xlsx } = format
9
9
 
10
10
  async function getFile (dest, ensureDir) {
11
11
  const { importPkg, getPluginDataDir } = this.app.bajo
12
- const { fs } = this.lib
12
+ const { fs } = this.app.lib
13
13
  const increment = await importPkg('bajo:add-filename-increment')
14
14
  let file
15
15
  if (path.isAbsolute(dest)) file = dest
16
16
  else {
17
- file = `${getPluginDataDir(this.name)}/export/${dest}`
17
+ file = `${getPluginDataDir(this.ns)}/export/${dest}`
18
18
  fs.ensureDirSync(path.dirname(file))
19
19
  }
20
20
  file = increment(file, { fs: true })
@@ -36,7 +36,7 @@ async function getFile (dest, ensureDir) {
36
36
 
37
37
  async function getData ({ source, filter, count, stream, progressFn, fields }) {
38
38
  let cnt = count ?? 0
39
- const { find } = this.lib._
39
+ const { find } = this.app.lib._
40
40
  const { recordFind, getSchema } = this.app.dobo
41
41
  const { maxLimit, hardLimit } = this.app.dobo.config.default.filter
42
42
  filter.limit = maxLimit
@@ -72,8 +72,8 @@ async function getData ({ source, filter, count, stream, progressFn, fields }) {
72
72
  }
73
73
 
74
74
  function exportTo (source, dest, { filter = {}, ensureDir, useHeader = true, batch = 500, progressFn, fields } = {}, opts = {}) {
75
- const { fs } = this.lib
76
- const { merge } = this.lib._
75
+ const { fs } = this.app.lib
76
+ const { merge } = this.app.lib._
77
77
  const { getInfo } = this.app.dobo
78
78
 
79
79
  filter.page = 1
@@ -10,14 +10,14 @@ const { json, ndjson, csv, xlsx } = format
10
10
  async function importFrom (source, dest, { trashOld = true, batch = 1, progressFn, converterFn, useHeader = true, fileType, createOpts = {} } = {}, opts = {}) {
11
11
  const { getPluginDataDir } = this.app.bajo
12
12
  const { recordCreate } = this.app.dobo
13
- const { merge } = this.lib._
14
- const { fs } = this.lib
13
+ const { merge } = this.app.lib._
14
+ const { fs } = this.app.lib
15
15
 
16
16
  if (dest !== false) this.app.dobo.getInfo(dest) // make sure dest model is valid
17
17
  let file
18
18
  if (path.isAbsolute(source)) file = source
19
19
  else {
20
- file = `${getPluginDataDir(this.name)}/import/${source}`
20
+ file = `${getPluginDataDir(this.ns)}/import/${source}`
21
21
  fs.ensureDirSync(path.dirname(file))
22
22
  }
23
23
  if (!fs.existsSync(file)) throw this.error('sourceFileNotExists%s', file)
package/package.json CHANGED
@@ -1,40 +1,45 @@
1
- {
2
- "name": "dobo-extra",
3
- "version": "2.0.0",
4
- "description": "Bajo DB Extra Tools/Utility",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "type": "module",
10
- "bajo": {
11
- "type": "plugin"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/ardhi/dobo-extra.git"
16
- },
17
- "keywords": [
18
- "extra",
19
- "db",
20
- "driver",
21
- "bajo",
22
- "framework",
23
- "modular"
24
- ],
25
- "author": "Ardhi Lukianto <ardhi@lukianto.com>",
26
- "license": "MIT",
27
- "bugs": {
28
- "url": "https://github.com/ardhi/dobo-extra/issues"
29
- },
30
- "homepage": "https://github.com/ardhi/dobo-extra#readme",
31
- "dependencies": {
32
- "@atomictech/xlsx-write-stream": "^2.0.2",
33
- "fast-csv": "^5.0.2",
34
- "ndjson": "^2.0.0",
35
- "scramjet": "^4.37.0",
36
- "stream-chain": "^3.3.2",
37
- "stream-json": "^1.9.1",
38
- "xlsx-parse-stream": "^1.1.0"
39
- }
40
- }
1
+ {
2
+ "name": "dobo-extra",
3
+ "version": "2.0.1",
4
+ "description": "Bajo DB Extra Tools/Utility",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build-doc": "jsdoc -c .jsdoc.conf.json",
8
+ "test": "mocha"
9
+ },
10
+ "type": "module",
11
+ "bajo": {
12
+ "type": "plugin"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/ardhi/dobo-extra.git"
17
+ },
18
+ "keywords": [
19
+ "extra",
20
+ "db",
21
+ "driver",
22
+ "bajo",
23
+ "framework",
24
+ "modular"
25
+ ],
26
+ "author": "Ardhi Lukianto <ardhi@lukianto.com>",
27
+ "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/ardhi/dobo-extra/issues"
30
+ },
31
+ "homepage": "https://github.com/ardhi/dobo-extra#readme",
32
+ "dependencies": {
33
+ "@atomictech/xlsx-write-stream": "^2.0.2",
34
+ "fast-csv": "^5.0.2",
35
+ "ndjson": "^2.0.0",
36
+ "scramjet": "^4.37.0",
37
+ "stream-chain": "^3.3.2",
38
+ "stream-json": "^1.9.1",
39
+ "xlsx-parse-stream": "^1.1.0"
40
+ },
41
+ "devDependencies": {
42
+ "clean-jsdoc-theme": "^4.3.0",
43
+ "jsdoc-plugin-intersection": "^1.0.4"
44
+ }
45
+ }
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.