dobo-extra 2.5.1 → 2.5.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.
package/index.js CHANGED
@@ -126,7 +126,6 @@ async function factory (pkgName) {
126
126
  * @param {string} dest - Destination file path (absolute or relative to plugin data dir)
127
127
  * @param {object} options - Export options
128
128
  * @param {object} [options.filter={}] - Filter object to select records to export
129
- * @param {boolean} [options.ensureDir] - Whether to create the destination directory if it doesn't exist
130
129
  * @param {boolean} [options.useHeader=true] - Whether to include the header row (for CSV/TSV/XLSX)
131
130
  * @param {number} [options.batch=500] - Number of records to export in a single batch
132
131
  * @param {function} [options.progressFn] - Callback function to report progress
@@ -136,33 +135,22 @@ async function factory (pkgName) {
136
135
  */
137
136
  exportTo = (source, dest, options = {}) => {
138
137
  let {
139
- filter = {}, ensureDir, useHeader = true, batch = 500,
140
- progressFn, fields, parserOpts = {}
138
+ filter = {}, useHeader = true, batch = 500, opts = {},
139
+ progressFn, fields, parserOpts = {}, exportOpts = {}
141
140
  } = options
142
- const { importPkg } = this.app.bajo
141
+ const { getDownloadDir } = this.app.bajo
143
142
  const { fs } = this.app.lib
144
143
  const { merge, omit } = this.app.lib._
145
144
  const { getModel } = this.app.dobo
145
+ const { generateId } = this.app.lib.aneka
146
146
 
147
147
  const getFile = async () => {
148
- const increment = await importPkg('bajo:add-filename-increment')
149
- let file
150
- if (path.isAbsolute(dest)) file = dest
151
- else {
152
- file = `${this.app.getPluginDataDir(this.ns)}/export/${dest}`
153
- fs.ensureDirSync(path.dirname(file))
154
- }
155
- file = increment(file, { fs: true, platform: 'win32' })
156
- const dir = path.dirname(file)
157
- if (!fs.existsSync(dir)) {
158
- if (ensureDir) fs.ensureDirSync(dir)
159
- else throw this.error('dirNotExists%s', dir)
160
- }
148
+ let ext = path.extname(dest)
149
+ const file = `${getDownloadDir()}/${generateId()}${ext}`
161
150
  let compress = false
162
- let ext = path.extname(file)
163
151
  if (ext === '.gz') {
164
152
  compress = true
165
- ext = path.extname(file.slice(0, -3))
153
+ ext = path.extname(dest.slice(0, -3))
166
154
  // file = file.slice(0, file.length - 3)
167
155
  }
168
156
  if (!exts.includes(ext)) throw this.error('unsupportedFormat%s', ext.slice(1))
@@ -190,7 +178,17 @@ async function factory (pkgName) {
190
178
  for (;;) {
191
179
  const batchStart = new Date()
192
180
  const { data: rows, page } = await model.findRecord(filter, { dataOnly: false, fields, fmt: true, refs: '*', noCache: true })
193
- const data = rows.map(item => omit(item, ['_immutable', '_fmt', '_ref']))
181
+ const data = rows.map(item => {
182
+ let _item = exportOpts.includes('fvalue') ? item._fmt : omit(item, ['_immutable', '_fmt', '_ref'])
183
+ if (exportOpts.includes('fkey')) {
184
+ const newItem = {}
185
+ for (const key in _item) {
186
+ newItem[opts.lang ? this.t(`field.${key}`, { lang: opts.lang }) : key] = _item[key]
187
+ }
188
+ _item = newItem
189
+ }
190
+ return _item
191
+ })
194
192
  if (data.length === 0) break
195
193
  if (cnt + data.length > hardCap) {
196
194
  const sliced = data.slice(0, hardCap - cnt)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dobo-extra",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "Bajo DB Extra Tools/Utility",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-07-26
4
+
5
+ - [2.5.2] Bug fix in `exportTo()`
6
+
3
7
  ## 2026-07-25
4
8
 
5
9
  - [2.5.1] Bug fix in `exportTo()`