@share-crm/sharedev-cli 0.0.4-rc.50-test.2 → 0.0.4-rc.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sharedev.js +78 -807
- package/package.json +1 -2
package/dist/sharedev.js
CHANGED
|
@@ -8572,8 +8572,6 @@ const index_ts_1 = __webpack_require__(22841);
|
|
|
8572
8572
|
const context_ts_1 = __webpack_require__(29531);
|
|
8573
8573
|
const logger_ts_1 = __webpack_require__(87562);
|
|
8574
8574
|
const request_ts_1 = __webpack_require__(83733);
|
|
8575
|
-
const request_channel_ts_1 = __webpack_require__(43355);
|
|
8576
|
-
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
8577
8575
|
const pkgMeta_ts_1 = __webpack_require__(48559);
|
|
8578
8576
|
const normalize_ts_1 = __importDefault(__webpack_require__(80399));
|
|
8579
8577
|
const debug_ts_1 = __webpack_require__(90667);
|
|
@@ -8699,8 +8697,6 @@ async function bootstrap() {
|
|
|
8699
8697
|
}
|
|
8700
8698
|
const runtimeContext = await (0, context_ts_1.createCliRuntimeContext)(bootstrapOptions);
|
|
8701
8699
|
request_ts_1.requestService.configure(runtimeContext.settings);
|
|
8702
|
-
(0, request_channel_ts_1.configureRequestChannel)(runtimeContext.settings);
|
|
8703
|
-
(0, sharecrm_session_ts_1.configureSharecrmSession)(runtimeContext.settings);
|
|
8704
8700
|
// npm 与 spec 版本检查并发执行(均带 1.5s 超时,错误吞掉,不影响命令执行)
|
|
8705
8701
|
await Promise.all([
|
|
8706
8702
|
checkForNpmUpdate(pkgMeta.name, version),
|
|
@@ -9893,48 +9889,6 @@ function registerApprovalNamespace(program, runtimeContext) {
|
|
|
9893
9889
|
}
|
|
9894
9890
|
|
|
9895
9891
|
|
|
9896
|
-
/***/ },
|
|
9897
|
-
|
|
9898
|
-
/***/ 85971
|
|
9899
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
9900
|
-
|
|
9901
|
-
var __webpack_unused_export__;
|
|
9902
|
-
|
|
9903
|
-
__webpack_unused_export__ = ({ value: true });
|
|
9904
|
-
exports.registerAuthCommand = registerAuthCommand;
|
|
9905
|
-
const command_ts_1 = __webpack_require__(51481);
|
|
9906
|
-
const index_ts_1 = __webpack_require__(98695);
|
|
9907
|
-
/**
|
|
9908
|
-
* auth 命令依赖工作区存在(登录环境从 settings.json 的 domain 反向推导):
|
|
9909
|
-
* 未 init 的目录下执行会在 bootstrap 阶段被引导先运行 `sharedev init`。
|
|
9910
|
-
*/
|
|
9911
|
-
function registerAuthCommand(program, runtimeContext) {
|
|
9912
|
-
const auth = program.command('auth').description('Manage sharecrm login state for sharedev CLI');
|
|
9913
|
-
auth
|
|
9914
|
-
.command('login')
|
|
9915
|
-
.description('Login via sharecrm device flow (environment inherited from workspace domain)')
|
|
9916
|
-
.addHelpText('after', `
|
|
9917
|
-
Examples:
|
|
9918
|
-
$ sharedev auth login
|
|
9919
|
-
`)
|
|
9920
|
-
.action((0, command_ts_1.createCommandAction)('auth', 'login', runtimeContext, async ({ context }) => {
|
|
9921
|
-
await (0, index_ts_1.authLoginCommand)(context.settings.domain);
|
|
9922
|
-
}));
|
|
9923
|
-
auth
|
|
9924
|
-
.command('status')
|
|
9925
|
-
.description('Show current login state (sharecrm login and certificate config)')
|
|
9926
|
-
.action((0, command_ts_1.createCommandAction)('auth', 'status', runtimeContext, async ({ context }) => {
|
|
9927
|
-
await (0, index_ts_1.authStatusCommand)(context.settings);
|
|
9928
|
-
}));
|
|
9929
|
-
auth
|
|
9930
|
-
.command('logout')
|
|
9931
|
-
.description('Clear workspace login state (does not logout sharecrm itself)')
|
|
9932
|
-
.action((0, command_ts_1.createCommandAction)('auth', 'logout', runtimeContext, async () => {
|
|
9933
|
-
await (0, index_ts_1.authLogoutCommand)();
|
|
9934
|
-
}));
|
|
9935
|
-
}
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
9892
|
/***/ },
|
|
9939
9893
|
|
|
9940
9894
|
/***/ 5264
|
|
@@ -12349,11 +12303,9 @@ const er_ts_1 = __webpack_require__(40402);
|
|
|
12349
12303
|
const semantic_ts_1 = __webpack_require__(35185);
|
|
12350
12304
|
const access_ts_1 = __webpack_require__(9759);
|
|
12351
12305
|
const app_dev_ts_1 = __webpack_require__(82916);
|
|
12352
|
-
const auth_ts_1 = __webpack_require__(85971);
|
|
12353
12306
|
function registerNamespaces(program, context) {
|
|
12354
12307
|
(0, init_ts_1.registerInitCommand)(program, context);
|
|
12355
12308
|
(0, config_ts_1.registerConfigCommand)(program, context);
|
|
12356
|
-
(0, auth_ts_1.registerAuthCommand)(program, context);
|
|
12357
12309
|
(0, apl_ts_1.registerAplNamespace)(program, context);
|
|
12358
12310
|
(0, completion_ts_1.registerCompletionCommand)(program, context);
|
|
12359
12311
|
(0, docs_ts_1.registerDocsNamespace)(program, context);
|
|
@@ -14840,11 +14792,9 @@ exports.getProjectPath = getProjectPath;
|
|
|
14840
14792
|
exports.findSettings = findSettings;
|
|
14841
14793
|
exports.validateSettings = validateSettings;
|
|
14842
14794
|
exports.loadSettings = loadSettings;
|
|
14843
|
-
exports.loadRelaxedSettings = loadRelaxedSettings;
|
|
14844
14795
|
const node_path_1 = __importDefault(__webpack_require__(76760));
|
|
14845
14796
|
const file_ts_1 = __webpack_require__(57452);
|
|
14846
14797
|
const path_ts_1 = __webpack_require__(89213);
|
|
14847
|
-
const logger_ts_1 = __webpack_require__(87562);
|
|
14848
14798
|
const SHAREDEV_RELATIVE_PATH = node_path_1.default.join('.sharedev');
|
|
14849
14799
|
const SETTINGS_NAME = 'settings.json';
|
|
14850
14800
|
function isValidUrl(value) {
|
|
@@ -14877,10 +14827,7 @@ async function findSharedevPath(startDir) {
|
|
|
14877
14827
|
let currentDir = node_path_1.default.resolve(startDir);
|
|
14878
14828
|
while (true) {
|
|
14879
14829
|
const candidate = node_path_1.default.join(currentDir, SHAREDEV_RELATIVE_PATH);
|
|
14880
|
-
|
|
14881
|
-
// 只存在 .sharedev 目录(如家目录的文档/快照残留)时继续向上查找,
|
|
14882
|
-
// 避免误命中导致 settings 读写与 init 落位跑到错误目录
|
|
14883
|
-
if (await (0, file_ts_1.pathExists)(node_path_1.default.join(candidate, SETTINGS_NAME))) {
|
|
14830
|
+
if (await (0, file_ts_1.pathExists)(candidate)) {
|
|
14884
14831
|
return candidate;
|
|
14885
14832
|
}
|
|
14886
14833
|
const parentDir = node_path_1.default.dirname(currentDir);
|
|
@@ -14905,8 +14852,9 @@ async function findSettings(startDir) {
|
|
|
14905
14852
|
return node_path_1.default.join(sharedevPath, SETTINGS_NAME);
|
|
14906
14853
|
}
|
|
14907
14854
|
function validateSettings(settings) {
|
|
14908
|
-
|
|
14909
|
-
|
|
14855
|
+
if (!settings.certificate?.trim()) {
|
|
14856
|
+
throw new Error('Missing certificate in .sharedev/settings.json.');
|
|
14857
|
+
}
|
|
14910
14858
|
if (!settings.domain?.trim()) {
|
|
14911
14859
|
throw new Error('Missing domain in .sharedev/settings.json.');
|
|
14912
14860
|
}
|
|
@@ -14935,37 +14883,6 @@ async function loadSettings(startDir) {
|
|
|
14935
14883
|
validateSettings(settings);
|
|
14936
14884
|
return settings;
|
|
14937
14885
|
}
|
|
14938
|
-
/**
|
|
14939
|
-
* 宽松读取 settings(不做 certificate/domain 校验),供「无 certificate + sharecrm 登录态」
|
|
14940
|
-
* 的运行模式兜底使用:settings.json 缺失时返回空字段形态,存在时尽量保留 domain 等信息
|
|
14941
|
-
* (环境一致性校验仍依赖 domain)。
|
|
14942
|
-
*/
|
|
14943
|
-
async function loadRelaxedSettings(startDir, fallbackDir) {
|
|
14944
|
-
const settingsPath = await findSettings(startDir);
|
|
14945
|
-
let rawSettings = {};
|
|
14946
|
-
if (settingsPath) {
|
|
14947
|
-
try {
|
|
14948
|
-
rawSettings = await (0, file_ts_1.readJsonFile)(settingsPath);
|
|
14949
|
-
}
|
|
14950
|
-
catch (error) {
|
|
14951
|
-
// 文件不存在(.sharedev 目录在但 settings.json 没有)是正常的登录态模式场景,静默跳过;
|
|
14952
|
-
// 文件存在但解析失败则必须警告——静默会丢失 domain 等工作区环境信息
|
|
14953
|
-
if (error.code !== 'ENOENT') {
|
|
14954
|
-
logger_ts_1.loggerService.warn(`Failed to parse ${settingsPath} (${error instanceof Error ? error.message : String(error)}). ` +
|
|
14955
|
-
'Running with sharecrm login state only; fix the settings file to restore environment checks.');
|
|
14956
|
-
}
|
|
14957
|
-
}
|
|
14958
|
-
}
|
|
14959
|
-
return {
|
|
14960
|
-
certificate: typeof rawSettings.certificate === 'string' ? rawSettings.certificate : '',
|
|
14961
|
-
domain: typeof rawSettings.domain === 'string' ? rawSettings.domain : '',
|
|
14962
|
-
developerName: typeof rawSettings.developerName === 'string' ? rawSettings.developerName : '',
|
|
14963
|
-
developerMobile: typeof rawSettings.developerMobile === 'string' ? rawSettings.developerMobile : '',
|
|
14964
|
-
specVersion: typeof rawSettings.specVersion === 'string' ? rawSettings.specVersion : '',
|
|
14965
|
-
settingsPath: settingsPath ?? '',
|
|
14966
|
-
settingsDir: settingsPath ? node_path_1.default.dirname(settingsPath) : fallbackDir
|
|
14967
|
-
};
|
|
14968
|
-
}
|
|
14969
14886
|
|
|
14970
14887
|
|
|
14971
14888
|
/***/ },
|
|
@@ -14979,28 +14896,11 @@ __webpack_unused_export__ = ({ value: true });
|
|
|
14979
14896
|
exports.createCliRuntimeContext = createCliRuntimeContext;
|
|
14980
14897
|
const config_ts_1 = __webpack_require__(43120);
|
|
14981
14898
|
const logger_ts_1 = __webpack_require__(87562);
|
|
14982
|
-
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
14983
14899
|
const path_ts_1 = __webpack_require__(89213);
|
|
14984
14900
|
async function createCliRuntimeContext(_options) {
|
|
14985
14901
|
const cwd = process.cwd();
|
|
14986
14902
|
const searchDir = await (0, config_ts_1.resolveSettingsSearchDir)(undefined, cwd);
|
|
14987
|
-
|
|
14988
|
-
try {
|
|
14989
|
-
settings = await (0, config_ts_1.loadSettings)(searchDir);
|
|
14990
|
-
}
|
|
14991
|
-
catch (error) {
|
|
14992
|
-
// settings 文件缺失或内容损坏时,工作区内存在登录凭证(.sharedev/session.json)则降级为
|
|
14993
|
-
// 「登录态模式」继续运行(certificate 可为空,业务请求走 open API 通道)。
|
|
14994
|
-
// 此时 configureSharecrmSession 尚未注入,直接按 .sharedev 目录读取凭证文件。
|
|
14995
|
-
const sharedevDir = await (0, config_ts_1.findSharedevPath)(searchDir);
|
|
14996
|
-
const session = sharedevDir ? (0, sharecrm_session_ts_1.readSharedevAuthSession)(sharedevDir) : null;
|
|
14997
|
-
if (!session?.accessToken) {
|
|
14998
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
14999
|
-
throw new Error(`${message}\nRun \`sharedev init\` to initialize a workspace first, then \`sharedev auth login\`.`);
|
|
15000
|
-
}
|
|
15001
|
-
settings = await (0, config_ts_1.loadRelaxedSettings)(searchDir, cwd);
|
|
15002
|
-
logger_ts_1.loggerService.info('No valid certificate configured; running with sharecrm login state.');
|
|
15003
|
-
}
|
|
14903
|
+
const settings = await (0, config_ts_1.loadSettings)(searchDir);
|
|
15004
14904
|
logger_ts_1.loggerService.debug(`settingsPath = ${settings.settingsPath}`);
|
|
15005
14905
|
logger_ts_1.loggerService.debug(`domain = ${settings.domain}`);
|
|
15006
14906
|
logger_ts_1.loggerService.debug(`certificate = ${(0, path_ts_1.maskCertificate)(settings.certificate)}`);
|
|
@@ -15851,126 +15751,6 @@ const fetchLatestNpmVersion = (packageName, timeoutMs = 1500) => new Promise((re
|
|
|
15851
15751
|
exports.fetchLatestNpmVersion = fetchLatestNpmVersion;
|
|
15852
15752
|
|
|
15853
15753
|
|
|
15854
|
-
/***/ },
|
|
15855
|
-
|
|
15856
|
-
/***/ 59848
|
|
15857
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15861
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15862
|
-
};
|
|
15863
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
15864
|
-
exports.OpenApiCommandError = void 0;
|
|
15865
|
-
exports.executeOpenApiCommand = executeOpenApiCommand;
|
|
15866
|
-
const node_crypto_1 = __webpack_require__(77598);
|
|
15867
|
-
const logger_ts_1 = __webpack_require__(87562);
|
|
15868
|
-
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
15869
|
-
const normalize_ts_1 = __importDefault(__webpack_require__(80399));
|
|
15870
|
-
const pkgMeta_ts_1 = __webpack_require__(48559);
|
|
15871
|
-
const isDebugEnabled_ts_1 = __webpack_require__(27570);
|
|
15872
|
-
/**
|
|
15873
|
-
* 操作中心 Open API 网关客户端。
|
|
15874
|
-
*
|
|
15875
|
-
* 与 FHH 网关(request.ts,certificate 鉴权)平行:本通道走
|
|
15876
|
-
* `POST {apiUrl}/api/v1/commands/execute`,鉴权为 sharecrm 登录的
|
|
15877
|
-
* `Authorization: Bearer <FSDTK token>`。两网关票据不通用,命令注册以
|
|
15878
|
-
* docs/action-centre-integration.md 的实测记录为准(注意 code-dev function 新命名)。
|
|
15879
|
-
*/
|
|
15880
|
-
class OpenApiCommandError extends Error {
|
|
15881
|
-
constructor(message, resultCode, detail, traceId) {
|
|
15882
|
-
super(message);
|
|
15883
|
-
this.name = 'OpenApiCommandError';
|
|
15884
|
-
this.resultCode = resultCode;
|
|
15885
|
-
this.detail = detail;
|
|
15886
|
-
this.traceId = traceId;
|
|
15887
|
-
}
|
|
15888
|
-
}
|
|
15889
|
-
exports.OpenApiCommandError = OpenApiCommandError;
|
|
15890
|
-
function toExecuteUrl(apiUrl) {
|
|
15891
|
-
if (!apiUrl) {
|
|
15892
|
-
throw new Error('Login session is missing apiUrl. Run `sharedev auth login` again.');
|
|
15893
|
-
}
|
|
15894
|
-
return `${apiUrl.replace(/\/+$/, '')}/api/v1/commands/execute`;
|
|
15895
|
-
}
|
|
15896
|
-
async function buildCommandHeaders(session) {
|
|
15897
|
-
const locale = normalize_ts_1.default.normalizeAcceptLanguage(process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG);
|
|
15898
|
-
const { version } = await (0, pkgMeta_ts_1.readCliPackageMeta)();
|
|
15899
|
-
return {
|
|
15900
|
-
'Content-Type': 'application/json',
|
|
15901
|
-
Authorization: `Bearer ${session.accessToken}`,
|
|
15902
|
-
'X-CLI-Id': 'sharedev-cli',
|
|
15903
|
-
'X-CLI-Version': version || '0.0.0',
|
|
15904
|
-
'X-Caller-Type': 'cli',
|
|
15905
|
-
'X-Request-Id': (0, node_crypto_1.randomUUID)(),
|
|
15906
|
-
'Accept-Language': locale ?? 'en-US',
|
|
15907
|
-
'X-FS-Locale': locale ?? 'en-US'
|
|
15908
|
-
};
|
|
15909
|
-
}
|
|
15910
|
-
async function executeOnce(session, commandKey, args, flags) {
|
|
15911
|
-
const response = await fetch(toExecuteUrl(session.apiUrl), {
|
|
15912
|
-
method: 'POST',
|
|
15913
|
-
headers: await buildCommandHeaders(session),
|
|
15914
|
-
body: JSON.stringify({
|
|
15915
|
-
commandKey,
|
|
15916
|
-
arguments: args ?? {},
|
|
15917
|
-
...(flags?.length ? { flags } : {})
|
|
15918
|
-
})
|
|
15919
|
-
});
|
|
15920
|
-
let payload;
|
|
15921
|
-
try {
|
|
15922
|
-
payload = (await response.json());
|
|
15923
|
-
}
|
|
15924
|
-
catch {
|
|
15925
|
-
throw new OpenApiCommandError(`Open API command failed: HTTP ${response.status} ${response.statusText}`, `HTTP_${response.status}`);
|
|
15926
|
-
}
|
|
15927
|
-
if ((0, isDebugEnabled_ts_1.isRuntimeDebugEnabled)()) {
|
|
15928
|
-
const dataPreview = typeof payload.data === 'string'
|
|
15929
|
-
? payload.data.slice(0, 200)
|
|
15930
|
-
: JSON.stringify(payload.data ?? null)?.slice(0, 200);
|
|
15931
|
-
logger_ts_1.loggerService.debug(`Open API response: ${commandKey} -> ${payload.resultCode ?? 'UNKNOWN'} ${dataPreview ?? ''}`);
|
|
15932
|
-
}
|
|
15933
|
-
if (payload.traceId) {
|
|
15934
|
-
logger_ts_1.loggerService.addTraceId(payload.traceId);
|
|
15935
|
-
}
|
|
15936
|
-
if (payload.resultCode === 'SUCCESS') {
|
|
15937
|
-
if (payload.helpInfoReturned === true) {
|
|
15938
|
-
const usage = payload.data && typeof payload.data === 'object'
|
|
15939
|
-
? payload.data.usage
|
|
15940
|
-
: undefined;
|
|
15941
|
-
throw new OpenApiCommandError(`Open API command "${commandKey}" was not executed: missing required arguments.${usage ? `\nUsage: ${usage}` : ''}`, 'HELP_INFO_RETURNED');
|
|
15942
|
-
}
|
|
15943
|
-
// 外层信封中 traceId 已在上方消费、helpInfoReturned 已转错误,
|
|
15944
|
-
// 对调用方有价值的只剩 content——统一在此剥出,调用方直接拿业务数据
|
|
15945
|
-
const envelope = payload.data;
|
|
15946
|
-
return (typeof envelope === 'object' && envelope !== null ? envelope.content : undefined);
|
|
15947
|
-
}
|
|
15948
|
-
const detail = typeof payload.data === 'string' ? payload.data : JSON.stringify(payload.data ?? '');
|
|
15949
|
-
throw new OpenApiCommandError(`Open API command "${commandKey}" failed: ${payload.resultCode ?? 'UNKNOWN'}${detail ? ` ${detail}` : ''}`, payload.resultCode ?? 'UNKNOWN', detail || undefined, payload.traceId);
|
|
15950
|
-
}
|
|
15951
|
-
/**
|
|
15952
|
-
* 执行操作中心 Open API 命令,返回解包后的 content(外层信封已统一处理)。
|
|
15953
|
-
*
|
|
15954
|
-
* 未登录抛错引导 `sharedev auth login`;token 过期自动刷新;
|
|
15955
|
-
* 服务端返回 AUTH_FAIL 时刷新一次后重试(服务端会话失效场景)。
|
|
15956
|
-
* flags 用于透传确认标记等命令行语义(如 NEED_CONFIRM 的 --yes)。
|
|
15957
|
-
*/
|
|
15958
|
-
async function executeOpenApiCommand(commandKey, args = {}, options) {
|
|
15959
|
-
const session = await (0, sharecrm_session_ts_1.ensureValidSharedevAuthSession)();
|
|
15960
|
-
try {
|
|
15961
|
-
return await executeOnce(session, commandKey, args, options?.flags);
|
|
15962
|
-
}
|
|
15963
|
-
catch (error) {
|
|
15964
|
-
if (error instanceof OpenApiCommandError && error.resultCode === 'AUTH_FAIL') {
|
|
15965
|
-
const refreshed = await (0, sharecrm_session_ts_1.refreshSharecrmSession)(session);
|
|
15966
|
-
(0, sharecrm_session_ts_1.saveSharedevAuthSession)(refreshed);
|
|
15967
|
-
return await executeOnce(refreshed, commandKey, args, options?.flags);
|
|
15968
|
-
}
|
|
15969
|
-
throw error;
|
|
15970
|
-
}
|
|
15971
|
-
}
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
15754
|
/***/ },
|
|
15975
15755
|
|
|
15976
15756
|
/***/ 2067
|
|
@@ -16253,47 +16033,6 @@ class PassthroughCommandBuilder {
|
|
|
16253
16033
|
__webpack_unused_export__ = PassthroughCommandBuilder;
|
|
16254
16034
|
|
|
16255
16035
|
|
|
16256
|
-
/***/ },
|
|
16257
|
-
|
|
16258
|
-
/***/ 43355
|
|
16259
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
16260
|
-
|
|
16261
|
-
var __webpack_unused_export__;
|
|
16262
|
-
|
|
16263
|
-
__webpack_unused_export__ = ({ value: true });
|
|
16264
|
-
exports.configureRequestChannel = configureRequestChannel;
|
|
16265
|
-
exports.resolveRequestChannel = resolveRequestChannel;
|
|
16266
|
-
exports.hasCertificateCredential = hasCertificateCredential;
|
|
16267
|
-
const logger_ts_1 = __webpack_require__(87562);
|
|
16268
|
-
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
16269
|
-
let currentSettings;
|
|
16270
|
-
/** bootstrap 时注入运行时 settings(与 requestService.configure 同位置调用一次) */
|
|
16271
|
-
function configureRequestChannel(settings) {
|
|
16272
|
-
currentSettings = settings;
|
|
16273
|
-
}
|
|
16274
|
-
/** 解析当前应使用的请求通道;双登录态并存时登录态优先 */
|
|
16275
|
-
function resolveRequestChannel() {
|
|
16276
|
-
const session = (0, sharecrm_session_ts_1.readSharedevAuthSession)();
|
|
16277
|
-
if (session?.accessToken) {
|
|
16278
|
-
logger_ts_1.loggerService.debug('Request channel: openapi (sharecrm login).');
|
|
16279
|
-
return 'openapi';
|
|
16280
|
-
}
|
|
16281
|
-
if (currentSettings?.certificate?.trim()) {
|
|
16282
|
-
logger_ts_1.loggerService.debug('Request channel: fhh (certificate).');
|
|
16283
|
-
return 'fhh';
|
|
16284
|
-
}
|
|
16285
|
-
throw new Error('No credentials available. Run `sharedev auth login`, or configure certificate/domain in .sharedev/settings.json.');
|
|
16286
|
-
}
|
|
16287
|
-
/**
|
|
16288
|
-
* 是否存在可用的 certificate 凭证(与 resolveRequestChannel 的判定一致)。
|
|
16289
|
-
* 供个别命令在 openapi 能力未就绪期间做局部降级:登录态优先的原则管「能力对等时的选择」,
|
|
16290
|
-
* 能力缺失时(如 PWC download-file 未就绪)允许回退 certificate,避免功能回退。
|
|
16291
|
-
*/
|
|
16292
|
-
function hasCertificateCredential() {
|
|
16293
|
-
return Boolean(currentSettings?.certificate?.trim());
|
|
16294
|
-
}
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
16036
|
/***/ },
|
|
16298
16037
|
|
|
16299
16038
|
/***/ 23634
|
|
@@ -16725,46 +16464,11 @@ __webpack_unused_export__ = ({ value: true });
|
|
|
16725
16464
|
exports.y = void 0;
|
|
16726
16465
|
exports.executeShareCliCommand = executeShareCliCommand;
|
|
16727
16466
|
const request_ts_1 = __webpack_require__(83733);
|
|
16728
|
-
const request_channel_ts_1 = __webpack_require__(43355);
|
|
16729
|
-
const openapi_request_ts_1 = __webpack_require__(59848);
|
|
16730
16467
|
const trace_ts_1 = __webpack_require__(36097);
|
|
16731
16468
|
/** 操作中心 shareCli/execute 的业务方标识 */
|
|
16732
16469
|
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
|
-
/**
|
|
16747
|
-
* 执行操作中心命令(透传族统一入口)。
|
|
16748
|
-
*
|
|
16749
|
-
* 双通道(二期):sharecrm 登录态 → open API `commands/execute`(commandKey = commandPath 空格连接,
|
|
16750
|
-
* code-dev apl * 自动映射为迁移后的 function 命名空间);
|
|
16751
|
-
* certificate → FHH `shareCli/execute`(现状不动)。响应统一适配为 ShareCliExecuteResponse
|
|
16752
|
-
* 形态({success, code, message, data}),上层 PassthroughCommandManager 无感。
|
|
16753
|
-
*/
|
|
16754
16470
|
async function executeShareCliCommand(commandPath, data, others) {
|
|
16755
16471
|
(0, trace_ts_1.traceExecute)(commandPath.join(' '));
|
|
16756
|
-
const channel = (0, request_channel_ts_1.resolveRequestChannel)();
|
|
16757
|
-
if (channel === 'openapi') {
|
|
16758
|
-
// open API 侧确认协议:flags 形式(sharecrm 同款);agentChannels 为 FHH 侧统计标记,暂无对应物
|
|
16759
|
-
const flags = others?.yes === true ? ['--yes'] : undefined;
|
|
16760
|
-
const commandKey = toOpenApiCommandPath(commandPath).join(' ');
|
|
16761
|
-
const content = await (0, openapi_request_ts_1.executeOpenApiCommand)(commandKey, data ?? {}, flags ? { flags } : undefined);
|
|
16762
|
-
return {
|
|
16763
|
-
success: true,
|
|
16764
|
-
code: 'OK',
|
|
16765
|
-
data: content
|
|
16766
|
-
};
|
|
16767
|
-
}
|
|
16768
16472
|
const payload = {
|
|
16769
16473
|
commandPath,
|
|
16770
16474
|
// 所有 sharedev 发起的操作中心请求统一携带 agentChannels,服务端按 Agent 渠道路由/统计
|
|
@@ -17125,231 +16829,6 @@ class RequestService {
|
|
|
17125
16829
|
exports.requestService = new RequestService();
|
|
17126
16830
|
|
|
17127
16831
|
|
|
17128
|
-
/***/ },
|
|
17129
|
-
|
|
17130
|
-
/***/ 47166
|
|
17131
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17135
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17136
|
-
};
|
|
17137
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
17138
|
-
exports.DOMAIN_HOST_TO_LOGIN_ENV = void 0;
|
|
17139
|
-
exports.configureSharecrmSession = configureSharecrmSession;
|
|
17140
|
-
exports.getRuntimeRequire = getRuntimeRequire;
|
|
17141
|
-
exports.readSharecrmSession = readSharecrmSession;
|
|
17142
|
-
exports.saveSharedevAuthSession = saveSharedevAuthSession;
|
|
17143
|
-
exports.readSharedevAuthSession = readSharedevAuthSession;
|
|
17144
|
-
exports.clearSharedevAuthSession = clearSharedevAuthSession;
|
|
17145
|
-
exports.isSessionExpired = isSessionExpired;
|
|
17146
|
-
exports.refreshSharecrmSession = refreshSharecrmSession;
|
|
17147
|
-
exports.ensureValidSharedevAuthSession = ensureValidSharedevAuthSession;
|
|
17148
|
-
exports.readSharecrmConfig = readSharecrmConfig;
|
|
17149
|
-
const node_module_1 = __webpack_require__(98995);
|
|
17150
|
-
const node_fs_1 = __importDefault(__webpack_require__(73024));
|
|
17151
|
-
const node_os_1 = __importDefault(__webpack_require__(48161));
|
|
17152
|
-
const node_path_1 = __importDefault(__webpack_require__(76760));
|
|
17153
|
-
/**
|
|
17154
|
-
* 工作区企业 domain → 登录环境(open API 网关)映射(环境域知识的唯一登记处)。
|
|
17155
|
-
* 登录环境继承 init 配置的工作区环境(无交互选择)。
|
|
17156
|
-
* 新增环境(香港/国际等)在此登记即可。
|
|
17157
|
-
*/
|
|
17158
|
-
exports.DOMAIN_HOST_TO_LOGIN_ENV = {
|
|
17159
|
-
'www.fxiaoke.com': { authBaseUrl: 'https://open.fxiaoke.com/', apiBaseUrl: 'https://open.fxiaoke.com/cli/' },
|
|
17160
|
-
'crm.ceshi112.com': { authBaseUrl: 'https://open.ceshi112.com/', apiBaseUrl: 'https://open.ceshi112.com/cli/' }
|
|
17161
|
-
};
|
|
17162
|
-
const SESSION_FILE_NAME = 'session.json';
|
|
17163
|
-
const GITIGNORE_ENTRY = '.sharedev/session.json';
|
|
17164
|
-
/** 由 bootstrap 注入的工作区 .sharedev 目录;skipSettings 分支(--help 等)不会注入 */
|
|
17165
|
-
let currentSharedevDir;
|
|
17166
|
-
/** bootstrap 时注入工作区 settings(与 requestService.configure 同位置调用一次) */
|
|
17167
|
-
function configureSharecrmSession(settings) {
|
|
17168
|
-
currentSharedevDir = settings.settingsDir;
|
|
17169
|
-
}
|
|
17170
|
-
function resolveSessionFile(sharedevDir) {
|
|
17171
|
-
const dir = sharedevDir ?? currentSharedevDir;
|
|
17172
|
-
return dir ? node_path_1.default.join(dir, SESSION_FILE_NAME) : undefined;
|
|
17173
|
-
}
|
|
17174
|
-
/** 登录态写入 .sharedev/session.json 时确保工作区 .gitignore 覆盖该敏感文件(失败不阻断登录) */
|
|
17175
|
-
function ensureGitignoreEntry() {
|
|
17176
|
-
if (!currentSharedevDir) {
|
|
17177
|
-
return;
|
|
17178
|
-
}
|
|
17179
|
-
const workspaceRoot = node_path_1.default.dirname(currentSharedevDir);
|
|
17180
|
-
const gitignorePath = node_path_1.default.join(workspaceRoot, '.gitignore');
|
|
17181
|
-
try {
|
|
17182
|
-
let content = '';
|
|
17183
|
-
try {
|
|
17184
|
-
content = node_fs_1.default.readFileSync(gitignorePath, 'utf8');
|
|
17185
|
-
}
|
|
17186
|
-
catch {
|
|
17187
|
-
// .gitignore 不存在,直接创建
|
|
17188
|
-
}
|
|
17189
|
-
const covered = content.split('\n').some((line) => line.trim() === GITIGNORE_ENTRY);
|
|
17190
|
-
if (!covered) {
|
|
17191
|
-
const prefix = content && !content.endsWith('\n') ? '\n' : '';
|
|
17192
|
-
node_fs_1.default.appendFileSync(gitignorePath, `${prefix}${GITIGNORE_ENTRY}\n`);
|
|
17193
|
-
}
|
|
17194
|
-
}
|
|
17195
|
-
catch {
|
|
17196
|
-
// .gitignore 追加失败不阻断登录流程
|
|
17197
|
-
}
|
|
17198
|
-
}
|
|
17199
|
-
// createRequire(import.meta.url) 会被 webpack 静态求值为构建机的绝对源码路径,发布后失效;
|
|
17200
|
-
// 与 pwc beefly 加载一致:以运行时入口(bin/cli.mjs / dist/sharedev.js,即 process.argv[1])
|
|
17201
|
-
// 做解析基准,从 CLI 自身安装位置向上命中包内 node_modules 的 @share-crm/sharecrm-cli。
|
|
17202
|
-
// npm link 场景下 argv[1] 是全局 bin 的 symlink,Node 解析不穿透 symlink,字面路径向上
|
|
17203
|
-
// 找不到 node_modules,必须先 realpath 回真实安装位置再解析。
|
|
17204
|
-
function getRuntimeRequire() {
|
|
17205
|
-
const entry = process.argv[1] ?? process.cwd();
|
|
17206
|
-
try {
|
|
17207
|
-
return (0, node_module_1.createRequire)(node_fs_1.default.realpathSync(entry));
|
|
17208
|
-
}
|
|
17209
|
-
catch {
|
|
17210
|
-
return (0, node_module_1.createRequire)(entry);
|
|
17211
|
-
}
|
|
17212
|
-
}
|
|
17213
|
-
function loadAuthSessionStoreModule() {
|
|
17214
|
-
const require = getRuntimeRequire();
|
|
17215
|
-
return require('@share-crm/sharecrm-cli/dist/core/state/authSessionStore.js');
|
|
17216
|
-
}
|
|
17217
|
-
/** 读取 sharecrm 当前登录会话(login 中转用);未登录返回 null;依赖缺失/结构变化抛出可读错误 */
|
|
17218
|
-
async function readSharecrmSession() {
|
|
17219
|
-
let module;
|
|
17220
|
-
try {
|
|
17221
|
-
module = loadAuthSessionStoreModule();
|
|
17222
|
-
}
|
|
17223
|
-
catch {
|
|
17224
|
-
throw new Error('Failed to load @share-crm/sharecrm-cli. Reinstall sharedev dependencies and try again.');
|
|
17225
|
-
}
|
|
17226
|
-
if (!module || typeof module.AuthSessionStore !== 'function') {
|
|
17227
|
-
throw new Error('Incompatible @share-crm/sharecrm-cli detected (AuthSessionStore missing). Upgrade sharedev or @share-crm/sharecrm-cli.');
|
|
17228
|
-
}
|
|
17229
|
-
try {
|
|
17230
|
-
return await new module.AuthSessionStore().load();
|
|
17231
|
-
}
|
|
17232
|
-
catch (error) {
|
|
17233
|
-
// AuthSessionStore.load() 在未登录时返回 null 而不抛错;
|
|
17234
|
-
// 走到这里意味着本地会话存储读取失败(钥匙串被拒 / 文件损坏等),
|
|
17235
|
-
// 不是未登录——原样抛出,避免误导用户重新 login。
|
|
17236
|
-
throw new Error(`Failed to read sharecrm session store: ${error instanceof Error ? error.message : String(error)}`);
|
|
17237
|
-
}
|
|
17238
|
-
}
|
|
17239
|
-
function saveSharedevAuthSession(session) {
|
|
17240
|
-
const sessionFile = resolveSessionFile();
|
|
17241
|
-
if (!sessionFile) {
|
|
17242
|
-
throw new Error('Workspace context is not configured. Run this command inside a sharedev workspace.');
|
|
17243
|
-
}
|
|
17244
|
-
ensureGitignoreEntry();
|
|
17245
|
-
node_fs_1.default.writeFileSync(sessionFile, JSON.stringify(session, null, 2), { mode: 0o600 });
|
|
17246
|
-
}
|
|
17247
|
-
function readSharedevAuthSession(sharedevDir) {
|
|
17248
|
-
const sessionFile = resolveSessionFile(sharedevDir);
|
|
17249
|
-
if (!sessionFile) {
|
|
17250
|
-
return null;
|
|
17251
|
-
}
|
|
17252
|
-
try {
|
|
17253
|
-
const session = JSON.parse(node_fs_1.default.readFileSync(sessionFile, 'utf8'));
|
|
17254
|
-
return session && typeof session.accessToken === 'string' && session.accessToken ? session : null;
|
|
17255
|
-
}
|
|
17256
|
-
catch {
|
|
17257
|
-
return null;
|
|
17258
|
-
}
|
|
17259
|
-
}
|
|
17260
|
-
/** 只清当前工作区的登录凭证,不影响 sharecrm 自己的登录态 */
|
|
17261
|
-
function clearSharedevAuthSession() {
|
|
17262
|
-
const sessionFile = resolveSessionFile();
|
|
17263
|
-
if (!sessionFile) {
|
|
17264
|
-
return;
|
|
17265
|
-
}
|
|
17266
|
-
try {
|
|
17267
|
-
node_fs_1.default.rmSync(sessionFile, { force: true });
|
|
17268
|
-
}
|
|
17269
|
-
catch {
|
|
17270
|
-
// ignore
|
|
17271
|
-
}
|
|
17272
|
-
}
|
|
17273
|
-
function isSessionExpired(session) {
|
|
17274
|
-
return !session.tokenExpireAt || session.tokenExpireAt <= Date.now();
|
|
17275
|
-
}
|
|
17276
|
-
/** authBaseUrl 由登录下发的 apiUrl 推导(https://open.fxiaoke.com/cli/ -> https://open.fxiaoke.com/);缺失即凭证异常 */
|
|
17277
|
-
function deriveAuthBaseUrl(apiUrl) {
|
|
17278
|
-
if (!apiUrl) {
|
|
17279
|
-
throw new Error('Login session is missing apiUrl. Run `sharedev auth login` again.');
|
|
17280
|
-
}
|
|
17281
|
-
try {
|
|
17282
|
-
return `${new URL(apiUrl).origin}/`;
|
|
17283
|
-
}
|
|
17284
|
-
catch {
|
|
17285
|
-
throw new Error(`Invalid apiUrl in login session: ${apiUrl}. Run \`sharedev auth login\` again.`);
|
|
17286
|
-
}
|
|
17287
|
-
}
|
|
17288
|
-
/**
|
|
17289
|
-
* 用 refreshToken 刷新 accessToken(与 sharecrm 的 /oauth2.0/token 契约一致)。
|
|
17290
|
-
* 成功返回新会话(不落盘,由调用方决定是否保存),失败抛出带重登指引的错误。
|
|
17291
|
-
*/
|
|
17292
|
-
async function refreshSharecrmSession(session) {
|
|
17293
|
-
const response = await fetch(new URL('oauth2.0/token', deriveAuthBaseUrl(session.apiUrl)), {
|
|
17294
|
-
method: 'POST',
|
|
17295
|
-
headers: { 'Content-Type': 'application/json' },
|
|
17296
|
-
body: JSON.stringify({
|
|
17297
|
-
appId: session.appId,
|
|
17298
|
-
grantType: 'refresh_token',
|
|
17299
|
-
refreshToken: session.refreshToken
|
|
17300
|
-
})
|
|
17301
|
-
});
|
|
17302
|
-
let payload;
|
|
17303
|
-
try {
|
|
17304
|
-
payload = (await response.json());
|
|
17305
|
-
}
|
|
17306
|
-
catch {
|
|
17307
|
-
throw new Error(`sharecrm token refresh failed (HTTP ${response.status}). Run \`sharedev auth login\` again.`);
|
|
17308
|
-
}
|
|
17309
|
-
if (payload.errorCode !== 0 || !payload.accessToken) {
|
|
17310
|
-
throw new Error(`sharecrm token refresh failed: ${payload.errorMessage ?? `errorCode ${payload.errorCode}`}. Run \`sharedev auth login\` again.`);
|
|
17311
|
-
}
|
|
17312
|
-
// OAuth 刷新响应允许不回发新 refreshToken(沿用旧值,sharecrm 同款行为);
|
|
17313
|
-
// expiresIn 是计算过期时间的必要输入,缺失即报错
|
|
17314
|
-
if (typeof payload.expiresIn !== 'number' || !Number.isFinite(payload.expiresIn) || payload.expiresIn <= 0) {
|
|
17315
|
-
throw new Error('sharecrm token refresh response is missing expiresIn. Run `sharedev auth login` again.');
|
|
17316
|
-
}
|
|
17317
|
-
return {
|
|
17318
|
-
...session,
|
|
17319
|
-
accessToken: payload.accessToken,
|
|
17320
|
-
refreshToken: payload.refreshToken ?? session.refreshToken,
|
|
17321
|
-
tokenExpireAt: Date.now() + payload.expiresIn * 1000
|
|
17322
|
-
};
|
|
17323
|
-
}
|
|
17324
|
-
/** 读取工作区登录凭证并保证可用:过期时自动刷新并回写工作区文件 */
|
|
17325
|
-
async function ensureValidSharedevAuthSession() {
|
|
17326
|
-
const session = readSharedevAuthSession();
|
|
17327
|
-
if (!session) {
|
|
17328
|
-
throw new Error('Not logged in. Run `sharedev auth login` first.');
|
|
17329
|
-
}
|
|
17330
|
-
if (!isSessionExpired(session)) {
|
|
17331
|
-
return session;
|
|
17332
|
-
}
|
|
17333
|
-
const refreshed = await refreshSharecrmSession(session);
|
|
17334
|
-
saveSharedevAuthSession(refreshed);
|
|
17335
|
-
return refreshed;
|
|
17336
|
-
}
|
|
17337
|
-
/**
|
|
17338
|
-
* 读取 sharecrm 全局 config(login 前的环境冲突检测用:config 优先级高于环境变量注入,
|
|
17339
|
-
* 用户在 sharecrm 侧固定过环境时,sharedev 的环境注入会被压制)。
|
|
17340
|
-
*/
|
|
17341
|
-
function readSharecrmConfig() {
|
|
17342
|
-
const configPath = node_path_1.default.join(node_os_1.default.homedir(), '.sharecrm-cli', 'config.json');
|
|
17343
|
-
try {
|
|
17344
|
-
const config = JSON.parse(node_fs_1.default.readFileSync(configPath, 'utf8'));
|
|
17345
|
-
return config && typeof config === 'object' ? config : {};
|
|
17346
|
-
}
|
|
17347
|
-
catch {
|
|
17348
|
-
return {};
|
|
17349
|
-
}
|
|
17350
|
-
}
|
|
17351
|
-
|
|
17352
|
-
|
|
17353
16832
|
/***/ },
|
|
17354
16833
|
|
|
17355
16834
|
/***/ 36097
|
|
@@ -19458,47 +18937,7 @@ exports.createAplTemplate = createAplTemplate;
|
|
|
19458
18937
|
exports.createFuncSource = createFuncSource;
|
|
19459
18938
|
const node_crypto_1 = __webpack_require__(77598);
|
|
19460
18939
|
const request_ts_1 = __webpack_require__(83733);
|
|
19461
|
-
const openapi_request_ts_1 = __webpack_require__(59848);
|
|
19462
|
-
const request_channel_ts_1 = __webpack_require__(43355);
|
|
19463
|
-
/**
|
|
19464
|
-
* open API 通道的函数列表查询(sharecrm 登录态时替代 FHH biz/query)。
|
|
19465
|
-
* 参数形态 2026-10-21 实测:分页为字符串,name_space 为数组,binding 过滤与 FHH 同名。
|
|
19466
|
-
*/
|
|
19467
|
-
async function getFuncListViaOpenApi(options) {
|
|
19468
|
-
const args = { pageNumber: '1', pageSize: '3000' };
|
|
19469
|
-
const bind = options.bind?.trim();
|
|
19470
|
-
if (bind) {
|
|
19471
|
-
args.binding_object_api_name = bind;
|
|
19472
|
-
}
|
|
19473
|
-
const space = options.space?.trim();
|
|
19474
|
-
if (space) {
|
|
19475
|
-
args.name_space = [space];
|
|
19476
|
-
}
|
|
19477
|
-
const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', args);
|
|
19478
|
-
return content?.result?.function ?? [];
|
|
19479
|
-
}
|
|
19480
|
-
/**
|
|
19481
|
-
* open API 通道的单函数详情(sharecrm 登录态时替代 FHH biz/find / batchQuery)。
|
|
19482
|
-
* 响应含完整函数体(body 源码),字段与 IFuncData 同构(2026-10-21 实测)。
|
|
19483
|
-
*/
|
|
19484
|
-
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', {
|
|
19486
|
-
api_name: apiName,
|
|
19487
|
-
...(bindingObjectApiName ? { binding_object_api_name: bindingObjectApiName } : {})
|
|
19488
|
-
});
|
|
19489
|
-
if (content?.errCode && content.errCode !== 0) {
|
|
19490
|
-
throw new Error(content.errMessage || `APL function lookup failed (errCode ${content.errCode}): ${apiName}`);
|
|
19491
|
-
}
|
|
19492
|
-
const func = content?.result?.function;
|
|
19493
|
-
if (!func) {
|
|
19494
|
-
throw new Error(`APL function not found: ${apiName}`);
|
|
19495
|
-
}
|
|
19496
|
-
return func;
|
|
19497
|
-
}
|
|
19498
18940
|
async function getFuncList(options = {}) {
|
|
19499
|
-
if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
|
|
19500
|
-
return getFuncListViaOpenApi(options);
|
|
19501
|
-
}
|
|
19502
18941
|
const bindingObjectApiName = options.bind?.trim();
|
|
19503
18942
|
const nameSpace = options.space?.trim();
|
|
19504
18943
|
const data = {
|
|
@@ -19527,9 +18966,6 @@ async function findFuncByApiNames(apiNames) {
|
|
|
19527
18966
|
return response.function;
|
|
19528
18967
|
}
|
|
19529
18968
|
async function findFuncByApiName(apiName, bindingObjectApiName = '') {
|
|
19530
|
-
if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
|
|
19531
|
-
return findFuncByApiNameViaOpenApi(apiName, bindingObjectApiName);
|
|
19532
|
-
}
|
|
19533
18969
|
if (bindingObjectApiName) {
|
|
19534
18970
|
const response = await request_ts_1.requestService.FHH({
|
|
19535
18971
|
url: '/EM1HFUNC/biz/find',
|
|
@@ -21816,39 +21252,13 @@ var __webpack_unused_export__;
|
|
|
21816
21252
|
__webpack_unused_export__ = ({ value: true });
|
|
21817
21253
|
exports.aplListNewService = aplListNewService;
|
|
21818
21254
|
const request_execute_command_paths_ts_1 = __webpack_require__(23634);
|
|
21819
|
-
const openapi_request_ts_1 = __webpack_require__(59848);
|
|
21820
|
-
const request_channel_ts_1 = __webpack_require__(43355);
|
|
21821
|
-
const logger_ts_1 = __webpack_require__(87562);
|
|
21822
21255
|
const types_ts_1 = __webpack_require__(42801);
|
|
21823
21256
|
const request_ts_1 = __webpack_require__(25285);
|
|
21824
|
-
/**
|
|
21825
|
-
* open API 通道的 list-new 查询:open API 未注册 code-dev function list,
|
|
21826
|
-
* 等价能力为 object-dev function query(过滤参数同名,2026-10-21 实测);
|
|
21827
|
-
* 响应包成 AplResponse 兼容信封,下游解析逻辑零改动。
|
|
21828
|
-
*
|
|
21829
|
-
* ⚠️ body / selectFieldName 为 FHH 老链路参数,object-dev function query 不支持
|
|
21830
|
-
* (2026-10-21 实测:传入后被服务端静默忽略、过滤不生效),显式剔除并提示用户。
|
|
21831
|
-
*/
|
|
21832
|
-
const requestAplListViaOpenApi = async (filters) => {
|
|
21833
|
-
const { body, selectFieldName, ...supported } = filters;
|
|
21834
|
-
if (body !== undefined || selectFieldName !== undefined) {
|
|
21835
|
-
logger_ts_1.loggerService.warn('Filters "body" and "selectFieldName" are not supported on the sharecrm login channel and were ignored.');
|
|
21836
|
-
}
|
|
21837
|
-
const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', supported);
|
|
21838
|
-
return {
|
|
21839
|
-
success: true,
|
|
21840
|
-
code: 'OK',
|
|
21841
|
-
data: { result: { function: content?.result?.function ?? [] } },
|
|
21842
|
-
};
|
|
21843
|
-
};
|
|
21844
21257
|
/**
|
|
21845
21258
|
* 操作中心接口包装调用:apl list(分页查询函数列表)
|
|
21846
21259
|
* pageNumber/pageSize 为必填(服务端要求字符串形态),其余为可选过滤条件
|
|
21847
21260
|
*/
|
|
21848
21261
|
const requestAplListExecute = async (filters) => {
|
|
21849
|
-
if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
|
|
21850
|
-
return requestAplListViaOpenApi(filters);
|
|
21851
|
-
}
|
|
21852
21262
|
const data = {
|
|
21853
21263
|
pageNumber: filters.pageNumber,
|
|
21854
21264
|
pageSize: filters.pageSize
|
|
@@ -25907,150 +25317,6 @@ async function executeApprovalRuntimeShareCli(commandPath, data, others) {
|
|
|
25907
25317
|
}
|
|
25908
25318
|
|
|
25909
25319
|
|
|
25910
|
-
/***/ },
|
|
25911
|
-
|
|
25912
|
-
/***/ 52402
|
|
25913
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
25914
|
-
|
|
25915
|
-
|
|
25916
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25917
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25918
|
-
};
|
|
25919
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25920
|
-
exports.authLoginCommand = authLoginCommand;
|
|
25921
|
-
exports.authStatusCommand = authStatusCommand;
|
|
25922
|
-
exports.authLogoutCommand = authLogoutCommand;
|
|
25923
|
-
const node_child_process_1 = __webpack_require__(31421);
|
|
25924
|
-
const node_path_1 = __importDefault(__webpack_require__(76760));
|
|
25925
|
-
const logger_ts_1 = __webpack_require__(87562);
|
|
25926
|
-
const openapi_request_ts_1 = __webpack_require__(59848);
|
|
25927
|
-
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
25928
|
-
/** 解析依赖包 @share-crm/sharecrm-cli 的 bin 入口(不走 PATH / 全局安装) */
|
|
25929
|
-
function resolveSharecrmBinEntry() {
|
|
25930
|
-
const require = (0, sharecrm_session_ts_1.getRuntimeRequire)();
|
|
25931
|
-
const packageJsonPath = require.resolve('@share-crm/sharecrm-cli/package.json');
|
|
25932
|
-
return node_path_1.default.join(node_path_1.default.dirname(packageJsonPath), 'dist', 'index.js');
|
|
25933
|
-
}
|
|
25934
|
-
/** 从工作区 domain 推导登录环境;未知 domain 报错并列出受支持的环境 */
|
|
25935
|
-
function deriveLoginEnvFromDomain(domain) {
|
|
25936
|
-
let host;
|
|
25937
|
-
try {
|
|
25938
|
-
host = new URL(domain).hostname;
|
|
25939
|
-
}
|
|
25940
|
-
catch {
|
|
25941
|
-
throw new Error(`Invalid workspace domain: ${domain}. Fix it in .sharedev/settings.json or run \`sharedev init\`.`);
|
|
25942
|
-
}
|
|
25943
|
-
const loginEnv = sharecrm_session_ts_1.DOMAIN_HOST_TO_LOGIN_ENV[host];
|
|
25944
|
-
if (!loginEnv) {
|
|
25945
|
-
const supported = Object.keys(sharecrm_session_ts_1.DOMAIN_HOST_TO_LOGIN_ENV).join(', ');
|
|
25946
|
-
throw new Error(`Workspace domain "${host}" has no known login environment mapping (supported: ${supported}). ` +
|
|
25947
|
-
'Ask the sharedev maintainers to add it, or switch the workspace domain.');
|
|
25948
|
-
}
|
|
25949
|
-
return loginEnv;
|
|
25950
|
-
}
|
|
25951
|
-
async function authLoginCommand(domain) {
|
|
25952
|
-
const loginEnv = deriveLoginEnvFromDomain(domain);
|
|
25953
|
-
// sharecrm 全局 config 优先级高于环境变量注入,固定过环境时会压制工作区推导——提前拦截
|
|
25954
|
-
const sharecrmConfig = (0, sharecrm_session_ts_1.readSharecrmConfig)();
|
|
25955
|
-
const pinned = sharecrmConfig.authBaseUrl?.trim();
|
|
25956
|
-
if (pinned && pinned.replace(/\/+$/, '') !== loginEnv.authBaseUrl.replace(/\/+$/, '')) {
|
|
25957
|
-
throw new Error(`sharecrm global config pins login environment to ${pinned}, conflicting with workspace (${loginEnv.authBaseUrl}). ` +
|
|
25958
|
-
'Remove authBaseUrl from ~/.sharecrm-cli/config.json or fix the workspace domain.');
|
|
25959
|
-
}
|
|
25960
|
-
let entry;
|
|
25961
|
-
try {
|
|
25962
|
-
entry = resolveSharecrmBinEntry();
|
|
25963
|
-
}
|
|
25964
|
-
catch {
|
|
25965
|
-
throw new Error('Failed to locate @share-crm/sharecrm-cli. Reinstall sharedev dependencies and try again.');
|
|
25966
|
-
}
|
|
25967
|
-
logger_ts_1.loggerService.info(`Login environment (from workspace domain): ${loginEnv.authBaseUrl}`);
|
|
25968
|
-
logger_ts_1.loggerService.info('Starting sharecrm device-flow login. Complete the authorization in your browser.');
|
|
25969
|
-
// 环境通过环境变量注入子进程(优先级低于 sharecrm config,上面已检测冲突),不写 sharecrm 全局配置
|
|
25970
|
-
const exitCode = await new Promise((resolve, reject) => {
|
|
25971
|
-
const child = (0, node_child_process_1.spawn)(process.execPath, [entry, 'auth', 'share-dev-login'], {
|
|
25972
|
-
stdio: 'inherit',
|
|
25973
|
-
env: {
|
|
25974
|
-
...process.env,
|
|
25975
|
-
FS_CLI_AUTH_BASE_URL: loginEnv.authBaseUrl,
|
|
25976
|
-
FS_CLI_API_BASE_URL: loginEnv.apiBaseUrl
|
|
25977
|
-
}
|
|
25978
|
-
});
|
|
25979
|
-
child.on('error', reject);
|
|
25980
|
-
child.on('exit', (code) => resolve(code));
|
|
25981
|
-
});
|
|
25982
|
-
if (exitCode !== 0) {
|
|
25983
|
-
throw new Error(`sharecrm auth share-dev-login exited with code ${exitCode ?? 'unknown'}.`);
|
|
25984
|
-
}
|
|
25985
|
-
const session = await (0, sharecrm_session_ts_1.readSharecrmSession)();
|
|
25986
|
-
if (!session?.accessToken) {
|
|
25987
|
-
throw new Error('sharecrm login finished but no session was stored. Run `sharedev auth login` again.');
|
|
25988
|
-
}
|
|
25989
|
-
// 中转完成:凭证固化到工作区(.sharedev/session.json,凭证跟工作区走)
|
|
25990
|
-
(0, sharecrm_session_ts_1.saveSharedevAuthSession)(session);
|
|
25991
|
-
logger_ts_1.loggerService.success(`Logged in as ${session.userName || `user ${session.userId}`} (appId ${session.appId}).`);
|
|
25992
|
-
// 端到端验证 Open API 通道(只读查询;失败仅 warn,部分环境命令集较旧属已知限制)
|
|
25993
|
-
try {
|
|
25994
|
-
const result = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', {
|
|
25995
|
-
pageNumber: '1',
|
|
25996
|
-
pageSize: '1'
|
|
25997
|
-
});
|
|
25998
|
-
const total = result?.result?.totalNumber;
|
|
25999
|
-
logger_ts_1.loggerService.success(`Open API channel verified${typeof total === 'number' ? `: ${total} functions visible` : ''}.`);
|
|
26000
|
-
}
|
|
26001
|
-
catch (error) {
|
|
26002
|
-
logger_ts_1.loggerService.warn(`Open API channel verification failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
26003
|
-
}
|
|
26004
|
-
}
|
|
26005
|
-
function formatExpireTime(session) {
|
|
26006
|
-
if (!session.tokenExpireAt) {
|
|
26007
|
-
return 'unknown';
|
|
26008
|
-
}
|
|
26009
|
-
return new Date(session.tokenExpireAt).toLocaleString();
|
|
26010
|
-
}
|
|
26011
|
-
async function authStatusCommand(settings) {
|
|
26012
|
-
const session = (0, sharecrm_session_ts_1.readSharedevAuthSession)();
|
|
26013
|
-
logger_ts_1.loggerService.info(`Workspace environment: ${settings.domain}`);
|
|
26014
|
-
if (!session) {
|
|
26015
|
-
logger_ts_1.loggerService.info('sharecrm login: not logged in. Run `sharedev auth login`.');
|
|
26016
|
-
}
|
|
26017
|
-
else {
|
|
26018
|
-
const expired = (0, sharecrm_session_ts_1.isSessionExpired)(session);
|
|
26019
|
-
logger_ts_1.loggerService.info([
|
|
26020
|
-
`sharecrm login: ${session.userName || `user ${session.userId}`} (appId ${session.appId})`,
|
|
26021
|
-
` apiUrl: ${session.apiUrl ?? 'https://open.fxiaoke.com/cli/'}`,
|
|
26022
|
-
` token : ${expired ? 'expired, will auto-refresh on next command' : `valid until ${formatExpireTime(session)}`}`
|
|
26023
|
-
].join('\n'));
|
|
26024
|
-
}
|
|
26025
|
-
// certificate 方式状态(老登录方式,配置在 .sharedev/settings.json;来自 bootstrap 加载的 settings)
|
|
26026
|
-
if (settings.certificate?.trim()) {
|
|
26027
|
-
logger_ts_1.loggerService.info(`certificate login: configured (${settings.settingsPath})`);
|
|
26028
|
-
}
|
|
26029
|
-
else {
|
|
26030
|
-
logger_ts_1.loggerService.info('certificate login: not configured');
|
|
26031
|
-
}
|
|
26032
|
-
}
|
|
26033
|
-
async function authLogoutCommand() {
|
|
26034
|
-
(0, sharecrm_session_ts_1.clearSharedevAuthSession)();
|
|
26035
|
-
logger_ts_1.loggerService.success('Workspace login state cleared (sharecrm own session is untouched).');
|
|
26036
|
-
}
|
|
26037
|
-
|
|
26038
|
-
|
|
26039
|
-
/***/ },
|
|
26040
|
-
|
|
26041
|
-
/***/ 98695
|
|
26042
|
-
(__unused_webpack_module, exports, __webpack_require__) {
|
|
26043
|
-
|
|
26044
|
-
var __webpack_unused_export__;
|
|
26045
|
-
|
|
26046
|
-
__webpack_unused_export__ = ({ value: true });
|
|
26047
|
-
exports.authLogoutCommand = exports.authStatusCommand = exports.authLoginCommand = void 0;
|
|
26048
|
-
var auth_command_ts_1 = __webpack_require__(52402);
|
|
26049
|
-
Object.defineProperty(exports, "authLoginCommand", ({ enumerable: true, get: function () { return auth_command_ts_1.authLoginCommand; } }));
|
|
26050
|
-
Object.defineProperty(exports, "authStatusCommand", ({ enumerable: true, get: function () { return auth_command_ts_1.authStatusCommand; } }));
|
|
26051
|
-
Object.defineProperty(exports, "authLogoutCommand", ({ enumerable: true, get: function () { return auth_command_ts_1.authLogoutCommand; } }));
|
|
26052
|
-
|
|
26053
|
-
|
|
26054
25320
|
/***/ },
|
|
26055
25321
|
|
|
26056
25322
|
/***/ 73302
|
|
@@ -26141,7 +25407,33 @@ async function bpmDefUpdateDefinitionCommand(_context, options) {
|
|
|
26141
25407
|
nameTranslateInfo: "object",
|
|
26142
25408
|
descTranslateInfo: "object"
|
|
26143
25409
|
};
|
|
26144
|
-
const
|
|
25410
|
+
const updates = buildOptionsData(options, typeMap);
|
|
25411
|
+
// 服务端为全量更新语义:必须先按 --id 拉取完整定义,再合并增量提交
|
|
25412
|
+
if (!updates.id) {
|
|
25413
|
+
throw new Error('bpm-dev update-definition requires --id to locate and load the full definition.');
|
|
25414
|
+
}
|
|
25415
|
+
const changedFields = Object.keys(updates).filter((key) => key !== 'id');
|
|
25416
|
+
if (changedFields.length === 0) {
|
|
25417
|
+
throw new Error('bpm-dev update-definition requires at least one field to update besides --id.');
|
|
25418
|
+
}
|
|
25419
|
+
logger_ts_1.loggerService.startLoading('Loading bpmDef detail for full definition');
|
|
25420
|
+
let outline;
|
|
25421
|
+
try {
|
|
25422
|
+
const detailResponse = await (0, bpm_def_service_ts_1.executeBpmDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('bpmDef', 'detail'), { id: updates.id });
|
|
25423
|
+
logger_ts_1.loggerService.stopLoading();
|
|
25424
|
+
const envelope = (detailResponse && typeof detailResponse === 'object')
|
|
25425
|
+
? detailResponse
|
|
25426
|
+
: {};
|
|
25427
|
+
if (envelope.success !== true || !envelope.data?.outline) {
|
|
25428
|
+
throw new Error(`Failed to load full definition via bpmDef detail: ${envelope.message ?? 'outline missing'}.`);
|
|
25429
|
+
}
|
|
25430
|
+
outline = envelope.data.outline;
|
|
25431
|
+
}
|
|
25432
|
+
catch (error) {
|
|
25433
|
+
logger_ts_1.loggerService.stopLoading();
|
|
25434
|
+
throw error;
|
|
25435
|
+
}
|
|
25436
|
+
const data = { ...outline, ...updates };
|
|
26145
25437
|
logger_ts_1.loggerService.startLoading('Executing bpmDef update-definition');
|
|
26146
25438
|
try {
|
|
26147
25439
|
const response = await (0, bpm_def_service_ts_1.executeBpmDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('bpmDef', 'updateDefinition'), data);
|
|
@@ -29459,7 +28751,7 @@ async function collectInitSettings(options) {
|
|
|
29459
28751
|
domain = await askWithDefault('Enter enterprise domain', 'https://www.fxiaoke.com');
|
|
29460
28752
|
}
|
|
29461
28753
|
if (!certificate) {
|
|
29462
|
-
certificate = await askWithDefault('Enter developer certificate
|
|
28754
|
+
certificate = await askWithDefault('Enter developer certificate');
|
|
29463
28755
|
}
|
|
29464
28756
|
// if (!developerName) {
|
|
29465
28757
|
// developerName = await askWithDefault('Enter your developer name (optional)');
|
|
@@ -29477,8 +28769,9 @@ async function collectInitSettings(options) {
|
|
|
29477
28769
|
if (!isValidUrl(domain)) {
|
|
29478
28770
|
throw new Error('Invalid enterprise domain URL. Use a full URL, e.g. https://www.fxiaoke.com.');
|
|
29479
28771
|
}
|
|
29480
|
-
|
|
29481
|
-
|
|
28772
|
+
if (!certificate) {
|
|
28773
|
+
throw new Error('Missing developer certificate. Use --certificate or provide it in interactive mode.');
|
|
28774
|
+
}
|
|
29482
28775
|
return {
|
|
29483
28776
|
enterpriseEA,
|
|
29484
28777
|
domain,
|
|
@@ -34147,11 +33440,13 @@ exports.objectDevImportSettingPushCommand = objectDevImportSettingPushCommand;
|
|
|
34147
33440
|
var __webpack_unused_export__;
|
|
34148
33441
|
|
|
34149
33442
|
__webpack_unused_export__ = ({ value: true });
|
|
34150
|
-
exports.
|
|
34151
|
-
exports.objectDevPrintTemplateDeleteCommand = exports.objectDevPrintTemplatePushCommand = exports.objectDevPrintTemplateUpdateCommand = exports.objectDevPrintTemplateCreateCommand = exports.objectDevPrintTemplatePullCommand = __webpack_unused_export__ = exports.objectDevEmailTemplateDeleteCommand = exports.objectDevEmailTemplatePushCommand = exports.objectDevEmailTemplateUpdateCommand = exports.objectDevEmailTemplateCreateCommand = exports.objectDevEmailTemplatePullCommand = exports.objectDevEmailTemplateListCommand = exports.objectDevObjectPluginPushCommand = exports.objectDevObjectPluginUpdateCommand = exports.objectDevObjectPluginCreateCommand = exports.objectDevObjectPluginPullCommand = exports.objectDevTagPushCommand = exports.objectDevTagUpdateCommand = exports.objectDevTagCreateCommand = exports.objectDevTagPullCommand = exports.objectDevImportSettingPushCommand = exports.objectDevImportSettingUpdateCommand = exports.objectDevImportSettingPullCommand = exports.objectDevObjectExtensionPushCommand = exports.objectDevObjectExtensionUpdateCommand = exports.objectDevObjectExtensionCreateCommand = exports.objectDevObjectExtensionPullCommand = exports.objectDevArchiveRulePushCommand = exports.objectDevArchiveRuleUpdateCommand = exports.objectDevArchiveRuleCreateCommand = exports.objectDevArchiveRulePullCommand = exports.objectDevConvertRulePushCommand = exports.objectDevConvertRuleUpdateCommand = exports.objectDevConvertRuleCreateCommand = exports.objectDevConvertRulePullCommand = exports.objectDevConvertRuleListCommand = exports.objectDevObjectMappingPushCommand = void 0;
|
|
33443
|
+
exports.objectDevObjectMappingPullCommand = exports.objectDevButtonPushCommand = exports.objectDevButtonUpdateCommand = exports.objectDevButtonCreateCommand = exports.objectDevButtonPullCommand = exports.objectDevButtonListCommand = exports.objectDevValidateRuleUpdateCommand = exports.objectDevValidateRulePushCommand = exports.objectDevValidateRulePullCommand = exports.objectDevValidateRuleListCommand = exports.objectDevValidateRuleCreateCommand = exports.objectDevLayoutRuleUpdateCommand = exports.objectDevLayoutRulePushCommand = exports.objectDevLayoutRulePullCommand = exports.objectDevLayoutRuleListCommand = exports.objectDevLayoutRuleCreateCommand = exports.objectDevLayoutUpdateCommand = exports.objectDevLayoutPushCommand = exports.objectDevLayoutPullCommand = exports.objectDevLayoutListCommand = exports.objectDevLayoutEnableEditCommand = exports.objectDevLayoutEditStatusCommand = exports.objectDevLayoutCreateCommand = exports.objectDevFieldPushCommand = exports.objectDevFieldUpdateCommand = exports.objectDevFieldCreateCommand = exports.objectDevFieldListCommand = exports.objectDevObjectPushCommand = exports.objectDevObjectUpdateCommand = exports.objectDevObjectCreateCommand = exports.objectDevSceneUpdateCommand = exports.objectDevScenePushCommand = exports.objectDevScenePullCommand = exports.objectDevSceneListCommand = exports.objectDevSceneCreateCommand = exports.objectDevMultiCurrencyPushCommand = exports.objectDevMultiCurrencyPullCommand = exports.objectDevGlobalVariablePushCommand = exports.objectDevGlobalVariablePullCommand = exports.objectDevOptionSetUpdateCommand = exports.objectDevOptionSetPushCommand = exports.objectDevOptionSetPullCommand = exports.objectDevOptionSetListCommand = exports.objectDevOptionSetDeleteCommand = exports.objectDevOptionSetCreateCommand = exports.objectDevObjectRelatedPullCommand = __webpack_unused_export__ = __webpack_unused_export__ = exports.objectDevObjectPullCommand = exports.objectDevObjectListCommand = void 0;
|
|
33444
|
+
exports.objectDevPrintTemplateDeleteCommand = exports.objectDevPrintTemplatePushCommand = exports.objectDevPrintTemplateUpdateCommand = exports.objectDevPrintTemplateCreateCommand = exports.objectDevPrintTemplatePullCommand = __webpack_unused_export__ = exports.objectDevEmailTemplateDeleteCommand = exports.objectDevEmailTemplatePushCommand = exports.objectDevEmailTemplateUpdateCommand = exports.objectDevEmailTemplateCreateCommand = exports.objectDevEmailTemplatePullCommand = exports.objectDevEmailTemplateListCommand = exports.objectDevObjectPluginPushCommand = exports.objectDevObjectPluginUpdateCommand = exports.objectDevObjectPluginCreateCommand = exports.objectDevObjectPluginPullCommand = exports.objectDevTagPushCommand = exports.objectDevTagUpdateCommand = exports.objectDevTagCreateCommand = exports.objectDevTagPullCommand = exports.objectDevImportSettingPushCommand = exports.objectDevImportSettingUpdateCommand = exports.objectDevImportSettingPullCommand = exports.objectDevObjectExtensionPushCommand = exports.objectDevObjectExtensionUpdateCommand = exports.objectDevObjectExtensionCreateCommand = exports.objectDevObjectExtensionPullCommand = exports.objectDevArchiveRulePushCommand = exports.objectDevArchiveRuleUpdateCommand = exports.objectDevArchiveRuleCreateCommand = exports.objectDevArchiveRulePullCommand = exports.objectDevConvertRulePushCommand = exports.objectDevConvertRuleUpdateCommand = exports.objectDevConvertRuleCreateCommand = exports.objectDevConvertRulePullCommand = exports.objectDevConvertRuleListCommand = exports.objectDevObjectMappingPushCommand = exports.objectDevObjectMappingUpdateCommand = exports.objectDevObjectMappingCreateCommand = void 0;
|
|
34152
33445
|
var object_ts_1 = __webpack_require__(13087);
|
|
34153
33446
|
Object.defineProperty(exports, "objectDevObjectListCommand", ({ enumerable: true, get: function () { return object_ts_1.objectDevObjectListCommand; } }));
|
|
34154
33447
|
Object.defineProperty(exports, "objectDevObjectPullCommand", ({ enumerable: true, get: function () { return object_ts_1.objectDevObjectPullCommand; } }));
|
|
33448
|
+
__webpack_unused_export__ = ({ enumerable: true, get: function () { return object_ts_1.ObjectDevObjectListOptions; } });
|
|
33449
|
+
__webpack_unused_export__ = ({ enumerable: true, get: function () { return object_ts_1.ObjectDevObjectPullOptions; } });
|
|
34155
33450
|
var object_related_ts_1 = __webpack_require__(90165);
|
|
34156
33451
|
Object.defineProperty(exports, "objectDevObjectRelatedPullCommand", ({ enumerable: true, get: function () { return object_related_ts_1.objectDevObjectRelatedPullCommand; } }));
|
|
34157
33452
|
var option_set_ts_1 = __webpack_require__(98892);
|
|
@@ -41703,9 +40998,9 @@ async function objectPullService(shouldQueryAll, queryType = null, apiName, skip
|
|
|
41703
40998
|
logger_ts_1.loggerService.info(`Skipped public object count: ${skippedPublicApiNames.length}`);
|
|
41704
40999
|
}
|
|
41705
41000
|
}
|
|
41706
|
-
//
|
|
41001
|
+
// 20个分批拉取
|
|
41707
41002
|
const apiNamesListGroups = apiNamesList.reduce((acc, item, index) => {
|
|
41708
|
-
const groupIndex = Math.floor(index /
|
|
41003
|
+
const groupIndex = Math.floor(index / 20);
|
|
41709
41004
|
if (!acc[groupIndex]) {
|
|
41710
41005
|
acc[groupIndex] = [];
|
|
41711
41006
|
}
|
|
@@ -45939,12 +45234,12 @@ exports.pwcInfoCommand = pwcInfoCommand;
|
|
|
45939
45234
|
exports.pwcDevCommand = pwcDevCommand;
|
|
45940
45235
|
exports.pwcPlaceholderCommand = pwcPlaceholderCommand;
|
|
45941
45236
|
const node_path_1 = __importDefault(__webpack_require__(76760));
|
|
45237
|
+
const node_module_1 = __webpack_require__(98995);
|
|
45942
45238
|
const prompts_1 = __webpack_require__(53503);
|
|
45943
45239
|
const file_ts_1 = __webpack_require__(57452);
|
|
45944
45240
|
const zip_ts_1 = __webpack_require__(89139);
|
|
45945
45241
|
const logger_ts_1 = __webpack_require__(87562);
|
|
45946
45242
|
const request_ts_1 = __webpack_require__(83733);
|
|
45947
|
-
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
45948
45243
|
const pwc_service_ts_1 = __webpack_require__(63358);
|
|
45949
45244
|
const pwc_types_ts_1 = __webpack_require__(55844);
|
|
45950
45245
|
const pwc_mateXml_ts_1 = __webpack_require__(53683);
|
|
@@ -46381,10 +45676,11 @@ async function pwcDevCommand(filePath, context, options = {}) {
|
|
|
46381
45676
|
logger_ts_1.loggerService.info(shouldQueryAll
|
|
46382
45677
|
? `Starting Beefly dev server for ${outputNames.length} entr${outputNames.length === 1 ? 'y' : 'ies'}`
|
|
46383
45678
|
: `Starting Beefly dev server with ${normalizedFilePath}`);
|
|
46384
|
-
//
|
|
46385
|
-
//
|
|
46386
|
-
//
|
|
46387
|
-
const
|
|
45679
|
+
// createRequire(import.meta.url) 会被 webpack 静态求值为构建机的绝对源码路径,发布后失效;
|
|
45680
|
+
// 改用运行时入口路径(bin/cli.mjs / dist/sharedev.js,即 process.argv[1])做解析基准,
|
|
45681
|
+
// 从 CLI 自身安装位置向上命中包内 node_modules 的 @share-crm/beefly。
|
|
45682
|
+
const require = (0, node_module_1.createRequire)(process.argv[1] ?? process.cwd());
|
|
45683
|
+
const beefly = require('@share-crm/beefly');
|
|
46388
45684
|
// 复用 Beefly 官方 API 启动 webpack dev server,入口名称决定预览产物名称。
|
|
46389
45685
|
const server = await beefly.cli.dev({
|
|
46390
45686
|
port: options.port,
|
|
@@ -47297,7 +46593,6 @@ function validatePwcMateXmlContent(input) {
|
|
|
47297
46593
|
var __webpack_unused_export__;
|
|
47298
46594
|
|
|
47299
46595
|
__webpack_unused_export__ = ({ value: true });
|
|
47300
|
-
exports.assertPwcFileUploadChannel = assertPwcFileUploadChannel;
|
|
47301
46596
|
exports.fetchCode = fetchCode;
|
|
47302
46597
|
exports.fetchCodeByType = fetchCodeByType;
|
|
47303
46598
|
exports.updateCodeSource = updateCodeSource;
|
|
@@ -47311,41 +46606,7 @@ exports.createPluginSource = createPluginSource;
|
|
|
47311
46606
|
exports.enablePwcResource = enablePwcResource;
|
|
47312
46607
|
exports.getUrlByApiName = getUrlByApiName;
|
|
47313
46608
|
const request_ts_1 = __webpack_require__(83733);
|
|
47314
|
-
const request_channel_ts_1 = __webpack_require__(43355);
|
|
47315
|
-
const logger_ts_1 = __webpack_require__(87562);
|
|
47316
|
-
/**
|
|
47317
|
-
* PWC 命令的通道保护:openapi 能力未就绪期间——
|
|
47318
|
-
* 有 certificate 则 warn 后降级走 FHH(避免登录态+certificate 并存的功能回退);
|
|
47319
|
-
* 无 certificate 抛错引导配置。待服务端 download-file 修复后移除。
|
|
47320
|
-
*/
|
|
47321
|
-
function assertPwcChannelOrFallback() {
|
|
47322
|
-
if ((0, request_channel_ts_1.resolveRequestChannel)() !== 'openapi') {
|
|
47323
|
-
return;
|
|
47324
|
-
}
|
|
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.');
|
|
47332
|
-
}
|
|
47333
|
-
/**
|
|
47334
|
-
* PWC 文件上传环节的通道断言:*-new 链路主体走 openapi(code-dev 命令),
|
|
47335
|
-
* 但源码包上传(uploadFileList)仍依赖 FHH——纯登录态时给出明确引导而非服务端原始报错。
|
|
47336
|
-
*/
|
|
47337
|
-
function assertPwcFileUploadChannel() {
|
|
47338
|
-
if ((0, request_channel_ts_1.resolveRequestChannel)() !== 'openapi') {
|
|
47339
|
-
return;
|
|
47340
|
-
}
|
|
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.');
|
|
47346
|
-
}
|
|
47347
46609
|
async function fetchCode(type, apiName) {
|
|
47348
|
-
assertPwcChannelOrFallback();
|
|
47349
46610
|
const response = await request_ts_1.requestService.FHH({
|
|
47350
46611
|
url: '/EM2HCompBuild/VscodeExtension/downloadCode',
|
|
47351
46612
|
data: {
|
|
@@ -47356,7 +46617,6 @@ async function fetchCode(type, apiName) {
|
|
|
47356
46617
|
return response.components ?? [];
|
|
47357
46618
|
}
|
|
47358
46619
|
async function fetchCodeByType(type) {
|
|
47359
|
-
assertPwcChannelOrFallback();
|
|
47360
46620
|
const response = await request_ts_1.requestService.FHH({
|
|
47361
46621
|
url: '/EM2HCompBuild/VscodeExtension/downloadCode',
|
|
47362
46622
|
data: {
|
|
@@ -47410,14 +46670,12 @@ async function updatePluginSource(apiName, params) {
|
|
|
47410
46670
|
});
|
|
47411
46671
|
}
|
|
47412
46672
|
async function updateCodeSource(type, apiName, params) {
|
|
47413
|
-
assertPwcChannelOrFallback();
|
|
47414
46673
|
if (type === 'plugin') {
|
|
47415
46674
|
return updatePluginSource(apiName, params);
|
|
47416
46675
|
}
|
|
47417
46676
|
return updateComponentSource(apiName, params);
|
|
47418
46677
|
}
|
|
47419
46678
|
async function buildCode(type, apiName, client = 'web') {
|
|
47420
|
-
assertPwcChannelOrFallback();
|
|
47421
46679
|
if (type === 'component') {
|
|
47422
46680
|
return request_ts_1.requestService.FHH({
|
|
47423
46681
|
url: '/EM9HCompBuild/Component/AsynBuildComponent',
|
|
@@ -47430,7 +46688,6 @@ async function buildCode(type, apiName, client = 'web') {
|
|
|
47430
46688
|
});
|
|
47431
46689
|
}
|
|
47432
46690
|
async function getBuildResult(buildId, type) {
|
|
47433
|
-
assertPwcChannelOrFallback();
|
|
47434
46691
|
return request_ts_1.requestService.FHH({
|
|
47435
46692
|
url: `/EM1HCompBuild/${type}/getBuildResult`,
|
|
47436
46693
|
data: { buildId }
|
|
@@ -47469,7 +46726,6 @@ async function hydratePwcComponent(component) {
|
|
|
47469
46726
|
};
|
|
47470
46727
|
}
|
|
47471
46728
|
async function getPwcConfig() {
|
|
47472
|
-
assertPwcChannelOrFallback();
|
|
47473
46729
|
const response = await request_ts_1.requestService.FHH({
|
|
47474
46730
|
url: '/EM1HCompBuild/Component/getConfig',
|
|
47475
46731
|
data: {}
|
|
@@ -47477,7 +46733,6 @@ async function getPwcConfig() {
|
|
|
47477
46733
|
return response.config ?? {};
|
|
47478
46734
|
}
|
|
47479
46735
|
async function getObjectApiNames() {
|
|
47480
|
-
assertPwcChannelOrFallback();
|
|
47481
46736
|
const response = await request_ts_1.requestService.FHH({
|
|
47482
46737
|
url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeManageList',
|
|
47483
46738
|
data: {
|
|
@@ -47494,14 +46749,12 @@ async function getObjectApiNames() {
|
|
|
47494
46749
|
.filter((item) => Boolean(item)))).sort((a, b) => a.localeCompare(b));
|
|
47495
46750
|
}
|
|
47496
46751
|
async function createComponentSource(data) {
|
|
47497
|
-
assertPwcChannelOrFallback();
|
|
47498
46752
|
await request_ts_1.requestService.FHH({
|
|
47499
46753
|
url: '/EM1HCompBuild/Component/createComponent',
|
|
47500
46754
|
data
|
|
47501
46755
|
});
|
|
47502
46756
|
}
|
|
47503
46757
|
async function createPluginSource(data) {
|
|
47504
|
-
assertPwcChannelOrFallback();
|
|
47505
46758
|
await request_ts_1.requestService.FHH({
|
|
47506
46759
|
url: '/EM1HCompBuild/Plugin/createPlugin',
|
|
47507
46760
|
data
|
|
@@ -47512,7 +46765,6 @@ async function createPluginSource(data) {
|
|
|
47512
46765
|
* create 成功后必须立即调用,失败时由请求层抛错并中止后续本地回拉流程。
|
|
47513
46766
|
*/
|
|
47514
46767
|
async function enablePwcResource(type, apiName) {
|
|
47515
|
-
assertPwcChannelOrFallback();
|
|
47516
46768
|
const resourceType = type === 'plugin' ? 'Plugin' : 'Component';
|
|
47517
46769
|
const action = type === 'plugin' ? 'enablePlugin' : 'enableComponent';
|
|
47518
46770
|
await request_ts_1.requestService.FHH({
|
|
@@ -47521,7 +46773,6 @@ async function enablePwcResource(type, apiName) {
|
|
|
47521
46773
|
});
|
|
47522
46774
|
}
|
|
47523
46775
|
async function getUrlByApiName(apiName, type) {
|
|
47524
|
-
assertPwcChannelOrFallback();
|
|
47525
46776
|
if (type === 'plugin') {
|
|
47526
46777
|
const response = await request_ts_1.requestService.FHH({
|
|
47527
46778
|
url: '/EM1HCompBuild/Plugin/queryPluginInfo',
|
|
@@ -48109,7 +47360,6 @@ async function pwcCreateNewService(input, context) {
|
|
|
48109
47360
|
let remoteFiles = [];
|
|
48110
47361
|
if (useAppletZip) {
|
|
48111
47362
|
logger_ts_1.loggerService.updateLoading('Uploading initialization template archive');
|
|
48112
|
-
(0, pwc_service_ts_1.assertPwcFileUploadChannel)();
|
|
48113
47363
|
const zipBuffer = await (0, zip_ts_1.createZipBufferFromTextFiles)(input.templateFiles);
|
|
48114
47364
|
const [remoteZip] = await request_ts_1.requestService.uploadFileList([
|
|
48115
47365
|
{
|
|
@@ -48125,7 +47375,6 @@ async function pwcCreateNewService(input, context) {
|
|
|
48125
47375
|
}
|
|
48126
47376
|
else {
|
|
48127
47377
|
logger_ts_1.loggerService.updateLoading('Uploading initialization template files');
|
|
48128
|
-
(0, pwc_service_ts_1.assertPwcFileUploadChannel)();
|
|
48129
47378
|
const uploaded = await request_ts_1.requestService.uploadFileList(input.templateFiles.map((file) => ({
|
|
48130
47379
|
fileName: file.fileName,
|
|
48131
47380
|
base64String: Buffer.from(file.content, 'utf8').toString('base64')
|
|
@@ -48659,7 +47908,6 @@ const request_ts_1 = __webpack_require__(83733);
|
|
|
48659
47908
|
const request_ts_2 = __webpack_require__(35604);
|
|
48660
47909
|
const types_ts_1 = __webpack_require__(6500);
|
|
48661
47910
|
const pwc_mateXml_ts_1 = __webpack_require__(53683);
|
|
48662
|
-
const pwc_service_ts_1 = __webpack_require__(63358);
|
|
48663
47911
|
const pwc_workspace_ts_1 = __webpack_require__(64635);
|
|
48664
47912
|
const pwc_types_ts_1 = __webpack_require__(55844);
|
|
48665
47913
|
/**
|
|
@@ -48715,7 +47963,6 @@ async function pwcPushNewService(apiName, type, context) {
|
|
|
48715
47963
|
const { readFile } = await Promise.resolve(/* import() */).then(() => (__webpack_require__(59031)));
|
|
48716
47964
|
const zipBuffer = await readFile(appletZipPath);
|
|
48717
47965
|
logger_ts_1.loggerService.updateLoading(`Uploading ${apiName}.zip`);
|
|
48718
|
-
(0, pwc_service_ts_1.assertPwcFileUploadChannel)();
|
|
48719
47966
|
const [remoteZip] = await request_ts_1.requestService.uploadFileList([
|
|
48720
47967
|
{
|
|
48721
47968
|
fileName: `${apiName}.zip`,
|
|
@@ -48734,7 +47981,6 @@ async function pwcPushNewService(apiName, type, context) {
|
|
|
48734
47981
|
bundle = await (0, pwc_workspace_ts_1.readLocalPwcUploadBundle)(context, type, apiName, (0, pwc_mateXml_ts_1.buildPwcTypeConstraints)(config));
|
|
48735
47982
|
// 上传源码 / 静态资源 / fileTree
|
|
48736
47983
|
logger_ts_1.loggerService.updateLoading(`Uploading ${bundle.uploadFiles.length} files`);
|
|
48737
|
-
(0, pwc_service_ts_1.assertPwcFileUploadChannel)();
|
|
48738
47984
|
const uploaded = await request_ts_1.requestService.uploadFileList(bundle.uploadFiles.map((item) => ({
|
|
48739
47985
|
fileName: item.fileName,
|
|
48740
47986
|
base64String: item.base64String
|
|
@@ -50535,7 +49781,33 @@ async function workflowDefUpdateDefinitionCommand(_context, options) {
|
|
|
50535
49781
|
nameTranslateInfo: "object",
|
|
50536
49782
|
descTranslateInfo: "object"
|
|
50537
49783
|
};
|
|
50538
|
-
const
|
|
49784
|
+
const updates = buildOptionsData(options, typeMap);
|
|
49785
|
+
// 服务端为全量更新语义:必须先按 --sourceWorkflowId 拉取完整定义,再合并增量提交
|
|
49786
|
+
if (!updates.sourceWorkflowId) {
|
|
49787
|
+
throw new Error('workflow-dev update-definition requires --sourceWorkflowId to locate and load the full definition.');
|
|
49788
|
+
}
|
|
49789
|
+
const changedFields = Object.keys(updates).filter((key) => key !== 'sourceWorkflowId');
|
|
49790
|
+
if (changedFields.length === 0) {
|
|
49791
|
+
throw new Error('workflow-dev update-definition requires at least one field to update besides --sourceWorkflowId.');
|
|
49792
|
+
}
|
|
49793
|
+
logger_ts_1.loggerService.startLoading('Loading workflowDef detail for full definition');
|
|
49794
|
+
let fullDefinition;
|
|
49795
|
+
try {
|
|
49796
|
+
const detailResponse = await (0, workflow_def_service_ts_1.executeWorkflowDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('workflowDef', 'detail'), { sourceWorkflowId: updates.sourceWorkflowId });
|
|
49797
|
+
logger_ts_1.loggerService.stopLoading();
|
|
49798
|
+
const envelope = (detailResponse && typeof detailResponse === 'object')
|
|
49799
|
+
? detailResponse
|
|
49800
|
+
: {};
|
|
49801
|
+
if (envelope.success !== true || !envelope.data?.workflow) {
|
|
49802
|
+
throw new Error(`Failed to load full definition via workflowDef detail: ${envelope.message ?? 'definition missing'}.`);
|
|
49803
|
+
}
|
|
49804
|
+
fullDefinition = envelope.data.workflow;
|
|
49805
|
+
}
|
|
49806
|
+
catch (error) {
|
|
49807
|
+
logger_ts_1.loggerService.stopLoading();
|
|
49808
|
+
throw error;
|
|
49809
|
+
}
|
|
49810
|
+
const data = { ...fullDefinition, ...updates };
|
|
50539
49811
|
logger_ts_1.loggerService.startLoading('Executing workflowDef update-definition');
|
|
50540
49812
|
try {
|
|
50541
49813
|
const response = await (0, workflow_def_service_ts_1.executeWorkflowDefShareCli)((0, request_execute_command_paths_ts_1.getShareCliCommandPath)('workflowDef', 'updateDefinition'), data);
|
|
@@ -51080,8 +50352,7 @@ function readRuntimeDebugFlag() {
|
|
|
51080
50352
|
}
|
|
51081
50353
|
function isRuntimeDebugEnabled() {
|
|
51082
50354
|
const runtimeEnabled = readRuntimeDebugFlag();
|
|
51083
|
-
|
|
51084
|
-
return ( false) || runtimeEnabled || false;
|
|
50355
|
+
return false || runtimeEnabled || false;
|
|
51085
50356
|
}
|
|
51086
50357
|
|
|
51087
50358
|
|
|
@@ -51282,8 +50553,8 @@ async function readCliPackageMeta() {
|
|
|
51282
50553
|
? "@share-crm/sharedev-cli".trim()
|
|
51283
50554
|
: '@share-crm/sharedev-cli';
|
|
51284
50555
|
const debugEnabled = true && Boolean(false);
|
|
51285
|
-
const rawVersion = ( true && "0.0.4-rc.
|
|
51286
|
-
? "0.0.4-rc.
|
|
50556
|
+
const rawVersion = ( true && "0.0.4-rc.51".trim())
|
|
50557
|
+
? "0.0.4-rc.51".trim()
|
|
51287
50558
|
: '0.0.0';
|
|
51288
50559
|
const version = rawVersion + (debugEnabled ? '-debug' : '');
|
|
51289
50560
|
return { name, version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@share-crm/sharedev-cli",
|
|
3
|
-
"version": "0.0.4-rc.
|
|
3
|
+
"version": "0.0.4-rc.51",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "sharedev command line tool",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@clack/prompts": "^1.1.0",
|
|
34
34
|
"@mariozechner/pi-coding-agent": "^0.62.0",
|
|
35
|
-
"@share-crm/sharecrm-cli": "^1.1.17",
|
|
36
35
|
"adm-zip": "^0.6.1",
|
|
37
36
|
"axios": "~1.13.0",
|
|
38
37
|
"chalk": "^5.6.2",
|