Skip to content

Commit 4a1e657

Browse files
chore: wip
1 parent 14c36e4 commit 4a1e657

30 files changed

+53
-93
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,14 +1689,14 @@ export interface ${formattedTableName}Table {
16891689
}
16901690

16911691
// Add relation foreign keys to the table interface
1692-
for (const relation of relations) {
1693-
const relationType = getRelationType(relation.relationship)
1694-
const relationCount = getRelationCount(relation.relationship)
1692+
// for (const relation of relations) {
1693+
// const relationType = getRelationType(relation.relationship)
1694+
// const relationCount = getRelationCount(relation.relationship)
16951695

1696-
if (relationType === 'belongsType' && !relationCount) {
1697-
typeString += ` ${relation.modelKey}: number\n`
1698-
}
1699-
}
1696+
// if (relationType === 'belongsType' && !relationCount) {
1697+
// typeString += ` ${relation.modelKey}: number\n`
1698+
// }
1699+
// }
17001700

17011701
if (useUuid) {
17021702
typeString += ` uuid?: string\n`
@@ -1757,14 +1757,14 @@ export interface ${formattedTableName}Table {
17571757

17581758
if (relationType === 'belongsType' && !relationCount) {
17591759
const relationName = camelCase(relation.relationName || formattedModelRelation)
1760-
modelTypeInterface += `
1761-
${relationName}Belong: () => Promise<${modelRelation}Type>`
1760+
modelTypeInterface += ` get ${snakeCase(relationName)}(): ${modelRelation}ModelType | undefined
1761+
`
17621762
}
17631763

17641764
if (relationType === 'belongsType' && relationCount === 'many') {
17651765
const relationName = relation.relationName || formattedModelName + plural(pascalCase(modelRelation))
1766-
modelTypeInterface += `
1767-
${relationName}: () => Promise<${modelRelation}Type[]>`
1766+
modelTypeInterface += ` get ${snakeCase(relationName)}(): ${modelRelation}ModelType[] | []
1767+
`
17681768
}
17691769
}
17701770

@@ -1890,13 +1890,13 @@ export interface ${formattedTableName}Table {
18901890
if (relationType === 'belongsType' && !relationCount) {
18911891
const relationName = camelCase(relation.relationName || formattedModelRelation)
18921892
modelTypeInterface += `
1893-
${relationName}Belong: () => Promise<${modelRelation}ModelType>`
1893+
${relationName}Belong: () => Promise<${modelRelation}ModelType>`
18941894
}
18951895

18961896
if (relationType === 'belongsType' && relationCount === 'many') {
18971897
const relationName = relation.relationName || formattedModelName + plural(pascalCase(modelRelation))
18981898
modelTypeInterface += `
1899-
${relationName}: () => Promise<${modelRelation}ModelType[]>`
1899+
${relationName}: () => Promise<${modelRelation}ModelType[]>`
19001900
}
19011901
}
19021902

storage/framework/orm/src/types/AuthorType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export interface AuthorsTable {
77
id: Generated<number>
88
name?: string
99
email?: string
10-
user_id: number
1110
uuid?: string
1211
created_at?: string
1312
updated_at?: string
@@ -44,8 +43,8 @@ export interface AuthorModelType {
4443
get email(): string | undefined
4544
set email(value: string)
4645
get post(): PostModelType[] | []
46+
get user(): UserModelType | undefined
4747

48-
userBelong: () => Promise<UserType>
4948
get uuid(): string | undefined
5049
set uuid(value: string)
5150

storage/framework/orm/src/types/CartItemType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export interface CartItemsTable {
1515
product_sku?: string
1616
product_image?: string
1717
notes?: string
18-
cart_id: number
1918
uuid?: string
2019
created_at?: string
2120
updated_at?: string
@@ -69,8 +68,8 @@ export interface CartItemModelType {
6968
set productImage(value: string)
7069
get notes(): string | undefined
7170
set notes(value: string)
71+
get cart(): CartModelType | undefined
7272

73-
cartBelong: () => Promise<CartType>
7473
get uuid(): string | undefined
7574
set uuid(value: string)
7675

storage/framework/orm/src/types/CartType.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export interface CartsTable {
1616
currency?: string
1717
notes?: string
1818
applied_coupon_id: string
19-
customer_id: number
20-
coupon_id: number
2119
uuid?: string
2220
created_at?: string
2321
updated_at?: string
@@ -70,9 +68,9 @@ export interface CartModelType {
7068
get appliedCouponId(): string
7169
set appliedCouponId(value: string)
7270
get cart_item(): CartItemModelType[] | []
71+
get customer(): CustomerModelType | undefined
72+
get coupon(): CouponModelType | undefined
7373

74-
customerBelong: () => Promise<CustomerType>
75-
couponBelong: () => Promise<CouponType>
7674
get uuid(): string | undefined
7775
set uuid(value: string)
7876

storage/framework/orm/src/types/CouponType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export interface CouponsTable {
1818
usage_count?: number
1919
start_date?: Date | string
2020
end_date?: Date | string
21-
product_id: number
2221
uuid?: string
2322
created_at?: string
2423
updated_at?: string
@@ -77,8 +76,8 @@ export interface CouponModelType {
7776
get endDate(): Date | string | undefined
7877
set endDate(value: Date | string)
7978
get order(): OrderModelType[] | []
79+
get product(): ProductModelType | undefined
8080

81-
productBelong: () => Promise<ProductType>
8281
get uuid(): string | undefined
8382
set uuid(value: string)
8483

storage/framework/orm/src/types/CustomerType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export interface CustomersTable {
1818
last_order?: string
1919
status: string | string[]
2020
avatar: string
21-
user_id: number
2221
uuid?: string
2322
created_at?: string
2423
updated_at?: string
@@ -71,8 +70,8 @@ export interface CustomerModelType {
7170
get license_key(): LicenseKeyModelType[] | []
7271
get waitlist_product(): WaitlistProductModelType[] | []
7372
get waitlist_restaurant(): WaitlistRestaurantModelType[] | []
73+
get user(): UserModelType | undefined
7474

75-
userBelong: () => Promise<UserType>
7675
get uuid(): string | undefined
7776
set uuid(value: string)
7877

storage/framework/orm/src/types/DeploymentType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface DeploymentsTable {
1111
execution_time?: number
1212
deploy_script?: string
1313
terminal_output?: string
14-
user_id: number
1514
uuid?: string
1615
created_at?: string
1716
updated_at?: string
@@ -57,8 +56,8 @@ export interface DeploymentModelType {
5756
set deployScript(value: string)
5857
get terminalOutput(): string | undefined
5958
set terminalOutput(value: string)
59+
get user(): UserModelType | undefined
6060

61-
userBelong: () => Promise<UserType>
6261
get uuid(): string | undefined
6362
set uuid(value: string)
6463

storage/framework/orm/src/types/DriverType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export interface DriversTable {
1010
vehicle_number: string
1111
license: string
1212
status?: string | string[]
13-
user_id: number
1413
uuid?: string
1514
created_at?: string
1615
updated_at?: string
@@ -53,8 +52,8 @@ export interface DriverModelType {
5352
get status(): string | string[] | undefined
5453
set status(value: string | string[])
5554
get delivery_route(): DeliveryRouteModelType[] | []
55+
get user(): UserModelType | undefined
5656

57-
userBelong: () => Promise<UserType>
5857
get uuid(): string | undefined
5958
set uuid(value: string)
6059

storage/framework/orm/src/types/GiftCardType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export interface GiftCardsTable {
2020
expiry_date?: Date | string
2121
last_used_date?: Date | string
2222
template_id?: string
23-
customer_id: number
2423
uuid?: string
2524
created_at?: string
2625
updated_at?: string
@@ -83,8 +82,8 @@ export interface GiftCardModelType {
8382
get templateId(): string | undefined
8483
set templateId(value: string)
8584
get order(): OrderModelType[] | []
85+
get customer(): CustomerModelType | undefined
8686

87-
customerBelong: () => Promise<CustomerType>
8887
get uuid(): string | undefined
8988
set uuid(value: string)
9089

storage/framework/orm/src/types/LicenseKeyType.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export interface LicenseKeysTable {
1010
template: string | string[]
1111
expiry_date: Date | string
1212
status?: string | string[]
13-
customer_id: number
14-
product_id: number
15-
order_id: number
1613
uuid?: string
1714
created_at?: string
1815
updated_at?: string
@@ -52,10 +49,10 @@ export interface LicenseKeyModelType {
5249
set expiryDate(value: Date | string)
5350
get status(): string | string[] | undefined
5451
set status(value: string | string[])
52+
get customer(): CustomerModelType | undefined
53+
get product(): ProductModelType | undefined
54+
get order(): OrderModelType | undefined
5555

56-
customerBelong: () => Promise<CustomerType>
57-
productBelong: () => Promise<ProductType>
58-
orderBelong: () => Promise<OrderType>
5956
get uuid(): string | undefined
6057
set uuid(value: string)
6158

0 commit comments

Comments
 (0)