sumba 2.41.0 → 2.43.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.
@@ -254,11 +254,14 @@ async function hook () {
254
254
  level: 10,
255
255
  name: 'waibu:preParsing',
256
256
  handler: async function (req, reply) {
257
- const { getHostname } = this.app.waibu
257
+ const { get } = this.app.lib._
258
+ const { getHostname, checkRoute } = this.app.waibu
259
+ const { checkTheme, checkIconset } = this.app.waibuMpa
258
260
  req.site = await this.getSite(getHostname(req))
259
- await this.checkRoute(req)
260
- await this.checkTheme(req, reply) // TODO: only check if webApp support it
261
- await this.checkIconset(req, reply) // TODO: s.a.
261
+ await checkRoute(req)
262
+ if (get(req, 'routeOptions.config.webApp') !== 'waibuMpa') return
263
+ await checkTheme(req, reply)
264
+ await checkIconset(req, reply)
262
265
  }
263
266
  }, {
264
267
  name: 'waibu:beforeStart',
@@ -276,6 +279,21 @@ async function hook () {
276
279
  } catch (err) {
277
280
  }
278
281
  }
282
+ }, {
283
+ level: 1000,
284
+ name: 'waibuMpa:afterBuildLocals',
285
+ handler: async function (locals, req, opts = {}) {
286
+ const { normalizeMenuItems } = this.app.waibuMpa
287
+ const { pullAt } = this.app.lib._
288
+ locals.sidebar = await normalizeMenuItems(locals.sidebar, req)
289
+ const deleted = []
290
+ for (const [index, menu] of locals.menu.pages.entries()) {
291
+ if (!menu.children) continue
292
+ menu.children = await normalizeMenuItems(menu.children, req)
293
+ if (menu.children.length === 0) deleted.push(index)
294
+ }
295
+ pullAt(locals.menu.pages, deleted)
296
+ }
279
297
  }]
280
298
  }
281
299
 
@@ -54,6 +54,10 @@
54
54
  "type": "string",
55
55
  "maxLength": 50,
56
56
  "required": true
57
+ }, {
58
+ "name": "subTitle",
59
+ "type": "string",
60
+ "maxLength": 50
57
61
  }, {
58
62
  "name": "orgName",
59
63
  "type": "string",
@@ -4,7 +4,7 @@ async function site (req = {}) {
4
4
  attachment: true,
5
5
  layout: [
6
6
  { name: 'meta', fields: ['id', 'createdAt', 'updatedAt'] },
7
- { name: 'general', fields: ['hostname', 'alias', 'title', 'orgName', 'email', 'status:4-md 6-sm'] },
7
+ { name: 'general', fields: ['hostname:3-md', 'alias:3-md', 'email:3-md', 'status:3-md', 'orgName:4-md', 'title:4-md', 'subTitle:4-md'] },
8
8
  { name: 'personInCharge', fields: ['picName:3-md 6-sm:Name', 'picRole:3-md 6-sm:Role', 'picPhone:3-md 6-sm:Phone', 'picEmail:3-md 6-sm:Email'] },
9
9
  { name: 'address', fields: ['address1:12', 'address2:12', 'city:6-md 8-sm', 'zipCode:2-md 4-sm', 'provinceState:4-md', 'country:6-md', 'phone:6-md', 'website:12'] },
10
10
  { name: 'socialMedia', fields: ['socX:3-md 6-sm', 'socInstagram:3-md 6-sm', 'socFacebook:3-md 6-sm', 'socLinkedIn:3-md 6-sm'] }
package/index.js CHANGED
@@ -870,59 +870,6 @@ async function factory (pkgName) {
870
870
  return asValue ? values.map(item => ({ value: item, text: item })) : values
871
871
  }
872
872
 
873
- /**
874
- * Gather all paths to check for a request
875
- * @method
876
- * @param {Object} req - The request object
877
- * @returns {Array} - An array of paths to check
878
- */
879
- pathsToCheck = (req) => {
880
- const { isSet } = this.app.lib.aneka
881
- const { uniq, without } = this.app.lib._
882
- const items = [req.routeOptions.url, req.url].filter(url => isSet(url)).map(url => url.split('?')[0].split('#')[0])
883
- return uniq(without(items, undefined, null))
884
- }
885
-
886
- /**
887
- * Check and set the iconset for a request
888
- * @async
889
- * @method
890
- * @param {Object} req - The request object
891
- * @param {Object} reply - The reply object
892
- * @returns {Promise<void>} A promise that resolves when the iconset is checked and set
893
- */
894
- checkIconset = async (req, reply) => {
895
- const { get, isString } = this.app.lib._
896
- const mpa = this.app.waibuMpa
897
-
898
- if (!req.site) return
899
- const siteIconset = get(req, 'site.setting.waibuMpa.iconset')
900
- req.iconset = siteIconset ?? get(mpa, 'config.iconset.set', 'default')
901
- const hiconset = req.headers['x-iconset']
902
- if (isString(hiconset) && mpa.getIconset(hiconset)) req.iconset = hiconset
903
- req.iconset = req.iconset ?? 'default'
904
- }
905
-
906
- /**
907
- * Check and set the theme for a request
908
- * @async
909
- * @method
910
- * @param {Object} req - The request object
911
- * @param {Object} reply - The reply object
912
- * @returns {Promise<void>} A promise that resolves when the theme is checked and set
913
- */
914
- checkTheme = async (req, reply) => {
915
- const { get, isString } = this.app.lib._
916
- const mpa = this.app.waibuMpa
917
-
918
- if (!req.site) return
919
- const siteTheme = get(req, 'site.setting.waibuMpa.theme')
920
- req.theme = siteTheme ?? get(mpa, 'config.theme.set', 'default')
921
- const htheme = req.headers['x-theme']
922
- if (isString(htheme) && mpa.getTheme(htheme)) req.theme = htheme
923
- req.theme = req.theme ?? 'default'
924
- }
925
-
926
873
  /**
927
874
  * Check and set the team for a request
928
875
  * @async
@@ -934,6 +881,7 @@ async function factory (pkgName) {
934
881
  checkTeam = async (req, reply) => {
935
882
  const { includes } = this.app.lib.aneka
936
883
  const { outmatch } = this.app.lib
884
+ const { pathsToCheck } = this.app.waibu
937
885
 
938
886
  if (req.user.isAdmin) return
939
887
  if (req.routeOptions.config.xSite && req.user.isXSiteAdmin) return
@@ -941,7 +889,7 @@ async function factory (pkgName) {
941
889
  const teamIds = req.user.teams.map(item => item.id + '')
942
890
  // if (req.user.teams.map(item => item.alias).length === 0) throw this.error('accessDenied', { statusCode: 403 })
943
891
 
944
- const paths = this.pathsToCheck(req)
892
+ const paths = pathsToCheck(req)
945
893
  const results = (await this.getSecureGuards()).filter(item => {
946
894
  if (item.siteId !== req.site.id + '' || item.path[0] === '!') return false
947
895
  return paths.some(outmatch([item.path]))
@@ -964,7 +912,7 @@ async function factory (pkgName) {
964
912
  */
965
913
  checkUser = async (req, reply, source) => {
966
914
  const { merge, isEmpty, camelCase, get } = this.app.lib._
967
- const { routePath } = this.app.waibu
915
+ const { routePath, pathsToCheck } = this.app.waibu
968
916
  const userId = get(req, 'session.userId')
969
917
  const setUser = async () => {
970
918
  if (!userId) return
@@ -987,7 +935,7 @@ async function factory (pkgName) {
987
935
  return
988
936
  }
989
937
 
990
- const paths = this.pathsToCheck(req)
938
+ const paths = pathsToCheck(req)
991
939
  let guards = (await this.getAnonymousGuards()).filter(item => item.siteId === req.site.id + '')
992
940
  const anonymous = this.checkRouteGuard(guards, paths)
993
941
  if (anonymous) {
@@ -1038,23 +986,6 @@ async function factory (pkgName) {
1038
986
  if (!get(req, 'user.isXSiteAdmin')) throw this.error('accessDenied', { statusCode: 403 })
1039
987
  }
1040
988
 
1041
- /**
1042
- * Check the route for a request
1043
- * @async
1044
- * @method
1045
- * @param {Object} req - The request object
1046
- * @returns {Promise<void>} A promise that resolves when the route is checked
1047
- */
1048
- checkRoute = async (req) => {
1049
- const { routePath } = this.app.waibu
1050
- const { outmatch } = this.app.lib
1051
- const routes = req.getSetting('waibu:route.disabled', []).map(item => routePath(item, false))
1052
- if (routes.length === 0) return
1053
- const isMatch = outmatch(routes)
1054
- const paths = this.pathsToCheck(req)
1055
- if (paths.find(isMatch)) throw this.error('_notFound')
1056
- }
1057
-
1058
989
  /**
1059
990
  * Parse namespace settings for a request
1060
991
  * @method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumba",
3
- "version": "2.41.0",
3
+ "version": "2.43.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,15 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-08-05
4
+
5
+ - [2.43.0] Add `subTitle` field on `SumbaSite` model
6
+
7
+ ## 2026-08-01
8
+
9
+ - [2.42.0] Remove `checkTheme()` and `checkIconset()` and move to `waibu-mpa`
10
+ - [2.42.0] Remove `pathsToCheck()` and `checkRoute()` and move to `waibu`
11
+ - [2.42.0] Update `hook.js`
12
+
3
13
  ## 2026-07-29
4
14
 
5
15
  - [2.41.0] Add `bajo` namespace to `getSite`