import { D as DbAdapter, j as CreateFlagInput, F as Flag, U as ListFlagsInput, V as ListFlagsResult, ak as UpdateFlagInput, I as FlagStatus, A as AddRuleInput, H as FlagRule, al as UpdateRuleInput, ac as RuleOrdering, l as CreateSegmentInput, ad as Segment, am as UpdateSegmentInput, ae as SegmentUsage, k as CreateReleaseInput, $ as Release, O as HistoryEntry, q as ExclusionLayer, r as ExclusionLayerAllocation, ai as TrackEventInput, aj as TrackingEvent } from '../types-YdF1AOxp.js'; import '../core/metrics.js'; import '../core/flag-types.js'; type RepositoryName = "Flag" | "Rule" | "Segment" | "Release" | "Assignment" | "History" | "Impression"; /** * Repositories that are optional for backwards-compatibility. If absent, * the corresponding feature (e.g. exclusion layers) is disabled at runtime * but the adapter still constructs and the required surface keeps working. */ type OptionalRepositoryName = "ExclusionLayer"; type AnyRepositoryName = RepositoryName | OptionalRepositoryName; interface RepositoryFindManyOptions { where?: Record; orderBy?: Array<{ field: string; direction: "asc" | "desc"; }>; } interface RowRepository { create(values: Record): Promise; findOne(where: Record): Promise; findMany(options?: RepositoryFindManyOptions): Promise; update(where: Record, values: Record): Promise; delete(where: Record): Promise; deleteMany(where: Record): Promise; } /** * Optional repos (e.g. `ExclusionLayer`) are added via the Partial intersection * so existing users without those tables continue to construct without errors. */ type RepositorySet = Record & Partial>; declare const ROLLEASE_REPOSITORY_NAMES: RepositoryName[]; declare const ROLLEASE_OPTIONAL_REPOSITORY_NAMES: OptionalRepositoryName[]; declare const ROLLEASE_REPOSITORY_REQUIRED_COLUMNS: Record; declare class RepositoryDbAdapter implements DbAdapter { protected repositories: RepositorySet; private closeHandler?; private idCounter; constructor(repositories: RepositorySet, opts?: { close?: () => Promise; }); private genId; createFlag(input: CreateFlagInput): Promise; getFlag(key: string): Promise; listFlags(input?: ListFlagsInput): Promise; updateFlag(key: string, input: UpdateFlagInput): Promise; setFlagStatus(key: string, status: FlagStatus): Promise; deleteFlag(key: string): Promise; cloneFlag(sourceKey: string, newKey: string, includeRules: boolean, includeRollout: boolean): Promise; setRollout(key: string, rollout: { percentage?: number; sticky?: boolean; hashKey?: string; rampSchedule?: { at: string; percentage: number; }[]; }): Promise; addRule(flagKey: string, input: AddRuleInput): Promise; updateRule(flagKey: string, ruleId: string, input: UpdateRuleInput): Promise; removeRule(flagKey: string, ruleId: string): Promise; listRules(flagKey: string): Promise; reorderRules(flagKey: string, ordering: RuleOrdering[]): Promise; createSegment(input: CreateSegmentInput): Promise; updateSegment(key: string, input: UpdateSegmentInput): Promise; deleteSegment(key: string): Promise; listSegments(): Promise; getSegment(key: string): Promise; getSegmentUsage(key: string): Promise; createRelease(input: CreateReleaseInput): Promise; approveRelease(releaseId: string, approverId: string): Promise; rejectRelease(releaseId: string, rejectorId: string, reason?: string): Promise; getRelease(releaseId: string): Promise; listReleases(filters?: { environment?: string; status?: string; limit?: number; }): Promise; deployRelease(releaseId: string, deployedBy?: string): Promise; rollbackRelease(releaseId: string, rolledBackBy?: string, reason?: string): Promise; getUserAssignment(flagKey: string, userId: string): Promise; getUserAssignments(flagKeys: string[], userId: string): Promise>; setUserAssignment(flagKey: string, userId: string, variantKey: string): Promise; addHistory(entry: Omit): Promise; getHistory(flagKey: string, opts?: { limit?: number; }): Promise; trackImpression(params: { flagKey: string; userId: string; value: unknown; variant: string | null; reason: string; }): Promise; getAllActiveFlags(opts?: { namespace?: string; tags?: string[]; keys?: string[]; limit?: number; offset?: number; }): Promise; addTags(flagKey: string, tags: string[]): Promise; removeTags(flagKey: string, tags: string[]): Promise; createExclusionLayer(input: ExclusionLayer): Promise; getExclusionLayer(key: string): Promise; updateExclusionLayer(key: string, allocations: ExclusionLayerAllocation[]): Promise; deleteExclusionLayer(key: string): Promise; listExclusionLayers(): Promise; touchFlagEvaluation(key: string): Promise; trackEvent(event: TrackEventInput): Promise; listTrackingEvents(filters?: { userId?: string; event?: string; limit?: number; }): Promise; getUserImpressions(userId: string, opts?: { limit?: number; flagKey?: string; }): Promise>; close(): Promise; private requireExclusionRepo; private getRequiredRelease; } declare function validateRepositorySet(repositories: Partial): void; declare function toFlag(row: unknown): Flag; declare function toRule(row: unknown): FlagRule; declare function toExclusionLayer(row: unknown): ExclusionLayer; declare function toSegment(row: unknown): Segment; declare function toRelease(row: unknown): Release; declare function toHistory(row: unknown): HistoryEntry; declare function plain(row: unknown): Record; declare function stripUndefined>(value: T): T; declare function date(value: unknown): Date; declare function nullableDate(value: unknown): Date | null; declare function optionalString(value: unknown): string | undefined; declare function optionalNumber(value: unknown): number | undefined; declare function optionalBoolean(value: unknown): boolean | undefined; declare function arrayOrUndefined(value: unknown): T[] | undefined; export { type AnyRepositoryName, type OptionalRepositoryName, ROLLEASE_OPTIONAL_REPOSITORY_NAMES, ROLLEASE_REPOSITORY_NAMES, ROLLEASE_REPOSITORY_REQUIRED_COLUMNS, RepositoryDbAdapter, type RepositoryFindManyOptions, type RepositoryName, type RepositorySet, type RowRepository, arrayOrUndefined, date, nullableDate, optionalBoolean, optionalNumber, optionalString, plain, stripUndefined, toExclusionLayer, toFlag, toHistory, toRelease, toRule, toSegment, validateRepositorySet };