@stacksjs/defaults 0.75.482 → 0.75.483
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/skills/stacks-actions/SKILL.md +1 -1
- package/ai/skills/stacks-native/CATALOG.md +4 -4
- package/ai/skills/stacks-queue/DURABLE-WORKFLOWS.md +12 -0
- package/app/Actions/Dashboard/Content/CommentIndexAction.ts +22 -112
- package/app/Actions/Dashboard/Content/PageIndexAction.ts +26 -25
- package/app/Actions/Dashboard/Content/PostIndexAction.ts +30 -35
- package/app/Actions/Dashboard/Content/PostShowAction.ts +41 -0
- package/app/Actions/Dashboard/Content/comment-input.ts +25 -1
- package/app/Actions/Dashboard/Content/comment-list.ts +311 -0
- package/app/Actions/Dashboard/Content/content-list.ts +69 -0
- package/app/Actions/Dashboard/Content/page-list.ts +108 -0
- package/app/Actions/Dashboard/Content/post-list.ts +140 -0
- package/app/Actions/Dashboard/Jobs/JobIndexAction.ts +12 -24
- package/app/Actions/Dashboard/Jobs/job-list.ts +168 -0
- package/app/Actions/Dashboard/Jobs/job-records.ts +8 -3
- package/app/Actions/Dashboard/Models/ModelShowAction.ts +8 -2
- package/app/Actions/Dashboard/Queries/QueryDashboardAction.ts +20 -10
- package/app/Actions/Dashboard/Queries/query-dashboard.ts +56 -9
- package/app/Actions/Dashboard/Queries/query-list.ts +161 -0
- package/app/Actions/Dashboard/Queue/QueueStatsAction.ts +14 -52
- package/app/Actions/Dashboard/Queue/queue-stats.ts +69 -0
- package/app/Actions/Monitoring/ErrorIndexAction.ts +9 -4
- package/app/Actions/Monitoring/error-provider.ts +85 -7
- package/functions/api.ts +14 -10
- package/functions/commerce/coupons.ts +4 -6
- package/functions/commerce/customers.ts +4 -6
- package/functions/commerce/gift-cards.ts +4 -2
- package/functions/commerce/orders.ts +4 -2
- package/functions/commerce/payments.ts +4 -2
- package/functions/commerce/products/categories.ts +4 -6
- package/functions/commerce/products/manufacturers.ts +4 -6
- package/functions/commerce/products/products.ts +4 -6
- package/functions/commerce/products/reviews.ts +4 -6
- package/functions/commerce/products/units.ts +4 -6
- package/functions/commerce/products/variants.ts +4 -6
- package/functions/commerce/taxes.ts +4 -2
- package/functions/commerce/waitlist/products.ts +4 -6
- package/functions/commerce/waitlist/restaurants.ts +4 -6
- package/functions/monitoring/errors.ts +77 -49
- package/functions/queries.ts +34 -2
- package/ide/vscode/package.json +1 -1
- package/package.json +2 -2
- package/resources/components/Dashboard/Analytics/AnalyticsHub.stx +4 -0
- package/resources/components/Dashboard/Auth/MagicLink.stx +6 -1
- package/resources/components/Dashboard/Content/CommentsDashboard.stx +90 -12
- package/resources/components/Dashboard/Content/PagesDashboard.stx +100 -16
- package/resources/components/Dashboard/Content/PostEditorDialog.stx +28 -8
- package/resources/components/Dashboard/Content/PostsDashboard.stx +179 -21
- package/resources/components/Dashboard/Monitoring/ErrorDashboard.stx +121 -36
- package/resources/components/Dashboard/Monitoring/ErrorTable.stx +29 -8
- package/resources/components/Dashboard/Queries/QueryDashboard.stx +73 -64
- package/resources/components/Dashboard/UI/Table.stx +30 -7
- package/routes/dashboard-api.ts +1 -0
- package/app/Actions/Buddy/JobsListAction.ts +0 -141
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Action } from '@stacksjs/actions/runtime'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* GET /api/buddy/jobs
|
|
5
|
-
*
|
|
6
|
-
* Powers the existing `dashboard/jobs/history.stx` view. Reads the
|
|
7
|
-
* `jobs` and `failed_jobs` tables and merges them into a single
|
|
8
|
-
* timeline shape the dashboard already understands.
|
|
9
|
-
*
|
|
10
|
-
* Query params:
|
|
11
|
-
* - status: 'all' | 'queued' | 'processing' | 'completed' | 'failed'
|
|
12
|
-
* - queue: 'all' | <queue-name>
|
|
13
|
-
* - q: free-text filter on job name
|
|
14
|
-
* - page, perPage: pagination
|
|
15
|
-
*/
|
|
16
|
-
export default new Action({
|
|
17
|
-
name: 'Buddy Jobs List',
|
|
18
|
-
description: 'List queued, in-flight, completed, and failed jobs for the admin dashboard.',
|
|
19
|
-
|
|
20
|
-
async handle(request) {
|
|
21
|
-
const status = String(request.get('status', 'all') ?? 'all')
|
|
22
|
-
const queue = String(request.get('queue', 'all') ?? 'all')
|
|
23
|
-
const q = String(request.get('q', '') ?? '')
|
|
24
|
-
const page = Math.max(1, Number(request.get('page', 1) ?? 1))
|
|
25
|
-
const perPage = Math.min(100, Math.max(1, Number(request.get('perPage', 25) ?? 25)))
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
const { db } = await import('@stacksjs/database/runtime')
|
|
29
|
-
const dbAny = db as any
|
|
30
|
-
|
|
31
|
-
// Pull the live `jobs` table — this contains queued + reserved (processing) rows.
|
|
32
|
-
let pendingQuery = dbAny.selectFrom('jobs').selectAll()
|
|
33
|
-
if (queue !== 'all') pendingQuery = pendingQuery.where('queue', '=', queue)
|
|
34
|
-
if (q) pendingQuery = pendingQuery.where('payload', 'like', `%${q}%`)
|
|
35
|
-
|
|
36
|
-
// Pull the failed_jobs table for the failed status.
|
|
37
|
-
let failedQuery = dbAny.selectFrom('failed_jobs').selectAll()
|
|
38
|
-
if (queue !== 'all') failedQuery = failedQuery.where('queue', '=', queue)
|
|
39
|
-
if (q) failedQuery = failedQuery.where('payload', 'like', `%${q}%`)
|
|
40
|
-
|
|
41
|
-
const [pending, failed] = await Promise.all([
|
|
42
|
-
status === 'failed' ? Promise.resolve([]) : pendingQuery.execute(),
|
|
43
|
-
status === 'queued' || status === 'processing' || status === 'completed' ? Promise.resolve([]) : failedQuery.execute(),
|
|
44
|
-
])
|
|
45
|
-
|
|
46
|
-
const normalized = [
|
|
47
|
-
...(pending as Array<Record<string, unknown>>).map(row => normalizePending(row, status)),
|
|
48
|
-
...(failed as Array<Record<string, unknown>>).map(normalizeFailed),
|
|
49
|
-
]
|
|
50
|
-
.filter((j): j is NonNullable<typeof j> => j !== null)
|
|
51
|
-
.sort((a, b) => (b.created_at?.localeCompare(a.created_at ?? '') ?? 0))
|
|
52
|
-
|
|
53
|
-
const total = normalized.length
|
|
54
|
-
const start = (page - 1) * perPage
|
|
55
|
-
const items = normalized.slice(start, start + perPage)
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
items,
|
|
59
|
-
total,
|
|
60
|
-
page,
|
|
61
|
-
perPage,
|
|
62
|
-
totalPages: Math.max(1, Math.ceil(total / perPage)),
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
// Fail soft so the dashboard can render an empty state instead of
|
|
67
|
-
// an opaque 500. Surface the underlying message so it's visible
|
|
68
|
-
// in the dev-mode error toast.
|
|
69
|
-
return {
|
|
70
|
-
items: [],
|
|
71
|
-
total: 0,
|
|
72
|
-
page,
|
|
73
|
-
perPage,
|
|
74
|
-
totalPages: 1,
|
|
75
|
-
error: err instanceof Error ? err.message : String(err),
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
interface NormalizedJob {
|
|
82
|
-
id: string
|
|
83
|
-
name: string
|
|
84
|
-
queue: string
|
|
85
|
-
status: 'queued' | 'processing' | 'completed' | 'failed'
|
|
86
|
-
attempts: number
|
|
87
|
-
runtime?: number
|
|
88
|
-
started_at?: string
|
|
89
|
-
finished_at?: string
|
|
90
|
-
error?: string
|
|
91
|
-
payload: unknown
|
|
92
|
-
created_at?: string
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function normalizePending(row: Record<string, unknown>, statusFilter: string): NormalizedJob | null {
|
|
96
|
-
const status: NormalizedJob['status'] = row.reserved_at ? 'processing' : 'queued'
|
|
97
|
-
if (statusFilter !== 'all' && statusFilter !== status) return null
|
|
98
|
-
let payload: unknown = row.payload
|
|
99
|
-
let name = 'unknown'
|
|
100
|
-
if (typeof payload === 'string') {
|
|
101
|
-
try {
|
|
102
|
-
const parsed = JSON.parse(payload) as { jobName?: string }
|
|
103
|
-
name = parsed.jobName ?? 'unknown'
|
|
104
|
-
payload = parsed
|
|
105
|
-
}
|
|
106
|
-
catch { /* leave as raw string */ }
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
id: String(row.id ?? ''),
|
|
110
|
-
name,
|
|
111
|
-
queue: String(row.queue ?? 'default'),
|
|
112
|
-
status,
|
|
113
|
-
attempts: Number(row.attempts ?? 0),
|
|
114
|
-
payload,
|
|
115
|
-
created_at: row.created_at ? String(row.created_at) : undefined,
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function normalizeFailed(row: Record<string, unknown>): NormalizedJob {
|
|
120
|
-
let payload: unknown = row.payload
|
|
121
|
-
let name = 'unknown'
|
|
122
|
-
if (typeof payload === 'string') {
|
|
123
|
-
try {
|
|
124
|
-
const parsed = JSON.parse(payload) as { jobName?: string }
|
|
125
|
-
name = parsed.jobName ?? 'unknown'
|
|
126
|
-
payload = parsed
|
|
127
|
-
}
|
|
128
|
-
catch { /* leave as raw */ }
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
id: String(row.id ?? ''),
|
|
132
|
-
name,
|
|
133
|
-
queue: String(row.queue ?? 'default'),
|
|
134
|
-
status: 'failed',
|
|
135
|
-
attempts: Number(row.attempts ?? 0),
|
|
136
|
-
error: row.exception ? String(row.exception) : undefined,
|
|
137
|
-
finished_at: row.failed_at ? String(row.failed_at) : undefined,
|
|
138
|
-
payload,
|
|
139
|
-
created_at: row.failed_at ? String(row.failed_at) : undefined,
|
|
140
|
-
}
|
|
141
|
-
}
|