addons/isl-server/src/__generated__/node-edenfs-notifications-client/index.d.tsblame
View source
b69ab311/**
b69ab312 * This software contains information and intellectual property that is
b69ab313 * confidential and proprietary to Facebook, Inc. and its affiliates.
b69ab314 *
b69ab315 * @generated
b69ab316 */
b69ab317
b69ab318/*
b69ab319 * This file is synced between fbcode/eden/fs/facebook/prototypes/node-edenfs-notifications-client/index.d.ts.
b69ab3110 * The authoritative copy is the one in eden/fs/.
b69ab3111 * Use `yarn sync-edenfs-notifications` to perform the sync.
b69ab3112 *
b69ab3113 * This file is intended to be self contained so it may be copied/referenced from other extensions,
b69ab3114 * which is why it should not import anything and why it reimplements many types.
b69ab3115 */
b69ab3116
b69ab3117/**
b69ab3118 * TypeScript type definitions for EdenFS Notifications Client
b69ab3119 * JavaScript interface for EdenFS CLI notify endpoint
b69ab3120 */
b69ab3121
b69ab3122import {EventEmitter} from 'events';
b69ab3123
b69ab3124/**
b69ab3125 * Options for initializing EdenFSNotificationsClient
b69ab3126 */
b69ab3127export interface EdenFSClientOptions {
b69ab3128 /** Path to the mount point */
b69ab3129 mountPoint?: string;
b69ab3130 /** Timeout in milliseconds for commands (default: 30000) */
b69ab3131 timeout?: number;
b69ab3132 /** Path to the eden binary (default: 'eden') */
b69ab3133 edenBinaryPath?: string;
b69ab3134}
b69ab3135
b69ab3136/**
b69ab3137 * Journal position information
b69ab3138 */
b69ab3139export interface JournalPosition {
b69ab3140 journalPosition: string;
b69ab3141}
b69ab3142
b69ab3143/**
b69ab3144 * Options for getStatus command
b69ab3145 */
b69ab3146export interface GetStatusOptions {
b69ab3147 /** Use case identifier for the command */
b69ab3148 useCase?: string;
b69ab3149}
b69ab3150
b69ab3151/**
b69ab3152 * Options for waitReady command
b69ab3153 */
b69ab3154export interface WaitReadyOptions {
b69ab3155 /** Use case identifier for the command */
b69ab3156 useCase?: string;
b69ab3157 /** Timeout in milliseconds for the command (overrides constructor value) */
b69ab3158 timeout?: number;
b69ab3159}
b69ab3160
b69ab3161/**
b69ab3162 * Options for getPosition command
b69ab3163 */
b69ab3164export interface GetPositionOptions {
b69ab3165 /** Use case identifier for the command */
b69ab3166 useCase?: string;
b69ab3167 /** Mount point path (overrides constructor value) */
b69ab3168 mountPoint?: string;
b69ab3169}
b69ab3170
b69ab3171/**
b69ab3172 * Options for getChangesSince command
b69ab3173 */
b69ab3174export interface GetChangesSinceOptions {
b69ab3175 /** Journal position to start from */
b69ab3176 position?: string | JournalPosition;
b69ab3177 /** Use case identifier */
b69ab3178 useCase?: string;
b69ab3179 /** Mount point path (overrides constructor value) */
b69ab3180 mountPoint?: string;
b69ab3181 /** Relative root to scope results */
b69ab3182 relativeRoot?: string;
b69ab3183 /** Include VCS roots in output */
b69ab3184 includeVcsRoots?: boolean;
b69ab3185 /** Included roots in output */
b69ab3186 includedRoots?: string[];
b69ab3187 /** Excluded roots in output */
b69ab3188 excludedRoots?: string[];
b69ab3189 /** Included file suffixes in output */
b69ab3190 includedSuffixes?: string[];
b69ab3191 /** Excluded file suffixes in output */
b69ab3192 excludedSuffixes?: string[];
b69ab3193 /** Return JSON format (default: true) */
b69ab3194 json?: boolean;
b69ab3195 /** States to wait for deassertion */
b69ab3196 deferredStates?: string[];
b69ab3197}
b69ab3198
b69ab3199/**
b69ab31100 * Options for subscription
b69ab31101 */
b69ab31102export interface SubscriptionOptions {
b69ab31103 /** Journal position to start from */
b69ab31104 position?: string;
b69ab31105 /** Use case identifier */
b69ab31106 useCase?: string;
b69ab31107 /** Mount point path */
b69ab31108 mountPoint?: string;
b69ab31109 /** Throttle in milliseconds between events (default: 0) */
b69ab31110 throttle?: number;
b69ab31111 /** Relative root to scope results */
b69ab31112 relativeRoot?: string;
b69ab31113 /** Include VCS roots in output */
b69ab31114 includeVcsRoots?: boolean;
b69ab31115 /** Included roots in output */
b69ab31116 includedRoots?: string[];
b69ab31117 /** Excluded roots in output */
b69ab31118 excludedRoots?: string[];
b69ab31119 /** Included file suffixes in output */
b69ab31120 includedSuffixes?: string[];
b69ab31121 /** Excluded file suffixes in output */
b69ab31122 excludedSuffixes?: string[];
b69ab31123 /** States to wait for deassertion */
b69ab31124 deferredStates?: string[];
b69ab31125 /** Path to eden binary */
b69ab31126 edenBinaryPath?: string;
b69ab31127}
b69ab31128
b69ab31129/**
b69ab31130 * Options for enterState command
b69ab31131 */
b69ab31132export interface EnterStateOptions {
b69ab31133 /** Duration in seconds to maintain state */
b69ab31134 duration?: number;
b69ab31135 /** Use case identifier */
b69ab31136 useCase?: string;
b69ab31137 /** Mount point path (overrides constructor value) */
b69ab31138 mountPoint?: string;
b69ab31139}
b69ab31140
b69ab31141/**
b69ab31142 * Small change types
b69ab31143 */
b69ab31144export interface AddedChange {
b69ab31145 path: number[];
b69ab31146 file_type: string;
b69ab31147}
b69ab31148
b69ab31149export interface ModifiedChange {
b69ab31150 path: number[];
b69ab31151 file_type: string;
b69ab31152}
b69ab31153
b69ab31154export interface RemovedChange {
b69ab31155 path: number[];
b69ab31156 file_type: string;
b69ab31157}
b69ab31158
b69ab31159export interface RenamedChange {
b69ab31160 from: number[];
b69ab31161 to: number[];
b69ab31162 file_type: string;
b69ab31163}
b69ab31164
b69ab31165export interface ReplacedChange {
b69ab31166 from: number[];
b69ab31167 to: number[];
b69ab31168 file_type: string;
b69ab31169}
b69ab31170
b69ab31171export interface SmallChange {
b69ab31172 Added?: AddedChange;
b69ab31173 Modified?: ModifiedChange;
b69ab31174 Removed?: RemovedChange;
b69ab31175 Renamed?: RenamedChange;
b69ab31176 Replaced?: ReplacedChange;
b69ab31177}
b69ab31178
b69ab31179/**
b69ab31180 * Large change types
b69ab31181 */
b69ab31182export interface DirectoryRenamedChange {
b69ab31183 from: number[];
b69ab31184 to: number[];
b69ab31185}
b69ab31186
b69ab31187export interface CommitTransitionChange {
b69ab31188 from: number[];
b69ab31189 to: number[];
b69ab31190}
b69ab31191
b69ab31192export interface LostChanges {
b69ab31193 reason: string;
b69ab31194}
b69ab31195
b69ab31196export interface LargeChange {
b69ab31197 DirectoryRenamed?: DirectoryRenamedChange;
b69ab31198 CommitTransition?: CommitTransitionChange;
b69ab31199 LostChanges?: LostChanges;
b69ab31200}
b69ab31201
b69ab31202/**
b69ab31203 * State change types
b69ab31204 */
b69ab31205export interface StateEnteredChange {
b69ab31206 state: string;
b69ab31207}
b69ab31208
b69ab31209export interface StateLeftChange {
b69ab31210 state: string;
b69ab31211}
b69ab31212
b69ab31213export interface StateChange {
b69ab31214 StateEntered?: StateEnteredChange;
b69ab31215 StateLeft?: StateLeftChange;
b69ab31216}
b69ab31217
b69ab31218/**
b69ab31219 * File system change event
b69ab31220 */
b69ab31221export interface Change {
b69ab31222 SmallChange?: SmallChange;
b69ab31223 LargeChange?: LargeChange;
b69ab31224 StateChange?: StateChange;
b69ab31225}
b69ab31226
b69ab31227/**
b69ab31228 * Response from getChangesSince
b69ab31229 */
b69ab31230export interface ChangesSinceResponse {
b69ab31231 /** List of changes */
b69ab31232 changes: Change[];
b69ab31233 /** New journal position after changes */
b69ab31234 to_position?: string;
b69ab31235}
b69ab31236
b69ab31237/**
b69ab31238 * Event emitted by subscription
b69ab31239 */
b69ab31240export interface SubscriptionEvent extends ChangesSinceResponse {
b69ab31241 /** Position a state change occurred at */
b69ab31242 position?: string;
b69ab31243 /** Event type for state changes */
b69ab31244 event_type?: 'Entered' | 'Left';
b69ab31245 /** State name for state change events */
b69ab31246 state?: string;
b69ab31247}
b69ab31248
b69ab31249/**
b69ab31250 * Callback for subscription events
b69ab31251 */
b69ab31252export type SubscriptionCallback = (error: Error | null, result: SubscriptionEvent | null) => void;
b69ab31253
b69ab31254/**
b69ab31255 * Custom error class for EdenFS errors
b69ab31256 */
b69ab31257export class EdenFSError extends Error {
b69ab31258 edenFSResponse: any;
b69ab31259}
b69ab31260
b69ab31261/**
b69ab31262 * EdenFS Notifications Client
b69ab31263 * Provides methods to interact with EdenFS notifications via the EdenFS CLI
b69ab31264 */
b69ab31265export class EdenFSNotificationsClient extends EventEmitter {
b69ab31266 mountPoint: string | null;
b69ab31267 timeout: number;
b69ab31268 edenBinaryPath: string;
b69ab31269 readonly DEFAULT_EDENFS_RECONNECT_DELAY_MS: number;
b69ab31270 readonly MAXIMUM_EDENFS_RECONNECT_DELAY_MS: number;
b69ab31271
b69ab31272 constructor(options?: EdenFSClientOptions);
b69ab31273
b69ab31274 /**
b69ab31275 * Get the current EdenFS status
b69ab31276 */
b69ab31277 getStatus(options?: GetStatusOptions): Promise<string>;
b69ab31278
b69ab31279 /**
b69ab31280 * Wait until EdenFS is ready, using getStatus
b69ab31281 * @returns Promise that resolves to true if healthy, false if timeout
b69ab31282 */
b69ab31283 waitReady(options?: WaitReadyOptions): Promise<boolean>;
b69ab31284
b69ab31285 /**
b69ab31286 * Get the current EdenFS journal position
b69ab31287 */
b69ab31288 getPosition(options?: GetPositionOptions): Promise<string>;
b69ab31289
b69ab31290 /**
b69ab31291 * Get changes since a specific journal position
b69ab31292 */
b69ab31293 getChangesSince(options?: GetChangesSinceOptions): Promise<ChangesSinceResponse>;
b69ab31294
b69ab31295 /**
b69ab31296 * Subscribe to filesystem changes
b69ab31297 */
b69ab31298 subscribe(options?: SubscriptionOptions, callback?: SubscriptionCallback): EdenFSSubscription;
b69ab31299
b69ab31300 /**
b69ab31301 * Enter a specific state
b69ab31302 */
b69ab31303 enterState(state: string, options?: EnterStateOptions): Promise<void>;
b69ab31304}
b69ab31305
b69ab31306/**
b69ab31307 * EdenFS Subscription
b69ab31308 * Handles real-time filesystem change notifications
b69ab31309 */
b69ab31310export class EdenFSSubscription extends EventEmitter {
b69ab31311 client: EdenFSNotificationsClient;
b69ab31312 options: SubscriptionOptions;
b69ab31313 process: any;
b69ab31314 edenBinaryPath: string;
b69ab31315 errData: string;
b69ab31316 killTimeout: NodeJS.Timeout | null;
b69ab31317
b69ab31318 constructor(client: EdenFSNotificationsClient, options?: SubscriptionOptions);
b69ab31319
b69ab31320 /**
b69ab31321 * Start the subscription
b69ab31322 */
b69ab31323 start(): Promise<void>;
b69ab31324
b69ab31325 /**
b69ab31326 * Stop the subscription
b69ab31327 */
b69ab31328 stop(): void;
b69ab31329
b69ab31330 // EventEmitter events
b69ab31331 on(event: 'change', listener: (event: SubscriptionEvent) => void): this;
b69ab31332 on(event: 'error', listener: (error: Error) => void): this;
b69ab31333 on(event: 'close', listener: () => void): this;
b69ab31334
b69ab31335 once(event: 'change', listener: (event: SubscriptionEvent) => void): this;
b69ab31336 once(event: 'error', listener: (error: Error) => void): this;
b69ab31337 once(event: 'close', listener: () => void): this;
b69ab31338
b69ab31339 emit(event: 'change', data: SubscriptionEvent): boolean;
b69ab31340 emit(event: 'error', error: Error): boolean;
b69ab31341 emit(event: 'close'): boolean;
b69ab31342}
b69ab31343
b69ab31344/**
b69ab31345 * Utility functions for working with EdenFS notify data
b69ab31346 */
b69ab31347export class EdenFSUtils {
b69ab31348 /**
b69ab31349 * Convert byte array path to string
b69ab31350 */
b69ab31351 static bytesToPath(pathBytes: number[]): string;
b69ab31352
b69ab31353 /**
b69ab31354 * Convert byte array to hex string
b69ab31355 */
b69ab31356 static bytesToHex(bytes: number[]): string;
b69ab31357
b69ab31358 /**
b69ab31359 * Extract file type from change
b69ab31360 */
b69ab31361 static extractFileType(smallChange: SmallChange): string;
b69ab31362
b69ab31363 /**
b69ab31364 * Extract file path(s) from single change
b69ab31365 */
b69ab31366 static extractPath(changes: SmallChange): string[];
b69ab31367
b69ab31368 /**
b69ab31369 * Extract file paths from changes
b69ab31370 */
b69ab31371 static extractPaths(changes: Change[]): string[];
b69ab31372
b69ab31373 /**
b69ab31374 * Get change type from a change object
b69ab31375 */
b69ab31376 static getChangeType(
b69ab31377 change: Change,
b69ab31378 ):
b69ab31379 | 'added'
b69ab31380 | 'modified'
b69ab31381 | 'removed'
b69ab31382 | 'renamed'
b69ab31383 | 'replaced'
b69ab31384 | 'directory renamed'
b69ab31385 | 'commit transition'
b69ab31386 | 'lost changes'
b69ab31387 | 'state entered'
b69ab31388 | 'state left'
b69ab31389 | 'unknown';
b69ab31390}
b69ab31391
b69ab31392declare const exports: {
b69ab31393 EdenFSNotificationsClient: typeof EdenFSNotificationsClient;
b69ab31394 EdenFSSubscription: typeof EdenFSSubscription;
b69ab31395 EdenFSUtils: typeof EdenFSUtils;
b69ab31396};
b69ab31397
b69ab31398export default exports;
b69ab31399
b69ab31400export type Options = {
b69ab31401 mountPoint?: string;
b69ab31402 timeout?: number;
b69ab31403 edenBinaryPath?: string;
b69ab31404};
b69ab31405
b69ab31406export type CommandCallback = (error?: Error, result?: Response) => void;