Files
openclaw/src/plugin-sdk/string-coerce-runtime.ts
T
Peter Steinberger 964c8c84c1 refactor: consolidate coercion ownership (#122299)
* refactor: consolidate coercion ownership

Centralize four canonical coercion helpers, migrate exact core and plugin duplicates through narrow Plugin SDK facades, and enforce declaration and plugin-normalization ownership boundaries.

The sweep adds eight focused SDK exports while deleting more production and tooling code than it adds. User-visible behavior is unchanged except for safer equivalent object and UI parsing at existing boundaries.

* fix: guard integer option ownership

Register resolveIntegerOption with the canonical function owner and extend the declaration-guard fixture so future local duplicates fail validation.

* fix: keep integer helpers on numeric facade

Remove the unshipped duplicate string-coerce exports and route every affected plugin consumer through the existing number-runtime contract.

* fix: point numeric coercion to number runtime

Make boundary and declaration diagnostics recommend the canonical numeric facade, with failing-before coverage for both guidance paths.
2026-08-11 17:14:53 -07:00

60 lines
1.8 KiB
TypeScript

// Narrow primitive coercion helpers for plugins that do not need the full text-runtime barrel.
export {
hasNonEmptyString,
localeLowercasePreservingWhitespace,
lowercasePreservingWhitespace,
normalizeFastMode,
normalizeBoundedOptionalString,
normalizeLowercaseStringOrEmpty,
normalizeNullableString,
normalizeOptionalLowercaseString,
normalizeOptionalString,
normalizeOptionalStringifiedId,
normalizeStringifiedEntries,
normalizeStringifiedOptionalString,
readNonBlankString,
readNonEmptyStringPreservingWhitespace,
readStringValue,
} from "../../packages/normalization-core/src/string-coerce.js";
export {
asFiniteNumberInRange,
asFiniteNumber,
asPositiveSafeInteger,
asSafeIntegerInRange,
parseFiniteNumber,
parseStrictFiniteNumber,
parseStrictInteger,
parseStrictNonNegativeInteger,
parseStrictPositiveInteger,
} from "../../packages/normalization-core/src/number-coercion.js";
export { asBoolean, parseBooleanValue } from "../utils/boolean.js";
export {
asRecord,
asNonArrayRecord,
asNullableObjectRecord,
asNullableRecord,
asOptionalObjectRecord,
asOptionalRecord,
filterStringRecord,
isRecord,
readStringField,
} from "../../packages/normalization-core/src/record-coerce.js";
export {
filterStringEntries,
normalizeAtHashSlug,
normalizeHyphenSlug,
normalizeOptionalTrimmedStringList,
normalizeSortedUniqueTrimmedStringList,
normalizeSingleOrTrimmedStringList,
normalizeStringEntries,
normalizeStringEntriesLower,
normalizeUniqueStringEntries,
normalizeUniqueTrimmedStringList,
normalizeTrimmedStringList,
sortUniqueStrings,
uniqueStrings,
uniqueValues,
} from "../../packages/normalization-core/src/string-normalization.js";
export { summarizeStringEntries } from "../shared/string-sample.js";