feat(FN-2718): add unavailable node policy setting and validation
- Define and export unavailable node policy types in core settings interfaces - Add project-level unavailable node policy default and runtime validation helper - Add core unit coverage for unavailable node policy parsing and acceptance cases - Guard Paperclip mint requests to include companyId only when available for type-safe payloads - Document unavailable node policy in the settings reference
This commit is contained in:
20
packages/core/src/settings-validation.ts
Normal file
20
packages/core/src/settings-validation.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { UnavailableNodePolicy } from "./types.js";
|
||||
|
||||
const UNAVAILABLE_NODE_POLICIES: readonly UnavailableNodePolicy[] = ["block", "fallback-local"] as const;
|
||||
|
||||
/**
|
||||
* Validates a project unavailable-node routing policy value.
|
||||
*
|
||||
* Returns the normalized policy value when valid, otherwise undefined.
|
||||
*/
|
||||
export function validateUnavailableNodePolicy(value: unknown): UnavailableNodePolicy | undefined {
|
||||
if (value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
return (UNAVAILABLE_NODE_POLICIES as readonly string[]).includes(value)
|
||||
? (value as UnavailableNodePolicy)
|
||||
: undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user