dobo 2.20.0 → 2.20.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.
@@ -52,12 +52,12 @@ async function sanitizeProp (model, prop, indexes) {
52
52
  * @param {Array} [inputs] - Array of properties
53
53
  * @param {Array} [indexes] - Container array to fill up found index
54
54
  */
55
- async function findAllProps (model, inputs = [], indexes = [], isExtender) {
55
+ async function findAllProps (model, inputs = [], indexes = []) {
56
56
  const { isPlainObject, cloneDeep } = this.app.lib._
57
57
  const isIdProp = inputs.find(p => {
58
58
  return isPlainObject(p) ? p.name === 'id' : p.startsWith('id,')
59
59
  })
60
- if (!isExtender && !isIdProp) {
60
+ if (!isIdProp) {
61
61
  const idField = cloneDeep(model.connection.driver.idField)
62
62
  idField.name = 'id'
63
63
  inputs.unshift(idField)
@@ -74,7 +74,7 @@ async function findAllProps (model, inputs = [], indexes = [], isExtender) {
74
74
  * @param {Object} options - Options to the feature
75
75
  * @returns {Array} New properties found in feature
76
76
  */
77
- async function applyFeature (model, feature, options, indexes, isExtender) {
77
+ async function applyFeature (model, feature, options, indexes) {
78
78
  const { isArray, findIndex } = this.app.lib._
79
79
  if (feature.name === 'dobo:unique' && options.field === 'id') {
80
80
  const idx = findIndex(model.properties, { name: 'id' })
@@ -103,14 +103,14 @@ async function applyFeature (model, feature, options, indexes, isExtender) {
103
103
  * @param {Object} model - Model
104
104
  * @param {Array} [inputs] - Array of properties
105
105
  */
106
- async function findAllFeats (model, inputs = [], indexes = [], isExtender) {
106
+ async function findAllFeats (model, inputs = [], indexes = []) {
107
107
  const { isString, omit } = this.app.lib._
108
108
  for (let feat of inputs) {
109
109
  if (isString(feat)) feat = { name: feat }
110
110
  const featName = feat.name.indexOf(':') === -1 ? `dobo:${feat.name}` : feat.name
111
111
  const feature = this.app.dobo.getFeature(featName)
112
112
  if (!feature) this.fatal('invalidFeature%s%s', model.name, featName)
113
- await applyFeature.call(this, model, feature, omit(feat, 'name'), indexes, isExtender)
113
+ await applyFeature.call(this, model, feature, omit(feat, 'name'), indexes)
114
114
  }
115
115
  }
116
116
 
@@ -235,9 +235,7 @@ export async function sanitizeAll (model) {
235
235
  * @returns {Object} Sanitized model
236
236
  */
237
237
  async function createSchema (item) {
238
- const { readConfig } = this.app.bajo
239
- const { fastGlob } = this.app.lib
240
- const { find, isPlainObject, orderBy, get, cloneDeep } = this.app.lib._
238
+ const { find, orderBy, get } = this.app.lib._
241
239
  const { mergeObjectsByKey, defaultsDeep, parseObject } = this.app.lib.aneka
242
240
  if (item.file && !item.base) item.base = path.basename(item.file, path.extname(item.file))
243
241
  item.attachment = item.attachment ?? true
@@ -265,29 +263,18 @@ async function createSchema (item) {
265
263
  if (!item.connection && conn === 'default') item.connection = this.getConnection('memory')
266
264
  }
267
265
  if (!item.connection) this.fatal('unknownConn%s%s', conn, item.name)
268
- const defCache = cloneDeep(get(this, 'app.bajoCache.config.default', this.config.default.cache))
269
- item.cache = item.cache ?? item.connection.options.cache ?? defCache
270
- if (item.cache === true) item.cache = get(item, 'connection.options.cache', defCache)
271
- else if (item.cache === false) item.cache = { ttlDur: 0 }
272
- item.cache = parseObject(defaultsDeep(get(this, `app.bajoCache.config.dobo.${item.name}`), item.cache))
266
+ // cache settings
267
+ const defCache = defaultsDeep({}, item.connection.options.cache, get(this, 'app.bajoCache.config.default', this.config.default.cache))
268
+ if (item.cache === false) item.cache = { ttlDur: 0 }
269
+ else if (item.cache === true) item.cache = defCache
270
+ else item.cache = defaultsDeep({}, item.cache, defCache)
271
+ item.cache = parseObject(item.cache)
272
+ if (item.connection.name === 'memory') item.cache.ttlDur = 0
273
+
274
+ // let's run
273
275
  await findAllProps.call(this, item, props, indexes)
274
276
  await findAllFeats.call(this, item, feats, indexes)
275
277
  await findAllIndexes.call(this, item, indexes)
276
- // item extender
277
- if (item.base) {
278
- for (const ns of this.app.getAllNs()) {
279
- const plugin = this.app[ns]
280
- const glob = `${plugin.dir.pkg}/extend/dobo/extend/${item.ns}/model/${item.base}.*`
281
- const files = await fastGlob(glob)
282
- for (const file of files) {
283
- const extender = await readConfig(file, { ns: plugin.ns, ignoreError: true })
284
- if (!isPlainObject(extender)) this.plugin.fatal('invalidModelExtender%s%s', ns, item.name)
285
- await findAllProps.call(this, item, extender.properties ?? [], indexes, true)
286
- await findAllFeats.call(this, item, extender.features ?? [], indexes, true)
287
- await findAllIndexes.call(this, item, extender.indexes ?? [], indexes, true)
288
- }
289
- }
290
- }
291
278
  for (const key of ['properties', 'indexes']) {
292
279
  item[key] = mergeObjectsByKey(item[key], 'name')
293
280
  }
@@ -322,10 +309,11 @@ async function collectModels () {
322
309
 
323
310
  const base = path.basename(file, path.extname(file))
324
311
  const defName = pascalCase(`${this.alias} ${base}`)
325
- const item = await readConfig(file, { ns: this.ns, ignoreError: true })
312
+ const item = await readConfig(file, { ns: this.ns, baseNs: me.ns })
326
313
  if (isEmpty(item)) return undefined
327
314
  if (!isPlainObject(item)) me.fatal('invalidModel%s', defName)
328
315
  item.name = item.name ?? defName
316
+ me.log.trace('- %s', item.name)
329
317
  item.collName = item.collName ?? item.name
330
318
  item.file = file
331
319
  item.ns = this.ns
@@ -344,7 +332,6 @@ async function collectModels () {
344
332
  }
345
333
  for (const model of me.models) {
346
334
  await sanitizeRef.call(this, model, me.models)
347
- me.log.trace('- %s', model.name)
348
335
  }
349
336
  this.log.debug('collected%s%d', this.t('model'), this.models.length)
350
337
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dobo",
3
- "version": "2.20.0",
3
+ "version": "2.20.1",
4
4
  "description": "DBMS for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-04-23
4
+
5
+ - [2.20.1] Bug fix in ```collect-models.js```, now with deep merge in advance
6
+
3
7
  ## 2026-04-21
4
8
 
5
9
  - [2.19.1] Bug fix in ```collect-models.js```, now values are sanitized with ```parseObject()```