@share-crm/sharedev-cli 0.0.4-rc.28 → 0.0.4-rc.29

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/dist/sharedev.js +97 -14
  2. package/package.json +1 -1
package/dist/sharedev.js CHANGED
@@ -13619,9 +13619,12 @@ function getShareCliCommandPath(namespace, key) {
13619
13619
 
13620
13620
 
13621
13621
  Object.defineProperty(exports, "__esModule", ({ value: true }));
13622
+ exports.SHARE_CLI_BUSINESS_NAME = void 0;
13622
13623
  exports.executeShareCliCommand = executeShareCliCommand;
13623
13624
  const request_ts_1 = __webpack_require__(2088);
13624
13625
  const trace_ts_1 = __webpack_require__(3632);
13626
+ /** 操作中心 shareCli/execute 的业务方标识 */
13627
+ exports.SHARE_CLI_BUSINESS_NAME = 'sharedev-cli';
13625
13628
  async function executeShareCliCommand(commandPath, data, others) {
13626
13629
  (0, trace_ts_1.traceExecute)(commandPath.join(' '));
13627
13630
  const payload = {
@@ -13631,7 +13634,11 @@ async function executeShareCliCommand(commandPath, data, others) {
13631
13634
  };
13632
13635
  return request_ts_1.requestService.FHH({
13633
13636
  url: '/EM1HActionCentre/shareCli/execute',
13634
- data: payload
13637
+ data: payload,
13638
+ // 操作中心侧按业务方来源做识别/统计,仅 shareCli/execute 需要携带
13639
+ headers: {
13640
+ 'x-fs-business-name': exports.SHARE_CLI_BUSINESS_NAME
13641
+ }
13635
13642
  });
13636
13643
  }
13637
13644
 
@@ -23952,6 +23959,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23952
23959
  };
23953
23960
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23954
23961
  exports.convertRulePushService = void 0;
23962
+ exports.toConvertRuleExecutePayload = toConvertRuleExecutePayload;
23955
23963
  const normalize_ts_1 = __importDefault(__webpack_require__(9268));
23956
23964
  const request_execute_command_paths_ts_1 = __webpack_require__(2351);
23957
23965
  const index_ts_1 = __webpack_require__(9985);
@@ -23961,6 +23969,23 @@ const request_ts_1 = __webpack_require__(3176);
23961
23969
  const logger_ts_1 = __webpack_require__(3333);
23962
23970
  const xmlMetadataManager = new index_ts_1.XmlMetadataManager();
23963
23971
  const isRecord = normalize_ts_1.default.isRecord;
23972
+ /**
23973
+ * 组 CreateConvertRule / UpdateConvertRule 远程 payload。
23974
+ * 请求体必须用 snake_case `rule_list`,对齐:
23975
+ * - Java ConvertRule.Arg @JsonProperty("rule_list")
23976
+ * - 前端 fe-paas/vui convertrule create/update
23977
+ * - object-mapping createRule/updateRule 的请求字段
23978
+ * 本地/pull 内容里可能出现 camelCase `ruleList`(响应侧),push 时归一成 `rule_list`。
23979
+ */
23980
+ function toConvertRuleExecutePayload(content) {
23981
+ const ruleListCandidate = content.rule_list ?? content.ruleList;
23982
+ if (!Array.isArray(ruleListCandidate)) {
23983
+ throw new Error('Invalid convert-rule content: rule_list is required and must be an array.');
23984
+ }
23985
+ return {
23986
+ rule_list: ruleListCandidate,
23987
+ };
23988
+ }
23964
23989
  const convertRulePushService = async (ruleApiNames, skipOverwriteConfirm = false) => {
23965
23990
  const errorMessages = [];
23966
23991
  const targetRuleApiNames = (ruleApiNames ?? '')
@@ -24026,19 +24051,14 @@ const convertRulePushService = async (ruleApiNames, skipOverwriteConfirm = false
24026
24051
  ruleMeta = await xmlMetadataManager.readXml('ConvertRule', ruleApiName);
24027
24052
  }
24028
24053
  const isCreate = ruleMeta.status === 'new';
24029
- const updatedContent = { ...(ruleMeta.content && isRecord(ruleMeta.content)
24030
- ? ruleMeta.content
24031
- : content) };
24032
- if ('ruleList' in updatedContent) {
24033
- if (!updatedContent.rule_list) {
24034
- updatedContent.rule_list = updatedContent.ruleList;
24035
- }
24036
- delete updatedContent.ruleList;
24037
- }
24054
+ const sourceContent = ruleMeta.content && isRecord(ruleMeta.content)
24055
+ ? ruleMeta.content
24056
+ : content;
24057
+ const executePayload = toConvertRuleExecutePayload(sourceContent);
24038
24058
  logger_ts_1.loggerService.startLoading('convert-rule push request: ' + ruleApiName + ' (' + (isCreate ? 'create' : 'update') + ')');
24039
24059
  const raw = await (0, request_ts_1.requestObjectDevExecute)(isCreate
24040
24060
  ? (0, request_execute_command_paths_ts_1.getShareCliCommandPath)('convertRule', 'create-rule')
24041
- : (0, request_execute_command_paths_ts_1.getShareCliCommandPath)('convertRule', 'update-rule'), updatedContent);
24061
+ : (0, request_execute_command_paths_ts_1.getShareCliCommandPath)('convertRule', 'update-rule'), executePayload);
24042
24062
  const response = raw;
24043
24063
  if (response.success !== true || normalize_ts_1.default.normalizeString(normalize_ts_1.default.asString(response.code)) !== 'OK') {
24044
24064
  logger_ts_1.loggerService.stopLoading();
@@ -28095,7 +28115,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28095
28115
  return (mod && mod.__esModule) ? mod : { "default": mod };
28096
28116
  };
28097
28117
  Object.defineProperty(exports, "__esModule", ({ value: true }));
28098
- exports.scenePushService = void 0;
28118
+ exports.scenePushService = exports.buildSceneExecutePayload = void 0;
28099
28119
  const normalize_ts_1 = __importDefault(__webpack_require__(9268));
28100
28120
  const request_execute_command_paths_ts_1 = __webpack_require__(2351);
28101
28121
  const index_ts_1 = __webpack_require__(9985);
@@ -28106,6 +28126,65 @@ const scene_pull_ts_1 = __webpack_require__(272);
28106
28126
  const logger_ts_1 = __webpack_require__(3333);
28107
28127
  const xmlMetadataManager = new index_ts_1.XmlMetadataManager();
28108
28128
  const isRecord = normalize_ts_1.default.isRecord;
28129
+ const asString = normalize_ts_1.default.asString;
28130
+ const normalizeString = normalize_ts_1.default.normalizeString;
28131
+ const SCENE_RUNTIME_FIELDS = [
28132
+ 'id',
28133
+ 'tenant_id',
28134
+ 'created_by',
28135
+ 'create_time',
28136
+ 'last_modified_by',
28137
+ 'last_modified_time'
28138
+ ];
28139
+ /**
28140
+ * 将本地 scene-meta content(扁平场景本体)包装为 create/update 远程契约:
28141
+ * { describe_api_name, extend_attribute, scene, i18nInfoList? }
28142
+ * 与 action-centre / share-cli-curl 的 required 对齐。
28143
+ */
28144
+ const buildSceneExecutePayload = (objectApiName, content, options = {}) => {
28145
+ const isCreate = options.isCreate !== false;
28146
+ const scene = { ...content };
28147
+ // i18n 属于远程 data 顶层可选字段,不落在 scene 本体里
28148
+ const i18nInfoList = Array.isArray(scene.i18nInfoList) ? scene.i18nInfoList : undefined;
28149
+ delete scene.i18nInfoList;
28150
+ if (isCreate) {
28151
+ // create:剥离运行时字段,由服务端生成
28152
+ for (const field of SCENE_RUNTIME_FIELDS) {
28153
+ delete scene[field];
28154
+ }
28155
+ }
28156
+ else {
28157
+ // update:远端强依赖 id/tenant_id 等运行时字段;本地草稿常缺失,从 list 结果回填
28158
+ for (const field of SCENE_RUNTIME_FIELDS) {
28159
+ const current = scene[field];
28160
+ const missing = current === undefined || current === null || current === '';
28161
+ if (!missing) {
28162
+ continue;
28163
+ }
28164
+ const remoteValue = options.remoteContent?.[field];
28165
+ if (remoteValue !== undefined && remoteValue !== null && remoteValue !== '') {
28166
+ scene[field] = remoteValue;
28167
+ }
28168
+ }
28169
+ }
28170
+ if (!normalizeString(asString(scene.object_describe_api_name))) {
28171
+ scene.object_describe_api_name = objectApiName;
28172
+ }
28173
+ if (!normalizeString(asString(scene.type))) {
28174
+ scene.type = 'tenant';
28175
+ }
28176
+ const payload = {
28177
+ describe_api_name: objectApiName,
28178
+ // curl 示例显式传空串;action-centre 也可 constant 注入,显式更稳
28179
+ extend_attribute: '',
28180
+ scene
28181
+ };
28182
+ if (i18nInfoList) {
28183
+ payload.i18nInfoList = i18nInfoList;
28184
+ }
28185
+ return payload;
28186
+ };
28187
+ exports.buildSceneExecutePayload = buildSceneExecutePayload;
28109
28188
  const scenePushService = async (objectApiName, sceneApiNames) => {
28110
28189
  const errorMessages = [];
28111
28190
  // 1) 校验 object 参数并解析待推送 scene 列表
@@ -28188,9 +28267,13 @@ const scenePushService = async (objectApiName, sceneApiNames) => {
28188
28267
  }
28189
28268
  logger_ts_1.loggerService.startLoading(`scene push request: ${checkedObjectApiName}.${sceneApiName}`);
28190
28269
  try {
28270
+ const remoteScene = sceneListResult.scenes.find((item) => item.apiName === sceneApiName);
28191
28271
  const response = await (0, request_ts_1.requestObjectDevExecute)(isCreate
28192
28272
  ? (0, request_execute_command_paths_ts_1.getShareCliCommandPath)('objectDev', 'createScene')
28193
- : (0, request_execute_command_paths_ts_1.getShareCliCommandPath)('objectDev', 'updateScene'), sceneMeta.content);
28273
+ : (0, request_execute_command_paths_ts_1.getShareCliCommandPath)('objectDev', 'updateScene'), (0, exports.buildSceneExecutePayload)(checkedObjectApiName, sceneMeta.content, {
28274
+ isCreate,
28275
+ remoteContent: remoteScene?.content
28276
+ }));
28194
28277
  if (response.success !== true || normalize_ts_1.default.normalizeString(normalize_ts_1.default.asString(response.code)) !== 'OK') {
28195
28278
  throw new Error(normalize_ts_1.default.normalizeText(response.message) || 'Unknown error');
28196
28279
  }
@@ -46741,7 +46824,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
46741
46824
  /***/ 8330
46742
46825
  (module) {
46743
46826
 
46744
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@share-crm/sharedev-cli","version":"0.0.4-rc.28","private":false,"description":"sharedev command line tool","type":"module","main":"dist/sharedev.js","bin":{"sharedev":"./bin/cli.mjs"},"author":{"name":"sharecrm-npm"},"files":["dist","bin","README.md"],"scripts":{"build":"tsc --noEmit && webpack --config build/webpack/webpack.prod.cjs","build:debug":"tsc --noEmit && webpack --config build/webpack/webpack.debug.cjs","build:bin":"bun build --compile --target=bun-darwin-x64 src/cli.ts --outfile scripts/sharedev-darwin-x64 && bun build --compile --target=bun-darwin-arm64 src/cli.ts --outfile scripts/sharedev-darwin-arm64 && bun build --compile --target=bun-windows-x64 src/cli.ts --outfile scripts/sharedev-windows-x64.exe","build:all":"npm run build && npm run build:bin","dev":"tsc --noEmit --watch & webpack --config build/webpack/webpack.dev.cjs --watch","dev2":"node src/cli.ts","typecheck":"tsc --noEmit","prettier":"prettier --write ./src/**/*.ts","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage"},"dependencies":{"@clack/prompts":"^1.1.0","@mariozechner/pi-coding-agent":"^0.62.0","axios":"~1.13.0","chalk":"^5.6.2","commander":"^14.0.1","extract-zip":"^2.0.1","fast-xml-parser":"^5.2.5","fs-extra":"^11.3.2","lodash-es":"^4.18.1","ora":"^9.3.0","terser-webpack-plugin":"^5.6.1"},"devDependencies":{"@types/extract-zip":"^2.0.3","@types/fs-extra":"^11.0.4","@types/lodash-es":"^4.17.12","@types/node":"^24.3.0","@vitest/coverage-v8":"^4.1.8","ts-loader":"^9.5.4","typescript":"^5.9.2","vitest":"^3.2.6","webpack":"^5.101.3","webpack-cli":"^6.0.1","webpack-merge":"^6.0.1"},"packageManager":"pnpm@10.17.0"}');
46827
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@share-crm/sharedev-cli","version":"0.0.4-rc.29","private":false,"description":"sharedev command line tool","type":"module","main":"dist/sharedev.js","bin":{"sharedev":"./bin/cli.mjs"},"author":{"name":"sharecrm-npm"},"files":["dist","bin","README.md"],"scripts":{"build":"tsc --noEmit && webpack --config build/webpack/webpack.prod.cjs","build:debug":"tsc --noEmit && webpack --config build/webpack/webpack.debug.cjs","build:bin":"bun build --compile --target=bun-darwin-x64 src/cli.ts --outfile scripts/sharedev-darwin-x64 && bun build --compile --target=bun-darwin-arm64 src/cli.ts --outfile scripts/sharedev-darwin-arm64 && bun build --compile --target=bun-windows-x64 src/cli.ts --outfile scripts/sharedev-windows-x64.exe","build:all":"npm run build && npm run build:bin","dev":"tsc --noEmit --watch & webpack --config build/webpack/webpack.dev.cjs --watch","dev2":"node src/cli.ts","typecheck":"tsc --noEmit","prettier":"prettier --write ./src/**/*.ts","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage"},"dependencies":{"@clack/prompts":"^1.1.0","@mariozechner/pi-coding-agent":"^0.62.0","axios":"~1.13.0","chalk":"^5.6.2","commander":"^14.0.1","extract-zip":"^2.0.1","fast-xml-parser":"^5.2.5","fs-extra":"^11.3.2","lodash-es":"^4.18.1","ora":"^9.3.0","terser-webpack-plugin":"^5.6.1"},"devDependencies":{"@types/extract-zip":"^2.0.3","@types/fs-extra":"^11.0.4","@types/lodash-es":"^4.17.12","@types/node":"^24.3.0","@vitest/coverage-v8":"^4.1.8","ts-loader":"^9.5.4","typescript":"^5.9.2","vitest":"^3.2.6","webpack":"^5.101.3","webpack-cli":"^6.0.1","webpack-merge":"^6.0.1"},"packageManager":"pnpm@10.17.0"}');
46745
46828
 
46746
46829
  /***/ }
46747
46830
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@share-crm/sharedev-cli",
3
- "version": "0.0.4-rc.28",
3
+ "version": "0.0.4-rc.29",
4
4
  "private": false,
5
5
  "description": "sharedev command line tool",
6
6
  "type": "module",