Skip to content

Commit

Permalink
pocketbase 0.24.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kluvin committed Jan 8, 2025
1 parent 86a0da0 commit b2228c8
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 4 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ db:

pb_types:
@echo Reading schema from $(PUBLIC_PB_HOST)
@npx --yes pocketbase-typegen@1.2.1 --url $(PUBLIC_PB_HOST) --email $(PB_ADMIN_EMAIL) --password $(PB_ADMIN_PASSWORD) --out ./src/lib/pocketbase/index.d.ts
@npx --yes pocketbase-typegen@1.3.0 --url $(PUBLIC_PB_HOST) --email $(PB_ADMIN_EMAIL) --password $(PB_ADMIN_PASSWORD) --out ./src/lib/pocketbase/index.d.ts
2 changes: 1 addition & 1 deletion pocketbase/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:latest

ARG PB_VERSION=0.22.21
ARG PB_VERSION=0.24.1

RUN apk add --no-cache \
unzip \
Expand Down
103 changes: 101 additions & 2 deletions src/lib/pocketbase/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import type PocketBase from 'pocketbase'
import type { RecordService } from 'pocketbase'

export enum Collections {
Authorigins = "_authOrigins",
Externalauths = "_externalAuths",
Mfas = "_mfas",
Otps = "_otps",
Superusers = "_superusers",
ActiveMessage = "activeMessage",
Categories = "categories",
DisplayMessages = "displayMessages",
Expand All @@ -23,8 +28,6 @@ export type HTMLString = string
// System fields
export type BaseSystemFields<T = never> = {
id: RecordIdString
created: IsoDateString
updated: IsoDateString
collectionId: string
collectionName: Collections
expand?: T
Expand All @@ -39,26 +42,87 @@ export type AuthSystemFields<T = never> = {

// Record types for each collection

export type AuthoriginsRecord = {
collectionRef: string
created?: IsoDateString
fingerprint: string
id: string
recordRef: string
updated?: IsoDateString
}

export type ExternalauthsRecord = {
collectionRef: string
created?: IsoDateString
id: string
provider: string
providerId: string
recordRef: string
updated?: IsoDateString
}

export type MfasRecord = {
collectionRef: string
created?: IsoDateString
id: string
method: string
recordRef: string
updated?: IsoDateString
}

export type OtpsRecord = {
collectionRef: string
created?: IsoDateString
id: string
password: string
recordRef: string
sentTo?: string
updated?: IsoDateString
}

export type SuperusersRecord = {
created?: IsoDateString
email: string
emailVisibility?: boolean
id: string
password: string
tokenKey: string
updated?: IsoDateString
verified?: boolean
}

export type ActiveMessageRecord = {
created?: IsoDateString
id: string
isVisible?: boolean
message?: RecordIdString
updated?: IsoDateString
}

export type CategoriesRecord = {
created?: IsoDateString
id: string
name: string
sort_order: number
updated?: IsoDateString
}

export type DisplayMessagesRecord = {
created?: IsoDateString
id: string
subtext?: string
title?: string
updated?: IsoDateString
}

export type DrinksRecord = {
category: RecordIdString
created?: IsoDateString
id: string
image: string
name: string
price: number
updated?: IsoDateString
}

export enum OrderDrinkServingSizeOptions {
Expand Down Expand Up @@ -89,11 +153,14 @@ export enum OrderDrinkFlavorOptions {
"spicy" = "spicy",
}
export type OrderDrinkRecord = {
created?: IsoDateString
drink: RecordIdString
extras?: OrderDrinkExtrasOptions[]
flavor?: OrderDrinkFlavorOptions[]
id: string
milk?: OrderDrinkMilkOptions
serving_size?: OrderDrinkServingSizeOptions
updated?: IsoDateString
}

export enum OrdersStateOptions {
Expand All @@ -103,21 +170,38 @@ export enum OrdersStateOptions {
"dispatched" = "dispatched",
}
export type OrdersRecord = {
created?: IsoDateString
customer?: RecordIdString
drinks: RecordIdString[]
id: string
payment_fulfilled?: boolean
state?: OrdersStateOptions
updated?: IsoDateString
}

export type UsersRecord = {
avatar?: string
created?: IsoDateString
email?: string
emailVisibility?: boolean
favorites?: RecordIdString[]
id: string
is_admin?: boolean
name?: string
password: string
purchased_cup?: boolean
tokenKey: string
updated?: IsoDateString
username: string
verified?: boolean
}

// Response types include system fields and match responses from the PocketBase API
export type AuthoriginsResponse<Texpand = unknown> = Required<AuthoriginsRecord> & BaseSystemFields<Texpand>
export type ExternalauthsResponse<Texpand = unknown> = Required<ExternalauthsRecord> & BaseSystemFields<Texpand>
export type MfasResponse<Texpand = unknown> = Required<MfasRecord> & BaseSystemFields<Texpand>
export type OtpsResponse<Texpand = unknown> = Required<OtpsRecord> & BaseSystemFields<Texpand>
export type SuperusersResponse<Texpand = unknown> = Required<SuperusersRecord> & AuthSystemFields<Texpand>
export type ActiveMessageResponse<Texpand = unknown> = Required<ActiveMessageRecord> & BaseSystemFields<Texpand>
export type CategoriesResponse<Texpand = unknown> = Required<CategoriesRecord> & BaseSystemFields<Texpand>
export type DisplayMessagesResponse<Texpand = unknown> = Required<DisplayMessagesRecord> & BaseSystemFields<Texpand>
Expand All @@ -129,6 +213,11 @@ export type UsersResponse<Texpand = unknown> = Required<UsersRecord> & AuthSyste
// 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
activeMessage: ActiveMessageRecord
categories: CategoriesRecord
displayMessages: DisplayMessagesRecord
Expand All @@ -139,6 +228,11 @@ export type CollectionRecords = {
}

export type CollectionResponses = {
_authOrigins: AuthoriginsResponse
_externalAuths: ExternalauthsResponse
_mfas: MfasResponse
_otps: OtpsResponse
_superusers: SuperusersResponse
activeMessage: ActiveMessageResponse
categories: CategoriesResponse
displayMessages: DisplayMessagesResponse
Expand All @@ -152,6 +246,11 @@ export type CollectionResponses = {
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions

export type TypedPocketBase = PocketBase & {
collection(idOrName: '_authOrigins'): RecordService<AuthoriginsResponse>
collection(idOrName: '_externalAuths'): RecordService<ExternalauthsResponse>
collection(idOrName: '_mfas'): RecordService<MfasResponse>
collection(idOrName: '_otps'): RecordService<OtpsResponse>
collection(idOrName: '_superusers'): RecordService<SuperusersResponse>
collection(idOrName: 'activeMessage'): RecordService<ActiveMessageResponse>
collection(idOrName: 'categories'): RecordService<CategoriesResponse>
collection(idOrName: 'displayMessages'): RecordService<DisplayMessagesResponse>
Expand Down

0 comments on commit b2228c8

Please sign in to comment.