mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 04:50:23 +00:00
refactor: consolidate plugin sdk surface
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user