mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 00:34:33 +00:00
fix(types): tighten shared helper typing contracts
This commit is contained in:
@@ -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