@share-crm/sharedev-cli 0.0.4-rc.50-test.2 → 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 +599 -260
  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
  });
@@ -19517,7 +19558,19 @@ async function getFuncList(options = {}) {
19517
19558
  });
19518
19559
  return response.function ?? [];
19519
19560
  }
19561
+ /**
19562
+ * open API 通道的批量函数查询(sharecrm 登录态时替代 FHH biz/batchQuery)。
19563
+ * 响应结构 2026-10-21 实测:content.function 直接为数组(无 result 嵌套,
19564
+ * 与 get-by-apiname-and-binding-object-apiname 的 {result:{function}} 不同形)。
19565
+ */
19566
+ async function findFuncByApiNamesViaOpenApi(apiNames) {
19567
+ const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev apl query-by-apinames', { apiNames });
19568
+ return content?.function ?? [];
19569
+ }
19520
19570
  async function findFuncByApiNames(apiNames) {
19571
+ if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
19572
+ return findFuncByApiNamesViaOpenApi(apiNames);
19573
+ }
19521
19574
  const response = await request_ts_1.requestService.FHH({
19522
19575
  url: '/EM1HFUNC/biz/batchQuery',
19523
19576
  data: {
@@ -20690,17 +20743,22 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
20690
20743
  exports.aplInfoNewCommand = aplInfoNewCommand;
20691
20744
  const logger_ts_1 = __webpack_require__(87562);
20692
20745
  const apl_info_ts_1 = __webpack_require__(1673);
20746
+ const apl_workspace_ts_1 = __webpack_require__(59696);
20693
20747
  /**
20694
20748
  * info-new 指令 CLI 交互逻辑:查询 APL 函数详情并打印(操作中心链路)
20695
20749
  */
20696
- async function aplInfoNewCommand(apiName, _context, options = {}) {
20697
- void _context;
20750
+ async function aplInfoNewCommand(apiName, context, options = {}) {
20698
20751
  if (!apiName?.trim()) {
20699
20752
  throw new Error('Invalid arguments: use sharedev apl info-new <apiName>.');
20700
20753
  }
20701
20754
  const requestedApiName = apiName.trim();
20702
- // 未绑定时 binding_object_api_name 按接口约定传 NONE(对齐操作中心 curl 示例)
20703
- 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';
20704
20762
  // 查询并复用现有格式化输出
20705
20763
  const func = await (0, apl_info_ts_1.aplInfoNewService)(requestedApiName, bindingObjectApiName);
20706
20764
  logger_ts_1.loggerService.printRaw(formatAplFuncDescribeNew(func));
@@ -20883,13 +20941,24 @@ async function aplListNewCommand(_context, options = {}) {
20883
20941
  Object.defineProperty(exports, "__esModule", ({ value: true }));
20884
20942
  exports.aplPullNewCommand = aplPullNewCommand;
20885
20943
  const apl_pull_ts_1 = __webpack_require__(48322);
20944
+ const apl_workspace_ts_1 = __webpack_require__(59696);
20886
20945
  const shared_ts_1 = __webpack_require__(23053);
20887
20946
  /**
20888
20947
  * pull-new 指令 CLI 交互逻辑:拉取 APL 函数到本地(操作中心链路)
20889
20948
  */
20890
20949
  async function aplPullNewCommand(apiName, context, options = {}) {
20891
20950
  const cliParameters = options.parameters?.trim() ? (0, shared_ts_1.parseAplParametersNew)(options.parameters) : undefined;
20892
- 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
+ });
20893
20962
  }
20894
20963
 
20895
20964
 
@@ -21358,7 +21427,7 @@ async function getAplNamespaceOptionsNew() {
21358
21427
  const returnTypes = result.returnTypes
21359
21428
  .map((item) => normalizeReturnTypeItemNew(item))
21360
21429
  .filter((item) => Boolean(item));
21361
- return { namespaces, returnTypes };
21430
+ return { namespaces, returnTypes, raw: response.data ?? {} };
21362
21431
  }
21363
21432
  function normalizeNamespaceItemNew(item) {
21364
21433
  const value = readStringNew(item.value) || readStringNew(item.namespace) || readStringNew(item.name_space) || readStringNew(item.name);
@@ -21795,7 +21864,9 @@ async function aplInfoNewService(apiName, bindingObjectApiName = '') {
21795
21864
  return result.data;
21796
21865
  });
21797
21866
  if (!func) {
21798
- 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`).');
21799
21870
  }
21800
21871
  // 收窄为 IFuncData 返回(打印交给 command 层复用现有格式化)
21801
21872
  const narrowed = (0, types_ts_1.narrowAplResponse)(func);
@@ -21822,11 +21893,10 @@ const logger_ts_1 = __webpack_require__(87562);
21822
21893
  const types_ts_1 = __webpack_require__(42801);
21823
21894
  const request_ts_1 = __webpack_require__(25285);
21824
21895
  /**
21825
- * open API 通道的 list-new 查询:open API 未注册 code-dev function list,
21826
- * 等价能力为 object-dev function query(过滤参数同名,2026-10-21 实测);
21896
+ * open API 通道的 list-new 查询:直接复用 code-dev apl list(过滤参数同名,2026-10-21 实测);
21827
21897
  * 响应包成 AplResponse 兼容信封,下游解析逻辑零改动。
21828
21898
  *
21829
- * ⚠️ body / selectFieldName 为 FHH 老链路参数,object-dev function query 不支持
21899
+ * ⚠️ body / selectFieldName 为 FHH 老链路参数,code-dev apl list 不支持
21830
21900
  * (2026-10-21 实测:传入后被服务端静默忽略、过滤不生效),显式剔除并提示用户。
21831
21901
  */
21832
21902
  const requestAplListViaOpenApi = async (filters) => {
@@ -21834,7 +21904,7 @@ const requestAplListViaOpenApi = async (filters) => {
21834
21904
  if (body !== undefined || selectFieldName !== undefined) {
21835
21905
  logger_ts_1.loggerService.warn('Filters "body" and "selectFieldName" are not supported on the sharecrm login channel and were ignored.');
21836
21906
  }
21837
- 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);
21838
21908
  return {
21839
21909
  success: true,
21840
21910
  code: 'OK',
@@ -21986,9 +22056,9 @@ async function aplPullNewService(apiName, context, options = {}) {
21986
22056
  logger_ts_1.loggerService.success(`Pulled APL functions: target=${apiNames.length}, written=${toWrite.length}, missing=${missing.length}.`);
21987
22057
  return;
21988
22058
  }
21989
- // 拉取单个:find 查详情(未绑定时 binding_object_api_name 按接口约定传 NONE)
22059
+ // 拉取单个:find 查详情(binding 解析优先级:--bind > 本地快照;都无则按接口约定传 NONE)
21990
22060
  logger_ts_1.loggerService.startLoading(`Fetching APL function ${apiName}`);
21991
- const response = await requestAplFindExecute(apiName, 'NONE');
22061
+ const response = await requestAplFindExecute(apiName, options.bindingObjectApiName?.trim() || 'NONE');
21992
22062
  logger_ts_1.loggerService.stopLoading();
21993
22063
  const func = await (0, request_ts_1.extractAplServiceResult)(response, types_ts_1.extractAplFunctionFromResponse).then((result) => {
21994
22064
  if (!result.success) {
@@ -21998,7 +22068,9 @@ async function aplPullNewService(apiName, context, options = {}) {
21998
22068
  });
21999
22069
  const narrowed = func ? (0, types_ts_1.narrowAplResponse)(func) : undefined;
22000
22070
  if (!narrowed) {
22001
- 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`.');
22002
22074
  }
22003
22075
  if (cliParameters) {
22004
22076
  narrowed.parameters = cliParameters;
@@ -22511,11 +22583,14 @@ exports.extractAplTemplateBodyFromResponse = extractAplTemplateBodyFromResponse;
22511
22583
  */
22512
22584
  const extractAplNamespaceDataFromResponse = (response) => {
22513
22585
  const level1 = narrowAplResponse(response.data);
22514
- // 兼容 data 直接就是命名空间结构或再包一层 data 两种形态
22586
+ // 兼容多种形态:data.namespaces / data.data / data.result.data(实测 query-namespaces 返回 result.data: [{label, value}])
22515
22587
  const dataRoot = narrowAplResponse(level1?.data) ?? level1 ?? {};
22588
+ const resultRoot = narrowAplResponse(dataRoot.result) ?? dataRoot;
22516
22589
  const namespaceItems = Array.isArray(dataRoot.namespaces)
22517
22590
  ? dataRoot.namespaces.map((item) => item)
22518
- : [];
22591
+ : Array.isArray(resultRoot.data)
22592
+ ? resultRoot.data.map((item) => item)
22593
+ : [];
22519
22594
  const returnTypeItems = Array.isArray(dataRoot.return_type)
22520
22595
  ? dataRoot.return_type.map((item) => item)
22521
22596
  : [];
@@ -25924,6 +25999,11 @@ const node_child_process_1 = __webpack_require__(31421);
25924
25999
  const node_path_1 = __importDefault(__webpack_require__(76760));
25925
26000
  const logger_ts_1 = __webpack_require__(87562);
25926
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);
25927
26007
  const sharecrm_session_ts_1 = __webpack_require__(47166);
25928
26008
  /** 解析依赖包 @share-crm/sharecrm-cli 的 bin 入口(不走 PATH / 全局安装) */
25929
26009
  function resolveSharecrmBinEntry() {
@@ -25948,7 +26028,7 @@ function deriveLoginEnvFromDomain(domain) {
25948
26028
  }
25949
26029
  return loginEnv;
25950
26030
  }
25951
- async function authLoginCommand(domain) {
26031
+ async function authLoginCommand(domain, context) {
25952
26032
  const loginEnv = deriveLoginEnvFromDomain(domain);
25953
26033
  // sharecrm 全局 config 优先级高于环境变量注入,固定过环境时会压制工作区推导——提前拦截
25954
26034
  const sharecrmConfig = (0, sharecrm_session_ts_1.readSharecrmConfig)();
@@ -25991,16 +26071,86 @@ async function authLoginCommand(domain) {
25991
26071
  logger_ts_1.loggerService.success(`Logged in as ${session.userName || `user ${session.userId}`} (appId ${session.appId}).`);
25992
26072
  // 端到端验证 Open API 通道(只读查询;失败仅 warn,部分环境命令集较旧属已知限制)
25993
26073
  try {
25994
- 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', {
25995
26075
  pageNumber: '1',
25996
26076
  pageSize: '1'
25997
26077
  });
25998
- const total = result?.result?.totalNumber;
25999
- 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` : ''}.`);
26000
26080
  }
26001
26081
  catch (error) {
26002
26082
  logger_ts_1.loggerService.warn(`Open API channel verification failed: ${error instanceof Error ? error.message : String(error)}`);
26003
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
+ }
26004
26154
  }
26005
26155
  function formatExpireTime(session) {
26006
26156
  if (!session.tokenExpireAt) {
@@ -26141,7 +26291,33 @@ async function bpmDefUpdateDefinitionCommand(_context, options) {
26141
26291
  nameTranslateInfo: "object",
26142
26292
  descTranslateInfo: "object"
26143
26293
  };
26144
- 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 };
26145
26321
  logger_ts_1.loggerService.startLoading('Executing bpmDef update-definition');
26146
26322
  try {
26147
26323
  const response = await (0, bpm_def_service_ts_1.executeBpmDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('bpmDef', 'updateDefinition'), data);
@@ -27956,19 +28132,29 @@ function formatUnknown(value) {
27956
28132
  /***/ 24814
27957
28133
  (__unused_webpack_module, exports, __webpack_require__) {
27958
28134
 
27959
- var __webpack_unused_export__;
27960
28135
 
27961
- __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 }));
27962
28140
  exports.getObjectDescribeList = getObjectDescribeList;
27963
28141
  exports.filterObjectDescribeList = filterObjectDescribeList;
27964
28142
  exports.getObjectDescribeByApiName = getObjectDescribeByApiName;
27965
28143
  exports.downloadObjectDescribeByApiNames = downloadObjectDescribeByApiNames;
27966
28144
  exports.getRuntimeNamespaceList = getRuntimeNamespaceList;
28145
+ exports.downloadInitMetadata = downloadInitMetadata;
27967
28146
  exports.toObjectSearchSummary = toObjectSearchSummary;
27968
28147
  exports.isExactObjectApiNameMatch = isExactObjectApiNameMatch;
27969
28148
  exports.extractObjectDescribe = extractObjectDescribe;
27970
- 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);
27971
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);
27972
28158
  function buildObjectSearchPayload(type) {
27973
28159
  return {
27974
28160
  isIncludeFieldDescribe: false,
@@ -27981,24 +28167,37 @@ function buildObjectSearchPayload(type) {
27981
28167
  }
27982
28168
  async function getObjectDescribeList(options = {}) {
27983
28169
  const items = [];
27984
- if (options.type) {
27985
- const response = await request_ts_1.requestService.FHH({
27986
- url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeManageList',
27987
- data: buildObjectSearchPayload(options.type)
27988
- });
27989
- items.push(...response.objectDescribeList ?? []);
27990
- }
27991
- else {
27992
- const resp1 = await request_ts_1.requestService.FHH({
27993
- url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeManageList',
27994
- data: buildObjectSearchPayload('package')
27995
- });
27996
- items.push(...resp1.objectDescribeList ?? []);
27997
- const resp2 = await request_ts_1.requestService.FHH({
27998
- url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeManageList',
27999
- data: buildObjectSearchPayload('custom')
28000
- });
28001
- 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
+ }
28002
28201
  }
28003
28202
  return items;
28004
28203
  }
@@ -28012,18 +28211,48 @@ function filterObjectDescribeList(items, query) {
28012
28211
  .sort((left, right) => compareObjectSearchItems(left, right, normalizedQuery));
28013
28212
  }
28014
28213
  async function getObjectDescribeByApiName(apiName) {
28015
- return request_ts_1.requestService.FHH({
28016
- url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeByApiName',
28017
- data: {
28018
- describe_apiname: apiName,
28019
- include_layout: true,
28020
- layout_type: 'detail',
28021
- get_label_direct: true,
28022
- include_describe_extra: false,
28023
- include_fields_extra: false,
28024
- check_cross_filter: false
28025
- }
28026
- });
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
+ };
28027
28256
  }
28028
28257
  async function downloadObjectDescribeByApiNames(apiNames, options) {
28029
28258
  const files = apiNames.map((apiName) => ({
@@ -28040,14 +28269,58 @@ async function downloadObjectDescribeByApiNames(apiNames, options) {
28040
28269
  });
28041
28270
  }
28042
28271
  async function getRuntimeNamespaceList() {
28043
- const response = await request_ts_1.requestService.FHH({
28044
- url: '/EM1HFUNC/runtime/namespace',
28045
- data: {}
28046
- });
28047
- 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);
28048
28274
  return {
28049
28275
  namespaces,
28050
- 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
28051
28324
  };
28052
28325
  }
28053
28326
  function toObjectSearchSummary(item) {
@@ -28075,35 +28348,6 @@ function extractObjectDescribe(result) {
28075
28348
  }
28076
28349
  return result.objectDescribe;
28077
28350
  }
28078
- function extractNamespaceArray(response) {
28079
- if (Array.isArray(response)) {
28080
- return normalizeNamespaceArray(response);
28081
- }
28082
- if (response && typeof response === 'object') {
28083
- const candidate = response;
28084
- const listCandidate = candidate.namespaceList ?? candidate.namespaces ?? candidate.list ?? candidate.data ?? candidate.value;
28085
- if (Array.isArray(listCandidate)) {
28086
- return normalizeNamespaceArray(listCandidate);
28087
- }
28088
- }
28089
- return [];
28090
- }
28091
- function normalizeNamespaceArray(items) {
28092
- const values = items
28093
- .map((item) => {
28094
- if (typeof item === 'string') {
28095
- return item.trim();
28096
- }
28097
- if (item && typeof item === 'object') {
28098
- const record = item;
28099
- const candidate = record.namespace ?? record.name ?? record.apiName ?? record.value;
28100
- return typeof candidate === 'string' ? candidate.trim() : '';
28101
- }
28102
- return '';
28103
- })
28104
- .filter(Boolean);
28105
- return Array.from(new Set(values)).sort((a, b) => a.localeCompare(b));
28106
- }
28107
28351
  function compareObjectSearchItems(left, right, normalizedQuery) {
28108
28352
  const leftScore = getObjectSearchScore(left, normalizedQuery);
28109
28353
  const rightScore = getObjectSearchScore(right, normalizedQuery);
@@ -29391,12 +29635,13 @@ const node_path_1 = __importDefault(__webpack_require__(76760));
29391
29635
  const prompts_1 = __webpack_require__(53503);
29392
29636
  const logger_ts_1 = __webpack_require__(87562);
29393
29637
  const request_ts_1 = __webpack_require__(83733);
29638
+ const request_channel_ts_1 = __webpack_require__(43355);
29639
+ const sharecrm_session_ts_1 = __webpack_require__(47166);
29394
29640
  const file_ts_1 = __webpack_require__(57452);
29395
29641
  const pkgMeta_ts_1 = __webpack_require__(48559);
29396
29642
  const apl_command_ts_1 = __webpack_require__(10508);
29397
29643
  const docs_service_ts_1 = __webpack_require__(37798);
29398
29644
  const dev_metadata_service_ts_1 = __webpack_require__(24814);
29399
- const dev_metadata_workspace_ts_1 = __webpack_require__(90328);
29400
29645
  const pwc_command_ts_1 = __webpack_require__(10372);
29401
29646
  const pwc_types_ts_1 = __webpack_require__(55844);
29402
29647
  const index_ts_1 = __webpack_require__(23916);
@@ -29668,7 +29913,7 @@ function createAplPullContext(context) {
29668
29913
  }
29669
29914
  async function runInitAplPull(context) {
29670
29915
  logger_ts_1.loggerService.info('Pulling all APL functions...');
29671
- 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 });
29672
29917
  }
29673
29918
  async function runInitPwcPull(context) {
29674
29919
  logger_ts_1.loggerService.info('Pulling all PWC components...');
@@ -29694,48 +29939,40 @@ async function runInitSpec(context, options, agentName) {
29694
29939
  showLoading: false
29695
29940
  });
29696
29941
  }
29697
- async function runInitMetadataDownload(context) {
29698
- const metadataRoot = node_path_1.default.join(context.settings.settingsDir, 'dev-metadata');
29699
- const objectsDir = node_path_1.default.join(metadataRoot, 'objects');
29700
- const namespacesDir = node_path_1.default.join(metadataRoot, 'namespaces');
29701
- logger_ts_1.loggerService.info('Downloading metadata...');
29702
- const [items, namespaceResult] = await Promise.all([
29703
- (0, dev_metadata_service_ts_1.getObjectDescribeList)(),
29704
- (0, dev_metadata_service_ts_1.getRuntimeNamespaceList)()
29705
- ]);
29706
- const sortedItems = (0, dev_metadata_service_ts_1.filterObjectDescribeList)(items);
29707
- await (0, dev_metadata_workspace_ts_1.writeObjectDescribeIndex)(objectsDir, sortedItems);
29708
- let succeeded = 0;
29709
- let failed = 0;
29710
- for (const item of sortedItems) {
29711
- try {
29712
- const infoResult = await (0, dev_metadata_service_ts_1.getObjectDescribeByApiName)(item.api_name);
29713
- await (0, dev_metadata_workspace_ts_1.writeObjectDescribeFile)(objectsDir, infoResult);
29714
- succeeded += 1;
29715
- }
29716
- catch {
29717
- failed += 1;
29718
- }
29719
- }
29720
- await (0, dev_metadata_workspace_ts_1.writeNamespaceMetadataFile)(namespacesDir, namespaceResult.raw);
29721
- logger_ts_1.loggerService.success(`Metadata download complete: objects=${succeeded}${failed ? `, failed=${failed}` : ''}, namespaces=${namespaceResult.namespaces.length}`);
29722
- }
29723
- async function runInitDownloadsConcurrently(context, options, pullSelections, agentName) {
29942
+ async function runInitDownloadsConcurrently(context, options, pullSelections, agentName, hasCredentials) {
29724
29943
  const tasks = [];
29944
+ if (!hasCredentials && (pullSelections.pullAllApl || pullSelections.pullAllPwc)) {
29945
+ // 凭证未就绪(certificate 未配置且工作区未登录):远端拉取类任务全部跳过,
29946
+ // 文档/spec 模板(公网资源)照常下载
29947
+ logger_ts_1.loggerService.warn('Credentials not ready (no certificate configured and not logged in). Skipping remote pulls.');
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
+ });
29953
+ }
29725
29954
  if (pullSelections.pullAllApl || pullSelections.pullAllPwc) {
29726
29955
  tasks.push(runInitDocsDownload(context, pullSelections));
29727
29956
  }
29728
29957
  if (pullSelections.pullAllApl || pullSelections.pullAllPwc) {
29729
29958
  tasks.push(runInitSpec(context, options, agentName));
29730
29959
  }
29731
- if (pullSelections.pullAllApl || pullSelections.pullAllPwc) {
29960
+ if (hasCredentials && (pullSelections.pullAllApl || pullSelections.pullAllPwc)) {
29732
29961
  request_ts_1.requestService.configure(context.settings);
29733
- 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
+ }));
29734
29967
  }
29735
- if (pullSelections.pullAllApl) {
29736
- tasks.push(runInitAplPull(context));
29968
+ if (hasCredentials && pullSelections.pullAllApl) {
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
+ }));
29737
29974
  }
29738
- if (pullSelections.pullAllPwc) {
29975
+ if (hasCredentials && pullSelections.pullAllPwc) {
29739
29976
  tasks.push(runInitPwcPull(context));
29740
29977
  }
29741
29978
  const results = await Promise.allSettled(tasks);
@@ -29767,10 +30004,20 @@ async function initProjectCommand(runtimeContext, options) {
29767
30004
  await (0, file_ts_1.ensureDir)(workspaceDir);
29768
30005
  await initGitWorkspace(workspaceDir, options);
29769
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);
29770
30012
  logger_ts_1.loggerService.success(`Initialization completed: ${settingsPath}`);
29771
30013
  logger_ts_1.loggerService.info(`Workspace folder created: ${workspaceDir}`);
29772
- const initContext = createInitRuntimeContext(runtimeContext, workspaceDir, settingsDir, settingsPath, payload);
29773
- await runInitDownloadsConcurrently(initContext, options, pullSelections, agentName);
30014
+ // 凭证就绪判定:本次配置了 certificate,或工作区已存在 sharecrm 登录态(--force 重建场景)
30015
+ const hasCredentials = Boolean(payload.certificate?.trim()) || Boolean((0, sharecrm_session_ts_1.readSharedevAuthSession)(settingsDir)?.accessToken);
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
+ }
29774
30021
  }
29775
30022
 
29776
30023
 
@@ -41703,9 +41950,9 @@ async function objectPullService(shouldQueryAll, queryType = null, apiName, skip
41703
41950
  logger_ts_1.loggerService.info(`Skipped public object count: ${skippedPublicApiNames.length}`);
41704
41951
  }
41705
41952
  }
41706
- // 50个分批拉取
41953
+ // 20个分批拉取
41707
41954
  const apiNamesListGroups = apiNamesList.reduce((acc, item, index) => {
41708
- const groupIndex = Math.floor(index / 50);
41955
+ const groupIndex = Math.floor(index / 20);
41709
41956
  if (!acc[groupIndex]) {
41710
41957
  acc[groupIndex] = [];
41711
41958
  }
@@ -45946,6 +46193,7 @@ const logger_ts_1 = __webpack_require__(87562);
45946
46193
  const request_ts_1 = __webpack_require__(83733);
45947
46194
  const sharecrm_session_ts_1 = __webpack_require__(47166);
45948
46195
  const pwc_service_ts_1 = __webpack_require__(63358);
46196
+ const pwc_pull_ts_1 = __webpack_require__(42094);
45949
46197
  const pwc_types_ts_1 = __webpack_require__(55844);
45950
46198
  const pwc_mateXml_ts_1 = __webpack_require__(53683);
45951
46199
  const pwc_workspace_ts_1 = __webpack_require__(64635);
@@ -45987,47 +46235,18 @@ async function pwcPullCommand(apiName, options, context) {
45987
46235
  if (options.type !== 'component' && options.type !== 'plugin') {
45988
46236
  throw new Error(`Invalid type: ${options.type}, accept 'component|plugin'.`);
45989
46237
  }
45990
- if (all) {
45991
- logger_ts_1.loggerService.startLoading(`Fetching PWC resources for type=${options.type}`);
45992
- const components = await (0, pwc_service_ts_1.fetchCodeByType)(options.type);
45993
- // if (!components.length) {
45994
- // loggerService.stopLoading();
45995
- // throw new Error(`No PWC resources found for type=${options.type}.`);
45996
- // }
45997
- const summary = {
45998
- target: components.length,
45999
- success: 0,
46000
- failed: 0
46001
- };
46002
- logger_ts_1.loggerService.updateLoading(`Found ${components.length} PWC resources, pulling...`);
46003
- for (const component of components) {
46004
- try {
46005
- assertPwcComponentType(component, options.type);
46006
- const componentRoot = await hydrateAndWritePwcComponent(context, component);
46007
- summary.success += 1;
46008
- logger_ts_1.loggerService.success(`Pulled PWC resource ${component.apiName} to ${componentRoot}`);
46009
- }
46010
- catch (error) {
46011
- summary.failed += 1;
46012
- const message = error instanceof Error ? error.message : String(error);
46013
- logger_ts_1.loggerService.error(`Failed to pull PWC resource ${component.apiName || '<unknown>'}: ${message}`);
46014
- }
46015
- }
46016
- logger_ts_1.loggerService.stopLoading();
46017
- logger_ts_1.loggerService.info(`PWC pull completed: target=${summary.target}, success=${summary.success}, failed=${summary.failed}`);
46018
- 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));
46019
46243
  }
46020
- logger_ts_1.loggerService.startLoading(`Fetching PWC resource ${normalizedApiName}`);
46021
- const components = await (0, pwc_service_ts_1.fetchCode)(options.type, normalizedApiName);
46022
- if (!components.length) {
46023
- logger_ts_1.loggerService.stopLoading();
46024
- 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;
46025
46247
  }
46026
- const component = components[0];
46027
- assertPwcComponentType(component, options.type);
46028
- const componentRoot = await hydrateAndWritePwcComponent(context, component);
46029
- logger_ts_1.loggerService.stopLoading();
46030
- 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;
46031
46250
  }
46032
46251
  async function pwcCreateCommand(options, context) {
46033
46252
  logger_ts_1.loggerService.startLoading('Preparing PWC create');
@@ -47297,9 +47516,9 @@ function validatePwcMateXmlContent(input) {
47297
47516
  var __webpack_unused_export__;
47298
47517
 
47299
47518
  __webpack_unused_export__ = ({ value: true });
47300
- exports.assertPwcFileUploadChannel = assertPwcFileUploadChannel;
47519
+ exports.uploadPwcFileList = uploadPwcFileList;
47301
47520
  exports.fetchCode = fetchCode;
47302
- exports.fetchCodeByType = fetchCodeByType;
47521
+ __webpack_unused_export__ = fetchCodeByType;
47303
47522
  exports.updateCodeSource = updateCodeSource;
47304
47523
  exports.buildCode = buildCode;
47305
47524
  exports.getBuildResult = getBuildResult;
@@ -47312,37 +47531,25 @@ exports.enablePwcResource = enablePwcResource;
47312
47531
  exports.getUrlByApiName = getUrlByApiName;
47313
47532
  const request_ts_1 = __webpack_require__(83733);
47314
47533
  const request_channel_ts_1 = __webpack_require__(43355);
47315
- 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);
47316
47536
  /**
47317
- * PWC 命令的通道保护:openapi 能力未就绪期间——
47318
- * 有 certificate 则 warn 后降级走 FHH(避免登录态+certificate 并存的功能回退);
47319
- * 无 certificate 抛错引导配置。待服务端 download-file 修复后移除。
47537
+ * PWC 命令的通道保护:以下接口仅有 FHH(企业网关,certificate 鉴权)实现,
47538
+ * 登录态(open API)下不回退证书通道——直接报错,说明该能力当前仅在证书模式可用。
47320
47539
  */
47321
47540
  function assertPwcChannelOrFallback() {
47322
47541
  if ((0, request_channel_ts_1.resolveRequestChannel)() !== 'openapi') {
47323
47542
  return;
47324
47543
  }
47325
- if ((0, request_channel_ts_1.hasCertificateCredential)()) {
47326
- logger_ts_1.loggerService.warn('PWC commands run via certificate channel (sharecrm login channel not ready for PWC file download).');
47327
- return;
47328
- }
47329
- throw new Error('PWC commands are not yet available on the sharecrm login channel ' +
47330
- '(Open API download-file returns empty content and has no URL query, 2026-10-21 measured). ' +
47331
- '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.');
47332
47546
  }
47333
- /**
47334
- * PWC 文件上传环节的通道断言:*-new 链路主体走 openapi(code-dev 命令),
47335
- * 但源码包上传(uploadFileList)仍依赖 FHH——纯登录态时给出明确引导而非服务端原始报错。
47336
- */
47337
- function assertPwcFileUploadChannel() {
47547
+ /** PWC 文件上传:登录态走操作中心,证书态保留 FHH 上传接口。 */
47548
+ async function uploadPwcFileList(fileList) {
47338
47549
  if ((0, request_channel_ts_1.resolveRequestChannel)() !== 'openapi') {
47339
- return;
47550
+ return request_ts_1.requestService.uploadFileList(fileList);
47340
47551
  }
47341
- if ((0, request_channel_ts_1.hasCertificateCredential)()) {
47342
- return;
47343
- }
47344
- throw new Error('PWC file upload requires the certificate channel (not yet available on the sharecrm login channel). ' +
47345
- '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)));
47346
47553
  }
47347
47554
  async function fetchCode(type, apiName) {
47348
47555
  assertPwcChannelOrFallback();
@@ -47441,6 +47648,22 @@ async function hydrateFile(file, groupName, apiName) {
47441
47648
  if (!nPath) {
47442
47649
  throw new Error(`Cannot download ${groupName} file ${file.fileName || '<unknown>'} for PWC resource ${apiName}: missing nPath/filePath.`);
47443
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
47444
47667
  try {
47445
47668
  const content = await request_ts_1.requestService.downloadFile(nPath);
47446
47669
  return {
@@ -48002,10 +48225,9 @@ exports.pwcCreateNewService = pwcCreateNewService;
48002
48225
  const node_path_1 = __importDefault(__webpack_require__(76760));
48003
48226
  const request_execute_command_paths_ts_1 = __webpack_require__(23634);
48004
48227
  const logger_ts_1 = __webpack_require__(87562);
48005
- const request_ts_1 = __webpack_require__(83733);
48006
48228
  const file_ts_1 = __webpack_require__(57452);
48007
48229
  const zip_ts_1 = __webpack_require__(89139);
48008
- const request_ts_2 = __webpack_require__(35604);
48230
+ const request_ts_1 = __webpack_require__(35604);
48009
48231
  const types_ts_1 = __webpack_require__(6500);
48010
48232
  const pwc_service_ts_1 = __webpack_require__(63358);
48011
48233
  const pwc_workspace_ts_1 = __webpack_require__(64635);
@@ -48013,7 +48235,7 @@ const pwc_types_ts_1 = __webpack_require__(55844);
48013
48235
  /**
48014
48236
  * 操作中心接口包装调用:objectDev queryDescribeManageList(create 对象多选,payload 与现网 getObjectApiNames 一致)
48015
48237
  */
48016
- 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'), {
48017
48239
  isIncludeFieldDescribe: false,
48018
48240
  isIncludeSystemObj: true,
48019
48241
  isIncludeUnActived: true,
@@ -48024,23 +48246,23 @@ const requestObjectDescribeManageListExecute = async () => await (0, request_ts_
48024
48246
  /**
48025
48247
  * 操作中心接口包装调用:component create(--data 整包)
48026
48248
  */
48027
- 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);
48028
48250
  /**
48029
48251
  * 操作中心接口包装调用:plugin create(--data 整包)
48030
48252
  */
48031
- 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);
48032
48254
  /**
48033
48255
  * 操作中心接口包装调用:component enable
48034
48256
  */
48035
- 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 });
48036
48258
  /**
48037
48259
  * 操作中心接口包装调用:plugin enable
48038
48260
  */
48039
- 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 });
48040
48262
  /**
48041
48263
  * 操作中心接口包装调用:vscode-extension download-code
48042
48264
  */
48043
- 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'), {
48044
48266
  apiName,
48045
48267
  type,
48046
48268
  downloadAll
@@ -48072,7 +48294,7 @@ const PLUGIN_DEFAULT_INDEX_JS = `export default class CustomPlugin {
48072
48294
  */
48073
48295
  async function getPwcObjectApiNamesNew() {
48074
48296
  const response = await requestObjectDescribeManageListExecute();
48075
- const result = await (0, request_ts_2.extractPwcServiceResult)(response, (res) => {
48297
+ const result = await (0, request_ts_1.extractPwcServiceResult)(response, (res) => {
48076
48298
  const level1 = (0, types_ts_1.narrowPwcResponse)(res.data);
48077
48299
  const level2 = (0, types_ts_1.narrowPwcResponse)(level1?.data) ?? level1;
48078
48300
  const list = (0, types_ts_1.narrowPwcResponse)(level2?.objectDescribeList) ?? [];
@@ -48109,9 +48331,8 @@ async function pwcCreateNewService(input, context) {
48109
48331
  let remoteFiles = [];
48110
48332
  if (useAppletZip) {
48111
48333
  logger_ts_1.loggerService.updateLoading('Uploading initialization template archive');
48112
- (0, pwc_service_ts_1.assertPwcFileUploadChannel)();
48113
48334
  const zipBuffer = await (0, zip_ts_1.createZipBufferFromTextFiles)(input.templateFiles);
48114
- const [remoteZip] = await request_ts_1.requestService.uploadFileList([
48335
+ const [remoteZip] = await (0, pwc_service_ts_1.uploadPwcFileList)([
48115
48336
  {
48116
48337
  fileName: `${input.apiName}.zip`,
48117
48338
  base64String: zipBuffer.toString('base64')
@@ -48125,8 +48346,7 @@ async function pwcCreateNewService(input, context) {
48125
48346
  }
48126
48347
  else {
48127
48348
  logger_ts_1.loggerService.updateLoading('Uploading initialization template files');
48128
- (0, pwc_service_ts_1.assertPwcFileUploadChannel)();
48129
- 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) => ({
48130
48350
  fileName: file.fileName,
48131
48351
  base64String: Buffer.from(file.content, 'utf8').toString('base64')
48132
48352
  })));
@@ -48191,7 +48411,7 @@ async function pwcCreateNewService(input, context) {
48191
48411
  const createResponse = input.kind === 'plugin'
48192
48412
  ? await requestPluginCreateExecute(payload)
48193
48413
  : await requestComponentCreateExecute(payload);
48194
- const created = await (0, request_ts_2.extractPwcServiceResult)(createResponse, (response) => response);
48414
+ const created = await (0, request_ts_1.extractPwcServiceResult)(createResponse, (response) => response);
48195
48415
  if (!created.success) {
48196
48416
  throw new Error(created.errorMessage);
48197
48417
  }
@@ -48200,7 +48420,7 @@ async function pwcCreateNewService(input, context) {
48200
48420
  const enableResponse = input.kind === 'plugin'
48201
48421
  ? await requestPluginEnableExecute(input.apiName)
48202
48422
  : await requestComponentEnableExecute(input.apiName);
48203
- const enabled = await (0, request_ts_2.extractPwcServiceResult)(enableResponse, (response) => response);
48423
+ const enabled = await (0, request_ts_1.extractPwcServiceResult)(enableResponse, (response) => response);
48204
48424
  if (!enabled.success) {
48205
48425
  throw new Error(enabled.errorMessage);
48206
48426
  }
@@ -48209,7 +48429,7 @@ async function pwcCreateNewService(input, context) {
48209
48429
  let pulled;
48210
48430
  for (let i = 1; i <= 8; i += 1) {
48211
48431
  const downloadResponse = await requestVsceDownloadCodeExecute(input.apiName, createdType, false);
48212
- 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);
48213
48433
  if (!downloadResult.success) {
48214
48434
  throw new Error(downloadResult.errorMessage);
48215
48435
  }
@@ -48324,7 +48544,7 @@ async function pwcDeployNewService(apiName, type, context) {
48324
48544
  if (!buildId) {
48325
48545
  throw new Error('Deploy failed: server did not return buildId.');
48326
48546
  }
48327
- // 轮询构建结果:最多 180 次、间隔 1s;status 2 成功、3 失败
48547
+ // 轮询构建结果:部分环境以 status=2 表示成功,112 环境返回 status=3;优先识别构建日志。
48328
48548
  const maxAttempts = 180;
48329
48549
  for (let i = 1; i <= maxAttempts; i += 1) {
48330
48550
  const pollResponse = type === pwc_types_ts_1.PWCType.Plugin
@@ -48335,7 +48555,10 @@ async function pwcDeployNewService(apiName, type, context) {
48335
48555
  throw new Error(pollResult.errorMessage);
48336
48556
  }
48337
48557
  const status = (0, types_ts_1.readPwcNumber)(pollResult.data, 'status');
48338
- 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)) {
48339
48562
  return {
48340
48563
  apiName,
48341
48564
  type,
@@ -48347,7 +48570,7 @@ async function pwcDeployNewService(apiName, type, context) {
48347
48570
  errorMessages
48348
48571
  };
48349
48572
  }
48350
- if (status === 3) {
48573
+ if ((status === 2 || status === 3) && (failed || !succeeded)) {
48351
48574
  throw new Error(`Deploy build failed: buildId=${buildId}`);
48352
48575
  }
48353
48576
  logger_ts_1.loggerService.updateLoading(`Waiting for build result... ${i}/${maxAttempts} (buildId=${buildId})`);
@@ -48359,6 +48582,45 @@ async function pwcDeployNewService(apiName, type, context) {
48359
48582
  }
48360
48583
 
48361
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
+
48362
48624
  /***/ },
48363
48625
 
48364
48626
  /***/ 32133
@@ -48655,8 +48917,7 @@ exports.getPwcConfigNew = getPwcConfigNew;
48655
48917
  exports.pwcPushNewService = pwcPushNewService;
48656
48918
  const request_execute_command_paths_ts_1 = __webpack_require__(23634);
48657
48919
  const logger_ts_1 = __webpack_require__(87562);
48658
- const request_ts_1 = __webpack_require__(83733);
48659
- const request_ts_2 = __webpack_require__(35604);
48920
+ const request_ts_1 = __webpack_require__(35604);
48660
48921
  const types_ts_1 = __webpack_require__(6500);
48661
48922
  const pwc_mateXml_ts_1 = __webpack_require__(53683);
48662
48923
  const pwc_service_ts_1 = __webpack_require__(63358);
@@ -48665,29 +48926,29 @@ const pwc_types_ts_1 = __webpack_require__(55844);
48665
48926
  /**
48666
48927
  * 操作中心接口包装调用:component get-config
48667
48928
  */
48668
- 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'), {});
48669
48930
  /**
48670
48931
  * 操作中心接口包装调用:component find-by-api-name
48671
48932
  */
48672
- 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 });
48673
48934
  /**
48674
48935
  * 操作中心接口包装调用:plugin find-by-api-name
48675
48936
  */
48676
- 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 });
48677
48938
  /**
48678
48939
  * 操作中心接口包装调用:component update(--data 整包)
48679
48940
  */
48680
- 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);
48681
48942
  /**
48682
48943
  * 操作中心接口包装调用:plugin update(--data 整包)
48683
48944
  */
48684
- 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);
48685
48946
  /**
48686
48947
  * 查询 PWC 配置(push/create 共用 get-config)
48687
48948
  */
48688
48949
  async function getPwcConfigNew() {
48689
48950
  const response = await requestComponentGetConfigExecute();
48690
- 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);
48691
48952
  if (!result.success) {
48692
48953
  throw new Error(result.errorMessage);
48693
48954
  }
@@ -48715,8 +48976,7 @@ async function pwcPushNewService(apiName, type, context) {
48715
48976
  const { readFile } = await Promise.resolve(/* import() */).then(() => (__webpack_require__(59031)));
48716
48977
  const zipBuffer = await readFile(appletZipPath);
48717
48978
  logger_ts_1.loggerService.updateLoading(`Uploading ${apiName}.zip`);
48718
- (0, pwc_service_ts_1.assertPwcFileUploadChannel)();
48719
- const [remoteZip] = await request_ts_1.requestService.uploadFileList([
48979
+ const [remoteZip] = await (0, pwc_service_ts_1.uploadPwcFileList)([
48720
48980
  {
48721
48981
  fileName: `${apiName}.zip`,
48722
48982
  base64String: zipBuffer.toString('base64')
@@ -48734,8 +48994,7 @@ async function pwcPushNewService(apiName, type, context) {
48734
48994
  bundle = await (0, pwc_workspace_ts_1.readLocalPwcUploadBundle)(context, type, apiName, (0, pwc_mateXml_ts_1.buildPwcTypeConstraints)(config));
48735
48995
  // 上传源码 / 静态资源 / fileTree
48736
48996
  logger_ts_1.loggerService.updateLoading(`Uploading ${bundle.uploadFiles.length} files`);
48737
- (0, pwc_service_ts_1.assertPwcFileUploadChannel)();
48738
- 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) => ({
48739
48998
  fileName: item.fileName,
48740
48999
  base64String: item.base64String
48741
49000
  })));
@@ -48769,7 +49028,7 @@ async function pwcPushNewService(apiName, type, context) {
48769
49028
  const findResponse = type === pwc_types_ts_1.PWCType.Plugin
48770
49029
  ? await requestPluginFindByApiNameExecute(apiName)
48771
49030
  : await requestComponentFindByApiNameExecute(apiName);
48772
- 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) => {
48773
49032
  if (!result.success) {
48774
49033
  throw new Error(result.errorMessage);
48775
49034
  }
@@ -48794,7 +49053,7 @@ async function pwcPushNewService(apiName, type, context) {
48794
49053
  const updateResponse = type === pwc_types_ts_1.PWCType.Plugin
48795
49054
  ? await requestPluginUpdateExecute(payload)
48796
49055
  : await requestComponentUpdateExecute(payload);
48797
- const updated = await (0, request_ts_2.extractPwcServiceResult)(updateResponse, (response) => response);
49056
+ const updated = await (0, request_ts_1.extractPwcServiceResult)(updateResponse, (response) => response);
48798
49057
  if (!updated.success) {
48799
49058
  throw new Error(updated.errorMessage);
48800
49059
  }
@@ -48811,6 +49070,27 @@ async function pwcPushNewService(apiName, type, context) {
48811
49070
  }
48812
49071
 
48813
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
+
48814
49094
  /***/ },
48815
49095
 
48816
49096
  /***/ 35604
@@ -49874,6 +50154,10 @@ async function stageDefDeployCommand(_context, options) {
49874
50154
  descTranslateInfo: "object"
49875
50155
  };
49876
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
+ }
49877
50161
  logger_ts_1.loggerService.startLoading('Executing stageDef deploy');
49878
50162
  try {
49879
50163
  const response = await (0, stage_def_service_ts_1.executeStageDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('stageDef', 'deploy'), data);
@@ -49904,7 +50188,36 @@ async function stageDefUpdateCommand(_context, options) {
49904
50188
  nameTranslateInfo: "object",
49905
50189
  descTranslateInfo: "object"
49906
50190
  };
49907
- 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;
49908
50221
  logger_ts_1.loggerService.startLoading('Executing stageDef update');
49909
50222
  try {
49910
50223
  const response = await (0, stage_def_service_ts_1.executeStageDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('stageDef', 'update'), data);
@@ -50535,7 +50848,33 @@ async function workflowDefUpdateDefinitionCommand(_context, options) {
50535
50848
  nameTranslateInfo: "object",
50536
50849
  descTranslateInfo: "object"
50537
50850
  };
50538
- 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 };
50539
50878
  logger_ts_1.loggerService.startLoading('Executing workflowDef update-definition');
50540
50879
  try {
50541
50880
  const response = await (0, workflow_def_service_ts_1.executeWorkflowDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('workflowDef', 'updateDefinition'), data);
@@ -51282,8 +51621,8 @@ async function readCliPackageMeta() {
51282
51621
  ? "@share-crm/sharedev-cli".trim()
51283
51622
  : '@share-crm/sharedev-cli';
51284
51623
  const debugEnabled = true && Boolean(false);
51285
- const rawVersion = ( true && "0.0.4-rc.50-test.2".trim())
51286
- ? "0.0.4-rc.50-test.2".trim()
51624
+ const rawVersion = ( true && "0.0.4-rc.50-test.4".trim())
51625
+ ? "0.0.4-rc.50-test.4".trim()
51287
51626
  : '0.0.0';
51288
51627
  const version = rawVersion + (debugEnabled ? '-debug' : '');
51289
51628
  return { name, version };