Skip to content

@xtandard/flags/schema

Core type definitions for @xtandard/flags.

This module is types only — no runtime code, no dependencies. It is safe to import from the request-path evaluator and the OpenFeature provider. Runtime validation (which pulls in valibot) lives in validation.

import { … } from "@xtandard/flags/schema";
Name Summary
isConditionGroup Whether a ConditionNode is a boolean group (vs a leaf condition).
leafConditions Depth-first walk of every leaf Condition under a list of nodes.
Name Summary
Actor Identity captured on snapshot/audit records.
AuditEntry A single entry in the publish/rollback/update/delete audit log.
Condition A single predicate evaluated against the EvaluationContext.
Draft The mutable working copy edited via the admin API before publishing.
EnvironmentMeta Environment metadata record (scoped to a project).
EvaluationContext OpenFeature evaluation context. targetingKey is the preferred bucketing key for deterministic splits; arbitrary attributes drive targeting rules.
EvaluationDetail The result of evaluating one flag against a context.
Flag A feature flag definition. This is the unit edited in drafts and frozen into snapshots.
FlagDuration A duration as an authored value + unit (kept faithful for round-tripping in the UI).
FlagOwner Who owns/maintains a flag — organizational metadata, never consulted by the evaluator.
FlagSchedule A flag’s active time window. Both bounds optional (open-ended). The flag is “live” only within [enableAt, disableAt]; outside it serves its default variant. ISO-8601 instants.
FlagTest One pinned expectation for Flag.tests.
LifecyclePolicy A flag’s stale-detection policy. expiry says when it’s overdue. For a duration expiry the flag is only flagged once it’s also been idle longer than idle (default 7 days) — so an actively-edited flag isn’t nagged. A datetime expiry is a hard deadline (idle is ignored).
Override An exact, highest-priority assignment for a specific targeting key.
Prerequisite A dependency on another flag: this flag is only “live” when the prerequisite flag resolves to the required variant for the same context. Otherwise the dependent flag serves its default variant (reason PREREQUISITE_FAILED). The dependency graph is validated acyclic at publish time.
ProjectMeta Project metadata record.
Rule A targeting rule. Rules are evaluated in array order; first match wins.
Segment A named, reusable audience — a tree of conditions (top-level AND, with nested AND/OR/NOT groups) referenced by targeting rules via the inSegment operator. Segments are an authoring convenience: a single-key inSegment is resolved (inlined) into rules at compile time; array inSegment and notInSegment are embedded in the snapshot and evaluated at runtime.
Snapshot An immutable, versioned, fully-resolved set of flags for one project/environment. This is what the runtime provider loads and evaluates.
SplitEntry One leg of a weighted split. Weights need not sum to 100.
Variant A named, addressable value a flag can serve. Every flag — including boolean flags — is variant-based internally.
Name Summary
ConditionGroup A boolean group of condition nodes — the building block for AND/OR/NOT nesting inside a rule (or segment). Exactly one key is set:
ConditionNode A node in a rule/segment’s conditions: either a leaf Condition or a boolean ConditionGroup. The top-level conditions array is an implicit AND of its nodes (so a flat list of leaves behaves exactly as before).
ConditionOperator Comparison/predicate operators available to targeting rule conditions.
DurationUnit Time unit for a FlagDuration.
EvaluationReason Resolution reasons surfaced by the evaluator. A superset of OpenFeature’s standard reasons; ./openfeature maps these to OF-compatible strings.
FlagErrorCode Error codes aligned with OpenFeature’s ErrorCode.
FlagType The four flag value types, matching OpenFeature’s typed evaluation methods.
FlagValue Any concrete value a flag can resolve to.
JsonValue JSON-serializable value, used for json-typed flag variants.
LifecycleExpiry When a flag is considered past its expected lifetime: either a relative duration from createdAt/updatedAt, or an absolute datetime (a hard deadline).
Serve What a rule (or fallthrough) serves: either a fixed variant or a deterministic weighted split keyed on the targeting key.
Name Summary
SNAPSHOT_SCHEMA_VERSION Current schema version for compiled snapshots.