Add shared outbound-push module for Hose deploy and replay
The deploy capability and the cross-tenant replay each carried their own copy of the same outbound pipeline: integration selection, the assisted-only gate, payload/URL construction, and push-then-verify. A change to the wire contract could drift into one path and not the other. Move the shared parts into domains/seal/outbound-push.ts and return the raw CloseAPI messageLog query to the hose domain (domains/hose/close/outbound.ts), leaving only the replay-specific log matching on the seal side. The production-target guard is now one implementation (replay-safety.ts) shared by the corp-pair resolver and the channel validator; both call sites are kept deliberately as defense in depth. Behavior note: replay used to silently pick the first integration when the target had several and no --sign-key was given. It now errors and lists the available signKeys, matching what deploy already did — pushing a message to the wrong outbound channel should not depend on array order.
This commit is contained in:
1 parent
f4147cec58
commit
df44791779
10 files changed
+774
-270
No files matched your search
@@ -6,6 +6,7 @@ import { booleanOption, jsonObject, numberOption, stringOption } from "../parser
|
||||
import { outputOptions } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
import * as api from "../../domains/seal/api.js";
|
||||
import { listHoseIntegrations } from "../../domains/seal/outbound-push.js";
|
||||
import { CliError } from "../errors.js";
|
||||
|
||||
export async function handleDeployCommand(
|
||||
@@ -68,7 +69,7 @@ export async function handleDeployCommand(
|
||||
const signKey = target ?? stringOption(args.options.signKey) ?? stringOption(args.options["sign-key"]);
|
||||
if (!signKey) {
|
||||
const config = await api.getApprovalStylePreferences(client);
|
||||
const hoseConfigs = (config.integrations ?? []).filter((i: any) => i.type === "hosecloud");
|
||||
const hoseConfigs = listHoseIntegrations(config);
|
||||
if (hoseConfigs.length === 0) {
|
||||
throw new Error(
|
||||
`当前企业 (${corp.name}) 尚未添加合思发布配置。\n` +
|
||||
@@ -78,9 +79,9 @@ export async function handleDeployCommand(
|
||||
console.error(`Usage: seal-use deploy hosecloud get <sign-key> [--corp ${corp.id}]\n`);
|
||||
console.error(`ℹ️ 当前企业发现以下可用的合思配置卡片:`);
|
||||
for (const item of hoseConfigs) {
|
||||
const name = (item as any).outboundName ?? "SealAI 审批";
|
||||
const name = item.outboundName ?? "SealAI 审批";
|
||||
const key = item.signKey;
|
||||
const origin = (item as any).apiOrigin ?? "production";
|
||||
const origin = item.apiOrigin ?? "production";
|
||||
console.error(` • "${name}" (signKey: ${key}, 环境: ${origin})`);
|
||||
console.error(` 👉 查看命令: seal-use deploy hosecloud get ${key} --corp ${corp.id}\n`);
|
||||
}
|
||||
@@ -122,7 +123,7 @@ export async function handleDeployCommand(
|
||||
|
||||
if (!signKey) {
|
||||
const config = await api.getApprovalStylePreferences(client);
|
||||
const hoseConfigs = (config.integrations ?? []).filter((i: any) => i.type === "hosecloud");
|
||||
const hoseConfigs = listHoseIntegrations(config);
|
||||
|
||||
if (hoseConfigs.length === 0) {
|
||||
throw new Error(
|
||||
@@ -142,9 +143,9 @@ export async function handleDeployCommand(
|
||||
console.error(`Usage: seal-use deploy hosecloud sync <sign-key> [--corp ${corp.id}]\n`);
|
||||
console.error(`ℹ️ 当前企业发现以下可用的合思配置卡片:`);
|
||||
for (const item of hoseConfigs) {
|
||||
const name = (item as any).outboundName ?? "SealAI 审批";
|
||||
const name = item.outboundName ?? "SealAI 审批";
|
||||
const key = item.signKey;
|
||||
const origin = (item as any).apiOrigin ?? "production";
|
||||
const origin = item.apiOrigin ?? "production";
|
||||
console.error(` • "${name}" (signKey: ${key}, 环境: ${origin})`);
|
||||
console.error(` 👉 同步命令: seal-use deploy hosecloud sync ${key} --corp ${corp.id}\n`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user