openxiangda 1.0.97 → 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.
Files changed (2) hide show
  1. package/lib/cli.js +104 -4
  2. package/package.json +1 -1
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);
@@ -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: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openxiangda",
3
- "version": "1.0.97",
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": {