bajo 2.10.1 → 2.11.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.
- package/class/app/log.js +1 -1
- package/class/app.js +6 -5
- package/class/bajo.js +14 -12
- package/class/base.js +3 -3
- package/class/plugin/tools.js +1 -1
- package/class/plugin.js +1 -1
- package/extend/bajo/intl/en-US.json +3 -1
- package/extend/bajo/intl/id.json +3 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +23 -13
package/class/app/log.js
CHANGED
package/class/app.js
CHANGED
|
@@ -328,6 +328,7 @@ class App {
|
|
|
328
328
|
|
|
329
329
|
_prepTrans = (ns, text, params) => {
|
|
330
330
|
const { fallback, supported } = this.bajo.config.intl
|
|
331
|
+
const { isSet } = this.lib.aneka
|
|
331
332
|
if (!text) {
|
|
332
333
|
text = ns
|
|
333
334
|
ns = 'bajo'
|
|
@@ -349,13 +350,13 @@ class App {
|
|
|
349
350
|
for (const p of plugins) {
|
|
350
351
|
const store = get(this, `${p}.intl.${lang}`, {})
|
|
351
352
|
trans = get(store, text)
|
|
352
|
-
if (trans) break
|
|
353
|
+
if (isSet(trans)) break
|
|
353
354
|
}
|
|
354
|
-
if (!trans) {
|
|
355
|
+
if (!isSet(trans)) {
|
|
355
356
|
for (const p of plugins) {
|
|
356
357
|
const store = get(this, `${p}.intl.${fallback}`, {})
|
|
357
358
|
trans = get(store, text)
|
|
358
|
-
if (trans) break
|
|
359
|
+
if (isSet(trans)) break
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
362
|
return { ns, text, lang, params, plugins, trans }
|
|
@@ -380,9 +381,9 @@ class App {
|
|
|
380
381
|
* @returns {string}
|
|
381
382
|
*/
|
|
382
383
|
t = (ns, text, ...params) => {
|
|
383
|
-
const { formatText } = this.lib.aneka
|
|
384
|
+
const { formatText, isSet } = this.lib.aneka
|
|
384
385
|
let { text: newText, trans, params: args } = this._prepTrans(ns, text, params)
|
|
385
|
-
if (!trans) trans = newText
|
|
386
|
+
if (!isSet(trans)) trans = newText
|
|
386
387
|
return formatText(trans, ...args)
|
|
387
388
|
}
|
|
388
389
|
|
package/class/bajo.js
CHANGED
|
@@ -301,15 +301,14 @@ class Bajo extends Plugin {
|
|
|
301
301
|
scope = item
|
|
302
302
|
item = args.shift()
|
|
303
303
|
}
|
|
304
|
-
const bajo = scope.app.bajo
|
|
305
304
|
if (isString(item)) {
|
|
306
|
-
if (item.startsWith('applet:') &&
|
|
305
|
+
if (item.startsWith('applet:') && this.app.applets.length > 0) {
|
|
307
306
|
const [, ns, path] = item.split(':')
|
|
308
|
-
const applet = find(
|
|
309
|
-
if (applet &&
|
|
307
|
+
const applet = find(this.app.applets, a => (a.ns === ns || a.alias === ns))
|
|
308
|
+
if (applet && this.app.bajoCli) result = await this.app.bajoCli.runApplet(applet, path, ...args)
|
|
310
309
|
} else {
|
|
311
310
|
const [ns, method, ...params] = item.split(':')
|
|
312
|
-
const fn =
|
|
311
|
+
const fn = this.getMethod(`${ns}:${method}`)
|
|
313
312
|
if (fn) {
|
|
314
313
|
if (params.length > 0) args.unshift(...params)
|
|
315
314
|
result = await fn(...args)
|
|
@@ -454,7 +453,7 @@ class Bajo extends Plugin {
|
|
|
454
453
|
* @returns {string} Formatted value
|
|
455
454
|
*/
|
|
456
455
|
format = (value, type, options = {}) => {
|
|
457
|
-
const { defaultsDeep } = this.app.lib.aneka
|
|
456
|
+
const { defaultsDeep, isSet } = this.app.lib.aneka
|
|
458
457
|
const { format } = this.config.intl
|
|
459
458
|
const { emptyValue = format.emptyValue } = options
|
|
460
459
|
const lang = options.lang ?? this.config.lang
|
|
@@ -496,6 +495,7 @@ class Bajo extends Plugin {
|
|
|
496
495
|
}
|
|
497
496
|
if (['array'].includes(type)) return value.join(', ')
|
|
498
497
|
if (['object'].includes(type)) return JSON.stringify(value)
|
|
498
|
+
if (['boolean'].includes(type) && isSet(value)) return value ? this.t('true', { lang }) : this.t('false', { lang })
|
|
499
499
|
return value
|
|
500
500
|
}
|
|
501
501
|
|
|
@@ -800,15 +800,17 @@ class Bajo extends Plugin {
|
|
|
800
800
|
* @param {string} [options.lastSeparator=and] - Text to use as the last separator
|
|
801
801
|
* @returns {string}
|
|
802
802
|
*/
|
|
803
|
-
join = (array, options) => {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
803
|
+
join = (array, options = {}) => {
|
|
804
|
+
let separator = ', '
|
|
805
|
+
let lastSeparator = 'and'
|
|
806
|
+
let lang
|
|
807
|
+
if (isString(options)) separator = options
|
|
808
|
+
else ({ separator, lastSeparator, lang } = options)
|
|
809
|
+
const translate = (val) => {
|
|
810
|
+
return this.t(val, { lang }).toLowerCase()
|
|
807
811
|
}
|
|
808
812
|
if (array.length === 0) return translate('none')
|
|
809
813
|
if (array.length === 1) return array[0]
|
|
810
|
-
if (isSet(options) && !isPlainObject(options)) return array.join(options)
|
|
811
|
-
let { separator = ', ', lastSeparator = 'and' } = options ?? {}
|
|
812
814
|
lastSeparator = translate(lastSeparator)
|
|
813
815
|
const last = (array.pop() ?? '').trim()
|
|
814
816
|
return array.map(a => (a + '').trim()).join(separator) + ` ${lastSeparator} ${last}`
|
package/class/base.js
CHANGED
|
@@ -94,14 +94,14 @@ class Base extends Plugin {
|
|
|
94
94
|
* @async
|
|
95
95
|
*/
|
|
96
96
|
exit = async () => {
|
|
97
|
-
this.dispose()
|
|
97
|
+
await this.dispose()
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Dispose internal references
|
|
102
102
|
*/
|
|
103
|
-
dispose = () => {
|
|
104
|
-
super.dispose()
|
|
103
|
+
dispose = async () => {
|
|
104
|
+
await super.dispose()
|
|
105
105
|
this.state = null
|
|
106
106
|
}
|
|
107
107
|
}
|
package/class/plugin/tools.js
CHANGED
package/class/plugin.js
CHANGED
|
@@ -182,5 +182,7 @@
|
|
|
182
182
|
"fieldError%s%s": "'%s': %s|lowerFirst",
|
|
183
183
|
"reservedName%s%s": "%s|upperFirst name '%s' is a reserved name. Please rename to something else",
|
|
184
184
|
"missing%s%s": "Missing '%s' %s",
|
|
185
|
-
"processing...": "Processing..."
|
|
185
|
+
"processing...": "Processing...",
|
|
186
|
+
"true": "True",
|
|
187
|
+
"false": "False"
|
|
186
188
|
}
|
package/extend/bajo/intl/id.json
CHANGED
|
@@ -182,5 +182,7 @@
|
|
|
182
182
|
"fieldError%s%s": "'%s': %s|lowerFirst",
|
|
183
183
|
"reservedName%s%s": "Nama %s|lowerFirst '%s' adalah nama tang di reserve. Silahkan gunakan nama lainnya",
|
|
184
184
|
"missing%s%s": "%s|upperFirst '%s' tidak ditemukan",
|
|
185
|
-
"processing...": "Memroses..."
|
|
185
|
+
"processing...": "Memroses...",
|
|
186
|
+
"true": "Benar",
|
|
187
|
+
"false": "Salah"
|
|
186
188
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-04-11
|
|
4
|
+
|
|
5
|
+
- [2.11.1] Bug fix in ```join()```
|
|
6
|
+
- [2.11.1] Bug fix in ```format()```
|
|
7
|
+
|
|
8
|
+
## 2026-04-07
|
|
9
|
+
|
|
10
|
+
- [2.11.0] Change ```dispose()``` to be an async function
|
|
11
|
+
- [2.11.0] Bug fix in ```_prepTrans()```
|
|
12
|
+
|
|
3
13
|
## 2026-03-30
|
|
4
14
|
|
|
5
15
|
- [2.10.0] Add ability to pass options of ```configHandlers``` with type ```.js```
|
|
6
16
|
- [2.10.0] Freezing config object now occurs ```{ns}:afterStart()```
|
|
7
|
-
- [2.10.0] Bug fix
|
|
8
|
-
- [2.10.1] Bug fix
|
|
17
|
+
- [2.10.0] Bug fix in ```print.fatal()``` when argument is an Error object
|
|
18
|
+
- [2.10.1] Bug fix in ```fromJs()```
|
|
9
19
|
|
|
10
20
|
## 2026-03-25
|
|
11
21
|
|
|
@@ -39,30 +49,30 @@
|
|
|
39
49
|
|
|
40
50
|
## 2026-02-26
|
|
41
51
|
|
|
42
|
-
- [2.6.2] Bug fix
|
|
52
|
+
- [2.6.2] Bug fix in ```getMethod()```
|
|
43
53
|
|
|
44
54
|
## 2026-02-23
|
|
45
55
|
|
|
46
|
-
- [2.6.1] Bug fix
|
|
47
|
-
- [2.6.1] Bug fix
|
|
56
|
+
- [2.6.1] Bug fix in ```readConfig()```
|
|
57
|
+
- [2.6.1] Bug fix in ```base.loadConfig()```
|
|
48
58
|
|
|
49
59
|
## 2026-02-20
|
|
50
60
|
|
|
51
61
|
- [2.6.0] Upgrade to ```aneka@0.12.0```
|
|
52
62
|
- [2.6.0] Add ```te()```
|
|
53
|
-
- [2.6.0] Bug fix
|
|
63
|
+
- [2.6.0] Bug fix in ```formatErrorDetails()``` in ```Err``` class
|
|
54
64
|
|
|
55
65
|
## 2026-02-08
|
|
56
66
|
|
|
57
|
-
- [2.5.0] Bug fix
|
|
67
|
+
- [2.5.0] Bug fix in handling log for ```error``` level
|
|
58
68
|
- [2.5.0] Add ```log.getErrorMessage()``` to get the right value of error message
|
|
59
69
|
- [2.5.0] Add ```timeZone``` in config for datetime data type
|
|
60
70
|
|
|
61
71
|
## 2026-01-29
|
|
62
72
|
|
|
63
73
|
- [2.4.0] Hooks can now be added through ```config``` object. This is specially usefull if you provide a custom config object on app boot
|
|
64
|
-
- [2.4.1] Bug fix
|
|
65
|
-
- [2.4.2] Bug fix
|
|
74
|
+
- [2.4.1] Bug fix in ```runHook()``` resolver. Source defaults to ```main``` if not provided. Scope defaults to ```bajo``` if not found/initialized yet
|
|
75
|
+
- [2.4.2] Bug fix in getting wrongly parsed ```env``` value
|
|
66
76
|
|
|
67
77
|
## 2026-01-24
|
|
68
78
|
|
|
@@ -70,18 +80,18 @@
|
|
|
70
80
|
|
|
71
81
|
## 2026-01-21
|
|
72
82
|
|
|
73
|
-
- [2.3.1] Bug fix
|
|
83
|
+
- [2.3.1] Bug fix in keys that needs to be used while reading plugin's config files
|
|
74
84
|
|
|
75
85
|
## 2026-01-18
|
|
76
86
|
|
|
77
87
|
- [2.3.0] ```App``` constructor now accept an object as its parameter. For details, please see documentation
|
|
78
88
|
- [2.3.0] Package upgrade to ```aneka@0.11.0```
|
|
79
|
-
- [2.3.0] Bug fix
|
|
89
|
+
- [2.3.0] Bug fix in ```checkDependencies()```
|
|
80
90
|
|
|
81
91
|
## 2026-01-16
|
|
82
92
|
|
|
83
|
-
- [2.2.1] Bug fix
|
|
84
|
-
- [2.2.1] Bug fix
|
|
93
|
+
- [2.2.1] Bug fix in multiple appearance of loaded plugins info
|
|
94
|
+
- [2.2.1] Bug fix in ```app.lib.parseObject()``` wrapper
|
|
85
95
|
|
|
86
96
|
## 2026-01-11
|
|
87
97
|
|