create-simone-app 0.1.0
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/README.md +70 -0
- package/bin/create-simone-app.ts +6 -0
- package/package.json +61 -0
- package/src/cli.ts +97 -0
- package/src/matrix.ts +39 -0
- package/src/options.ts +137 -0
- package/src/prompts.ts +108 -0
- package/src/scaffold.ts +304 -0
- package/src/templates.ts +77 -0
- package/templates/api/base/.agents/skills/ai-rules/SKILL.md +12 -0
- package/templates/api/base/.agents/skills/plan-feature/SKILL.md +13 -0
- package/templates/api/base/.agents/skills/review-diff/SKILL.md +12 -0
- package/templates/api/base/.agents/skills/tdd-step/SKILL.md +14 -0
- package/templates/api/base/.claude/agents/reviewer.md +20 -0
- package/templates/api/base/.claude/hooks/format.sh +22 -0
- package/templates/api/base/.claude/settings.json +38 -0
- package/templates/api/base/.codex/agents/reviewer.toml +7 -0
- package/templates/api/base/.codex/config.toml +10 -0
- package/templates/api/base/.codex/hooks.json +12 -0
- package/templates/api/base/.env.example +2 -0
- package/templates/api/base/.github/workflows/ci.yml +18 -0
- package/templates/api/base/.prettierignore +10 -0
- package/templates/api/base/.prettierrc +20 -0
- package/templates/api/base/CLAUDE.md +1 -0
- package/templates/api/base/README.md +43 -0
- package/templates/api/base/TASK.md.template +30 -0
- package/templates/api/base/_gitignore +8 -0
- package/templates/api/base/docs/agents/base.md +54 -0
- package/templates/api/base/eslint.config.js +21 -0
- package/templates/api/base/openapi.yaml +233 -0
- package/templates/api/base/package.json +41 -0
- package/templates/api/base/scripts/agents-build.ts +26 -0
- package/templates/api/base/scripts/rules-check.ts +48 -0
- package/templates/api/base/scripts/rules-sync.ts +35 -0
- package/templates/api/base/scripts/rules.config.ts +28 -0
- package/templates/api/base/scripts/seed-regen.ts +64 -0
- package/templates/api/base/src/data/orders.json +187 -0
- package/templates/api/base/src/data/products.json +142 -0
- package/templates/api/base/src/data/repository.ts +55 -0
- package/templates/api/base/src/data/schemas.ts +44 -0
- package/templates/api/base/src/data/users.json +352 -0
- package/templates/api/base/src/lib/appName.ts +2 -0
- package/templates/api/base/src/lib/http-error.ts +14 -0
- package/templates/api/base/src/lib/pagination.ts +55 -0
- package/templates/api/base/src/modules/orders/orders.repository.ts +26 -0
- package/templates/api/base/src/modules/orders/orders.schema.ts +11 -0
- package/templates/api/base/src/modules/products/products.repository.ts +17 -0
- package/templates/api/base/src/modules/products/products.schema.ts +21 -0
- package/templates/api/base/src/modules/stats/stats.repository.ts +37 -0
- package/templates/api/base/src/modules/users/users.repository.ts +26 -0
- package/templates/api/base/src/modules/users/users.schema.ts +15 -0
- package/templates/api/base/test/docs.test.ts +23 -0
- package/templates/api/base/test/health.test.ts +19 -0
- package/templates/api/base/test/orders.test.ts +82 -0
- package/templates/api/base/test/products.test.ts +54 -0
- package/templates/api/base/test/repository.test.ts +45 -0
- package/templates/api/base/test/smoke.test.ts +7 -0
- package/templates/api/base/test/stats.test.ts +40 -0
- package/templates/api/base/test/users.test.ts +84 -0
- package/templates/api/base/tsconfig.json +22 -0
- package/templates/api/base/vitest.config.ts +16 -0
- package/templates/api/variants/features/no-github-ci/variant.json +1 -0
- package/templates/api/variants/framework/express/docs/agents/framework-express.md +9 -0
- package/templates/api/variants/framework/express/src/app.ts +37 -0
- package/templates/api/variants/framework/express/src/middleware/errorHandler.ts +13 -0
- package/templates/api/variants/framework/express/src/middleware/validate.ts +59 -0
- package/templates/api/variants/framework/express/src/modules/docs/docs.router.ts +15 -0
- package/templates/api/variants/framework/express/src/modules/health/health.router.ts +7 -0
- package/templates/api/variants/framework/express/src/modules/orders/orders.router.ts +14 -0
- package/templates/api/variants/framework/express/src/modules/products/products.router.ts +24 -0
- package/templates/api/variants/framework/express/src/modules/stats/stats.router.ts +9 -0
- package/templates/api/variants/framework/express/src/modules/users/users.router.ts +24 -0
- package/templates/api/variants/framework/express/src/server.ts +8 -0
- package/templates/api/variants/framework/express/test/errorHandler.test.ts +89 -0
- package/templates/api/variants/framework/express/variant.json +15 -0
- package/templates/fe/base/.agents/skills/ai-rules/SKILL.md +12 -0
- package/templates/fe/base/.agents/skills/plan-feature/SKILL.md +13 -0
- package/templates/fe/base/.agents/skills/review-diff/SKILL.md +12 -0
- package/templates/fe/base/.agents/skills/tdd-step/SKILL.md +14 -0
- package/templates/fe/base/.claude/agents/reviewer.md +21 -0
- package/templates/fe/base/.claude/hooks/format.sh +22 -0
- package/templates/fe/base/.claude/settings.json +41 -0
- package/templates/fe/base/.codex/agents/reviewer.toml +7 -0
- package/templates/fe/base/.codex/config.toml +10 -0
- package/templates/fe/base/.codex/hooks.json +12 -0
- package/templates/fe/base/.env.example +2 -0
- package/templates/fe/base/.github/workflows/ci.yml +37 -0
- package/templates/fe/base/.prettierignore +14 -0
- package/templates/fe/base/.prettierrc +20 -0
- package/templates/fe/base/CLAUDE.md +1 -0
- package/templates/fe/base/README.md +37 -0
- package/templates/fe/base/TASK.md.template +31 -0
- package/templates/fe/base/_gitignore +11 -0
- package/templates/fe/base/docs/agents/base.md +69 -0
- package/templates/fe/base/e2e/users.spec.ts +82 -0
- package/templates/fe/base/eslint.config.js +169 -0
- package/templates/fe/base/index.html +13 -0
- package/templates/fe/base/package.json +63 -0
- package/templates/fe/base/playwright.config.ts +17 -0
- package/templates/fe/base/public/favicon.svg +1 -0
- package/templates/fe/base/public/icons.svg +24 -0
- package/templates/fe/base/scripts/agents-build.ts +26 -0
- package/templates/fe/base/scripts/rules-check.ts +48 -0
- package/templates/fe/base/scripts/rules-sync.ts +35 -0
- package/templates/fe/base/scripts/rules.config.ts +35 -0
- package/templates/fe/base/src/components/shared/EmptyState.tsx +23 -0
- package/templates/fe/base/src/components/shared/ErrorState.tsx +37 -0
- package/templates/fe/base/src/components/shared/PageHeader.tsx +21 -0
- package/templates/fe/base/src/features/users/UserSearch.tsx +48 -0
- package/templates/fe/base/src/features/users/UsersPage.tsx +58 -0
- package/templates/fe/base/src/features/users/UsersTable.tsx +245 -0
- package/templates/fe/base/src/features/users/UsersTableSkeleton.tsx +16 -0
- package/templates/fe/base/src/features/users/__tests__/UserSearch.test.tsx +30 -0
- package/templates/fe/base/src/features/users/__tests__/UsersPage.test.tsx +69 -0
- package/templates/fe/base/src/features/users/__tests__/UsersTable.test.tsx +120 -0
- package/templates/fe/base/src/features/users/__tests__/useUsers.test.tsx +62 -0
- package/templates/fe/base/src/features/users/useUsers.ts +22 -0
- package/templates/fe/base/src/features/users/users.api.ts +22 -0
- package/templates/fe/base/src/features/users/users.schema.ts +43 -0
- package/templates/fe/base/src/lib/apiClient.test.ts +56 -0
- package/templates/fe/base/src/lib/apiClient.ts +42 -0
- package/templates/fe/base/src/lib/appName.ts +2 -0
- package/templates/fe/base/src/lib/env.test.ts +21 -0
- package/templates/fe/base/src/lib/env.ts +26 -0
- package/templates/fe/base/src/lib/queryClient.ts +15 -0
- package/templates/fe/base/src/lib/router.ts +11 -0
- package/templates/fe/base/src/main.tsx +21 -0
- package/templates/fe/base/src/routeTree.gen.ts +77 -0
- package/templates/fe/base/src/routes/__root.tsx +83 -0
- package/templates/fe/base/src/routes/index.tsx +26 -0
- package/templates/fe/base/src/routes/users/index.tsx +24 -0
- package/templates/fe/base/src/stores/seam.test.ts +21 -0
- package/templates/fe/base/src/test/api-mock.ts +22 -0
- package/templates/fe/base/src/test/fixtures/users.ts +39 -0
- package/templates/fe/base/src/test/msw/handlers.ts +9 -0
- package/templates/fe/base/src/test/msw/server.ts +5 -0
- package/templates/fe/base/src/test/render.tsx +45 -0
- package/templates/fe/base/src/test/setup.ts +15 -0
- package/templates/fe/base/tsconfig.json +25 -0
- package/templates/fe/base/vite.config.ts +22 -0
- package/templates/fe/base/vitest.config.ts +21 -0
- package/templates/fe/variants/features/no-github-ci/variant.json +1 -0
- package/templates/fe/variants/features/no-msw/src/test/api-mock.ts +52 -0
- package/templates/fe/variants/features/no-msw/src/test/setup.ts +13 -0
- package/templates/fe/variants/features/no-msw/variant.json +4 -0
- package/templates/fe/variants/features/no-playwright/.github/workflows/ci.yml +19 -0
- package/templates/fe/variants/features/no-playwright/variant.json +5 -0
- package/templates/fe/variants/state/jotai/docs/agents/state-jotai.md +5 -0
- package/templates/fe/variants/state/jotai/src/stores/index.ts +15 -0
- package/templates/fe/variants/state/jotai/src/stores/ui.atoms.test.tsx +29 -0
- package/templates/fe/variants/state/jotai/src/stores/ui.atoms.ts +39 -0
- package/templates/fe/variants/state/jotai/variant.json +12 -0
- package/templates/fe/variants/state/zustand/docs/agents/state-zustand.md +5 -0
- package/templates/fe/variants/state/zustand/src/stores/index.ts +12 -0
- package/templates/fe/variants/state/zustand/src/stores/ui.store.test.ts +34 -0
- package/templates/fe/variants/state/zustand/src/stores/ui.store.ts +62 -0
- package/templates/fe/variants/state/zustand/variant.json +5 -0
- package/templates/fe/variants/ui/base-ui/components.json +25 -0
- package/templates/fe/variants/ui/base-ui/docs/agents/ui-base-ui.md +7 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/alert.tsx +75 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/button.tsx +57 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/input.tsx +19 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/skeleton.tsx +13 -0
- package/templates/fe/variants/ui/base-ui/src/components/ui/table.tsx +113 -0
- package/templates/fe/variants/ui/base-ui/src/index.css +130 -0
- package/templates/fe/variants/ui/base-ui/src/lib/utils.test.ts +10 -0
- package/templates/fe/variants/ui/base-ui/src/lib/utils.ts +1 -0
- package/templates/fe/variants/ui/base-ui/variant.json +23 -0
- package/templates/fe/variants/ui/radix/components.json +25 -0
- package/templates/fe/variants/ui/radix/docs/agents/ui-radix.md +7 -0
- package/templates/fe/variants/ui/radix/src/components/ui/alert.tsx +75 -0
- package/templates/fe/variants/ui/radix/src/components/ui/button.tsx +66 -0
- package/templates/fe/variants/ui/radix/src/components/ui/input.tsx +18 -0
- package/templates/fe/variants/ui/radix/src/components/ui/skeleton.tsx +13 -0
- package/templates/fe/variants/ui/radix/src/components/ui/table.tsx +113 -0
- package/templates/fe/variants/ui/radix/src/index.css +130 -0
- package/templates/fe/variants/ui/radix/src/lib/utils.test.ts +10 -0
- package/templates/fe/variants/ui/radix/src/lib/utils.ts +1 -0
- package/templates/fe/variants/ui/radix/variant.json +23 -0
- package/templates/fullstack/.github/workflows/ci.yml +18 -0
- package/templates/fullstack/AGENTS.md +7 -0
- package/templates/fullstack/CLAUDE.md +1 -0
- package/templates/fullstack/README.md +16 -0
- package/templates/fullstack/_gitignore +11 -0
- package/templates/fullstack/package.json +16 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "94bc1885-edbb-47eb-8bd4-c355fdbb8f76",
|
|
4
|
+
"userId": "79c28625-102f-48f6-a487-1a39a20c70f0",
|
|
5
|
+
"items": [
|
|
6
|
+
{
|
|
7
|
+
"productId": "17166151-cf1f-4841-88cb-016434ce6e57",
|
|
8
|
+
"qty": 5,
|
|
9
|
+
"unitPrice": 325.6
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"productId": "8f20cc14-04c8-4550-a4af-d0ecc7641337",
|
|
13
|
+
"qty": 1,
|
|
14
|
+
"unitPrice": 393.65
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"productId": "67af9b8a-1457-4024-af57-39438003015c",
|
|
18
|
+
"qty": 2,
|
|
19
|
+
"unitPrice": 48.19
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"total": 2118.03,
|
|
23
|
+
"createdAt": "2025-06-20T21:05:02.905Z"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "f73bd8f0-8bd2-4c86-82d2-44dac499de0a",
|
|
27
|
+
"userId": "9fa4a8c1-c8f5-4ae1-beb1-4b19590dffb2",
|
|
28
|
+
"items": [
|
|
29
|
+
{
|
|
30
|
+
"productId": "153329c9-2ca6-4a45-ae47-eb020a72f838",
|
|
31
|
+
"qty": 1,
|
|
32
|
+
"unitPrice": 275.59
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"productId": "13257ba9-5d7f-4a2a-a5a1-2d3d4ab84304",
|
|
36
|
+
"qty": 4,
|
|
37
|
+
"unitPrice": 334.12
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"total": 1612.07,
|
|
41
|
+
"createdAt": "2024-07-29T06:13:42.666Z"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "61c46a50-5faa-4a36-9c14-46f182f16bb6",
|
|
45
|
+
"userId": "55b73722-76e5-49a0-8a2f-261f891b3e33",
|
|
46
|
+
"items": [
|
|
47
|
+
{
|
|
48
|
+
"productId": "7991a3bd-c882-4c47-a42a-0b50804b1d03",
|
|
49
|
+
"qty": 2,
|
|
50
|
+
"unitPrice": 422.15
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"productId": "f5e9df4f-6658-4288-acd7-443054f85927",
|
|
54
|
+
"qty": 4,
|
|
55
|
+
"unitPrice": 313.55
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"total": 2098.5,
|
|
59
|
+
"createdAt": "2024-07-12T04:27:45.675Z"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "4af911f4-199a-440f-a4ab-9549df12fbe3",
|
|
63
|
+
"userId": "0ae3e0e5-1744-44c8-949b-4612a28b194f",
|
|
64
|
+
"items": [
|
|
65
|
+
{
|
|
66
|
+
"productId": "1d7de0e7-8ae0-47bb-bb24-5c43f0fad40b",
|
|
67
|
+
"qty": 2,
|
|
68
|
+
"unitPrice": 330.9
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"total": 661.8,
|
|
72
|
+
"createdAt": "2025-05-12T03:52:57.826Z"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "f6d3af10-61be-4646-8b09-9a3b13eb0334",
|
|
76
|
+
"userId": "58b5ff47-4409-4804-be32-7f3ac3b5aa81",
|
|
77
|
+
"items": [
|
|
78
|
+
{
|
|
79
|
+
"productId": "7991a3bd-c882-4c47-a42a-0b50804b1d03",
|
|
80
|
+
"qty": 2,
|
|
81
|
+
"unitPrice": 422.15
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"productId": "13257ba9-5d7f-4a2a-a5a1-2d3d4ab84304",
|
|
85
|
+
"qty": 3,
|
|
86
|
+
"unitPrice": 334.12
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"total": 1846.66,
|
|
90
|
+
"createdAt": "2024-12-01T11:39:08.264Z"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "de839bb8-15e9-4845-8eac-7a3b67ae1d47",
|
|
94
|
+
"userId": "6245a95f-9312-4322-b42e-186f16fdd42a",
|
|
95
|
+
"items": [
|
|
96
|
+
{
|
|
97
|
+
"productId": "8177d86f-160b-4e4d-84ec-c0fb4d4d1b81",
|
|
98
|
+
"qty": 5,
|
|
99
|
+
"unitPrice": 152.15
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"productId": "e84602c0-680f-4344-b30b-f3abd645bd25",
|
|
103
|
+
"qty": 5,
|
|
104
|
+
"unitPrice": 297.39
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"productId": "6e6f1a76-ab02-4baf-9cfb-41ca05f86735",
|
|
108
|
+
"qty": 5,
|
|
109
|
+
"unitPrice": 425.95
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"total": 4377.45,
|
|
113
|
+
"createdAt": "2025-01-02T10:09:44.572Z"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"id": "1c6a4221-2aed-4a14-b438-855dc4ef558f",
|
|
117
|
+
"userId": "91543f6e-ac89-473b-940a-2ffe50e6ffd4",
|
|
118
|
+
"items": [
|
|
119
|
+
{
|
|
120
|
+
"productId": "1d7de0e7-8ae0-47bb-bb24-5c43f0fad40b",
|
|
121
|
+
"qty": 5,
|
|
122
|
+
"unitPrice": 330.9
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"total": 1654.5,
|
|
126
|
+
"createdAt": "2024-10-14T02:04:04.983Z"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "b792a2b3-120b-4b82-b102-e35138930633",
|
|
130
|
+
"userId": "b0e08bdb-c5d1-4e8d-97a8-b1032d3f52ca",
|
|
131
|
+
"items": [
|
|
132
|
+
{
|
|
133
|
+
"productId": "153329c9-2ca6-4a45-ae47-eb020a72f838",
|
|
134
|
+
"qty": 4,
|
|
135
|
+
"unitPrice": 275.59
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"productId": "67af9b8a-1457-4024-af57-39438003015c",
|
|
139
|
+
"qty": 5,
|
|
140
|
+
"unitPrice": 48.19
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"productId": "17166151-cf1f-4841-88cb-016434ce6e57",
|
|
144
|
+
"qty": 5,
|
|
145
|
+
"unitPrice": 325.6
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"total": 2971.31,
|
|
149
|
+
"createdAt": "2025-02-11T01:52:30.908Z"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"id": "286da819-152b-436e-b386-0c178ab40b8d",
|
|
153
|
+
"userId": "4c96319c-a80f-4c4f-899b-ca25e35679f3",
|
|
154
|
+
"items": [
|
|
155
|
+
{
|
|
156
|
+
"productId": "17166151-cf1f-4841-88cb-016434ce6e57",
|
|
157
|
+
"qty": 4,
|
|
158
|
+
"unitPrice": 325.6
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"productId": "60783feb-8d2c-41c4-aef2-7f7d9643c687",
|
|
162
|
+
"qty": 4,
|
|
163
|
+
"unitPrice": 383.45
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"total": 2836.2,
|
|
167
|
+
"createdAt": "2024-12-20T14:30:02.088Z"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"id": "e716ce31-e68f-41a1-86c6-f85355157bab",
|
|
171
|
+
"userId": "db11f55d-ffc6-41c8-b6e1-707011ab9f54",
|
|
172
|
+
"items": [
|
|
173
|
+
{
|
|
174
|
+
"productId": "60783feb-8d2c-41c4-aef2-7f7d9643c687",
|
|
175
|
+
"qty": 1,
|
|
176
|
+
"unitPrice": 383.45
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"productId": "153329c9-2ca6-4a45-ae47-eb020a72f838",
|
|
180
|
+
"qty": 5,
|
|
181
|
+
"unitPrice": 275.59
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"total": 1761.4,
|
|
185
|
+
"createdAt": "2025-04-28T16:35:20.299Z"
|
|
186
|
+
}
|
|
187
|
+
]
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "13257ba9-5d7f-4a2a-a5a1-2d3d4ab84304",
|
|
4
|
+
"name": "Tasty Steel Shirt",
|
|
5
|
+
"category": "toys",
|
|
6
|
+
"price": 334.12,
|
|
7
|
+
"stock": 134
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "8177d86f-160b-4e4d-84ec-c0fb4d4d1b81",
|
|
11
|
+
"name": "Awesome Granite Chips",
|
|
12
|
+
"category": "garden",
|
|
13
|
+
"price": 152.15,
|
|
14
|
+
"stock": 9
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "eda9e213-c09f-4d81-bd91-1eade98656c9",
|
|
18
|
+
"name": "Handmade Metal Pizza",
|
|
19
|
+
"category": "garden",
|
|
20
|
+
"price": 352.85,
|
|
21
|
+
"stock": 20
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "67af9b8a-1457-4024-af57-39438003015c",
|
|
25
|
+
"name": "Intelligent Concrete Towels",
|
|
26
|
+
"category": "electronics",
|
|
27
|
+
"price": 48.19,
|
|
28
|
+
"stock": 69
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "8d7bf246-66eb-494d-bfd0-a0409a167516",
|
|
32
|
+
"name": "Bespoke Bamboo Computer",
|
|
33
|
+
"category": "food",
|
|
34
|
+
"price": 335.99,
|
|
35
|
+
"stock": 119
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "0ae9db1e-1820-4647-b901-85badb6a44c7",
|
|
39
|
+
"name": "Sleek Silk Table",
|
|
40
|
+
"category": "garden",
|
|
41
|
+
"price": 162.89,
|
|
42
|
+
"stock": 120
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "bb5262e5-20aa-4516-84a9-53f7b2708f60",
|
|
46
|
+
"name": "Handcrafted Bronze Bacon",
|
|
47
|
+
"category": "toys",
|
|
48
|
+
"price": 231.92,
|
|
49
|
+
"stock": 23
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "f5e9df4f-6658-4288-acd7-443054f85927",
|
|
53
|
+
"name": "Intelligent Gold Tuna",
|
|
54
|
+
"category": "food",
|
|
55
|
+
"price": 313.55,
|
|
56
|
+
"stock": 40
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "60783feb-8d2c-41c4-aef2-7f7d9643c687",
|
|
60
|
+
"name": "Small Wooden Fish",
|
|
61
|
+
"category": "food",
|
|
62
|
+
"price": 383.45,
|
|
63
|
+
"stock": 40
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "1d7de0e7-8ae0-47bb-bb24-5c43f0fad40b",
|
|
67
|
+
"name": "Recycled Bronze Shirt",
|
|
68
|
+
"category": "toys",
|
|
69
|
+
"price": 330.9,
|
|
70
|
+
"stock": 123
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "17166151-cf1f-4841-88cb-016434ce6e57",
|
|
74
|
+
"name": "Oriental Wooden Pants",
|
|
75
|
+
"category": "electronics",
|
|
76
|
+
"price": 325.6,
|
|
77
|
+
"stock": 101
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "7991a3bd-c882-4c47-a42a-0b50804b1d03",
|
|
81
|
+
"name": "Generic Bamboo Computer",
|
|
82
|
+
"category": "electronics",
|
|
83
|
+
"price": 422.15,
|
|
84
|
+
"stock": 179
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "6e6f1a76-ab02-4baf-9cfb-41ca05f86735",
|
|
88
|
+
"name": "Bespoke Rubber Fish",
|
|
89
|
+
"category": "food",
|
|
90
|
+
"price": 425.95,
|
|
91
|
+
"stock": 94
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "e3a942ab-5a6b-43e4-a501-84d065016768",
|
|
95
|
+
"name": "Awesome Gold Tuna",
|
|
96
|
+
"category": "garden",
|
|
97
|
+
"price": 340.35,
|
|
98
|
+
"stock": 155
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "8f20cc14-04c8-4550-a4af-d0ecc7641337",
|
|
102
|
+
"name": "Incredible Aluminum Towels",
|
|
103
|
+
"category": "food",
|
|
104
|
+
"price": 393.65,
|
|
105
|
+
"stock": 193
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "153329c9-2ca6-4a45-ae47-eb020a72f838",
|
|
109
|
+
"name": "Electronic Concrete Shoes",
|
|
110
|
+
"category": "garden",
|
|
111
|
+
"price": 275.59,
|
|
112
|
+
"stock": 33
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"id": "730dfcd3-f3ff-4bf9-9469-19f3ceff8fc2",
|
|
116
|
+
"name": "Recycled Ceramic Pizza",
|
|
117
|
+
"category": "toys",
|
|
118
|
+
"price": 85.55,
|
|
119
|
+
"stock": 100
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "005e3a35-db16-407a-9146-ef0c56cef95c",
|
|
123
|
+
"name": "Luxurious Cotton Pizza",
|
|
124
|
+
"category": "electronics",
|
|
125
|
+
"price": 99.89,
|
|
126
|
+
"stock": 101
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "3002d4f9-698c-445e-afe6-c773925d311f",
|
|
130
|
+
"name": "Handmade Silk Soap",
|
|
131
|
+
"category": "electronics",
|
|
132
|
+
"price": 348.35,
|
|
133
|
+
"stock": 30
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "e84602c0-680f-4344-b30b-f3abd645bd25",
|
|
137
|
+
"name": "Rustic Wooden Shirt",
|
|
138
|
+
"category": "electronics",
|
|
139
|
+
"price": 297.39,
|
|
140
|
+
"stock": 109
|
|
141
|
+
}
|
|
142
|
+
]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ZodType } from 'zod'
|
|
2
|
+
|
|
3
|
+
import ordersJson from './orders.json'
|
|
4
|
+
import productsJson from './products.json'
|
|
5
|
+
import {
|
|
6
|
+
type Order,
|
|
7
|
+
OrderSchema,
|
|
8
|
+
type Product,
|
|
9
|
+
ProductSchema,
|
|
10
|
+
type User,
|
|
11
|
+
UserSchema,
|
|
12
|
+
} from './schemas'
|
|
13
|
+
import usersJson from './users.json'
|
|
14
|
+
|
|
15
|
+
export interface Repository<T extends { id: string }> {
|
|
16
|
+
all(): readonly T[]
|
|
17
|
+
findById(id: string): T | undefined
|
|
18
|
+
insert(row: T): T
|
|
19
|
+
/** Reload the committed fixture (tests). */
|
|
20
|
+
reset(): void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** In-memory table loaded from a committed JSON fixture, validated once with zod. */
|
|
24
|
+
const createRepository = <T extends { id: string }>(
|
|
25
|
+
schema: ZodType<T>,
|
|
26
|
+
fixture: unknown,
|
|
27
|
+
): Repository<T> => {
|
|
28
|
+
const load = (): T[] =>
|
|
29
|
+
fixture instanceof Array ? fixture.map((row) => schema.parse(row)) : []
|
|
30
|
+
let rows = load()
|
|
31
|
+
return {
|
|
32
|
+
all: () => rows,
|
|
33
|
+
findById: (id) => rows.find((row) => row.id === id),
|
|
34
|
+
insert: (row) => {
|
|
35
|
+
rows.push(schema.parse(row))
|
|
36
|
+
return row
|
|
37
|
+
},
|
|
38
|
+
reset: () => {
|
|
39
|
+
rows = load()
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const usersRepository: Repository<User> = createRepository(
|
|
45
|
+
UserSchema,
|
|
46
|
+
usersJson,
|
|
47
|
+
)
|
|
48
|
+
export const productsRepository: Repository<Product> = createRepository(
|
|
49
|
+
ProductSchema,
|
|
50
|
+
productsJson,
|
|
51
|
+
)
|
|
52
|
+
export const ordersRepository: Repository<Order> = createRepository(
|
|
53
|
+
OrderSchema,
|
|
54
|
+
ordersJson,
|
|
55
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const USER_ROLES = ['admin', 'editor', 'viewer'] as const
|
|
4
|
+
export const PRODUCT_CATEGORIES = [
|
|
5
|
+
'books',
|
|
6
|
+
'electronics',
|
|
7
|
+
'garden',
|
|
8
|
+
'toys',
|
|
9
|
+
'food',
|
|
10
|
+
] as const
|
|
11
|
+
|
|
12
|
+
export const UserSchema = z.object({
|
|
13
|
+
id: z.uuid(),
|
|
14
|
+
name: z.string().min(1),
|
|
15
|
+
email: z.email(),
|
|
16
|
+
role: z.enum(USER_ROLES),
|
|
17
|
+
createdAt: z.iso.datetime(),
|
|
18
|
+
})
|
|
19
|
+
export type User = z.infer<typeof UserSchema>
|
|
20
|
+
|
|
21
|
+
export const ProductSchema = z.object({
|
|
22
|
+
id: z.uuid(),
|
|
23
|
+
name: z.string().min(1),
|
|
24
|
+
category: z.enum(PRODUCT_CATEGORIES),
|
|
25
|
+
price: z.number().nonnegative(),
|
|
26
|
+
stock: z.int().nonnegative(),
|
|
27
|
+
})
|
|
28
|
+
export type Product = z.infer<typeof ProductSchema>
|
|
29
|
+
|
|
30
|
+
export const OrderItemSchema = z.object({
|
|
31
|
+
productId: z.uuid(),
|
|
32
|
+
qty: z.int().min(1),
|
|
33
|
+
unitPrice: z.number().nonnegative(),
|
|
34
|
+
})
|
|
35
|
+
export type OrderItem = z.infer<typeof OrderItemSchema>
|
|
36
|
+
|
|
37
|
+
export const OrderSchema = z.object({
|
|
38
|
+
id: z.uuid(),
|
|
39
|
+
userId: z.uuid(),
|
|
40
|
+
items: z.array(OrderItemSchema).min(1),
|
|
41
|
+
total: z.number().nonnegative(),
|
|
42
|
+
createdAt: z.iso.datetime(),
|
|
43
|
+
})
|
|
44
|
+
export type Order = z.infer<typeof OrderSchema>
|