/** * This file was @generated using pocketbase-typegen */ import type PocketBase from 'pocketbase' import type { RecordService } from 'pocketbase' export enum Collections { Authorigins = "_authOrigins", Externalauths = "_externalAuths", Mfas = "_mfas", Otps = "_otps", Superusers = "_superusers", Base = "base", CustomAuth = "custom_auth", Everything = "everything", MyView = "my_view", Posts = "posts", Users = "users", } // Alias types for improved usability export type IsoDateString = string export type IsoAutoDateString = string & { readonly autodate: unique symbol } export type RecordIdString = string export type FileNameString = string & { readonly filename: unique symbol } export type HTMLString = string export type GeoPoint = { lon: number lat: number } type ExpandType = unknown extends T ? T extends unknown ? { expand?: unknown } : { expand: T } : { expand: T } // System fields export type BaseSystemFields = { id: RecordIdString collectionId: string collectionName: Collections } & ExpandType export type AuthSystemFields = { email: string emailVisibility: boolean username: string verified: boolean } & BaseSystemFields // Record types for each collection export type AuthoriginsRecord = { collectionRef: string created: IsoAutoDateString fingerprint: string id: string recordRef: string updated: IsoAutoDateString } export type ExternalauthsRecord = { collectionRef: string created: IsoAutoDateString id: string provider: string providerId: string recordRef: string updated: IsoAutoDateString } export type MfasRecord = { collectionRef: string created: IsoAutoDateString id: string method: string recordRef: string updated: IsoAutoDateString } export type OtpsRecord = { collectionRef: string created: IsoAutoDateString id: string password: string recordRef: string sentTo?: string updated: IsoAutoDateString } export type SuperusersRecord = { created: IsoAutoDateString email: string emailVisibility?: boolean id: string password: string tokenKey: string updated: IsoAutoDateString verified?: boolean } export type BaseRecord = { created: IsoAutoDateString field?: string id: string updated: IsoAutoDateString } export type CustomAuthRecord = { created: IsoAutoDateString custom_field?: string email: string emailVisibility?: boolean id: string password: string tokenKey: string updated: IsoAutoDateString verified?: boolean } export enum EverythingSelectFieldOptions { "optionA" = "optionA", "OptionA" = "OptionA", "optionB" = "optionB", "optionC" = "optionC", "option with space" = "option with space", "sy?mb@!$" = "sy?mb@!$", } export type EverythingRecord = { another_json_field?: null | Tanother_json_field bool_field?: boolean created: IsoAutoDateString custom_relation_field?: RecordIdString[] date_field?: IsoDateString email_field?: string file_field?: FileNameString geopoint_field?: GeoPoint id: string json_field?: null | Tjson_field number_field?: number post_relation_field?: RecordIdString rich_editor_field?: HTMLString select_field?: EverythingSelectFieldOptions select_field_no_values?: string text_field?: string three_files_field?: FileNameString[] updated?: IsoAutoDateString url_field?: string user_relation_field?: RecordIdString } export type MyViewRecord = { id: string json_field?: null | Tjson_field post_relation_field?: RecordIdString text_field?: string } export type PostsRecord = { created: IsoAutoDateString field1?: number id: string nonempty_bool: boolean nonempty_field: string updated?: IsoAutoDateString } export type UsersRecord = { avatar?: FileNameString created: IsoAutoDateString email: string emailVisibility?: boolean id: string name?: string password: string tokenKey: string updated: IsoAutoDateString verified?: boolean } // Response types include system fields and match responses from the PocketBase API export type AuthoriginsResponse = Required & BaseSystemFields export type ExternalauthsResponse = Required & BaseSystemFields export type MfasResponse = Required & BaseSystemFields export type OtpsResponse = Required & BaseSystemFields export type SuperusersResponse = Required & AuthSystemFields export type BaseResponse = Required & BaseSystemFields export type CustomAuthResponse = Required & AuthSystemFields export type EverythingResponse = Required> & BaseSystemFields export type MyViewResponse = Required> & BaseSystemFields export type PostsResponse = Required & BaseSystemFields export type UsersResponse = Required & AuthSystemFields // Types containing all Records and Responses, useful for creating typing helper functions export type CollectionRecords = { _authOrigins: AuthoriginsRecord _externalAuths: ExternalauthsRecord _mfas: MfasRecord _otps: OtpsRecord _superusers: SuperusersRecord base: BaseRecord custom_auth: CustomAuthRecord everything: EverythingRecord my_view: MyViewRecord posts: PostsRecord users: UsersRecord } export type CollectionResponses = { _authOrigins: AuthoriginsResponse _externalAuths: ExternalauthsResponse _mfas: MfasResponse _otps: OtpsResponse _superusers: SuperusersResponse base: BaseResponse custom_auth: CustomAuthResponse everything: EverythingResponse my_view: MyViewResponse posts: PostsResponse users: UsersResponse } // Utility types for create/update operations type ProcessCreateAndUpdateFields = Omit<{ // Omit AutoDate fields [K in keyof T as Extract extends never ? K : never]: // Convert FileNameString to File T[K] extends infer U ? U extends (FileNameString | FileNameString[]) ? U extends any[] ? File[] : File : U : never }, 'id'> // Create type for Auth collections export type CreateAuth = { id?: RecordIdString email: string emailVisibility?: boolean password: string passwordConfirm: string verified?: boolean } & ProcessCreateAndUpdateFields // Create type for Base collections export type CreateBase = { id?: RecordIdString } & ProcessCreateAndUpdateFields // Update type for Auth collections export type UpdateAuth = Partial< Omit, keyof AuthSystemFields> > & { email?: string emailVisibility?: boolean oldPassword?: string password?: string passwordConfirm?: string verified?: boolean } // Update type for Base collections export type UpdateBase = Partial< Omit, keyof BaseSystemFields> > // Get the correct create type for any collection export type Create = CollectionResponses[T] extends AuthSystemFields ? CreateAuth : CreateBase // Get the correct update type for any collection export type Update = CollectionResponses[T] extends AuthSystemFields ? UpdateAuth : UpdateBase // Type for usage with type asserted PocketBase instance // https://github.com/pocketbase/js-sdk#specify-typescript-definitions export type TypedPocketBase = { collection( idOrName: T ): RecordService } & PocketBase