create-fullstack-scaffold 0.4.12 → 0.4.13
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/package.json
CHANGED
|
@@ -86,12 +86,16 @@ export const NotificationDrawer: React.FC<NotificationDrawerProps> = ({
|
|
|
86
86
|
className="p-4 cursor-pointer transition-colors"
|
|
87
87
|
style={{
|
|
88
88
|
borderBottom: `1px solid ${token.colorBorderSecondary}`,
|
|
89
|
-
backgroundColor: !notif.read ?
|
|
89
|
+
backgroundColor: !notif.read ? token.colorInfoBg ?? 'transparent' : undefined,
|
|
90
90
|
}}
|
|
91
91
|
onClick={() => !notif.read && onMarkAsRead(notif.id)}
|
|
92
|
-
onMouseEnter={e =>
|
|
92
|
+
onMouseEnter={e =>
|
|
93
|
+
(e.currentTarget.style.backgroundColor = token.colorBgTextHover ?? 'transparent')
|
|
94
|
+
}
|
|
93
95
|
onMouseLeave={e =>
|
|
94
|
-
(e.currentTarget.style.backgroundColor = !notif.read
|
|
96
|
+
(e.currentTarget.style.backgroundColor = !notif.read
|
|
97
|
+
? token.colorInfoBg ?? 'transparent'
|
|
98
|
+
: 'transparent')
|
|
95
99
|
}
|
|
96
100
|
>
|
|
97
101
|
<div className="flex items-start gap-3">
|
|
@@ -4,6 +4,20 @@ import { z } from 'zod'
|
|
|
4
4
|
import { getClient } from '@cli/utils/api'
|
|
5
5
|
import type { Role } from '@shared/modules/permission'
|
|
6
6
|
|
|
7
|
+
const createUserParams = z.object({
|
|
8
|
+
username: z.string().min(1).describe('Username'),
|
|
9
|
+
email: z.string().email().describe('Email'),
|
|
10
|
+
password: z.string().min(6).describe('Password'),
|
|
11
|
+
role: z.enum(['super_admin', 'customer_service', 'user']).default('user').describe('Role'),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const updateUserParams = z.object({
|
|
15
|
+
id: z.string().describe('User ID'),
|
|
16
|
+
username: z.string().optional().describe('New username'),
|
|
17
|
+
email: z.string().email().optional().describe('New email'),
|
|
18
|
+
role: z.enum(['super_admin', 'customer_service', 'user']).optional().describe('New role'),
|
|
19
|
+
})
|
|
20
|
+
|
|
7
21
|
export function registerAdminCommands(site: SiteInstance) {
|
|
8
22
|
site.command('dashboard', {
|
|
9
23
|
description: 'Get dashboard statistics',
|
|
@@ -85,15 +99,10 @@ export function registerAdminCommands(site: SiteInstance) {
|
|
|
85
99
|
|
|
86
100
|
site.command('create-user', {
|
|
87
101
|
description: 'Create a new user',
|
|
88
|
-
parameters:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
role: z.enum(['super_admin', 'customer_service', 'user']).default('user').describe('Role'),
|
|
93
|
-
}),
|
|
94
|
-
handler: async (params: unknown) => {
|
|
95
|
-
type CreateParams = { username: string; email: string; password: string; role: 'super_admin' | 'customer_service' | 'user' }
|
|
96
|
-
const p = params as CreateParams
|
|
102
|
+
parameters: createUserParams,
|
|
103
|
+
handler: async params => {
|
|
104
|
+
// @ts-expect-error -- auto-command passes unknown, we parse from zod schema
|
|
105
|
+
const p: z.infer<typeof createUserParams> = params
|
|
97
106
|
try {
|
|
98
107
|
const client = getClient()
|
|
99
108
|
const res = await client.api.admin.users.$post({
|
|
@@ -101,6 +110,8 @@ export function registerAdminCommands(site: SiteInstance) {
|
|
|
101
110
|
username: p.username,
|
|
102
111
|
email: p.email,
|
|
103
112
|
password: p.password,
|
|
113
|
+
// Role enum values overlap with z.enum string literals — safe cast for RPC compatibility
|
|
114
|
+
// eslint-disable-next-line local-rules/no-type-assertion-on-shared-types
|
|
104
115
|
role: p.role as Role,
|
|
105
116
|
},
|
|
106
117
|
})
|
|
@@ -114,15 +125,10 @@ export function registerAdminCommands(site: SiteInstance) {
|
|
|
114
125
|
|
|
115
126
|
site.command('update-user', {
|
|
116
127
|
description: 'Update a user',
|
|
117
|
-
parameters:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
role: z.enum(['super_admin', 'customer_service', 'user']).optional().describe('New role'),
|
|
122
|
-
}),
|
|
123
|
-
handler: async (params: unknown) => {
|
|
124
|
-
type UpdateParams = { id: string; username?: string; email?: string; role?: 'super_admin' | 'customer_service' | 'user' }
|
|
125
|
-
const p = params as UpdateParams
|
|
128
|
+
parameters: updateUserParams,
|
|
129
|
+
handler: async params => {
|
|
130
|
+
// @ts-expect-error -- auto-command passes unknown, we parse from zod schema
|
|
131
|
+
const p: z.infer<typeof updateUserParams> = params
|
|
126
132
|
const { id, ...rest } = p
|
|
127
133
|
const body: Record<string, string | undefined> = {}
|
|
128
134
|
if (rest.username) body.username = rest.username
|
|
@@ -14,6 +14,7 @@ import { registerOrderCommands } from './order'
|
|
|
14
14
|
import { registerPermissionCommands } from './permission'
|
|
15
15
|
import { registerTenantCommands } from './tenant'
|
|
16
16
|
import { registerTicketCommands } from './ticket'
|
|
17
|
+
import { registerMerchantCommands } from './merchant'
|
|
17
18
|
|
|
18
19
|
export function registerBuiltinCommands(app: Core) {
|
|
19
20
|
const api = app.loader.getAPI()
|
|
@@ -38,6 +39,7 @@ export function registerBuiltinCommands(app: Core) {
|
|
|
38
39
|
registerPermissionCommands(site)
|
|
39
40
|
registerTenantCommands(site)
|
|
40
41
|
registerTicketCommands(site)
|
|
42
|
+
registerMerchantCommands(site)
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export {
|
|
@@ -56,4 +58,5 @@ export {
|
|
|
56
58
|
registerPermissionCommands,
|
|
57
59
|
registerTenantCommands,
|
|
58
60
|
registerTicketCommands,
|
|
61
|
+
registerMerchantCommands,
|
|
59
62
|
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { SiteInstance } from '@dyyz1993/xcli-core'
|
|
2
|
+
import { ok, fail } from '@dyyz1993/xcli-core'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
import { getClient } from '@cli/utils/api'
|
|
5
|
+
|
|
6
|
+
const createProductParams = z.object({
|
|
7
|
+
name: z.string().min(1).describe('Product name'),
|
|
8
|
+
description: z.string().max(1000).describe('Product description'),
|
|
9
|
+
price: z.coerce.number().positive().describe('Product price'),
|
|
10
|
+
stock: z.coerce.number().int().min(0).default(0).describe('Stock quantity'),
|
|
11
|
+
status: z
|
|
12
|
+
.enum(['active', 'inactive', 'out_of_stock'])
|
|
13
|
+
.default('active')
|
|
14
|
+
.describe('Product status'),
|
|
15
|
+
'image-url': z.string().url().nullable().default(null).describe('Image URL'),
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export function registerMerchantCommands(site: SiteInstance) {
|
|
19
|
+
site.command('login', {
|
|
20
|
+
description: 'Login as merchant',
|
|
21
|
+
parameters: z.object({
|
|
22
|
+
username: z.string().min(1).describe('Merchant username'),
|
|
23
|
+
password: z.string().min(6).describe('Merchant password'),
|
|
24
|
+
}),
|
|
25
|
+
handler: async (params: unknown) => {
|
|
26
|
+
const p = params as { username: string; password: string }
|
|
27
|
+
try {
|
|
28
|
+
const client = getClient()
|
|
29
|
+
const res = await client.api.merchant.login.$post({
|
|
30
|
+
json: { username: p.username, password: p.password },
|
|
31
|
+
})
|
|
32
|
+
const data = await res.json()
|
|
33
|
+
return ok(data)
|
|
34
|
+
} catch (err) {
|
|
35
|
+
return fail(err instanceof Error ? err.message : 'Failed to login')
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
site.command('me', {
|
|
41
|
+
description: 'Get current merchant profile',
|
|
42
|
+
parameters: z.object({}),
|
|
43
|
+
handler: async () => {
|
|
44
|
+
try {
|
|
45
|
+
const client = getClient()
|
|
46
|
+
const res = await client.api.merchant.me.$get()
|
|
47
|
+
const data = await res.json()
|
|
48
|
+
return ok(data)
|
|
49
|
+
} catch (err) {
|
|
50
|
+
return fail(err instanceof Error ? err.message : 'Failed to get merchant profile')
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
site.command('stats', {
|
|
56
|
+
description: 'Get merchant statistics',
|
|
57
|
+
parameters: z.object({}),
|
|
58
|
+
handler: async () => {
|
|
59
|
+
try {
|
|
60
|
+
const client = getClient()
|
|
61
|
+
const res = await client.api.merchant.stats.$get()
|
|
62
|
+
const data = await res.json()
|
|
63
|
+
return ok(data)
|
|
64
|
+
} catch (err) {
|
|
65
|
+
return fail(err instanceof Error ? err.message : 'Failed to get merchant stats')
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
site.command('list-products', {
|
|
71
|
+
description: 'List merchant products',
|
|
72
|
+
parameters: z.object({
|
|
73
|
+
page: z.coerce.number().int().positive().default(1).describe('Page number'),
|
|
74
|
+
'page-size': z.coerce.number().int().positive().max(100).default(20).describe('Page size'),
|
|
75
|
+
status: z
|
|
76
|
+
.enum(['active', 'inactive', 'out_of_stock'])
|
|
77
|
+
.optional()
|
|
78
|
+
.describe('Filter by status'),
|
|
79
|
+
}),
|
|
80
|
+
handler: async (params: unknown) => {
|
|
81
|
+
const p = params as { page: number; 'page-size': number; status?: string }
|
|
82
|
+
try {
|
|
83
|
+
const client = getClient()
|
|
84
|
+
const query: Record<string, string> = {
|
|
85
|
+
page: String(p.page),
|
|
86
|
+
pageSize: String(p['page-size']),
|
|
87
|
+
}
|
|
88
|
+
if (p.status) query.status = p.status
|
|
89
|
+
const res = await client.api.merchant.products.$get({ query })
|
|
90
|
+
const data = await res.json()
|
|
91
|
+
return ok(data)
|
|
92
|
+
} catch (err) {
|
|
93
|
+
return fail(err instanceof Error ? err.message : 'Failed to list products')
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
site.command('create-product', {
|
|
99
|
+
description: 'Create a new product',
|
|
100
|
+
parameters: createProductParams,
|
|
101
|
+
handler: async params => {
|
|
102
|
+
// @ts-expect-error -- auto-command passes unknown, we parse from zod schema
|
|
103
|
+
const p: z.infer<typeof createProductParams> = params
|
|
104
|
+
try {
|
|
105
|
+
const client = getClient()
|
|
106
|
+
const res = await client.api.merchant.products.$post({
|
|
107
|
+
json: {
|
|
108
|
+
name: p.name,
|
|
109
|
+
description: p.description,
|
|
110
|
+
price: p.price,
|
|
111
|
+
stock: p.stock,
|
|
112
|
+
status: p.status,
|
|
113
|
+
imageUrl: p['image-url'],
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
const data = await res.json()
|
|
117
|
+
return ok(data, ['Product created'])
|
|
118
|
+
} catch (err) {
|
|
119
|
+
return fail(err instanceof Error ? err.message : 'Failed to create product')
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
}
|
package/template/vite.config.ts
CHANGED
|
@@ -85,6 +85,11 @@ export default defineConfig({
|
|
|
85
85
|
}),
|
|
86
86
|
],
|
|
87
87
|
},
|
|
88
|
+
onwarn(warning, defaultHandler) {
|
|
89
|
+
// Suppress antd "use client" directive warnings (React Server Components marker)
|
|
90
|
+
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') return
|
|
91
|
+
defaultHandler(warning)
|
|
92
|
+
},
|
|
88
93
|
},
|
|
89
94
|
},
|
|
90
95
|
resolve: {
|