@unifiedcommerce/core 0.1.0 → 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 (174) hide show
  1. package/package.json +1 -2
  2. package/src/adapters/console-email.ts +0 -43
  3. package/src/auth/access.ts +0 -187
  4. package/src/auth/auth-schema.ts +0 -139
  5. package/src/auth/middleware.ts +0 -161
  6. package/src/auth/org.ts +0 -41
  7. package/src/auth/permissions.ts +0 -28
  8. package/src/auth/setup.ts +0 -169
  9. package/src/auth/system-actor.ts +0 -19
  10. package/src/auth/types.ts +0 -10
  11. package/src/config/defaults.ts +0 -82
  12. package/src/config/define-config.ts +0 -53
  13. package/src/config/types.ts +0 -299
  14. package/src/generated/plugin-capabilities.d.ts +0 -20
  15. package/src/generated/plugin-manifest.ts +0 -23
  16. package/src/generated/plugin-repositories.d.ts +0 -20
  17. package/src/hooks/checkout-completion.ts +0 -262
  18. package/src/hooks/checkout.ts +0 -677
  19. package/src/hooks/order-emails.ts +0 -62
  20. package/src/index.ts +0 -214
  21. package/src/interfaces/mcp/agent-prompt.ts +0 -174
  22. package/src/interfaces/mcp/context-enrichment.ts +0 -177
  23. package/src/interfaces/mcp/server.ts +0 -617
  24. package/src/interfaces/mcp/transport.ts +0 -68
  25. package/src/interfaces/rest/customer-portal.ts +0 -299
  26. package/src/interfaces/rest/index.ts +0 -74
  27. package/src/interfaces/rest/router.ts +0 -334
  28. package/src/interfaces/rest/routes/admin-jobs.ts +0 -58
  29. package/src/interfaces/rest/routes/audit.ts +0 -50
  30. package/src/interfaces/rest/routes/carts.ts +0 -89
  31. package/src/interfaces/rest/routes/catalog.ts +0 -493
  32. package/src/interfaces/rest/routes/checkout.ts +0 -283
  33. package/src/interfaces/rest/routes/inventory.ts +0 -70
  34. package/src/interfaces/rest/routes/media.ts +0 -86
  35. package/src/interfaces/rest/routes/orders.ts +0 -78
  36. package/src/interfaces/rest/routes/payments.ts +0 -60
  37. package/src/interfaces/rest/routes/pricing.ts +0 -57
  38. package/src/interfaces/rest/routes/promotions.ts +0 -92
  39. package/src/interfaces/rest/routes/search.ts +0 -71
  40. package/src/interfaces/rest/routes/webhooks.ts +0 -46
  41. package/src/interfaces/rest/schemas/admin-jobs.ts +0 -40
  42. package/src/interfaces/rest/schemas/audit.ts +0 -46
  43. package/src/interfaces/rest/schemas/carts.ts +0 -125
  44. package/src/interfaces/rest/schemas/catalog.ts +0 -450
  45. package/src/interfaces/rest/schemas/checkout.ts +0 -66
  46. package/src/interfaces/rest/schemas/customer-portal.ts +0 -195
  47. package/src/interfaces/rest/schemas/inventory.ts +0 -138
  48. package/src/interfaces/rest/schemas/media.ts +0 -75
  49. package/src/interfaces/rest/schemas/orders.ts +0 -104
  50. package/src/interfaces/rest/schemas/pricing.ts +0 -80
  51. package/src/interfaces/rest/schemas/promotions.ts +0 -110
  52. package/src/interfaces/rest/schemas/responses.ts +0 -85
  53. package/src/interfaces/rest/schemas/search.ts +0 -58
  54. package/src/interfaces/rest/schemas/shared.ts +0 -62
  55. package/src/interfaces/rest/schemas/webhooks.ts +0 -68
  56. package/src/interfaces/rest/utils.ts +0 -104
  57. package/src/interfaces/rest/webhook-router.ts +0 -50
  58. package/src/kernel/compensation/executor.ts +0 -61
  59. package/src/kernel/compensation/types.ts +0 -26
  60. package/src/kernel/database/adapter.ts +0 -13
  61. package/src/kernel/database/drizzle-db.ts +0 -56
  62. package/src/kernel/database/migrate.ts +0 -76
  63. package/src/kernel/database/plugin-types.ts +0 -34
  64. package/src/kernel/database/schema.ts +0 -49
  65. package/src/kernel/database/scoped-db.ts +0 -68
  66. package/src/kernel/database/tx-context.ts +0 -46
  67. package/src/kernel/error-mapper.ts +0 -15
  68. package/src/kernel/errors.ts +0 -89
  69. package/src/kernel/factory/repository-factory.ts +0 -242
  70. package/src/kernel/hooks/create-context.ts +0 -43
  71. package/src/kernel/hooks/executor.ts +0 -88
  72. package/src/kernel/hooks/registry.ts +0 -74
  73. package/src/kernel/hooks/types.ts +0 -52
  74. package/src/kernel/http-error.ts +0 -44
  75. package/src/kernel/jobs/adapter.ts +0 -36
  76. package/src/kernel/jobs/drizzle-adapter.ts +0 -58
  77. package/src/kernel/jobs/runner.ts +0 -153
  78. package/src/kernel/jobs/schema.ts +0 -46
  79. package/src/kernel/jobs/types.ts +0 -30
  80. package/src/kernel/local-api.ts +0 -185
  81. package/src/kernel/plugin/manifest.ts +0 -253
  82. package/src/kernel/query/executor.ts +0 -184
  83. package/src/kernel/query/registry.ts +0 -46
  84. package/src/kernel/result.ts +0 -33
  85. package/src/kernel/schema/extra-columns.ts +0 -37
  86. package/src/kernel/service-registry.ts +0 -76
  87. package/src/kernel/service-timing.ts +0 -89
  88. package/src/kernel/state-machine/machine.ts +0 -101
  89. package/src/modules/analytics/drizzle-adapter.ts +0 -426
  90. package/src/modules/analytics/hooks.ts +0 -11
  91. package/src/modules/analytics/models.ts +0 -125
  92. package/src/modules/analytics/repository/index.ts +0 -6
  93. package/src/modules/analytics/service.ts +0 -245
  94. package/src/modules/analytics/types.ts +0 -180
  95. package/src/modules/audit/hooks.ts +0 -78
  96. package/src/modules/audit/schema.ts +0 -33
  97. package/src/modules/audit/service.ts +0 -151
  98. package/src/modules/cart/access.ts +0 -27
  99. package/src/modules/cart/matcher.ts +0 -26
  100. package/src/modules/cart/repository/index.ts +0 -234
  101. package/src/modules/cart/schema.ts +0 -42
  102. package/src/modules/cart/schemas.ts +0 -38
  103. package/src/modules/cart/service.ts +0 -541
  104. package/src/modules/catalog/repository/index.ts +0 -772
  105. package/src/modules/catalog/schema.ts +0 -203
  106. package/src/modules/catalog/schemas.ts +0 -104
  107. package/src/modules/catalog/service.ts +0 -1544
  108. package/src/modules/customers/repository/index.ts +0 -327
  109. package/src/modules/customers/schema.ts +0 -64
  110. package/src/modules/customers/service.ts +0 -171
  111. package/src/modules/fulfillment/repository/index.ts +0 -426
  112. package/src/modules/fulfillment/schema.ts +0 -101
  113. package/src/modules/fulfillment/service.ts +0 -555
  114. package/src/modules/fulfillment/types.ts +0 -59
  115. package/src/modules/inventory/repository/index.ts +0 -509
  116. package/src/modules/inventory/schema.ts +0 -94
  117. package/src/modules/inventory/schemas.ts +0 -38
  118. package/src/modules/inventory/service.ts +0 -490
  119. package/src/modules/media/adapter.ts +0 -17
  120. package/src/modules/media/repository/index.ts +0 -274
  121. package/src/modules/media/schema.ts +0 -41
  122. package/src/modules/media/service.ts +0 -151
  123. package/src/modules/orders/repository/index.ts +0 -287
  124. package/src/modules/orders/schema.ts +0 -66
  125. package/src/modules/orders/service.ts +0 -619
  126. package/src/modules/orders/stale-order-cleanup.ts +0 -76
  127. package/src/modules/organization/service.ts +0 -191
  128. package/src/modules/payments/adapter.ts +0 -47
  129. package/src/modules/payments/repository/index.ts +0 -6
  130. package/src/modules/payments/service.ts +0 -107
  131. package/src/modules/pricing/repository/index.ts +0 -291
  132. package/src/modules/pricing/schema.ts +0 -71
  133. package/src/modules/pricing/schemas.ts +0 -38
  134. package/src/modules/pricing/service.ts +0 -494
  135. package/src/modules/promotions/repository/index.ts +0 -325
  136. package/src/modules/promotions/schema.ts +0 -62
  137. package/src/modules/promotions/schemas.ts +0 -38
  138. package/src/modules/promotions/service.ts +0 -598
  139. package/src/modules/search/adapter.ts +0 -57
  140. package/src/modules/search/hooks.ts +0 -12
  141. package/src/modules/search/repository/index.ts +0 -6
  142. package/src/modules/search/service.ts +0 -315
  143. package/src/modules/shipping/calculator.ts +0 -188
  144. package/src/modules/shipping/repository/index.ts +0 -6
  145. package/src/modules/shipping/service.ts +0 -51
  146. package/src/modules/tax/adapter.ts +0 -60
  147. package/src/modules/tax/repository/index.ts +0 -6
  148. package/src/modules/tax/service.ts +0 -53
  149. package/src/modules/webhooks/hook.ts +0 -34
  150. package/src/modules/webhooks/repository/index.ts +0 -278
  151. package/src/modules/webhooks/schema.ts +0 -56
  152. package/src/modules/webhooks/service.ts +0 -117
  153. package/src/modules/webhooks/signing.ts +0 -6
  154. package/src/modules/webhooks/ssrf-guard.ts +0 -71
  155. package/src/modules/webhooks/tasks.ts +0 -52
  156. package/src/modules/webhooks/worker.ts +0 -134
  157. package/src/runtime/commerce.ts +0 -145
  158. package/src/runtime/kernel.ts +0 -419
  159. package/src/runtime/logger.ts +0 -36
  160. package/src/runtime/server.ts +0 -349
  161. package/src/runtime/shutdown.ts +0 -43
  162. package/src/test-utils/create-pglite-adapter.ts +0 -129
  163. package/src/test-utils/create-plugin-test-app.ts +0 -128
  164. package/src/test-utils/create-repository-test-harness.ts +0 -16
  165. package/src/test-utils/create-test-config.ts +0 -190
  166. package/src/test-utils/create-test-kernel.ts +0 -7
  167. package/src/test-utils/create-test-plugin-context.ts +0 -75
  168. package/src/test-utils/rest-api-test-utils.ts +0 -265
  169. package/src/test-utils/test-actors.ts +0 -62
  170. package/src/test-utils/typed-hooks.ts +0 -54
  171. package/src/types/commerce-types.ts +0 -34
  172. package/src/utils/id.ts +0 -3
  173. package/src/utils/logger.ts +0 -18
  174. 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
- });