import { GlideRecord } from "./GlideRecord.js"; /** * TypeScript definitions for ServiceNow GlideQuery */ /** * Represents a single record returned from a query */ interface GlideQueryRecord { [field: string]: any; } /** * Optional container that may or may not contain a value */ interface Optional { /** * Returns the value if present, otherwise returns the provided default value */ orElse(defaultValue: T): T; /** * Returns the value if present */ get(): T | undefined; /** * Returns true if a value is present */ isPresent(): boolean; /** * Executes the provided function if a value is present */ ifPresent(consumer: (value: T) => void): void; } /** * Stream interface for processing query results */ interface Stream { /** * Converts the stream to an array */ toArray(maxSize?: number): T[]; /** * Executes the provided function for each element */ forEach(callback: (item: T) => void): void; /** * Filters elements based on a predicate */ filter(predicate: (item: T) => boolean): Stream; /** * Maps elements to a new form */ map(mapper: (item: T) => R): Stream; /** * Reduces the stream to a single value */ reduce(accumulator: (acc: R, item: T) => R, initialValue: R): R; /** * Returns the first element as an Optional */ findFirst(): Optional; /** * Limits the stream to the specified number of elements */ limit(maxSize: number): Stream; /** * Returns true if any element matches the predicate */ anyMatch(predicate: (item: T) => boolean): boolean; /** * Returns true if all elements match the predicate */ allMatch(predicate: (item: T) => boolean): boolean; /** * Returns true if no elements match the predicate */ noneMatch(predicate: (item: T) => boolean): boolean; } /** * Valid comparison operators for where clauses */ type ComparisonOperator = '=' | '!=' | '>' | '>=' | '<' | '<='; /** * Valid array operators */ type ArrayOperator = 'IN' | 'NOT IN' | 'BETWEEN'; /** * Valid string operators */ type StringOperator = 'STARTSWITH' | 'ENDSWITH' | 'CONTAINS' | 'DOES NOT CONTAIN' | 'INSTANCEOF' | 'SAMEAS' | 'NSAMEAS' | 'GT_FIELD' | 'LT_FIELD' | 'GT_OR_EQUALS_FIELD' | 'LT_OR_EQUALS_FIELD' | 'DYNAMIC' | 'EMPTYSTRING' | 'ANYTHING' | 'LIKE' | 'NOT LIKE' | 'ON'; /** * All valid operators */ type WhereOperator = ComparisonOperator | ArrayOperator | StringOperator; /** * Valid aggregate function types */ type AggregateType = 'sum' | 'avg' | 'min' | 'max' | 'count'; /** * Field name with optional flag (e.g., 'company$DISPLAY') */ type FieldWithFlag = string; /** * Key-value object for record data */ interface KeyValues { [key: string]: any; } /** * Options for GlideQuery constructor */ interface GlideQueryOptions { scope?: string; } /** * Result of updateMultiple operation */ interface UpdateMultipleResult { rowCount: number; } export declare class GlideQuery { readonly table: T; readonly plan: any[]; readonly type: 'GlideQuery'; constructor(table: T, plan?: any[], options?: GlideQueryOptions); where(field: string, value: any): GlideQuery; where(field: string, operator: WhereOperator, value: any): GlideQuery; where(query: GlideQuery): GlideQuery; orWhere(field: string, value: any): GlideQuery; orWhere(field: string, operator: WhereOperator, value: any): GlideQuery; orWhere(query: GlideQuery): GlideQuery; whereNotNull(field: string): GlideQuery; orWhereNotNull(field: string): GlideQuery; whereNull(field: string): GlideQuery; orWhereNull(field: string): GlideQuery; getBy(keyValues: KeyValues, selectedFields?: string[]): Optional; get(key: string, selectFields?: string[]): Optional; select(...fields: FieldWithFlag[]): Stream; selectOne(...fields: FieldWithFlag[]): Optional; insert(keyValues: KeyValues, selectFields?: string[]): Optional; insertOrUpdate(changes: KeyValues, selectFields?: string[], reason?: string): Optional; update(changes: KeyValues, selectFields?: string[], reason?: string, prefetchedSchema?: any, planOverride?: any, insertWhenNotFound?: boolean): Optional; updateMultiple(changes: KeyValues): UpdateMultipleResult; deleteMultiple(): void; del(): void; disableWorkflow(): GlideQuery; disableAutoSysFields(): GlideQuery; forceUpdate(): GlideQuery; orderBy(field: string): GlideQuery; orderByDesc(field: string): GlideQuery; orderByDesc(aggregateType: AggregateType, field: string): GlideQuery; limit(limit: number): GlideQuery; withAcls(): GlideQuery; withSecurityDataFilters(): GlideQuery; avg(field: string): Optional; max(field: string): Optional; min(field: string): Optional; sum(field: string): Optional; count(): number; groupBy(...fields: string[]): GlideQuery; aggregate(aggregateType: AggregateType, field: string): GlideQuery; having(aggregateType: AggregateType, field: string, operator: ComparisonOperator, value: number): GlideQuery; toGlideRecord(): GlideRecord; toString(): string; static parse(table: string, encodedQuery: string): GlideQuery; } export {}; //# sourceMappingURL=GlideQuery.d.ts.map