/**
* This file was @generated using pocketbase-typegen
*/

import type PocketBase from 'pocketbase'
import type { RecordService } from 'pocketbase'

export enum Collections {
	Albums = "albums",
	Channels = "channels",
	Messages = "messages",
	Pages = "pages",
	Photos = "photos",
	Users = "users",
}

// Alias types for improved usability
export type IsoDateString = string
export type RecordIdString = string
export type HTMLString = string

// System fields
export type BaseSystemFields<T = never> = {
	id: RecordIdString
	created: IsoDateString
	updated: IsoDateString
	collectionId: string
	collectionName: Collections
	expand?: T
}

export type AuthSystemFields<T = never> = {
	email: string
	emailVisibility: boolean
	username: string
	verified: boolean
} & BaseSystemFields<T>

// Record types for each collection

export type AlbumsRecord = {
	description?: string
	pictures?: RecordIdString[]
	title?: string
}

export type ChannelsRecord = {
	creator?: RecordIdString
	name?: string
}

export type MessagesRecord = {
	attachment?: string
	author?: RecordIdString
	channel?: RecordIdString
	content?: string
}

export type PagesRecord<Tcontent = unknown> = {
	content?: null | Tcontent
	slug?: string
	title?: string
}

export type PhotosRecord = {
	alt?: string
	description?: string
	image?: string
	title?: string
}

export type UsersRecord = {
	avatar?: string
	firstname?: string
	lastname?: string
}

// Response types include system fields and match responses from the PocketBase API
export type AlbumsResponse<Texpand = unknown> = Required<AlbumsRecord> & BaseSystemFields<Texpand>
export type ChannelsResponse<Texpand = unknown> = Required<ChannelsRecord> & BaseSystemFields<Texpand>
export type MessagesResponse<Texpand = unknown> = Required<MessagesRecord> & BaseSystemFields<Texpand>
export type PagesResponse<Tcontent = unknown, Texpand = unknown> = Required<PagesRecord<Tcontent>> & BaseSystemFields<Texpand>
export type PhotosResponse<Texpand = unknown> = Required<PhotosRecord> & BaseSystemFields<Texpand>
export type UsersResponse<Texpand = unknown> = Required<UsersRecord> & AuthSystemFields<Texpand>

// Types containing all Records and Responses, useful for creating typing helper functions

export type CollectionRecords = {
	albums: AlbumsRecord
	channels: ChannelsRecord
	messages: MessagesRecord
	pages: PagesRecord
	photos: PhotosRecord
	users: UsersRecord
}

export type CollectionResponses = {
	albums: AlbumsResponse
	channels: ChannelsResponse
	messages: MessagesResponse
	pages: PagesResponse
	photos: PhotosResponse
	users: UsersResponse
}

// Type for usage with type asserted PocketBase instance
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions

export type TypedPocketBase = PocketBase & {
	collection(idOrName: 'albums'): RecordService<AlbumsResponse>
	collection(idOrName: 'channels'): RecordService<ChannelsResponse>
	collection(idOrName: 'messages'): RecordService<MessagesResponse>
	collection(idOrName: 'pages'): RecordService<PagesResponse>
	collection(idOrName: 'photos'): RecordService<PhotosResponse>
	collection(idOrName: 'users'): RecordService<UsersResponse>
}
