Skip to content

Commit 9ec3e08

Browse files
chore: wip
1 parent b596421 commit 9ec3e08

21 files changed

+116
-120
lines changed

storage/framework/.biomelintrc-auto-import.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,4 @@
349349
"whenever"
350350
]
351351
}
352-
}
352+
}

storage/framework/core/orm/src/utils.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export function getFillableAttributes(attributes: Attributes | undefined): strin
240240
.map((attribute) => snakeCase(attribute))
241241
}
242242

243-
export async function writeModelNames() {
243+
export async function writeModelNames(): Promise<void> {
244244
const models = globSync([path.userModelsPath('*.ts')], { absolute: true })
245245
let fileString = `export type ModelNames = `
246246

@@ -265,7 +265,7 @@ export async function writeModelNames() {
265265
}
266266
}
267267

268-
export async function writeModelRequest() {
268+
export async function writeModelRequest(): Promise<void> {
269269
const modelFiles = globSync([path.userModelsPath('*.ts')], { absolute: true })
270270
const requestD = Bun.file(path.frameworkPath('types/requests.d.ts'))
271271

@@ -354,9 +354,9 @@ export async function writeModelRequest() {
354354
`
355355
}
356356

357-
fieldString += `created_at?: string
358-
updated_at?: string
359-
deleted_at?: string`
357+
fieldString += `created_at?: Date
358+
updated_at?: Date
359+
deleted_at?: Date`
360360

361361
const requestFile = Bun.file(path.frameworkPath(`requests/${modelName}Request.ts`))
362362

@@ -567,7 +567,7 @@ function parseRule(rule: string): FieldArrayElement | null {
567567
)
568568
}
569569

570-
export async function generateApiRoutes(modelFiles: string[]) {
570+
export async function generateApiRoutes(modelFiles: string[]): Promise<void> {
571571
const file = Bun.file(path.frameworkPath(`orm/routes.ts`))
572572
const writer = file.writer()
573573
let routeString = `import { route } from '@stacksjs/router'\n\n\n`
@@ -610,10 +610,6 @@ export async function generateApiRoutes(modelFiles: string[]) {
610610

611611
const formattedApiRoute = apiRoute.charAt(0).toUpperCase() + apiRoute.slice(1)
612612

613-
const pathAction = path.builtUserActionsPath(`src/${modelName}${formattedApiRoute}OrmAction.ts`, {
614-
relative: true,
615-
})
616-
617613
if (apiRoute === 'index')
618614
routeString += `route.get('${uri}', '${modelName}${formattedApiRoute}OrmAction').middleware(['Api'])\n\n`
619615
if (apiRoute === 'show')
@@ -684,7 +680,7 @@ export async function generateApiRoutes(modelFiles: string[]) {
684680
await writer.end()
685681
}
686682

687-
export async function deleteExistingModels(modelStringFile?: string) {
683+
export async function deleteExistingModels(modelStringFile?: string): Promise<void> {
688684
const typePath = path.frameworkPath(`orm/src/types.ts`)
689685
if (fs.existsSync(typePath)) await fs.promises.unlink(typePath)
690686

@@ -709,7 +705,7 @@ export async function deleteExistingModels(modelStringFile?: string) {
709705
return
710706
}
711707

712-
export async function deleteExistingOrmActions(modelStringFile?: string) {
708+
export async function deleteExistingOrmActions(modelStringFile?: string): Promise<void> {
713709
if (modelStringFile) {
714710
const ormPath = path.builtUserActionsPath(`src/${modelStringFile}.ts`)
715711
if (fs.existsSync(ormPath)) await fs.promises.unlink(ormPath)
@@ -724,12 +720,12 @@ export async function deleteExistingOrmActions(modelStringFile?: string) {
724720
}
725721
}
726722

727-
export async function deleteExistingModelNameTypes() {
723+
export async function deleteExistingModelNameTypes(): Promise<void> {
728724
const typeFile = path.corePath(`types/src/model-names.ts`)
729725
if (fs.existsSync(typeFile)) await fs.promises.unlink(typeFile)
730726
}
731727

732-
export async function deleteExistingModelRequest(modelStringFile?: string) {
728+
export async function deleteExistingModelRequest(modelStringFile?: string): Promise<void> {
733729
const requestD = path.frameworkPath('types/requests.d.ts')
734730
if (fs.existsSync(requestD)) await fs.promises.unlink(requestD)
735731

@@ -746,12 +742,12 @@ export async function deleteExistingModelRequest(modelStringFile?: string) {
746742
}
747743
}
748744

749-
export async function deleteExistingOrmRoute() {
745+
export async function deleteExistingOrmRoute(): Promise<void> {
750746
const ormRoute = path.frameworkPath('orm/routes.ts')
751747
if (fs.existsSync(ormRoute)) await fs.promises.unlink(ormRoute)
752748
}
753749

754-
export async function generateKyselyTypes() {
750+
export async function generateKyselyTypes(): Promise<void> {
755751
const modelFiles = globSync([path.userModelsPath('*.ts')], { absolute: true })
756752
let text = ``
757753

@@ -1091,14 +1087,14 @@ export async function generateModelString(
10911087

10921088
if (useTimestamps) {
10931089
fieldString += `
1094-
created_at?: string\n
1095-
updated_at?: string
1090+
created_at?: Date\n
1091+
updated_at?: Date
10961092
`
10971093
}
10981094

10991095
if (useSoftDeletes) {
11001096
fieldString += `
1101-
deleted_at?: string
1097+
deleted_at?: Date
11021098
`
11031099
}
11041100

storage/framework/orm/src/models/AccessToken.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ export interface PersonalAccessTokensTable {
1919
abilities?: string[]
2020
team_id?: number
2121

22-
created_at?: string
22+
created_at?: Date
2323

24-
updated_at?: string
24+
updated_at?: Date
2525
}
2626

2727
interface AccessTokenResponse {

storage/framework/orm/src/models/Deployment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export interface DeploymentsTable {
2222
terminal_output?: string
2323
user_id?: number
2424

25-
created_at?: string
25+
created_at?: Date
2626

27-
updated_at?: string
27+
updated_at?: Date
2828
}
2929

3030
interface DeploymentResponse {

storage/framework/orm/src/models/Post.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export interface PostsTable {
1717
body?: string
1818
user_id?: number
1919

20-
created_at?: string
20+
created_at?: Date
2121

22-
updated_at?: string
22+
updated_at?: Date
2323
}
2424

2525
interface PostResponse {

storage/framework/orm/src/models/Project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export interface ProjectsTable {
1717
url?: string
1818
status?: string
1919

20-
created_at?: string
20+
created_at?: Date
2121

22-
updated_at?: string
22+
updated_at?: Date
2323
}
2424

2525
interface ProjectResponse {

storage/framework/orm/src/models/Release.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export interface ReleasesTable {
1414
id: Generated<number>
1515
version?: string
1616

17-
created_at?: string
17+
created_at?: Date
1818

19-
updated_at?: string
19+
updated_at?: Date
2020
}
2121

2222
interface ReleaseResponse {

storage/framework/orm/src/models/Subscriber.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export interface SubscribersTable {
1515
subscribed?: boolean
1616
user_id?: number
1717

18-
created_at?: string
18+
created_at?: Date
1919

20-
updated_at?: string
20+
updated_at?: Date
2121
}
2222

2323
interface SubscriberResponse {

storage/framework/orm/src/models/SubscriberEmail.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export interface SubscriberEmailsTable {
1414
id: Generated<number>
1515
email?: string
1616

17-
created_at?: string
17+
created_at?: Date
1818

19-
updated_at?: string
19+
updated_at?: Date
2020

21-
deleted_at?: string
21+
deleted_at?: Date
2222
}
2323

2424
interface SubscriberEmailResponse {

storage/framework/orm/src/models/Team.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export interface TeamsTable {
2626
accesstoken_id?: number
2727
user_id?: number
2828

29-
created_at?: string
29+
created_at?: Date
3030

31-
updated_at?: string
31+
updated_at?: Date
3232
}
3333

3434
interface TeamResponse {

0 commit comments

Comments
 (0)