bajo-spatial 2.0.1 → 2.2.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.
Files changed (47) hide show
  1. package/.github/FUNDING.yml +0 -0
  2. package/.github/workflows/repo-lockdown.yml +0 -0
  3. package/.jsdoc.conf.json +0 -0
  4. package/LICENSE +0 -0
  5. package/README.md +0 -0
  6. package/docs/BajoSpatial.html +0 -0
  7. package/docs/data/search.json +0 -0
  8. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  9. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  10. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  11. package/docs/global.html +0 -0
  12. package/docs/index.html +0 -0
  13. package/docs/index.js.html +0 -0
  14. package/docs/scripts/core.js +476 -477
  15. package/docs/scripts/core.min.js +0 -0
  16. package/docs/scripts/resize.js +36 -36
  17. package/docs/scripts/search.js +105 -105
  18. package/docs/scripts/search.min.js +0 -0
  19. package/docs/scripts/third-party/Apache-License-2.0.txt +0 -0
  20. package/docs/scripts/third-party/fuse.js +1 -1
  21. package/docs/scripts/third-party/hljs-line-num-original.js +282 -285
  22. package/docs/scripts/third-party/hljs-line-num.js +1 -1
  23. package/docs/scripts/third-party/hljs-original.js +1195 -1202
  24. package/docs/scripts/third-party/hljs.js +1 -1
  25. package/docs/scripts/third-party/popper.js +1 -1
  26. package/docs/scripts/third-party/tippy.js +1 -1
  27. package/docs/scripts/third-party/tocbot.js +508 -509
  28. package/docs/scripts/third-party/tocbot.min.js +0 -0
  29. package/docs/static/bitcoin.jpeg +0 -0
  30. package/docs/static/home.md +0 -0
  31. package/docs/static/logo-ecosystem.png +0 -0
  32. package/docs/static/logo.png +0 -0
  33. package/docs/styles/clean-jsdoc-theme-base.css +0 -0
  34. package/docs/styles/clean-jsdoc-theme-dark.css +0 -0
  35. package/docs/styles/clean-jsdoc-theme-light.css +0 -0
  36. package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -0
  37. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
  38. package/docs/styles/clean-jsdoc-theme.min.css +0 -0
  39. package/extend/bajo/hook/dobo@before-find-record.js +10 -0
  40. package/extend/waibuStatic/virtual.json +0 -0
  41. package/index.js +13 -13
  42. package/package.json +4 -3
  43. package/wiki/CHANGES.md +5 -0
  44. package/wiki/CONFIG.md +0 -0
  45. package/wiki/CONTRIBUTING.md +0 -0
  46. package/wiki/toc.json +0 -0
  47. package/extend/bajo/hook/dobo@before-record-find.js +0 -11
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ const beforeFindRecord = {
2
+ level: 1001,
3
+ handler: async function (modelName, filter, options) {
4
+ if (!filter.bbox || !this.app.dobo) return
5
+ const model = this.app.dobo.getModel(modelName)
6
+ filter.query = await this.buildBboxQuery({ bbox: filter.bbox, query: filter.query, model, options })
7
+ }
8
+ }
9
+
10
+ export default beforeFindRecord
File without changes
package/index.js CHANGED
@@ -1,5 +1,3 @@
1
- import anekaSpatial from 'aneka-spatial/index.js'
2
-
3
1
  /**
4
2
  * Plugin factory
5
3
  *
@@ -14,18 +12,15 @@ async function factory (pkgName) {
14
12
  *
15
13
  * @class
16
14
  */
17
- class BajoSpatial extends this.app.pluginClass.base {
18
- static alias = 'spatial'
19
-
15
+ class BajoSpatial extends this.app.baseClass.Base {
20
16
  constructor () {
21
17
  super(pkgName, me.app)
22
18
  this.config = {}
23
- this.app.lib.anekaSpatial = anekaSpatial
24
19
  }
25
20
 
26
- buildBboxQuery = async ({ bbox, query, schema, options = {} } = {}) => {
21
+ buildBboxQuery = async ({ bbox, query = {}, model, options = {} } = {}) => {
27
22
  const { merge, isEmpty } = this.app.lib._
28
- const props = schema.properties.map(item => item.name)
23
+ const props = model.properties.map(item => item.name)
29
24
  const { bboxLatField = 'lat', bboxLngField = 'lng' } = options
30
25
  if (props.includes(bboxLatField) && props.includes(bboxLngField)) {
31
26
  const [minx, miny, maxx, maxy] = await this.parseBbox(bbox)
@@ -34,9 +29,14 @@ async function factory (pkgName) {
34
29
  q[bboxLatField] = { $gte: miny, $lte: maxy }
35
30
  if (isEmpty(query)) query = q
36
31
  else {
37
- const $or = query.$or
38
- if ($or) query = merge(q, { $or })
39
- else merge(query, q)
32
+ if (query.$and) {
33
+ query.$and.push(q)
34
+ } else if (query.$or) {
35
+ const old = query.$or
36
+ query = { $and: [old, q] }
37
+ } else {
38
+ merge(query, q)
39
+ }
40
40
  }
41
41
  }
42
42
  return query
@@ -46,8 +46,8 @@ async function factory (pkgName) {
46
46
  item = item + ''
47
47
  if (item.includes(',')) return
48
48
  if (!this.app.bajoCommonDb || !this.app.dobo) return
49
- const { recordGet } = this.app.dobo
50
- const country = await recordGet('CdbCountry', item, { thrownNotFound: false })
49
+ const model = this.app.dobo.getModel('CdbCountry')
50
+ const country = await model.getRecord(item, { throwNotFound: false })
51
51
  if (country) return country.bbox
52
52
  throw this.error('Invalid country bbox \'%s\'', item, { statusCode: 400 })
53
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo-spatial",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "Spatial functions for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "type": "module",
11
11
  "bajo": {
12
- "type": "plugin"
12
+ "type": "plugin",
13
+ "alias": "spatial"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
@@ -28,7 +29,7 @@
28
29
  },
29
30
  "homepage": "https://github.com/ardhi/bajo-spatial#readme",
30
31
  "dependencies": {
31
- "@turf/turf": "^7.2.0",
32
+ "@turf/turf": "^7.3.1",
32
33
  "aneka-spatial": "^0.0.4",
33
34
  "geolib": "^3.3.4"
34
35
  },
@@ -0,0 +1,5 @@
1
+ # Changes
2
+
3
+ ## 2026-01-07
4
+
5
+ - [2.2.0] Ported to match ```bajo@2.2.x``` specs
package/wiki/CONFIG.md CHANGED
File without changes
File without changes
package/wiki/toc.json CHANGED
File without changes
@@ -1,11 +0,0 @@
1
- const beforeRecordFind = {
2
- level: 1001,
3
- handler: async function (name, filter, options) {
4
- if (!filter.bbox) return
5
- const { getSchema } = this.app.dobo
6
- const schema = getSchema(name)
7
- filter.query = await this.buildBboxQuery({ bbox: filter.bbox, query: filter.query, schema, options })
8
- }
9
- }
10
-
11
- export default beforeRecordFind