@unifiedcommerce/core 0.0.4 → 0.1.1

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.
Files changed (179) hide show
  1. package/dist/auth/auth-schema.d.ts +92 -0
  2. package/dist/auth/auth-schema.d.ts.map +1 -1
  3. package/dist/auth/auth-schema.js +7 -0
  4. package/dist/auth/setup.d.ts.map +1 -1
  5. package/dist/auth/setup.js +3 -1
  6. package/package.json +1 -2
  7. package/src/adapters/console-email.ts +0 -43
  8. package/src/auth/access.ts +0 -187
  9. package/src/auth/auth-schema.ts +0 -131
  10. package/src/auth/middleware.ts +0 -161
  11. package/src/auth/org.ts +0 -41
  12. package/src/auth/permissions.ts +0 -28
  13. package/src/auth/setup.ts +0 -165
  14. package/src/auth/system-actor.ts +0 -19
  15. package/src/auth/types.ts +0 -10
  16. package/src/config/defaults.ts +0 -82
  17. package/src/config/define-config.ts +0 -53
  18. package/src/config/types.ts +0 -299
  19. package/src/generated/plugin-capabilities.d.ts +0 -20
  20. package/src/generated/plugin-manifest.ts +0 -23
  21. package/src/generated/plugin-repositories.d.ts +0 -20
  22. package/src/hooks/checkout-completion.ts +0 -262
  23. package/src/hooks/checkout.ts +0 -677
  24. package/src/hooks/order-emails.ts +0 -62
  25. package/src/index.ts +0 -214
  26. package/src/interfaces/mcp/agent-prompt.ts +0 -174
  27. package/src/interfaces/mcp/context-enrichment.ts +0 -177
  28. package/src/interfaces/mcp/server.ts +0 -617
  29. package/src/interfaces/mcp/transport.ts +0 -68
  30. package/src/interfaces/rest/customer-portal.ts +0 -299
  31. package/src/interfaces/rest/index.ts +0 -74
  32. package/src/interfaces/rest/router.ts +0 -334
  33. package/src/interfaces/rest/routes/admin-jobs.ts +0 -58
  34. package/src/interfaces/rest/routes/audit.ts +0 -50
  35. package/src/interfaces/rest/routes/carts.ts +0 -89
  36. package/src/interfaces/rest/routes/catalog.ts +0 -493
  37. package/src/interfaces/rest/routes/checkout.ts +0 -283
  38. package/src/interfaces/rest/routes/inventory.ts +0 -70
  39. package/src/interfaces/rest/routes/media.ts +0 -86
  40. package/src/interfaces/rest/routes/orders.ts +0 -78
  41. package/src/interfaces/rest/routes/payments.ts +0 -60
  42. package/src/interfaces/rest/routes/pricing.ts +0 -57
  43. package/src/interfaces/rest/routes/promotions.ts +0 -92
  44. package/src/interfaces/rest/routes/search.ts +0 -71
  45. package/src/interfaces/rest/routes/webhooks.ts +0 -46
  46. package/src/interfaces/rest/schemas/admin-jobs.ts +0 -40
  47. package/src/interfaces/rest/schemas/audit.ts +0 -46
  48. package/src/interfaces/rest/schemas/carts.ts +0 -125
  49. package/src/interfaces/rest/schemas/catalog.ts +0 -450
  50. package/src/interfaces/rest/schemas/checkout.ts +0 -66
  51. package/src/interfaces/rest/schemas/customer-portal.ts +0 -195
  52. package/src/interfaces/rest/schemas/inventory.ts +0 -138
  53. package/src/interfaces/rest/schemas/media.ts +0 -75
  54. package/src/interfaces/rest/schemas/orders.ts +0 -104
  55. package/src/interfaces/rest/schemas/pricing.ts +0 -80
  56. package/src/interfaces/rest/schemas/promotions.ts +0 -110
  57. package/src/interfaces/rest/schemas/responses.ts +0 -85
  58. package/src/interfaces/rest/schemas/search.ts +0 -58
  59. package/src/interfaces/rest/schemas/shared.ts +0 -62
  60. package/src/interfaces/rest/schemas/webhooks.ts +0 -68
  61. package/src/interfaces/rest/utils.ts +0 -104
  62. package/src/interfaces/rest/webhook-router.ts +0 -50
  63. package/src/kernel/compensation/executor.ts +0 -61
  64. package/src/kernel/compensation/types.ts +0 -26
  65. package/src/kernel/database/adapter.ts +0 -13
  66. package/src/kernel/database/drizzle-db.ts +0 -56
  67. package/src/kernel/database/migrate.ts +0 -76
  68. package/src/kernel/database/plugin-types.ts +0 -34
  69. package/src/kernel/database/schema.ts +0 -49
  70. package/src/kernel/database/scoped-db.ts +0 -68
  71. package/src/kernel/database/tx-context.ts +0 -46
  72. package/src/kernel/error-mapper.ts +0 -15
  73. package/src/kernel/errors.ts +0 -89
  74. package/src/kernel/factory/repository-factory.ts +0 -242
  75. package/src/kernel/hooks/create-context.ts +0 -43
  76. package/src/kernel/hooks/executor.ts +0 -88
  77. package/src/kernel/hooks/registry.ts +0 -74
  78. package/src/kernel/hooks/types.ts +0 -52
  79. package/src/kernel/http-error.ts +0 -44
  80. package/src/kernel/jobs/adapter.ts +0 -36
  81. package/src/kernel/jobs/drizzle-adapter.ts +0 -58
  82. package/src/kernel/jobs/runner.ts +0 -153
  83. package/src/kernel/jobs/schema.ts +0 -46
  84. package/src/kernel/jobs/types.ts +0 -30
  85. package/src/kernel/local-api.ts +0 -185
  86. package/src/kernel/plugin/manifest.ts +0 -253
  87. package/src/kernel/query/executor.ts +0 -184
  88. package/src/kernel/query/registry.ts +0 -46
  89. package/src/kernel/result.ts +0 -33
  90. package/src/kernel/schema/extra-columns.ts +0 -37
  91. package/src/kernel/service-registry.ts +0 -76
  92. package/src/kernel/service-timing.ts +0 -89
  93. package/src/kernel/state-machine/machine.ts +0 -101
  94. package/src/modules/analytics/drizzle-adapter.ts +0 -426
  95. package/src/modules/analytics/hooks.ts +0 -11
  96. package/src/modules/analytics/models.ts +0 -125
  97. package/src/modules/analytics/repository/index.ts +0 -6
  98. package/src/modules/analytics/service.ts +0 -245
  99. package/src/modules/analytics/types.ts +0 -180
  100. package/src/modules/audit/hooks.ts +0 -78
  101. package/src/modules/audit/schema.ts +0 -33
  102. package/src/modules/audit/service.ts +0 -151
  103. package/src/modules/cart/access.ts +0 -27
  104. package/src/modules/cart/matcher.ts +0 -26
  105. package/src/modules/cart/repository/index.ts +0 -234
  106. package/src/modules/cart/schema.ts +0 -42
  107. package/src/modules/cart/schemas.ts +0 -38
  108. package/src/modules/cart/service.ts +0 -541
  109. package/src/modules/catalog/repository/index.ts +0 -772
  110. package/src/modules/catalog/schema.ts +0 -203
  111. package/src/modules/catalog/schemas.ts +0 -104
  112. package/src/modules/catalog/service.ts +0 -1544
  113. package/src/modules/customers/repository/index.ts +0 -327
  114. package/src/modules/customers/schema.ts +0 -64
  115. package/src/modules/customers/service.ts +0 -171
  116. package/src/modules/fulfillment/repository/index.ts +0 -426
  117. package/src/modules/fulfillment/schema.ts +0 -101
  118. package/src/modules/fulfillment/service.ts +0 -555
  119. package/src/modules/fulfillment/types.ts +0 -59
  120. package/src/modules/inventory/repository/index.ts +0 -509
  121. package/src/modules/inventory/schema.ts +0 -94
  122. package/src/modules/inventory/schemas.ts +0 -38
  123. package/src/modules/inventory/service.ts +0 -490
  124. package/src/modules/media/adapter.ts +0 -17
  125. package/src/modules/media/repository/index.ts +0 -274
  126. package/src/modules/media/schema.ts +0 -41
  127. package/src/modules/media/service.ts +0 -151
  128. package/src/modules/orders/repository/index.ts +0 -287
  129. package/src/modules/orders/schema.ts +0 -66
  130. package/src/modules/orders/service.ts +0 -619
  131. package/src/modules/orders/stale-order-cleanup.ts +0 -76
  132. package/src/modules/organization/service.ts +0 -191
  133. package/src/modules/payments/adapter.ts +0 -47
  134. package/src/modules/payments/repository/index.ts +0 -6
  135. package/src/modules/payments/service.ts +0 -107
  136. package/src/modules/pricing/repository/index.ts +0 -291
  137. package/src/modules/pricing/schema.ts +0 -71
  138. package/src/modules/pricing/schemas.ts +0 -38
  139. package/src/modules/pricing/service.ts +0 -494
  140. package/src/modules/promotions/repository/index.ts +0 -325
  141. package/src/modules/promotions/schema.ts +0 -62
  142. package/src/modules/promotions/schemas.ts +0 -38
  143. package/src/modules/promotions/service.ts +0 -598
  144. package/src/modules/search/adapter.ts +0 -57
  145. package/src/modules/search/hooks.ts +0 -12
  146. package/src/modules/search/repository/index.ts +0 -6
  147. package/src/modules/search/service.ts +0 -315
  148. package/src/modules/shipping/calculator.ts +0 -188
  149. package/src/modules/shipping/repository/index.ts +0 -6
  150. package/src/modules/shipping/service.ts +0 -51
  151. package/src/modules/tax/adapter.ts +0 -60
  152. package/src/modules/tax/repository/index.ts +0 -6
  153. package/src/modules/tax/service.ts +0 -53
  154. package/src/modules/webhooks/hook.ts +0 -34
  155. package/src/modules/webhooks/repository/index.ts +0 -278
  156. package/src/modules/webhooks/schema.ts +0 -56
  157. package/src/modules/webhooks/service.ts +0 -117
  158. package/src/modules/webhooks/signing.ts +0 -6
  159. package/src/modules/webhooks/ssrf-guard.ts +0 -71
  160. package/src/modules/webhooks/tasks.ts +0 -52
  161. package/src/modules/webhooks/worker.ts +0 -134
  162. package/src/runtime/commerce.ts +0 -145
  163. package/src/runtime/kernel.ts +0 -419
  164. package/src/runtime/logger.ts +0 -36
  165. package/src/runtime/server.ts +0 -349
  166. package/src/runtime/shutdown.ts +0 -43
  167. package/src/test-utils/create-pglite-adapter.ts +0 -129
  168. package/src/test-utils/create-plugin-test-app.ts +0 -128
  169. package/src/test-utils/create-repository-test-harness.ts +0 -16
  170. package/src/test-utils/create-test-config.ts +0 -190
  171. package/src/test-utils/create-test-kernel.ts +0 -7
  172. package/src/test-utils/create-test-plugin-context.ts +0 -75
  173. package/src/test-utils/rest-api-test-utils.ts +0 -265
  174. package/src/test-utils/test-actors.ts +0 -62
  175. package/src/test-utils/typed-hooks.ts +0 -54
  176. package/src/types/commerce-types.ts +0 -34
  177. package/src/utils/id.ts +0 -3
  178. package/src/utils/logger.ts +0 -18
  179. package/src/utils/pagination.ts +0 -22
@@ -1,450 +0,0 @@
1
- import { z, createRoute } from "@hono/zod-openapi";
2
- import { errorResponses } from "./shared.js";
3
- import { CatalogEntityResponse, CatalogEntityListResponse } from "./responses.js";
4
- import {
5
- CreateEntityBodySchema,
6
- UpdateEntityBodySchema,
7
- SetAttributesBodySchema,
8
- CreateCategoryBodySchema,
9
- UpdateCategoryBodySchema,
10
- CreateBrandBodySchema,
11
- UpdateBrandBodySchema,
12
- CreateOptionTypeBodySchema,
13
- CreateOptionValueBodySchema,
14
- CreateVariantBodySchema,
15
- GenerateVariantsBodySchema,
16
- } from "../../../modules/catalog/schemas.js";
17
-
18
- // ─── Response Schemas ───────────────────────────────────────────────────────
19
-
20
- const DataResponse = CatalogEntityResponse;
21
- const DataWithPaginationResponse = CatalogEntityListResponse;
22
-
23
- // ─── Path Params ────────────────────────────────────────────────────────────
24
-
25
- const EntityIdOrSlugParam = z.object({
26
- idOrSlug: z.string().min(1).openapi({ example: "my-product" }),
27
- });
28
-
29
- const EntityIdParam = z.object({
30
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
31
- });
32
-
33
- const EntityIdLocaleParam = z.object({
34
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
35
- locale: z.string().min(1).openapi({ example: "en" }),
36
- });
37
-
38
- const CategoryIdParam = z.object({
39
- categoryId: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
40
- });
41
-
42
- const BrandIdParam = z.object({
43
- brandId: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
44
- });
45
-
46
- const EntityCategoryParam = z.object({
47
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
48
- categoryId: z.uuid().openapi({ example: "660e8400-e29b-41d4-a716-446655440000" }),
49
- });
50
-
51
- const EntityBrandParam = z.object({
52
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
53
- brandId: z.uuid().openapi({ example: "660e8400-e29b-41d4-a716-446655440000" }),
54
- });
55
-
56
- // ─── GET Route Definitions ─────────────────────────────────────────────────
57
-
58
- export const listEntitiesRoute = createRoute({
59
- method: "get",
60
- path: "/entities",
61
- tags: ["Catalog"],
62
- summary: "List catalog entities",
63
- request: {
64
- query: z.object({
65
- type: z.string().optional(),
66
- status: z.string().optional(),
67
- category: z.string().optional(),
68
- brand: z.string().optional(),
69
- include: z.string().optional(),
70
- sort: z.string().optional(),
71
- page: z.string().optional(),
72
- limit: z.string().optional(),
73
- }),
74
- },
75
- responses: {
76
- 200: { content: { "application/json": { schema: DataWithPaginationResponse } }, description: "Success" },
77
- },
78
- });
79
-
80
- export const getEntityRoute = createRoute({
81
- method: "get",
82
- path: "/entities/{idOrSlug}",
83
- tags: ["Catalog"],
84
- summary: "Get a catalog entity by ID or slug",
85
- request: {
86
- params: EntityIdOrSlugParam,
87
- query: z.object({ include: z.string().optional() }),
88
- },
89
- responses: {
90
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Success" },
91
- ...errorResponses,
92
- },
93
- });
94
-
95
- export const getEntityAttributesRoute = createRoute({
96
- method: "get",
97
- path: "/entities/{id}/attributes/{locale}",
98
- tags: ["Catalog"],
99
- summary: "Get entity attributes for a locale",
100
- request: { params: EntityIdLocaleParam },
101
- responses: {
102
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Success" },
103
- ...errorResponses,
104
- },
105
- });
106
-
107
- export const listCategoriesRoute = createRoute({
108
- method: "get",
109
- path: "/categories",
110
- tags: ["Catalog"],
111
- summary: "List all categories",
112
- responses: {
113
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Success" },
114
- },
115
- });
116
-
117
- export const listBrandsRoute = createRoute({
118
- method: "get",
119
- path: "/brands",
120
- tags: ["Catalog"],
121
- summary: "List all brands",
122
- responses: {
123
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Success" },
124
- },
125
- });
126
-
127
- // ─── DELETE Route Definitions ──────────────────────────────────────────────
128
-
129
- export const deleteEntityRoute = createRoute({
130
- method: "delete",
131
- path: "/entities/{id}",
132
- tags: ["Catalog"],
133
- summary: "Delete a catalog entity",
134
- request: { params: EntityIdParam },
135
- responses: {
136
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ deleted: z.literal(true) }) }) } }, description: "Deleted" },
137
- ...errorResponses,
138
- },
139
- });
140
-
141
- export const deleteCategoryRoute = createRoute({
142
- method: "delete",
143
- path: "/categories/{categoryId}",
144
- tags: ["Catalog"],
145
- summary: "Delete a category",
146
- request: { params: CategoryIdParam },
147
- responses: {
148
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ deleted: z.literal(true) }) }) } }, description: "Deleted" },
149
- ...errorResponses,
150
- },
151
- });
152
-
153
- export const deleteBrandRoute = createRoute({
154
- method: "delete",
155
- path: "/brands/{brandId}",
156
- tags: ["Catalog"],
157
- summary: "Delete a brand",
158
- request: { params: BrandIdParam },
159
- responses: {
160
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ deleted: z.literal(true) }) }) } }, description: "Deleted" },
161
- ...errorResponses,
162
- },
163
- });
164
-
165
- export const removeEntityFromCategoryRoute = createRoute({
166
- method: "delete",
167
- path: "/entities/{id}/categories/{categoryId}",
168
- tags: ["Catalog"],
169
- summary: "Remove entity from category",
170
- request: { params: EntityCategoryParam },
171
- responses: {
172
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ unlinked: z.literal(true) }) }) } }, description: "Unlinked" },
173
- ...errorResponses,
174
- },
175
- });
176
-
177
- export const removeEntityFromBrandRoute = createRoute({
178
- method: "delete",
179
- path: "/entities/{id}/brands/{brandId}",
180
- tags: ["Catalog"],
181
- summary: "Remove entity from brand",
182
- request: { params: EntityBrandParam },
183
- responses: {
184
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ unlinked: z.literal(true) }) }) } }, description: "Unlinked" },
185
- ...errorResponses,
186
- },
187
- });
188
-
189
- // ─── No-body POST Route Definitions ────────────────────────────────────────
190
-
191
- export const publishEntityRoute = createRoute({
192
- method: "post",
193
- path: "/entities/{id}/publish",
194
- tags: ["Catalog"],
195
- summary: "Publish a catalog entity",
196
- request: { params: EntityIdParam },
197
- responses: {
198
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Published" },
199
- ...errorResponses,
200
- },
201
- });
202
-
203
- export const archiveEntityRoute = createRoute({
204
- method: "post",
205
- path: "/entities/{id}/archive",
206
- tags: ["Catalog"],
207
- summary: "Archive a catalog entity",
208
- request: { params: EntityIdParam },
209
- responses: {
210
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Archived" },
211
- ...errorResponses,
212
- },
213
- });
214
-
215
- export const discontinueEntityRoute = createRoute({
216
- method: "post",
217
- path: "/entities/{id}/discontinue",
218
- tags: ["Catalog"],
219
- summary: "Discontinue a catalog entity",
220
- request: { params: EntityIdParam },
221
- responses: {
222
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Discontinued" },
223
- ...errorResponses,
224
- },
225
- });
226
-
227
- export const addEntityToCategoryRoute = createRoute({
228
- method: "post",
229
- path: "/entities/{id}/categories/{categoryId}",
230
- tags: ["Catalog"],
231
- summary: "Add entity to a category",
232
- request: { params: EntityCategoryParam },
233
- responses: {
234
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ linked: z.literal(true) }) }) } }, description: "Linked" },
235
- ...errorResponses,
236
- },
237
- });
238
-
239
- export const addEntityToBrandRoute = createRoute({
240
- method: "post",
241
- path: "/entities/{id}/brands/{brandId}",
242
- tags: ["Catalog"],
243
- summary: "Add entity to a brand",
244
- request: { params: EntityBrandParam },
245
- responses: {
246
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ linked: z.literal(true) }) }) } }, description: "Linked" },
247
- ...errorResponses,
248
- },
249
- });
250
-
251
- // ─── Mutation Route Definitions ─────────────────────────────────────────────
252
-
253
- const OptionTypeIdParam = z.object({
254
- optionTypeId: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
255
- });
256
-
257
- export const createEntityRoute = createRoute({
258
- method: "post",
259
- path: "/entities",
260
- tags: ["Catalog"],
261
- summary: "Create a catalog entity",
262
- request: {
263
- body: {
264
- content: { "application/json": { schema: CreateEntityBodySchema } },
265
- required: true,
266
- },
267
- },
268
- responses: {
269
- 201: { content: { "application/json": { schema: DataResponse } }, description: "Created" },
270
- ...errorResponses,
271
- },
272
- });
273
-
274
- export const updateEntityRoute = createRoute({
275
- method: "patch",
276
- path: "/entities/{id}",
277
- tags: ["Catalog"],
278
- summary: "Update a catalog entity",
279
- request: {
280
- params: EntityIdParam,
281
- body: {
282
- content: { "application/json": { schema: UpdateEntityBodySchema } },
283
- required: true,
284
- },
285
- },
286
- responses: {
287
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Updated" },
288
- ...errorResponses,
289
- },
290
- });
291
-
292
- export const setEntityAttributesRoute = createRoute({
293
- method: "put",
294
- path: "/entities/{id}/attributes/{locale}",
295
- tags: ["Catalog"],
296
- summary: "Set entity attributes for a locale",
297
- request: {
298
- params: EntityIdLocaleParam,
299
- body: {
300
- content: { "application/json": { schema: SetAttributesBodySchema } },
301
- required: true,
302
- },
303
- },
304
- responses: {
305
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ updated: z.literal(true) }) }) } }, description: "Updated" },
306
- ...errorResponses,
307
- },
308
- });
309
-
310
- export const createCategoryRoute = createRoute({
311
- method: "post",
312
- path: "/categories",
313
- tags: ["Catalog"],
314
- summary: "Create a category",
315
- request: {
316
- body: {
317
- content: { "application/json": { schema: CreateCategoryBodySchema } },
318
- required: true,
319
- },
320
- },
321
- responses: {
322
- 201: { content: { "application/json": { schema: DataResponse } }, description: "Created" },
323
- ...errorResponses,
324
- },
325
- });
326
-
327
- export const updateCategoryRoute = createRoute({
328
- method: "patch",
329
- path: "/categories/{categoryId}",
330
- tags: ["Catalog"],
331
- summary: "Update a category",
332
- request: {
333
- params: CategoryIdParam,
334
- body: {
335
- content: { "application/json": { schema: UpdateCategoryBodySchema } },
336
- required: true,
337
- },
338
- },
339
- responses: {
340
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Updated" },
341
- ...errorResponses,
342
- },
343
- });
344
-
345
- export const createBrandRoute = createRoute({
346
- method: "post",
347
- path: "/brands",
348
- tags: ["Catalog"],
349
- summary: "Create a brand",
350
- request: {
351
- body: {
352
- content: { "application/json": { schema: CreateBrandBodySchema } },
353
- required: true,
354
- },
355
- },
356
- responses: {
357
- 201: { content: { "application/json": { schema: DataResponse } }, description: "Created" },
358
- ...errorResponses,
359
- },
360
- });
361
-
362
- export const updateBrandRoute = createRoute({
363
- method: "patch",
364
- path: "/brands/{brandId}",
365
- tags: ["Catalog"],
366
- summary: "Update a brand",
367
- request: {
368
- params: BrandIdParam,
369
- body: {
370
- content: { "application/json": { schema: UpdateBrandBodySchema } },
371
- required: true,
372
- },
373
- },
374
- responses: {
375
- 200: { content: { "application/json": { schema: DataResponse } }, description: "Updated" },
376
- ...errorResponses,
377
- },
378
- });
379
-
380
- export const createOptionTypeRoute = createRoute({
381
- method: "post",
382
- path: "/entities/{id}/options",
383
- tags: ["Catalog"],
384
- summary: "Create an option type for an entity",
385
- request: {
386
- params: EntityIdParam,
387
- body: {
388
- content: { "application/json": { schema: CreateOptionTypeBodySchema } },
389
- required: true,
390
- },
391
- },
392
- responses: {
393
- 201: { content: { "application/json": { schema: DataResponse } }, description: "Created" },
394
- ...errorResponses,
395
- },
396
- });
397
-
398
- export const createOptionValueRoute = createRoute({
399
- method: "post",
400
- path: "/options/{optionTypeId}/values",
401
- tags: ["Catalog"],
402
- summary: "Create an option value",
403
- request: {
404
- params: OptionTypeIdParam,
405
- body: {
406
- content: { "application/json": { schema: CreateOptionValueBodySchema } },
407
- required: true,
408
- },
409
- },
410
- responses: {
411
- 201: { content: { "application/json": { schema: DataResponse } }, description: "Created" },
412
- ...errorResponses,
413
- },
414
- });
415
-
416
- export const createVariantRoute = createRoute({
417
- method: "post",
418
- path: "/entities/{id}/variants",
419
- tags: ["Catalog"],
420
- summary: "Create a variant for an entity",
421
- request: {
422
- params: EntityIdParam,
423
- body: {
424
- content: { "application/json": { schema: CreateVariantBodySchema } },
425
- required: true,
426
- },
427
- },
428
- responses: {
429
- 201: { content: { "application/json": { schema: DataResponse } }, description: "Created" },
430
- ...errorResponses,
431
- },
432
- });
433
-
434
- export const generateVariantsRoute = createRoute({
435
- method: "post",
436
- path: "/entities/{id}/variants/generate",
437
- tags: ["Catalog"],
438
- summary: "Generate variants from option combinations",
439
- request: {
440
- params: EntityIdParam,
441
- body: {
442
- content: { "application/json": { schema: GenerateVariantsBodySchema } },
443
- required: true,
444
- },
445
- },
446
- responses: {
447
- 201: { content: { "application/json": { schema: DataResponse } }, description: "Generated" },
448
- ...errorResponses,
449
- },
450
- });
@@ -1,66 +0,0 @@
1
- import { z, createRoute } from "@hono/zod-openapi";
2
- import { ErrorSchema, errorResponses } from "./shared.js";
3
-
4
- // ─── Request Schema ──────────────────────────────────────────────────────────
5
-
6
- export const CheckoutBodySchema = z.object({
7
- cartId: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
8
- paymentMethodId: z.string().openapi({ example: "pm_card_visa" }),
9
- customerId: z.string().optional().openapi({ example: "customer-uuid-or-user-id" }),
10
- customerGroupIds: z.array(z.string()).optional(),
11
- currency: z.string().length(3).optional().openapi({ example: "USD" }),
12
- promotionCodes: z.array(z.string()).optional().openapi({ example: ["SUMMER10"] }),
13
- shippingAddress: z.object({
14
- line1: z.string(),
15
- line2: z.string().optional(),
16
- city: z.string(),
17
- state: z.string().optional(),
18
- postalCode: z.string(),
19
- country: z.string(),
20
- }).optional(),
21
- }).openapi("CheckoutRequest");
22
-
23
- // ─── Response Schema ─────────────────────────────────────────────────────────
24
-
25
- export const OrderResponseSchema = z.object({
26
- data: z.object({
27
- id: z.uuid(),
28
- orderNumber: z.string(),
29
- status: z.string(),
30
- currency: z.string(),
31
- subtotal: z.number(),
32
- taxTotal: z.number(),
33
- shippingTotal: z.number(),
34
- discountTotal: z.number(),
35
- grandTotal: z.number(),
36
- placedAt: z.string(),
37
- }),
38
- meta: z.object({
39
- hookErrors: z.array(z.string()),
40
- }).optional(),
41
- }).openapi("CheckoutResponse");
42
-
43
- // ─── Route Definition ────────────────────────────────────────────────────────
44
-
45
- export const checkoutRoute = createRoute({
46
- method: "post",
47
- path: "/",
48
- tags: ["Checkout"],
49
- summary: "Process checkout and create an order",
50
- description: "Validates cart, reserves inventory, authorizes payment, calculates tax/shipping, and creates the order.",
51
- request: {
52
- body: {
53
- content: {
54
- "application/json": { schema: CheckoutBodySchema },
55
- },
56
- required: true,
57
- },
58
- },
59
- responses: {
60
- 201: {
61
- content: { "application/json": { schema: OrderResponseSchema } },
62
- description: "Order created successfully.",
63
- },
64
- ...errorResponses,
65
- },
66
- });