@murumets-ee/create 0.1.14 → 0.1.16
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/dist/cli.mjs +463 -3
- package/dist/index.mjs +463 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import{i as e,n as t,o as n,r,t as i}from"./utils-Bmw75lEa.mjs";import{join as a}from"node:path";import{mkdir as o}from"node:fs/promises";async function s(e,t){await n(a(e,`lib/admin-config.ts`),`import { Media } from '@murumets-ee/media'
|
|
2
|
+
import {
|
|
3
|
+
Ticket,
|
|
4
|
+
TicketMessage,
|
|
5
|
+
TicketAttachment,
|
|
6
|
+
Department,
|
|
7
|
+
TicketTag,
|
|
8
|
+
} from '@murumets-ee/ticketing'
|
|
2
9
|
import { Article, Category } from '@/entities'
|
|
3
10
|
|
|
4
11
|
/** All entities available in the admin (drives sidebar nav + CRUD) */
|
|
5
|
-
export const allEntities = [
|
|
12
|
+
export const allEntities = [
|
|
13
|
+
Article, Media, Category,
|
|
14
|
+
Ticket, TicketMessage, TicketAttachment, Department, TicketTag,
|
|
15
|
+
]
|
|
6
16
|
|
|
7
17
|
/** Taxonomy entities keyed by name */
|
|
8
|
-
export const taxonomyVocabularies = {
|
|
18
|
+
export const taxonomyVocabularies = {
|
|
19
|
+
category: Category,
|
|
20
|
+
department: Department,
|
|
21
|
+
ticket_tag: TicketTag,
|
|
22
|
+
}
|
|
9
23
|
|
|
10
24
|
/** Entities exposed via generic CRUD API handler */
|
|
11
|
-
export const crudEntities = [Article, Media]
|
|
25
|
+
export const crudEntities = [Article, Media, Ticket, TicketMessage, TicketAttachment]
|
|
12
26
|
|
|
13
27
|
/** Plugin resources for the permission catalog */
|
|
14
28
|
export const pluginResources = [
|
|
@@ -16,6 +30,7 @@ export const pluginResources = [
|
|
|
16
30
|
{ resource: 'settings', actions: ['view', 'update'] },
|
|
17
31
|
{ resource: 'audit-logs', actions: ['view'] },
|
|
18
32
|
{ resource: 'permissions', actions: ['view', 'create', 'update', 'delete'] },
|
|
33
|
+
{ resource: 'ticketing', actions: ['view', 'create', 'update', 'delete'] },
|
|
19
34
|
]
|
|
20
35
|
`),await n(a(e,`lib/content-locale.ts`),`import { cookies } from 'next/headers'
|
|
21
36
|
import { hasLocale } from 'next-intl'
|
|
@@ -106,15 +121,20 @@ import { AdminShell } from '@murumets-ee/admin-ui'
|
|
|
106
121
|
import type { AdminNavGroup } from '@murumets-ee/admin-ui/server'
|
|
107
122
|
import {
|
|
108
123
|
Activity,
|
|
124
|
+
Building2,
|
|
109
125
|
FileText,
|
|
110
126
|
FolderTree,
|
|
111
127
|
Home,
|
|
112
128
|
Image,
|
|
113
129
|
ImageDown,
|
|
130
|
+
Inbox,
|
|
131
|
+
Kanban,
|
|
114
132
|
Lock,
|
|
115
133
|
PenTool,
|
|
116
134
|
ShieldCheck,
|
|
135
|
+
Tag,
|
|
117
136
|
Tags,
|
|
137
|
+
Ticket,
|
|
118
138
|
Users,
|
|
119
139
|
type LucideIcon,
|
|
120
140
|
} from 'lucide-react'
|
|
@@ -126,6 +146,7 @@ const ICON_MAP: Record<string, LucideIcon> = {
|
|
|
126
146
|
'file-text': FileText,
|
|
127
147
|
'folder-tree': FolderTree,
|
|
128
148
|
tags: Tags,
|
|
149
|
+
ticket: Ticket,
|
|
129
150
|
}
|
|
130
151
|
|
|
131
152
|
interface AdminLayoutProps {
|
|
@@ -161,6 +182,16 @@ export function AdminLayout({
|
|
|
161
182
|
],
|
|
162
183
|
}
|
|
163
184
|
|
|
185
|
+
const supportGroup: SidebarNavGroup = {
|
|
186
|
+
label: 'Support',
|
|
187
|
+
items: [
|
|
188
|
+
{ label: 'Tickets', href: '/admin/tickets', icon: Inbox },
|
|
189
|
+
{ label: 'Board', href: '/admin/tickets/board', icon: Kanban },
|
|
190
|
+
{ label: 'Departments', href: '/admin/departments', icon: Building2 },
|
|
191
|
+
{ label: 'Ticket Tags', href: '/admin/ticket-tags', icon: Tag },
|
|
192
|
+
],
|
|
193
|
+
}
|
|
194
|
+
|
|
164
195
|
const systemGroup: SidebarNavGroup = {
|
|
165
196
|
label: 'System',
|
|
166
197
|
items: [
|
|
@@ -176,6 +207,7 @@ export function AdminLayout({
|
|
|
176
207
|
const navGroups: SidebarNavGroup[] = [
|
|
177
208
|
staticBefore,
|
|
178
209
|
...dynamicGroups,
|
|
210
|
+
supportGroup,
|
|
179
211
|
systemGroup,
|
|
180
212
|
]
|
|
181
213
|
|
|
@@ -1016,6 +1048,432 @@ export default async function ActivityPage({ params }: { params: Promise<{ local
|
|
|
1016
1048
|
)
|
|
1017
1049
|
})
|
|
1018
1050
|
}
|
|
1051
|
+
`),await n(a(e,`app/[locale]/(shell)/admin/tickets/page.tsx`),`import { Ticket, Department, TicketTag } from '@murumets-ee/ticketing'
|
|
1052
|
+
import { headers } from 'next/headers'
|
|
1053
|
+
import { setRequestLocale } from 'next-intl/server'
|
|
1054
|
+
import { withAdminContext } from '@/lib/with-admin-context'
|
|
1055
|
+
import { auth } from '@/lib/auth'
|
|
1056
|
+
import { TicketsInboxClient } from './tickets-inbox-client'
|
|
1057
|
+
import { fetchEntityList } from '@murumets-ee/admin-ui/server'
|
|
1058
|
+
import type {
|
|
1059
|
+
TicketData,
|
|
1060
|
+
DepartmentData,
|
|
1061
|
+
TagData,
|
|
1062
|
+
} from '@murumets-ee/ticketing-ui'
|
|
1063
|
+
|
|
1064
|
+
interface TicketsPageProps {
|
|
1065
|
+
params: Promise<{ locale: string }>
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
export default async function TicketsPage({ params }: TicketsPageProps) {
|
|
1069
|
+
const { locale } = await params
|
|
1070
|
+
setRequestLocale(locale)
|
|
1071
|
+
|
|
1072
|
+
const h = await headers()
|
|
1073
|
+
const session = await auth.api.getSession({ headers: h })
|
|
1074
|
+
const currentUserId = session?.user?.id ?? ''
|
|
1075
|
+
|
|
1076
|
+
return withAdminContext(locale, async () => {
|
|
1077
|
+
const ticketData = await fetchEntityList(Ticket, {
|
|
1078
|
+
sortField: 'lastReplyAt',
|
|
1079
|
+
sortDirection: 'desc',
|
|
1080
|
+
limit: 50,
|
|
1081
|
+
})
|
|
1082
|
+
|
|
1083
|
+
const departmentData = await fetchEntityList(Department, {
|
|
1084
|
+
sortField: 'name',
|
|
1085
|
+
sortDirection: 'asc',
|
|
1086
|
+
limit: 100,
|
|
1087
|
+
})
|
|
1088
|
+
|
|
1089
|
+
const tagData = await fetchEntityList(TicketTag, {
|
|
1090
|
+
sortField: 'name',
|
|
1091
|
+
sortDirection: 'asc',
|
|
1092
|
+
limit: 100,
|
|
1093
|
+
})
|
|
1094
|
+
|
|
1095
|
+
return (
|
|
1096
|
+
<TicketsInboxClient
|
|
1097
|
+
initialTickets={ticketData.items as unknown as TicketData[]}
|
|
1098
|
+
initialTotal={ticketData.total}
|
|
1099
|
+
initialDepartments={departmentData.items as unknown as DepartmentData[]}
|
|
1100
|
+
initialTags={tagData.items as unknown as TagData[]}
|
|
1101
|
+
currentUserId={currentUserId}
|
|
1102
|
+
locale={locale}
|
|
1103
|
+
/>
|
|
1104
|
+
)
|
|
1105
|
+
})
|
|
1106
|
+
}
|
|
1107
|
+
`),await n(a(e,`app/[locale]/(shell)/admin/tickets/tickets-inbox-client.tsx`),`'use client'
|
|
1108
|
+
|
|
1109
|
+
import { QueryProvider } from '@murumets-ee/admin-ui'
|
|
1110
|
+
import { InboxProvider, TicketInbox } from '@murumets-ee/ticketing-ui/inbox'
|
|
1111
|
+
import type {
|
|
1112
|
+
TicketData,
|
|
1113
|
+
DepartmentData,
|
|
1114
|
+
TagData,
|
|
1115
|
+
} from '@murumets-ee/ticketing-ui'
|
|
1116
|
+
|
|
1117
|
+
interface TicketsInboxClientProps {
|
|
1118
|
+
initialTickets: TicketData[]
|
|
1119
|
+
initialTotal: number
|
|
1120
|
+
initialDepartments: DepartmentData[]
|
|
1121
|
+
initialTags: TagData[]
|
|
1122
|
+
currentUserId: string
|
|
1123
|
+
locale: string
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
export function TicketsInboxClient({
|
|
1127
|
+
initialTickets,
|
|
1128
|
+
initialTotal,
|
|
1129
|
+
initialDepartments,
|
|
1130
|
+
initialTags,
|
|
1131
|
+
currentUserId,
|
|
1132
|
+
}: TicketsInboxClientProps) {
|
|
1133
|
+
return (
|
|
1134
|
+
<QueryProvider>
|
|
1135
|
+
<InboxProvider
|
|
1136
|
+
apiBasePath="/api/admin"
|
|
1137
|
+
initialTickets={initialTickets}
|
|
1138
|
+
initialTotal={initialTotal}
|
|
1139
|
+
initialDepartments={initialDepartments}
|
|
1140
|
+
initialTags={initialTags}
|
|
1141
|
+
currentUserId={currentUserId}
|
|
1142
|
+
>
|
|
1143
|
+
<div className="h-[calc(100vh-3.5rem)]">
|
|
1144
|
+
<TicketInbox currentUserId={currentUserId} />
|
|
1145
|
+
</div>
|
|
1146
|
+
</InboxProvider>
|
|
1147
|
+
</QueryProvider>
|
|
1148
|
+
)
|
|
1149
|
+
}
|
|
1150
|
+
`),await n(a(e,`app/[locale]/(shell)/admin/tickets/board/page.tsx`),`import { Ticket, Department } from '@murumets-ee/ticketing'
|
|
1151
|
+
import { setRequestLocale } from 'next-intl/server'
|
|
1152
|
+
import { withAdminContext } from '@/lib/with-admin-context'
|
|
1153
|
+
import { fetchEntityList } from '@murumets-ee/admin-ui/server'
|
|
1154
|
+
import { TicketBoardClient } from './ticket-board-client'
|
|
1155
|
+
import type { TicketData, DepartmentData } from '@murumets-ee/ticketing-ui'
|
|
1156
|
+
|
|
1157
|
+
interface TicketBoardPageProps {
|
|
1158
|
+
params: Promise<{ locale: string }>
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
export default async function TicketBoardPage({ params }: TicketBoardPageProps) {
|
|
1162
|
+
const { locale } = await params
|
|
1163
|
+
setRequestLocale(locale)
|
|
1164
|
+
|
|
1165
|
+
return withAdminContext(locale, async () => {
|
|
1166
|
+
const ticketData = await fetchEntityList(Ticket, {
|
|
1167
|
+
sortField: 'lastReplyAt',
|
|
1168
|
+
sortDirection: 'desc',
|
|
1169
|
+
limit: 200,
|
|
1170
|
+
})
|
|
1171
|
+
|
|
1172
|
+
const departmentData = await fetchEntityList(Department, {
|
|
1173
|
+
sortField: 'name',
|
|
1174
|
+
sortDirection: 'asc',
|
|
1175
|
+
limit: 100,
|
|
1176
|
+
})
|
|
1177
|
+
|
|
1178
|
+
return (
|
|
1179
|
+
<div className="p-6 h-[calc(100vh-3.5rem)]">
|
|
1180
|
+
<div className="mb-4">
|
|
1181
|
+
<h1 className="text-2xl font-bold">Ticket Board</h1>
|
|
1182
|
+
<p className="text-sm text-muted-foreground">
|
|
1183
|
+
Kanban view of tickets by status
|
|
1184
|
+
</p>
|
|
1185
|
+
</div>
|
|
1186
|
+
<TicketBoardClient
|
|
1187
|
+
initialTickets={ticketData.items as unknown as TicketData[]}
|
|
1188
|
+
initialDepartments={departmentData.items as unknown as DepartmentData[]}
|
|
1189
|
+
locale={locale}
|
|
1190
|
+
/>
|
|
1191
|
+
</div>
|
|
1192
|
+
)
|
|
1193
|
+
})
|
|
1194
|
+
}
|
|
1195
|
+
`),await n(a(e,`app/[locale]/(shell)/admin/tickets/board/ticket-board-client.tsx`),`'use client'
|
|
1196
|
+
|
|
1197
|
+
import { useMemo } from 'react'
|
|
1198
|
+
import { TicketBoard } from '@murumets-ee/ticketing-ui/board'
|
|
1199
|
+
import type { TicketData, DepartmentData } from '@murumets-ee/ticketing-ui'
|
|
1200
|
+
import { useRouter } from 'next/navigation'
|
|
1201
|
+
|
|
1202
|
+
interface TicketBoardClientProps {
|
|
1203
|
+
initialTickets: TicketData[]
|
|
1204
|
+
initialDepartments: DepartmentData[]
|
|
1205
|
+
locale: string
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
export function TicketBoardClient({
|
|
1209
|
+
initialTickets,
|
|
1210
|
+
initialDepartments,
|
|
1211
|
+
locale,
|
|
1212
|
+
}: TicketBoardClientProps) {
|
|
1213
|
+
const router = useRouter()
|
|
1214
|
+
const departmentMap = useMemo(
|
|
1215
|
+
() => new Map(initialDepartments.map((d) => [d.id, d])),
|
|
1216
|
+
[initialDepartments],
|
|
1217
|
+
)
|
|
1218
|
+
|
|
1219
|
+
return (
|
|
1220
|
+
<TicketBoard
|
|
1221
|
+
tickets={initialTickets}
|
|
1222
|
+
departments={departmentMap}
|
|
1223
|
+
onTicketSelect={(ticket) => {
|
|
1224
|
+
router.push(\`/\${locale}/admin/tickets?selected=\${ticket.id}\`)
|
|
1225
|
+
}}
|
|
1226
|
+
className="h-[calc(100%-4rem)]"
|
|
1227
|
+
/>
|
|
1228
|
+
)
|
|
1229
|
+
}
|
|
1230
|
+
`),await n(a(e,`app/api/ticketing/inbound/route.ts`),`/**
|
|
1231
|
+
* Resend inbound email webhook endpoint.
|
|
1232
|
+
*
|
|
1233
|
+
* Public endpoint (no session auth) — protected by webhook signature
|
|
1234
|
+
* verification (HMAC-SHA256). Lives outside the admin API handler
|
|
1235
|
+
* because the admin handler requires authentication.
|
|
1236
|
+
*/
|
|
1237
|
+
|
|
1238
|
+
import { getToolkitApp } from '@/lib/app'
|
|
1239
|
+
|
|
1240
|
+
await getToolkitApp()
|
|
1241
|
+
|
|
1242
|
+
export async function POST(req: Request): Promise<Response> {
|
|
1243
|
+
const { handleInboundWebhook } = await import('@murumets-ee/ticketing')
|
|
1244
|
+
const { QueueClient } = await import('@murumets-ee/queue/client')
|
|
1245
|
+
const { getApp } = await import('@murumets-ee/core')
|
|
1246
|
+
|
|
1247
|
+
const db = getApp().db.readWrite
|
|
1248
|
+
const queueClient = new QueueClient({ db })
|
|
1249
|
+
|
|
1250
|
+
return handleInboundWebhook(req, (type, payload) => queueClient.enqueue(type, payload))
|
|
1251
|
+
}
|
|
1252
|
+
`),await n(a(e,`app/[locale]/(shell)/admin/seed/actions.ts`),`'use server'
|
|
1253
|
+
|
|
1254
|
+
import { AdminClient } from '@murumets-ee/entity/admin'
|
|
1255
|
+
import { createTaxonomyClient } from '@murumets-ee/taxonomy/client'
|
|
1256
|
+
import { Ticket, TicketMessage, Department, TicketTag } from '@murumets-ee/ticketing'
|
|
1257
|
+
import { headers } from 'next/headers'
|
|
1258
|
+
import { Article, Category } from '@/entities'
|
|
1259
|
+
import { getToolkitApp } from '@/lib/app'
|
|
1260
|
+
import { auth } from '@/lib/auth'
|
|
1261
|
+
|
|
1262
|
+
async function requireAdmin() {
|
|
1263
|
+
const session = await auth.api.getSession({ headers: await headers() })
|
|
1264
|
+
if (!session?.user) throw new Error('Unauthorized')
|
|
1265
|
+
const role = (session.user as Record<string, unknown>).role as string | undefined
|
|
1266
|
+
if (role !== 'admin') throw new Error('Forbidden: admin role required')
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
export async function seedContent() {
|
|
1270
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1271
|
+
return { error: 'Seed disabled in production' }
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
await requireAdmin()
|
|
1275
|
+
const app = await getToolkitApp()
|
|
1276
|
+
const categories = createTaxonomyClient(Category)
|
|
1277
|
+
const articles = new AdminClient({
|
|
1278
|
+
entity: Article,
|
|
1279
|
+
db: app.db.readWrite,
|
|
1280
|
+
logger: app.logger.child({ entity: 'article' }),
|
|
1281
|
+
})
|
|
1282
|
+
|
|
1283
|
+
const techCat = await categories.create({ name: 'Technology', slug: 'technology', color: '#3B82F6' })
|
|
1284
|
+
const newsCat = await categories.create({ name: 'News', slug: 'news', color: '#EF4444' })
|
|
1285
|
+
|
|
1286
|
+
await articles.create({
|
|
1287
|
+
title: 'Getting Started with Lumi CMS',
|
|
1288
|
+
slug: 'getting-started',
|
|
1289
|
+
excerpt: 'Learn how to build apps with the toolkit',
|
|
1290
|
+
body: [{ type: 'p', children: [{ text: 'A guide to getting started with Lumi CMS.' }] }],
|
|
1291
|
+
category: techCat.id as string,
|
|
1292
|
+
status: 'published',
|
|
1293
|
+
publishedAt: new Date(),
|
|
1294
|
+
})
|
|
1295
|
+
|
|
1296
|
+
await articles.create({
|
|
1297
|
+
title: 'Lumi CMS v1.0 Released',
|
|
1298
|
+
slug: 'v1-released',
|
|
1299
|
+
excerpt: 'We are excited to announce version 1.0',
|
|
1300
|
+
body: [{ type: 'p', children: [{ text: 'After months of development, v1.0 is here.' }] }],
|
|
1301
|
+
category: newsCat.id as string,
|
|
1302
|
+
status: 'published',
|
|
1303
|
+
publishedAt: new Date(),
|
|
1304
|
+
})
|
|
1305
|
+
|
|
1306
|
+
return { ok: true, created: { categories: 2, articles: 2 } }
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
export async function seedTicketing() {
|
|
1310
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1311
|
+
return { error: 'Seed disabled in production' }
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
await requireAdmin()
|
|
1315
|
+
const app = await getToolkitApp()
|
|
1316
|
+
|
|
1317
|
+
const deptClient = createTaxonomyClient(Department)
|
|
1318
|
+
const tagClient = createTaxonomyClient(TicketTag)
|
|
1319
|
+
const ticketAdmin = new AdminClient({
|
|
1320
|
+
entity: Ticket,
|
|
1321
|
+
db: app.db.readWrite,
|
|
1322
|
+
logger: app.logger.child({ entity: 'ticket' }),
|
|
1323
|
+
})
|
|
1324
|
+
const messageAdmin = new AdminClient({
|
|
1325
|
+
entity: TicketMessage,
|
|
1326
|
+
db: app.db.readWrite,
|
|
1327
|
+
logger: app.logger.child({ entity: 'ticket_message' }),
|
|
1328
|
+
})
|
|
1329
|
+
|
|
1330
|
+
const support = await deptClient.create({
|
|
1331
|
+
name: 'General Support', slug: 'general-support', color: '#3B82F6',
|
|
1332
|
+
description: 'General customer support inquiries',
|
|
1333
|
+
emailAddress: 'support@example.com',
|
|
1334
|
+
slaFirstResponseHours: 4, slaResolutionHours: 24,
|
|
1335
|
+
})
|
|
1336
|
+
const billing = await deptClient.create({
|
|
1337
|
+
name: 'Billing', slug: 'billing', color: '#10B981',
|
|
1338
|
+
description: 'Payment and invoice questions',
|
|
1339
|
+
emailAddress: 'billing@example.com',
|
|
1340
|
+
slaFirstResponseHours: 2, slaResolutionHours: 12,
|
|
1341
|
+
})
|
|
1342
|
+
const technical = await deptClient.create({
|
|
1343
|
+
name: 'Technical', slug: 'technical', color: '#8B5CF6',
|
|
1344
|
+
description: 'Technical issues and bug reports',
|
|
1345
|
+
emailAddress: 'tech@example.com',
|
|
1346
|
+
slaFirstResponseHours: 1, slaResolutionHours: 8,
|
|
1347
|
+
})
|
|
1348
|
+
|
|
1349
|
+
const bugTag = await tagClient.create({ name: 'Bug', slug: 'bug', color: '#EF4444' })
|
|
1350
|
+
const featureTag = await tagClient.create({ name: 'Feature Request', slug: 'feature-request', color: '#F59E0B' })
|
|
1351
|
+
const urgentTag = await tagClient.create({ name: 'Urgent', slug: 'urgent', color: '#DC2626' })
|
|
1352
|
+
await tagClient.create({ name: 'Feedback', slug: 'feedback', color: '#06B6D4' })
|
|
1353
|
+
await tagClient.create({ name: 'Documentation', slug: 'documentation', color: '#6366F1' })
|
|
1354
|
+
|
|
1355
|
+
const now = Date.now()
|
|
1356
|
+
let counter = 0
|
|
1357
|
+
|
|
1358
|
+
async function createTicket(opts: {
|
|
1359
|
+
subject: string; department: string; status: string; priority: string;
|
|
1360
|
+
requesterEmail: string; requesterName: string; tags?: string[];
|
|
1361
|
+
messages: Array<{ body: string; senderType: string; senderEmail: string; senderName: string; visibility?: string; minutesAgo: number }>
|
|
1362
|
+
}) {
|
|
1363
|
+
counter++
|
|
1364
|
+
const lastMsg = opts.messages[opts.messages.length - 1]
|
|
1365
|
+
const ticket = await ticketAdmin.create({
|
|
1366
|
+
subject: opts.subject, status: opts.status, priority: opts.priority,
|
|
1367
|
+
department: opts.department, requesterEmail: opts.requesterEmail,
|
|
1368
|
+
requesterName: opts.requesterName,
|
|
1369
|
+
ticketNumber: \`TK-\${String(counter).padStart(6, '0')}\`,
|
|
1370
|
+
lastReplyAt: new Date(now - lastMsg.minutesAgo * 60_000),
|
|
1371
|
+
lastReplierType: lastMsg.senderType,
|
|
1372
|
+
tags: opts.tags ?? [],
|
|
1373
|
+
})
|
|
1374
|
+
for (const msg of opts.messages) {
|
|
1375
|
+
await messageAdmin.create({
|
|
1376
|
+
ticket: ticket.id, body: msg.body, bodyFormat: 'html',
|
|
1377
|
+
senderType: msg.senderType, senderEmail: msg.senderEmail,
|
|
1378
|
+
senderName: msg.senderName, visibility: msg.visibility ?? 'public',
|
|
1379
|
+
})
|
|
1380
|
+
}
|
|
1381
|
+
return ticket
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
await createTicket({
|
|
1385
|
+
subject: 'API returns 500 error on file upload',
|
|
1386
|
+
department: technical.id as string, status: 'open', priority: 'high',
|
|
1387
|
+
requesterEmail: 'john@acme.com', requesterName: 'John Smith',
|
|
1388
|
+
tags: [bugTag.id as string, urgentTag.id as string],
|
|
1389
|
+
messages: [
|
|
1390
|
+
{ body: '<p>When I upload files larger than 5MB, I get a 500 error. Started after the last update.</p>', senderType: 'customer', senderEmail: 'john@acme.com', senderName: 'John Smith', minutesAgo: 120 },
|
|
1391
|
+
{ body: '<p>Thanks for reporting this. I can see the error in our logs. Escalating to backend team.</p>', senderType: 'agent', senderEmail: 'sarah@support.com', senderName: 'Sarah Chen', minutesAgo: 90 },
|
|
1392
|
+
{ body: '<p>Any update? We have a deadline tomorrow.</p>', senderType: 'customer', senderEmail: 'john@acme.com', senderName: 'John Smith', minutesAgo: 30 },
|
|
1393
|
+
],
|
|
1394
|
+
})
|
|
1395
|
+
|
|
1396
|
+
await createTicket({
|
|
1397
|
+
subject: 'Invoice #2024-0847 has incorrect amount',
|
|
1398
|
+
department: billing.id as string, status: 'pending', priority: 'normal',
|
|
1399
|
+
requesterEmail: 'maria@startup.io', requesterName: 'Maria Garcia',
|
|
1400
|
+
messages: [
|
|
1401
|
+
{ body: '<p>Invoice #2024-0847 shows $299 instead of the agreed $199. Please correct.</p>', senderType: 'customer', senderEmail: 'maria@startup.io', senderName: 'Maria Garcia', minutesAgo: 1440 },
|
|
1402
|
+
{ body: '<p>Apologies for the discrepancy. Checking with billing team, should be resolved in 24h.</p>', senderType: 'agent', senderEmail: 'alex@support.com', senderName: 'Alex Johnson', minutesAgo: 1380 },
|
|
1403
|
+
],
|
|
1404
|
+
})
|
|
1405
|
+
|
|
1406
|
+
await createTicket({
|
|
1407
|
+
subject: 'Production site down — 503 errors',
|
|
1408
|
+
department: technical.id as string, status: 'open', priority: 'urgent',
|
|
1409
|
+
requesterEmail: 'ops@enterprise.co', requesterName: 'Emma Wilson',
|
|
1410
|
+
tags: [bugTag.id as string, urgentTag.id as string],
|
|
1411
|
+
messages: [
|
|
1412
|
+
{ body: '<p><strong>URGENT</strong> — Production returning 503 for all users. Need immediate help.</p>', senderType: 'customer', senderEmail: 'ops@enterprise.co', senderName: 'Emma Wilson', minutesAgo: 15 },
|
|
1413
|
+
],
|
|
1414
|
+
})
|
|
1415
|
+
|
|
1416
|
+
await createTicket({
|
|
1417
|
+
subject: 'Can we get dark mode for the dashboard?',
|
|
1418
|
+
department: support.id as string, status: 'resolved', priority: 'low',
|
|
1419
|
+
requesterEmail: 'dev@techcorp.com', requesterName: 'David Lee',
|
|
1420
|
+
tags: [featureTag.id as string],
|
|
1421
|
+
messages: [
|
|
1422
|
+
{ body: '<p>Would it be possible to add dark mode? Our team works late hours.</p>', senderType: 'customer', senderEmail: 'dev@techcorp.com', senderName: 'David Lee', minutesAgo: 10080 },
|
|
1423
|
+
{ body: '<p>Dark mode just shipped! Toggle it in Settings → Appearance.</p>', senderType: 'agent', senderEmail: 'sarah@support.com', senderName: 'Sarah Chen', minutesAgo: 4320 },
|
|
1424
|
+
{ body: '<p>Perfect, exactly what we needed. Thanks!</p>', senderType: 'customer', senderEmail: 'dev@techcorp.com', senderName: 'David Lee', minutesAgo: 4200 },
|
|
1425
|
+
],
|
|
1426
|
+
})
|
|
1427
|
+
|
|
1428
|
+
return { ok: true, created: { departments: 3, tags: 5, tickets: 4, messages: 9 } }
|
|
1429
|
+
}
|
|
1430
|
+
`),await n(a(e,`app/[locale]/(shell)/admin/seed/page.tsx`),`'use client'
|
|
1431
|
+
|
|
1432
|
+
import { Button } from '@murumets-ee/ui'
|
|
1433
|
+
import { useState } from 'react'
|
|
1434
|
+
import { seedContent, seedTicketing } from './actions'
|
|
1435
|
+
|
|
1436
|
+
export default function SeedPage() {
|
|
1437
|
+
const [result, setResult] = useState<string | null>(null)
|
|
1438
|
+
const [loading, setLoading] = useState(false)
|
|
1439
|
+
|
|
1440
|
+
async function run(action: () => Promise<unknown>) {
|
|
1441
|
+
setLoading(true)
|
|
1442
|
+
setResult(null)
|
|
1443
|
+
try {
|
|
1444
|
+
const res = await action()
|
|
1445
|
+
setResult(JSON.stringify(res, null, 2))
|
|
1446
|
+
} catch (e) {
|
|
1447
|
+
setResult(\`Error: \${e instanceof Error ? e.message : String(e)}\`)
|
|
1448
|
+
} finally {
|
|
1449
|
+
setLoading(false)
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
return (
|
|
1454
|
+
<div className="max-w-2xl mx-auto p-8">
|
|
1455
|
+
<h1 className="text-2xl font-bold mb-2">Seed Data</h1>
|
|
1456
|
+
<p className="text-sm text-zinc-500 dark:text-zinc-400 mb-6">
|
|
1457
|
+
Create demo content for testing. Only available in development mode.
|
|
1458
|
+
</p>
|
|
1459
|
+
|
|
1460
|
+
<div className="flex gap-3 flex-wrap">
|
|
1461
|
+
<Button onClick={() => run(seedContent)} loading={loading}>
|
|
1462
|
+
Seed Content
|
|
1463
|
+
</Button>
|
|
1464
|
+
<Button onClick={() => run(seedTicketing)} loading={loading} variant="secondary">
|
|
1465
|
+
Seed Ticketing
|
|
1466
|
+
</Button>
|
|
1467
|
+
</div>
|
|
1468
|
+
|
|
1469
|
+
{result && (
|
|
1470
|
+
<pre className="mt-6 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-lg p-4 text-sm overflow-auto">
|
|
1471
|
+
{result}
|
|
1472
|
+
</pre>
|
|
1473
|
+
)}
|
|
1474
|
+
</div>
|
|
1475
|
+
)
|
|
1476
|
+
}
|
|
1019
1477
|
`),await n(a(e,`app/api/admin/[...path]/route.ts`),`import { createAdminApiHandler } from '@murumets-ee/admin-ui/server'
|
|
1020
1478
|
import { buildPermissionChecker, buildResourceCatalog } from '@murumets-ee/auth'
|
|
1021
1479
|
import { permissionRoutes } from '@murumets-ee/auth/admin'
|
|
@@ -1035,6 +1493,7 @@ import { createSettingsClient } from '@murumets-ee/settings'
|
|
|
1035
1493
|
import { settingsRoutes } from '@murumets-ee/settings/admin'
|
|
1036
1494
|
import { storageRoutes } from '@murumets-ee/storage/admin'
|
|
1037
1495
|
import { taxonomyRoutes } from '@murumets-ee/taxonomy/admin'
|
|
1496
|
+
import { ticketingRoutes } from '@murumets-ee/ticketing/admin'
|
|
1038
1497
|
import {
|
|
1039
1498
|
allEntities,
|
|
1040
1499
|
crudEntities,
|
|
@@ -1057,6 +1516,7 @@ const routes = [
|
|
|
1057
1516
|
storageRoutes(),
|
|
1058
1517
|
settingsRoutes(siteSettings),
|
|
1059
1518
|
taxonomyRoutes(taxonomyVocabularies),
|
|
1519
|
+
ticketingRoutes(),
|
|
1060
1520
|
logRoutes(() => new AuditLogClient(getApp().db.readWrite)),
|
|
1061
1521
|
permissionRoutes({
|
|
1062
1522
|
getStatements: () => buildResourceCatalog(allEntities, pluginResources),
|