openxiangda 1.0.9 → 1.0.10

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.
package/lib/cli.js CHANGED
@@ -743,8 +743,10 @@ async function menu(args) {
743
743
  fail('用法: openxiangda menu create <menuCode> --name <text>');
744
744
  }
745
745
  const target = getWorkspaceTarget(config, profileName, flags);
746
+ const pageCode = flags['page-code'];
747
+ const pageEntry = pageCode ? findPageEntry(target.bound, entry => entry.pageCode === pageCode || entry.routeKey === pageCode) : undefined;
746
748
  const formUuid = flags['form-uuid'] || resolveOptionalFormUuid(target.bound, flags['form-code']);
747
- const pageId = flags['page-id'] || resolveOptionalPageId(target.bound, flags['page-code']);
749
+ const pageId = flags['page-id'] || resolveOptionalPageId(target.bound, pageCode);
748
750
  const data = await requestWithAuth(
749
751
  config,
750
752
  target.profileName,
@@ -767,6 +769,9 @@ async function menu(args) {
767
769
  type: flags.type || 'nav',
768
770
  ...(formUuid ? { formUuid } : {}),
769
771
  ...(pageId ? { pageId } : {}),
772
+ ...(pageCode ? { pageCode } : {}),
773
+ ...(pageEntry?.routeKey ? { routeKey: pageEntry.routeKey } : pageCode ? { routeKey: pageCode } : {}),
774
+ ...(pageEntry?.legacyFormUuid ? { legacyFormUuid: pageEntry.legacyFormUuid } : {}),
770
775
  });
771
776
  }
772
777
  if (flags.json) return writeJson(data);
@@ -1905,26 +1910,67 @@ function resolvePagePermissionMenuTargets(bound, flags = {}) {
1905
1910
  ...splitList(flags['menu-form-uuids']),
1906
1911
  ...splitList(flags['menu-ids']),
1907
1912
  ];
1908
- const fromMenuCodes = splitList(flags['menu-codes']).map(code => resolveMenuId(bound, code));
1913
+ const fromMenuCodes = splitList(flags['menu-codes']).flatMap(code => resolveMenuPermissionTargets(bound, code));
1909
1914
  const fromFormCodes = splitList(flags['form-codes']).map(code => resolveOptionalFormUuid(bound, code));
1910
- const fromPageCodes = splitList(flags['page-codes']).map(code => resolvePageMenuTarget(bound, code));
1915
+ const fromPageCodes = splitList(flags['page-codes']).flatMap(code => resolvePagePermissionTargets(bound, code));
1911
1916
  return unique([...direct, ...fromMenuCodes, ...fromFormCodes, ...fromPageCodes].filter(Boolean));
1912
1917
  }
1913
1918
 
1914
- function resolvePageMenuTarget(bound, pageCode) {
1919
+ function resolveMenuPermissionTargets(bound, menuCode) {
1920
+ const menuEntry = bound.resources?.menus?.[menuCode];
1921
+ const menuId = resolveMenuId(bound, menuCode);
1922
+ if (menuEntry?.formUuid) return [menuEntry.formUuid];
1923
+ if (menuEntry?.pageId || menuEntry?.pageCode || menuEntry?.routeKey || menuEntry?.legacyFormUuid) {
1924
+ return unique([menuId, ...resolveCodePagePermissionAliases(bound, menuEntry)]);
1925
+ }
1926
+ return [menuId];
1927
+ }
1928
+
1929
+ function resolvePagePermissionTargets(bound, pageCode) {
1915
1930
  const pageId = resolveOptionalPageId(bound, pageCode);
1916
1931
  const menuEntry = findMenuEntry(bound, entry => {
1917
1932
  if (!entry) return false;
1918
1933
  return entry.pageId === pageId || entry.pageCode === pageCode || entry.routeKey === pageCode;
1919
1934
  });
1920
- if (menuEntry?.menuId) return menuEntry.menuId;
1935
+ if (menuEntry?.menuId) {
1936
+ return unique([menuEntry.menuId, ...resolveCodePagePermissionAliases(bound, menuEntry, pageCode)]);
1937
+ }
1921
1938
  fail(`页面 ${pageCode} 未找到已绑定菜单。请先发布/创建菜单,或直接传 --menu-codes/--menu-ids。`);
1922
1939
  }
1923
1940
 
1941
+ function resolveCodePagePermissionAliases(bound, menuEntry = {}, pageCode) {
1942
+ const pageEntry = findPageEntry(bound, entry => {
1943
+ if (!entry) return false;
1944
+ return (
1945
+ entry.pageCode === pageCode ||
1946
+ entry.routeKey === pageCode ||
1947
+ entry.pageId === menuEntry.pageId ||
1948
+ entry.pageCode === menuEntry.pageCode ||
1949
+ entry.routeKey === menuEntry.routeKey ||
1950
+ entry.legacyFormUuid === menuEntry.legacyFormUuid
1951
+ );
1952
+ });
1953
+ return unique([
1954
+ pageCode,
1955
+ menuEntry.pageCode,
1956
+ menuEntry.routeKey,
1957
+ menuEntry.legacyFormUuid,
1958
+ pageEntry?.pageCode,
1959
+ pageEntry?.routeKey,
1960
+ pageEntry?.legacyFormUuid,
1961
+ ].filter(Boolean));
1962
+ }
1963
+
1924
1964
  function findMenuEntry(bound, predicate) {
1925
1965
  return Object.values(bound.resources?.menus || {}).find(predicate);
1926
1966
  }
1927
1967
 
1968
+ function findPageEntry(bound, predicate) {
1969
+ return Object.entries(bound.resources?.pages || {})
1970
+ .map(([pageCode, entry]) => ({ pageCode, ...(entry || {}) }))
1971
+ .find(predicate);
1972
+ }
1973
+
1928
1974
  function resolveSettingsFormUuid(bound, formKey, flags = {}) {
1929
1975
  const key = formKey || flags['form-code'] || flags['form-uuid'];
1930
1976
  if (!key && !flags['form-uuid']) {
@@ -369,11 +369,11 @@ Body:
369
369
  {
370
370
  "name": "销售可见页面",
371
371
  "roles": ["sales"],
372
- "menuFormUuids": ["FORM_XXX", "MENU_ID_FOR_CODE_PAGE"]
372
+ "menuFormUuids": ["FORM_XXX", "MENU_ID_FOR_CODE_PAGE", "CODE_PAGE_ROUTE_KEY", "PAGE_LEGACY_FORM_UUID"]
373
373
  }
374
374
  ```
375
375
 
376
- An empty `menuFormUuids` array means all menus/pages are visible to the matched roles. For form menus this field can contain form UUIDs; for custom code page menus use the actual menu ID returned by `/apps/:appType/menus`, not the code page `PAGE_...` legacy form UUID.
376
+ An empty `menuFormUuids` array means all menus/pages are visible to the matched roles. For form menus this field can contain form UUIDs. For custom code page menus, current platform runtimes may check different identifiers at different layers, so OpenXiangda CLI `--page-codes` / `--menu-codes` writes the actual menu ID, the code page route key, and the legacy `PAGE_...` form UUID alias.
377
377
 
378
378
  ### GET `/apps/:appType/page-permission-groups/:groupId`
379
379
 
@@ -24,7 +24,7 @@ Page permission groups map role codes to visible menu `formUuid` values:
24
24
  {
25
25
  "name": "销售页面",
26
26
  "roles": ["sales"],
27
- "menuFormUuids": ["FORM_CUSTOMER", "FORM_ORDER", "MENU_ID_FOR_CODE_PAGE"]
27
+ "menuFormUuids": ["FORM_CUSTOMER", "FORM_ORDER", "MENU_ID_FOR_CODE_PAGE", "CODE_PAGE_ROUTE_KEY", "PAGE_LEGACY_FORM_UUID"]
28
28
  }
29
29
  ```
30
30
 
@@ -33,7 +33,7 @@ Rules:
33
33
  - `roles: []` means all roles can match.
34
34
  - `menuFormUuids: []` means all menus/pages are visible to matched roles.
35
35
  - Prefer `--form-codes` in CLI for form menus so each profile resolves its own form UUIDs.
36
- - Prefer `--page-codes` or `--menu-codes` in CLI for custom code page menus so each profile resolves to real menu IDs.
36
+ - Prefer `--page-codes` or `--menu-codes` in CLI for custom code page menus. The CLI writes the menu ID plus the code page route key and legacy `PAGE_...` alias required by current `/view` and custom-page runtime permission checks.
37
37
 
38
38
  ## Form Permission Groups
39
39
 
@@ -43,7 +43,7 @@ openxiangda permission page-group-create sales_pages --name "销售页面" --rol
43
43
  openxiangda permission page-group-create portal_pages --name "门户页面" --page-codes portal_pc,portal_mobile --profile dev
44
44
  ```
45
45
 
46
- Use `--page-codes` or `--menu-codes` for custom code page menus; the CLI resolves code pages to their published menu IDs. Use `--form-codes` for form menus; the CLI resolves forms to profile-local form UUIDs. Empty target lists mean all menus/pages are visible to matched roles.
46
+ Use `--page-codes` or `--menu-codes` for custom code page menus; the CLI resolves code pages to the published menu ID plus the route key and legacy `PAGE_...` alias required by current runtime permission checks. Use `--form-codes` for form menus; the CLI resolves forms to profile-local form UUIDs. Empty target lists mean all menus/pages are visible to matched roles.
47
47
 
48
48
  ## Form Permission Groups
49
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openxiangda",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
5
5
  "private": false,
6
6
  "bin": {