mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:11:22 +00:00
refactor: centralize isPlainObject, isRecord, isErrno, isLoopbackHost utilities (#12926)
This commit is contained in:
@@ -5,7 +5,7 @@ import type { PluginOrigin } from "../../plugins/types.js";
|
||||
import type { ChannelMeta } from "./types.js";
|
||||
import { MANIFEST_KEY } from "../../compat/legacy-names.js";
|
||||
import { discoverOpenClawPlugins } from "../../plugins/discovery.js";
|
||||
import { CONFIG_DIR, resolveUserPath } from "../../utils.js";
|
||||
import { CONFIG_DIR, isRecord, resolveUserPath } from "../../utils.js";
|
||||
|
||||
export type ChannelUiMetaEntry = {
|
||||
id: string;
|
||||
@@ -61,10 +61,6 @@ const ENV_CATALOG_PATHS = ["OPENCLAW_PLUGIN_CATALOG_PATHS", "OPENCLAW_MPM_CATALO
|
||||
|
||||
type ManifestKey = typeof MANIFEST_KEY;
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
||||
}
|
||||
|
||||
function parseCatalogEntries(raw: unknown): ExternalCatalogEntry[] {
|
||||
if (Array.isArray(raw)) {
|
||||
return raw.filter((entry): entry is ExternalCatalogEntry => isRecord(entry));
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { isRecord } from "../../../utils.js";
|
||||
export { isRecord };
|
||||
|
||||
export function asString(value: unknown): string | undefined {
|
||||
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
||||
}
|
||||
|
||||
export function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
|
||||
export function formatMatchMetadata(params: {
|
||||
matchKey?: unknown;
|
||||
matchSource?: unknown;
|
||||
|
||||
Reference in New Issue
Block a user