waibu-db 2.32.0 → 2.32.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.
@@ -22,10 +22,10 @@
22
22
  "yes": "Yes",
23
23
  "no": "No",
24
24
  "db": "DB",
25
- "excelXlsx": "Excel XLSX",
26
- "csv": "CSV",
27
- "xml": "XML",
28
- "json": "JSON",
25
+ "fileXlsx": "Excel File",
26
+ "fileCsv": "CSV File",
27
+ "fileXml": "XML File",
28
+ "fileJson": "JSON File",
29
29
  "addMoreAfterSubmit": "Add more after submit",
30
30
  "clonePrevious": "Clone previous",
31
31
  "actionPermanentlyDisabled%s": "Sorry, action '%s' is permanently disabled at database level. For more information, please contact your Admin immediately, thank you!",
@@ -34,8 +34,8 @@
34
34
  "uncheckAll": "Uncheck All",
35
35
  "attachment": "Attachment",
36
36
  "exportInQueue": "Data export in queue. Please check your download list for progress",
37
- "tsv": "TSV",
38
- "ndjson": "NDJSON",
37
+ "fileTsv": "TSV File",
38
+ "fileNdjson": "NDJSON File",
39
39
  "dataValue": "Data value",
40
40
  "suppressedError": "Error occured and suppressed. Please check error log for details",
41
41
  "queryHint%s": "Search by %s",
@@ -22,10 +22,10 @@
22
22
  "yes": "Ya",
23
23
  "no": "Tidak",
24
24
  "db": "DB",
25
- "excelXlsx": "Excel XLSX",
26
- "csv": "CSV",
27
- "xml": "XML",
28
- "json": "JSON",
25
+ "fileXlsx": "Berkas Excel",
26
+ "fileCsv": "Berkas CSV",
27
+ "fileXml": "Berkas XML",
28
+ "fileJson": "Berkas JSON",
29
29
  "addMoreAfterSubmit": "Tambah lagi setelah kirim",
30
30
  "clonePrevious": "Duplikasi sebelumnya",
31
31
  "actionPermanentlyDisabled%s": "Sorry, action '%s' is permanently disabled at database level. For more information, please contact your Admin immediately, thank you!",
@@ -34,8 +34,8 @@
34
34
  "uncheckAll": "Uncheck Semua",
35
35
  "attachment": "Attachment",
36
36
  "exportInQueue": "Ekspor data sedang dalam antrian. Silahkan cek daftar unduh Anda untuk perkembangan terakhir",
37
- "tsv": "TSV",
38
- "ndjson": "NDJSON",
37
+ "fileTsv": "Berkas TSV",
38
+ "fileNdjson": "Berkas NDJSON",
39
39
  "dataValue": "Nilai data",
40
40
  "suppressedError": "Kesalahan terjadi dan tidak ditampilkan. Silahkan cek log kesalahan untuk detilnya",
41
41
  "queryHint%s": "Cari berdasarkan %s",
@@ -95,7 +95,7 @@ async function btnExport () {
95
95
  },
96
96
  async submit () {
97
97
  const instance = wbs.getInstance('Modal', $refs.export)
98
- const handler = '${this.params.attr.handler ?? ''}'
98
+ const handler = '${this.params.attr.noBase ? '' : (this.params.attr.handler ?? '')}'
99
99
  if (this.delivery === 'clipboard') {
100
100
  const selector = '${this.params.attr.selector}'
101
101
  if (_.isEmpty(selector)) {
@@ -128,11 +128,11 @@ async function btnExport () {
128
128
  </c:grid-col>
129
129
  <c:grid-col col="6-md">
130
130
  <c:fieldset t:legend="fileType" legend-type="6">
131
- <c:form-radio x-ref="xlsx" x-model="ftype" value="xlsx" t:label="excelXlsx" />
132
- <c:form-radio x-ref="csv" x-model="ftype" value="csv" t:label="csv" />
133
- <c:form-radio x-ref="tsv" x-model="ftype" value="tsv" t:label="tsv" />
134
- <c:form-radio x-ref="json" x-model="ftype" value="json" t:label="json" />
135
- <c:form-radio x-ref="ndjson" x-model="ftype" value="ndjson" t:label="ndjson" />
131
+ <c:form-radio x-ref="xlsx" x-model="ftype" value="xlsx" t:label="fileXlsx" />
132
+ <c:form-radio x-ref="csv" x-model="ftype" value="csv" t:label="fileCsv" />
133
+ <c:form-radio x-ref="tsv" x-model="ftype" value="tsv" t:label="fileTsv" />
134
+ <c:form-radio x-ref="json" x-model="ftype" value="json" t:label="fileJson" />
135
+ <c:form-radio x-ref="ndjson" x-model="ftype" value="ndjson" t:label="fileNdjson" />
136
136
  </c:fieldset />
137
137
  </c:grid-col>
138
138
  </c:grid-row>
package/index.js CHANGED
@@ -87,34 +87,17 @@ async function factory (pkgName) {
87
87
  */
88
88
  exportData = async (params) => {
89
89
  const { get } = this.app.lib._
90
- const { fs } = this.app.lib
91
90
  const { exportTo } = this.app.doboExtra
92
91
  const model = get(params, 'payload.data.name')
93
92
  const fields = get(params, 'payload.data.opts.fields')
94
- const { id, file } = get(params, 'payload.data.download', {})
93
+ const file = get(params, 'payload.data.file', {})
95
94
  const options = {
96
95
  filter: get(params, 'payload.data.filter', {}),
97
96
  exportOpts: get(params, 'payload.data.exportOpts', []),
98
97
  opts: get(params, 'payload.data.opts', {}),
99
98
  fields
100
99
  }
101
- options.filter.sort = 'id:1' // TODO: make this configurable
102
- if (!this.app.sumba || !id) {
103
- const result = await exportTo(model, file, options)
104
- return result.file
105
- }
106
- const dmodel = this.app.dobo.getModel('SumbaDownload')
107
- let dest
108
- try {
109
- await dmodel.updateRecord(id, { status: 'PROCESSING' })
110
- const result = await exportTo(model, file, options)
111
- dest = result.file
112
- const { size } = fs.statSync(dest)
113
- await dmodel.updateRecord(id, { size, status: 'COMPLETE' })
114
- } catch (err) {
115
- await dmodel.updateRecord(id, { status: 'FAIL' })
116
- }
117
- return dest
100
+ return await exportTo(model, file, options)
118
101
  }
119
102
 
120
103
  /**
@@ -36,23 +36,29 @@ async function exportHandler (opts = {}) {
36
36
  const mdl = this.app.dobo.getModel(model)
37
37
  const { schema } = await getSchemaExt(model, 'add', merge({ args: [{ req, model: mdl }] }, { params }, options))
38
38
  if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
39
- const data = await prepCrud.call(this.app.getPlugin('waibuDb'), { model, req, reply, args: ['model'] })
40
- data.opts = omit(data.opts, ['req', 'reply'])
39
+ const crud = await prepCrud.call(this.app.getPlugin('waibuDb'), { model, req, reply, args: ['model'] })
40
+ const data = {
41
+ name: model,
42
+ filter: crud.filter,
43
+ opts: omit(crud.opts, ['req', 'reply', 'model'])
44
+ }
41
45
  data.opts.lang = req.lang
42
46
  data.opts.fields = isEmpty(req.query.fields) ? get(schema, 'view.fields', []) : req.query.fields.split(',')
43
47
 
44
- data.opts.timeZone = get(req, 'site.setting.sumba.timeZone', this.app.bajo.config.intl.format.datetime.timeZone)
45
- data.opts.dateStyle = get(req, 'site.setting.sumba.dateStyle', this.app.bajo.config.intl.format.datetime.dateStyle)
46
- data.opts.timeStyle = get(req, 'site.setting.sumba.timeStyle', this.app.bajo.config.intl.format.datetime.timeStyle)
47
- const source = `${this.name}:/export-handler`
48
- const worker = 'waibuDb:exportData'
49
- const type = get(data, 'input.ftype', 'json')
50
- data.exportOpts = get(data, 'input.options', '').split(',')
48
+ data.opts.datetime = get(opts, 'req.site.setting.bajo.intl.datetime', this.app.bajo.config.intl.datetime)
49
+ data.opts.date = get(opts, 'req.site.setting.bajo.intl.date', this.app.bajo.config.intl.date)
50
+ data.opts.time = get(opts, 'req.site.setting.bajo.intl.time', this.app.bajo.config.intl.time)
51
+ data.opts.timeZone = get(opts, 'req.site.setting.bajo.intl.timeZone', this.app.bajo.config.intl.timeZone)
52
+
53
+ const source = `${this.ns}:/export-handler`
54
+ const worker = `${this.ns}:exportData`
55
+ const type = get(crud, 'input.ftype', 'json')
56
+ data.exportOpts = get(crud, 'input.options', '').split(',')
51
57
  const ext = data.exportOpts.includes('zip') ? `${type}.gz` : type
52
- // const file = `${kebabCase(model)}_${dayjs().format('YYYYMMDDhhmmss')}.${ext}`
53
58
  const file = `${kebabCase(model)}.${ext}`
54
59
  if (this.app.sumba) {
55
- await this.app.sumba.download({ file, type, worker, source, data, req })
60
+ const description = kebabCase(model).split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')
61
+ await this.app.sumba.pushDownload({ file, description, type, worker, source, data, req })
56
62
  req.flash('notify', req.t('exportInQueue'))
57
63
  } else {
58
64
  const _opts = {
@@ -62,7 +68,7 @@ async function exportHandler (opts = {}) {
62
68
  opts: data.opts,
63
69
  exportOpts: data.exportOpts,
64
70
  filter: data.filter,
65
- download: { file }
71
+ file
66
72
  }
67
73
  }
68
74
  }
@@ -70,7 +76,8 @@ async function exportHandler (opts = {}) {
70
76
  const { download } = await importModule('waibu:/lib/helper.js', { asDefaultImport: false })
71
77
  await download.call(this, destFile, req, reply, file)
72
78
  }
73
- const url = buildUrl({ url: req.url, base: req.body.handler })
79
+ const base = isEmpty(req.body.handler) ? undefined : req.body.handler
80
+ const url = buildUrl({ url: req.url, base })
74
81
  return reply.redirectTo(url)
75
82
  }
76
83
 
@@ -1,11 +1,11 @@
1
1
  import { prepCrud, processHandler } from '../util.js'
2
2
 
3
- async function createRecord ({ model, req, reply, options = {}, transaction } = {}) {
3
+ async function createRecord ({ model, req, body, reply, options = {}, transaction } = {}) {
4
4
  const { model: mdl, opts, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, options, args: ['model'], transaction })
5
5
 
6
6
  async function handler (trx) {
7
7
  if (opts.trx === true) opts.trx = trx
8
- const ret = await mdl.createRecord(req.body, { ...opts, partial: true, strict: true })
8
+ const ret = await mdl.createRecord(body ?? req.body, { ...opts, partial: true, strict: true })
9
9
  if (attachment) ret.data._attachment = await mdl.findAttachment(ret.data.id, { stats, mimeType })
10
10
  return ret
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-db",
3
- "version": "2.32.0",
3
+ "version": "2.32.2",
4
4
  "description": "DB Helper",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-07-29
4
+
5
+ - [2.32.2] Bug fix in `export-handler.js`
6
+
7
+ ## 2026-07-28
8
+
9
+ - [2.32.1] Bug fix in `exportData()`
10
+ - [2.32.1] Bug fix in `btn-export.js`
11
+ - [2.32.1] Bug fix in `export-handler.js`
12
+ - [2.32.1] Bug fix in `create-record.js`
13
+
3
14
  ## 2026-07-27
4
15
 
5
16
  - [2.32.0] Add support for `sumba.download()` through `export-handler.js`