refactor: consolidate plugin sdk surface

This commit is contained in:
Peter Steinberger
2026-03-20 18:50:25 +00:00
parent 46854a84a4
commit 62ddc9d9e0
294 changed files with 2071 additions and 1268 deletions

View File

@@ -1,3 +1,32 @@
export type {
AllowlistMatch,
AllowlistMatchSource,
CompiledAllowlist,
} from "../channels/allowlist-match.js";
export type { AllowlistUserResolutionLike } from "../channels/allowlists/resolve-utils.js";
export {
compileAllowlist,
formatAllowlistMatchMeta,
resolveAllowlistCandidates,
resolveAllowlistMatchByCandidates,
resolveAllowlistMatchSimple,
resolveCompiledAllowlistMatch,
} from "../channels/allowlist-match.js";
export {
firstDefined,
isSenderIdAllowed,
mergeDmAllowFromSources,
resolveGroupAllowFromSources,
} from "../channels/allow-from.js";
export {
addAllowlistUserEntriesFromConfigEntry,
buildAllowlistResolutionSummary,
canonicalizeAllowlistWithResolvedIds,
mergeAllowlist,
patchAllowlistUsersInConfigEntries,
summarizeMapping,
} from "../channels/allowlists/resolve-utils.js";
/** Lowercase and optionally strip prefixes from allowlist entries before sender comparisons. */
export function formatAllowFromLowercase(params: {
allowFrom: Array<string | number>;
@@ -96,3 +125,36 @@ export function isAllowedParsedChatSender<TParsed extends ParsedChatAllowTarget>
}
return false;
}
export type BasicAllowlistResolutionEntry = {
input: string;
resolved: boolean;
id?: string;
name?: string;
note?: string;
};
/** Clone allowlist resolution entries into a plain serializable shape for UI and docs output. */
export function mapBasicAllowlistResolutionEntries(
entries: BasicAllowlistResolutionEntry[],
): BasicAllowlistResolutionEntry[] {
return entries.map((entry) => ({
input: entry.input,
resolved: entry.resolved,
id: entry.id,
name: entry.name,
note: entry.note,
}));
}
/** Map allowlist inputs sequentially so resolver side effects stay ordered and predictable. */
export async function mapAllowlistResolutionInputs<T>(params: {
inputs: string[];
mapInput: (input: string) => Promise<T> | T;
}): Promise<T[]> {
const results: T[] = [];
for (const input of params.inputs) {
results.push(await params.mapInput(input));
}
return results;
}