@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,195 +0,0 @@
1
- import { z, createRoute } from "@hono/zod-openapi";
2
- import { errorResponses } from "./shared.js";
3
- import { CustomerResponse, OrderResponse, OrderListResponse, CustomerAddressListResponse, CartResponse } from "./responses.js";
4
-
5
- const GenericDataResponse = z.object({ data: z.record(z.string(), z.unknown()) });
6
-
7
- // ─── GET Route Definitions ─────────────────────────────────────────────────
8
-
9
- export const getProfileRoute = createRoute({
10
- method: "get",
11
- path: "/profile",
12
- tags: ["Customer Portal"],
13
- summary: "Get customer profile",
14
- responses: {
15
- 200: { content: { "application/json": { schema: CustomerResponse } }, description: "Customer profile" },
16
- ...errorResponses,
17
- },
18
- });
19
-
20
- export const listAddressesRoute = createRoute({
21
- method: "get",
22
- path: "/addresses",
23
- tags: ["Customer Portal"],
24
- summary: "List customer addresses",
25
- responses: {
26
- 200: { content: { "application/json": { schema: CustomerAddressListResponse } }, description: "Addresses" },
27
- },
28
- });
29
-
30
- export const listCustomerOrdersRoute = createRoute({
31
- method: "get",
32
- path: "/orders",
33
- tags: ["Customer Portal"],
34
- summary: "List customer orders",
35
- request: {
36
- query: z.object({
37
- status: z.string().optional(),
38
- page: z.string().optional(),
39
- limit: z.string().optional(),
40
- }),
41
- },
42
- responses: {
43
- 200: { content: { "application/json": { schema: OrderListResponse } }, description: "Orders" },
44
- },
45
- });
46
-
47
- export const getCustomerOrderRoute = createRoute({
48
- method: "get",
49
- path: "/orders/{idOrNumber}",
50
- tags: ["Customer Portal"],
51
- summary: "Get a specific customer order",
52
- request: {
53
- params: z.object({
54
- idOrNumber: z.string().min(1).openapi({ example: "ORD-001" }),
55
- }),
56
- },
57
- responses: {
58
- 200: { content: { "application/json": { schema: OrderResponse } }, description: "Order details" },
59
- ...errorResponses,
60
- },
61
- });
62
-
63
- export const getOrderTrackingRoute = createRoute({
64
- method: "get",
65
- path: "/orders/{idOrNumber}/tracking",
66
- tags: ["Customer Portal"],
67
- summary: "Get tracking info for an order",
68
- request: {
69
- params: z.object({
70
- idOrNumber: z.string().min(1).openapi({ example: "ORD-001" }),
71
- }),
72
- },
73
- responses: {
74
- 200: { content: { "application/json": { schema: GenericDataResponse } }, description: "Tracking info" },
75
- ...errorResponses,
76
- },
77
- });
78
-
79
- export const getOrderDownloadsRoute = createRoute({
80
- method: "get",
81
- path: "/orders/{orderId}/downloads",
82
- tags: ["Customer Portal"],
83
- summary: "Get digital downloads for an order",
84
- request: {
85
- params: z.object({
86
- orderId: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
87
- }),
88
- },
89
- responses: {
90
- 200: { content: { "application/json": { schema: GenericDataResponse } }, description: "Downloads" },
91
- ...errorResponses,
92
- },
93
- });
94
-
95
- export const listCoursesRoute = createRoute({
96
- method: "get",
97
- path: "/courses",
98
- tags: ["Customer Portal"],
99
- summary: "List customer course access",
100
- responses: {
101
- 200: { content: { "application/json": { schema: GenericDataResponse } }, description: "Courses" },
102
- },
103
- });
104
-
105
- // ─── DELETE Route Definitions ──────────────────────────────────────────────
106
-
107
- export const deleteAddressRoute = createRoute({
108
- method: "delete",
109
- path: "/addresses/{id}",
110
- tags: ["Customer Portal"],
111
- summary: "Delete a customer address",
112
- request: {
113
- params: z.object({
114
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
115
- }),
116
- },
117
- responses: {
118
- 200: { content: { "application/json": { schema: z.object({ data: z.object({ deleted: z.literal(true) }) }) } }, description: "Deleted" },
119
- ...errorResponses,
120
- },
121
- });
122
-
123
- // ─── POST Route Definitions (no body or special) ───────────────────────────
124
-
125
- export const reorderRoute = createRoute({
126
- method: "post",
127
- path: "/orders/{orderId}/reorder",
128
- tags: ["Customer Portal"],
129
- summary: "Reorder items from a previous order",
130
- request: {
131
- params: z.object({
132
- orderId: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
133
- }),
134
- },
135
- responses: {
136
- 201: { content: { "application/json": { schema: CartResponse } }, description: "Reorder cart created" },
137
- ...errorResponses,
138
- },
139
- });
140
-
141
- // ─── Mutation Route Definitions ─────────────────────────────────────────────
142
-
143
- const UpdateProfileBodySchema = z.object({
144
- firstName: z.string().optional(),
145
- lastName: z.string().optional(),
146
- phone: z.string().optional(),
147
- metadata: z.record(z.string(), z.unknown()).optional(),
148
- }).openapi("UpdateProfileBody");
149
-
150
- const CreateAddressBodySchema = z.object({
151
- type: z.enum(["shipping", "billing"]).openapi({ example: "shipping" }),
152
- firstName: z.string().openapi({ example: "John" }),
153
- lastName: z.string().openapi({ example: "Doe" }),
154
- line1: z.string().openapi({ example: "123 Main St" }),
155
- line2: z.string().optional(),
156
- city: z.string().openapi({ example: "New York" }),
157
- state: z.string().optional(),
158
- postalCode: z.string().optional(),
159
- country: z.string().openapi({ example: "US" }),
160
- phone: z.string().optional(),
161
- }).openapi("CreateAddressBody");
162
-
163
- export const updateProfileRoute = createRoute({
164
- method: "patch",
165
- path: "/profile",
166
- tags: ["Customer Portal"],
167
- summary: "Update customer profile",
168
- request: {
169
- body: {
170
- content: { "application/json": { schema: UpdateProfileBodySchema } },
171
- required: true,
172
- },
173
- },
174
- responses: {
175
- 200: { content: { "application/json": { schema: CustomerResponse } }, description: "Updated" },
176
- ...errorResponses,
177
- },
178
- });
179
-
180
- export const createAddressRoute = createRoute({
181
- method: "post",
182
- path: "/addresses",
183
- tags: ["Customer Portal"],
184
- summary: "Create a customer address",
185
- request: {
186
- body: {
187
- content: { "application/json": { schema: CreateAddressBodySchema } },
188
- required: true,
189
- },
190
- },
191
- responses: {
192
- 201: { content: { "application/json": { schema: GenericDataResponse } }, description: "Created" },
193
- ...errorResponses,
194
- },
195
- });
@@ -1,138 +0,0 @@
1
- import { z, createRoute } from "@hono/zod-openapi";
2
- import { ErrorSchema, errorResponses } from "./shared.js";
3
-
4
- // ─── Request Schemas ─────────────────────────────────────────────────────────
5
-
6
- import { InventoryAdjustBodySchema, InventoryReserveBodySchema, InventoryReleaseBodySchema } from "../../../modules/inventory/schemas.js";
7
- export { InventoryAdjustBodySchema, InventoryReserveBodySchema, InventoryReleaseBodySchema };
8
-
9
- export const CreateWarehouseBodySchema = z.object({
10
- name: z.string().openapi({ example: "Main Warehouse" }),
11
- code: z.string().optional().openapi({ example: "WH-MAIN" }),
12
- address: z.record(z.string(), z.unknown()).optional(),
13
- }).openapi("CreateWarehouseRequest");
14
-
15
- // ─── Route Definitions ──────────────────────────────────────────────────────
16
-
17
- export const inventoryCheckRoute = createRoute({
18
- method: "get",
19
- path: "/check",
20
- tags: ["Inventory"],
21
- summary: "Check inventory for entities",
22
- request: {
23
- query: z.object({
24
- entityIds: z.string().optional().openapi({ example: "uuid1,uuid2" }),
25
- }),
26
- },
27
- responses: {
28
- 200: {
29
- content: { "application/json": { schema: z.object({ data: z.record(z.string(), z.unknown()) }) } },
30
- description: "Inventory levels",
31
- },
32
- },
33
- });
34
-
35
- export const listWarehousesRoute = createRoute({
36
- method: "get",
37
- path: "/warehouses",
38
- tags: ["Inventory"],
39
- summary: "List all warehouses",
40
- responses: {
41
- 200: {
42
- content: { "application/json": { schema: z.object({ data: z.record(z.string(), z.unknown()) }) } },
43
- description: "Warehouses",
44
- },
45
- },
46
- });
47
-
48
- export const inventoryAdjustRoute = createRoute({
49
- method: "post",
50
- path: "/adjust",
51
- tags: ["Inventory"],
52
- summary: "Adjust inventory levels",
53
- description: "Adjusts the on-hand quantity for a given entity/variant in a warehouse.",
54
- request: {
55
- body: {
56
- content: {
57
- "application/json": { schema: InventoryAdjustBodySchema },
58
- },
59
- required: true,
60
- },
61
- },
62
- responses: {
63
- 200: {
64
- content: { "application/json": { schema: z.object({ data: z.record(z.string(), z.unknown()) }) } },
65
- description: "Inventory adjusted.",
66
- },
67
- ...errorResponses,
68
- },
69
- });
70
-
71
- export const inventoryReserveRoute = createRoute({
72
- method: "post",
73
- path: "/reserve",
74
- tags: ["Inventory"],
75
- summary: "Reserve inventory",
76
- description: "Reserves inventory quantity for an order.",
77
- request: {
78
- body: {
79
- content: {
80
- "application/json": { schema: InventoryReserveBodySchema },
81
- },
82
- required: true,
83
- },
84
- },
85
- responses: {
86
- 200: {
87
- content: { "application/json": { schema: z.object({ data: z.object({ reserved: z.literal(true) }) }) } },
88
- description: "Inventory reserved.",
89
- },
90
- ...errorResponses,
91
- },
92
- });
93
-
94
- export const inventoryReleaseRoute = createRoute({
95
- method: "post",
96
- path: "/release",
97
- tags: ["Inventory"],
98
- summary: "Release reserved inventory",
99
- description: "Releases previously reserved inventory back to available stock.",
100
- request: {
101
- body: {
102
- content: {
103
- "application/json": { schema: InventoryReleaseBodySchema },
104
- },
105
- required: true,
106
- },
107
- },
108
- responses: {
109
- 200: {
110
- content: { "application/json": { schema: z.object({ data: z.object({ released: z.literal(true) }) }) } },
111
- description: "Inventory released.",
112
- },
113
- ...errorResponses,
114
- },
115
- });
116
-
117
- export const createWarehouseRoute = createRoute({
118
- method: "post",
119
- path: "/warehouses",
120
- tags: ["Inventory"],
121
- summary: "Create a warehouse",
122
- description: "Creates a new warehouse for inventory management.",
123
- request: {
124
- body: {
125
- content: {
126
- "application/json": { schema: CreateWarehouseBodySchema },
127
- },
128
- required: true,
129
- },
130
- },
131
- responses: {
132
- 201: {
133
- content: { "application/json": { schema: z.object({ data: z.record(z.string(), z.unknown()) }) } },
134
- description: "Warehouse created.",
135
- },
136
- ...errorResponses,
137
- },
138
- });
@@ -1,75 +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 AttachMediaBodySchema = z.object({
7
- mediaAssetId: z.string().openapi({ example: "asset-uuid" }),
8
- entityId: z.string().openapi({ example: "product-uuid" }),
9
- role: z.enum(["primary", "gallery", "thumbnail", "video", "document"]).openapi({ example: "primary" }),
10
- variantId: z.string().optional(),
11
- sortOrder: z.number().optional().openapi({ example: 0 }),
12
- }).openapi("AttachMediaRequest");
13
-
14
- // ─── Route Definitions ──────────────────────────────────────────────────────
15
-
16
- export const getMediaRoute = createRoute({
17
- method: "get",
18
- path: "/{id}",
19
- tags: ["Media"],
20
- summary: "Get a media asset (redirects to URL)",
21
- request: {
22
- params: z.object({
23
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
24
- }),
25
- query: z.object({
26
- signed: z.string().optional().openapi({ example: "true" }),
27
- }),
28
- },
29
- responses: {
30
- 302: { description: "Redirect to media URL" },
31
- ...errorResponses,
32
- },
33
- });
34
-
35
- export const deleteMediaRoute = createRoute({
36
- method: "delete",
37
- path: "/{id}",
38
- tags: ["Media"],
39
- summary: "Delete a media asset",
40
- request: {
41
- params: z.object({
42
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
43
- }),
44
- },
45
- responses: {
46
- 200: {
47
- content: { "application/json": { schema: z.object({ data: z.object({ deleted: z.literal(true) }) }) } },
48
- description: "Media deleted.",
49
- },
50
- ...errorResponses,
51
- },
52
- });
53
-
54
- export const attachMediaRoute = createRoute({
55
- method: "post",
56
- path: "/attach",
57
- tags: ["Media"],
58
- summary: "Attach a media asset to an entity",
59
- description: "Links an uploaded media asset to a catalog entity (product, variant, etc.).",
60
- request: {
61
- body: {
62
- content: {
63
- "application/json": { schema: AttachMediaBodySchema },
64
- },
65
- required: true,
66
- },
67
- },
68
- responses: {
69
- 201: {
70
- content: { "application/json": { schema: z.object({ data: z.object({ attached: z.literal(true) }) }) } },
71
- description: "Media attached to entity.",
72
- },
73
- ...errorResponses,
74
- },
75
- });
@@ -1,104 +0,0 @@
1
- import { z, createRoute } from "@hono/zod-openapi";
2
- import { ErrorSchema, errorResponses } from "./shared.js";
3
- import { OrderResponse, OrderListResponse } from "./responses.js";
4
-
5
- // ─── Request Schemas ────────────────────────────────────────────────────────
6
-
7
- export const ChangeOrderStatusBodySchema = z.object({
8
- // Accept any string — custom state machines (e.g., BNPL) add states like
9
- // "payment_initiated", "shipped", "delivered" etc. The order service's
10
- // state machine validates valid transitions at runtime.
11
- status: z.string().min(1).openapi({ example: "confirmed" }),
12
- reason: z.string().optional().openapi({ example: "Payment verified" }),
13
- }).openapi("ChangeOrderStatusRequest");
14
-
15
- // ─── Response Schemas ───────────────────────────────────────────────────────
16
-
17
- export const OrderDataResponseSchema = OrderResponse;
18
-
19
- // ─── Path Params ────────────────────────────────────────────────────────────
20
-
21
- const OrderIdParam = z.object({
22
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
23
- });
24
-
25
- // ─── Route Definitions ──────────────────────────────────────────────────────
26
-
27
- export const listOrdersRoute = createRoute({
28
- method: "get",
29
- path: "/",
30
- tags: ["Orders"],
31
- summary: "List orders",
32
- request: {
33
- query: z.object({
34
- status: z.string().optional(),
35
- page: z.string().optional(),
36
- limit: z.string().optional(),
37
- }),
38
- },
39
- responses: {
40
- 200: {
41
- content: { "application/json": { schema: OrderListResponse } },
42
- description: "Success",
43
- },
44
- },
45
- });
46
-
47
- export const getOrderRoute = createRoute({
48
- method: "get",
49
- path: "/{idOrNumber}",
50
- tags: ["Orders"],
51
- summary: "Get an order by ID or order number",
52
- request: {
53
- params: z.object({
54
- idOrNumber: z.string().min(1).openapi({ example: "ORD-001" }),
55
- }),
56
- },
57
- responses: {
58
- 200: {
59
- content: { "application/json": { schema: OrderDataResponseSchema } },
60
- description: "Success",
61
- },
62
- ...errorResponses,
63
- },
64
- });
65
-
66
- export const getOrderFulfillmentsRoute = createRoute({
67
- method: "get",
68
- path: "/{id}/fulfillments",
69
- tags: ["Orders"],
70
- summary: "Get fulfillments for an order",
71
- request: {
72
- params: OrderIdParam,
73
- },
74
- responses: {
75
- 200: {
76
- content: { "application/json": { schema: OrderDataResponseSchema } },
77
- description: "Success",
78
- },
79
- ...errorResponses,
80
- },
81
- });
82
-
83
- export const changeOrderStatusRoute = createRoute({
84
- method: "patch",
85
- path: "/{id}/status",
86
- tags: ["Orders"],
87
- summary: "Change the status of an order",
88
- request: {
89
- params: OrderIdParam,
90
- body: {
91
- content: {
92
- "application/json": { schema: ChangeOrderStatusBodySchema },
93
- },
94
- required: true,
95
- },
96
- },
97
- responses: {
98
- 200: {
99
- content: { "application/json": { schema: OrderDataResponseSchema } },
100
- description: "Order status updated.",
101
- },
102
- ...errorResponses,
103
- },
104
- });
@@ -1,80 +0,0 @@
1
- import { z, createRoute } from "@hono/zod-openapi";
2
- import { ErrorSchema, errorResponses } from "./shared.js";
3
-
4
- // ─── Request Schemas ────────────────────────────────────────────────────────
5
-
6
- import { SetBasePriceBodySchema, CreateModifierBodySchema } from "../../../modules/pricing/schemas.js";
7
- export { SetBasePriceBodySchema, CreateModifierBodySchema };
8
-
9
- // ─── Response Schemas ───────────────────────────────────────────────────────
10
-
11
- export const PricingResponseSchema = z.object({
12
- data: z.record(z.string(), z.unknown()),
13
- }).openapi("PricingResponse");
14
-
15
- // ─── Route Definitions ──────────────────────────────────────────────────────
16
-
17
- export const listPricesRoute = createRoute({
18
- method: "get",
19
- path: "/prices",
20
- tags: ["Pricing"],
21
- summary: "List prices",
22
- request: {
23
- query: z.object({
24
- entityId: z.string().optional(),
25
- variantId: z.string().optional(),
26
- currency: z.string().optional(),
27
- customerGroupId: z.string().optional(),
28
- }),
29
- },
30
- responses: {
31
- 200: {
32
- content: { "application/json": { schema: PricingResponseSchema } },
33
- description: "Prices",
34
- },
35
- },
36
- });
37
-
38
- export const setBasePriceRoute = createRoute({
39
- method: "post",
40
- path: "/prices",
41
- tags: ["Pricing"],
42
- summary: "Set a base price for a product or variant",
43
- request: {
44
- body: {
45
- content: {
46
- "application/json": { schema: SetBasePriceBodySchema },
47
- },
48
- required: true,
49
- },
50
- },
51
- responses: {
52
- 201: {
53
- content: { "application/json": { schema: PricingResponseSchema } },
54
- description: "Base price set successfully.",
55
- },
56
- ...errorResponses,
57
- },
58
- });
59
-
60
- export const createModifierRoute = createRoute({
61
- method: "post",
62
- path: "/modifiers",
63
- tags: ["Pricing"],
64
- summary: "Create a price modifier",
65
- request: {
66
- body: {
67
- content: {
68
- "application/json": { schema: CreateModifierBodySchema },
69
- },
70
- required: true,
71
- },
72
- },
73
- responses: {
74
- 201: {
75
- content: { "application/json": { schema: PricingResponseSchema } },
76
- description: "Price modifier created successfully.",
77
- },
78
- ...errorResponses,
79
- },
80
- });
@@ -1,110 +0,0 @@
1
- import { z, createRoute } from "@hono/zod-openapi";
2
- import { ErrorSchema, errorResponses, UuidParamSchema } from "./shared.js";
3
-
4
- // ─── Request Schemas ────────────────────────────────────────────────────────
5
-
6
- import { CreatePromotionBodySchema } from "../../../modules/promotions/schemas.js";
7
- export { CreatePromotionBodySchema };
8
-
9
- export const ValidatePromotionBodySchema = z.object({
10
- code: z.string().openapi({ example: "SUMMER10" }),
11
- currency: z.string().length(3).openapi({ example: "USD" }),
12
- subtotal: z.number().openapi({ example: 100 }),
13
- lineItems: z.array(z.object({
14
- entityId: z.string(),
15
- entityType: z.string(),
16
- quantity: z.number().int(),
17
- unitPrice: z.number(),
18
- totalPrice: z.number(),
19
- })),
20
- customerId: z.string().optional(),
21
- customerGroupIds: z.array(z.string()).optional(),
22
- }).openapi("ValidatePromotionRequest");
23
-
24
- // ─── Response Schemas ───────────────────────────────────────────────────────
25
-
26
- export const PromotionResponseSchema = z.object({
27
- data: z.record(z.string(), z.unknown()),
28
- }).openapi("PromotionResponse");
29
-
30
- // ─── Path Params ────────────────────────────────────────────────────────────
31
-
32
- const PromotionIdParam = z.object({
33
- id: z.uuid().openapi({ example: "550e8400-e29b-41d4-a716-446655440000" }),
34
- });
35
-
36
- // ─── Route Definitions ──────────────────────────────────────────────────────
37
-
38
- export const listActivePromotionsRoute = createRoute({
39
- method: "get",
40
- path: "/",
41
- tags: ["Promotions"],
42
- summary: "List active promotions",
43
- responses: {
44
- 200: {
45
- content: { "application/json": { schema: PromotionResponseSchema } },
46
- description: "Active promotions",
47
- },
48
- },
49
- });
50
-
51
- export const createPromotionRoute = createRoute({
52
- method: "post",
53
- path: "/",
54
- tags: ["Promotions"],
55
- summary: "Create a new promotion",
56
- request: {
57
- body: {
58
- content: {
59
- "application/json": { schema: CreatePromotionBodySchema },
60
- },
61
- required: true,
62
- },
63
- },
64
- responses: {
65
- 201: {
66
- content: { "application/json": { schema: PromotionResponseSchema } },
67
- description: "Promotion created successfully.",
68
- },
69
- ...errorResponses,
70
- },
71
- });
72
-
73
- export const validatePromotionRoute = createRoute({
74
- method: "post",
75
- path: "/validate",
76
- tags: ["Promotions"],
77
- summary: "Validate a promotion code against a cart",
78
- request: {
79
- body: {
80
- content: {
81
- "application/json": { schema: ValidatePromotionBodySchema },
82
- },
83
- required: true,
84
- },
85
- },
86
- responses: {
87
- 200: {
88
- content: { "application/json": { schema: PromotionResponseSchema } },
89
- description: "Promotion validation result.",
90
- },
91
- ...errorResponses,
92
- },
93
- });
94
-
95
- export const deactivatePromotionRoute = createRoute({
96
- method: "post",
97
- path: "/{id}/deactivate",
98
- tags: ["Promotions"],
99
- summary: "Deactivate a promotion",
100
- request: {
101
- params: PromotionIdParam,
102
- },
103
- responses: {
104
- 200: {
105
- content: { "application/json": { schema: PromotionResponseSchema } },
106
- description: "Promotion deactivated.",
107
- },
108
- ...errorResponses,
109
- },
110
- });