Skip to content

Commit

Permalink
add $api import shortcut, add generated services to src/lib/api
Browse files Browse the repository at this point in the history
  • Loading branch information
cocowmn committed Jan 13, 2024
1 parent 32a561f commit 88ffc59
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/api/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<<<<<<< HEAD
import type {
=======
import {
>>>>>>> b81fd30 (add $api import shortcut, add generated services to src/lib/api)
Book,
Facility,
Note,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './models'
export * from './endpoints'
94 changes: 94 additions & 0 deletions src/lib/api/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }

export type Book = WithRequired<
{
type: 'Book'
} & Omit<PackageContent, 'type'> & {
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<PackageContent, 'type'> & {
code?: string
},
'code' | 'title'
>
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"strictNullChecks": false,

"paths": {
"$api": ["./src/lib/api"],
"$assets/*": ["./src/lib/assets/*"],
"$components/*": ["./src/lib/components/*"],
"$models/*": ["./src/lib/models/*"],
Expand Down
1 change: 1 addition & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 88ffc59

Please sign in to comment.