waibu-db 2.29.1 → 2.30.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.
@@ -30,8 +30,8 @@ async function btnExport () {
30
30
  ftype: 'json',
31
31
  toggle (val) {
32
32
  if (val === 'clipboard') {
33
- $refs.fkey.removeAttribute('disabled')
34
- $refs.fvalue.removeAttribute('disabled')
33
+ // $refs.fkey.removeAttribute('disabled')
34
+ // $refs.fvalue.removeAttribute('disabled')
35
35
  $refs.zip.setAttribute('disabled', '')
36
36
  $refs.xlsx.setAttribute('disabled', '')
37
37
  $refs.tsv.setAttribute('disabled', '')
@@ -39,8 +39,8 @@ async function btnExport () {
39
39
  _.pull(this.options, 'zip')
40
40
  if (!['json', 'csv'].includes(this.ftype)) this.ftype = 'json'
41
41
  } else {
42
- $refs.fkey.setAttribute('disabled', '')
43
- $refs.fvalue.setAttribute('disabled', '')
42
+ // $refs.fkey.setAttribute('disabled', '')
43
+ // $refs.fvalue.setAttribute('disabled', '')
44
44
  $refs.zip.removeAttribute('disabled')
45
45
  $refs.xlsx.removeAttribute('disabled')
46
46
  $refs.tsv.removeAttribute('disabled')
package/index.js CHANGED
@@ -92,23 +92,22 @@ async function factory (pkgName) {
92
92
  const model = get(params, 'payload.data.name')
93
93
  const fields = get(params, 'payload.data.opts.fields')
94
94
  const { id, file } = get(params, 'payload.data.download', {})
95
- let dest = `${this.app.bajo.getDownloadDir()}/${file}`
96
95
  const options = {
97
96
  filter: get(params, 'payload.data.filter', {}),
98
- ensureDir: true,
97
+ exportOpts: get(params, 'payload.data.exportOpts', []),
98
+ opts: get(params, 'payload.data.opts', {}),
99
99
  fields
100
100
  }
101
101
  options.filter.sort = 'id:1' // TODO: make this configurable
102
102
  if (!this.app.sumba || !id) {
103
- const result = await exportTo(model, dest, options)
103
+ const result = await exportTo(model, file, options)
104
104
  return result.file
105
105
  }
106
- const { downloadDir } = this.app.sumba
107
- dest = `${downloadDir}/${file}`
108
106
  const dmodel = this.app.dobo.getModel('SumbaDownload')
107
+ let dest
109
108
  try {
110
109
  await dmodel.updateRecord(id, { status: 'PROCESSING' })
111
- const result = await exportTo(model, dest, options)
110
+ const result = await exportTo(model, file, options)
112
111
  dest = result.file
113
112
  const { size } = fs.statSync(dest)
114
113
  await dmodel.updateRecord(id, { size, status: 'COMPLETE' })
@@ -31,21 +31,23 @@ async function exportHandler (opts = {}) {
31
31
  const { pascalCase } = this.app.lib.aneka
32
32
  const { getSchemaExt } = this.app.waibuDb
33
33
  const { buildUrl } = this.app.waibuMpa
34
+ const { callHandler, importModule } = this.app.bajo
34
35
  model = pascalCase(model ?? req.params.model)
35
36
  const mdl = this.app.dobo.getModel(model)
36
37
  const { schema } = await getSchemaExt(model, 'add', merge({ args: [{ req, model: mdl }] }, { params }, options))
37
38
  if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
38
39
  const data = await prepCrud.call(this.app.getPlugin('waibuDb'), { model, req, reply, args: ['model'] })
39
40
  data.opts = omit(data.opts, ['req', 'reply'])
41
+ data.opts.lang = req.lang
40
42
  const source = `${this.name}:/export-handler`
41
43
  const worker = 'waibuDb:exportData'
42
44
  const type = get(data, 'input.ftype', 'json')
43
- const settings = get(data, 'input.options', '').split(',')
44
- const ext = settings.includes('zip') ? `${type}.gz` : type
45
+ data.exportOpts = get(data, 'input.options', '').split(',')
46
+ const ext = data.exportOpts.includes('zip') ? `${type}.gz` : type
45
47
  // const file = `${kebabCase(model)}_${dayjs().format('YYYYMMDDhhmmss')}.${ext}`
46
48
  const file = `${kebabCase(model)}.${ext}`
47
- if (this.app.masohi && this.app.sumba) {
48
- await this.app.sumba.pushDownload({ file, type, worker, source, data, req })
49
+ if (this.app.sumbaXXX) {
50
+ await this.app.sumba.download({ file, type, worker, source, data, req })
49
51
  req.flash('notify', req.t('exportInQueue'))
50
52
  } else {
51
53
  const _opts = {
@@ -53,15 +55,15 @@ async function exportHandler (opts = {}) {
53
55
  data: {
54
56
  name: model,
55
57
  opts: data.opts,
58
+ exportOpts: data.exportOpts,
56
59
  filter: data.filter,
57
- download: { id: null, file }
60
+ download: { file }
58
61
  }
59
62
  }
60
63
  }
61
- const destFile = await this.exportData(_opts)
62
- const { importModule } = this.app.bajo
64
+ const destFile = await callHandler(worker, _opts)
63
65
  const { download } = await importModule('waibu:/lib/helper.js', { asDefaultImport: false })
64
- await download.call(this, destFile, req, reply, true)
66
+ await download.call(this, destFile, req, reply, file)
65
67
  }
66
68
  const url = buildUrl({ url: req.url, base: req.body.handler })
67
69
  return reply.redirectTo(url)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.29.1",
3
+ "version": "2.30.0",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-07-26
4
+
5
+ - [2.30.0] Canges in `exportTo()`
6
+ - [2.30.0] Bug fix in `btn-export.js`
7
+ - [2.30.0] Bug fix in `export-handler.js`
8
+
3
9
  ## 2026-07-25
4
10
 
5
11
  - [2.29.1] Bug fix in `exportData()`