/** * 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", Counters = "counters", FcmTokens = "fcm_tokens", Notifications = "notifications", 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 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 CountersRecord = { count?: number created: IsoAutoDateString id: string updated: IsoAutoDateString userId?: RecordIdString } export type FcmTokensRecord = { created: IsoAutoDateString id: string token?: string updated: IsoAutoDateString userId?: RecordIdString } export type NotificationsRecord = { body?: string created: IsoAutoDateString id: string isRead?: boolean title?: string updated: IsoAutoDateString userId?: RecordIdString } export enum UsersLanguageOptions { "de" = "de", "en" = "en", } export type UsersRecord = { avatar?: FileNameString created: IsoAutoDateString email: string emailVisibility?: boolean id: string language?: UsersLanguageOptions 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 CountersResponse = Required & BaseSystemFields export type FcmTokensResponse = Required & BaseSystemFields export type NotificationsResponse = 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 counters: CountersRecord fcm_tokens: FcmTokensRecord notifications: NotificationsRecord users: UsersRecord } export type CollectionResponses = { _authOrigins: AuthoriginsResponse _externalAuths: ExternalauthsResponse _mfas: MfasResponse _otps: OtpsResponse _superusers: SuperusersResponse counters: CountersResponse fcm_tokens: FcmTokensResponse notifications: NotificationsResponse 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