FEAT-2: typed CRUD API clients for enclosures + contacts

This commit is contained in:
2026-06-06 00:07:01 +02:00
parent 12e787671c
commit a1d02c0d4e
2 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/** Typed API functions for the Kontakte (Contact) resource. (FEAT-2) */
import { api, resources } from './client'
import { toQueryString, type GridifyQuery } from './gridify'
import type { Contact, Paged } from './types'
/** Payload for POST /contacts. */
export interface CreateContact {
name: string
contactInfo?: string | null
notes?: string | null
}
/** Payload for PUT /contacts/{id}. */
export type UpdateContact = Partial<CreateContact>
export function listContactsPaged(query: GridifyQuery): Promise<Paged<Contact>> {
return api.get<Paged<Contact>>(`${resources.contacts}${toQueryString(query)}`)
}
export function getContact(id: string): Promise<Contact> {
return api.get<Contact>(`${resources.contacts}/${id}`)
}
export function createContact(body: CreateContact): Promise<Contact> {
return api.post<Contact>(resources.contacts, body)
}
export function updateContact(id: string, body: UpdateContact): Promise<Contact> {
return api.put<Contact>(`${resources.contacts}/${id}`, body)
}
export function deleteContact(id: string): Promise<void> {
return api.delete(`${resources.contacts}/${id}`)
}

View File

@@ -0,0 +1,33 @@
/** Typed API functions for the Becken (Enclosure) resource. (FEAT-2) */
import { api, resources } from './client'
import { toQueryString, type GridifyQuery } from './gridify'
import type { Enclosure, Paged } from './types'
/** Payload for POST /enclosures. */
export interface CreateEnclosure {
name: string
notes?: string | null
}
/** Payload for PUT /enclosures/{id}. */
export type UpdateEnclosure = Partial<CreateEnclosure>
export function listEnclosuresPaged(query: GridifyQuery): Promise<Paged<Enclosure>> {
return api.get<Paged<Enclosure>>(`${resources.enclosures}${toQueryString(query)}`)
}
export function getEnclosure(id: string): Promise<Enclosure> {
return api.get<Enclosure>(`${resources.enclosures}/${id}`)
}
export function createEnclosure(body: CreateEnclosure): Promise<Enclosure> {
return api.post<Enclosure>(resources.enclosures, body)
}
export function updateEnclosure(id: string, body: UpdateEnclosure): Promise<Enclosure> {
return api.put<Enclosure>(`${resources.enclosures}/${id}`, body)
}
export function deleteEnclosure(id: string): Promise<void> {
return api.delete(`${resources.enclosures}/${id}`)
}