sumba 0.3.3 → 0.3.5

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,12 +1,12 @@
1
1
  const bajoDbOnBeforeRecordCreate = {
2
2
  level: 1000,
3
3
  handler: async function (coll, body, options) {
4
- const { importPkg } = this.bajo.helper
5
4
  const { get } = this.bajo.helper._
6
5
  const { hasColumn } = this.sumba.helper
7
- const item = { siteId: 'req.site.id', userId: 'req.user.id' }
6
+ if (options.noAutoFilter) return
7
+ const item = { siteId: 'site.id', userId: 'user.id' }
8
8
  for (const i in item) {
9
- const rec = get(options, item[i])
9
+ const rec = get(options.req, item[i])
10
10
  if (rec && await hasColumn(i, coll)) body[i] = rec
11
11
  }
12
12
  }
@@ -0,0 +1,8 @@
1
+ import { handler } from './bajoDb@on-before-record-find.js'
2
+
3
+ const bajoDbOnBeforeRecordFindOne = {
4
+ level: 1000,
5
+ handler
6
+ }
7
+
8
+ export default bajoDbOnBeforeRecordFindOne
@@ -1,23 +1,26 @@
1
- const bajoDbOnBeforeRecordFind = {
2
- level: 1000,
3
- handler: async function (coll, filter, options) {
4
- const { isSet } = this.bajo.helper
5
- const { isEmpty, cloneDeep, get, set } = this.bajo.helper._
6
- const { hasColumn } = this.sumba.helper
7
- const item = { siteId: 'req.site.id', userId: 'req.user.id' }
8
- for (const i in item) {
9
- const rec = get(options, item[i])
10
- if (isSet(rec) && await hasColumn(i, coll)) {
11
- filter.query = filter.query ?? {}
12
- const old = cloneDeep(filter.query.$or)
13
- if (old) {
14
- filter.query = { $and: [old] }
15
- filter.query.$and.push(set({}, i, rec))
16
- } else filter.query[i] = rec
17
- if (isEmpty(filter.query)) filter.query = undefined
18
- }
1
+ export async function handler (coll, filter, options) {
2
+ const { isSet } = this.bajo.helper
3
+ const { isEmpty, cloneDeep, get, set } = this.bajo.helper._
4
+ const { hasColumn } = this.sumba.helper
5
+ if (options.noAutoFilter) return
6
+ const item = { siteId: 'site.id', userId: 'user.id' }
7
+ for (const i in item) {
8
+ const rec = get(options.req, item[i])
9
+ if (isSet(rec) && await hasColumn(i, coll)) {
10
+ filter.query = filter.query ?? {}
11
+ const old = cloneDeep(filter.query.$or)
12
+ if (old) {
13
+ filter.query = { $and: [old] }
14
+ filter.query.$and.push(set({}, i, rec))
15
+ } else filter.query[i] = rec
16
+ if (isEmpty(filter.query)) filter.query = undefined
19
17
  }
20
18
  }
21
19
  }
22
20
 
21
+ const bajoDbOnBeforeRecordFind = {
22
+ level: 1000,
23
+ handler
24
+ }
25
+
23
26
  export default bajoDbOnBeforeRecordFind
@@ -1,11 +1,12 @@
1
- export async function checker (coll, id, req) {
1
+ export async function checker (coll, id, options) {
2
2
  const { error } = this.bajo.helper
3
3
  const { recordFind } = this.bajoDb.helper
4
4
  const { get } = this.bajo.helper._
5
5
  const { hasColumn } = this.sumba.helper
6
+ if (options.noAutoFilter) return
6
7
  const item = { siteId: 'site.id', userId: 'user.id' }
7
8
  for (const i in item) {
8
- const rec = get(req, item[i])
9
+ const rec = get(options.req, item[i])
9
10
  if (rec && await hasColumn(i, coll)) {
10
11
  const filter = { query: { id }, limit: 1 }
11
12
  filter.query[i] = rec
@@ -18,7 +19,7 @@ export async function checker (coll, id, req) {
18
19
  const bajoDbOnBeforeRecordGet = {
19
20
  level: 1000,
20
21
  handler: async function (coll, id, options) {
21
- await checker.call(this, coll, id, options.req)
22
+ await checker.call(this, coll, id, options)
22
23
  }
23
24
  }
24
25
 
@@ -3,7 +3,7 @@ import { checker } from './bajoDb@on-before-record-get.js'
3
3
  const bajoDbOnBeforeRecordUpdate = {
4
4
  level: 1000,
5
5
  handler: async function (coll, id, body, options) {
6
- await checker.call(this, coll, id, options.req)
6
+ await checker.call(this, coll, id, options)
7
7
  }
8
8
  }
9
9
 
package/bajo/init.js ADDED
@@ -0,0 +1,11 @@
1
+ async function init () {
2
+ /*
3
+ const { eachPlugins } = this.bajo.helper
4
+ const pattern = 'auto-detect.*'
5
+ await eachPlugins(async function ({ file, plugin, alias }) {
6
+ console.log(file, plugin, alias)
7
+ }, pattern)
8
+ */
9
+ }
10
+
11
+ export default init
@@ -51,6 +51,7 @@
51
51
  }]
52
52
  },
53
53
  "edit": {
54
+ "shown": ["password"],
54
55
  "layouts": [{
55
56
  "title": "Meta Info",
56
57
  "fields": [
@@ -65,6 +66,7 @@
65
66
  "fields": [
66
67
  "username;small:6,medium:6",
67
68
  "email;small:6,medium:6",
69
+ "password;small:12,medium:12",
68
70
  "firstName;small:6,medium:6",
69
71
  "lastName;small:6,medium:6"
70
72
  ]
@@ -1,7 +1,6 @@
1
1
  async function checker (req, container) {
2
- const { importPkg, getConfig } = this.bajo.helper
2
+ const { getConfig, outmatch } = this.bajo.helper
3
3
  const { get } = this.bajo.helper._
4
- const outmatch = await importPkg('outmatch')
5
4
  let match
6
5
  for (const item of container) {
7
6
  let path = item.path
@@ -2,7 +2,7 @@ const indexes = []
2
2
  const invIndexes = []
3
3
 
4
4
  async function collect (type, { file, plugin, dir }) {
5
- const { readConfig, importPkg } = this.bajo.helper
5
+ const { readConfig } = this.bajo.helper
6
6
  const { routeDir } = this.bajoWeb.helper
7
7
  const { trim } = this.bajo.helper._
8
8
  const { hash } = this.bajoExtra.helper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Bajo Framework's Biz Suite",
5
5
  "main": "index.js",
6
6
  "scripts": {