import * as pocketbase from 'pocketbase'; import pocketbase__default, { RecordSubscription, SendOptions, UnsubscribeFunc, ListResult, RecordService, RecordAuthResponse, OAuth2AuthConfig, RecordOptions, CommonOptions, SubBatchService, BatchRequestResult } from 'pocketbase'; type Prettify = T extends infer o ? { [K in keyof o]: o[K]; } : never; type MaybeArray = T | T[]; type MaybeMakeArray = T extends any[] ? Out[] : Out; type ArrayInnerType = T extends Array ? V : T; type Values = T[keyof T]; type Overide = Prettify & B>; type RemoveIndex = { [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K]; }; type LooseAutocomplete = T | (string & {}); type UnionToIntersection = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never; type BaseRecord = Record; type BaseSystemFields = { id: string; created: string; updated: string; }; type GenericCollection = { type: string; collectionId: string; collectionName: string; response: BaseRecord; create?: BaseRecord; update?: BaseRecord; relations: Record; }; type GenericSchema = { [K: string]: GenericCollection; }; type TypedRecord = Data & { expand: Expand; }; interface SystemFields { id: string; created: string; update: string; } type BaseCollectionRecords = Record; type Fields = keyof T['response']; type Columns = T['response']; type Expands = { [K in keyof T['relations']]?: T['relations'][K] extends GenericCollection[] ? TypedRecord>[] : T['relations'][K] extends GenericCollection ? TypedRecord> : never; }; type GenericExpand = Record | TypedRecord[]>; type JoinPath = Parts extends [ infer A extends string, ...infer Rest extends string[] ] ? Rest['length'] extends 0 ? A : `${A}.${JoinPath}` : never; type _RecordWithExpandToDotPath = { [K in keyof T['response'] as JoinPath<[ ...Path, K & string ]>]: T['response'][K]; } & (Path['length'] extends 4 ? {} : UnionToIntersection, [ ...Path, K & string ]>; }>>); type RecordWithExpandToDotPath = Prettify<_RecordWithExpandToDotPath>; type ReservedRecordNames = 'collectionId' | 'collectionName'; type Select = { [K in keyof Collection['response']]?: boolean; }; type SelectWithExpand = Select & { expand?: { [K in keyof Collection['relations']]?: SelectWithExpand> | boolean; }; }; type ResolveSelect | undefined> = Extract extends never ? TCollection['response'] : { [K in keyof TSelect & keyof TCollection['response'] as TSelect[K] extends true ? K : never]: TCollection['response'][K]; }; type ResolveSelectWithExpand | undefined> = Prettify & ('expand' extends keyof TSelect ? { expand?: { [Relation in keyof TSelect['expand'] & keyof TCollection['relations'] as TSelect['expand'][Relation] extends false ? never : Relation]?: TSelect['expand'][Relation] extends true ? MaybeMakeArray['response']> : TSelect['expand'][Relation] extends object ? MaybeMakeArray, TSelect['expand'][Relation]>> : never; }; } : {})>; type ActualFilter = [ K, FilterOperand, T[K] ]; type FilterOperand = '=' | '!=' | '>' | '>=' | '<' | '<=' | '~' | '!~' | '?=' | '?!=' | '?>' | '?>=' | '?<' | '?<=' | '?~' | '?!~'; type FilterParam = { __record__?: T; } & string; type Filter = ActualFilter | FilterParam | false | null | undefined; declare function and(...filters: Filter[]): FilterParam; declare function or(...filters: Filter[]): FilterParam; declare function eq(column: Key, value: T[Key]): FilterParam; declare function neq(column: Key, value: T[Key]): FilterParam; declare function gt(column: Key, value: T[Key]): FilterParam; declare function gte(column: Key, value: T[Key]): FilterParam; declare function lt(column: Key, value: T[Key]): FilterParam; declare function lte(column: Key, value: T[Key]): FilterParam; declare function like(column: Key, value: T[Key]): FilterParam; declare function nlike(column: Key, value: T[Key]): FilterParam; type Sort = `${'+' | '-'}${keyof T & string}` | false | null | undefined; declare const FORWARD_METHODS: readonly ["unsubscribe", "listAuthMethods", "requestPasswordReset", "confirmPasswordReset", "requestVerification", "confirmVerification", "requestEmailChange", "confirmEmailChange", "listExternalAuths", "unlinkExternalAuth", "requestOTP"]; interface ViewCollectionService> { collectionName: Collection['collectionName']; client: pocketbase__default; subscribe | undefined>(topic: string, callback: (data: RecordSubscription>) => void, options?: { select?: TSelect; } & SendOptions): Promise; getFullList | undefined>(options?: { select?: TSelect; page?: number; perPage?: number; sort?: MaybeArray>; filter?: Filter; } & SendOptions): Promise[]>; getList = {}>(page?: number, perPage?: number, options?: { select?: TSelect; sort?: MaybeArray>; filter?: Filter; } & SendOptions): Promise>>; getFirstListItem = {}>(filter: Filter, options?: { select?: TSelect; sort?: MaybeArray>; } & SendOptions): Promise>; getOne = {}>(id: string, options?: { select?: TSelect; } & SendOptions): Promise>; createFilter(filter: Filter): Filter; createSort(...sort: Sort[]): Sort; createSelect>(select: T): T; } interface BaseCollectionService extends ViewCollectionService { create = {}>(bodyParams: Collection['create'], options?: { select?: TSelect; } & SendOptions): Promise>; update = {}>(id: string, bodyParams: Collection['update'], options?: { select?: TSelect; } & SendOptions): Promise>; delete(id: string): Promise; } interface AuthCollectionService extends BaseCollectionService, Pick { /** * Authenticates a user with a password. * * @param usernameOrEmail the username or email of the user * @param password the password of the user * @param options optional settings for the request * * @returns a promise that resolves to the record's authentication response */ authWithPassword = {}>(usernameOrEmail: string, password: string, options?: { select?: TSelect; } & SendOptions): Promise>>; /** * Authenticates a user via OAuth2 authorization code flow. * * @param provider the OAuth2 provider name * @param code the authorization code * @param codeVerifier the code verifier * @param redirectUrl the redirect URL * @param createData optional data to create a new record with (if the user doesn't exist) * @param options optional settings for the request * * @returns a promise that resolves to the record's authentication response */ authWithOAuth2Code = {}>(provider: string, code: string, codeVerifier: string, redirectUrl: string, createData?: { [key: string]: any; }, options?: { select?: TSelect; } & SendOptions): Promise>>; /** * Authenticates a user using the OAuth2 flow. * * If the user is already authenticated, the request will be rejected. * * @param options settings for the request. * @param options.createData optional data to use when creating a new user. * @param options.select optional select clause for the response. * @param options... additional options to pass to the underlying method. * * @returns a promise that resolves with the authentication response */ authWithOAuth2(options: Omit & { createData?: Collection['create']; } & SendOptions): Promise>; /** * Authenticates a user using the refresh token. * * @param options Optional settings for the request. * @param options.select Optional select clause for the response. * @param options.select Optional select clause for the response. * @returns A promise that resolves to the authenticated user data. */ authRefresh = {}>(options?: { select?: TSelect; } & SendOptions): Promise>>; /** * Authenticates a user using the provided OTP id and password. * * Only works with `auth` collections. * * @param otpId the OTP id to use for the authentication * @param password the password to use for the authentication * @param options additional options to pass to the underlying method * * @returns a promise that resolves with the authentication response */ authWithOTP = {}>(otpId: string, password: string, options?: { select?: TSelect; } & SendOptions): Promise>>; } type TypedRecordServiceSchema = Omit, 'unsubscribe' | 'listAuthMethods' | 'requestPasswordReset' | 'confirmPasswordReset' | 'requestVerification' | 'confirmVerification' | 'requestEmailChange' | 'confirmEmailChange' | 'listExternalAuths' | 'unlinkExternalAuth' | 'requestOTP'>; declare class TypedRecordService implements TypedRecordServiceSchema { readonly service: RecordService; constructor(service: RecordService); get client(): pocketbase.default; get collectionName(): string; private prepareOptions; createFilter(filter: Filter>): string | null; createSort(...sorters: any[]): any; createSelect(select: any): any; subscribe(topic: string, callback: (data: RecordSubscription) => void, options?: SendOptions): Promise; getFullList(options?: SendOptions): Promise; getList(page?: number, perPage?: number, options?: SendOptions): Promise>; getFirstListItem(filter: string, options?: SendOptions): Promise; getOne(id: string, options?: { select?: any; } & SendOptions): Promise; create(bodyParams?: { [key: string]: any; } | FormData, options?: { select?: any; } & SendOptions): Promise; update(id: string, bodyParams?: FormData | { [key: string]: any; }, options?: { select?: any; } & SendOptions): Promise; delete(id: string, options?: SendOptions): Promise; authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions | undefined): Promise>; authWithOAuth2Code(provider: string, code: string, codeVerifier: string, redirectUrl: string, createData?: { [key: string]: any; } | undefined, options?: RecordOptions | undefined): Promise>; authWithOAuth2(options: OAuth2AuthConfig): Promise; authRefresh(options?: RecordOptions | undefined): Promise>; authWithOTP(otpId: string, password: string, options?: CommonOptions): Promise>; } declare class TypedBatch { private pb; private batch; /** * Creates a new instance of {@link TypedBatch}. * * @param pb The {@link TypedPocketBase} instance to use. */ constructor(pb: TypedPocketBase); /** * Returns a typed {@link TypedBatchCollection} instance for the given collection. * * @template CollectionName The name of the collection. * @param name The name of the collection. * @returns A typed {@link TypedBatchCollection} instance for the given collection. */ from(name: CollectionName): TypedBatchCollection; /** * Sends all the collected batch operations to the server. * * @param options optional settings for the request * * @returns a promise that resolves to an array of {@link BatchRequestResult} * with the results of all batch operations, in the same order as they were * added to the batch */ send(options?: SendOptions): Promise>; } declare class TypedBatchCollection { private batchService; constructor(batchService: SubBatchService); /** * Creates a new record in the batch service. * @param bodyParams The create data. * @param options Optional options to pass to the underlying `create` method. * @see https://pocketbase.io/docs/api-records/#create-record */ create(bodyParams: Collection['create'], options?: RecordOptions): void; /** * Creates multiple records in the batch service. * @param bodyParams The list of create data to create the records with. * @param options Optional options to pass to the underlying `create` method. * @see https://pocketbase.io/docs/api-records/#create-record */ createMany(bodyParams: Collection['create'][], options?: RecordOptions): void; /** * Queues an update operation for the given record. * * @param id The id of the record to update. * @param bodyParams The body parameters to update the record with. * @param options Additional options to pass to the underlying `update` method. */ update(id: string, bodyParams: Collection['update'], options?: RecordOptions): void; /** * Queues multiple update operations for the same record. * * @param id The id of the record to update. * @param bodyParams The array of body parameters to update the record with. * @param options Additional options to pass to the underlying `update` method. */ updateMany(id: string, bodyParams: Collection['update'][], options?: RecordOptions): void; /** * Queues a delete operation for the given record. * * @param bodyParams The body parameters with the `id` of the record to delete. * @param options Additional options to pass to the underlying `delete` method. */ delete(bodyParams: Partial & { id: string; }, options?: SendOptions): void; /** * Adds multiple delete requests to the batch for the provided `bodyParams`. * @param bodyParams The list of body parameters with the `id` property to delete. * @param options Optional settings for the request. * @returns a promise that resolves when the request is submitted */ deleteMany(bodyParams: Partial & { id: string; }[], options?: SendOptions): void; /** * Adds a delete request to the batch for the provided `id`. * * @param id the id of the record to delete * @param options optional settings for the request */ deleteById(id: string, options?: SendOptions): void; /** * Adds multiple delete requests to the batch for the provided `ids`. * * @param ids the ids of the records to delete * @param options optional settings for the request */ deleteManyById(ids: string[], options?: SendOptions): void; /** * Adds an upsert request to the batch for the provided `bodyParams`. * * @param bodyParams the data to upsert * @param options optional settings for the request * @returns a promise that resolves when the request is submitted */ upsert(bodyParams: Collection['update'], options?: RecordOptions): void; } declare class TypedPocketBase extends pocketbase__default { /** * Creates a typed {@link TypedRecordService} instance for the given collection. * * @template CollectionName The name of the collection. * @template Collection The collection type. Defaults to `Schema[CollectionName]`. * @param name The name of the collection. * @returns A typed {@link ViewCollectionService} instance if the collection is a view, * a typed {@link BaseCollectionService} instance if the collection is a base collection, * or a typed {@link AuthCollectionService} instance if the collection is an auth collection. */ from(name: CollectionName): Collection['type'] extends 'view' ? ViewCollectionService : Collection['type'] extends 'base' ? BaseCollectionService : AuthCollectionService; /** * Returns a new instance of {@link TypedBatch} to be used for batching record operations. * * @returns A new instance of {@link TypedBatch}. */ fromBatch(): TypedBatch; /** * Temporarily impersonates the provided record id as if it was the real authenticated user. * * Only works for `auth` collections. * * @param collectionName - The collection name of the collection. * @param recordId - The id of the record to impersonate. * @param duration - The amount of milliseconds to impersonate for. * @param options - Additional options to pass to the underlying `impersonate` method. * * @returns A promise that resolves to the impersonated client instance if the collection is an `auth` collection, or `never` otherwise. */ impersonate(collectionName: CollectionName, recordId: string, duration: number, options?: CommonOptions): Collection['type'] extends 'auth' ? Promise, 'impersonate'>> : Promise; } export { type ActualFilter, type ArrayInnerType, type AuthCollectionService, type BaseCollectionRecords, type BaseCollectionService, type BaseRecord, type BaseSystemFields, type Columns, type Expands, type Fields, type Filter, type FilterOperand, type FilterParam, type GenericCollection, type GenericExpand, type GenericSchema, type LooseAutocomplete, type MaybeArray, type MaybeMakeArray, type Overide, type Prettify, type RecordWithExpandToDotPath, type RemoveIndex, type ReservedRecordNames, type ResolveSelect, type ResolveSelectWithExpand, type Select, type SelectWithExpand, type Sort, type SystemFields, TypedPocketBase, type TypedRecord, TypedRecordService, type UnionToIntersection, type Values, type ViewCollectionService, and, eq, gt, gte, like, lt, lte, neq, nlike, or };