Skip to content

Commit 6806bdc

Browse files
chore: wip
1 parent e829516 commit 6806bdc

35 files changed

+978
-49
lines changed

app/Jobs/ExampleJob.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { log } from '@stacksjs/cli'
21
import { Job } from '@stacksjs/queue'
32
import { Every } from '@stacksjs/types'
43

@@ -9,7 +8,7 @@ export default new Job({
98
backoff: 3, // optional, defaults to 3-second delays between retries
109
rate: Every.Minute, // optional, '* * * * *' in cron syntax
1110
handle: () => {
12-
log.info('This message logs every minute') // unless triggered via a route.job() call, in which case it logs once
11+
// console.log('hello world') // unless triggered via a route.job() call, in which case it logs once
1312
},
1413
// action: 'SendWelcomeEmail', // instead of handle, you may target an action or `action: () => {`
1514
})

database/migrations/1736175792802-create-jobs-table.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

database/migrations/1734960728770-create-subscriber_emails-table.ts renamed to database/migrations/1736240733671-create-subscriber_emails-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export async function up(db: Database<any>) {
88
.addColumn('email', 'varchar(255)', col => col.unique())
99
.addColumn('created_at', 'timestamp', col => col.notNull().defaultTo(sql`CURRENT_TIMESTAMP`))
1010
.addColumn('updated_at', 'timestamp')
11-
.addColumn('deleted_at', 'text')
11+
.addColumn('deleted_at', 'timestamp')
1212
.execute()
1313
}

resources/views/dashboard/components/transaction/index.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ function getUnitPrice(lineData: LineItem[]) {
6565
function getLastDigits(paymentIntent: any) {
6666
return paymentIntent.payment_method.card.last4
6767
}
68-
69-
function getBrand(paymentIntent: any) {
70-
return 'visa'
71-
}
7268
</script>
7369

7470
<template>

storage/framework/core/buddy/src/commands/make.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function make(buddy: CLI): void {
6969

7070
if (make) {
7171
options.name = buddy.args[1]
72-
72+
7373
switch (make) {
7474
case 'action':
7575
await makeAction(options)

storage/framework/core/database/src/custom/jobs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export async function createJobsMigration(): Promise<Result<MigrationResult[] |
3535
await Bun.write(migrationFilePath, migrationContent) // Ensure the write operation is awaited
3636

3737
log.success('Created jobs migration')
38-
} else {
38+
}
39+
else {
3940
log.success('Jobs migration already created')
4041
}
4142
}

storage/framework/core/database/src/drivers/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export async function hasMigrationBeenCreated(tableName: string): Promise<boolea
4848
log.debug(`hasTableBeenMigrated for table: ${tableName}`)
4949

5050
const migrations = globSync([path.userMigrationsPath('*.ts')], { absolute: true })
51-
52-
return migrations.some(path => path.includes("create-jobs-"))
51+
52+
return migrations.some(path => path.includes('create-jobs-'))
5353
}
5454

5555
export async function getExecutedMigrations(): Promise<{ name: string }[]> {

storage/framework/core/database/src/drivers/sqlite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async function createTableMigration(modelPath: string) {
257257
}
258258

259259
if (useSoftDeletes)
260-
migrationContent += ` .addColumn('deleted_at', 'text')\n`
260+
migrationContent += ` .addColumn('deleted_at', 'timestamp')\n`
261261

262262
migrationContent += ` .execute()\n`
263263
migrationContent += `}\n`

storage/framework/core/queue/src/sample.ts

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type ModelNames = 'Project' | 'SubscriberEmail' | 'AccessToken' | 'Team' | 'Subscriber' | 'Deployment' | 'Release' | 'User' | 'Post' | 'Product' | 'PaymentMethod' | 'Transaction' | 'Subscription' | 'Error'
1+
export type ModelNames = 'Project' | 'SubscriberEmail' | 'AccessToken' | 'Team' | 'Subscriber' | 'Deployment' | 'Release' | 'User' | 'Post' | 'Product' | 'PaymentMethod' | 'Transaction' | 'Job' | 'Subscription' | 'Error'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type TableNames = 'projects' | 'subscriber_emails' | 'personal_access_tokens' | 'personal_access_token_teams' | 'team_users' | 'teams' | 'subscribers' | 'deployments' | 'releases' | 'team_users' | 'users' | 'posts' | 'products' | 'payment_methods' | 'transactions' | 'subscriptions' | 'errors'
1+
export type TableNames = 'projects' | 'subscriber_emails' | 'personal_access_tokens' | 'personal_access_token_teams' | 'team_users' | 'teams' | 'subscribers' | 'deployments' | 'releases' | 'team_users' | 'users' | 'posts' | 'products' | 'payment_methods' | 'transactions' | 'jobs' | 'subscriptions' | 'errors'

storage/framework/database/models/generated/Error.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Model } from '@stacksjs/types'
22
import { faker } from '@stacksjs/faker'
3+
import { schema } from '@stacksjs/validation'
34

45
export default {
56
name: 'Error',
@@ -14,17 +15,22 @@ export default {
1415
attributes: {
1516
type: {
1617
required: true,
17-
order: 1,
1818
fillable: true,
19-
20-
factory: () => faker.system.fileType(),
19+
validation: {
20+
rule: schema.string().maxLength(255),
21+
message: {
22+
maxLength: 'Queue must have a maximum characters of 255',
23+
},
24+
},
25+
factory: () => 'default',
2126
},
2227

23-
message: {
28+
payload: {
2429
required: true,
25-
order: 2,
2630
fillable: true,
27-
31+
validation: {
32+
rule: schema.string(),
33+
},
2834
factory: () => faker.lorem.sentence(),
2935
},
3036

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { Model } from '@stacksjs/types'
2+
import { faker } from '@stacksjs/faker'
3+
import { schema } from '@stacksjs/validation'
4+
5+
export default {
6+
name: 'Job',
7+
table: 'jobs',
8+
primaryKey: 'id',
9+
autoIncrement: true,
10+
11+
traits: {
12+
useTimestamps: true,
13+
},
14+
15+
attributes: {
16+
queue: {
17+
required: true,
18+
fillable: true,
19+
validation: {
20+
rule: schema.string().maxLength(255),
21+
message: {
22+
maxLength: 'Queue must have a maximum of 255 characters',
23+
},
24+
},
25+
factory: () => 'default',
26+
},
27+
28+
payload: {
29+
required: true,
30+
fillable: true,
31+
validation: {
32+
rule: schema.string(),
33+
},
34+
factory: () => faker.lorem.sentence(),
35+
},
36+
37+
attempts: {
38+
fillable: true,
39+
validation: {
40+
rule: schema.number(),
41+
message: {
42+
number: 'attempts must be a number',
43+
},
44+
},
45+
factory: () => faker.number.int({ min: 0, max: 10 }),
46+
},
47+
48+
reserved_at: {
49+
required: true,
50+
order: 4,
51+
fillable: true,
52+
validation: {
53+
rule: schema.date(),
54+
},
55+
factory: () => '2024-12-23 13:32:19',
56+
},
57+
},
58+
} satisfies Model

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { HttpError } from '@stacksjs/error-handling'
55

66
export interface ErrorsTable {
77
id?: number
8-
type?: undefined
9-
message?: undefined
8+
type?: string
9+
payload?: string
1010
stack?: undefined
1111
status?: undefined
1212
user_id?: undefined
@@ -48,16 +48,16 @@ interface QueryOptions {
4848

4949
export class ErrorModel {
5050
private hidden = []
51-
private fillable = ['type', 'message', 'stack', 'status', 'user_id', 'additional_info', 'uuid']
51+
private fillable = ['type', 'payload', 'stack', 'status', 'user_id', 'additional_info', 'uuid']
5252
private softDeletes = false
5353
protected selectFromQuery: any
5454
protected withRelations: string[]
5555
protected updateFromQuery: any
5656
protected deleteFromQuery: any
5757
protected hasSelect: boolean
5858
public id: number
59-
public type: undefined | undefined
60-
public message: undefined | undefined
59+
public type: string | undefined
60+
public payload: string | undefined
6161
public stack: undefined | undefined
6262
public status: undefined | undefined
6363
public user_id: undefined | undefined
@@ -69,7 +69,7 @@ export class ErrorModel {
6969
constructor(error: Partial<ErrorType> | null) {
7070
this.id = error?.id || 1
7171
this.type = error?.type
72-
this.message = error?.message
72+
this.payload = error?.payload
7373
this.stack = error?.stack
7474
this.status = error?.status
7575
this.user_id = error?.user_id
@@ -460,10 +460,10 @@ export class ErrorModel {
460460
return instance
461461
}
462462

463-
static whereMessage(value: string): ErrorModel {
463+
static wherePayload(value: string): ErrorModel {
464464
const instance = new ErrorModel(null)
465465

466-
instance.selectFromQuery = instance.selectFromQuery.where('message', '=', value)
466+
instance.selectFromQuery = instance.selectFromQuery.where('payload', '=', value)
467467

468468
return instance
469469
}
@@ -740,7 +740,7 @@ export class ErrorModel {
740740

741741
id: this.id,
742742
type: this.type,
743-
message: this.message,
743+
payload: this.payload,
744744
stack: this.stack,
745745
status: this.status,
746746
user_id: this.user_id,
@@ -801,15 +801,15 @@ export async function remove(id: number): Promise<void> {
801801
.execute()
802802
}
803803

804-
export async function whereType(value: undefined): Promise<ErrorModel[]> {
804+
export async function whereType(value: string): Promise<ErrorModel[]> {
805805
const query = db.selectFrom('errors').where('type', '=', value)
806806
const results = await query.execute()
807807

808808
return results.map(modelItem => new ErrorModel(modelItem))
809809
}
810810

811-
export async function whereMessage(value: undefined): Promise<ErrorModel[]> {
812-
const query = db.selectFrom('errors').where('message', '=', value)
811+
export async function wherePayload(value: string): Promise<ErrorModel[]> {
812+
const query = db.selectFrom('errors').where('payload', '=', value)
813813
const results = await query.execute()
814814

815815
return results.map(modelItem => new ErrorModel(modelItem))

0 commit comments

Comments
 (0)