openxiangda 1.0.96 → 1.0.98

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
@@ -3542,7 +3542,8 @@ async function resource(args) {
3542
3542
  return;
3543
3543
  }
3544
3544
 
3545
- const manifest = loadWorkspaceResources();
3545
+ const typeFilters = getResourceTypeFilters(positional, flags);
3546
+ const manifest = loadWorkspaceResources({ typeFilters });
3546
3547
  if (subcommand === 'typegen') {
3547
3548
  const result = generateResourceTypes(manifest, flags.out || flags.output);
3548
3549
  if (flags.json) return writeJson(result);
@@ -4073,7 +4074,7 @@ async function commands(args) {
4073
4074
  resourceNotes: [
4074
4075
  'For formal multi-resource development, prefer src/resources/** + openxiangda resource validate|plan|publish.',
4075
4076
  'Use first-class route/public-access/auth-config/function/connector/notification/data-view/menu/permission commands for discovery, diagnosis, dry-run, and small live fixes.',
4076
- 'public-access is the new React SPA public policy resource for /view/:appType/public/* routes.',
4077
+ 'public-access is the new React SPA public policy resource for /view/:appType/public/* routes; page code should use PublicAccessGate, and Page SDK hooks must stay inside OpenXiangdaProvider + OpenXiangdaPageProvider.',
4077
4078
  'settings public-access is legacy form public-access compatibility/repair and should not be used for new React SPA apps.',
4078
4079
  'Direct live mutation commands should use --dry-run first and --write-manifest when the repository should remain source of truth.',
4079
4080
  ],
@@ -4958,11 +4959,108 @@ const RESOURCE_SPECS = [
4958
4959
  },
4959
4960
  ];
4960
4961
 
4961
- function loadWorkspaceResources() {
4962
+ const RESOURCE_TYPE_ALIASES = new Map([
4963
+ ['role', 'roles'],
4964
+ ['roles', 'roles'],
4965
+ ['connector', 'connectors'],
4966
+ ['connectors', 'connectors'],
4967
+ ['notification', 'notifications'],
4968
+ ['notifications', 'notifications'],
4969
+ ['notification-template', 'notifications'],
4970
+ ['notification-templates', 'notifications'],
4971
+ ['notification-type-config', 'notifications'],
4972
+ ['notification-type-configs', 'notifications'],
4973
+ ['menu', 'menus'],
4974
+ ['menus', 'menus'],
4975
+ ['workflow', 'workflows'],
4976
+ ['workflows', 'workflows'],
4977
+ ['automation', 'automations'],
4978
+ ['automations', 'automations'],
4979
+ ['function', 'functions'],
4980
+ ['functions', 'functions'],
4981
+ ['data-view', 'dataViews'],
4982
+ ['data-views', 'dataViews'],
4983
+ ['dataview', 'dataViews'],
4984
+ ['dataviews', 'dataViews'],
4985
+ ['data-view-resource', 'dataViews'],
4986
+ ['auth', 'authConfigs'],
4987
+ ['auth-config', 'authConfigs'],
4988
+ ['auth-configs', 'authConfigs'],
4989
+ ['authconfig', 'authConfigs'],
4990
+ ['authconfigs', 'authConfigs'],
4991
+ ['route', 'routes'],
4992
+ ['routes', 'routes'],
4993
+ ['public-access', 'publicAccessPolicies'],
4994
+ ['public-access-policy', 'publicAccessPolicies'],
4995
+ ['public-access-policies', 'publicAccessPolicies'],
4996
+ ['publicaccess', 'publicAccessPolicies'],
4997
+ ['publicaccesspolicy', 'publicAccessPolicies'],
4998
+ ['publicaccesspolicies', 'publicAccessPolicies'],
4999
+ ['page-permission-group', 'pagePermissionGroups'],
5000
+ ['page-permission-groups', 'pagePermissionGroups'],
5001
+ ['page-group', 'pagePermissionGroups'],
5002
+ ['page-groups', 'pagePermissionGroups'],
5003
+ ['pagepermissiongroup', 'pagePermissionGroups'],
5004
+ ['pagepermissiongroups', 'pagePermissionGroups'],
5005
+ ['form-permission-group', 'formPermissionGroups'],
5006
+ ['form-permission-groups', 'formPermissionGroups'],
5007
+ ['form-group', 'formPermissionGroups'],
5008
+ ['form-groups', 'formPermissionGroups'],
5009
+ ['formpermissiongroup', 'formPermissionGroups'],
5010
+ ['formpermissiongroups', 'formPermissionGroups'],
5011
+ ['form-setting', 'formSettings'],
5012
+ ['form-settings', 'formSettings'],
5013
+ ['settings-form', 'formSettings'],
5014
+ ['settings-forms', 'formSettings'],
5015
+ ['formsetting', 'formSettings'],
5016
+ ['formsettings', 'formSettings'],
5017
+ ]);
5018
+
5019
+ function getResourceTypeFilters(positional = [], flags = {}) {
5020
+ const rawValues = [
5021
+ ...positional,
5022
+ flags.type,
5023
+ flags['resource-type'],
5024
+ flags['resource-types'],
5025
+ ]
5026
+ .filter(Boolean)
5027
+ .flatMap(value => String(value).split(','))
5028
+ .map(value => value.trim())
5029
+ .filter(Boolean);
5030
+
5031
+ if (rawValues.length === 0) return null;
5032
+
5033
+ const filters = new Set();
5034
+ for (const rawType of rawValues) {
5035
+ const normalized = normalizeResourceTypeAlias(rawType);
5036
+ const key = RESOURCE_TYPE_ALIASES.get(normalized);
5037
+ if (!key) {
5038
+ fail(`未知资源类型: ${rawType}`);
5039
+ }
5040
+ filters.add(key);
5041
+ }
5042
+ return filters;
5043
+ }
5044
+
5045
+ function normalizeResourceTypeAlias(value) {
5046
+ return String(value || '')
5047
+ .trim()
5048
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
5049
+ .replace(/[_\s]+/g, '-')
5050
+ .toLowerCase();
5051
+ }
5052
+
5053
+ function loadWorkspaceResources(options = {}) {
4962
5054
  const baseDir = path.join(process.cwd(), 'src', 'resources');
4963
- const manifest = { baseDir };
5055
+ const typeFilters = options.typeFilters || null;
5056
+ const manifest = {
5057
+ baseDir,
5058
+ ...(typeFilters ? { resourceTypeFilters: Array.from(typeFilters).sort() } : {}),
5059
+ };
4964
5060
  for (const spec of RESOURCE_SPECS) {
4965
- manifest[spec.key] = readResourceItems(baseDir, spec);
5061
+ manifest[spec.key] = !typeFilters || typeFilters.has(spec.key)
5062
+ ? readResourceItems(baseDir, spec)
5063
+ : [];
4966
5064
  }
4967
5065
  return manifest;
4968
5066
  }
@@ -5733,6 +5831,7 @@ async function buildResourcePlan(config, target, manifest) {
5733
5831
  return {
5734
5832
  appType: target.appType,
5735
5833
  profile: target.profileName,
5834
+ ...(manifest.resourceTypeFilters ? { resourceTypeFilters: manifest.resourceTypeFilters } : {}),
5736
5835
  actions,
5737
5836
  summary: summarizeActions(actions),
5738
5837
  };
@@ -5742,6 +5841,7 @@ async function publishResourceManifest(config, target, manifest, options = {}) {
5742
5841
  const result = {
5743
5842
  appType: target.appType,
5744
5843
  profile: target.profileName,
5844
+ ...(manifest.resourceTypeFilters ? { resourceTypeFilters: manifest.resourceTypeFilters } : {}),
5745
5845
  published: [],
5746
5846
  pruned: [],
5747
5847
  warnings: [],
@@ -95,7 +95,7 @@ const DESIGN_GATE_TOPICS = [
95
95
  '是否需要限流、过期时间、审计字段和回收策略',
96
96
  ],
97
97
  recommendedDefaults: [
98
- '新 React SPA 仅使用 /view/:appType/public/* + routes + public-access policy',
98
+ '新 React SPA 仅使用 /view/:appType/public/* + routes + public-access policy + PublicAccessGate',
99
99
  '普通公开页用 scoped public session;敏感页用 ticket 模式',
100
100
  '未显式 grant 的 form/dataView/function/connector 一律拒绝',
101
101
  ],
@@ -357,7 +357,7 @@ function renderDesignTemplate(topicCode) {
357
357
  '## 2. 推荐方案',
358
358
  '- Runtime:React SPA',
359
359
  '- 资源发布:src/resources/** + openxiangda resource plan/publish',
360
- '- 公开访问:仅使用 /view/:appType/public/* + routes + public-access policy',
360
+ '- 公开访问:仅使用 /view/:appType/public/* + routes + public-access policy + PublicAccessGate',
361
361
  '',
362
362
  '## 3. 待确认问题',
363
363
  ];
@@ -422,6 +422,7 @@ const RESOURCE_EXPLAINS = {
422
422
  'openxiangda public-access upsert --json-file src/resources/public-access/public_register.json',
423
423
  'openxiangda public-access session-test public_register --path /view/APP_XXX/public/register',
424
424
  'openxiangda public-access grant-check public_register --form-code customer',
425
+ 'React 页面侧使用 PublicAccessGate;如果使用 Page SDK hooks,放在 OpenXiangdaProvider + OpenXiangdaPageProvider 内',
425
426
  ],
426
427
  },
427
428
  'auth-config': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openxiangda",
3
- "version": "1.0.96",
3
+ "version": "1.0.98",
4
4
  "description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
5
5
  "private": false,
6
6
  "bin": {