fix(types): tighten shared helper typing contracts

This commit is contained in:
Peter Steinberger
2026-03-02 15:19:19 +00:00
parent ed21b63bb8
commit 44c50d9a73
6 changed files with 21 additions and 11 deletions

View File

@@ -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 });