mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 21:44:32 +00:00
fix(types): tighten shared helper typing contracts
This commit is contained in:
@@ -49,16 +49,17 @@ export function resolveInboundRouteEnvelopeBuilder<
|
||||
TConfig,
|
||||
TEnvelope,
|
||||
TRoute extends RouteLike,
|
||||
TPeer extends RoutePeerLike,
|
||||
>(params: {
|
||||
cfg: TConfig;
|
||||
channel: string;
|
||||
accountId: string;
|
||||
peer: RoutePeerLike;
|
||||
peer: TPeer;
|
||||
resolveAgentRoute: (params: {
|
||||
cfg: TConfig;
|
||||
channel: string;
|
||||
accountId: string;
|
||||
peer: RoutePeerLike;
|
||||
peer: TPeer;
|
||||
}) => TRoute;
|
||||
sessionStore?: string;
|
||||
resolveStorePath: (store: string | undefined, opts: { agentId: string }) => string;
|
||||
@@ -94,13 +95,18 @@ export function resolveInboundRouteEnvelopeBuilder<
|
||||
return { route, buildEnvelope };
|
||||
}
|
||||
|
||||
type InboundRouteEnvelopeRuntime<TConfig, TEnvelope, TRoute extends RouteLike> = {
|
||||
type InboundRouteEnvelopeRuntime<
|
||||
TConfig,
|
||||
TEnvelope,
|
||||
TRoute extends RouteLike,
|
||||
TPeer extends RoutePeerLike,
|
||||
> = {
|
||||
routing: {
|
||||
resolveAgentRoute: (params: {
|
||||
cfg: TConfig;
|
||||
channel: string;
|
||||
accountId: string;
|
||||
peer: RoutePeerLike;
|
||||
peer: TPeer;
|
||||
}) => TRoute;
|
||||
};
|
||||
session: {
|
||||
@@ -124,12 +130,13 @@ export function resolveInboundRouteEnvelopeBuilderWithRuntime<
|
||||
TConfig,
|
||||
TEnvelope,
|
||||
TRoute extends RouteLike,
|
||||
TPeer extends RoutePeerLike,
|
||||
>(params: {
|
||||
cfg: TConfig;
|
||||
channel: string;
|
||||
accountId: string;
|
||||
peer: RoutePeerLike;
|
||||
runtime: InboundRouteEnvelopeRuntime<TConfig, TEnvelope, TRoute>;
|
||||
peer: TPeer;
|
||||
runtime: InboundRouteEnvelopeRuntime<TConfig, TEnvelope, TRoute, TPeer>;
|
||||
sessionStore?: string;
|
||||
}): {
|
||||
route: TRoute;
|
||||
|
||||
@@ -23,6 +23,7 @@ export function normalizeAllowListLower(list?: Array<string | number>) {
|
||||
export type SlackAllowListMatch = AllowlistMatch<
|
||||
"wildcard" | "id" | "prefixed-id" | "prefixed-user" | "name" | "prefixed-name" | "slug"
|
||||
>;
|
||||
type SlackAllowListSource = Exclude<SlackAllowListMatch["matchSource"], undefined>;
|
||||
|
||||
export function resolveSlackAllowListMatch(params: {
|
||||
allowList: string[];
|
||||
@@ -40,7 +41,7 @@ export function resolveSlackAllowListMatch(params: {
|
||||
const id = params.id?.toLowerCase();
|
||||
const name = params.name?.toLowerCase();
|
||||
const slug = normalizeSlackSlug(name);
|
||||
const candidates: Array<{ value?: string; source: SlackAllowListMatch["matchSource"] }> = [
|
||||
const candidates: Array<{ value?: string; source: SlackAllowListSource }> = [
|
||||
{ value: id, source: "id" },
|
||||
{ value: id ? `slack:${id}` : undefined, source: "prefixed-id" },
|
||||
{ value: id ? `user:${id}` : undefined, source: "prefixed-user" },
|
||||
@@ -49,7 +50,7 @@ export function resolveSlackAllowListMatch(params: {
|
||||
{ value: name, source: "name" as const },
|
||||
{ value: name ? `slack:${name}` : undefined, source: "prefixed-name" as const },
|
||||
{ value: slug, source: "slug" as const },
|
||||
] satisfies Array<{ value?: string; source: SlackAllowListMatch["matchSource"] }>)
|
||||
] satisfies Array<{ value?: string; source: SlackAllowListSource }>)
|
||||
: []),
|
||||
];
|
||||
return resolveAllowlistMatchByCandidates({ allowList, candidates });
|
||||
|
||||
Reference in New Issue
Block a user