refactor(nodes-cli): share node.invoke param builder
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { Command } from "commander";
|
||||
import type { NodeListNode, NodesRpcOpts } from "./types.js";
|
||||
import { callGateway } from "../../gateway/call.js";
|
||||
import { callGateway, randomIdempotencyKey } from "../../gateway/call.js";
|
||||
import { resolveNodeIdFromCandidates } from "../../shared/node-match.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
|
||||
import { withProgress } from "../progress.js";
|
||||
@@ -37,6 +37,25 @@ export const callGatewayCli = async (
|
||||
}),
|
||||
);
|
||||
|
||||
export function buildNodeInvokeParams(params: {
|
||||
nodeId: string;
|
||||
command: string;
|
||||
params?: Record<string, unknown>;
|
||||
timeoutMs?: number;
|
||||
idempotencyKey?: string;
|
||||
}): Record<string, unknown> {
|
||||
const invokeParams: Record<string, unknown> = {
|
||||
nodeId: params.nodeId,
|
||||
command: params.command,
|
||||
params: params.params,
|
||||
idempotencyKey: params.idempotencyKey ?? randomIdempotencyKey(),
|
||||
};
|
||||
if (typeof params.timeoutMs === "number" && Number.isFinite(params.timeoutMs)) {
|
||||
invokeParams.timeoutMs = params.timeoutMs;
|
||||
}
|
||||
return invokeParams;
|
||||
}
|
||||
|
||||
export function unauthorizedHintForMessage(message: string): string | null {
|
||||
const haystack = message.toLowerCase();
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user