Skip to content

Commit 5d43731

Browse files
chore: wip
1 parent b23e7a9 commit 5d43731

File tree

17 files changed

+437
-2
lines changed

17 files changed

+437
-2
lines changed

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export async function generateModelString(
2525

2626
let fieldString = ''
2727
let getFields = ''
28+
let setFields = ''
2829
// const constructorFields = ''
2930
let jsonFields = '{\n'
3031
let jsonRelations = ''
@@ -170,6 +171,7 @@ export async function generateModelString(
170171
getFields += `get ${snakeCase(relationName)}():${modelRelation}Model[] | undefined {
171172
return this.attributes.${snakeCase(relationName)}
172173
}\n\n`
174+
173175
// constructorFields += `this.${snakeCase(relationName)} = ${formattedModelName}?.${snakeCase(relationName)}\n`
174176
fieldString += `${snakeCase(relationName)}?: ${modelRelation}Model[] | undefined\n`
175177

@@ -566,6 +568,10 @@ export async function generateModelString(
566568
return this.attributes.stripe_id
567569
}\n\n`
568570

571+
setFields += `set stripe_id(value: string) {
572+
this.attributes.stripe_id = value
573+
}\n\n`
574+
569575
// constructorFields += `this.stripe_id = ${formattedModelName}?.stripe_id\n `
570576
}
571577

@@ -576,6 +582,10 @@ export async function generateModelString(
576582
return this.attributes.two_factor_secret
577583
}\n\n`
578584

585+
setFields += `set two_factor_secret(value: string) {
586+
this.attributes.two_factor_secret = value
587+
}\n\n`
588+
579589
// constructorFields += `this.two_factor_secret = ${formattedModelName}?.two_factor_secret\n `
580590

581591
twoFactorStatements += `
@@ -603,6 +613,10 @@ export async function generateModelString(
603613
getFields += `get uuid(): string | undefined {
604614
return this.attributes.uuid
605615
}\n\n`
616+
617+
setFields += `set uuid(value: string) {
618+
this.attributes.uuid = value
619+
}\n\n`
606620
// constructorFields += `this.uuid = ${formattedModelName}?.uuid\n `
607621
}
608622

@@ -611,6 +625,10 @@ export async function generateModelString(
611625
getFields += `get public_passkey(): string | undefined {
612626
return this.attributes.public_passkey
613627
}\n\n`
628+
629+
setFields += `set public_passkey(value: string) {
630+
this.attributes.public_passkey = value
631+
}\n\n`
614632
// constructorFields += `this.public_passkey = ${formattedModelName}?.public_passkey\n `
615633
}
616634

@@ -623,6 +641,10 @@ export async function generateModelString(
623641
getFields += `get ${snakeCase(attribute.field)}(): ${entity} | undefined {
624642
return this.attributes.${snakeCase(attribute.field)}
625643
}\n\n`
644+
645+
setFields += `set ${snakeCase(attribute.field)}(value: ${entity}) {
646+
this.attributes.${snakeCase(attribute.field)} = value
647+
}\n\n`
626648
// constructorFields += `this.${snakeCase(attribute.field)} = ${formattedModelName}?.${snakeCase(attribute.field)}\n `
627649
jsonFields += `${snakeCase(attribute.field)}: this.${snakeCase(attribute.field)},\n `
628650

@@ -650,11 +672,15 @@ export async function generateModelString(
650672

651673
getFields += `get created_at(): Date | undefined {
652674
return this.attributes.created_at
653-
}\n\n
675+
}
654676
655677
get updated_at(): Date | undefined {
656678
return this.attributes.updated_at
657-
}`
679+
}\n\n`
680+
681+
setFields += `set updated_at(value: Date) {
682+
this.attributes.updated_at = value
683+
}\n\n`
658684

659685
// constructorFields += `
660686
// this.created_at = ${formattedModelName}?.created_at\n
@@ -675,6 +701,10 @@ export async function generateModelString(
675701
return this.attributes.deleted_at
676702
}\n\n`
677703

704+
setFields += `get deleted_at(value: Date) {
705+
this.attributes.deleted_at = value
706+
}\n\n`
707+
678708
// constructorFields += `
679709
// this.deleted_at = ${formattedModelName}?.deleted_at\n
680710
// `
@@ -800,6 +830,7 @@ export async function generateModelString(
800830
}
801831
802832
${getFields}
833+
${setFields}
803834
804835
select(params: (keyof ${modelName}Type)[] | RawBuilder<string> | string): ${modelName}Model {
805836
return ${modelName}Model.select(params)

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@ export class AccessTokenModel {
120120
return this.attributes.updated_at
121121
}
122122

123+
set name(value: string) {
124+
this.attributes.name = value
125+
}
126+
127+
set token(value: string) {
128+
this.attributes.token = value
129+
}
130+
131+
set plain_text_token(value: string) {
132+
this.attributes.plain_text_token = value
133+
}
134+
135+
set abilities(value: string[]) {
136+
this.attributes.abilities = value
137+
}
138+
139+
set updated_at(value: Date) {
140+
this.attributes.updated_at = value
141+
}
142+
123143
select(params: (keyof AccessTokenType)[] | RawBuilder<string> | string): AccessTokenModel {
124144
return AccessTokenModel.select(params)
125145
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,42 @@ export class DeploymentModel {
140140
return this.attributes.updated_at
141141
}
142142

143+
set uuid(value: string) {
144+
this.attributes.uuid = value
145+
}
146+
147+
set commit_sha(value: string) {
148+
this.attributes.commit_sha = value
149+
}
150+
151+
set commit_message(value: string) {
152+
this.attributes.commit_message = value
153+
}
154+
155+
set branch(value: string) {
156+
this.attributes.branch = value
157+
}
158+
159+
set status(value: string) {
160+
this.attributes.status = value
161+
}
162+
163+
set execution_time(value: number) {
164+
this.attributes.execution_time = value
165+
}
166+
167+
set deploy_script(value: string) {
168+
this.attributes.deploy_script = value
169+
}
170+
171+
set terminal_output(value: string) {
172+
this.attributes.terminal_output = value
173+
}
174+
175+
set updated_at(value: Date) {
176+
this.attributes.updated_at = value
177+
}
178+
143179
select(params: (keyof DeploymentType)[] | RawBuilder<string> | string): DeploymentModel {
144180
return DeploymentModel.select(params)
145181
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,30 @@ export class ErrorModel {
112112
return this.attributes.updated_at
113113
}
114114

115+
set type(value: string) {
116+
this.attributes.type = value
117+
}
118+
119+
set message(value: string) {
120+
this.attributes.message = value
121+
}
122+
123+
set stack(value: string) {
124+
this.attributes.stack = value
125+
}
126+
127+
set status(value: number) {
128+
this.attributes.status = value
129+
}
130+
131+
set additional_info(value: string) {
132+
this.attributes.additional_info = value
133+
}
134+
135+
set updated_at(value: Date) {
136+
this.attributes.updated_at = value
137+
}
138+
115139
select(params: (keyof ErrorType)[] | RawBuilder<string> | string): ErrorModel {
116140
return ErrorModel.select(params)
117141
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,30 @@ export class FailedJobModel {
112112
return this.attributes.updated_at
113113
}
114114

115+
set connection(value: string) {
116+
this.attributes.connection = value
117+
}
118+
119+
set queue(value: string) {
120+
this.attributes.queue = value
121+
}
122+
123+
set payload(value: string) {
124+
this.attributes.payload = value
125+
}
126+
127+
set exception(value: string) {
128+
this.attributes.exception = value
129+
}
130+
131+
set failed_at(value: Date | string) {
132+
this.attributes.failed_at = value
133+
}
134+
135+
set updated_at(value: Date) {
136+
this.attributes.updated_at = value
137+
}
138+
115139
select(params: (keyof FailedJobType)[] | RawBuilder<string> | string): FailedJobModel {
116140
return FailedJobModel.select(params)
117141
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,30 @@ export class JobModel {
112112
return this.attributes.updated_at
113113
}
114114

115+
set queue(value: string) {
116+
this.attributes.queue = value
117+
}
118+
119+
set payload(value: string) {
120+
this.attributes.payload = value
121+
}
122+
123+
set attempts(value: number) {
124+
this.attributes.attempts = value
125+
}
126+
127+
set available_at(value: number) {
128+
this.attributes.available_at = value
129+
}
130+
131+
set reserved_at(value: Date | string) {
132+
this.attributes.reserved_at = value
133+
}
134+
135+
set updated_at(value: Date) {
136+
this.attributes.updated_at = value
137+
}
138+
115139
select(params: (keyof JobType)[] | RawBuilder<string> | string): JobModel {
116140
return JobModel.select(params)
117141
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,42 @@ export class PaymentMethodModel {
149149
return this.attributes.updated_at
150150
}
151151

152+
set uuid(value: string) {
153+
this.attributes.uuid = value
154+
}
155+
156+
set type(value: string) {
157+
this.attributes.type = value
158+
}
159+
160+
set last_four(value: number) {
161+
this.attributes.last_four = value
162+
}
163+
164+
set brand(value: string) {
165+
this.attributes.brand = value
166+
}
167+
168+
set exp_month(value: number) {
169+
this.attributes.exp_month = value
170+
}
171+
172+
set exp_year(value: number) {
173+
this.attributes.exp_year = value
174+
}
175+
176+
set is_default(value: boolean) {
177+
this.attributes.is_default = value
178+
}
179+
180+
set provider_id(value: string) {
181+
this.attributes.provider_id = value
182+
}
183+
184+
set updated_at(value: Date) {
185+
this.attributes.updated_at = value
186+
}
187+
152188
select(params: (keyof PaymentMethodType)[] | RawBuilder<string> | string): PaymentMethodModel {
153189
return PaymentMethodModel.select(params)
154190
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ export class PostModel {
110110
return this.attributes.updated_at
111111
}
112112

113+
set title(value: string) {
114+
this.attributes.title = value
115+
}
116+
117+
set body(value: string) {
118+
this.attributes.body = value
119+
}
120+
121+
set updated_at(value: Date) {
122+
this.attributes.updated_at = value
123+
}
124+
113125
select(params: (keyof PostType)[] | RawBuilder<string> | string): PostModel {
114126
return PostModel.select(params)
115127
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,42 @@ export class ProductModel {
127127
return this.attributes.updated_at
128128
}
129129

130+
set uuid(value: string) {
131+
this.attributes.uuid = value
132+
}
133+
134+
set name(value: string) {
135+
this.attributes.name = value
136+
}
137+
138+
set description(value: number) {
139+
this.attributes.description = value
140+
}
141+
142+
set key(value: number) {
143+
this.attributes.key = value
144+
}
145+
146+
set unit_price(value: number) {
147+
this.attributes.unit_price = value
148+
}
149+
150+
set status(value: string) {
151+
this.attributes.status = value
152+
}
153+
154+
set image(value: string) {
155+
this.attributes.image = value
156+
}
157+
158+
set provider_id(value: string) {
159+
this.attributes.provider_id = value
160+
}
161+
162+
set updated_at(value: Date) {
163+
this.attributes.updated_at = value
164+
}
165+
130166
select(params: (keyof ProductType)[] | RawBuilder<string> | string): ProductModel {
131167
return ProductModel.select(params)
132168
}

0 commit comments

Comments
 (0)