From 98c461b79d606d3256e12cff768ad0ace887689c Mon Sep 17 00:00:00 2001 From: Coal Cooper Date: Sat, 13 Jan 2024 09:08:34 -0500 Subject: [PATCH] add $api import shortcut, add generated services to src/lib/api --- src/lib/api/endpoints.ts | 791 +++++++++++++++++++++++++++++++++++++++ src/lib/api/index.ts | 2 + src/lib/api/models.ts | 94 +++++ tsconfig.json | 1 + vite.config.js | 1 + 5 files changed, 889 insertions(+) create mode 100644 src/lib/api/endpoints.ts create mode 100644 src/lib/api/index.ts create mode 100644 src/lib/api/models.ts diff --git a/src/lib/api/endpoints.ts b/src/lib/api/endpoints.ts new file mode 100644 index 0000000..6a2c553 --- /dev/null +++ b/src/lib/api/endpoints.ts @@ -0,0 +1,791 @@ +import { + Book, + Facility, + Note, + PackageContent, + Recipient, + Shipment, + SpecialRequest, + Zine, +} from './models' + +type Fetch = (input: URL | RequestInfo, init?: RequestInit) => Promise + +export const BASE_URL = 'http://localhost:8080' + +function resolveURL( + url: URL, + { query, path }: { query?: { [index: string]: any }; path?: { [index: string]: any } }, +): string { + let resolvedURL = url.toString() + + if (path) { + for (const [key, value] of Object.entries(path)) { + const variablePattern = new RegExp(`{s*${key}s*}`, 'g') + resolvedURL = resolvedURL.replace(variablePattern, value) + } + } + + if (query) { + const searchParams = new URLSearchParams(query) + const queryString = searchParams.toString() + + if (queryString) { + resolvedURL += resolvedURL.includes('?') ? `&${queryString}` : `?${queryString}` + } + } + + return resolvedURL +} + +export async function updateShipment(fetch: Fetch, body: Shipment): Promise { + const url = new URL('/updateShipment', BASE_URL).toString() + const options: RequestInit = { + method: 'put', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Shipment + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function updateRecipient( + fetch: Fetch, + body: Recipient, +): Promise { + const url = new URL('/updateRecipient', BASE_URL).toString() + const options: RequestInit = { + method: 'put', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Recipient + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function updateFacility(fetch: Fetch, body: Facility): Promise { + const url = new URL('/updateFacility', BASE_URL).toString() + const options: RequestInit = { + method: 'put', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Facility + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function updateContent( + fetch: Fetch, + body: Book | Zine, +): Promise { + const url = new URL('/updateContent', BASE_URL).toString() + const options: RequestInit = { + method: 'put', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book | Zine + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function addSpecialRequest( + fetch: Fetch, + body: SpecialRequest, +): Promise { + const url = new URL('/addSpecialRequest', BASE_URL).toString() + const options: RequestInit = { + method: 'post', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as SpecialRequest + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function addShipment(fetch: Fetch, body: Shipment): Promise { + const url = new URL('/addShipment', BASE_URL).toString() + const options: RequestInit = { + method: 'post', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Shipment + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function addRecipient(fetch: Fetch, body: Recipient): Promise { + const url = new URL('/addRecipient', BASE_URL).toString() + const options: RequestInit = { + method: 'post', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Recipient + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function addNote(fetch: Fetch, body: Note): Promise { + const url = new URL('/addNote', BASE_URL).toString() + const options: RequestInit = { + method: 'post', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Note + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function addFacility(fetch: Fetch, body: Facility): Promise { + const url = new URL('/addFacility', BASE_URL).toString() + const options: RequestInit = { + method: 'post', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Facility + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function addContent( + fetch: Fetch, + body: Book | Zine, +): Promise { + const url = new URL('/addContent', BASE_URL).toString() + const options: RequestInit = { + method: 'post', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body), + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book | Zine + } catch (error) { + console.error( + `received error while fetching url("${url}") with data(${JSON.stringify(body)})`, + error, + ) + return undefined + } +} + +export async function searchBooksByTitleAndAuthor( + fetch: Fetch, + query: { title: string; author?: string }, +): Promise { + const url = resolveURL(new URL('/searchBooks', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function queryGoogleByTitleAndAuthor( + fetch: Fetch, + query: { title: string; author?: string }, +): Promise { + const url = resolveURL(new URL('/queryGoogle', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getZineByCode( + fetch: Fetch, + query: { code: string }, +): Promise { + const url = resolveURL(new URL('/getZineByCode', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Zine + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getShipmentsByDate( + fetch: Fetch, + query: { date: string }, +): Promise { + const url = resolveURL(new URL('/getShipmentsByDate', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Shipment[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getShipment( + fetch: Fetch, + query: { id: number }, +): Promise { + const url = resolveURL(new URL('/getShipment', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Shipment + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getShipmentCountBetweenDates( + fetch: Fetch, + query: { date1: string; date2: string }, +): Promise { + const url = resolveURL(new URL('/getShipmentCountBetweenDates', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as number + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getRecipients( + fetch: Fetch, + query: { firstName: string; lastName: string }, +): Promise { + const url = resolveURL(new URL('/getRecipients', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Recipient[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getRecipient( + fetch: Fetch, + query: { id: number }, +): Promise { + const url = resolveURL(new URL('/getRecipient', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Recipient + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getRecipientLocation( + fetch: Fetch, + query: { id: string }, +): Promise { + const url = resolveURL(new URL('/getRecipientLocation', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as string + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getRecipientByAssignedId( + fetch: Fetch, + query: { assignedId: string }, +): Promise { + const url = resolveURL(new URL('/getRecipientByAssignedId', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Recipient + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getBooksWithNoIsbn(fetch: Fetch): Promise { + const url = new URL('/getNoIsbnBooks', BASE_URL).toString() + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getFacilityById( + fetch: Fetch, + query: { id: number }, +): Promise { + const url = resolveURL(new URL('/getFacility', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Facility + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getFacilityByNameAndState( + fetch: Fetch, + query: { name: string; state: 'NC' | 'AL' | 'TN' | 'WV' | 'KY' | 'MD' | 'VA' | 'DE' }, +): Promise { + const url = resolveURL(new URL('/getFacilityByName', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Facility[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getContent( + fetch: Fetch, + query: { id: number }, +): Promise { + const url = resolveURL(new URL('/getContent', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book | Zine + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getContentByTitle( + fetch: Fetch, + query: { title: string }, +): Promise { + const url = resolveURL(new URL('/getContentByTitle', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book[] | Zine[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getBookByISBN( + fetch: Fetch, + query: { isbn: string }, +): Promise { + const url = resolveURL(new URL('/getBookByISBN', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getAllZines(fetch: Fetch): Promise { + const url = new URL('/getAllZines', BASE_URL).toString() + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Zine[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getAllSpecialRequests(fetch: Fetch): Promise { + const url = new URL('/getAllSpecialRequests', BASE_URL).toString() + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as SpecialRequest[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getAllShipmentsByRecipient( + fetch: Fetch, + query: { id: number }, +): Promise { + const url = resolveURL(new URL('/getAllShipmentsByRecipient', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Shipment[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getAllRecipients(fetch: Fetch): Promise { + const url = new URL('/getAllRecipients', BASE_URL).toString() + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Recipient[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getAllFacilities(fetch: Fetch): Promise { + const url = new URL('/getAllFacilities', BASE_URL).toString() + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Facility[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getAllContent(fetch: Fetch): Promise { + const url = new URL('/getAllContent', BASE_URL).toString() + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book[] | Zine[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function getContentByTitleAndAuthor( + fetch: Fetch, + query: { title: string; author?: string }, +): Promise { + const url = resolveURL(new URL('/content', BASE_URL), { query }) + const options: RequestInit = { + method: 'get', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return (await response.json()) as Book[] | Zine[] + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function deleteShipment(fetch: Fetch, query: { id: number }): Promise { + const url = resolveURL(new URL('/deleteShipment', BASE_URL), { query }) + const options: RequestInit = { + method: 'delete', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function deleteRecipient(fetch: Fetch, query: { id: number }): Promise { + const url = resolveURL(new URL('/deleteRecipient', BASE_URL), { query }) + const options: RequestInit = { + method: 'delete', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function deleteFacility(fetch: Fetch, query: { id: number }): Promise { + const url = resolveURL(new URL('/deleteFacility', BASE_URL), { query }) + const options: RequestInit = { + method: 'delete', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function deleteContent(fetch: Fetch, query: { id: number }): Promise { + const url = resolveURL(new URL('/deleteContent', BASE_URL), { query }) + const options: RequestInit = { + method: 'delete', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} + +export async function deleteShipmentsByRecipient( + fetch: Fetch, + query: { id: number }, +): Promise { + const url = resolveURL(new URL('/deleteAllShipmentsByRecipientId', BASE_URL), { query }) + const options: RequestInit = { + method: 'delete', + headers: { 'Content-Type': 'application/json' }, + } + + try { + const response = await fetch(url, options) + if (!response.ok) throw new Error(`Request failed with status: ${response.status}`) + return + } catch (error) { + console.error(`received error while fetching url: ${url}`, error) + return undefined + } +} diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts new file mode 100644 index 0000000..89d7090 --- /dev/null +++ b/src/lib/api/index.ts @@ -0,0 +1,2 @@ +export * from './models' +export * from './endpoints' diff --git a/src/lib/api/models.ts b/src/lib/api/models.ts new file mode 100644 index 0000000..6847208 --- /dev/null +++ b/src/lib/api/models.ts @@ -0,0 +1,94 @@ +export type WithRequired = T & { [P in K]-?: T[P] } + +export type Book = WithRequired< + { + type: 'Book' + } & Omit & { + authors?: string + isbn10?: string + isbn13?: string + }, + 'title' +> + +export type Facility = { + /** Format: int64 */ + id?: number + name: string + additionalInfo?: string + street: string + city: string + /** @enum {string} */ + state: 'NC' | 'AL' | 'TN' | 'WV' | 'KY' | 'MD' | 'VA' | 'DE' + zip: string +} + +export type Note = { + /** Format: int64 */ + id?: number + content?: string + /** Format: date */ + date?: string +} + +export type PackageContent = { + /** Format: int64 */ + id?: number + title: string + type: string +} + +export type Recipient = { + /** Format: int64 */ + id?: number + firstName: string + middleName?: string + lastName: string + assignedId?: string + facility?: Facility + shipments?: Shipment[] + specialRequests?: SpecialRequest[] +} + +export type Shipment = { + /** Format: int64 */ + id?: number + /** Format: date */ + date?: string + facility?: Facility + recipient?: Recipient + notes?: Note[] + content?: (Book | Zine)[] +} + +export type SpecialRequest = { + /** Format: int64 */ + id?: number + volunteerName?: string + request?: string + /** Format: date */ + specialRequestDate?: string + /** Format: date */ + letterMailedDate?: string + /** @enum {string} */ + category?: + | 'VOCATIONAL' + | 'EDUCATIONAL' + | 'CAREER_GROWTH' + | 'FOREIGN_LANGUAGE' + | 'LEGAL' + | 'SPIRITUAL_RELIGIOUS' + | 'OTHER' + /** @enum {string} */ + status?: 'OPEN' | 'COMPLETED' | 'CANCELLED' + recipient?: Recipient +} + +export type Zine = WithRequired< + { + type: 'Zine' + } & Omit & { + code?: string + }, + 'code' | 'title' +> diff --git a/tsconfig.json b/tsconfig.json index 9f0a046..13772b0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,7 @@ "strictNullChecks": false, "paths": { + "$api/*": ["./src/lib/api/*"], "$assets/*": ["./src/lib/assets/*"], "$components/*": ["./src/lib/components/*"], "$models/*": ["./src/lib/models/*"], diff --git a/vite.config.js b/vite.config.js index 217a092..464d685 100644 --- a/vite.config.js +++ b/vite.config.js @@ -6,6 +6,7 @@ export default defineConfig({ plugins: [sveltekit()], resolve: { alias: { + $api: resolve('./src/lib/api'), $assets: resolve('./src/lib/assets'), $components: resolve('./src/lib/components'), $models: resolve('./src/lib/models'),