@share-crm/sharedev-cli 0.0.4-rc.50 → 0.0.4-rc.50-test.1
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 +796 -16
- package/package.json +2 -1
package/dist/sharedev.js
CHANGED
|
@@ -8572,6 +8572,8 @@ 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);
|
|
8575
8577
|
const pkgMeta_ts_1 = __webpack_require__(48559);
|
|
8576
8578
|
const normalize_ts_1 = __importDefault(__webpack_require__(80399));
|
|
8577
8579
|
const debug_ts_1 = __webpack_require__(90667);
|
|
@@ -8697,6 +8699,8 @@ async function bootstrap() {
|
|
|
8697
8699
|
}
|
|
8698
8700
|
const runtimeContext = await (0, context_ts_1.createCliRuntimeContext)(bootstrapOptions);
|
|
8699
8701
|
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);
|
|
8700
8704
|
// npm 与 spec 版本检查并发执行(均带 1.5s 超时,错误吞掉,不影响命令执行)
|
|
8701
8705
|
await Promise.all([
|
|
8702
8706
|
checkForNpmUpdate(pkgMeta.name, version),
|
|
@@ -9889,6 +9893,48 @@ function registerApprovalNamespace(program, runtimeContext) {
|
|
|
9889
9893
|
}
|
|
9890
9894
|
|
|
9891
9895
|
|
|
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
|
+
|
|
9892
9938
|
/***/ },
|
|
9893
9939
|
|
|
9894
9940
|
/***/ 5264
|
|
@@ -12303,9 +12349,11 @@ const er_ts_1 = __webpack_require__(40402);
|
|
|
12303
12349
|
const semantic_ts_1 = __webpack_require__(35185);
|
|
12304
12350
|
const access_ts_1 = __webpack_require__(9759);
|
|
12305
12351
|
const app_dev_ts_1 = __webpack_require__(82916);
|
|
12352
|
+
const auth_ts_1 = __webpack_require__(85971);
|
|
12306
12353
|
function registerNamespaces(program, context) {
|
|
12307
12354
|
(0, init_ts_1.registerInitCommand)(program, context);
|
|
12308
12355
|
(0, config_ts_1.registerConfigCommand)(program, context);
|
|
12356
|
+
(0, auth_ts_1.registerAuthCommand)(program, context);
|
|
12309
12357
|
(0, apl_ts_1.registerAplNamespace)(program, context);
|
|
12310
12358
|
(0, completion_ts_1.registerCompletionCommand)(program, context);
|
|
12311
12359
|
(0, docs_ts_1.registerDocsNamespace)(program, context);
|
|
@@ -14792,9 +14840,11 @@ exports.getProjectPath = getProjectPath;
|
|
|
14792
14840
|
exports.findSettings = findSettings;
|
|
14793
14841
|
exports.validateSettings = validateSettings;
|
|
14794
14842
|
exports.loadSettings = loadSettings;
|
|
14843
|
+
exports.loadRelaxedSettings = loadRelaxedSettings;
|
|
14795
14844
|
const node_path_1 = __importDefault(__webpack_require__(76760));
|
|
14796
14845
|
const file_ts_1 = __webpack_require__(57452);
|
|
14797
14846
|
const path_ts_1 = __webpack_require__(89213);
|
|
14847
|
+
const logger_ts_1 = __webpack_require__(87562);
|
|
14798
14848
|
const SHAREDEV_RELATIVE_PATH = node_path_1.default.join('.sharedev');
|
|
14799
14849
|
const SETTINGS_NAME = 'settings.json';
|
|
14800
14850
|
function isValidUrl(value) {
|
|
@@ -14883,6 +14933,37 @@ async function loadSettings(startDir) {
|
|
|
14883
14933
|
validateSettings(settings);
|
|
14884
14934
|
return settings;
|
|
14885
14935
|
}
|
|
14936
|
+
/**
|
|
14937
|
+
* 宽松读取 settings(不做 certificate/domain 校验),供「无 certificate + sharecrm 登录态」
|
|
14938
|
+
* 的运行模式兜底使用:settings.json 缺失时返回空字段形态,存在时尽量保留 domain 等信息
|
|
14939
|
+
* (环境一致性校验仍依赖 domain)。
|
|
14940
|
+
*/
|
|
14941
|
+
async function loadRelaxedSettings(startDir, fallbackDir) {
|
|
14942
|
+
const settingsPath = await findSettings(startDir);
|
|
14943
|
+
let rawSettings = {};
|
|
14944
|
+
if (settingsPath) {
|
|
14945
|
+
try {
|
|
14946
|
+
rawSettings = await (0, file_ts_1.readJsonFile)(settingsPath);
|
|
14947
|
+
}
|
|
14948
|
+
catch (error) {
|
|
14949
|
+
// 文件不存在(.sharedev 目录在但 settings.json 没有)是正常的登录态模式场景,静默跳过;
|
|
14950
|
+
// 文件存在但解析失败则必须警告——静默会丢失 domain 等工作区环境信息
|
|
14951
|
+
if (error.code !== 'ENOENT') {
|
|
14952
|
+
logger_ts_1.loggerService.warn(`Failed to parse ${settingsPath} (${error instanceof Error ? error.message : String(error)}). ` +
|
|
14953
|
+
'Running with sharecrm login state only; fix the settings file to restore environment checks.');
|
|
14954
|
+
}
|
|
14955
|
+
}
|
|
14956
|
+
}
|
|
14957
|
+
return {
|
|
14958
|
+
certificate: typeof rawSettings.certificate === 'string' ? rawSettings.certificate : '',
|
|
14959
|
+
domain: typeof rawSettings.domain === 'string' ? rawSettings.domain : '',
|
|
14960
|
+
developerName: typeof rawSettings.developerName === 'string' ? rawSettings.developerName : '',
|
|
14961
|
+
developerMobile: typeof rawSettings.developerMobile === 'string' ? rawSettings.developerMobile : '',
|
|
14962
|
+
specVersion: typeof rawSettings.specVersion === 'string' ? rawSettings.specVersion : '',
|
|
14963
|
+
settingsPath: settingsPath ?? '',
|
|
14964
|
+
settingsDir: settingsPath ? node_path_1.default.dirname(settingsPath) : fallbackDir
|
|
14965
|
+
};
|
|
14966
|
+
}
|
|
14886
14967
|
|
|
14887
14968
|
|
|
14888
14969
|
/***/ },
|
|
@@ -14896,11 +14977,28 @@ __webpack_unused_export__ = ({ value: true });
|
|
|
14896
14977
|
exports.createCliRuntimeContext = createCliRuntimeContext;
|
|
14897
14978
|
const config_ts_1 = __webpack_require__(43120);
|
|
14898
14979
|
const logger_ts_1 = __webpack_require__(87562);
|
|
14980
|
+
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
14899
14981
|
const path_ts_1 = __webpack_require__(89213);
|
|
14900
14982
|
async function createCliRuntimeContext(_options) {
|
|
14901
14983
|
const cwd = process.cwd();
|
|
14902
14984
|
const searchDir = await (0, config_ts_1.resolveSettingsSearchDir)(undefined, cwd);
|
|
14903
|
-
|
|
14985
|
+
let settings;
|
|
14986
|
+
try {
|
|
14987
|
+
settings = await (0, config_ts_1.loadSettings)(searchDir);
|
|
14988
|
+
}
|
|
14989
|
+
catch (error) {
|
|
14990
|
+
// settings 缺失/不完整时,工作区内存在登录凭证(.sharedev/session.json)则降级为
|
|
14991
|
+
// 「登录态模式」继续运行(certificate 可为空,业务请求走 open API 通道)。
|
|
14992
|
+
// 此时 configureSharecrmSession 尚未注入,直接按 .sharedev 目录读取凭证文件。
|
|
14993
|
+
const sharedevDir = await (0, config_ts_1.findSharedevPath)(searchDir);
|
|
14994
|
+
const session = sharedevDir ? (0, sharecrm_session_ts_1.readSharedevAuthSession)(sharedevDir) : null;
|
|
14995
|
+
if (!session?.accessToken) {
|
|
14996
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
14997
|
+
throw new Error(`${message}\nRun \`sharedev init\` to initialize a workspace first, then \`sharedev auth login\`.`);
|
|
14998
|
+
}
|
|
14999
|
+
settings = await (0, config_ts_1.loadRelaxedSettings)(searchDir, cwd);
|
|
15000
|
+
logger_ts_1.loggerService.info('No valid certificate configured; running with sharecrm login state.');
|
|
15001
|
+
}
|
|
14904
15002
|
logger_ts_1.loggerService.debug(`settingsPath = ${settings.settingsPath}`);
|
|
14905
15003
|
logger_ts_1.loggerService.debug(`domain = ${settings.domain}`);
|
|
14906
15004
|
logger_ts_1.loggerService.debug(`certificate = ${(0, path_ts_1.maskCertificate)(settings.certificate)}`);
|
|
@@ -15751,6 +15849,126 @@ const fetchLatestNpmVersion = (packageName, timeoutMs = 1500) => new Promise((re
|
|
|
15751
15849
|
exports.fetchLatestNpmVersion = fetchLatestNpmVersion;
|
|
15752
15850
|
|
|
15753
15851
|
|
|
15852
|
+
/***/ },
|
|
15853
|
+
|
|
15854
|
+
/***/ 59848
|
|
15855
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
15856
|
+
|
|
15857
|
+
|
|
15858
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15859
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15860
|
+
};
|
|
15861
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
15862
|
+
exports.OpenApiCommandError = void 0;
|
|
15863
|
+
exports.executeOpenApiCommand = executeOpenApiCommand;
|
|
15864
|
+
const node_crypto_1 = __webpack_require__(77598);
|
|
15865
|
+
const logger_ts_1 = __webpack_require__(87562);
|
|
15866
|
+
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
15867
|
+
const normalize_ts_1 = __importDefault(__webpack_require__(80399));
|
|
15868
|
+
const pkgMeta_ts_1 = __webpack_require__(48559);
|
|
15869
|
+
const isDebugEnabled_ts_1 = __webpack_require__(27570);
|
|
15870
|
+
/**
|
|
15871
|
+
* 操作中心 Open API 网关客户端。
|
|
15872
|
+
*
|
|
15873
|
+
* 与 FHH 网关(request.ts,certificate 鉴权)平行:本通道走
|
|
15874
|
+
* `POST {apiUrl}/api/v1/commands/execute`,鉴权为 sharecrm 登录的
|
|
15875
|
+
* `Authorization: Bearer <FSDTK token>`。两网关票据不通用,命令注册以
|
|
15876
|
+
* docs/action-centre-integration.md 的实测记录为准(注意 code-dev function 新命名)。
|
|
15877
|
+
*/
|
|
15878
|
+
class OpenApiCommandError extends Error {
|
|
15879
|
+
constructor(message, resultCode, detail, traceId) {
|
|
15880
|
+
super(message);
|
|
15881
|
+
this.name = 'OpenApiCommandError';
|
|
15882
|
+
this.resultCode = resultCode;
|
|
15883
|
+
this.detail = detail;
|
|
15884
|
+
this.traceId = traceId;
|
|
15885
|
+
}
|
|
15886
|
+
}
|
|
15887
|
+
exports.OpenApiCommandError = OpenApiCommandError;
|
|
15888
|
+
function toExecuteUrl(apiUrl) {
|
|
15889
|
+
if (!apiUrl) {
|
|
15890
|
+
throw new Error('Login session is missing apiUrl. Run `sharedev auth login` again.');
|
|
15891
|
+
}
|
|
15892
|
+
return `${apiUrl.replace(/\/+$/, '')}/api/v1/commands/execute`;
|
|
15893
|
+
}
|
|
15894
|
+
async function buildCommandHeaders(session) {
|
|
15895
|
+
const locale = normalize_ts_1.default.normalizeAcceptLanguage(process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG);
|
|
15896
|
+
const { version } = await (0, pkgMeta_ts_1.readCliPackageMeta)();
|
|
15897
|
+
return {
|
|
15898
|
+
'Content-Type': 'application/json',
|
|
15899
|
+
Authorization: `Bearer ${session.accessToken}`,
|
|
15900
|
+
'X-CLI-Id': 'sharedev-cli',
|
|
15901
|
+
'X-CLI-Version': version || '0.0.0',
|
|
15902
|
+
'X-Caller-Type': 'cli',
|
|
15903
|
+
'X-Request-Id': (0, node_crypto_1.randomUUID)(),
|
|
15904
|
+
'Accept-Language': locale ?? 'en-US',
|
|
15905
|
+
'X-FS-Locale': locale ?? 'en-US'
|
|
15906
|
+
};
|
|
15907
|
+
}
|
|
15908
|
+
async function executeOnce(session, commandKey, args, flags) {
|
|
15909
|
+
const response = await fetch(toExecuteUrl(session.apiUrl), {
|
|
15910
|
+
method: 'POST',
|
|
15911
|
+
headers: await buildCommandHeaders(session),
|
|
15912
|
+
body: JSON.stringify({
|
|
15913
|
+
commandKey,
|
|
15914
|
+
arguments: args ?? {},
|
|
15915
|
+
...(flags?.length ? { flags } : {})
|
|
15916
|
+
})
|
|
15917
|
+
});
|
|
15918
|
+
let payload;
|
|
15919
|
+
try {
|
|
15920
|
+
payload = (await response.json());
|
|
15921
|
+
}
|
|
15922
|
+
catch {
|
|
15923
|
+
throw new OpenApiCommandError(`Open API command failed: HTTP ${response.status} ${response.statusText}`, `HTTP_${response.status}`);
|
|
15924
|
+
}
|
|
15925
|
+
if ((0, isDebugEnabled_ts_1.isRuntimeDebugEnabled)()) {
|
|
15926
|
+
const dataPreview = typeof payload.data === 'string'
|
|
15927
|
+
? payload.data.slice(0, 200)
|
|
15928
|
+
: JSON.stringify(payload.data ?? null)?.slice(0, 200);
|
|
15929
|
+
logger_ts_1.loggerService.debug(`Open API response: ${commandKey} -> ${payload.resultCode ?? 'UNKNOWN'} ${dataPreview ?? ''}`);
|
|
15930
|
+
}
|
|
15931
|
+
if (payload.traceId) {
|
|
15932
|
+
logger_ts_1.loggerService.addTraceId(payload.traceId);
|
|
15933
|
+
}
|
|
15934
|
+
if (payload.resultCode === 'SUCCESS') {
|
|
15935
|
+
if (payload.helpInfoReturned === true) {
|
|
15936
|
+
const usage = payload.data && typeof payload.data === 'object'
|
|
15937
|
+
? payload.data.usage
|
|
15938
|
+
: undefined;
|
|
15939
|
+
throw new OpenApiCommandError(`Open API command "${commandKey}" was not executed: missing required arguments.${usage ? `\nUsage: ${usage}` : ''}`, 'HELP_INFO_RETURNED');
|
|
15940
|
+
}
|
|
15941
|
+
// 外层信封中 traceId 已在上方消费、helpInfoReturned 已转错误,
|
|
15942
|
+
// 对调用方有价值的只剩 content——统一在此剥出,调用方直接拿业务数据
|
|
15943
|
+
const envelope = payload.data;
|
|
15944
|
+
return (typeof envelope === 'object' && envelope !== null ? envelope.content : undefined);
|
|
15945
|
+
}
|
|
15946
|
+
const detail = typeof payload.data === 'string' ? payload.data : JSON.stringify(payload.data ?? '');
|
|
15947
|
+
throw new OpenApiCommandError(`Open API command "${commandKey}" failed: ${payload.resultCode ?? 'UNKNOWN'}${detail ? ` ${detail}` : ''}`, payload.resultCode ?? 'UNKNOWN', detail || undefined, payload.traceId);
|
|
15948
|
+
}
|
|
15949
|
+
/**
|
|
15950
|
+
* 执行操作中心 Open API 命令,返回解包后的 content(外层信封已统一处理)。
|
|
15951
|
+
*
|
|
15952
|
+
* 未登录抛错引导 `sharedev auth login`;token 过期自动刷新;
|
|
15953
|
+
* 服务端返回 AUTH_FAIL 时刷新一次后重试(服务端会话失效场景)。
|
|
15954
|
+
* flags 用于透传确认标记等命令行语义(如 NEED_CONFIRM 的 --yes)。
|
|
15955
|
+
*/
|
|
15956
|
+
async function executeOpenApiCommand(commandKey, args = {}, options) {
|
|
15957
|
+
const session = await (0, sharecrm_session_ts_1.ensureValidSharedevAuthSession)();
|
|
15958
|
+
try {
|
|
15959
|
+
return await executeOnce(session, commandKey, args, options?.flags);
|
|
15960
|
+
}
|
|
15961
|
+
catch (error) {
|
|
15962
|
+
if (error instanceof OpenApiCommandError && error.resultCode === 'AUTH_FAIL') {
|
|
15963
|
+
const refreshed = await (0, sharecrm_session_ts_1.refreshSharecrmSession)(session);
|
|
15964
|
+
(0, sharecrm_session_ts_1.saveSharedevAuthSession)(refreshed);
|
|
15965
|
+
return await executeOnce(refreshed, commandKey, args, options?.flags);
|
|
15966
|
+
}
|
|
15967
|
+
throw error;
|
|
15968
|
+
}
|
|
15969
|
+
}
|
|
15970
|
+
|
|
15971
|
+
|
|
15754
15972
|
/***/ },
|
|
15755
15973
|
|
|
15756
15974
|
/***/ 2067
|
|
@@ -16033,6 +16251,47 @@ class PassthroughCommandBuilder {
|
|
|
16033
16251
|
__webpack_unused_export__ = PassthroughCommandBuilder;
|
|
16034
16252
|
|
|
16035
16253
|
|
|
16254
|
+
/***/ },
|
|
16255
|
+
|
|
16256
|
+
/***/ 43355
|
|
16257
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
16258
|
+
|
|
16259
|
+
var __webpack_unused_export__;
|
|
16260
|
+
|
|
16261
|
+
__webpack_unused_export__ = ({ value: true });
|
|
16262
|
+
exports.configureRequestChannel = configureRequestChannel;
|
|
16263
|
+
exports.resolveRequestChannel = resolveRequestChannel;
|
|
16264
|
+
exports.hasCertificateCredential = hasCertificateCredential;
|
|
16265
|
+
const logger_ts_1 = __webpack_require__(87562);
|
|
16266
|
+
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
16267
|
+
let currentSettings;
|
|
16268
|
+
/** bootstrap 时注入运行时 settings(与 requestService.configure 同位置调用一次) */
|
|
16269
|
+
function configureRequestChannel(settings) {
|
|
16270
|
+
currentSettings = settings;
|
|
16271
|
+
}
|
|
16272
|
+
/** 解析当前应使用的请求通道;双登录态并存时登录态优先 */
|
|
16273
|
+
function resolveRequestChannel() {
|
|
16274
|
+
const session = (0, sharecrm_session_ts_1.readSharedevAuthSession)();
|
|
16275
|
+
if (session?.accessToken) {
|
|
16276
|
+
logger_ts_1.loggerService.debug('Request channel: openapi (sharecrm login).');
|
|
16277
|
+
return 'openapi';
|
|
16278
|
+
}
|
|
16279
|
+
if (currentSettings?.certificate?.trim()) {
|
|
16280
|
+
logger_ts_1.loggerService.debug('Request channel: fhh (certificate).');
|
|
16281
|
+
return 'fhh';
|
|
16282
|
+
}
|
|
16283
|
+
throw new Error('No credentials available. Run `sharedev auth login`, or configure certificate/domain in .sharedev/settings.json.');
|
|
16284
|
+
}
|
|
16285
|
+
/**
|
|
16286
|
+
* 是否存在可用的 certificate 凭证(与 resolveRequestChannel 的判定一致)。
|
|
16287
|
+
* 供个别命令在 openapi 能力未就绪期间做局部降级:登录态优先的原则管「能力对等时的选择」,
|
|
16288
|
+
* 能力缺失时(如 PWC download-file 未就绪)允许回退 certificate,避免功能回退。
|
|
16289
|
+
*/
|
|
16290
|
+
function hasCertificateCredential() {
|
|
16291
|
+
return Boolean(currentSettings?.certificate?.trim());
|
|
16292
|
+
}
|
|
16293
|
+
|
|
16294
|
+
|
|
16036
16295
|
/***/ },
|
|
16037
16296
|
|
|
16038
16297
|
/***/ 23634
|
|
@@ -16464,11 +16723,46 @@ __webpack_unused_export__ = ({ value: true });
|
|
|
16464
16723
|
exports.y = void 0;
|
|
16465
16724
|
exports.executeShareCliCommand = executeShareCliCommand;
|
|
16466
16725
|
const request_ts_1 = __webpack_require__(83733);
|
|
16726
|
+
const request_channel_ts_1 = __webpack_require__(43355);
|
|
16727
|
+
const openapi_request_ts_1 = __webpack_require__(59848);
|
|
16467
16728
|
const trace_ts_1 = __webpack_require__(36097);
|
|
16468
16729
|
/** 操作中心 shareCli/execute 的业务方标识 */
|
|
16469
16730
|
exports.y = 'sharedev-cli';
|
|
16731
|
+
/**
|
|
16732
|
+
* open API 侧 code-dev 命名空间迁移:apl → function(子命令同名,2026-10-21 实测)。
|
|
16733
|
+
* list 例外:open API 未注册 code-dev function list,等价能力为 object-dev function query。
|
|
16734
|
+
*/
|
|
16735
|
+
function toOpenApiCommandPath(commandPath) {
|
|
16736
|
+
if (commandPath.length >= 3 && commandPath[0] === 'code-dev' && commandPath[1] === 'apl') {
|
|
16737
|
+
if (commandPath[2] === 'list') {
|
|
16738
|
+
throw new Error('Command "code-dev apl list" is not registered on the Open API gateway; the equivalent is "object-dev function query".');
|
|
16739
|
+
}
|
|
16740
|
+
return ['code-dev', 'function', ...commandPath.slice(2)];
|
|
16741
|
+
}
|
|
16742
|
+
return commandPath;
|
|
16743
|
+
}
|
|
16744
|
+
/**
|
|
16745
|
+
* 执行操作中心命令(透传族统一入口)。
|
|
16746
|
+
*
|
|
16747
|
+
* 双通道(二期):sharecrm 登录态 → open API `commands/execute`(commandKey = commandPath 空格连接,
|
|
16748
|
+
* code-dev apl * 自动映射为迁移后的 function 命名空间);
|
|
16749
|
+
* certificate → FHH `shareCli/execute`(现状不动)。响应统一适配为 ShareCliExecuteResponse
|
|
16750
|
+
* 形态({success, code, message, data}),上层 PassthroughCommandManager 无感。
|
|
16751
|
+
*/
|
|
16470
16752
|
async function executeShareCliCommand(commandPath, data, others) {
|
|
16471
16753
|
(0, trace_ts_1.traceExecute)(commandPath.join(' '));
|
|
16754
|
+
const channel = (0, request_channel_ts_1.resolveRequestChannel)();
|
|
16755
|
+
if (channel === 'openapi') {
|
|
16756
|
+
// open API 侧确认协议:flags 形式(sharecrm 同款);agentChannels 为 FHH 侧统计标记,暂无对应物
|
|
16757
|
+
const flags = others?.yes === true ? ['--yes'] : undefined;
|
|
16758
|
+
const commandKey = toOpenApiCommandPath(commandPath).join(' ');
|
|
16759
|
+
const content = await (0, openapi_request_ts_1.executeOpenApiCommand)(commandKey, data ?? {}, flags ? { flags } : undefined);
|
|
16760
|
+
return {
|
|
16761
|
+
success: true,
|
|
16762
|
+
code: 'OK',
|
|
16763
|
+
data: content
|
|
16764
|
+
};
|
|
16765
|
+
}
|
|
16472
16766
|
const payload = {
|
|
16473
16767
|
commandPath,
|
|
16474
16768
|
// 所有 sharedev 发起的操作中心请求统一携带 agentChannels,服务端按 Agent 渠道路由/统计
|
|
@@ -16829,6 +17123,231 @@ class RequestService {
|
|
|
16829
17123
|
exports.requestService = new RequestService();
|
|
16830
17124
|
|
|
16831
17125
|
|
|
17126
|
+
/***/ },
|
|
17127
|
+
|
|
17128
|
+
/***/ 47166
|
|
17129
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
17130
|
+
|
|
17131
|
+
|
|
17132
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17133
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17134
|
+
};
|
|
17135
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
17136
|
+
exports.DOMAIN_HOST_TO_LOGIN_ENV = void 0;
|
|
17137
|
+
exports.configureSharecrmSession = configureSharecrmSession;
|
|
17138
|
+
exports.getRuntimeRequire = getRuntimeRequire;
|
|
17139
|
+
exports.readSharecrmSession = readSharecrmSession;
|
|
17140
|
+
exports.saveSharedevAuthSession = saveSharedevAuthSession;
|
|
17141
|
+
exports.readSharedevAuthSession = readSharedevAuthSession;
|
|
17142
|
+
exports.clearSharedevAuthSession = clearSharedevAuthSession;
|
|
17143
|
+
exports.isSessionExpired = isSessionExpired;
|
|
17144
|
+
exports.refreshSharecrmSession = refreshSharecrmSession;
|
|
17145
|
+
exports.ensureValidSharedevAuthSession = ensureValidSharedevAuthSession;
|
|
17146
|
+
exports.readSharecrmConfig = readSharecrmConfig;
|
|
17147
|
+
const node_module_1 = __webpack_require__(98995);
|
|
17148
|
+
const node_fs_1 = __importDefault(__webpack_require__(73024));
|
|
17149
|
+
const node_os_1 = __importDefault(__webpack_require__(48161));
|
|
17150
|
+
const node_path_1 = __importDefault(__webpack_require__(76760));
|
|
17151
|
+
/**
|
|
17152
|
+
* 工作区企业 domain → 登录环境(open API 网关)映射(环境域知识的唯一登记处)。
|
|
17153
|
+
* 登录环境继承 init 配置的工作区环境(无交互选择)。
|
|
17154
|
+
* 新增环境(香港/国际等)在此登记即可。
|
|
17155
|
+
*/
|
|
17156
|
+
exports.DOMAIN_HOST_TO_LOGIN_ENV = {
|
|
17157
|
+
'www.fxiaoke.com': { authBaseUrl: 'https://open.fxiaoke.com/', apiBaseUrl: 'https://open.fxiaoke.com/cli/' },
|
|
17158
|
+
'crm.ceshi112.com': { authBaseUrl: 'https://open.ceshi112.com/', apiBaseUrl: 'https://open.ceshi112.com/cli/' }
|
|
17159
|
+
};
|
|
17160
|
+
const SESSION_FILE_NAME = 'session.json';
|
|
17161
|
+
const GITIGNORE_ENTRY = '.sharedev/session.json';
|
|
17162
|
+
/** 由 bootstrap 注入的工作区 .sharedev 目录;skipSettings 分支(--help 等)不会注入 */
|
|
17163
|
+
let currentSharedevDir;
|
|
17164
|
+
/** bootstrap 时注入工作区 settings(与 requestService.configure 同位置调用一次) */
|
|
17165
|
+
function configureSharecrmSession(settings) {
|
|
17166
|
+
currentSharedevDir = settings.settingsDir;
|
|
17167
|
+
}
|
|
17168
|
+
function resolveSessionFile(sharedevDir) {
|
|
17169
|
+
const dir = sharedevDir ?? currentSharedevDir;
|
|
17170
|
+
return dir ? node_path_1.default.join(dir, SESSION_FILE_NAME) : undefined;
|
|
17171
|
+
}
|
|
17172
|
+
/** 登录态写入 .sharedev/session.json 时确保工作区 .gitignore 覆盖该敏感文件(失败不阻断登录) */
|
|
17173
|
+
function ensureGitignoreEntry() {
|
|
17174
|
+
if (!currentSharedevDir) {
|
|
17175
|
+
return;
|
|
17176
|
+
}
|
|
17177
|
+
const workspaceRoot = node_path_1.default.dirname(currentSharedevDir);
|
|
17178
|
+
const gitignorePath = node_path_1.default.join(workspaceRoot, '.gitignore');
|
|
17179
|
+
try {
|
|
17180
|
+
let content = '';
|
|
17181
|
+
try {
|
|
17182
|
+
content = node_fs_1.default.readFileSync(gitignorePath, 'utf8');
|
|
17183
|
+
}
|
|
17184
|
+
catch {
|
|
17185
|
+
// .gitignore 不存在,直接创建
|
|
17186
|
+
}
|
|
17187
|
+
const covered = content.split('\n').some((line) => line.trim() === GITIGNORE_ENTRY);
|
|
17188
|
+
if (!covered) {
|
|
17189
|
+
const prefix = content && !content.endsWith('\n') ? '\n' : '';
|
|
17190
|
+
node_fs_1.default.appendFileSync(gitignorePath, `${prefix}${GITIGNORE_ENTRY}\n`);
|
|
17191
|
+
}
|
|
17192
|
+
}
|
|
17193
|
+
catch {
|
|
17194
|
+
// .gitignore 追加失败不阻断登录流程
|
|
17195
|
+
}
|
|
17196
|
+
}
|
|
17197
|
+
// createRequire(import.meta.url) 会被 webpack 静态求值为构建机的绝对源码路径,发布后失效;
|
|
17198
|
+
// 与 pwc beefly 加载一致:以运行时入口(bin/cli.mjs / dist/sharedev.js,即 process.argv[1])
|
|
17199
|
+
// 做解析基准,从 CLI 自身安装位置向上命中包内 node_modules 的 @share-crm/sharecrm-cli。
|
|
17200
|
+
// npm link 场景下 argv[1] 是全局 bin 的 symlink,Node 解析不穿透 symlink,字面路径向上
|
|
17201
|
+
// 找不到 node_modules,必须先 realpath 回真实安装位置再解析。
|
|
17202
|
+
function getRuntimeRequire() {
|
|
17203
|
+
const entry = process.argv[1] ?? process.cwd();
|
|
17204
|
+
try {
|
|
17205
|
+
return (0, node_module_1.createRequire)(node_fs_1.default.realpathSync(entry));
|
|
17206
|
+
}
|
|
17207
|
+
catch {
|
|
17208
|
+
return (0, node_module_1.createRequire)(entry);
|
|
17209
|
+
}
|
|
17210
|
+
}
|
|
17211
|
+
function loadAuthSessionStoreModule() {
|
|
17212
|
+
const require = getRuntimeRequire();
|
|
17213
|
+
return require('@share-crm/sharecrm-cli/dist/core/state/authSessionStore.js');
|
|
17214
|
+
}
|
|
17215
|
+
/** 读取 sharecrm 当前登录会话(login 中转用);未登录返回 null;依赖缺失/结构变化抛出可读错误 */
|
|
17216
|
+
async function readSharecrmSession() {
|
|
17217
|
+
let module;
|
|
17218
|
+
try {
|
|
17219
|
+
module = loadAuthSessionStoreModule();
|
|
17220
|
+
}
|
|
17221
|
+
catch {
|
|
17222
|
+
throw new Error('Failed to load @share-crm/sharecrm-cli. Reinstall sharedev dependencies and try again.');
|
|
17223
|
+
}
|
|
17224
|
+
if (!module || typeof module.AuthSessionStore !== 'function') {
|
|
17225
|
+
throw new Error('Incompatible @share-crm/sharecrm-cli detected (AuthSessionStore missing). Upgrade sharedev or @share-crm/sharecrm-cli.');
|
|
17226
|
+
}
|
|
17227
|
+
try {
|
|
17228
|
+
return await new module.AuthSessionStore().load();
|
|
17229
|
+
}
|
|
17230
|
+
catch (error) {
|
|
17231
|
+
// AuthSessionStore.load() 在未登录时返回 null 而不抛错;
|
|
17232
|
+
// 走到这里意味着本地会话存储读取失败(钥匙串被拒 / 文件损坏等),
|
|
17233
|
+
// 不是未登录——原样抛出,避免误导用户重新 login。
|
|
17234
|
+
throw new Error(`Failed to read sharecrm session store: ${error instanceof Error ? error.message : String(error)}`);
|
|
17235
|
+
}
|
|
17236
|
+
}
|
|
17237
|
+
function saveSharedevAuthSession(session) {
|
|
17238
|
+
const sessionFile = resolveSessionFile();
|
|
17239
|
+
if (!sessionFile) {
|
|
17240
|
+
throw new Error('Workspace context is not configured. Run this command inside a sharedev workspace.');
|
|
17241
|
+
}
|
|
17242
|
+
ensureGitignoreEntry();
|
|
17243
|
+
node_fs_1.default.writeFileSync(sessionFile, JSON.stringify(session, null, 2), { mode: 0o600 });
|
|
17244
|
+
}
|
|
17245
|
+
function readSharedevAuthSession(sharedevDir) {
|
|
17246
|
+
const sessionFile = resolveSessionFile(sharedevDir);
|
|
17247
|
+
if (!sessionFile) {
|
|
17248
|
+
return null;
|
|
17249
|
+
}
|
|
17250
|
+
try {
|
|
17251
|
+
const session = JSON.parse(node_fs_1.default.readFileSync(sessionFile, 'utf8'));
|
|
17252
|
+
return session && typeof session.accessToken === 'string' && session.accessToken ? session : null;
|
|
17253
|
+
}
|
|
17254
|
+
catch {
|
|
17255
|
+
return null;
|
|
17256
|
+
}
|
|
17257
|
+
}
|
|
17258
|
+
/** 只清当前工作区的登录凭证,不影响 sharecrm 自己的登录态 */
|
|
17259
|
+
function clearSharedevAuthSession() {
|
|
17260
|
+
const sessionFile = resolveSessionFile();
|
|
17261
|
+
if (!sessionFile) {
|
|
17262
|
+
return;
|
|
17263
|
+
}
|
|
17264
|
+
try {
|
|
17265
|
+
node_fs_1.default.rmSync(sessionFile, { force: true });
|
|
17266
|
+
}
|
|
17267
|
+
catch {
|
|
17268
|
+
// ignore
|
|
17269
|
+
}
|
|
17270
|
+
}
|
|
17271
|
+
function isSessionExpired(session) {
|
|
17272
|
+
return !session.tokenExpireAt || session.tokenExpireAt <= Date.now();
|
|
17273
|
+
}
|
|
17274
|
+
/** authBaseUrl 由登录下发的 apiUrl 推导(https://open.fxiaoke.com/cli/ -> https://open.fxiaoke.com/);缺失即凭证异常 */
|
|
17275
|
+
function deriveAuthBaseUrl(apiUrl) {
|
|
17276
|
+
if (!apiUrl) {
|
|
17277
|
+
throw new Error('Login session is missing apiUrl. Run `sharedev auth login` again.');
|
|
17278
|
+
}
|
|
17279
|
+
try {
|
|
17280
|
+
return `${new URL(apiUrl).origin}/`;
|
|
17281
|
+
}
|
|
17282
|
+
catch {
|
|
17283
|
+
throw new Error(`Invalid apiUrl in login session: ${apiUrl}. Run \`sharedev auth login\` again.`);
|
|
17284
|
+
}
|
|
17285
|
+
}
|
|
17286
|
+
/**
|
|
17287
|
+
* 用 refreshToken 刷新 accessToken(与 sharecrm 的 /oauth2.0/token 契约一致)。
|
|
17288
|
+
* 成功返回新会话(不落盘,由调用方决定是否保存),失败抛出带重登指引的错误。
|
|
17289
|
+
*/
|
|
17290
|
+
async function refreshSharecrmSession(session) {
|
|
17291
|
+
const response = await fetch(new URL('oauth2.0/token', deriveAuthBaseUrl(session.apiUrl)), {
|
|
17292
|
+
method: 'POST',
|
|
17293
|
+
headers: { 'Content-Type': 'application/json' },
|
|
17294
|
+
body: JSON.stringify({
|
|
17295
|
+
appId: session.appId,
|
|
17296
|
+
grantType: 'refresh_token',
|
|
17297
|
+
refreshToken: session.refreshToken
|
|
17298
|
+
})
|
|
17299
|
+
});
|
|
17300
|
+
let payload;
|
|
17301
|
+
try {
|
|
17302
|
+
payload = (await response.json());
|
|
17303
|
+
}
|
|
17304
|
+
catch {
|
|
17305
|
+
throw new Error(`sharecrm token refresh failed (HTTP ${response.status}). Run \`sharedev auth login\` again.`);
|
|
17306
|
+
}
|
|
17307
|
+
if (payload.errorCode !== 0 || !payload.accessToken) {
|
|
17308
|
+
throw new Error(`sharecrm token refresh failed: ${payload.errorMessage ?? `errorCode ${payload.errorCode}`}. Run \`sharedev auth login\` again.`);
|
|
17309
|
+
}
|
|
17310
|
+
// OAuth 刷新响应允许不回发新 refreshToken(沿用旧值,sharecrm 同款行为);
|
|
17311
|
+
// expiresIn 是计算过期时间的必要输入,缺失即报错
|
|
17312
|
+
if (typeof payload.expiresIn !== 'number' || !Number.isFinite(payload.expiresIn) || payload.expiresIn <= 0) {
|
|
17313
|
+
throw new Error('sharecrm token refresh response is missing expiresIn. Run `sharedev auth login` again.');
|
|
17314
|
+
}
|
|
17315
|
+
return {
|
|
17316
|
+
...session,
|
|
17317
|
+
accessToken: payload.accessToken,
|
|
17318
|
+
refreshToken: payload.refreshToken ?? session.refreshToken,
|
|
17319
|
+
tokenExpireAt: Date.now() + payload.expiresIn * 1000
|
|
17320
|
+
};
|
|
17321
|
+
}
|
|
17322
|
+
/** 读取工作区登录凭证并保证可用:过期时自动刷新并回写工作区文件 */
|
|
17323
|
+
async function ensureValidSharedevAuthSession() {
|
|
17324
|
+
const session = readSharedevAuthSession();
|
|
17325
|
+
if (!session) {
|
|
17326
|
+
throw new Error('Not logged in. Run `sharedev auth login` first.');
|
|
17327
|
+
}
|
|
17328
|
+
if (!isSessionExpired(session)) {
|
|
17329
|
+
return session;
|
|
17330
|
+
}
|
|
17331
|
+
const refreshed = await refreshSharecrmSession(session);
|
|
17332
|
+
saveSharedevAuthSession(refreshed);
|
|
17333
|
+
return refreshed;
|
|
17334
|
+
}
|
|
17335
|
+
/**
|
|
17336
|
+
* 读取 sharecrm 全局 config(login 前的环境冲突检测用:config 优先级高于环境变量注入,
|
|
17337
|
+
* 用户在 sharecrm 侧固定过环境时,sharedev 的环境注入会被压制)。
|
|
17338
|
+
*/
|
|
17339
|
+
function readSharecrmConfig() {
|
|
17340
|
+
const configPath = node_path_1.default.join(node_os_1.default.homedir(), '.sharecrm-cli', 'config.json');
|
|
17341
|
+
try {
|
|
17342
|
+
const config = JSON.parse(node_fs_1.default.readFileSync(configPath, 'utf8'));
|
|
17343
|
+
return config && typeof config === 'object' ? config : {};
|
|
17344
|
+
}
|
|
17345
|
+
catch {
|
|
17346
|
+
return {};
|
|
17347
|
+
}
|
|
17348
|
+
}
|
|
17349
|
+
|
|
17350
|
+
|
|
16832
17351
|
/***/ },
|
|
16833
17352
|
|
|
16834
17353
|
/***/ 36097
|
|
@@ -18937,7 +19456,47 @@ exports.createAplTemplate = createAplTemplate;
|
|
|
18937
19456
|
exports.createFuncSource = createFuncSource;
|
|
18938
19457
|
const node_crypto_1 = __webpack_require__(77598);
|
|
18939
19458
|
const request_ts_1 = __webpack_require__(83733);
|
|
19459
|
+
const openapi_request_ts_1 = __webpack_require__(59848);
|
|
19460
|
+
const request_channel_ts_1 = __webpack_require__(43355);
|
|
19461
|
+
/**
|
|
19462
|
+
* open API 通道的函数列表查询(sharecrm 登录态时替代 FHH biz/query)。
|
|
19463
|
+
* 参数形态 2026-10-21 实测:分页为字符串,name_space 为数组,binding 过滤与 FHH 同名。
|
|
19464
|
+
*/
|
|
19465
|
+
async function getFuncListViaOpenApi(options) {
|
|
19466
|
+
const args = { pageNumber: '1', pageSize: '3000' };
|
|
19467
|
+
const bind = options.bind?.trim();
|
|
19468
|
+
if (bind) {
|
|
19469
|
+
args.binding_object_api_name = bind;
|
|
19470
|
+
}
|
|
19471
|
+
const space = options.space?.trim();
|
|
19472
|
+
if (space) {
|
|
19473
|
+
args.name_space = [space];
|
|
19474
|
+
}
|
|
19475
|
+
const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', args);
|
|
19476
|
+
return content?.result?.function ?? [];
|
|
19477
|
+
}
|
|
19478
|
+
/**
|
|
19479
|
+
* open API 通道的单函数详情(sharecrm 登录态时替代 FHH biz/find / batchQuery)。
|
|
19480
|
+
* 响应含完整函数体(body 源码),字段与 IFuncData 同构(2026-10-21 实测)。
|
|
19481
|
+
*/
|
|
19482
|
+
async function findFuncByApiNameViaOpenApi(apiName, bindingObjectApiName) {
|
|
19483
|
+
const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('code-dev function get-by-apiname-and-binding-object-apiname', {
|
|
19484
|
+
api_name: apiName,
|
|
19485
|
+
...(bindingObjectApiName ? { binding_object_api_name: bindingObjectApiName } : {})
|
|
19486
|
+
});
|
|
19487
|
+
if (content?.errCode && content.errCode !== 0) {
|
|
19488
|
+
throw new Error(content.errMessage || `APL function lookup failed (errCode ${content.errCode}): ${apiName}`);
|
|
19489
|
+
}
|
|
19490
|
+
const func = content?.result?.function;
|
|
19491
|
+
if (!func) {
|
|
19492
|
+
throw new Error(`APL function not found: ${apiName}`);
|
|
19493
|
+
}
|
|
19494
|
+
return func;
|
|
19495
|
+
}
|
|
18940
19496
|
async function getFuncList(options = {}) {
|
|
19497
|
+
if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
|
|
19498
|
+
return getFuncListViaOpenApi(options);
|
|
19499
|
+
}
|
|
18941
19500
|
const bindingObjectApiName = options.bind?.trim();
|
|
18942
19501
|
const nameSpace = options.space?.trim();
|
|
18943
19502
|
const data = {
|
|
@@ -18966,6 +19525,9 @@ async function findFuncByApiNames(apiNames) {
|
|
|
18966
19525
|
return response.function;
|
|
18967
19526
|
}
|
|
18968
19527
|
async function findFuncByApiName(apiName, bindingObjectApiName = '') {
|
|
19528
|
+
if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
|
|
19529
|
+
return findFuncByApiNameViaOpenApi(apiName, bindingObjectApiName);
|
|
19530
|
+
}
|
|
18969
19531
|
if (bindingObjectApiName) {
|
|
18970
19532
|
const response = await request_ts_1.requestService.FHH({
|
|
18971
19533
|
url: '/EM1HFUNC/biz/find',
|
|
@@ -21252,13 +21814,39 @@ var __webpack_unused_export__;
|
|
|
21252
21814
|
__webpack_unused_export__ = ({ value: true });
|
|
21253
21815
|
exports.aplListNewService = aplListNewService;
|
|
21254
21816
|
const request_execute_command_paths_ts_1 = __webpack_require__(23634);
|
|
21817
|
+
const openapi_request_ts_1 = __webpack_require__(59848);
|
|
21818
|
+
const request_channel_ts_1 = __webpack_require__(43355);
|
|
21819
|
+
const logger_ts_1 = __webpack_require__(87562);
|
|
21255
21820
|
const types_ts_1 = __webpack_require__(42801);
|
|
21256
21821
|
const request_ts_1 = __webpack_require__(25285);
|
|
21822
|
+
/**
|
|
21823
|
+
* open API 通道的 list-new 查询:open API 未注册 code-dev function list,
|
|
21824
|
+
* 等价能力为 object-dev function query(过滤参数同名,2026-10-21 实测);
|
|
21825
|
+
* 响应包成 AplResponse 兼容信封,下游解析逻辑零改动。
|
|
21826
|
+
*
|
|
21827
|
+
* ⚠️ body / selectFieldName 为 FHH 老链路参数,object-dev function query 不支持
|
|
21828
|
+
* (2026-10-21 实测:传入后被服务端静默忽略、过滤不生效),显式剔除并提示用户。
|
|
21829
|
+
*/
|
|
21830
|
+
const requestAplListViaOpenApi = async (filters) => {
|
|
21831
|
+
const { body, selectFieldName, ...supported } = filters;
|
|
21832
|
+
if (body !== undefined || selectFieldName !== undefined) {
|
|
21833
|
+
logger_ts_1.loggerService.warn('Filters "body" and "selectFieldName" are not supported on the sharecrm login channel and were ignored.');
|
|
21834
|
+
}
|
|
21835
|
+
const content = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', supported);
|
|
21836
|
+
return {
|
|
21837
|
+
success: true,
|
|
21838
|
+
code: 'OK',
|
|
21839
|
+
data: { result: { function: content?.result?.function ?? [] } },
|
|
21840
|
+
};
|
|
21841
|
+
};
|
|
21257
21842
|
/**
|
|
21258
21843
|
* 操作中心接口包装调用:apl list(分页查询函数列表)
|
|
21259
21844
|
* pageNumber/pageSize 为必填(服务端要求字符串形态),其余为可选过滤条件
|
|
21260
21845
|
*/
|
|
21261
21846
|
const requestAplListExecute = async (filters) => {
|
|
21847
|
+
if ((0, request_channel_ts_1.resolveRequestChannel)() === 'openapi') {
|
|
21848
|
+
return requestAplListViaOpenApi(filters);
|
|
21849
|
+
}
|
|
21262
21850
|
const data = {
|
|
21263
21851
|
pageNumber: filters.pageNumber,
|
|
21264
21852
|
pageSize: filters.pageSize
|
|
@@ -25317,6 +25905,150 @@ async function executeApprovalRuntimeShareCli(commandPath, data, others) {
|
|
|
25317
25905
|
}
|
|
25318
25906
|
|
|
25319
25907
|
|
|
25908
|
+
/***/ },
|
|
25909
|
+
|
|
25910
|
+
/***/ 52402
|
|
25911
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
25912
|
+
|
|
25913
|
+
|
|
25914
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25915
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25916
|
+
};
|
|
25917
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25918
|
+
exports.authLoginCommand = authLoginCommand;
|
|
25919
|
+
exports.authStatusCommand = authStatusCommand;
|
|
25920
|
+
exports.authLogoutCommand = authLogoutCommand;
|
|
25921
|
+
const node_child_process_1 = __webpack_require__(31421);
|
|
25922
|
+
const node_path_1 = __importDefault(__webpack_require__(76760));
|
|
25923
|
+
const logger_ts_1 = __webpack_require__(87562);
|
|
25924
|
+
const openapi_request_ts_1 = __webpack_require__(59848);
|
|
25925
|
+
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
25926
|
+
/** 解析依赖包 @share-crm/sharecrm-cli 的 bin 入口(不走 PATH / 全局安装) */
|
|
25927
|
+
function resolveSharecrmBinEntry() {
|
|
25928
|
+
const require = (0, sharecrm_session_ts_1.getRuntimeRequire)();
|
|
25929
|
+
const packageJsonPath = require.resolve('@share-crm/sharecrm-cli/package.json');
|
|
25930
|
+
return node_path_1.default.join(node_path_1.default.dirname(packageJsonPath), 'dist', 'index.js');
|
|
25931
|
+
}
|
|
25932
|
+
/** 从工作区 domain 推导登录环境;未知 domain 报错并列出受支持的环境 */
|
|
25933
|
+
function deriveLoginEnvFromDomain(domain) {
|
|
25934
|
+
let host;
|
|
25935
|
+
try {
|
|
25936
|
+
host = new URL(domain).hostname;
|
|
25937
|
+
}
|
|
25938
|
+
catch {
|
|
25939
|
+
throw new Error(`Invalid workspace domain: ${domain}. Fix it in .sharedev/settings.json or run \`sharedev init\`.`);
|
|
25940
|
+
}
|
|
25941
|
+
const loginEnv = sharecrm_session_ts_1.DOMAIN_HOST_TO_LOGIN_ENV[host];
|
|
25942
|
+
if (!loginEnv) {
|
|
25943
|
+
const supported = Object.keys(sharecrm_session_ts_1.DOMAIN_HOST_TO_LOGIN_ENV).join(', ');
|
|
25944
|
+
throw new Error(`Workspace domain "${host}" has no known login environment mapping (supported: ${supported}). ` +
|
|
25945
|
+
'Ask the sharedev maintainers to add it, or switch the workspace domain.');
|
|
25946
|
+
}
|
|
25947
|
+
return loginEnv;
|
|
25948
|
+
}
|
|
25949
|
+
async function authLoginCommand(domain) {
|
|
25950
|
+
const loginEnv = deriveLoginEnvFromDomain(domain);
|
|
25951
|
+
// sharecrm 全局 config 优先级高于环境变量注入,固定过环境时会压制工作区推导——提前拦截
|
|
25952
|
+
const sharecrmConfig = (0, sharecrm_session_ts_1.readSharecrmConfig)();
|
|
25953
|
+
const pinned = sharecrmConfig.authBaseUrl?.trim();
|
|
25954
|
+
if (pinned && pinned.replace(/\/+$/, '') !== loginEnv.authBaseUrl.replace(/\/+$/, '')) {
|
|
25955
|
+
throw new Error(`sharecrm global config pins login environment to ${pinned}, conflicting with workspace (${loginEnv.authBaseUrl}). ` +
|
|
25956
|
+
'Remove authBaseUrl from ~/.sharecrm-cli/config.json or fix the workspace domain.');
|
|
25957
|
+
}
|
|
25958
|
+
let entry;
|
|
25959
|
+
try {
|
|
25960
|
+
entry = resolveSharecrmBinEntry();
|
|
25961
|
+
}
|
|
25962
|
+
catch {
|
|
25963
|
+
throw new Error('Failed to locate @share-crm/sharecrm-cli. Reinstall sharedev dependencies and try again.');
|
|
25964
|
+
}
|
|
25965
|
+
logger_ts_1.loggerService.info(`Login environment (from workspace domain): ${loginEnv.authBaseUrl}`);
|
|
25966
|
+
logger_ts_1.loggerService.info('Starting sharecrm device-flow login. Complete the authorization in your browser.');
|
|
25967
|
+
// 环境通过环境变量注入子进程(优先级低于 sharecrm config,上面已检测冲突),不写 sharecrm 全局配置
|
|
25968
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
25969
|
+
const child = (0, node_child_process_1.spawn)(process.execPath, [entry, 'auth', 'share-dev-login'], {
|
|
25970
|
+
stdio: 'inherit',
|
|
25971
|
+
env: {
|
|
25972
|
+
...process.env,
|
|
25973
|
+
FS_CLI_AUTH_BASE_URL: loginEnv.authBaseUrl,
|
|
25974
|
+
FS_CLI_API_BASE_URL: loginEnv.apiBaseUrl
|
|
25975
|
+
}
|
|
25976
|
+
});
|
|
25977
|
+
child.on('error', reject);
|
|
25978
|
+
child.on('exit', (code) => resolve(code));
|
|
25979
|
+
});
|
|
25980
|
+
if (exitCode !== 0) {
|
|
25981
|
+
throw new Error(`sharecrm auth share-dev-login exited with code ${exitCode ?? 'unknown'}.`);
|
|
25982
|
+
}
|
|
25983
|
+
const session = await (0, sharecrm_session_ts_1.readSharecrmSession)();
|
|
25984
|
+
if (!session?.accessToken) {
|
|
25985
|
+
throw new Error('sharecrm login finished but no session was stored. Run `sharedev auth login` again.');
|
|
25986
|
+
}
|
|
25987
|
+
// 中转完成:凭证固化到工作区(.sharedev/session.json,凭证跟工作区走)
|
|
25988
|
+
(0, sharecrm_session_ts_1.saveSharedevAuthSession)(session);
|
|
25989
|
+
logger_ts_1.loggerService.success(`Logged in as ${session.userName || `user ${session.userId}`} (appId ${session.appId}).`);
|
|
25990
|
+
// 端到端验证 Open API 通道(只读查询;失败仅 warn,部分环境命令集较旧属已知限制)
|
|
25991
|
+
try {
|
|
25992
|
+
const result = await (0, openapi_request_ts_1.executeOpenApiCommand)('object-dev function query', {
|
|
25993
|
+
pageNumber: '1',
|
|
25994
|
+
pageSize: '1'
|
|
25995
|
+
});
|
|
25996
|
+
const total = result?.result?.totalNumber;
|
|
25997
|
+
logger_ts_1.loggerService.success(`Open API channel verified${typeof total === 'number' ? `: ${total} functions visible` : ''}.`);
|
|
25998
|
+
}
|
|
25999
|
+
catch (error) {
|
|
26000
|
+
logger_ts_1.loggerService.warn(`Open API channel verification failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
26001
|
+
}
|
|
26002
|
+
}
|
|
26003
|
+
function formatExpireTime(session) {
|
|
26004
|
+
if (!session.tokenExpireAt) {
|
|
26005
|
+
return 'unknown';
|
|
26006
|
+
}
|
|
26007
|
+
return new Date(session.tokenExpireAt).toLocaleString();
|
|
26008
|
+
}
|
|
26009
|
+
async function authStatusCommand(settings) {
|
|
26010
|
+
const session = (0, sharecrm_session_ts_1.readSharedevAuthSession)();
|
|
26011
|
+
logger_ts_1.loggerService.info(`Workspace environment: ${settings.domain}`);
|
|
26012
|
+
if (!session) {
|
|
26013
|
+
logger_ts_1.loggerService.info('sharecrm login: not logged in. Run `sharedev auth login`.');
|
|
26014
|
+
}
|
|
26015
|
+
else {
|
|
26016
|
+
const expired = (0, sharecrm_session_ts_1.isSessionExpired)(session);
|
|
26017
|
+
logger_ts_1.loggerService.info([
|
|
26018
|
+
`sharecrm login: ${session.userName || `user ${session.userId}`} (appId ${session.appId})`,
|
|
26019
|
+
` apiUrl: ${session.apiUrl ?? 'https://open.fxiaoke.com/cli/'}`,
|
|
26020
|
+
` token : ${expired ? 'expired, will auto-refresh on next command' : `valid until ${formatExpireTime(session)}`}`
|
|
26021
|
+
].join('\n'));
|
|
26022
|
+
}
|
|
26023
|
+
// certificate 方式状态(老登录方式,配置在 .sharedev/settings.json;来自 bootstrap 加载的 settings)
|
|
26024
|
+
if (settings.certificate?.trim()) {
|
|
26025
|
+
logger_ts_1.loggerService.info(`certificate login: configured (${settings.settingsPath})`);
|
|
26026
|
+
}
|
|
26027
|
+
else {
|
|
26028
|
+
logger_ts_1.loggerService.info('certificate login: not configured');
|
|
26029
|
+
}
|
|
26030
|
+
}
|
|
26031
|
+
async function authLogoutCommand() {
|
|
26032
|
+
(0, sharecrm_session_ts_1.clearSharedevAuthSession)();
|
|
26033
|
+
logger_ts_1.loggerService.success('Workspace login state cleared (sharecrm own session is untouched).');
|
|
26034
|
+
}
|
|
26035
|
+
|
|
26036
|
+
|
|
26037
|
+
/***/ },
|
|
26038
|
+
|
|
26039
|
+
/***/ 98695
|
|
26040
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
26041
|
+
|
|
26042
|
+
var __webpack_unused_export__;
|
|
26043
|
+
|
|
26044
|
+
__webpack_unused_export__ = ({ value: true });
|
|
26045
|
+
exports.authLogoutCommand = exports.authStatusCommand = exports.authLoginCommand = void 0;
|
|
26046
|
+
var auth_command_ts_1 = __webpack_require__(52402);
|
|
26047
|
+
Object.defineProperty(exports, "authLoginCommand", ({ enumerable: true, get: function () { return auth_command_ts_1.authLoginCommand; } }));
|
|
26048
|
+
Object.defineProperty(exports, "authStatusCommand", ({ enumerable: true, get: function () { return auth_command_ts_1.authStatusCommand; } }));
|
|
26049
|
+
Object.defineProperty(exports, "authLogoutCommand", ({ enumerable: true, get: function () { return auth_command_ts_1.authLogoutCommand; } }));
|
|
26050
|
+
|
|
26051
|
+
|
|
25320
26052
|
/***/ },
|
|
25321
26053
|
|
|
25322
26054
|
/***/ 73302
|
|
@@ -33414,13 +34146,11 @@ exports.objectDevImportSettingPushCommand = objectDevImportSettingPushCommand;
|
|
|
33414
34146
|
var __webpack_unused_export__;
|
|
33415
34147
|
|
|
33416
34148
|
__webpack_unused_export__ = ({ value: true });
|
|
33417
|
-
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 =
|
|
33418
|
-
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 =
|
|
34149
|
+
exports.objectDevObjectMappingUpdateCommand = exports.objectDevObjectMappingCreateCommand = 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 = exports.objectDevObjectPullCommand = exports.objectDevObjectListCommand = void 0;
|
|
34150
|
+
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;
|
|
33419
34151
|
var object_ts_1 = __webpack_require__(13087);
|
|
33420
34152
|
Object.defineProperty(exports, "objectDevObjectListCommand", ({ enumerable: true, get: function () { return object_ts_1.objectDevObjectListCommand; } }));
|
|
33421
34153
|
Object.defineProperty(exports, "objectDevObjectPullCommand", ({ enumerable: true, get: function () { return object_ts_1.objectDevObjectPullCommand; } }));
|
|
33422
|
-
__webpack_unused_export__ = ({ enumerable: true, get: function () { return object_ts_1.ObjectDevObjectListOptions; } });
|
|
33423
|
-
__webpack_unused_export__ = ({ enumerable: true, get: function () { return object_ts_1.ObjectDevObjectPullOptions; } });
|
|
33424
34154
|
var object_related_ts_1 = __webpack_require__(90165);
|
|
33425
34155
|
Object.defineProperty(exports, "objectDevObjectRelatedPullCommand", ({ enumerable: true, get: function () { return object_related_ts_1.objectDevObjectRelatedPullCommand; } }));
|
|
33426
34156
|
var option_set_ts_1 = __webpack_require__(98892);
|
|
@@ -40972,9 +41702,9 @@ async function objectPullService(shouldQueryAll, queryType = null, apiName, skip
|
|
|
40972
41702
|
logger_ts_1.loggerService.info(`Skipped public object count: ${skippedPublicApiNames.length}`);
|
|
40973
41703
|
}
|
|
40974
41704
|
}
|
|
40975
|
-
//
|
|
41705
|
+
// 50个分批拉取
|
|
40976
41706
|
const apiNamesListGroups = apiNamesList.reduce((acc, item, index) => {
|
|
40977
|
-
const groupIndex = Math.floor(index /
|
|
41707
|
+
const groupIndex = Math.floor(index / 50);
|
|
40978
41708
|
if (!acc[groupIndex]) {
|
|
40979
41709
|
acc[groupIndex] = [];
|
|
40980
41710
|
}
|
|
@@ -45208,12 +45938,12 @@ exports.pwcInfoCommand = pwcInfoCommand;
|
|
|
45208
45938
|
exports.pwcDevCommand = pwcDevCommand;
|
|
45209
45939
|
exports.pwcPlaceholderCommand = pwcPlaceholderCommand;
|
|
45210
45940
|
const node_path_1 = __importDefault(__webpack_require__(76760));
|
|
45211
|
-
const node_module_1 = __webpack_require__(98995);
|
|
45212
45941
|
const prompts_1 = __webpack_require__(53503);
|
|
45213
45942
|
const file_ts_1 = __webpack_require__(57452);
|
|
45214
45943
|
const zip_ts_1 = __webpack_require__(89139);
|
|
45215
45944
|
const logger_ts_1 = __webpack_require__(87562);
|
|
45216
45945
|
const request_ts_1 = __webpack_require__(83733);
|
|
45946
|
+
const sharecrm_session_ts_1 = __webpack_require__(47166);
|
|
45217
45947
|
const pwc_service_ts_1 = __webpack_require__(63358);
|
|
45218
45948
|
const pwc_types_ts_1 = __webpack_require__(55844);
|
|
45219
45949
|
const pwc_mateXml_ts_1 = __webpack_require__(53683);
|
|
@@ -45650,11 +46380,10 @@ async function pwcDevCommand(filePath, context, options = {}) {
|
|
|
45650
46380
|
logger_ts_1.loggerService.info(shouldQueryAll
|
|
45651
46381
|
? `Starting Beefly dev server for ${outputNames.length} entr${outputNames.length === 1 ? 'y' : 'ies'}`
|
|
45652
46382
|
: `Starting Beefly dev server with ${normalizedFilePath}`);
|
|
45653
|
-
//
|
|
45654
|
-
//
|
|
45655
|
-
//
|
|
45656
|
-
const
|
|
45657
|
-
const beefly = require('@share-crm/beefly');
|
|
46383
|
+
// 运行时入口路径(bin/cli.mjs / dist/sharedev.js,即 process.argv[1])做解析基准,
|
|
46384
|
+
// 从 CLI 自身安装位置向上命中包内 node_modules 的 @share-crm/beefly;
|
|
46385
|
+
// npm link 下 argv[1] 是全局 bin symlink,getRuntimeRequire 会先 realpath 穿透再解析。
|
|
46386
|
+
const beefly = (0, sharecrm_session_ts_1.getRuntimeRequire)()('@share-crm/beefly');
|
|
45658
46387
|
// 复用 Beefly 官方 API 启动 webpack dev server,入口名称决定预览产物名称。
|
|
45659
46388
|
const server = await beefly.cli.dev({
|
|
45660
46389
|
port: options.port,
|
|
@@ -46567,6 +47296,7 @@ function validatePwcMateXmlContent(input) {
|
|
|
46567
47296
|
var __webpack_unused_export__;
|
|
46568
47297
|
|
|
46569
47298
|
__webpack_unused_export__ = ({ value: true });
|
|
47299
|
+
exports.assertPwcFileUploadChannel = assertPwcFileUploadChannel;
|
|
46570
47300
|
exports.fetchCode = fetchCode;
|
|
46571
47301
|
exports.fetchCodeByType = fetchCodeByType;
|
|
46572
47302
|
exports.updateCodeSource = updateCodeSource;
|
|
@@ -46580,7 +47310,41 @@ exports.createPluginSource = createPluginSource;
|
|
|
46580
47310
|
exports.enablePwcResource = enablePwcResource;
|
|
46581
47311
|
exports.getUrlByApiName = getUrlByApiName;
|
|
46582
47312
|
const request_ts_1 = __webpack_require__(83733);
|
|
47313
|
+
const request_channel_ts_1 = __webpack_require__(43355);
|
|
47314
|
+
const logger_ts_1 = __webpack_require__(87562);
|
|
47315
|
+
/**
|
|
47316
|
+
* PWC 命令的通道保护:openapi 能力未就绪期间——
|
|
47317
|
+
* 有 certificate 则 warn 后降级走 FHH(避免登录态+certificate 并存的功能回退);
|
|
47318
|
+
* 无 certificate 抛错引导配置。待服务端 download-file 修复后移除。
|
|
47319
|
+
*/
|
|
47320
|
+
function assertPwcChannelOrFallback() {
|
|
47321
|
+
if ((0, request_channel_ts_1.resolveRequestChannel)() !== 'openapi') {
|
|
47322
|
+
return;
|
|
47323
|
+
}
|
|
47324
|
+
if ((0, request_channel_ts_1.hasCertificateCredential)()) {
|
|
47325
|
+
logger_ts_1.loggerService.warn('PWC commands run via certificate channel (sharecrm login channel not ready for PWC file download).');
|
|
47326
|
+
return;
|
|
47327
|
+
}
|
|
47328
|
+
throw new Error('PWC commands are not yet available on the sharecrm login channel ' +
|
|
47329
|
+
'(Open API download-file returns empty content and has no URL query, 2026-10-21 measured). ' +
|
|
47330
|
+
'Use certificate mode (.sharedev/settings.json) for PWC commands.');
|
|
47331
|
+
}
|
|
47332
|
+
/**
|
|
47333
|
+
* PWC 文件上传环节的通道断言:*-new 链路主体走 openapi(code-dev 命令),
|
|
47334
|
+
* 但源码包上传(uploadFileList)仍依赖 FHH——纯登录态时给出明确引导而非服务端原始报错。
|
|
47335
|
+
*/
|
|
47336
|
+
function assertPwcFileUploadChannel() {
|
|
47337
|
+
if ((0, request_channel_ts_1.resolveRequestChannel)() !== 'openapi') {
|
|
47338
|
+
return;
|
|
47339
|
+
}
|
|
47340
|
+
if ((0, request_channel_ts_1.hasCertificateCredential)()) {
|
|
47341
|
+
return;
|
|
47342
|
+
}
|
|
47343
|
+
throw new Error('PWC file upload requires the certificate channel (not yet available on the sharecrm login channel). ' +
|
|
47344
|
+
'Use certificate mode (.sharedev/settings.json) for PWC push/deploy/create.');
|
|
47345
|
+
}
|
|
46583
47346
|
async function fetchCode(type, apiName) {
|
|
47347
|
+
assertPwcChannelOrFallback();
|
|
46584
47348
|
const response = await request_ts_1.requestService.FHH({
|
|
46585
47349
|
url: '/EM2HCompBuild/VscodeExtension/downloadCode',
|
|
46586
47350
|
data: {
|
|
@@ -46591,6 +47355,7 @@ async function fetchCode(type, apiName) {
|
|
|
46591
47355
|
return response.components ?? [];
|
|
46592
47356
|
}
|
|
46593
47357
|
async function fetchCodeByType(type) {
|
|
47358
|
+
assertPwcChannelOrFallback();
|
|
46594
47359
|
const response = await request_ts_1.requestService.FHH({
|
|
46595
47360
|
url: '/EM2HCompBuild/VscodeExtension/downloadCode',
|
|
46596
47361
|
data: {
|
|
@@ -46644,12 +47409,14 @@ async function updatePluginSource(apiName, params) {
|
|
|
46644
47409
|
});
|
|
46645
47410
|
}
|
|
46646
47411
|
async function updateCodeSource(type, apiName, params) {
|
|
47412
|
+
assertPwcChannelOrFallback();
|
|
46647
47413
|
if (type === 'plugin') {
|
|
46648
47414
|
return updatePluginSource(apiName, params);
|
|
46649
47415
|
}
|
|
46650
47416
|
return updateComponentSource(apiName, params);
|
|
46651
47417
|
}
|
|
46652
47418
|
async function buildCode(type, apiName, client = 'web') {
|
|
47419
|
+
assertPwcChannelOrFallback();
|
|
46653
47420
|
if (type === 'component') {
|
|
46654
47421
|
return request_ts_1.requestService.FHH({
|
|
46655
47422
|
url: '/EM9HCompBuild/Component/AsynBuildComponent',
|
|
@@ -46662,6 +47429,7 @@ async function buildCode(type, apiName, client = 'web') {
|
|
|
46662
47429
|
});
|
|
46663
47430
|
}
|
|
46664
47431
|
async function getBuildResult(buildId, type) {
|
|
47432
|
+
assertPwcChannelOrFallback();
|
|
46665
47433
|
return request_ts_1.requestService.FHH({
|
|
46666
47434
|
url: `/EM1HCompBuild/${type}/getBuildResult`,
|
|
46667
47435
|
data: { buildId }
|
|
@@ -46700,6 +47468,7 @@ async function hydratePwcComponent(component) {
|
|
|
46700
47468
|
};
|
|
46701
47469
|
}
|
|
46702
47470
|
async function getPwcConfig() {
|
|
47471
|
+
assertPwcChannelOrFallback();
|
|
46703
47472
|
const response = await request_ts_1.requestService.FHH({
|
|
46704
47473
|
url: '/EM1HCompBuild/Component/getConfig',
|
|
46705
47474
|
data: {}
|
|
@@ -46707,6 +47476,7 @@ async function getPwcConfig() {
|
|
|
46707
47476
|
return response.config ?? {};
|
|
46708
47477
|
}
|
|
46709
47478
|
async function getObjectApiNames() {
|
|
47479
|
+
assertPwcChannelOrFallback();
|
|
46710
47480
|
const response = await request_ts_1.requestService.FHH({
|
|
46711
47481
|
url: '/EM1HNCRM/API/v1/object/describe/service/findDescribeManageList',
|
|
46712
47482
|
data: {
|
|
@@ -46723,12 +47493,14 @@ async function getObjectApiNames() {
|
|
|
46723
47493
|
.filter((item) => Boolean(item)))).sort((a, b) => a.localeCompare(b));
|
|
46724
47494
|
}
|
|
46725
47495
|
async function createComponentSource(data) {
|
|
47496
|
+
assertPwcChannelOrFallback();
|
|
46726
47497
|
await request_ts_1.requestService.FHH({
|
|
46727
47498
|
url: '/EM1HCompBuild/Component/createComponent',
|
|
46728
47499
|
data
|
|
46729
47500
|
});
|
|
46730
47501
|
}
|
|
46731
47502
|
async function createPluginSource(data) {
|
|
47503
|
+
assertPwcChannelOrFallback();
|
|
46732
47504
|
await request_ts_1.requestService.FHH({
|
|
46733
47505
|
url: '/EM1HCompBuild/Plugin/createPlugin',
|
|
46734
47506
|
data
|
|
@@ -46739,6 +47511,7 @@ async function createPluginSource(data) {
|
|
|
46739
47511
|
* create 成功后必须立即调用,失败时由请求层抛错并中止后续本地回拉流程。
|
|
46740
47512
|
*/
|
|
46741
47513
|
async function enablePwcResource(type, apiName) {
|
|
47514
|
+
assertPwcChannelOrFallback();
|
|
46742
47515
|
const resourceType = type === 'plugin' ? 'Plugin' : 'Component';
|
|
46743
47516
|
const action = type === 'plugin' ? 'enablePlugin' : 'enableComponent';
|
|
46744
47517
|
await request_ts_1.requestService.FHH({
|
|
@@ -46747,6 +47520,7 @@ async function enablePwcResource(type, apiName) {
|
|
|
46747
47520
|
});
|
|
46748
47521
|
}
|
|
46749
47522
|
async function getUrlByApiName(apiName, type) {
|
|
47523
|
+
assertPwcChannelOrFallback();
|
|
46750
47524
|
if (type === 'plugin') {
|
|
46751
47525
|
const response = await request_ts_1.requestService.FHH({
|
|
46752
47526
|
url: '/EM1HCompBuild/Plugin/queryPluginInfo',
|
|
@@ -47334,6 +48108,7 @@ async function pwcCreateNewService(input, context) {
|
|
|
47334
48108
|
let remoteFiles = [];
|
|
47335
48109
|
if (useAppletZip) {
|
|
47336
48110
|
logger_ts_1.loggerService.updateLoading('Uploading initialization template archive');
|
|
48111
|
+
(0, pwc_service_ts_1.assertPwcFileUploadChannel)();
|
|
47337
48112
|
const zipBuffer = await (0, zip_ts_1.createZipBufferFromTextFiles)(input.templateFiles);
|
|
47338
48113
|
const [remoteZip] = await request_ts_1.requestService.uploadFileList([
|
|
47339
48114
|
{
|
|
@@ -47349,6 +48124,7 @@ async function pwcCreateNewService(input, context) {
|
|
|
47349
48124
|
}
|
|
47350
48125
|
else {
|
|
47351
48126
|
logger_ts_1.loggerService.updateLoading('Uploading initialization template files');
|
|
48127
|
+
(0, pwc_service_ts_1.assertPwcFileUploadChannel)();
|
|
47352
48128
|
const uploaded = await request_ts_1.requestService.uploadFileList(input.templateFiles.map((file) => ({
|
|
47353
48129
|
fileName: file.fileName,
|
|
47354
48130
|
base64String: Buffer.from(file.content, 'utf8').toString('base64')
|
|
@@ -47882,6 +48658,7 @@ const request_ts_1 = __webpack_require__(83733);
|
|
|
47882
48658
|
const request_ts_2 = __webpack_require__(35604);
|
|
47883
48659
|
const types_ts_1 = __webpack_require__(6500);
|
|
47884
48660
|
const pwc_mateXml_ts_1 = __webpack_require__(53683);
|
|
48661
|
+
const pwc_service_ts_1 = __webpack_require__(63358);
|
|
47885
48662
|
const pwc_workspace_ts_1 = __webpack_require__(64635);
|
|
47886
48663
|
const pwc_types_ts_1 = __webpack_require__(55844);
|
|
47887
48664
|
/**
|
|
@@ -47937,6 +48714,7 @@ async function pwcPushNewService(apiName, type, context) {
|
|
|
47937
48714
|
const { readFile } = await Promise.resolve(/* import() */).then(() => (__webpack_require__(59031)));
|
|
47938
48715
|
const zipBuffer = await readFile(appletZipPath);
|
|
47939
48716
|
logger_ts_1.loggerService.updateLoading(`Uploading ${apiName}.zip`);
|
|
48717
|
+
(0, pwc_service_ts_1.assertPwcFileUploadChannel)();
|
|
47940
48718
|
const [remoteZip] = await request_ts_1.requestService.uploadFileList([
|
|
47941
48719
|
{
|
|
47942
48720
|
fileName: `${apiName}.zip`,
|
|
@@ -47955,6 +48733,7 @@ async function pwcPushNewService(apiName, type, context) {
|
|
|
47955
48733
|
bundle = await (0, pwc_workspace_ts_1.readLocalPwcUploadBundle)(context, type, apiName, (0, pwc_mateXml_ts_1.buildPwcTypeConstraints)(config));
|
|
47956
48734
|
// 上传源码 / 静态资源 / fileTree
|
|
47957
48735
|
logger_ts_1.loggerService.updateLoading(`Uploading ${bundle.uploadFiles.length} files`);
|
|
48736
|
+
(0, pwc_service_ts_1.assertPwcFileUploadChannel)();
|
|
47958
48737
|
const uploaded = await request_ts_1.requestService.uploadFileList(bundle.uploadFiles.map((item) => ({
|
|
47959
48738
|
fileName: item.fileName,
|
|
47960
48739
|
base64String: item.base64String
|
|
@@ -50300,7 +51079,8 @@ function readRuntimeDebugFlag() {
|
|
|
50300
51079
|
}
|
|
50301
51080
|
function isRuntimeDebugEnabled() {
|
|
50302
51081
|
const runtimeEnabled = readRuntimeDebugFlag();
|
|
50303
|
-
|
|
51082
|
+
// typeof 保护:webpack DefinePlugin 常量在直跑(bun/tsx/node strip)路径下不存在
|
|
51083
|
+
return ( false) || runtimeEnabled || false;
|
|
50304
51084
|
}
|
|
50305
51085
|
|
|
50306
51086
|
|
|
@@ -50501,8 +51281,8 @@ async function readCliPackageMeta() {
|
|
|
50501
51281
|
? "@share-crm/sharedev-cli".trim()
|
|
50502
51282
|
: '@share-crm/sharedev-cli';
|
|
50503
51283
|
const debugEnabled = true && Boolean(false);
|
|
50504
|
-
const rawVersion = ( true && "0.0.4-rc.50".trim())
|
|
50505
|
-
? "0.0.4-rc.50".trim()
|
|
51284
|
+
const rawVersion = ( true && "0.0.4-rc.50-test.1".trim())
|
|
51285
|
+
? "0.0.4-rc.50-test.1".trim()
|
|
50506
51286
|
: '0.0.0';
|
|
50507
51287
|
const version = rawVersion + (debugEnabled ? '-debug' : '');
|
|
50508
51288
|
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.50",
|
|
3
|
+
"version": "0.0.4-rc.50-test.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "sharedev command line tool",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,7 @@
|
|
|
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",
|
|
35
36
|
"adm-zip": "^0.6.1",
|
|
36
37
|
"axios": "~1.13.0",
|
|
37
38
|
"chalk": "^5.6.2",
|