sumba 2.45.0 → 2.46.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.
@@ -148,6 +148,11 @@
148
148
  "statusComplete": "Complete",
149
149
  "statusFail": "Fail",
150
150
  "fileDownloadNA": "File download is no longer available, has been removed, expired or you don't have permission to access it",
151
+ "modelRequired": "Model is required",
152
+ "modelNotFound%s": "Model '%s' is nowhere to be found",
153
+ "noSiteIdProperty%s": "Model '%s' does not have a 'siteId' property",
154
+ "aboutToRebuildModelWithSite%s%s": "You're about to rebuild model '%s' with alias '%s'. Continue?",
155
+ "modelPopulated%s%s": "Model successfully populated with site '%s' (%s record(s))",
151
156
  "field": {
152
157
  "currentPassword": "Current Password",
153
158
  "newPassword": "New Password",
@@ -154,6 +154,11 @@
154
154
  "statusComplete": "Selesai",
155
155
  "statusFail": "Gagal",
156
156
  "fileDownloadNA": "Unduhan file tidak lagi tersedia, telah dihapus, kedaluwarsa, atau Anda tidak memiliki izin untuk mengaksesnya",
157
+ "modelRequired": "Model harus diisi",
158
+ "modelNotFound%s": "Model '%s' tidak ditemukan",
159
+ "noSiteIdProperty%s": "Model '%s' tidak memiliki properti 'siteId'",
160
+ "aboutToRebuildModelWithSite%s%s": "Anda akan membangun ulang model '%s' dengan alias '%s'. Lanjutkan?",
161
+ "modelPopulated%s%s": "Model berhasil diisi dengan situs '%s' (%s data)",
157
162
  "field": {
158
163
  "currentPassword": "Kata Sandi Saat Ini",
159
164
  "newPassword": "Kata Sandi Baru",
@@ -0,0 +1,49 @@
1
+ async function populateModelWithSite (path, ...args) {
2
+ const { getModel } = this.app.dobo
3
+ const { importPkg } = this.app.bajo
4
+ const { isArray } = this.app.lib._
5
+ const confirm = await importPkg('bajoCli:@inquirer/confirm')
6
+ let [modelName, alias] = args
7
+ if (!modelName) this.print.fatal('modelRequired')
8
+ if (!alias) this.print.fatal('aliasRequired')
9
+ const model = getModel(modelName, true)
10
+ if (!model) this.print.fatal('modelNotFound%s', modelName)
11
+ if (!model.hasProperty('siteId')) this.print.fatal('noSiteIdProperty%s', modelName)
12
+ const answer = await confirm({ message: this.print.buildText('aboutToRebuildModelWithSite%s%s', modelName, alias), default: false })
13
+ if (!answer) {
14
+ this.print.fail('aborted')
15
+ this.app.exit()
16
+ }
17
+ if (alias.includes(',')) alias = alias.split(',').map(item => item.trim())
18
+ await this.app.dobo.start()
19
+ try {
20
+ const fixtures = await model.loadFixtures({ ignoreError: false, collectItems: true })
21
+ const siteModel = getModel('SumbaSite')
22
+ let sites = []
23
+ if (['all', '*'].includes(alias)) {
24
+ sites = await siteModel.findAllRecord({}, { dataOnly: true, fields: ['id', 'hostname'] })
25
+ } else {
26
+ if (!isArray(alias)) alias = [alias]
27
+ sites = await siteModel.findAllRecord({ query: { alias: { $in: alias } } }, { dataOnly: true, fields: ['id', 'hostname'] })
28
+ }
29
+ await model.transaction(async (trx) => {
30
+ for (const site of sites) {
31
+ for (const fixture of fixtures) {
32
+ const siteId = site.id + ''
33
+ fixture.siteId = siteId
34
+ const results = await model.findAllRecord({ query: { siteId, code: fixture.code } }, { fields: ['id'], trx })
35
+ for (const rec of results) {
36
+ await model.removeRecord(rec.id, { noCache: true, noResult: true, trx, throwNotFound: false })
37
+ }
38
+ await model.createRecord(fixture, { noCache: true, noResult: true, trx })
39
+ }
40
+ this.print.info('modelPopulated%s%s', site.hostname, fixtures.length)
41
+ }
42
+ })
43
+ } catch (err) {
44
+ this.print.fatal(err)
45
+ }
46
+ this.app.exit()
47
+ }
48
+
49
+ export default populateModelWithSite
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "2.45.0",
3
+ "version": "2.46.0",
4
4
  "description": "Biz Suite 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-08-13
4
+
5
+ - [2.46.0] Add `populateModelWithSite` applet
6
+
3
7
  ## 2026-08-08
4
8
 
5
9
  - [2.45.0] Add `lat` & `lng` columns to `site` schema