mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
Extract shared normalization/coercion helpers into private @openclaw/normalization-core workspace package while preserving existing plugin SDK helper subpaths.\n\nAlso keeps direct normalization-core imports internal, wires UI/build/loader resolution, and replaces the slow PR network CodeQL lane with a fast added-line boundary scan while retaining full CodeQL for scheduled/manual runs.\n\nVerification: local moved tests, plugin SDK boundary tests, extension loader tests, agents-support shard, UI build/test, build artifacts, lint, workflow guards, autoreview, and GitHub CI passed on PR head 963d893715.
26 lines
892 B
JavaScript
26 lines
892 B
JavaScript
//#region packages/normalization-core/src/record-coerce.ts
|
|
function isRecord(value) {
|
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
}
|
|
function asRecord(value) {
|
|
return typeof value === "object" && value !== null ? value : {};
|
|
}
|
|
function readStringField(record, key) {
|
|
const value = record?.[key];
|
|
return typeof value === "string" ? value : void 0;
|
|
}
|
|
function asOptionalRecord(value) {
|
|
return isRecord(value) ? value : void 0;
|
|
}
|
|
function asNullableRecord(value) {
|
|
return isRecord(value) ? value : null;
|
|
}
|
|
function asOptionalObjectRecord(value) {
|
|
return value && typeof value === "object" ? value : void 0;
|
|
}
|
|
function asNullableObjectRecord(value) {
|
|
return value && typeof value === "object" ? value : null;
|
|
}
|
|
//#endregion
|
|
export { asNullableObjectRecord, asNullableRecord, asOptionalObjectRecord, asOptionalRecord, asRecord, isRecord, readStringField };
|