@share-crm/sharedev-cli 0.0.4-rc.50-test.3 → 0.0.4-rc.50-test.4

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 +575 -257
  2. package/package.json +1 -1
package/dist/sharedev.js CHANGED
@@ -8959,6 +8959,8 @@ var __webpack_unused_export__;
8959
8959
  __webpack_unused_export__ = ({ value: true });
8960
8960
  exports.registerAplNamespace = registerAplNamespace;
8961
8961
  const command_ts_1 = __webpack_require__(51481);
8962
+ const logger_ts_1 = __webpack_require__(87562);
8963
+ const request_channel_ts_1 = __webpack_require__(43355);
8962
8964
  const apl_command_ts_1 = __webpack_require__(10508);
8963
8965
  const index_ts_1 = __webpack_require__(76266);
8964
8966
  function registerAplNamespace(program, runtimeContext) {
@@ -8991,6 +8993,11 @@ Examples:
8991
8993
  .option('--all', 'Pull all APL functions')
8992
8994
  .option('--parameters <json>', 'Override function parameters, e.g. \'[{"name":"xx","type":"String","remark":"xx","default_value":"xx"}]\'')
8993
8995
  .action((0, command_ts_1.createCommandAction)('apl', 'pull', runtimeContext, async ({ args, options, context }) => {
8996
+ if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
8997
+ logger_ts_1.loggerService.info('ShareCRM login detected. Using operation-center command "apl pull-new" for legacy command "apl pull".');
8998
+ await (0, index_ts_1.aplPullNewCommand)(args[0], context, options);
8999
+ return;
9000
+ }
8994
9001
  await (0, apl_command_ts_1.aplPullCommand)(args[0], context, options);
8995
9002
  }));
8996
9003
  apl.command('diff [apiName]')
@@ -9016,11 +9023,21 @@ Examples:
9016
9023
  apl.command('analyze [apiName]')
9017
9024
  .description('Analyze local APL source against remote metadata')
9018
9025
  .action((0, command_ts_1.createCommandAction)('apl', 'analyze', runtimeContext, async ({ args, context }) => {
9026
+ if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
9027
+ logger_ts_1.loggerService.info('ShareCRM login detected. Using operation-center command "apl analyze-new" for legacy command "apl analyze".');
9028
+ await (0, index_ts_1.aplAnalyzeNewCommand)(args[0], context);
9029
+ return;
9030
+ }
9019
9031
  await (0, apl_command_ts_1.aplAnalyzeCommand)(args[0], context);
9020
9032
  }));
9021
9033
  apl.command('compile [apiName]')
9022
9034
  .description('Compile-check local APL source against remote metadata')
9023
9035
  .action((0, command_ts_1.createCommandAction)('apl', 'compile', runtimeContext, async ({ args, context }) => {
9036
+ if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
9037
+ logger_ts_1.loggerService.info('ShareCRM login detected. Using operation-center command "apl compile-new" for legacy command "apl compile".');
9038
+ await (0, index_ts_1.aplCompileNewCommand)(args[0], context);
9039
+ return;
9040
+ }
9024
9041
  await (0, apl_command_ts_1.aplCompileCommand)(args[0], context);
9025
9042
  }));
9026
9043
  apl.command('debug [apiName]')
@@ -9048,7 +9065,7 @@ Examples:
9048
9065
  };
9049
9066
  await (0, apl_command_ts_1.aplCreateCommand)(context, resolvedOptions);
9050
9067
  }));
9051
- // ===== 操作中心动作:code-dev function(启用或停用函数 set-active / 查询函数执行日志 list-execution-logs / 查询函数执行日志详情 get-execution-log) =====
9068
+ // ===== 操作中心动作:code-dev apl(启用或停用函数 set-active / 查询函数执行日志 list-execution-logs / 查询函数执行日志详情 get-execution-log) =====
9052
9069
  apl.command('set-active <apiName>')
9053
9070
  .description('[operation-center] 启用或停用函数 / Enable or disable a remote APL function by api name')
9054
9071
  .requiredOption('--is_active <boolean>', 'Target active state: true or false')
@@ -9112,7 +9129,7 @@ Examples:
9112
9129
  }));
9113
9130
  apl.command('info-new <apiName>')
9114
9131
  .description('[operation-center] Show APL function details')
9115
- .option('--bind <bindingObjectApiName>', 'Provide binding object api name for bound functions')
9132
+ .option('--bind <bindingObjectApiName>', 'Binding object api name; bound functions are only found with the correct binding (defaults to local snapshot)')
9116
9133
  .action((0, command_ts_1.createCommandAction)('apl', 'info-new', runtimeContext, async ({ args, options, context }) => {
9117
9134
  await (0, index_ts_1.aplInfoNewCommand)(args[0], context, options);
9118
9135
  }));
@@ -9120,6 +9137,7 @@ Examples:
9120
9137
  .description('[operation-center] Pull APL source from remote')
9121
9138
  .option('--all', 'Pull all APL functions')
9122
9139
  .option('--parameters <json>', 'Override function parameters, e.g. \'[{"name":"xx","type":"String","remark":"xx","default_value":"xx"}]\'')
9140
+ .option('--bind <bindingObjectApiName>', 'Binding object api name; bound functions are only found with the correct binding (defaults to local snapshot)')
9123
9141
  .action((0, command_ts_1.createCommandAction)('apl', 'pull-new', runtimeContext, async ({ args, options, context }) => {
9124
9142
  await (0, index_ts_1.aplPullNewCommand)(args[0], context, options);
9125
9143
  }));
@@ -9918,7 +9936,7 @@ Examples:
9918
9936
  $ sharedev auth login
9919
9937
  `)
9920
9938
  .action((0, command_ts_1.createCommandAction)('auth', 'login', runtimeContext, async ({ context }) => {
9921
- await (0, index_ts_1.authLoginCommand)(context.settings.domain);
9939
+ await (0, index_ts_1.authLoginCommand)(context.settings.domain, context);
9922
9940
  }));
9923
9941
  auth
9924
9942
  .command('status')
@@ -13753,6 +13771,8 @@ __webpack_unused_export__ = ({ value: true });
13753
13771
  exports.registerPwcNamespace = registerPwcNamespace;
13754
13772
  const commander_1 = __webpack_require__(63219);
13755
13773
  const command_ts_1 = __webpack_require__(51481);
13774
+ const logger_ts_1 = __webpack_require__(87562);
13775
+ const request_channel_ts_1 = __webpack_require__(43355);
13756
13776
  const pwc_command_ts_1 = __webpack_require__(10372);
13757
13777
  const index_ts_1 = __webpack_require__(60063);
13758
13778
  const pwc_types_ts_1 = __webpack_require__(55844);
@@ -13767,6 +13787,12 @@ function resolveApiNameOrPath(commandName, apiname, pathValue) {
13767
13787
  }
13768
13788
  return normalizedPath ?? normalizedApiName;
13769
13789
  }
13790
+ function useOpenApiPwcCommands() {
13791
+ return (0, request_channel_ts_1.resolveRequestChannel)() === 'openapi';
13792
+ }
13793
+ function announcePwcCommandMapping(legacyCommand, operationCenterCommand) {
13794
+ logger_ts_1.loggerService.info(`ShareCRM login detected. Using operation-center command "pwc ${operationCenterCommand}" for legacy command "pwc ${legacyCommand}".`);
13795
+ }
13770
13796
  function registerPwcNamespace(program, runtimeContext) {
13771
13797
  const pwc = program.command('pwc').description('PWC workspace commands');
13772
13798
  pwc.addHelpText('after', `
@@ -13780,6 +13806,7 @@ Examples:
13780
13806
  $ sharedev pwc push --apiname MyPlugin --type plugin
13781
13807
  $ sharedev pwc deploy --apiname MyComponent --type component
13782
13808
  $ sharedev pwc create --type component --name Demo --apiname demo__c
13809
+ $ sharedev pwc create --type component --name Demo --apiname demo__c
13783
13810
  $ sharedev pwc list-new --type component
13784
13811
  $ sharedev pwc info-new --apiname MyComponent --type component
13785
13812
  $ sharedev pwc pull-new --apiname MyComponent --type component
@@ -13789,11 +13816,17 @@ Examples:
13789
13816
  $ sharedev pwc create-new --type component --name Demo --apiname demo__c
13790
13817
  $ sharedev pwc dev src/index.js
13791
13818
  `);
13819
+ pwc.addHelpText('after', '\nWhen authenticated with `sharedev auth login`, `info`, `create`, `push`, and `deploy` automatically use their `*-new` operation-center equivalents. Certificate mode keeps using the legacy commands.');
13792
13820
  pwc.command('info')
13793
13821
  .description('Show detail info (URL, type, clients) for a PWC resource by apiName')
13794
13822
  .requiredOption('--apiname <apiName>', 'PWC resource API name')
13795
13823
  .addOption(new commander_1.Option('--type <type>', 'PWC type: component or plugin').choices(pwc_types_ts_1.PWC_TYPE_VALUES).makeOptionMandatory())
13796
13824
  .action((0, command_ts_1.createCommandAction)('pwc', 'info', runtimeContext, async ({ options }) => {
13825
+ if (useOpenApiPwcCommands()) {
13826
+ announcePwcCommandMapping('info', 'info-new');
13827
+ await (0, index_ts_1.pwcPwcInfoCommand)(options);
13828
+ return;
13829
+ }
13797
13830
  await (0, pwc_command_ts_1.pwcInfoCommand)(options.apiname, options.type);
13798
13831
  }));
13799
13832
  pwc.command('pull')
@@ -13810,6 +13843,11 @@ Examples:
13810
13843
  .option('--path <path>', 'Deploy one PWC resource by local path')
13811
13844
  .addOption(new commander_1.Option('--type <type>', 'PWC type: component or plugin').choices(pwc_types_ts_1.PWC_TYPE_VALUES).makeOptionMandatory())
13812
13845
  .action((0, command_ts_1.createCommandAction)('pwc', 'deploy', runtimeContext, async ({ options, context }) => {
13846
+ if (useOpenApiPwcCommands()) {
13847
+ announcePwcCommandMapping('deploy', 'deploy-new');
13848
+ await (0, index_ts_1.pwcPwcDeployCommand)(options, context);
13849
+ return;
13850
+ }
13813
13851
  const target = resolveApiNameOrPath('deploy', options.apiname, options.path);
13814
13852
  await (0, pwc_command_ts_1.pwcDeployCommand)(target, options, context);
13815
13853
  }));
@@ -13835,6 +13873,11 @@ Examples:
13835
13873
  ...options,
13836
13874
  apiName: options.apiName ?? options.apiname
13837
13875
  };
13876
+ if (useOpenApiPwcCommands()) {
13877
+ announcePwcCommandMapping('create', 'create-new');
13878
+ await (0, index_ts_1.pwcPwcCreateCommand)(resolvedOptions, context);
13879
+ return;
13880
+ }
13838
13881
  await (0, pwc_command_ts_1.pwcCreateCommand)(resolvedOptions, context);
13839
13882
  }));
13840
13883
  ['init', 'publish'].forEach((commandName) => {
@@ -13858,6 +13901,11 @@ Examples:
13858
13901
  .option('--path <path>', 'Push one PWC resource by local path')
13859
13902
  .addOption(new commander_1.Option('--type <type>', 'PWC type: component or plugin').choices(pwc_types_ts_1.PWC_TYPE_VALUES).makeOptionMandatory())
13860
13903
  .action((0, command_ts_1.createCommandAction)('pwc', 'push', runtimeContext, async ({ options, context }) => {
13904
+ if (useOpenApiPwcCommands()) {
13905
+ announcePwcCommandMapping('push', 'push-new');
13906
+ await (0, index_ts_1.pwcPwcPushCommand)(options, context);
13907
+ return;
13908
+ }
13861
13909
  const target = resolveApiNameOrPath('push', options.apiname, options.path);
13862
13910
  await (0, pwc_command_ts_1.pwcPushCommand)(target, options, context);
13863
13911
  }));
@@ -15875,7 +15923,7 @@ const isDebugEnabled_ts_1 = __webpack_require__(27570);
15875
15923
  * 与 FHH 网关(request.ts,certificate 鉴权)平行:本通道走
15876
15924
  * `POST {apiUrl}/api/v1/commands/execute`,鉴权为 sharecrm 登录的
15877
15925
  * `Authorization: Bearer <FSDTK token>`。两网关票据不通用,命令注册以
15878
- * docs/action-centre-integration.md 的实测记录为准(注意 code-dev function 新命名)。
15926
+ * docs/action-centre-integration.md 的实测记录为准(注意 code-dev apl 命名)。
15879
15927
  */
15880
15928
  class OpenApiCommandError extends Error {
15881
15929
  constructor(message, resultCode, detail, traceId) {
@@ -15900,14 +15948,14 @@ async function buildCommandHeaders(session) {
15900
15948
  'Content-Type': 'application/json',
15901
15949
  Authorization: `Bearer ${session.accessToken}`,
15902
15950
  'X-CLI-Id': 'sharedev-cli',
15903
- 'X-CLI-Version': version || '0.0.0',
15951
+ 'X-CLI-Version': "1.1.17",
15904
15952
  'X-Caller-Type': 'cli',
15905
15953
  'X-Request-Id': (0, node_crypto_1.randomUUID)(),
15906
15954
  'Accept-Language': locale ?? 'en-US',
15907
15955
  'X-FS-Locale': locale ?? 'en-US'
15908
15956
  };
15909
15957
  }
15910
- async function executeOnce(session, commandKey, args, flags) {
15958
+ async function executeOnce(session, commandKey, args, flags, onTraceId) {
15911
15959
  const response = await fetch(toExecuteUrl(session.apiUrl), {
15912
15960
  method: 'POST',
15913
15961
  headers: await buildCommandHeaders(session),
@@ -15932,6 +15980,7 @@ async function executeOnce(session, commandKey, args, flags) {
15932
15980
  }
15933
15981
  if (payload.traceId) {
15934
15982
  logger_ts_1.loggerService.addTraceId(payload.traceId);
15983
+ onTraceId?.(payload.traceId);
15935
15984
  }
15936
15985
  if (payload.resultCode === 'SUCCESS') {
15937
15986
  if (payload.helpInfoReturned === true) {
@@ -15954,17 +16003,18 @@ async function executeOnce(session, commandKey, args, flags) {
15954
16003
  * 未登录抛错引导 `sharedev auth login`;token 过期自动刷新;
15955
16004
  * 服务端返回 AUTH_FAIL 时刷新一次后重试(服务端会话失效场景)。
15956
16005
  * flags 用于透传确认标记等命令行语义(如 NEED_CONFIRM 的 --yes)。
16006
+ * onTraceId 用于回传服务端 traceId(调用方需要在报错里展示 traceId 时使用)。
15957
16007
  */
15958
16008
  async function executeOpenApiCommand(commandKey, args = {}, options) {
15959
16009
  const session = await (0, sharecrm_session_ts_1.ensureValidSharedevAuthSession)();
15960
16010
  try {
15961
- return await executeOnce(session, commandKey, args, options?.flags);
16011
+ return await executeOnce(session, commandKey, args, options?.flags, options?.onTraceId);
15962
16012
  }
15963
16013
  catch (error) {
15964
16014
  if (error instanceof OpenApiCommandError && error.resultCode === 'AUTH_FAIL') {
15965
16015
  const refreshed = await (0, sharecrm_session_ts_1.refreshSharecrmSession)(session);
15966
16016
  (0, sharecrm_session_ts_1.saveSharedevAuthSession)(refreshed);
15967
- return await executeOnce(refreshed, commandKey, args, options?.flags);
16017
+ return await executeOnce(refreshed, commandKey, args, options?.flags, options?.onTraceId);
15968
16018
  }
15969
16019
  throw error;
15970
16020
  }
@@ -16263,7 +16313,7 @@ var __webpack_unused_export__;
16263
16313
  __webpack_unused_export__ = ({ value: true });
16264
16314
  exports.configureRequestChannel = configureRequestChannel;
16265
16315
  exports.resolveRequestChannel = resolveRequestChannel;
16266
- exports.hasCertificateCredential = hasCertificateCredential;
16316
+ __webpack_unused_export__ = hasCertificateCredential;
16267
16317
  const logger_ts_1 = __webpack_require__(87562);
16268
16318
  const sharecrm_session_ts_1 = __webpack_require__(47166);
16269
16319
  let currentSettings;
@@ -16702,10 +16752,9 @@ const SHARE_CLI_COMMAND_PATH_MAP = {
16702
16752
  aplFind: ['code-dev', 'apl', 'get-by-apiname-and-binding-object-apiname'],
16703
16753
  aplBatchQuery: ['code-dev', 'apl', 'query-by-apinames'],
16704
16754
  aplList: ['code-dev', 'apl', 'list'],
16705
- // ===== function(apl 函数启用/停用 + 执行日志,操作中心新命名空间,已实测 fktest5642 环境) =====
16706
- functionSetActive: ['code-dev', 'function', 'set-active'],
16707
- functionListExecutionLogs: ['code-dev', 'function', 'list-execution-logs'],
16708
- functionGetExecutionLog: ['code-dev', 'function', 'get-execution-log'],
16755
+ functionSetActive: ['code-dev', 'apl', 'set-active'],
16756
+ functionListExecutionLogs: ['code-dev', 'apl', 'list-execution-logs'],
16757
+ functionGetExecutionLog: ['code-dev', 'apl', 'get-execution-log'],
16709
16758
  },
16710
16759
  };
16711
16760
  function getShareCliCommandPath(namespace, key) {
@@ -16730,24 +16779,10 @@ const openapi_request_ts_1 = __webpack_require__(59848);
16730
16779
  const trace_ts_1 = __webpack_require__(36097);
16731
16780
  /** 操作中心 shareCli/execute 的业务方标识 */
16732
16781
  exports.y = 'sharedev-cli';
16733
- /**
16734
- * open API 侧 code-dev 命名空间迁移:apl → function(子命令同名,2026-10-21 实测)。
16735
- * list 例外:open API 未注册 code-dev function list,等价能力为 object-dev function query。
16736
- */
16737
- function toOpenApiCommandPath(commandPath) {
16738
- if (commandPath.length >= 3 && commandPath[0] === 'code-dev' && commandPath[1] === 'apl') {
16739
- if (commandPath[2] === 'list') {
16740
- throw new Error('Command "code-dev apl list" is not registered on the Open API gateway; the equivalent is "object-dev function query".');
16741
- }
16742
- return ['code-dev', 'function', ...commandPath.slice(2)];
16743
- }
16744
- return commandPath;
16745
- }
16746
16782
  /**
16747
16783
  * 执行操作中心命令(透传族统一入口)。
16748
16784
  *
16749
- * 双通道(二期):sharecrm 登录态 → open API `commands/execute`(commandKey = commandPath 空格连接,
16750
- * code-dev apl * 自动映射为迁移后的 function 命名空间);
16785
+ * 双通道(二期):sharecrm 登录态 → open API `commands/execute`(commandKey = commandPath 空格连接);
16751
16786
  * certificate → FHH `shareCli/execute`(现状不动)。响应统一适配为 ShareCliExecuteResponse
16752
16787
  * 形态({success, code, message, data}),上层 PassthroughCommandManager 无感。
16753
16788
  */
@@ -16757,7 +16792,7 @@ async function executeShareCliCommand(commandPath, data, others) {
16757
16792
  if (channel === 'openapi') {
16758
16793
  // open API 侧确认协议:flags 形式(sharecrm 同款);agentChannels 为 FHH 侧统计标记,暂无对应物
16759
16794
  const flags = others?.yes === true ? ['--yes'] : undefined;
16760
- const commandKey = toOpenApiCommandPath(commandPath).join(' ');
16795
+ const commandKey = commandPath.join(' ');
16761
16796
  const content = await (0, openapi_request_ts_1.executeOpenApiCommand)(commandKey, data ?? {}, flags ? { flags } : undefined);
16762
16797
  return {
16763
16798
  success: true,
@@ -18566,6 +18601,10 @@ async function aplPullCommand(apiName, context, options = {}) {
18566
18601
  const functions = await (0, apl_service_ts_1.getFuncList)();
18567
18602
  const filtered = functions.filter((item) => item.lang === 0 && !item.is_control);
18568
18603
  const apiNames = filtered.map((item) => item.api_name).filter(Boolean);
18604
+ if (!apiNames.length) {
18605
+ logger_ts_1.loggerService.info('No pullable APL functions found.');
18606
+ return true;
18607
+ }
18569
18608
  logger_ts_1.loggerService.updateLoading('Fetching APL function details');
18570
18609
  const funcDetails = await (0, apl_service_ts_1.findFuncByApiNames)(apiNames);
18571
18610
  const detailMap = new Map(funcDetails.map((item) => [item.api_name, item]));
@@ -18578,7 +18617,8 @@ async function aplPullCommand(apiName, context, options = {}) {
18578
18617
  .map((name) => detailMap.get(name))
18579
18618
  .filter((x) => Boolean(x));
18580
18619
  if (!toWrite.length) {
18581
- throw logger_ts_1.loggerService.info('No APL function details were returned. Nothing can be written.');
18620
+ logger_ts_1.loggerService.info('No APL function details were returned. Nothing can be written.');
18621
+ return false;
18582
18622
  }
18583
18623
  if (cliParameters) {
18584
18624
  for (const func of toWrite) {
@@ -18589,7 +18629,7 @@ async function aplPullCommand(apiName, context, options = {}) {
18589
18629
  await (0, apl_workspace_ts_1.writeAplFunctions)(context, toWrite);
18590
18630
  await (0, apl_workspace_ts_1.writeAplSnapshot)(context, toWrite);
18591
18631
  logger_ts_1.loggerService.success(`Pulled APL functions: target=${apiNames.length}, written=${toWrite.length}, missing=${missing.length}.`);
18592
- return;
18632
+ return missing.length === 0;
18593
18633
  }
18594
18634
  const func = await (0, apl_service_ts_1.findFuncByApiName)(apiName);
18595
18635
  if (cliParameters) {
@@ -18599,6 +18639,7 @@ async function aplPullCommand(apiName, context, options = {}) {
18599
18639
  const filePath = await (0, apl_workspace_ts_1.writeAplFunction)(context, func);
18600
18640
  await (0, apl_workspace_ts_1.writeAplSnapshot)(context, func);
18601
18641
  logger_ts_1.loggerService.success(`Pulled APL function ${apiName} to ${filePath}`);
18642
+ return true;
18602
18643
  }
18603
18644
  async function aplDiffCommand(apiName, context, options = {}) {
18604
18645
  const target = await (0, apl_workspace_ts_1.resolveAplTarget)(context, apiName);
@@ -19474,7 +19515,7 @@ async function getFuncListViaOpenApi(options) {
19474
19515
  if (space) {
19475
19516
  args.name_space = [space];
19476
19517
  }
19477
- const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', args);
19518
+ const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev apl list', args);
19478
19519
  return content?.result?.function ?? [];
19479
19520
  }
19480
19521
  /**
@@ -19482,7 +19523,7 @@ async function getFuncListViaOpenApi(options) {
19482
19523
  * 响应含完整函数体(body 源码),字段与 IFuncData 同构(2026-10-21 实测)。
19483
19524
  */
19484
19525
  async function findFuncByApiNameViaOpenApi(apiName, bindingObjectApiName) {
19485
- const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev function get-by-apiname-and-binding-object-apiname', {
19526
+ const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev apl get-by-apiname-and-binding-object-apiname', {
19486
19527
  api_name: apiName,
19487
19528
  ...(bindingObjectApiName ? { binding_object_api_name: bindingObjectApiName } : {})
19488
19529
  });
@@ -19523,7 +19564,7 @@ async function getFuncList(options = {}) {
19523
19564
  * 与 get-by-apiname-and-binding-object-apiname 的 {result:{function}} 不同形)。
19524
19565
  */
19525
19566
  async function findFuncByApiNamesViaOpenApi(apiNames) {
19526
- const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev function query-by-apinames', { apiNames });
19567
+ const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev apl query-by-apinames', { apiNames });
19527
19568
  return content?.function ?? [];
19528
19569
  }
19529
19570
  async function findFuncByApiNames(apiNames) {
@@ -20702,17 +20743,22 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
20702
20743
  exports.aplInfoNewCommand = aplInfoNewCommand;
20703
20744
  const logger_ts_1 = __webpack_require__(87562);
20704
20745
  const apl_info_ts_1 = __webpack_require__(1673);
20746
+ const apl_workspace_ts_1 = __webpack_require__(59696);
20705
20747
  /**
20706
20748
  * info-new 指令 CLI 交互逻辑:查询 APL 函数详情并打印(操作中心链路)
20707
20749
  */
20708
- async function aplInfoNewCommand(apiName, _context, options = {}) {
20709
- void _context;
20750
+ async function aplInfoNewCommand(apiName, context, options = {}) {
20710
20751
  if (!apiName?.trim()) {
20711
20752
  throw new Error('Invalid arguments: use sharedev apl info-new <apiName>.');
20712
20753
  }
20713
20754
  const requestedApiName = apiName.trim();
20714
- // 未绑定时 binding_object_api_name 按接口约定传 NONE(对齐操作中心 curl 示例)
20715
- const bindingObjectApiName = options.bind?.trim() || 'NONE';
20755
+ // binding 解析优先级:--bind 显式传入 > 本地快照记录(对齐 set-active 模式);仍无则按接口约定传 NONE
20756
+ let bindingObjectApiName = options.bind?.trim() || undefined;
20757
+ if (!bindingObjectApiName) {
20758
+ const tracked = await (0, apl_workspace_ts_1.readAplTrackedRecord)(context, requestedApiName).catch(() => undefined);
20759
+ bindingObjectApiName = tracked?.snapshot?.bindingObjectApiName || undefined;
20760
+ }
20761
+ bindingObjectApiName = bindingObjectApiName || 'NONE';
20716
20762
  // 查询并复用现有格式化输出
20717
20763
  const func = await (0, apl_info_ts_1.aplInfoNewService)(requestedApiName, bindingObjectApiName);
20718
20764
  logger_ts_1.loggerService.printRaw(formatAplFuncDescribeNew(func));
@@ -20895,13 +20941,24 @@ async function aplListNewCommand(_context, options = {}) {
20895
20941
  Object.defineProperty(exports, "__esModule", ({ value: true }));
20896
20942
  exports.aplPullNewCommand = aplPullNewCommand;
20897
20943
  const apl_pull_ts_1 = __webpack_require__(48322);
20944
+ const apl_workspace_ts_1 = __webpack_require__(59696);
20898
20945
  const shared_ts_1 = __webpack_require__(23053);
20899
20946
  /**
20900
20947
  * pull-new 指令 CLI 交互逻辑:拉取 APL 函数到本地(操作中心链路)
20901
20948
  */
20902
20949
  async function aplPullNewCommand(apiName, context, options = {}) {
20903
20950
  const cliParameters = options.parameters?.trim() ? (0, shared_ts_1.parseAplParametersNew)(options.parameters) : undefined;
20904
- await (0, apl_pull_ts_1.aplPullNewService)(apiName, context, { all: options.all, parameters: cliParameters });
20951
+ // binding 解析优先级:--bind 显式传入 > 本地快照记录(对齐 set-active 模式)
20952
+ let bindingObjectApiName = options.bind?.trim() || undefined;
20953
+ if (!bindingObjectApiName && apiName?.trim()) {
20954
+ const tracked = await (0, apl_workspace_ts_1.readAplTrackedRecord)(context, apiName.trim()).catch(() => undefined);
20955
+ bindingObjectApiName = tracked?.snapshot?.bindingObjectApiName || undefined;
20956
+ }
20957
+ await (0, apl_pull_ts_1.aplPullNewService)(apiName, context, {
20958
+ all: options.all,
20959
+ parameters: cliParameters,
20960
+ bindingObjectApiName
20961
+ });
20905
20962
  }
20906
20963
 
20907
20964
 
@@ -21370,7 +21427,7 @@ async function getAplNamespaceOptionsNew() {
21370
21427
  const returnTypes = result.returnTypes
21371
21428
  .map((item) => normalizeReturnTypeItemNew(item))
21372
21429
  .filter((item) => Boolean(item));
21373
- return { namespaces, returnTypes };
21430
+ return { namespaces, returnTypes, raw: response.data ?? {} };
21374
21431
  }
21375
21432
  function normalizeNamespaceItemNew(item) {
21376
21433
  const value = readStringNew(item.value) || readStringNew(item.namespace) || readStringNew(item.name_space) || readStringNew(item.name);
@@ -21807,7 +21864,9 @@ async function aplInfoNewService(apiName, bindingObjectApiName = '') {
21807
21864
  return result.data;
21808
21865
  });
21809
21866
  if (!func) {
21810
- throw new Error(`APL function not found: ${apiName}.`);
21867
+ throw new Error(`APL function not found: ${apiName}.\n` +
21868
+ 'If the function is bound to an object, retry with --bind <bindingObjectApiName> ' +
21869
+ '(find it via `apl list` / legacy `apl info`).');
21811
21870
  }
21812
21871
  // 收窄为 IFuncData 返回(打印交给 command 层复用现有格式化)
21813
21872
  const narrowed = (0, types_ts_1.narrowAplResponse)(func);
@@ -21834,11 +21893,10 @@ const logger_ts_1 = __webpack_require__(87562);
21834
21893
  const types_ts_1 = __webpack_require__(42801);
21835
21894
  const request_ts_1 = __webpack_require__(25285);
21836
21895
  /**
21837
- * open API 通道的 list-new 查询:open API 未注册 code-dev function list,
21838
- * 等价能力为 object-dev function query(过滤参数同名,2026-10-21 实测);
21896
+ * open API 通道的 list-new 查询:直接复用 code-dev apl list(过滤参数同名,2026-10-21 实测);
21839
21897
  * 响应包成 AplResponse 兼容信封,下游解析逻辑零改动。
21840
21898
  *
21841
- * ⚠️ body / selectFieldName 为 FHH 老链路参数,object-dev function query 不支持
21899
+ * ⚠️ body / selectFieldName 为 FHH 老链路参数,code-dev apl list 不支持
21842
21900
  * (2026-10-21 实测:传入后被服务端静默忽略、过滤不生效),显式剔除并提示用户。
21843
21901
  */
21844
21902
  const requestAplListViaOpenApi = async (filters) => {
@@ -21846,7 +21904,7 @@ const requestAplListViaOpenApi = async (filters) => {
21846
21904
  if (body !== undefined || selectFieldName !== undefined) {
21847
21905
  logger_ts_1.loggerService.warn('Filters "body" and "selectFieldName" are not supported on the sharecrm login channel and were ignored.');
21848
21906
  }
21849
- const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', supported);
21907
+ const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev apl list', supported);
21850
21908
  return {
21851
21909
  success: true,
21852
21910
  code: 'OK',
@@ -21998,9 +22056,9 @@ async function aplPullNewService(apiName, context, options = {}) {
21998
22056
  logger_ts_1.loggerService.success(`Pulled APL functions: target=${apiNames.length}, written=${toWrite.length}, missing=${missing.length}.`);
21999
22057
  return;
22000
22058
  }
22001
- // 拉取单个:find 查详情(未绑定时 binding_object_api_name 按接口约定传 NONE)
22059
+ // 拉取单个:find 查详情(binding 解析优先级:--bind > 本地快照;都无则按接口约定传 NONE)
22002
22060
  logger_ts_1.loggerService.startLoading(`Fetching APL function ${apiName}`);
22003
- const response = await requestAplFindExecute(apiName, 'NONE');
22061
+ const response = await requestAplFindExecute(apiName, options.bindingObjectApiName?.trim() || 'NONE');
22004
22062
  logger_ts_1.loggerService.stopLoading();
22005
22063
  const func = await (0, request_ts_1.extractAplServiceResult)(response, types_ts_1.extractAplFunctionFromResponse).then((result) => {
22006
22064
  if (!result.success) {
@@ -22010,7 +22068,9 @@ async function aplPullNewService(apiName, context, options = {}) {
22010
22068
  });
22011
22069
  const narrowed = func ? (0, types_ts_1.narrowAplResponse)(func) : undefined;
22012
22070
  if (!narrowed) {
22013
- throw new Error(`APL function not found: ${apiName}.`);
22071
+ throw new Error(`APL function not found: ${apiName}.\n` +
22072
+ 'If the function is bound to an object, retry with --bind <bindingObjectApiName> ' +
22073
+ '(find it via `apl list` / legacy `apl info`), or use `apl pull-new --all`.');
22014
22074
  }
22015
22075
  if (cliParameters) {
22016
22076
  narrowed.parameters = cliParameters;
@@ -22523,11 +22583,14 @@ exports.extractAplTemplateBodyFromResponse = extractAplTemplateBodyFromResponse;
22523
22583
  */
22524
22584
  const extractAplNamespaceDataFromResponse = (response) => {
22525
22585
  const level1 = narrowAplResponse(response.data);
22526
- // 兼容 data 直接就是命名空间结构或再包一层 data 两种形态
22586
+ // 兼容多种形态:data.namespaces / data.data / data.result.data(实测 query-namespaces 返回 result.data: [{label, value}])
22527
22587
  const dataRoot = narrowAplResponse(level1?.data) ?? level1 ?? {};
22588
+ const resultRoot = narrowAplResponse(dataRoot.result) ?? dataRoot;
22528
22589
  const namespaceItems = Array.isArray(dataRoot.namespaces)
22529
22590
  ? dataRoot.namespaces.map((item) => item)
22530
- : [];
22591
+ : Array.isArray(resultRoot.data)
22592
+ ? resultRoot.data.map((item) => item)
22593
+ : [];
22531
22594
  const returnTypeItems = Array.isArray(dataRoot.return_type)
22532
22595
  ? dataRoot.return_type.map((item) => item)
22533
22596
  : [];
@@ -25936,6 +25999,11 @@ const node_child_process_1 = __webpack_require__(31421);
25936
25999
  const node_path_1 = __importDefault(__webpack_require__(76760));
25937
26000
  const logger_ts_1 = __webpack_require__(87562);
25938
26001
  const openapi_request_ts_1 = __webpack_require__(59848);
26002
+ const apl_command_ts_1 = __webpack_require__(10508);
26003
+ const pwc_command_ts_1 = __webpack_require__(10372);
26004
+ const pwc_types_ts_1 = __webpack_require__(55844);
26005
+ const dev_metadata_service_ts_1 = __webpack_require__(24814);
26006
+ const file_ts_1 = __webpack_require__(57452);
25939
26007
  const sharecrm_session_ts_1 = __webpack_require__(47166);
25940
26008
  /** 解析依赖包 @share-crm/sharecrm-cli 的 bin 入口(不走 PATH / 全局安装) */
25941
26009
  function resolveSharecrmBinEntry() {
@@ -25960,7 +26028,7 @@ function deriveLoginEnvFromDomain(domain) {
25960
26028
  }
25961
26029
  return loginEnv;
25962
26030
  }
25963
- async function authLoginCommand(domain) {
26031
+ async function authLoginCommand(domain, context) {
25964
26032
  const loginEnv = deriveLoginEnvFromDomain(domain);
25965
26033
  // sharecrm 全局 config 优先级高于环境变量注入,固定过环境时会压制工作区推导——提前拦截
25966
26034
  const sharecrmConfig = (0, sharecrm_session_ts_1.readSharecrmConfig)();
@@ -26003,16 +26071,86 @@ async function authLoginCommand(domain) {
26003
26071
  logger_ts_1.loggerService.success(`Logged in as ${session.userName || `user ${session.userId}`} (appId ${session.appId}).`);
26004
26072
  // 端到端验证 Open API 通道(只读查询;失败仅 warn,部分环境命令集较旧属已知限制)
26005
26073
  try {
26006
- const result = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', {
26074
+ const result = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev apl list', {
26007
26075
  pageNumber: '1',
26008
26076
  pageSize: '1'
26009
26077
  });
26010
- const total = result?.result?.totalNumber;
26011
- logger_ts_1.loggerService.success(`Open API channel verified${typeof total === 'number' ? `: ${total} functions visible` : ''}.`);
26078
+ const functions = result?.result?.function;
26079
+ logger_ts_1.loggerService.success(`Open API channel verified${Array.isArray(functions) ? `: ${functions.length} functions visible` : ''}.`);
26012
26080
  }
26013
26081
  catch (error) {
26014
26082
  logger_ts_1.loggerService.warn(`Open API channel verification failed: ${error instanceof Error ? error.message : String(error)}`);
26015
26083
  }
26084
+ // 登录成功且通道可用后,自动拉取远端资源(与 sharedev init 的 pull 流程一致):
26085
+ // APL 全部函数 + PWC 全部组件/插件,写入当前工作区。单类失败仅告警,不阻断整体登录结果。
26086
+ await runPostLoginPulls(context);
26087
+ }
26088
+ /** 登录成功后只补拉 init 因未登录而跳过的资源;普通登录不自动下载全量资源。 */
26089
+ async function runPostLoginPulls(context) {
26090
+ const pendingPullsPath = node_path_1.default.join(context.settings.settingsDir, 'pending-pulls.json');
26091
+ if (!(await (0, file_ts_1.pathExists)(pendingPullsPath))) {
26092
+ logger_ts_1.loggerService.info('Login complete. No pending init pulls.');
26093
+ return;
26094
+ }
26095
+ const pendingPulls = await (0, file_ts_1.readJsonFile)(pendingPullsPath);
26096
+ let succeeded = true;
26097
+ // 登录后补拉 init 因未认证而跳过的对象元数据。
26098
+ if (pendingPulls.pullMetadata === true) {
26099
+ try {
26100
+ logger_ts_1.loggerService.info('Pulling object metadata selected during init...');
26101
+ const metadataResult = await (0, dev_metadata_service_ts_1.downloadInitMetadata)(context);
26102
+ succeeded = metadataResult.success && succeeded;
26103
+ if (!metadataResult.success) {
26104
+ logger_ts_1.loggerService.warn('Some object metadata could not be downloaded; it will be retried after login.');
26105
+ }
26106
+ }
26107
+ catch (error) {
26108
+ succeeded = false;
26109
+ logger_ts_1.loggerService.warn(`Object metadata pull failed after login: ${error instanceof Error ? error.message : String(error)}`);
26110
+ }
26111
+ }
26112
+ // 只补拉 init 时用户选中的 APL 资源。
26113
+ if (pendingPulls.pullAllApl === true) {
26114
+ try {
26115
+ logger_ts_1.loggerService.info('Pulling APL functions selected during init...');
26116
+ const aplSucceeded = await (0, apl_command_ts_1.aplPullCommand)(undefined, context, { all: true });
26117
+ succeeded = aplSucceeded && succeeded;
26118
+ if (!aplSucceeded) {
26119
+ logger_ts_1.loggerService.warn('Some APL functions could not be downloaded; they will be retried after login.');
26120
+ }
26121
+ }
26122
+ catch (error) {
26123
+ succeeded = false;
26124
+ logger_ts_1.loggerService.warn(`APL pull failed after login: ${error instanceof Error ? error.message : String(error)}`);
26125
+ }
26126
+ }
26127
+ // 只补拉 init 时用户选中的 PWC 组件和插件。
26128
+ if (pendingPulls.pullAllPwc === true) {
26129
+ logger_ts_1.loggerService.info('Pulling PWC resources selected during init...');
26130
+ const results = await Promise.allSettled([
26131
+ (0, pwc_command_ts_1.pwcPullCommand)(undefined, { all: true, type: pwc_types_ts_1.PWCType.Component }, context),
26132
+ (0, pwc_command_ts_1.pwcPullCommand)(undefined, { all: true, type: pwc_types_ts_1.PWCType.Plugin }, context)
26133
+ ]);
26134
+ const componentSucceeded = results[0].status === 'fulfilled' && results[0].value;
26135
+ const pluginSucceeded = results[1].status === 'fulfilled' && results[1].value;
26136
+ if (!componentSucceeded) {
26137
+ const error = results[0].status === 'rejected' ? results[0].reason : undefined;
26138
+ logger_ts_1.loggerService.warn(`PWC component pull failed after login: ${error instanceof Error ? error.message : String(error)}`);
26139
+ }
26140
+ if (!pluginSucceeded) {
26141
+ const error = results[1].status === 'rejected' ? results[1].reason : undefined;
26142
+ logger_ts_1.loggerService.warn(`PWC plugin pull failed after login: ${error instanceof Error ? error.message : String(error)}`);
26143
+ }
26144
+ succeeded = succeeded && componentSucceeded && pluginSucceeded;
26145
+ }
26146
+ // 仅在所有待补拉任务成功后清除标记;失败时保留,便于下次登录重试。
26147
+ if (succeeded) {
26148
+ await (0, file_ts_1.removePath)(pendingPullsPath);
26149
+ logger_ts_1.loggerService.success('Pending init pulls completed.');
26150
+ }
26151
+ else {
26152
+ logger_ts_1.loggerService.warn('Some init pulls failed. Run `sharedev auth login` again to retry.');
26153
+ }
26016
26154
  }
26017
26155
  function formatExpireTime(session) {
26018
26156
  if (!session.tokenExpireAt) {
@@ -26153,7 +26291,33 @@ async function bpmDefUpdateDefinitionCommand(_context, options) {
26153
26291
  nameTranslateInfo: "object",
26154
26292
  descTranslateInfo: "object"
26155
26293
  };
26156
- const data = buildOptionsData(options, typeMap);
26294
+ const updates = buildOptionsData(options, typeMap);
26295
+ // 服务端为全量更新语义:必须先按 --id 拉取完整定义,再合并增量提交
26296
+ if (!updates.id) {
26297
+ throw new Error('bpm-dev update-definition requires --id to locate and load the full definition.');
26298
+ }
26299
+ const changedFields = Object.keys(updates).filter((key) => key !== 'id');
26300
+ if (changedFields.length === 0) {
26301
+ throw new Error('bpm-dev update-definition requires at least one field to update besides --id.');
26302
+ }
26303
+ logger_ts_1.loggerService.startLoading('Loading bpmDef detail for full definition');
26304
+ let outline;
26305
+ try {
26306
+ const detailResponse = await (0, bpm_def_service_ts_1.executeBpmDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('bpmDef', 'detail'), { id: updates.id });
26307
+ logger_ts_1.loggerService.stopLoading();
26308
+ const envelope = (detailResponse && typeof detailResponse === 'object')
26309
+ ? detailResponse
26310
+ : {};
26311
+ if (envelope.success !== true || !envelope.data?.outline) {
26312
+ throw new Error(`Failed to load full definition via bpmDef detail: ${envelope.message ?? 'outline missing'}.`);
26313
+ }
26314
+ outline = envelope.data.outline;
26315
+ }
26316
+ catch (error) {
26317
+ logger_ts_1.loggerService.stopLoading();
26318
+ throw error;
26319
+ }
26320
+ const data = { ...outline, ...updates };
26157
26321
  logger_ts_1.loggerService.startLoading('Executing bpmDef update-definition');
26158
26322
  try {
26159
26323
  const response = await (0, bpm_def_service_ts_1.executeBpmDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('bpmDef', 'updateDefinition'), data);
@@ -27968,19 +28132,29 @@ function formatUnknown(value) {
27968
28132
  /***/ 24814
27969
28133
  (__unused_webpack_module, exports, __webpack_require__) {
27970
28134
 
27971
- var __webpack_unused_export__;
27972
28135
 
27973
- __webpack_unused_export__ = ({ value: true });
28136
+ var __importDefault = (this && this.__importDefault) || function (mod) {
28137
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28138
+ };
28139
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
27974
28140
  exports.getObjectDescribeList = getObjectDescribeList;
27975
28141
  exports.filterObjectDescribeList = filterObjectDescribeList;
27976
28142
  exports.getObjectDescribeByApiName = getObjectDescribeByApiName;
27977
28143
  exports.downloadObjectDescribeByApiNames = downloadObjectDescribeByApiNames;
27978
28144
  exports.getRuntimeNamespaceList = getRuntimeNamespaceList;
28145
+ exports.downloadInitMetadata = downloadInitMetadata;
27979
28146
  exports.toObjectSearchSummary = toObjectSearchSummary;
27980
28147
  exports.isExactObjectApiNameMatch = isExactObjectApiNameMatch;
27981
28148
  exports.extractObjectDescribe = extractObjectDescribe;
27982
- const request_ts_1 = __webpack_require__(83733);
28149
+ const node_path_1 = __importDefault(__webpack_require__(76760));
28150
+ const request_execute_ts_1 = __webpack_require__(4839);
28151
+ const request_execute_command_paths_ts_1 = __webpack_require__(23634);
27983
28152
  const download_ts_1 = __webpack_require__(15142);
28153
+ const logger_ts_1 = __webpack_require__(87562);
28154
+ const layout_list_ts_1 = __webpack_require__(95164);
28155
+ const apl_create_ts_1 = __webpack_require__(79921);
28156
+ const types_ts_1 = __webpack_require__(74709);
28157
+ const dev_metadata_workspace_ts_1 = __webpack_require__(90328);
27984
28158
  function buildObjectSearchPayload(type) {
27985
28159
  return {
27986
28160
  isIncludeFieldDescribe: false,
@@ -27993,24 +28167,37 @@ function buildObjectSearchPayload(type) {
27993
28167
  }
27994
28168
  async function getObjectDescribeList(options = {}) {
27995
28169
  const items = [];
27996
- if (options.type) {
27997
- const response = await request_ts_1.requestService.FHH({
27998
- url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeManageList',
27999
- data: buildObjectSearchPayload(options.type)
28000
- });
28001
- items.push(...response.objectDescribeList ?? []);
28002
- }
28003
- else {
28004
- const resp1 = await request_ts_1.requestService.FHH({
28005
- url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeManageList',
28006
- data: buildObjectSearchPayload('package')
28007
- });
28008
- items.push(...resp1.objectDescribeList ?? []);
28009
- const resp2 = await request_ts_1.requestService.FHH({
28010
- url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeManageList',
28011
- data: buildObjectSearchPayload('custom')
28012
- });
28013
- items.push(...resp2.objectDescribeList ?? []);
28170
+ const types = options.type ? [options.type] : ['package', 'custom'];
28171
+ for (const type of types) {
28172
+ const response = await (0, request_execute_ts_1.executeShareCliCommand)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('objectDev', 'queryDescribeManageList'), { ...buildObjectSearchPayload(type), includeControlLevel: true });
28173
+ const root = (0, types_ts_1.narrowObjectDevResponse)(response);
28174
+ if (root?.success !== true || root.code !== 'OK') {
28175
+ throw new Error(typeof root?.message === 'string' ? root.message : 'Object list request failed.');
28176
+ }
28177
+ const level1 = (0, types_ts_1.narrowObjectDevResponse)(root.data);
28178
+ const level2 = (0, types_ts_1.narrowObjectDevResponse)(level1?.data);
28179
+ const objectList = (0, types_ts_1.narrowObjectDevResponse)(level2?.objectDescribeList);
28180
+ if (!objectList) {
28181
+ throw new Error(`Object list response is missing objectDescribeList (type=${type}).`);
28182
+ }
28183
+ for (const item of objectList) {
28184
+ const apiName = typeof item.api_name === 'string' ? item.api_name : '';
28185
+ if (!apiName)
28186
+ continue;
28187
+ items.push({
28188
+ ...item,
28189
+ api_name: apiName,
28190
+ display_name: typeof item.display_name === 'string' ? item.display_name : undefined,
28191
+ display_name_r: typeof item.display_name_r === 'string' ? item.display_name_r : undefined,
28192
+ package: typeof item.package === 'string' ? item.package : undefined,
28193
+ package_name: typeof item.package_name === 'string' ? item.package_name : undefined,
28194
+ is_udef: typeof item.is_udef === 'boolean' ? item.is_udef : undefined,
28195
+ is_active: typeof item.is_active === 'boolean' ? item.is_active : undefined,
28196
+ version: typeof item.version === 'number' || typeof item.version === 'string' ? item.version : undefined,
28197
+ description: typeof item.description === 'string' ? item.description : undefined,
28198
+ define_type: typeof item.define_type === 'string' ? item.define_type : undefined
28199
+ });
28200
+ }
28014
28201
  }
28015
28202
  return items;
28016
28203
  }
@@ -28024,18 +28211,48 @@ function filterObjectDescribeList(items, query) {
28024
28211
  .sort((left, right) => compareObjectSearchItems(left, right, normalizedQuery));
28025
28212
  }
28026
28213
  async function getObjectDescribeByApiName(apiName) {
28027
- return request_ts_1.requestService.FHH({
28028
- url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeByApiName',
28029
- data: {
28030
- describe_apiname: apiName,
28031
- include_layout: true,
28032
- layout_type: 'detail',
28033
- get_label_direct: true,
28034
- include_describe_extra: false,
28035
- include_fields_extra: false,
28036
- check_cross_filter: false
28037
- }
28038
- });
28214
+ const response = await (0, request_execute_ts_1.executeShareCliCommand)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('objectDev', 'queryDescribeListByApiName'), { describe_apiname_list: [apiName], excludeBigObject: true, include_describe_extra: true });
28215
+ const root = (0, types_ts_1.narrowObjectDevResponse)(response);
28216
+ if (root?.success !== true || root.code !== 'OK') {
28217
+ throw new Error(typeof root?.message === 'string' ? root.message : 'Object describe request failed.');
28218
+ }
28219
+ const level1 = (0, types_ts_1.narrowObjectDevResponse)(root?.data);
28220
+ const level2 = (0, types_ts_1.narrowObjectDevResponse)(level1?.data);
28221
+ const describeList = (0, types_ts_1.narrowObjectDevResponse)(level2?.objectDescribeList);
28222
+ if (!describeList) {
28223
+ throw new Error(`Object describe response is missing objectDescribeList: ${apiName}`);
28224
+ }
28225
+ const describe = describeList[0];
28226
+ if (!describe || typeof describe.api_name !== 'string') {
28227
+ throw new Error(`Object describe not found: ${apiName}`);
28228
+ }
28229
+ const fields = [];
28230
+ const fieldMap = (0, types_ts_1.narrowObjectDevResponse)(describe.fields);
28231
+ for (const [fieldApiName, value] of Object.entries(fieldMap ?? {})) {
28232
+ const field = (0, types_ts_1.narrowObjectDevResponse)(value);
28233
+ if (field)
28234
+ fields.push({ ...field, api_name: fieldApiName });
28235
+ }
28236
+ const layouts = await (0, layout_list_ts_1.layoutListService)([apiName], 'detail');
28237
+ if (layouts.errorMessages.length) {
28238
+ throw new Error(layouts.errorMessages.join('; '));
28239
+ }
28240
+ const selectedLayout = layouts.layouts.find((item) => item.isDefault === 'true') ?? layouts.layouts[0];
28241
+ const layoutContent = selectedLayout?.content;
28242
+ return {
28243
+ objectDescribe: { ...describe, api_name: describe.api_name, fields },
28244
+ layout: layoutContent
28245
+ ? {
28246
+ api_name: selectedLayout.apiName,
28247
+ display_name: selectedLayout.displayName,
28248
+ layout_type: selectedLayout.layoutType,
28249
+ is_default: selectedLayout.isDefault === 'true',
28250
+ ref_object_api_name: typeof layoutContent.ref_object_api_name === 'string'
28251
+ ? layoutContent.ref_object_api_name
28252
+ : undefined
28253
+ }
28254
+ : undefined
28255
+ };
28039
28256
  }
28040
28257
  async function downloadObjectDescribeByApiNames(apiNames, options) {
28041
28258
  const files = apiNames.map((apiName) => ({
@@ -28052,14 +28269,58 @@ async function downloadObjectDescribeByApiNames(apiNames, options) {
28052
28269
  });
28053
28270
  }
28054
28271
  async function getRuntimeNamespaceList() {
28055
- const response = await request_ts_1.requestService.FHH({
28056
- url: '/EM1HFUNC/runtime/namespace',
28057
- data: {}
28058
- });
28059
- const namespaces = extractNamespaceArray(response);
28272
+ const response = await (0, apl_create_ts_1.getAplNamespaceOptionsNew)();
28273
+ const namespaces = response.namespaces.map((item) => item.value).filter(Boolean);
28060
28274
  return {
28061
28275
  namespaces,
28062
- raw: response
28276
+ raw: response.raw
28277
+ };
28278
+ }
28279
+ async function downloadInitMetadata(context) {
28280
+ const metadataRoot = node_path_1.default.join(context.settings.settingsDir, 'dev-metadata');
28281
+ const objectsDir = node_path_1.default.join(metadataRoot, 'objects');
28282
+ const namespacesDir = node_path_1.default.join(metadataRoot, 'namespaces');
28283
+ const failures = [];
28284
+ logger_ts_1.loggerService.info('Downloading metadata...');
28285
+ const [items, namespaceResult] = await Promise.all([
28286
+ getObjectDescribeList(),
28287
+ getRuntimeNamespaceList()
28288
+ ]);
28289
+ const sortedItems = filterObjectDescribeList(items);
28290
+ if (!sortedItems.length) {
28291
+ throw new Error('Object list was empty; metadata download was not completed.');
28292
+ }
28293
+ await (0, dev_metadata_workspace_ts_1.writeObjectDescribeIndex)(objectsDir, sortedItems);
28294
+ const result = await downloadObjectDescribeByApiNames(sortedItems.map((item) => item.api_name), {
28295
+ title: 'Downloading object metadata...',
28296
+ summaryName: 'Downloading object describe files',
28297
+ concurrency: 6,
28298
+ delayMs: 120
28299
+ });
28300
+ for (const failure of result.failures) {
28301
+ failures.push(`${failure.fileName}: ${failure.message}`);
28302
+ }
28303
+ const layoutsMissing = result.values
28304
+ .filter((item) => !item.infoResult.layout)
28305
+ .map((item) => item.apiName);
28306
+ await Promise.all(result.values.map((item) => (0, dev_metadata_workspace_ts_1.writeObjectDescribeFile)(objectsDir, item.infoResult)));
28307
+ await (0, dev_metadata_workspace_ts_1.writeNamespaceMetadataFile)(namespacesDir, namespaceResult.raw);
28308
+ const success = result.failed === 0;
28309
+ logger_ts_1.loggerService.success(`Metadata download complete: objects=${result.succeeded}, failed=${result.failed}, namespaces=${namespaceResult.namespaces.length}`);
28310
+ if (failures.length) {
28311
+ logger_ts_1.loggerService.warn(`Objects without complete metadata: ${failures.map((item) => item.split(':', 1)[0]).join(', ')}`);
28312
+ }
28313
+ if (layoutsMissing.length) {
28314
+ logger_ts_1.loggerService.warn(`No detail layout returned for objects: ${layoutsMissing.join(', ')}`);
28315
+ }
28316
+ return {
28317
+ success,
28318
+ objectsFound: sortedItems.length,
28319
+ objectsWritten: result.succeeded,
28320
+ objectsFailed: result.failed,
28321
+ namespaces: namespaceResult.namespaces.length,
28322
+ failures,
28323
+ layoutsMissing
28063
28324
  };
28064
28325
  }
28065
28326
  function toObjectSearchSummary(item) {
@@ -28087,35 +28348,6 @@ function extractObjectDescribe(result) {
28087
28348
  }
28088
28349
  return result.objectDescribe;
28089
28350
  }
28090
- function extractNamespaceArray(response) {
28091
- if (Array.isArray(response)) {
28092
- return normalizeNamespaceArray(response);
28093
- }
28094
- if (response && typeof response === 'object') {
28095
- const candidate = response;
28096
- const listCandidate = candidate.namespaceList ?? candidate.namespaces ?? candidate.list ?? candidate.data ?? candidate.value;
28097
- if (Array.isArray(listCandidate)) {
28098
- return normalizeNamespaceArray(listCandidate);
28099
- }
28100
- }
28101
- return [];
28102
- }
28103
- function normalizeNamespaceArray(items) {
28104
- const values = items
28105
- .map((item) => {
28106
- if (typeof item === 'string') {
28107
- return item.trim();
28108
- }
28109
- if (item && typeof item === 'object') {
28110
- const record = item;
28111
- const candidate = record.namespace ?? record.name ?? record.apiName ?? record.value;
28112
- return typeof candidate === 'string' ? candidate.trim() : '';
28113
- }
28114
- return '';
28115
- })
28116
- .filter(Boolean);
28117
- return Array.from(new Set(values)).sort((a, b) => a.localeCompare(b));
28118
- }
28119
28351
  function compareObjectSearchItems(left, right, normalizedQuery) {
28120
28352
  const leftScore = getObjectSearchScore(left, normalizedQuery);
28121
28353
  const rightScore = getObjectSearchScore(right, normalizedQuery);
@@ -29403,13 +29635,13 @@ const node_path_1 = __importDefault(__webpack_require__(76760));
29403
29635
  const prompts_1 = __webpack_require__(53503);
29404
29636
  const logger_ts_1 = __webpack_require__(87562);
29405
29637
  const request_ts_1 = __webpack_require__(83733);
29638
+ const request_channel_ts_1 = __webpack_require__(43355);
29406
29639
  const sharecrm_session_ts_1 = __webpack_require__(47166);
29407
29640
  const file_ts_1 = __webpack_require__(57452);
29408
29641
  const pkgMeta_ts_1 = __webpack_require__(48559);
29409
29642
  const apl_command_ts_1 = __webpack_require__(10508);
29410
29643
  const docs_service_ts_1 = __webpack_require__(37798);
29411
29644
  const dev_metadata_service_ts_1 = __webpack_require__(24814);
29412
- const dev_metadata_workspace_ts_1 = __webpack_require__(90328);
29413
29645
  const pwc_command_ts_1 = __webpack_require__(10372);
29414
29646
  const pwc_types_ts_1 = __webpack_require__(55844);
29415
29647
  const index_ts_1 = __webpack_require__(23916);
@@ -29681,7 +29913,7 @@ function createAplPullContext(context) {
29681
29913
  }
29682
29914
  async function runInitAplPull(context) {
29683
29915
  logger_ts_1.loggerService.info('Pulling all APL functions...');
29684
- await (0, apl_command_ts_1.aplPullCommand)(undefined, createAplPullContext(context), { all: true });
29916
+ return (0, apl_command_ts_1.aplPullCommand)(undefined, createAplPullContext(context), { all: true });
29685
29917
  }
29686
29918
  async function runInitPwcPull(context) {
29687
29919
  logger_ts_1.loggerService.info('Pulling all PWC components...');
@@ -29707,39 +29939,17 @@ async function runInitSpec(context, options, agentName) {
29707
29939
  showLoading: false
29708
29940
  });
29709
29941
  }
29710
- async function runInitMetadataDownload(context) {
29711
- const metadataRoot = node_path_1.default.join(context.settings.settingsDir, 'dev-metadata');
29712
- const objectsDir = node_path_1.default.join(metadataRoot, 'objects');
29713
- const namespacesDir = node_path_1.default.join(metadataRoot, 'namespaces');
29714
- logger_ts_1.loggerService.info('Downloading metadata...');
29715
- const [items, namespaceResult] = await Promise.all([
29716
- (0, dev_metadata_service_ts_1.getObjectDescribeList)(),
29717
- (0, dev_metadata_service_ts_1.getRuntimeNamespaceList)()
29718
- ]);
29719
- const sortedItems = (0, dev_metadata_service_ts_1.filterObjectDescribeList)(items);
29720
- await (0, dev_metadata_workspace_ts_1.writeObjectDescribeIndex)(objectsDir, sortedItems);
29721
- let succeeded = 0;
29722
- let failed = 0;
29723
- for (const item of sortedItems) {
29724
- try {
29725
- const infoResult = await (0, dev_metadata_service_ts_1.getObjectDescribeByApiName)(item.api_name);
29726
- await (0, dev_metadata_workspace_ts_1.writeObjectDescribeFile)(objectsDir, infoResult);
29727
- succeeded += 1;
29728
- }
29729
- catch {
29730
- failed += 1;
29731
- }
29732
- }
29733
- await (0, dev_metadata_workspace_ts_1.writeNamespaceMetadataFile)(namespacesDir, namespaceResult.raw);
29734
- logger_ts_1.loggerService.success(`Metadata download complete: objects=${succeeded}${failed ? `, failed=${failed}` : ''}, namespaces=${namespaceResult.namespaces.length}`);
29735
- }
29736
29942
  async function runInitDownloadsConcurrently(context, options, pullSelections, agentName, hasCredentials) {
29737
29943
  const tasks = [];
29738
29944
  if (!hasCredentials && (pullSelections.pullAllApl || pullSelections.pullAllPwc)) {
29739
29945
  // 凭证未就绪(certificate 未配置且工作区未登录):远端拉取类任务全部跳过,
29740
29946
  // 文档/spec 模板(公网资源)照常下载
29741
29947
  logger_ts_1.loggerService.warn('Credentials not ready (no certificate configured and not logged in). Skipping remote pulls.');
29742
- logger_ts_1.loggerService.info('Run `sharedev auth login` first, then `sharedev apl pull --all` / `sharedev pwc pull --all --type <component|plugin>`.');
29948
+ logger_ts_1.loggerService.info('Run `sharedev auth login` to sign in and continue pulling the resources selected above.');
29949
+ await (0, file_ts_1.writeJsonFile)(node_path_1.default.join(context.settings.settingsDir, 'pending-pulls.json'), {
29950
+ ...pullSelections,
29951
+ pullMetadata: true
29952
+ });
29743
29953
  }
29744
29954
  if (pullSelections.pullAllApl || pullSelections.pullAllPwc) {
29745
29955
  tasks.push(runInitDocsDownload(context, pullSelections));
@@ -29749,10 +29959,18 @@ async function runInitDownloadsConcurrently(context, options, pullSelections, ag
29749
29959
  }
29750
29960
  if (hasCredentials && (pullSelections.pullAllApl || pullSelections.pullAllPwc)) {
29751
29961
  request_ts_1.requestService.configure(context.settings);
29752
- tasks.push(runInitMetadataDownload(context));
29962
+ tasks.push((0, dev_metadata_service_ts_1.downloadInitMetadata)(context).then((result) => {
29963
+ if (!result.success) {
29964
+ throw new Error(`Metadata pull incomplete: ${result.objectsFailed} object(s) failed.`);
29965
+ }
29966
+ }));
29753
29967
  }
29754
29968
  if (hasCredentials && pullSelections.pullAllApl) {
29755
- tasks.push(runInitAplPull(context));
29969
+ tasks.push(runInitAplPull(context).then((success) => {
29970
+ if (!success) {
29971
+ throw new Error('APL pull incomplete; some function details were not downloaded.');
29972
+ }
29973
+ }));
29756
29974
  }
29757
29975
  if (hasCredentials && pullSelections.pullAllPwc) {
29758
29976
  tasks.push(runInitPwcPull(context));
@@ -29786,12 +30004,20 @@ async function initProjectCommand(runtimeContext, options) {
29786
30004
  await (0, file_ts_1.ensureDir)(workspaceDir);
29787
30005
  await initGitWorkspace(workspaceDir, options);
29788
30006
  await (0, file_ts_1.writeJsonFile)(settingsPath, payload);
30007
+ const initContext = createInitRuntimeContext(runtimeContext, workspaceDir, settingsDir, settingsPath, payload);
30008
+ // 让 init 后续的请求使用刚创建工作区的证书和登录态目录。
30009
+ request_ts_1.requestService.configure(initContext.settings);
30010
+ (0, request_channel_ts_1.configureRequestChannel)(initContext.settings);
30011
+ (0, sharecrm_session_ts_1.configureSharecrmSession)(initContext.settings);
29789
30012
  logger_ts_1.loggerService.success(`Initialization completed: ${settingsPath}`);
29790
30013
  logger_ts_1.loggerService.info(`Workspace folder created: ${workspaceDir}`);
29791
30014
  // 凭证就绪判定:本次配置了 certificate,或工作区已存在 sharecrm 登录态(--force 重建场景)
29792
30015
  const hasCredentials = Boolean(payload.certificate?.trim()) || Boolean((0, sharecrm_session_ts_1.readSharedevAuthSession)(settingsDir)?.accessToken);
29793
- const initContext = createInitRuntimeContext(runtimeContext, workspaceDir, settingsDir, settingsPath, payload);
29794
30016
  await runInitDownloadsConcurrently(initContext, options, pullSelections, agentName, hasCredentials);
30017
+ // 有凭证时初始化拉取已经由本次 init 执行,不保留之前可能存在的待拉取标记。
30018
+ if (hasCredentials) {
30019
+ await (0, file_ts_1.removePath)(node_path_1.default.join(settingsDir, 'pending-pulls.json'));
30020
+ }
29795
30021
  }
29796
30022
 
29797
30023
 
@@ -41724,9 +41950,9 @@ async function objectPullService(shouldQueryAll, queryType = null, apiName, skip
41724
41950
  logger_ts_1.loggerService.info(`Skipped public object count: ${skippedPublicApiNames.length}`);
41725
41951
  }
41726
41952
  }
41727
- // 50个分批拉取
41953
+ // 20个分批拉取
41728
41954
  const apiNamesListGroups = apiNamesList.reduce((acc, item, index) => {
41729
- const groupIndex = Math.floor(index / 50);
41955
+ const groupIndex = Math.floor(index / 20);
41730
41956
  if (!acc[groupIndex]) {
41731
41957
  acc[groupIndex] = [];
41732
41958
  }
@@ -45967,6 +46193,7 @@ const logger_ts_1 = __webpack_require__(87562);
45967
46193
  const request_ts_1 = __webpack_require__(83733);
45968
46194
  const sharecrm_session_ts_1 = __webpack_require__(47166);
45969
46195
  const pwc_service_ts_1 = __webpack_require__(63358);
46196
+ const pwc_pull_ts_1 = __webpack_require__(42094);
45970
46197
  const pwc_types_ts_1 = __webpack_require__(55844);
45971
46198
  const pwc_mateXml_ts_1 = __webpack_require__(53683);
45972
46199
  const pwc_workspace_ts_1 = __webpack_require__(64635);
@@ -46008,47 +46235,18 @@ async function pwcPullCommand(apiName, options, context) {
46008
46235
  if (options.type !== 'component' && options.type !== 'plugin') {
46009
46236
  throw new Error(`Invalid type: ${options.type}, accept 'component|plugin'.`);
46010
46237
  }
46011
- if (all) {
46012
- logger_ts_1.loggerService.startLoading(`Fetching PWC resources for type=${options.type}`);
46013
- const components = await (0, pwc_service_ts_1.fetchCodeByType)(options.type);
46014
- // if (!components.length) {
46015
- // loggerService.stopLoading();
46016
- // throw new Error(`No PWC resources found for type=${options.type}.`);
46017
- // }
46018
- const summary = {
46019
- target: components.length,
46020
- success: 0,
46021
- failed: 0
46022
- };
46023
- logger_ts_1.loggerService.updateLoading(`Found ${components.length} PWC resources, pulling...`);
46024
- for (const component of components) {
46025
- try {
46026
- assertPwcComponentType(component, options.type);
46027
- const componentRoot = await hydrateAndWritePwcComponent(context, component);
46028
- summary.success += 1;
46029
- logger_ts_1.loggerService.success(`Pulled PWC resource ${component.apiName} to ${componentRoot}`);
46030
- }
46031
- catch (error) {
46032
- summary.failed += 1;
46033
- const message = error instanceof Error ? error.message : String(error);
46034
- logger_ts_1.loggerService.error(`Failed to pull PWC resource ${component.apiName || '<unknown>'}: ${message}`);
46035
- }
46036
- }
46037
- logger_ts_1.loggerService.stopLoading();
46038
- logger_ts_1.loggerService.info(`PWC pull completed: target=${summary.target}, success=${summary.success}, failed=${summary.failed}`);
46039
- return;
46238
+ // 拉取 PWC 资源:统一走 open API 链路(code-dev vscode-extension download-code),
46239
+ // 不再依赖 FHH 下载通道;失败信息由 service 汇总,这里统一打印。
46240
+ const result = await (0, pwc_pull_ts_1.pwcPullNewService)(normalizedApiName, options.type, context, { all });
46241
+ if (result.errorMessages.length) {
46242
+ result.errorMessages.forEach((error) => logger_ts_1.loggerService.error(error));
46040
46243
  }
46041
- logger_ts_1.loggerService.startLoading(`Fetching PWC resource ${normalizedApiName}`);
46042
- const components = await (0, pwc_service_ts_1.fetchCode)(options.type, normalizedApiName);
46043
- if (!components.length) {
46044
- logger_ts_1.loggerService.stopLoading();
46045
- throw new Error(`PWC resource not found: ${normalizedApiName}`);
46244
+ if (all) {
46245
+ logger_ts_1.loggerService.info(`PWC pull completed: target=${result.found}, success=${result.written}, failed=${result.failed}`);
46246
+ return result.failed === 0;
46046
46247
  }
46047
- const component = components[0];
46048
- assertPwcComponentType(component, options.type);
46049
- const componentRoot = await hydrateAndWritePwcComponent(context, component);
46050
- logger_ts_1.loggerService.stopLoading();
46051
- logger_ts_1.loggerService.success(`Pulled PWC resource ${normalizedApiName} to ${componentRoot}`);
46248
+ logger_ts_1.loggerService.success(`Pulled PWC resource ${result.apiNames[0]} to ${result.componentRoot}`);
46249
+ return true;
46052
46250
  }
46053
46251
  async function pwcCreateCommand(options, context) {
46054
46252
  logger_ts_1.loggerService.startLoading('Preparing PWC create');
@@ -47318,9 +47516,9 @@ function validatePwcMateXmlContent(input) {
47318
47516
  var __webpack_unused_export__;
47319
47517
 
47320
47518
  __webpack_unused_export__ = ({ value: true });
47321
- exports.assertPwcFileUploadChannel = assertPwcFileUploadChannel;
47519
+ exports.uploadPwcFileList = uploadPwcFileList;
47322
47520
  exports.fetchCode = fetchCode;
47323
- exports.fetchCodeByType = fetchCodeByType;
47521
+ __webpack_unused_export__ = fetchCodeByType;
47324
47522
  exports.updateCodeSource = updateCodeSource;
47325
47523
  exports.buildCode = buildCode;
47326
47524
  exports.getBuildResult = getBuildResult;
@@ -47333,37 +47531,25 @@ exports.enablePwcResource = enablePwcResource;
47333
47531
  exports.getUrlByApiName = getUrlByApiName;
47334
47532
  const request_ts_1 = __webpack_require__(83733);
47335
47533
  const request_channel_ts_1 = __webpack_require__(43355);
47336
- const logger_ts_1 = __webpack_require__(87562);
47534
+ const pwc_download_file_ts_1 = __webpack_require__(95960);
47535
+ const pwc_upload_file_ts_1 = __webpack_require__(10771);
47337
47536
  /**
47338
- * PWC 命令的通道保护:openapi 能力未就绪期间——
47339
- * 有 certificate 则 warn 后降级走 FHH(避免登录态+certificate 并存的功能回退);
47340
- * 无 certificate 抛错引导配置。待服务端 download-file 修复后移除。
47537
+ * PWC 命令的通道保护:以下接口仅有 FHH(企业网关,certificate 鉴权)实现,
47538
+ * 登录态(open API)下不回退证书通道——直接报错,说明该能力当前仅在证书模式可用。
47341
47539
  */
47342
47540
  function assertPwcChannelOrFallback() {
47343
47541
  if ((0, request_channel_ts_1.resolveRequestChannel)() !== 'openapi') {
47344
47542
  return;
47345
47543
  }
47346
- if ((0, request_channel_ts_1.hasCertificateCredential)()) {
47347
- logger_ts_1.loggerService.warn('PWC commands run via certificate channel (sharecrm login channel not ready for PWC file download).');
47348
- return;
47349
- }
47350
- throw new Error('PWC commands are not yet available on the sharecrm login channel ' +
47351
- '(Open API download-file returns empty content and has no URL query, 2026-10-21 measured). ' +
47352
- 'Use certificate mode (.sharedev/settings.json) for PWC commands.');
47544
+ throw new Error('This PWC operation is only available in certificate mode (it is not exposed on the sharecrm login channel yet). ' +
47545
+ 'Use a workspace configured with certificate in .sharedev/settings.json.');
47353
47546
  }
47354
- /**
47355
- * PWC 文件上传环节的通道断言:*-new 链路主体走 openapi(code-dev 命令),
47356
- * 但源码包上传(uploadFileList)仍依赖 FHH——纯登录态时给出明确引导而非服务端原始报错。
47357
- */
47358
- function assertPwcFileUploadChannel() {
47547
+ /** PWC 文件上传:登录态走操作中心,证书态保留 FHH 上传接口。 */
47548
+ async function uploadPwcFileList(fileList) {
47359
47549
  if ((0, request_channel_ts_1.resolveRequestChannel)() !== 'openapi') {
47360
- return;
47550
+ return request_ts_1.requestService.uploadFileList(fileList);
47361
47551
  }
47362
- if ((0, request_channel_ts_1.hasCertificateCredential)()) {
47363
- return;
47364
- }
47365
- throw new Error('PWC file upload requires the certificate channel (not yet available on the sharecrm login channel). ' +
47366
- 'Use certificate mode (.sharedev/settings.json) for PWC push/deploy/create.');
47552
+ return Promise.all(fileList.map((file) => (0, pwc_upload_file_ts_1.requestPwcUploadFileExecute)(file.fileName, file.base64String)));
47367
47553
  }
47368
47554
  async function fetchCode(type, apiName) {
47369
47555
  assertPwcChannelOrFallback();
@@ -47462,6 +47648,22 @@ async function hydrateFile(file, groupName, apiName) {
47462
47648
  if (!nPath) {
47463
47649
  throw new Error(`Cannot download ${groupName} file ${file.fileName || '<unknown>'} for PWC resource ${apiName}: missing nPath/filePath.`);
47464
47650
  }
47651
+ // 登录态(open API):只走操作中心指令 code-dev vscode-extension download-file,不回退 FHH。
47652
+ // 服务端返回空内容时,把 traceId 一并带出,便于到服务端操作日志定位。
47653
+ if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
47654
+ const { base64, traceId } = await (0, pwc_download_file_ts_1.requestPwcDownloadFileExecute)(nPath);
47655
+ if (!base64) {
47656
+ throw new Error(`Failed to download ${groupName} file ${file.fileName || '<unknown>'} for PWC resource ${apiName} (${nPath}): ` +
47657
+ `Open API command "code-dev vscode-extension download-file" returned an empty content.` +
47658
+ (traceId ? ` traceId: ${traceId}` : ''));
47659
+ }
47660
+ return {
47661
+ fileName: file.fileName,
47662
+ path: file.path,
47663
+ content: Buffer.from(base64, 'base64')
47664
+ };
47665
+ }
47666
+ // 证书态(FHH):走企业网关的 downloadFile
47465
47667
  try {
47466
47668
  const content = await request_ts_1.requestService.downloadFile(nPath);
47467
47669
  return {
@@ -48023,10 +48225,9 @@ exports.pwcCreateNewService = pwcCreateNewService;
48023
48225
  const node_path_1 = __importDefault(__webpack_require__(76760));
48024
48226
  const request_execute_command_paths_ts_1 = __webpack_require__(23634);
48025
48227
  const logger_ts_1 = __webpack_require__(87562);
48026
- const request_ts_1 = __webpack_require__(83733);
48027
48228
  const file_ts_1 = __webpack_require__(57452);
48028
48229
  const zip_ts_1 = __webpack_require__(89139);
48029
- const request_ts_2 = __webpack_require__(35604);
48230
+ const request_ts_1 = __webpack_require__(35604);
48030
48231
  const types_ts_1 = __webpack_require__(6500);
48031
48232
  const pwc_service_ts_1 = __webpack_require__(63358);
48032
48233
  const pwc_workspace_ts_1 = __webpack_require__(64635);
@@ -48034,7 +48235,7 @@ const pwc_types_ts_1 = __webpack_require__(55844);
48034
48235
  /**
48035
48236
  * 操作中心接口包装调用:objectDev queryDescribeManageList(create 对象多选,payload 与现网 getObjectApiNames 一致)
48036
48237
  */
48037
- const requestObjectDescribeManageListExecute = async () => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('objectDev', 'queryDescribeManageList'), {
48238
+ const requestObjectDescribeManageListExecute = async () => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('objectDev', 'queryDescribeManageList'), {
48038
48239
  isIncludeFieldDescribe: false,
48039
48240
  isIncludeSystemObj: true,
48040
48241
  isIncludeUnActived: true,
@@ -48045,23 +48246,23 @@ const requestObjectDescribeManageListExecute = async () => await (0, request_ts_
48045
48246
  /**
48046
48247
  * 操作中心接口包装调用:component create(--data 整包)
48047
48248
  */
48048
- const requestComponentCreateExecute = async (data) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentCreate'), data);
48249
+ const requestComponentCreateExecute = async (data) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentCreate'), data);
48049
48250
  /**
48050
48251
  * 操作中心接口包装调用:plugin create(--data 整包)
48051
48252
  */
48052
- const requestPluginCreateExecute = async (data) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'pluginCreate'), data);
48253
+ const requestPluginCreateExecute = async (data) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'pluginCreate'), data);
48053
48254
  /**
48054
48255
  * 操作中心接口包装调用:component enable
48055
48256
  */
48056
- const requestComponentEnableExecute = async (apiName) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentEnable'), { apiName });
48257
+ const requestComponentEnableExecute = async (apiName) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentEnable'), { apiName });
48057
48258
  /**
48058
48259
  * 操作中心接口包装调用:plugin enable
48059
48260
  */
48060
- const requestPluginEnableExecute = async (apiName) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'pluginEnable'), { apiName });
48261
+ const requestPluginEnableExecute = async (apiName) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'pluginEnable'), { apiName });
48061
48262
  /**
48062
48263
  * 操作中心接口包装调用:vscode-extension download-code
48063
48264
  */
48064
- const requestVsceDownloadCodeExecute = async (apiName, type, downloadAll) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'vsceDownloadCode'), {
48265
+ const requestVsceDownloadCodeExecute = async (apiName, type, downloadAll) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'vsceDownloadCode'), {
48065
48266
  apiName,
48066
48267
  type,
48067
48268
  downloadAll
@@ -48093,7 +48294,7 @@ const PLUGIN_DEFAULT_INDEX_JS = `export default class CustomPlugin {
48093
48294
  */
48094
48295
  async function getPwcObjectApiNamesNew() {
48095
48296
  const response = await requestObjectDescribeManageListExecute();
48096
- const result = await (0, request_ts_2.extractPwcServiceResult)(response, (res) => {
48297
+ const result = await (0, request_ts_1.extractPwcServiceResult)(response, (res) => {
48097
48298
  const level1 = (0, types_ts_1.narrowPwcResponse)(res.data);
48098
48299
  const level2 = (0, types_ts_1.narrowPwcResponse)(level1?.data) ?? level1;
48099
48300
  const list = (0, types_ts_1.narrowPwcResponse)(level2?.objectDescribeList) ?? [];
@@ -48130,9 +48331,8 @@ async function pwcCreateNewService(input, context) {
48130
48331
  let remoteFiles = [];
48131
48332
  if (useAppletZip) {
48132
48333
  logger_ts_1.loggerService.updateLoading('Uploading initialization template archive');
48133
- (0, pwc_service_ts_1.assertPwcFileUploadChannel)();
48134
48334
  const zipBuffer = await (0, zip_ts_1.createZipBufferFromTextFiles)(input.templateFiles);
48135
- const [remoteZip] = await request_ts_1.requestService.uploadFileList([
48335
+ const [remoteZip] = await (0, pwc_service_ts_1.uploadPwcFileList)([
48136
48336
  {
48137
48337
  fileName: `${input.apiName}.zip`,
48138
48338
  base64String: zipBuffer.toString('base64')
@@ -48146,8 +48346,7 @@ async function pwcCreateNewService(input, context) {
48146
48346
  }
48147
48347
  else {
48148
48348
  logger_ts_1.loggerService.updateLoading('Uploading initialization template files');
48149
- (0, pwc_service_ts_1.assertPwcFileUploadChannel)();
48150
- const uploaded = await request_ts_1.requestService.uploadFileList(input.templateFiles.map((file) => ({
48349
+ const uploaded = await (0, pwc_service_ts_1.uploadPwcFileList)(input.templateFiles.map((file) => ({
48151
48350
  fileName: file.fileName,
48152
48351
  base64String: Buffer.from(file.content, 'utf8').toString('base64')
48153
48352
  })));
@@ -48212,7 +48411,7 @@ async function pwcCreateNewService(input, context) {
48212
48411
  const createResponse = input.kind === 'plugin'
48213
48412
  ? await requestPluginCreateExecute(payload)
48214
48413
  : await requestComponentCreateExecute(payload);
48215
- const created = await (0, request_ts_2.extractPwcServiceResult)(createResponse, (response) => response);
48414
+ const created = await (0, request_ts_1.extractPwcServiceResult)(createResponse, (response) => response);
48216
48415
  if (!created.success) {
48217
48416
  throw new Error(created.errorMessage);
48218
48417
  }
@@ -48221,7 +48420,7 @@ async function pwcCreateNewService(input, context) {
48221
48420
  const enableResponse = input.kind === 'plugin'
48222
48421
  ? await requestPluginEnableExecute(input.apiName)
48223
48422
  : await requestComponentEnableExecute(input.apiName);
48224
- const enabled = await (0, request_ts_2.extractPwcServiceResult)(enableResponse, (response) => response);
48423
+ const enabled = await (0, request_ts_1.extractPwcServiceResult)(enableResponse, (response) => response);
48225
48424
  if (!enabled.success) {
48226
48425
  throw new Error(enabled.errorMessage);
48227
48426
  }
@@ -48230,7 +48429,7 @@ async function pwcCreateNewService(input, context) {
48230
48429
  let pulled;
48231
48430
  for (let i = 1; i <= 8; i += 1) {
48232
48431
  const downloadResponse = await requestVsceDownloadCodeExecute(input.apiName, createdType, false);
48233
- const downloadResult = await (0, request_ts_2.extractPwcServiceResult)(downloadResponse, types_ts_1.extractPwcRecordArray);
48432
+ const downloadResult = await (0, request_ts_1.extractPwcServiceResult)(downloadResponse, types_ts_1.extractPwcRecordArray);
48234
48433
  if (!downloadResult.success) {
48235
48434
  throw new Error(downloadResult.errorMessage);
48236
48435
  }
@@ -48345,7 +48544,7 @@ async function pwcDeployNewService(apiName, type, context) {
48345
48544
  if (!buildId) {
48346
48545
  throw new Error('Deploy failed: server did not return buildId.');
48347
48546
  }
48348
- // 轮询构建结果:最多 180 次、间隔 1s;status 2 成功、3 失败
48547
+ // 轮询构建结果:部分环境以 status=2 表示成功,112 环境返回 status=3;优先识别构建日志。
48349
48548
  const maxAttempts = 180;
48350
48549
  for (let i = 1; i <= maxAttempts; i += 1) {
48351
48550
  const pollResponse = type === pwc_types_ts_1.PWCType.Plugin
@@ -48356,7 +48555,10 @@ async function pwcDeployNewService(apiName, type, context) {
48356
48555
  throw new Error(pollResult.errorMessage);
48357
48556
  }
48358
48557
  const status = (0, types_ts_1.readPwcNumber)(pollResult.data, 'status');
48359
- if (status === 2) {
48558
+ const output = (0, types_ts_1.readPwcText)(pollResult.data, 'buildResult');
48559
+ const succeeded = /\[INFO\]\s*build success/i.test(output);
48560
+ const failed = /\[ERROR\]|\[INFO\]\s*build failed/i.test(output);
48561
+ if (succeeded || (status === 2 && !failed)) {
48360
48562
  return {
48361
48563
  apiName,
48362
48564
  type,
@@ -48368,7 +48570,7 @@ async function pwcDeployNewService(apiName, type, context) {
48368
48570
  errorMessages
48369
48571
  };
48370
48572
  }
48371
- if (status === 3) {
48573
+ if ((status === 2 || status === 3) && (failed || !succeeded)) {
48372
48574
  throw new Error(`Deploy build failed: buildId=${buildId}`);
48373
48575
  }
48374
48576
  logger_ts_1.loggerService.updateLoading(`Waiting for build result... ${i}/${maxAttempts} (buildId=${buildId})`);
@@ -48380,6 +48582,45 @@ async function pwcDeployNewService(apiName, type, context) {
48380
48582
  }
48381
48583
 
48382
48584
 
48585
+ /***/ },
48586
+
48587
+ /***/ 95960
48588
+ (__unused_webpack_module, exports, __webpack_require__) {
48589
+
48590
+ var __webpack_unused_export__;
48591
+
48592
+ __webpack_unused_export__ = ({ value: true });
48593
+ exports.requestPwcDownloadFileExecute = requestPwcDownloadFileExecute;
48594
+ const request_execute_command_paths_ts_1 = __webpack_require__(23634);
48595
+ const openapi_request_ts_1 = __webpack_require__(59848);
48596
+ const types_ts_1 = __webpack_require__(6500);
48597
+ /**
48598
+ * open API 通道的源文件下载(code-dev vscode-extension download-file)。
48599
+ *
48600
+ * 入参 nPath 为必填字符串(服务端权威 usage:`--nPath <string>`)。
48601
+ * 2026-10-27 实测(fktest5642 / open.fxiaoke.com):返回 { base64String },文件内容可正常读取。
48602
+ * 若其他环境没有返回内容,这里同时回传 traceId,便于定位服务端操作日志。
48603
+ */
48604
+ async function requestPwcDownloadFileExecute(nPath) {
48605
+ let traceId;
48606
+ const content = await (0, openapi_request_ts_1.executeOpenApiCommand)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'vsceDownloadFile').join(' '), { nPath }, {
48607
+ onTraceId: (value) => {
48608
+ traceId = value;
48609
+ }
48610
+ });
48611
+ // 服务端可能直接返回 base64 文本,也可能是 { base64String } / { content } 等包装结构
48612
+ let base64;
48613
+ if (typeof content === 'string') {
48614
+ base64 = content || undefined;
48615
+ }
48616
+ else if (content && typeof content === 'object') {
48617
+ base64 =
48618
+ (0, types_ts_1.readPwcText)(content, 'base64String', 'base64_string', 'content', 'fileContent', 'file') || undefined;
48619
+ }
48620
+ return { base64, traceId };
48621
+ }
48622
+
48623
+
48383
48624
  /***/ },
48384
48625
 
48385
48626
  /***/ 32133
@@ -48676,8 +48917,7 @@ exports.getPwcConfigNew = getPwcConfigNew;
48676
48917
  exports.pwcPushNewService = pwcPushNewService;
48677
48918
  const request_execute_command_paths_ts_1 = __webpack_require__(23634);
48678
48919
  const logger_ts_1 = __webpack_require__(87562);
48679
- const request_ts_1 = __webpack_require__(83733);
48680
- const request_ts_2 = __webpack_require__(35604);
48920
+ const request_ts_1 = __webpack_require__(35604);
48681
48921
  const types_ts_1 = __webpack_require__(6500);
48682
48922
  const pwc_mateXml_ts_1 = __webpack_require__(53683);
48683
48923
  const pwc_service_ts_1 = __webpack_require__(63358);
@@ -48686,29 +48926,29 @@ const pwc_types_ts_1 = __webpack_require__(55844);
48686
48926
  /**
48687
48927
  * 操作中心接口包装调用:component get-config
48688
48928
  */
48689
- const requestComponentGetConfigExecute = async () => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentGetConfig'), {});
48929
+ const requestComponentGetConfigExecute = async () => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentGetConfig'), {});
48690
48930
  /**
48691
48931
  * 操作中心接口包装调用:component find-by-api-name
48692
48932
  */
48693
- const requestComponentFindByApiNameExecute = async (apiName) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentFindByApiName'), { apiName });
48933
+ const requestComponentFindByApiNameExecute = async (apiName) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentFindByApiName'), { apiName });
48694
48934
  /**
48695
48935
  * 操作中心接口包装调用:plugin find-by-api-name
48696
48936
  */
48697
- const requestPluginFindByApiNameExecute = async (apiName) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'pluginFindByApiName'), { apiName });
48937
+ const requestPluginFindByApiNameExecute = async (apiName) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'pluginFindByApiName'), { apiName });
48698
48938
  /**
48699
48939
  * 操作中心接口包装调用:component update(--data 整包)
48700
48940
  */
48701
- const requestComponentUpdateExecute = async (data) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentUpdate'), data);
48941
+ const requestComponentUpdateExecute = async (data) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'componentUpdate'), data);
48702
48942
  /**
48703
48943
  * 操作中心接口包装调用:plugin update(--data 整包)
48704
48944
  */
48705
- const requestPluginUpdateExecute = async (data) => await (0, request_ts_2.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'pluginUpdate'), data);
48945
+ const requestPluginUpdateExecute = async (data) => await (0, request_ts_1.requestPwcExecute)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'pluginUpdate'), data);
48706
48946
  /**
48707
48947
  * 查询 PWC 配置(push/create 共用 get-config)
48708
48948
  */
48709
48949
  async function getPwcConfigNew() {
48710
48950
  const response = await requestComponentGetConfigExecute();
48711
- const result = await (0, request_ts_2.extractPwcServiceResult)(response, types_ts_1.extractPwcConfig);
48951
+ const result = await (0, request_ts_1.extractPwcServiceResult)(response, types_ts_1.extractPwcConfig);
48712
48952
  if (!result.success) {
48713
48953
  throw new Error(result.errorMessage);
48714
48954
  }
@@ -48736,8 +48976,7 @@ async function pwcPushNewService(apiName, type, context) {
48736
48976
  const { readFile } = await Promise.resolve(/* import() */).then(() => (__webpack_require__(59031)));
48737
48977
  const zipBuffer = await readFile(appletZipPath);
48738
48978
  logger_ts_1.loggerService.updateLoading(`Uploading ${apiName}.zip`);
48739
- (0, pwc_service_ts_1.assertPwcFileUploadChannel)();
48740
- const [remoteZip] = await request_ts_1.requestService.uploadFileList([
48979
+ const [remoteZip] = await (0, pwc_service_ts_1.uploadPwcFileList)([
48741
48980
  {
48742
48981
  fileName: `${apiName}.zip`,
48743
48982
  base64String: zipBuffer.toString('base64')
@@ -48755,8 +48994,7 @@ async function pwcPushNewService(apiName, type, context) {
48755
48994
  bundle = await (0, pwc_workspace_ts_1.readLocalPwcUploadBundle)(context, type, apiName, (0, pwc_mateXml_ts_1.buildPwcTypeConstraints)(config));
48756
48995
  // 上传源码 / 静态资源 / fileTree
48757
48996
  logger_ts_1.loggerService.updateLoading(`Uploading ${bundle.uploadFiles.length} files`);
48758
- (0, pwc_service_ts_1.assertPwcFileUploadChannel)();
48759
- const uploaded = await request_ts_1.requestService.uploadFileList(bundle.uploadFiles.map((item) => ({
48997
+ const uploaded = await (0, pwc_service_ts_1.uploadPwcFileList)(bundle.uploadFiles.map((item) => ({
48760
48998
  fileName: item.fileName,
48761
48999
  base64String: item.base64String
48762
49000
  })));
@@ -48790,7 +49028,7 @@ async function pwcPushNewService(apiName, type, context) {
48790
49028
  const findResponse = type === pwc_types_ts_1.PWCType.Plugin
48791
49029
  ? await requestPluginFindByApiNameExecute(apiName)
48792
49030
  : await requestComponentFindByApiNameExecute(apiName);
48793
- const existing = await (0, request_ts_2.extractPwcServiceResult)(findResponse, types_ts_1.extractPwcRecord).then((result) => {
49031
+ const existing = await (0, request_ts_1.extractPwcServiceResult)(findResponse, types_ts_1.extractPwcRecord).then((result) => {
48794
49032
  if (!result.success) {
48795
49033
  throw new Error(result.errorMessage);
48796
49034
  }
@@ -48815,7 +49053,7 @@ async function pwcPushNewService(apiName, type, context) {
48815
49053
  const updateResponse = type === pwc_types_ts_1.PWCType.Plugin
48816
49054
  ? await requestPluginUpdateExecute(payload)
48817
49055
  : await requestComponentUpdateExecute(payload);
48818
- const updated = await (0, request_ts_2.extractPwcServiceResult)(updateResponse, (response) => response);
49056
+ const updated = await (0, request_ts_1.extractPwcServiceResult)(updateResponse, (response) => response);
48819
49057
  if (!updated.success) {
48820
49058
  throw new Error(updated.errorMessage);
48821
49059
  }
@@ -48832,6 +49070,27 @@ async function pwcPushNewService(apiName, type, context) {
48832
49070
  }
48833
49071
 
48834
49072
 
49073
+ /***/ },
49074
+
49075
+ /***/ 10771
49076
+ (__unused_webpack_module, exports, __webpack_require__) {
49077
+
49078
+ var __webpack_unused_export__;
49079
+
49080
+ __webpack_unused_export__ = ({ value: true });
49081
+ exports.requestPwcUploadFileExecute = requestPwcUploadFileExecute;
49082
+ const request_execute_command_paths_ts_1 = __webpack_require__(23634);
49083
+ const openapi_request_ts_1 = __webpack_require__(59848);
49084
+ /** 通过操作中心上传单个 PWC 文件,并返回后续 create/update 所需的 nPath。 */
49085
+ async function requestPwcUploadFileExecute(fileName, base64String) {
49086
+ const response = await (0, openapi_request_ts_1.executeOpenApiCommand)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('codeDev', 'vsceUploadFile').join(' '), { fileName, base64String });
49087
+ if (typeof response?.nPath !== 'string' || !response.nPath) {
49088
+ throw new Error(`Open API command "code-dev vscode-extension upload-file" returned no nPath for ${fileName}.`);
49089
+ }
49090
+ return { fileName, nPath: response.nPath };
49091
+ }
49092
+
49093
+
48835
49094
  /***/ },
48836
49095
 
48837
49096
  /***/ 35604
@@ -49895,6 +50154,10 @@ async function stageDefDeployCommand(_context, options) {
49895
50154
  descTranslateInfo: "object"
49896
50155
  };
49897
50156
  const data = buildOptionsData(options, typeMap);
50157
+ // 空 body 会被服务端直接拒绝为 500,本地先校验定位字段
50158
+ if (!data.id && !data.sourceWorkflowId) {
50159
+ throw new Error('stage-dev deploy requires --id or --sourceWorkflowId to locate the definition.');
50160
+ }
49898
50161
  logger_ts_1.loggerService.startLoading('Executing stageDef deploy');
49899
50162
  try {
49900
50163
  const response = await (0, stage_def_service_ts_1.executeStageDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('stageDef', 'deploy'), data);
@@ -49925,7 +50188,36 @@ async function stageDefUpdateCommand(_context, options) {
49925
50188
  nameTranslateInfo: "object",
49926
50189
  descTranslateInfo: "object"
49927
50190
  };
49928
- const data = buildOptionsData(options, typeMap);
50191
+ const updates = buildOptionsData(options, typeMap);
50192
+ // 服务端为全量更新语义:必须先按 --sourceWorkflowId 拉取完整定义,再合并增量提交
50193
+ if (!updates.sourceWorkflowId) {
50194
+ throw new Error('stage-dev update requires --sourceWorkflowId to locate and load the full definition.');
50195
+ }
50196
+ const changedFields = Object.keys(updates).filter((key) => key !== 'sourceWorkflowId');
50197
+ if (changedFields.length === 0) {
50198
+ throw new Error('stage-dev update requires at least one field to update besides --sourceWorkflowId.');
50199
+ }
50200
+ logger_ts_1.loggerService.startLoading('Loading stageDef detail for full definition');
50201
+ let fullDefinition;
50202
+ try {
50203
+ const detailResponse = await (0, stage_def_service_ts_1.executeStageDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('stageDef', 'detail'), { sourceWorkflowId: updates.sourceWorkflowId });
50204
+ logger_ts_1.loggerService.stopLoading();
50205
+ const envelope = (detailResponse && typeof detailResponse === 'object')
50206
+ ? detailResponse
50207
+ : {};
50208
+ if (envelope.success !== true || !envelope.data) {
50209
+ throw new Error(`Failed to load full definition via stageDef detail: ${envelope.message ?? 'definition missing'}.`);
50210
+ }
50211
+ fullDefinition = envelope.data;
50212
+ }
50213
+ catch (error) {
50214
+ logger_ts_1.loggerService.stopLoading();
50215
+ throw error;
50216
+ }
50217
+ // 服务端 schema 将 id 定义为 object 类型,detail 返回的 string id 回传会被校验拒绝;
50218
+ // 定位统一交给 sourceWorkflowId(schema 中 id 非必填)
50219
+ const { id: _omitId, ...data } = { ...fullDefinition, ...updates };
50220
+ void _omitId;
49929
50221
  logger_ts_1.loggerService.startLoading('Executing stageDef update');
49930
50222
  try {
49931
50223
  const response = await (0, stage_def_service_ts_1.executeStageDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('stageDef', 'update'), data);
@@ -50556,7 +50848,33 @@ async function workflowDefUpdateDefinitionCommand(_context, options) {
50556
50848
  nameTranslateInfo: "object",
50557
50849
  descTranslateInfo: "object"
50558
50850
  };
50559
- const data = buildOptionsData(options, typeMap);
50851
+ const updates = buildOptionsData(options, typeMap);
50852
+ // 服务端为全量更新语义:必须先按 --sourceWorkflowId 拉取完整定义,再合并增量提交
50853
+ if (!updates.sourceWorkflowId) {
50854
+ throw new Error('workflow-dev update-definition requires --sourceWorkflowId to locate and load the full definition.');
50855
+ }
50856
+ const changedFields = Object.keys(updates).filter((key) => key !== 'sourceWorkflowId');
50857
+ if (changedFields.length === 0) {
50858
+ throw new Error('workflow-dev update-definition requires at least one field to update besides --sourceWorkflowId.');
50859
+ }
50860
+ logger_ts_1.loggerService.startLoading('Loading workflowDef detail for full definition');
50861
+ let fullDefinition;
50862
+ try {
50863
+ const detailResponse = await (0, workflow_def_service_ts_1.executeWorkflowDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('workflowDef', 'detail'), { sourceWorkflowId: updates.sourceWorkflowId });
50864
+ logger_ts_1.loggerService.stopLoading();
50865
+ const envelope = (detailResponse && typeof detailResponse === 'object')
50866
+ ? detailResponse
50867
+ : {};
50868
+ if (envelope.success !== true || !envelope.data?.workflow) {
50869
+ throw new Error(`Failed to load full definition via workflowDef detail: ${envelope.message ?? 'definition missing'}.`);
50870
+ }
50871
+ fullDefinition = envelope.data.workflow;
50872
+ }
50873
+ catch (error) {
50874
+ logger_ts_1.loggerService.stopLoading();
50875
+ throw error;
50876
+ }
50877
+ const data = { ...fullDefinition, ...updates };
50560
50878
  logger_ts_1.loggerService.startLoading('Executing workflowDef update-definition');
50561
50879
  try {
50562
50880
  const response = await (0, workflow_def_service_ts_1.executeWorkflowDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('workflowDef', 'updateDefinition'), data);
@@ -51303,8 +51621,8 @@ async function readCliPackageMeta() {
51303
51621
  ? "@share-crm/sharedev-cli".trim()
51304
51622
  : '@share-crm/sharedev-cli';
51305
51623
  const debugEnabled = true && Boolean(false);
51306
- const rawVersion = ( true && "0.0.4-rc.50-test.3".trim())
51307
- ? "0.0.4-rc.50-test.3".trim()
51624
+ const rawVersion = ( true && "0.0.4-rc.50-test.4".trim())
51625
+ ? "0.0.4-rc.50-test.4".trim()
51308
51626
  : '0.0.0';
51309
51627
  const version = rawVersion + (debugEnabled ? '-debug' : '');
51310
51628
  return { name, version };