dobo 1.0.17 → 1.0.19

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.
@@ -1,10 +1,10 @@
1
1
  {
2
- "isConnected%s%s": "[%s] '%s' is connected",
3
- "errorOn%s%s": "[%s] Error on '%s': %s",
4
- "isDestroyed%s%s": "[%s] '%s' is destroyed",
5
- "loadedSchemas%s": "[%s] Loaded schemas: %s",
6
- "loadSchema%s%s%d": "[%s] Load schema: %s (%d)",
7
- "loadedConns%s%s": "[%s] Loaded connections: %s",
2
+ "isConnected%s%s": "%s' is connected",
3
+ "errorOn%s%s": "Error on '%s': %s",
4
+ "isDestroyed%s%s": "'%s' is destroyed",
5
+ "loadedSchemas%s": "Loaded schemas: %s",
6
+ "loadSchema%s%s%d": "Load schema: %s (%d)",
7
+ "loadedConns%s%s": "Loaded connections: %s",
8
8
  "unsupportedPropTypeIn%s%s": "Unsupported property type '%s' in '%s'",
9
9
  "noSchemaFound": "No schema found!",
10
10
  "enterSchemaName": "Enter schema name, separated by space:",
@@ -20,7 +20,7 @@
20
20
  "errorCreatingModel%s%s": "Error creating model '%s': %s",
21
21
  "modelDropped%s": "Model '%s' successfully dropped",
22
22
  "memoryDbSkipped%s%s": "DB '%s' for '%s' is a memory DB, skipped",
23
- "modelBuiltOnthefly%s%s%s": "[%s] Model '%s@%s' successfully built on the fly",
23
+ "modelBuiltOnthefly%s%s%s": "Model '%s@%s' successfully built on the fly",
24
24
  "unableToBuildModel%s%s%s": "Unable to re-build model '%s' in '%s': %s",
25
25
  "unknownSchema%s": "Unknown schema '%s'",
26
26
  "payloadMustBeJson": "Payload must be a valid JSON",
@@ -185,7 +185,7 @@
185
185
  "validation": {
186
186
  "any": {
187
187
  "required": "Required",
188
- "only": "Must match with {{ref}}"
188
+ "only": "Must match with %(ref)s"
189
189
  },
190
190
  "string": {
191
191
  "alphanum": "Must only contain alpha-numeric characters",
@@ -200,14 +200,14 @@
200
200
  "hex": "Must only contain hexadecimal characters",
201
201
  "hexAlign": "Hex decoded representation must be byte aligned",
202
202
  "hostname": "Must be a valid hostname",
203
- "ip": "must be a valid ip address with a {{cidr}} CIDR",
204
- "ipVersion": "Must be a valid ip address of one of the following versions {{version}} with a {{cidr}} CIDR",
203
+ "ip": "must be a valid ip address with a %(cidr)s CIDR",
204
+ "ipVersion": "Must be a valid ip address of one of the following versions %(version)s with a %(cidr)s CIDR",
205
205
  "isoDate": "Must be in iso format",
206
206
  "isoDuration": "Must be a valid ISO 8601 duration",
207
- "length": "Length must be {{limit}} characters long",
207
+ "length": "Length must be %(limit)s characters long",
208
208
  "lowercase": "Must only contain lowercase characters",
209
- "max": "Length must be less than or equal to {{limit}} characters long",
210
- "min": "Length must be at least {{limit}} characters long",
209
+ "max": "Length must be less than or equal to %(limit)s characters long",
210
+ "min": "Length must be at least %(limit)s characters long",
211
211
  "token": "Must only contain alpha-numeric and underscore characters",
212
212
  "trim": "Must not have leading or trailing whitespace",
213
213
  "uri": "Must be a valid uri",
package/bajo/intl/id.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
- "isConnected%s%s": "[%s] '%s' telah tersambung",
3
- "errorOn%s%s": "[%s] Kesalahan pada '%s': %s",
4
- "isDestroyed%s%s": "[%s] '%s' telah dimusnahkan",
5
- "loadedSchemas%s": "[%s] Skema termuat: %s",
6
- "loadSchema%s%s%d": "[%s] Muat skema: %s (%d)",
7
- "loadedConns%s%s": "[%s] Koneksi termuat: %s",
2
+ "isConnected%s%s": "'%s' telah tersambung",
3
+ "errorOn%s%s": "Kesalahan pada '%s': %s",
4
+ "isDestroyed%s%s": "'%s' telah dimusnahkan",
5
+ "loadedSchemas%s": "Skema termuat: %s",
6
+ "loadSchema%s%s%d": "Muat skema: %s (%d)",
7
+ "loadedConns%s%s": "Koneksi termuat: %s",
8
8
  "unsupportedPropTypeIn%s%s": "Tipe properti '%s' di '%s' tidak didukung",
9
9
  "noSchemaFound": "Tidak ditemukan skema!",
10
10
  "enterSchemaName": "Masukkan nama skema, dipisah dengan spasi:",
@@ -19,7 +19,7 @@
19
19
  "errorCreatingModel%s%s": "Gagal membuat model '%s': %s",
20
20
  "modelDropped%s": "Model '%s' sukses dihapus",
21
21
  "memoryDbSkipped%s%s": "Db '%s' untuk '%s' adalah database memori, lewati",
22
- "modelBuiltOnthefly%s%s%s": "[%s] Model '%s@%s' sukses dibuat ulang on the fly",
22
+ "modelBuiltOnthefly%s%s%s": "Model '%s@%s' sukses dibuat ulang on the fly",
23
23
  "unableToBuildModel%s%s%s": "Gagal membuat ulang model '%s' di '%s': %s",
24
24
  "unknownSchema%s": "Skema '%s' tidak dikenal",
25
25
  "payloadMustBeJson": "Data harus berupa obyek JSON yang valid",
@@ -183,7 +183,7 @@
183
183
  "validation": {
184
184
  "any": {
185
185
  "required": "Harus diisi/dipilih",
186
- "only": "Harus sesuai dengan {{ref}}"
186
+ "only": "Harus sesuai dengan %(ref)s"
187
187
  },
188
188
  "string": {
189
189
  "alphanum": "Harus berupa alfa numerik karakter saja",
@@ -198,14 +198,14 @@
198
198
  "hex": "Harus mengandung hexadesimal karakter yang valid saja",
199
199
  "hexAlign": "Representasi hex yang terdekode harus byte aligned",
200
200
  "hostname": "Harus berupa nama host yang valid",
201
- "ip": "Harus berupa alamat ip yang valid dengan CIDR {{cidr}}",
202
- "ipVersion": "Harus berupa alamat ip yang valid dengan versi {{version}} dan CIDR {{cidr}}",
201
+ "ip": "Harus berupa alamat ip yang valid dengan CIDR %(cidr)s",
202
+ "ipVersion": "Harus berupa alamat ip yang valid dengan versi %(version)s dan CIDR %(cidr)s",
203
203
  "isoDate": "Harus dalam format ISO",
204
204
  "isoDuration": "Harus berupa durasi ISO 8601 yang valid",
205
- "length": "Panjang harus pas {{limit}} karakter",
205
+ "length": "Panjang harus pas %(limit)s karakter",
206
206
  "lowercase": "Hanya boleh mengandung huruf kecil saja",
207
- "max": "Panjang karakter harus lebih kecil atau sama dengan {{limit}} karakter",
208
- "min": "Panjang karakter harus setidaknya {{limit}} karakter",
207
+ "max": "Panjang karakter harus lebih kecil atau sama dengan %(limit)s karakter",
208
+ "min": "Panjang karakter harus setidaknya %(limit)s karakter",
209
209
  "token": "Hanya boleh terdiri atas karakter alfanumerik dan garis bawah saja",
210
210
  "trim": "Tidak boleh memiliki spasi didepan atau dibelakang",
211
211
  "uri": "Harus berupa URI yang valid",
@@ -213,17 +213,17 @@
213
213
  },
214
214
  "number": {
215
215
  "base": "Harus berupa angka",
216
- "greater": "Harus lebih besar dari {{limit}}",
216
+ "greater": "Harus lebih besar dari %(limit)s",
217
217
  "infinity": "Tidak bisa tak terbatas",
218
218
  "integer": "Harus berupa integer",
219
- "less": "Harus lebih kecil dari {{limit}}",
220
- "max": "Harus lebih kecil atau sama dengan {{limit}}",
221
- "min": "Harus lebih besar atau sama dengan {{limit}}",
222
- "multiple": "Harus kelipatan dari {{multiple}}",
219
+ "less": "Harus lebih kecil dari %(limit)s",
220
+ "max": "Harus lebih kecil atau sama dengan %(limit)s",
221
+ "min": "Harus lebih besar atau sama dengan %(limit)s",
222
+ "multiple": "Harus kelipatan dari %(multiple)s",
223
223
  "negative": "Harus berupa angka negatif",
224
224
  "port": "Harus berupa nomor port yang valid",
225
225
  "positive": "Harus berupa angka positif",
226
- "precision": "Harus memiliki tidak lebih dari {{limit}} tempat desimal",
226
+ "precision": "Harus memiliki tidak lebih dari %(limit)s tempat desimal",
227
227
  "unsafe": "Harus berupa nomor yang aman"
228
228
  }
229
229
  }
@@ -1,17 +1,20 @@
1
1
  import path from 'path'
2
2
 
3
- async function copyUploaded (name, id, { req, setField, setFile, mimeType, stats, silent = true } = {}) {
3
+ async function copyUploaded (name, id, options = {}) {
4
4
  const { fs } = this.app.bajo.lib
5
+ const { omit } = this.app.bajo.lib._
6
+ console.log(omit(options, ['req']))
7
+ const { req, setField, setFile, mimeType, stats, silent = true } = options
5
8
  name = this.attachmentPreCheck(name)
6
9
  if (!name) {
7
10
  if (silent) return
8
11
  throw this.error('isMissing%s', this.print.write('field.name'))
9
12
  }
10
- if (!this.bajoWeb) {
13
+ if (!this.app.waibu) {
11
14
  if (silent) return
12
- throw this.error('missingPlugin%s')
15
+ throw this.error('missingPlugin%s', 'Waibu')
13
16
  }
14
- const { dir, files } = await this.bajoWeb.getUploadedFiles(req.id, false, true)
17
+ const { dir, files } = await this.app.waibu.getUploadedFiles(req.id, false, true)
15
18
  const result = []
16
19
  if (files.length === 0) return result
17
20
  for (const f of files) {
@@ -20,6 +23,7 @@ async function copyUploaded (name, id, { req, setField, setFile, mimeType, stats
20
23
  field = setField ?? field
21
24
  const file = setFile ?? parts.join('@')
22
25
  const opts = { source: f, field, file, mimeType, stats, req }
26
+ console.log(setField, setFile, omit(opts, ['req']))
23
27
  const rec = await this.attachmentCreate(name, id, opts)
24
28
  delete rec.dir
25
29
  result.push(rec)
@@ -4,8 +4,9 @@ async function clear (name, opts = {}) {
4
4
  const { runHook } = this.app.bajo
5
5
  await this.modelExists(name, true)
6
6
  const { cloneDeep, camelCase, omit } = this.app.bajo.lib._
7
- const options = cloneDeep(omit(opts, ['req']))
7
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
8
8
  options.req = opts.req
9
+ options.reply = opts.reply
9
10
  const { noHook } = options
10
11
  const { handler, schema, driver } = await resolveMethod.call(this, name, 'record-clear', options)
11
12
  if (!noHook) {
@@ -4,8 +4,9 @@ async function count (name, filter = {}, opts = {}) {
4
4
  const { runHook } = this.app.bajo
5
5
  const { get, set } = this.cache ?? {}
6
6
  const { cloneDeep, camelCase, omit } = this.app.bajo.lib._
7
- const options = cloneDeep(omit(opts, ['req']))
7
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
8
8
  options.req = opts.req
9
+ options.reply = opts.reply
9
10
  options.dataOnly = options.dataOnly ?? true
10
11
  let { dataOnly, noHook, noCache } = options
11
12
  options.dataOnly = false
@@ -9,8 +9,9 @@ async function create (name, input, opts = {}) {
9
9
  const { generateId, runHook, isSet } = this.app.bajo
10
10
  const { clearModel } = this.cache ?? {}
11
11
  const { find, forOwn, cloneDeep, camelCase, omit, get, pick } = this.app.bajo.lib._
12
- const options = cloneDeep(omit(opts, ['req']))
12
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
13
13
  options.req = opts.req
14
+ options.reply = opts.reply
14
15
  options.dataOnly = options.dataOnly ?? true
15
16
  input = cloneDeep(input)
16
17
  const { fields, dataOnly, noHook, noValidation, noCheckUnique, noFeatureHook, noResult, noSanitize, hidden, forceNoHidden } = options
@@ -5,8 +5,9 @@ async function findOne (name, filter = {}, opts = {}) {
5
5
  const { runHook, isSet } = this.app.bajo
6
6
  const { get, set } = this.cache ?? {}
7
7
  const { cloneDeep, camelCase, omit } = this.app.bajo.lib._
8
- const options = cloneDeep(omit(opts, ['req']))
8
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
9
9
  options.req = opts.req
10
+ options.reply = opts.reply
10
11
  options.dataOnly = options.dataOnly ?? true
11
12
  let { fields, dataOnly, noHook, noCache, hidden, forceNoHidden } = options
12
13
  options.count = false
@@ -5,8 +5,9 @@ async function find (name, filter = {}, opts = {}) {
5
5
  const { runHook, isSet } = this.app.bajo
6
6
  const { get, set } = this.cache ?? {}
7
7
  const { cloneDeep, camelCase, omit } = this.app.bajo.lib._
8
- const options = cloneDeep(omit(opts, ['req']))
8
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
9
9
  options.req = opts.req
10
+ options.reply = opts.reply
10
11
  options.dataOnly = options.dataOnly ?? true
11
12
  let { fields, dataOnly, noHook, noCache, hidden, forceNoHidden } = options
12
13
  options.count = options.count ?? false
@@ -5,8 +5,9 @@ async function get (name, id, opts = {}) {
5
5
  const { runHook, isSet } = this.app.bajo
6
6
  const { get, set } = this.cache ?? {}
7
7
  const { cloneDeep, camelCase, omit } = this.app.bajo.lib._
8
- const options = cloneDeep(omit(opts, ['req']))
8
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
9
9
  options.req = opts.req
10
+ options.reply = opts.reply
10
11
  options.dataOnly = options.dataOnly ?? true
11
12
  let { fields, dataOnly, noHook, noCache, hidden = [], forceNoHidden } = options
12
13
  await this.modelExists(name, true)
@@ -5,8 +5,9 @@ async function remove (name, id, opts = {}) {
5
5
  const { runHook } = this.app.bajo
6
6
  const { clearModel } = this.cache ?? {}
7
7
  const { cloneDeep, camelCase, omit } = this.app.bajo.lib._
8
- const options = cloneDeep(omit(opts, ['req']))
8
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
9
9
  options.req = opts.req
10
+ options.reply = opts.reply
10
11
  options.dataOnly = options.dataOnly ?? true
11
12
  const { fields, dataOnly, noHook, noResult, hidden, forceNoHidden } = options
12
13
  options.dataOnly = false
@@ -8,8 +8,9 @@ async function update (name, id, input, opts = {}) {
8
8
  const { runHook, isSet } = this.app.bajo
9
9
  const { clearModel } = this.cache ?? {}
10
10
  const { forOwn, find, cloneDeep, camelCase, omit, get } = this.app.bajo.lib._
11
- const options = cloneDeep(omit(opts, ['req']))
11
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
12
12
  options.req = opts.req
13
+ options.reply = opts.reply
13
14
  options.dataOnly = options.dataOnly ?? true
14
15
  input = cloneDeep(input)
15
16
  const { fields, dataOnly, noHook, noValidation, noCheckUnique, noFeatureHook, noResult, noSanitize, partial = true, hidden, forceNoHidden } = options
@@ -2,8 +2,9 @@ async function upsert (name, input, opts = {}) {
2
2
  const { generateId } = this.app.bajo
3
3
  const { find } = this.app.bajo.lib._
4
4
  const { cloneDeep, omit } = this.app.bajo.lib._
5
- const options = cloneDeep(omit(opts, ['req']))
5
+ const options = cloneDeep(omit(opts, ['req', 'reply']))
6
6
  options.req = opts.req
7
+ options.reply = opts.reply
7
8
  options.dataOnly = options.dataOnly ?? true
8
9
  await this.modelExists(name, true)
9
10
  const { schema } = this.getInfo(name)
@@ -2,8 +2,8 @@ async function mergeAttachmentInfo (rec, source, { mimeType, stats, fullPath })
2
2
  const { importPkg } = this.app.bajo
3
3
  const { fs } = this.app.bajo.lib
4
4
  const { pick } = this.app.bajo.lib._
5
- if (!this.bajoWeb) return
6
- const mime = await importPkg('bajoWeb:mime')
5
+ if (!this.app.waibu) return
6
+ const mime = await importPkg('waibu:mime')
7
7
 
8
8
  if (mimeType) rec.mimeType = mime.getType(rec.file)
9
9
  if (fullPath) rec.fullPath = source
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dobo",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Database ORM/ODM for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,16 @@
1
+ import path from 'path'
2
+
3
+ async function attachment (req, reply) {
4
+ const { importPkg, getPluginDataDir, pascalCase } = this.app.bajo
5
+ const mime = await importPkg('waibu:mime')
6
+ const { fs } = this.app.bajo.lib
7
+ const file = `${getPluginDataDir('dobo')}/attachment/${pascalCase(req.params.model)}/${req.params.id}/${req.params.field}/${req.params.file}`
8
+ if (!fs.existsSync(file)) throw this.error('_notFound')
9
+ const mimeType = mime.getType(path.extname(file))
10
+ reply.header('Content-Type', mimeType)
11
+ const stream = fs.createReadStream(file)
12
+ reply.send(stream)
13
+ return reply
14
+ }
15
+
16
+ export default attachment