Skip to content

Commit 301eb0a

Browse files
chore: wip
1 parent 5b330f4 commit 301eb0a

File tree

13 files changed

+40
-44
lines changed

13 files changed

+40
-44
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ export async function generateModelString(
10111011
let fieldString = ''
10121012
let constructorFields = ''
10131013
let jsonFields = '{\n'
1014+
let jsonRelations = ''
10141015
let declareFields = ''
10151016
let uuidQuery = ''
10161017
let uuidQueryMany = ''
@@ -1167,7 +1168,7 @@ export async function generateModelString(
11671168
model.${snakeCase(relationName)} = await this.${relationName}HasMany()\n
11681169
}
11691170
`
1170-
jsonFields += `${snakeCase(relationName)}: this.${snakeCase(relationName)},\n`
1171+
jsonRelations += `${snakeCase(relationName)}: this.${snakeCase(relationName)},\n`
11711172

11721173
relationMethods += `
11731174
async ${relationName}HasMany(): Promise<${modelRelation}Model[]> {
@@ -1207,7 +1208,7 @@ export async function generateModelString(
12071208
fieldString += ` ${relation.modelKey}?: number \n`
12081209
declareFields += `public ${relation.modelKey}: number | undefined \n `
12091210
constructorFields += `this.${relation.modelKey} = ${formattedModelName}?.${relation.modelKey}\n `
1210-
jsonFields += `${relation.modelKey}: this.${relation.modelKey},\n `
1211+
jsonRelations += `${relation.modelKey}: this.${relation.modelKey},\n `
12111212

12121213
declareFields += `public ${snakeCase(relationName)}: ${modelRelation}Model | undefined\n`
12131214
constructorFields += `this.${snakeCase(relationName)} = ${formattedModelName}?.${snakeCase(relationName)}\n`
@@ -1218,7 +1219,7 @@ export async function generateModelString(
12181219
model.${snakeCase(relationName)} = await this.${relationName}Belong()\n
12191220
}
12201221
`
1221-
jsonFields += `${snakeCase(relationName)}: this.${snakeCase(relationName)},\n`
1222+
jsonRelations += `${snakeCase(relationName)}: this.${snakeCase(relationName)},\n`
12221223

12231224
relationMethods += `
12241225
async ${relationName}Belong(): Promise<${modelRelation}Model> {
@@ -1630,6 +1631,8 @@ export async function generateModelString(
16301631
`
16311632
}
16321633

1634+
jsonFields += jsonRelations
1635+
16331636
jsonFields += '}'
16341637

16351638
const otherModelRelations = await fetchOtherModelRelations(modelName)

storage/framework/core/router/src/router.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ export class Router implements RouterInterface {
279279
actionModule = await import(p.storagePath(`/framework/actions/src/${modulePath}.ts`))
280280
else actionModule = await import(importPathFunction(modulePath))
281281

282-
283282
// Use custom path from action module if available
284283
const newPath = actionModule.default.path ?? originalPath
285284
this.updatePathIfNeeded(newPath, originalPath)
@@ -304,7 +303,6 @@ export class Router implements RouterInterface {
304303
if (isObjectNotEmpty(actionModule.default.validations) && requestInstance)
305304
await customValidate(actionModule.default.validations, requestInstance.all())
306305

307-
308306
return await actionModule.default.handle(requestInstance)
309307
}
310308
catch (error: any) {
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import type { AutoImportsOptions } from 'bun-plugin-auto-imports'
2-
import { plugin } from 'bun'
3-
import { path } from '@stacksjs/path'
4-
import { autoImports } from 'bun-plugin-auto-imports'
5-
61
export function initiateImports(): void {
7-
const options: AutoImportsOptions = {
8-
dts: path.storagePath('framework/types/server-auto-imports.d.ts'),
9-
dirs: [
10-
path.storagePath('framework/orm/src/models'),
11-
path.storagePath('framework/requests'),
12-
],
13-
eslint: {
14-
enabled: true, // TODO: not needed in production envs
15-
filepath: path.storagePath('framework/server-auto-imports.json'),
16-
},
17-
}
2+
// const options: AutoImportsOptions = {
3+
// dts: path.storagePath('framework/types/server-auto-imports.d.ts'),
4+
// dirs: [
5+
// path.storagePath('framework/orm/src/models'),
6+
// path.storagePath('framework/requests'),
7+
// ],
8+
// eslint: {
9+
// enabled: true, // TODO: not needed in production envs
10+
// filepath: path.storagePath('framework/server-auto-imports.json'),
11+
// },
12+
// }
1813

19-
plugin(autoImports(options))
14+
// plugin(autoImports(options))
2015
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,6 @@ export class AccessTokenModel {
813813

814814
toJSON() {
815815
const output: Partial<AccessTokenType> = {
816-
team_id: this.team_id,
817-
team: this.team,
818816

819817
id: this.id,
820818
name: this.name,
@@ -826,6 +824,8 @@ export class AccessTokenModel {
826824

827825
updated_at: this.updated_at,
828826

827+
team_id: this.team_id,
828+
team: this.team,
829829
}
830830

831831
type AccessToken = Omit<AccessTokenType, 'password'>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,6 @@ export class DeploymentModel {
856856

857857
toJSON() {
858858
const output: Partial<DeploymentType> = {
859-
user_id: this.user_id,
860-
user: this.user,
861859

862860
id: this.id,
863861
commit_sha: this.commit_sha,
@@ -872,6 +870,8 @@ export class DeploymentModel {
872870

873871
updated_at: this.updated_at,
874872

873+
user_id: this.user_id,
874+
user: this.user,
875875
}
876876

877877
type Deployment = Omit<DeploymentType, 'password'>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,6 @@ export class PaymentMethodModel {
879879

880880
toJSON() {
881881
const output: Partial<PaymentMethodType> = {
882-
user_id: this.user_id,
883-
user: this.user,
884-
transactions: this.transactions,
885882

886883
id: this.id,
887884
type: this.type,
@@ -896,6 +893,9 @@ export class PaymentMethodModel {
896893

897894
updated_at: this.updated_at,
898895

896+
user_id: this.user_id,
897+
user: this.user,
898+
transactions: this.transactions,
899899
}
900900

901901
type PaymentMethod = Omit<PaymentMethodType, 'password'>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,6 @@ export class PostModel {
791791

792792
toJSON() {
793793
const output: Partial<PostType> = {
794-
user_id: this.user_id,
795-
user: this.user,
796794

797795
id: this.id,
798796
title: this.title,
@@ -802,6 +800,8 @@ export class PostModel {
802800

803801
updated_at: this.updated_at,
804802

803+
user_id: this.user_id,
804+
user: this.user,
805805
}
806806

807807
type Post = Omit<PostType, 'password'>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,6 @@ export class SubscriptionModel {
889889

890890
toJSON() {
891891
const output: Partial<SubscriptionType> = {
892-
user_id: this.user_id,
893-
user: this.user,
894892

895893
id: this.id,
896894
type: this.type,
@@ -908,6 +906,8 @@ export class SubscriptionModel {
908906

909907
updated_at: this.updated_at,
910908

909+
user_id: this.user_id,
910+
user: this.user,
911911
}
912912

913913
type Subscription = Omit<SubscriptionType, 'password'>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,6 @@ export class TeamModel {
874874

875875
toJSON() {
876876
const output: Partial<TeamType> = {
877-
personal_access_tokens: this.personal_access_tokens,
878877

879878
id: this.id,
880879
name: this.name,
@@ -890,6 +889,7 @@ export class TeamModel {
890889

891890
updated_at: this.updated_at,
892891

892+
personal_access_tokens: this.personal_access_tokens,
893893
}
894894

895895
type Team = Omit<TeamType, 'password'>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,6 @@ export class TransactionModel {
861861

862862
toJSON() {
863863
const output: Partial<TransactionType> = {
864-
user_id: this.user_id,
865-
user: this.user,
866-
payment_method_id: this.payment_method_id,
867-
payment_method: this.payment_method,
868864

869865
id: this.id,
870866
name: this.name,
@@ -877,6 +873,10 @@ export class TransactionModel {
877873

878874
updated_at: this.updated_at,
879875

876+
user_id: this.user_id,
877+
user: this.user,
878+
payment_method_id: this.payment_method_id,
879+
payment_method: this.payment_method,
880880
}
881881

882882
type Transaction = Omit<TransactionType, 'password'>

0 commit comments

Comments
 (0)