@contractspec/example.marketplace 1.56.1 → 1.58.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.
Files changed (302) hide show
  1. package/dist/browser/docs/index.js +103 -0
  2. package/dist/browser/docs/marketplace.docblock.js +103 -0
  3. package/dist/browser/entities/index.js +721 -0
  4. package/dist/browser/entities/order.js +167 -0
  5. package/dist/browser/entities/payout.js +142 -0
  6. package/dist/browser/entities/product.js +152 -0
  7. package/dist/browser/entities/review.js +129 -0
  8. package/dist/browser/entities/store.js +97 -0
  9. package/dist/browser/example.js +42 -0
  10. package/dist/browser/handlers/index.js +303 -0
  11. package/dist/browser/handlers/marketplace.handlers.js +303 -0
  12. package/dist/browser/index.js +2016 -0
  13. package/dist/browser/marketplace.capability.js +40 -0
  14. package/dist/browser/marketplace.feature.js +137 -0
  15. package/dist/browser/order/index.js +307 -0
  16. package/dist/browser/order/order.enum.js +17 -0
  17. package/dist/browser/order/order.event.js +131 -0
  18. package/dist/browser/order/order.operations.js +172 -0
  19. package/dist/browser/order/order.presentation.js +153 -0
  20. package/dist/browser/order/order.schema.js +79 -0
  21. package/dist/browser/payout/index.js +152 -0
  22. package/dist/browser/payout/payout.enum.js +12 -0
  23. package/dist/browser/payout/payout.event.js +55 -0
  24. package/dist/browser/payout/payout.operations.js +94 -0
  25. package/dist/browser/payout/payout.presentation.js +111 -0
  26. package/dist/browser/payout/payout.schema.js +61 -0
  27. package/dist/browser/product/index.js +249 -0
  28. package/dist/browser/product/product.enum.js +13 -0
  29. package/dist/browser/product/product.event.js +74 -0
  30. package/dist/browser/product/product.operations.js +171 -0
  31. package/dist/browser/product/product.presentation.js +158 -0
  32. package/dist/browser/product/product.schema.js +84 -0
  33. package/dist/browser/review/index.js +206 -0
  34. package/dist/browser/review/review.enum.js +11 -0
  35. package/dist/browser/review/review.event.js +50 -0
  36. package/dist/browser/review/review.operations.js +152 -0
  37. package/dist/browser/review/review.presentation.js +123 -0
  38. package/dist/browser/review/review.schema.js +74 -0
  39. package/dist/browser/seeders/index.js +12 -0
  40. package/dist/browser/store/index.js +142 -0
  41. package/dist/browser/store/store.enum.js +11 -0
  42. package/dist/browser/store/store.event.js +52 -0
  43. package/dist/browser/store/store.operations.js +88 -0
  44. package/dist/browser/store/store.presentation.js +94 -0
  45. package/dist/browser/store/store.schema.js +43 -0
  46. package/dist/browser/tests/operations.test-spec.js +139 -0
  47. package/dist/browser/ui/MarketplaceDashboard.js +418 -0
  48. package/dist/browser/ui/hooks/index.js +59 -0
  49. package/dist/browser/ui/hooks/useMarketplaceData.js +56 -0
  50. package/dist/browser/ui/index.js +668 -0
  51. package/dist/browser/ui/renderers/index.js +248 -0
  52. package/dist/browser/ui/renderers/marketplace.markdown.js +248 -0
  53. package/dist/docs/index.d.ts +2 -1
  54. package/dist/docs/index.d.ts.map +1 -0
  55. package/dist/docs/index.js +104 -1
  56. package/dist/docs/marketplace.docblock.d.ts +2 -1
  57. package/dist/docs/marketplace.docblock.d.ts.map +1 -0
  58. package/dist/docs/marketplace.docblock.js +46 -57
  59. package/dist/entities/index.d.ts +302 -307
  60. package/dist/entities/index.d.ts.map +1 -1
  61. package/dist/entities/index.js +719 -43
  62. package/dist/entities/order.d.ts +77 -82
  63. package/dist/entities/order.d.ts.map +1 -1
  64. package/dist/entities/order.js +162 -167
  65. package/dist/entities/payout.d.ts +64 -69
  66. package/dist/entities/payout.d.ts.map +1 -1
  67. package/dist/entities/payout.js +137 -156
  68. package/dist/entities/product.d.ts +69 -74
  69. package/dist/entities/product.d.ts.map +1 -1
  70. package/dist/entities/product.js +148 -156
  71. package/dist/entities/review.d.ts +55 -60
  72. package/dist/entities/review.d.ts.map +1 -1
  73. package/dist/entities/review.js +124 -146
  74. package/dist/entities/store.d.ts +40 -45
  75. package/dist/entities/store.d.ts.map +1 -1
  76. package/dist/entities/store.js +94 -106
  77. package/dist/example.d.ts +2 -6
  78. package/dist/example.d.ts.map +1 -1
  79. package/dist/example.js +40 -55
  80. package/dist/handlers/index.d.ts +2 -2
  81. package/dist/handlers/index.d.ts.map +1 -0
  82. package/dist/handlers/index.js +304 -3
  83. package/dist/handlers/marketplace.handlers.d.ts +138 -138
  84. package/dist/handlers/marketplace.handlers.d.ts.map +1 -1
  85. package/dist/handlers/marketplace.handlers.js +284 -309
  86. package/dist/index.d.ts +13 -31
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +2017 -32
  89. package/dist/marketplace.capability.d.ts +3 -8
  90. package/dist/marketplace.capability.d.ts.map +1 -1
  91. package/dist/marketplace.capability.js +41 -34
  92. package/dist/marketplace.feature.d.ts +1 -7
  93. package/dist/marketplace.feature.d.ts.map +1 -1
  94. package/dist/marketplace.feature.js +136 -313
  95. package/dist/node/docs/index.js +103 -0
  96. package/dist/node/docs/marketplace.docblock.js +103 -0
  97. package/dist/node/entities/index.js +721 -0
  98. package/dist/node/entities/order.js +167 -0
  99. package/dist/node/entities/payout.js +142 -0
  100. package/dist/node/entities/product.js +152 -0
  101. package/dist/node/entities/review.js +129 -0
  102. package/dist/node/entities/store.js +97 -0
  103. package/dist/node/example.js +42 -0
  104. package/dist/node/handlers/index.js +303 -0
  105. package/dist/node/handlers/marketplace.handlers.js +303 -0
  106. package/dist/node/index.js +2016 -0
  107. package/dist/node/marketplace.capability.js +40 -0
  108. package/dist/node/marketplace.feature.js +137 -0
  109. package/dist/node/order/index.js +307 -0
  110. package/dist/node/order/order.enum.js +17 -0
  111. package/dist/node/order/order.event.js +131 -0
  112. package/dist/node/order/order.operations.js +172 -0
  113. package/dist/node/order/order.presentation.js +153 -0
  114. package/dist/node/order/order.schema.js +79 -0
  115. package/dist/node/payout/index.js +152 -0
  116. package/dist/node/payout/payout.enum.js +12 -0
  117. package/dist/node/payout/payout.event.js +55 -0
  118. package/dist/node/payout/payout.operations.js +94 -0
  119. package/dist/node/payout/payout.presentation.js +111 -0
  120. package/dist/node/payout/payout.schema.js +61 -0
  121. package/dist/node/product/index.js +249 -0
  122. package/dist/node/product/product.enum.js +13 -0
  123. package/dist/node/product/product.event.js +74 -0
  124. package/dist/node/product/product.operations.js +171 -0
  125. package/dist/node/product/product.presentation.js +158 -0
  126. package/dist/node/product/product.schema.js +84 -0
  127. package/dist/node/review/index.js +206 -0
  128. package/dist/node/review/review.enum.js +11 -0
  129. package/dist/node/review/review.event.js +50 -0
  130. package/dist/node/review/review.operations.js +152 -0
  131. package/dist/node/review/review.presentation.js +123 -0
  132. package/dist/node/review/review.schema.js +74 -0
  133. package/dist/node/seeders/index.js +12 -0
  134. package/dist/node/store/index.js +142 -0
  135. package/dist/node/store/store.enum.js +11 -0
  136. package/dist/node/store/store.event.js +52 -0
  137. package/dist/node/store/store.operations.js +88 -0
  138. package/dist/node/store/store.presentation.js +94 -0
  139. package/dist/node/store/store.schema.js +43 -0
  140. package/dist/node/tests/operations.test-spec.js +139 -0
  141. package/dist/node/ui/MarketplaceDashboard.js +418 -0
  142. package/dist/node/ui/hooks/index.js +59 -0
  143. package/dist/node/ui/hooks/useMarketplaceData.js +56 -0
  144. package/dist/node/ui/index.js +668 -0
  145. package/dist/node/ui/renderers/index.js +248 -0
  146. package/dist/node/ui/renderers/marketplace.markdown.js +248 -0
  147. package/dist/order/index.d.ts +8 -5
  148. package/dist/order/index.d.ts.map +1 -0
  149. package/dist/order/index.js +307 -5
  150. package/dist/order/order.enum.d.ts +1 -6
  151. package/dist/order/order.enum.d.ts.map +1 -1
  152. package/dist/order/order.enum.js +16 -20
  153. package/dist/order/order.event.d.ts +133 -139
  154. package/dist/order/order.event.d.ts.map +1 -1
  155. package/dist/order/order.event.js +121 -205
  156. package/dist/order/order.operations.d.ts +291 -297
  157. package/dist/order/order.operations.d.ts.map +1 -1
  158. package/dist/order/order.operations.js +169 -115
  159. package/dist/order/order.presentation.d.ts +3 -8
  160. package/dist/order/order.presentation.d.ts.map +1 -1
  161. package/dist/order/order.presentation.js +149 -81
  162. package/dist/order/order.schema.d.ts +143 -148
  163. package/dist/order/order.schema.d.ts.map +1 -1
  164. package/dist/order/order.schema.js +75 -150
  165. package/dist/payout/index.d.ts +8 -5
  166. package/dist/payout/index.d.ts.map +1 -0
  167. package/dist/payout/index.js +152 -5
  168. package/dist/payout/payout.enum.d.ts +1 -6
  169. package/dist/payout/payout.enum.d.ts.map +1 -1
  170. package/dist/payout/payout.enum.js +11 -15
  171. package/dist/payout/payout.event.d.ts +54 -60
  172. package/dist/payout/payout.event.d.ts.map +1 -1
  173. package/dist/payout/payout.event.js +51 -87
  174. package/dist/payout/payout.operations.d.ts +82 -88
  175. package/dist/payout/payout.operations.d.ts.map +1 -1
  176. package/dist/payout/payout.operations.js +92 -50
  177. package/dist/payout/payout.presentation.d.ts +2 -7
  178. package/dist/payout/payout.presentation.d.ts.map +1 -1
  179. package/dist/payout/payout.presentation.js +108 -56
  180. package/dist/payout/payout.schema.d.ts +139 -144
  181. package/dist/payout/payout.schema.d.ts.map +1 -1
  182. package/dist/payout/payout.schema.js +58 -112
  183. package/dist/product/index.d.ts +8 -5
  184. package/dist/product/index.d.ts.map +1 -0
  185. package/dist/product/index.js +249 -5
  186. package/dist/product/product.enum.d.ts +1 -6
  187. package/dist/product/product.enum.d.ts.map +1 -1
  188. package/dist/product/product.enum.js +12 -16
  189. package/dist/product/product.event.d.ts +63 -69
  190. package/dist/product/product.event.d.ts.map +1 -1
  191. package/dist/product/product.event.js +68 -113
  192. package/dist/product/product.operations.d.ts +225 -231
  193. package/dist/product/product.operations.d.ts.map +1 -1
  194. package/dist/product/product.operations.js +168 -104
  195. package/dist/product/product.presentation.d.ts +3 -8
  196. package/dist/product/product.presentation.d.ts.map +1 -1
  197. package/dist/product/product.presentation.js +154 -81
  198. package/dist/product/product.schema.d.ts +196 -201
  199. package/dist/product/product.schema.d.ts.map +1 -1
  200. package/dist/product/product.schema.js +80 -171
  201. package/dist/review/index.d.ts +8 -5
  202. package/dist/review/index.d.ts.map +1 -0
  203. package/dist/review/index.js +206 -5
  204. package/dist/review/review.enum.d.ts +1 -6
  205. package/dist/review/review.enum.d.ts.map +1 -1
  206. package/dist/review/review.enum.js +10 -14
  207. package/dist/review/review.event.d.ts +46 -52
  208. package/dist/review/review.event.d.ts.map +1 -1
  209. package/dist/review/review.event.js +46 -79
  210. package/dist/review/review.operations.d.ts +190 -196
  211. package/dist/review/review.operations.d.ts.map +1 -1
  212. package/dist/review/review.operations.js +149 -102
  213. package/dist/review/review.presentation.d.ts +2 -7
  214. package/dist/review/review.presentation.d.ts.map +1 -1
  215. package/dist/review/review.presentation.js +120 -56
  216. package/dist/review/review.schema.d.ts +164 -169
  217. package/dist/review/review.schema.d.ts.map +1 -1
  218. package/dist/review/review.schema.js +70 -151
  219. package/dist/seeders/index.d.ts +4 -8
  220. package/dist/seeders/index.d.ts.map +1 -1
  221. package/dist/seeders/index.js +11 -16
  222. package/dist/store/index.d.ts +8 -5
  223. package/dist/store/index.d.ts.map +1 -0
  224. package/dist/store/index.js +142 -5
  225. package/dist/store/store.enum.d.ts +1 -6
  226. package/dist/store/store.enum.d.ts.map +1 -1
  227. package/dist/store/store.enum.js +10 -14
  228. package/dist/store/store.event.d.ts +42 -48
  229. package/dist/store/store.event.d.ts.map +1 -1
  230. package/dist/store/store.event.js +48 -75
  231. package/dist/store/store.operations.d.ts +98 -104
  232. package/dist/store/store.operations.d.ts.map +1 -1
  233. package/dist/store/store.operations.js +86 -58
  234. package/dist/store/store.presentation.d.ts +2 -7
  235. package/dist/store/store.presentation.d.ts.map +1 -1
  236. package/dist/store/store.presentation.js +91 -56
  237. package/dist/store/store.schema.d.ts +70 -75
  238. package/dist/store/store.schema.d.ts.map +1 -1
  239. package/dist/store/store.schema.js +41 -90
  240. package/dist/tests/operations.test-spec.d.ts +5 -10
  241. package/dist/tests/operations.test-spec.d.ts.map +1 -1
  242. package/dist/tests/operations.test-spec.js +134 -146
  243. package/dist/ui/MarketplaceDashboard.d.ts +1 -6
  244. package/dist/ui/MarketplaceDashboard.d.ts.map +1 -1
  245. package/dist/ui/MarketplaceDashboard.js +413 -313
  246. package/dist/ui/hooks/index.d.ts +2 -2
  247. package/dist/ui/hooks/index.d.ts.map +1 -0
  248. package/dist/ui/hooks/index.js +59 -4
  249. package/dist/ui/hooks/useMarketplaceData.d.ts +16 -20
  250. package/dist/ui/hooks/useMarketplaceData.d.ts.map +1 -1
  251. package/dist/ui/hooks/useMarketplaceData.js +53 -60
  252. package/dist/ui/index.d.ts +7 -6
  253. package/dist/ui/index.d.ts.map +1 -0
  254. package/dist/ui/index.js +668 -5
  255. package/dist/ui/renderers/index.d.ts +2 -2
  256. package/dist/ui/renderers/index.d.ts.map +1 -0
  257. package/dist/ui/renderers/index.js +249 -3
  258. package/dist/ui/renderers/marketplace.markdown.d.ts +13 -15
  259. package/dist/ui/renderers/marketplace.markdown.d.ts.map +1 -1
  260. package/dist/ui/renderers/marketplace.markdown.js +241 -236
  261. package/package.json +529 -110
  262. package/dist/docs/marketplace.docblock.js.map +0 -1
  263. package/dist/entities/index.js.map +0 -1
  264. package/dist/entities/order.js.map +0 -1
  265. package/dist/entities/payout.js.map +0 -1
  266. package/dist/entities/product.js.map +0 -1
  267. package/dist/entities/review.js.map +0 -1
  268. package/dist/entities/store.js.map +0 -1
  269. package/dist/example.js.map +0 -1
  270. package/dist/handlers/marketplace.handlers.js.map +0 -1
  271. package/dist/marketplace.capability.js.map +0 -1
  272. package/dist/marketplace.feature.js.map +0 -1
  273. package/dist/order/order.enum.js.map +0 -1
  274. package/dist/order/order.event.js.map +0 -1
  275. package/dist/order/order.operations.js.map +0 -1
  276. package/dist/order/order.presentation.js.map +0 -1
  277. package/dist/order/order.schema.js.map +0 -1
  278. package/dist/payout/payout.enum.js.map +0 -1
  279. package/dist/payout/payout.event.js.map +0 -1
  280. package/dist/payout/payout.operations.js.map +0 -1
  281. package/dist/payout/payout.presentation.js.map +0 -1
  282. package/dist/payout/payout.schema.js.map +0 -1
  283. package/dist/product/product.enum.js.map +0 -1
  284. package/dist/product/product.event.js.map +0 -1
  285. package/dist/product/product.operations.js.map +0 -1
  286. package/dist/product/product.presentation.js.map +0 -1
  287. package/dist/product/product.schema.js.map +0 -1
  288. package/dist/review/review.enum.js.map +0 -1
  289. package/dist/review/review.event.js.map +0 -1
  290. package/dist/review/review.operations.js.map +0 -1
  291. package/dist/review/review.presentation.js.map +0 -1
  292. package/dist/review/review.schema.js.map +0 -1
  293. package/dist/seeders/index.js.map +0 -1
  294. package/dist/store/store.enum.js.map +0 -1
  295. package/dist/store/store.event.js.map +0 -1
  296. package/dist/store/store.operations.js.map +0 -1
  297. package/dist/store/store.presentation.js.map +0 -1
  298. package/dist/store/store.schema.js.map +0 -1
  299. package/dist/tests/operations.test-spec.js.map +0 -1
  300. package/dist/ui/MarketplaceDashboard.js.map +0 -1
  301. package/dist/ui/hooks/useMarketplaceData.js.map +0 -1
  302. package/dist/ui/renderers/marketplace.markdown.js.map +0 -1
@@ -1,119 +1,173 @@
1
- import { CreateOrderInputModel, OrderModel, UpdateOrderStatusInputModel } from "./order.schema.js";
2
- import { defineCommand } from "@contractspec/lib.contracts/operations";
1
+ // @bun
2
+ // src/order/order.enum.ts
3
+ import { defineEnum } from "@contractspec/lib.schema";
4
+ var OrderStatusEnum = defineEnum("OrderStatus", [
5
+ "PENDING",
6
+ "PAID",
7
+ "PROCESSING",
8
+ "SHIPPED",
9
+ "DELIVERED",
10
+ "COMPLETED",
11
+ "CANCELLED",
12
+ "REFUNDED",
13
+ "PARTIALLY_REFUNDED",
14
+ "DISPUTED"
15
+ ]);
3
16
 
4
- //#region src/order/order.operations.ts
5
- const OWNERS = ["@example.marketplace"];
6
- /**
7
- * Create a new order.
8
- */
9
- const CreateOrderContract = defineCommand({
10
- meta: {
11
- key: "marketplace.order.create",
12
- version: "1.0.0",
13
- stability: "stable",
14
- owners: [...OWNERS],
15
- tags: [
16
- "marketplace",
17
- "order",
18
- "create"
19
- ],
20
- description: "Create a new order.",
21
- goal: "Allow buyers to purchase products.",
22
- context: "Checkout flow."
23
- },
24
- io: {
25
- input: CreateOrderInputModel,
26
- output: OrderModel
27
- },
28
- policy: { auth: "user" },
29
- sideEffects: {
30
- emits: [{
31
- key: "marketplace.order.created",
32
- version: "1.0.0",
33
- when: "Order is created",
34
- payload: OrderModel
35
- }],
36
- audit: ["marketplace.order.created"]
37
- },
38
- acceptance: {
39
- scenarios: [{
40
- key: "create-order-happy-path",
41
- given: ["User is authenticated"],
42
- when: ["User creates order with valid items"],
43
- then: ["Order is created", "OrderCreated event is emitted"]
44
- }],
45
- examples: [{
46
- key: "create-basic-order",
47
- input: {
48
- storeId: "store-123",
49
- items: [{
50
- productId: "prod-456",
51
- quantity: 1,
52
- unitPrice: 100
53
- }]
54
- },
55
- output: {
56
- id: "order-789",
57
- status: "pending",
58
- total: 100
59
- }
60
- }]
61
- }
17
+ // src/order/order.schema.ts
18
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
19
+ var OrderItemModel = defineSchemaModel({
20
+ name: "OrderItemModel",
21
+ fields: {
22
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ productName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
25
+ unitPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
26
+ quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
27
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
28
+ }
29
+ });
30
+ var OrderModel = defineSchemaModel({
31
+ name: "OrderModel",
32
+ description: "An order",
33
+ fields: {
34
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
35
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ buyerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ status: { type: OrderStatusEnum, isOptional: false },
39
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
40
+ shippingTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
41
+ taxTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
42
+ total: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
43
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
44
+ items: { type: OrderItemModel, isArray: true, isOptional: true },
45
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
46
+ }
47
+ });
48
+ var CreateOrderInputModel = defineSchemaModel({
49
+ name: "CreateOrderInput",
50
+ fields: {
51
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
+ items: {
53
+ type: ScalarTypeEnum.JSON(),
54
+ isOptional: false,
55
+ description: "Array of {productId, variantId?, quantity}"
56
+ },
57
+ shippingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
58
+ billingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
59
+ buyerNote: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
60
+ }
62
61
  });
63
- /**
64
- * Update order status.
65
- */
66
- const UpdateOrderStatusContract = defineCommand({
67
- meta: {
68
- key: "marketplace.order.updateStatus",
69
- version: "1.0.0",
70
- stability: "stable",
71
- owners: [...OWNERS],
72
- tags: [
73
- "marketplace",
74
- "order",
75
- "status"
76
- ],
77
- description: "Update order status.",
78
- goal: "Track order fulfillment.",
79
- context: "Order management."
80
- },
81
- io: {
82
- input: UpdateOrderStatusInputModel,
83
- output: OrderModel
84
- },
85
- policy: { auth: "user" },
86
- sideEffects: {
87
- emits: [{
88
- key: "marketplace.order.statusUpdated",
89
- version: "1.0.0",
90
- when: "Status changes",
91
- payload: OrderModel
92
- }],
93
- audit: ["marketplace.order.statusUpdated"]
94
- },
95
- acceptance: {
96
- scenarios: [{
97
- key: "update-status-happy-path",
98
- given: ["Order exists"],
99
- when: ["Seller updates order status"],
100
- then: ["Status is updated", "OrderStatusUpdated event is emitted"]
101
- }],
102
- examples: [{
103
- key: "mark-shipped",
104
- input: {
105
- orderId: "order-789",
106
- status: "shipped",
107
- trackingNumber: "TRACK123"
108
- },
109
- output: {
110
- id: "order-789",
111
- status: "shipped"
112
- }
113
- }]
114
- }
62
+ var UpdateOrderStatusInputModel = defineSchemaModel({
63
+ name: "UpdateOrderStatusInput",
64
+ fields: {
65
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
66
+ status: { type: OrderStatusEnum, isOptional: false },
67
+ trackingNumber: {
68
+ type: ScalarTypeEnum.String_unsecure(),
69
+ isOptional: true
70
+ },
71
+ trackingUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
72
+ note: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
73
+ }
115
74
  });
116
75
 
117
- //#endregion
118
- export { CreateOrderContract, UpdateOrderStatusContract };
119
- //# sourceMappingURL=order.operations.js.map
76
+ // src/order/order.operations.ts
77
+ import { defineCommand } from "@contractspec/lib.contracts/operations";
78
+ var OWNERS = ["@example.marketplace"];
79
+ var CreateOrderContract = defineCommand({
80
+ meta: {
81
+ key: "marketplace.order.create",
82
+ version: "1.0.0",
83
+ stability: "stable",
84
+ owners: [...OWNERS],
85
+ tags: ["marketplace", "order", "create"],
86
+ description: "Create a new order.",
87
+ goal: "Allow buyers to purchase products.",
88
+ context: "Checkout flow."
89
+ },
90
+ io: { input: CreateOrderInputModel, output: OrderModel },
91
+ policy: { auth: "user" },
92
+ sideEffects: {
93
+ emits: [
94
+ {
95
+ key: "marketplace.order.created",
96
+ version: "1.0.0",
97
+ when: "Order is created",
98
+ payload: OrderModel
99
+ }
100
+ ],
101
+ audit: ["marketplace.order.created"]
102
+ },
103
+ acceptance: {
104
+ scenarios: [
105
+ {
106
+ key: "create-order-happy-path",
107
+ given: ["User is authenticated"],
108
+ when: ["User creates order with valid items"],
109
+ then: ["Order is created", "OrderCreated event is emitted"]
110
+ }
111
+ ],
112
+ examples: [
113
+ {
114
+ key: "create-basic-order",
115
+ input: {
116
+ storeId: "store-123",
117
+ items: [{ productId: "prod-456", quantity: 1, unitPrice: 100 }]
118
+ },
119
+ output: { id: "order-789", status: "pending", total: 100 }
120
+ }
121
+ ]
122
+ }
123
+ });
124
+ var UpdateOrderStatusContract = defineCommand({
125
+ meta: {
126
+ key: "marketplace.order.updateStatus",
127
+ version: "1.0.0",
128
+ stability: "stable",
129
+ owners: [...OWNERS],
130
+ tags: ["marketplace", "order", "status"],
131
+ description: "Update order status.",
132
+ goal: "Track order fulfillment.",
133
+ context: "Order management."
134
+ },
135
+ io: { input: UpdateOrderStatusInputModel, output: OrderModel },
136
+ policy: { auth: "user" },
137
+ sideEffects: {
138
+ emits: [
139
+ {
140
+ key: "marketplace.order.statusUpdated",
141
+ version: "1.0.0",
142
+ when: "Status changes",
143
+ payload: OrderModel
144
+ }
145
+ ],
146
+ audit: ["marketplace.order.statusUpdated"]
147
+ },
148
+ acceptance: {
149
+ scenarios: [
150
+ {
151
+ key: "update-status-happy-path",
152
+ given: ["Order exists"],
153
+ when: ["Seller updates order status"],
154
+ then: ["Status is updated", "OrderStatusUpdated event is emitted"]
155
+ }
156
+ ],
157
+ examples: [
158
+ {
159
+ key: "mark-shipped",
160
+ input: {
161
+ orderId: "order-789",
162
+ status: "shipped",
163
+ trackingNumber: "TRACK123"
164
+ },
165
+ output: { id: "order-789", status: "shipped" }
166
+ }
167
+ ]
168
+ }
169
+ });
170
+ export {
171
+ UpdateOrderStatusContract,
172
+ CreateOrderContract
173
+ };
@@ -1,9 +1,4 @@
1
- import * as _contractspec_lib_contracts11 from "@contractspec/lib.contracts";
2
-
3
- //#region src/order/order.presentation.d.ts
4
- declare const OrderListPresentation: _contractspec_lib_contracts11.PresentationSpec;
5
- declare const OrderDetailPresentation: _contractspec_lib_contracts11.PresentationSpec;
6
- declare const CheckoutPresentation: _contractspec_lib_contracts11.PresentationSpec;
7
- //#endregion
8
- export { CheckoutPresentation, OrderDetailPresentation, OrderListPresentation };
1
+ export declare const OrderListPresentation: import("@contractspec/lib.contracts").PresentationSpec;
2
+ export declare const OrderDetailPresentation: import("@contractspec/lib.contracts").PresentationSpec;
3
+ export declare const CheckoutPresentation: import("@contractspec/lib.contracts").PresentationSpec;
9
4
  //# sourceMappingURL=order.presentation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"order.presentation.d.ts","names":[],"sources":["../../src/order/order.presentation.ts"],"sourcesContent":[],"mappings":";;;cAGa,uBAuBX,6BAAA,CAvBgC;cAyBrB,yBAwBX,6BAAA,CAxBkC;cA0BvB,sBAuBX,6BAAA,CAvB+B"}
1
+ {"version":3,"file":"order.presentation.d.ts","sourceRoot":"","sources":["../../src/order/order.presentation.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,wDAuBhC,CAAC;AAEH,eAAO,MAAM,uBAAuB,wDAwBlC,CAAC;AAEH,eAAO,MAAM,oBAAoB,wDAuB/B,CAAC"}
@@ -1,86 +1,154 @@
1
- import { OrderModel } from "./order.schema.js";
2
- import { StabilityEnum, definePresentation } from "@contractspec/lib.contracts";
1
+ // @bun
2
+ // src/order/order.enum.ts
3
+ import { defineEnum } from "@contractspec/lib.schema";
4
+ var OrderStatusEnum = defineEnum("OrderStatus", [
5
+ "PENDING",
6
+ "PAID",
7
+ "PROCESSING",
8
+ "SHIPPED",
9
+ "DELIVERED",
10
+ "COMPLETED",
11
+ "CANCELLED",
12
+ "REFUNDED",
13
+ "PARTIALLY_REFUNDED",
14
+ "DISPUTED"
15
+ ]);
3
16
 
4
- //#region src/order/order.presentation.ts
5
- const OrderListPresentation = definePresentation({
6
- meta: {
7
- key: "marketplace.order.list",
8
- version: "1.0.0",
9
- title: "Order List",
10
- description: "List of orders with status and tracking",
11
- domain: "marketplace",
12
- owners: ["@marketplace-team"],
13
- tags: [
14
- "marketplace",
15
- "order",
16
- "list"
17
- ],
18
- stability: StabilityEnum.Experimental,
19
- goal: "Provide a comprehensive view of all orders for the user.",
20
- context: "Used in the buyer and seller dashboards to track order progress."
21
- },
22
- source: {
23
- type: "component",
24
- framework: "react",
25
- componentKey: "OrderList",
26
- props: OrderModel
27
- },
28
- targets: ["react", "markdown"],
29
- policy: { flags: ["marketplace.orders.enabled"] }
17
+ // src/order/order.schema.ts
18
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
19
+ var OrderItemModel = defineSchemaModel({
20
+ name: "OrderItemModel",
21
+ fields: {
22
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ productName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
25
+ unitPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
26
+ quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
27
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
28
+ }
30
29
  });
31
- const OrderDetailPresentation = definePresentation({
32
- meta: {
33
- key: "marketplace.order.detail",
34
- version: "1.0.0",
35
- title: "Order Details",
36
- description: "Order detail with items and shipping info",
37
- domain: "marketplace",
38
- owners: ["@marketplace-team"],
39
- tags: [
40
- "marketplace",
41
- "order",
42
- "detail"
43
- ],
44
- stability: StabilityEnum.Experimental,
45
- goal: "Display all details of a single order.",
46
- context: "Accessed from the order list to see specific items, shipping, and payment details."
47
- },
48
- source: {
49
- type: "component",
50
- framework: "react",
51
- componentKey: "OrderDetail",
52
- props: OrderModel
53
- },
54
- targets: ["react", "markdown"],
55
- policy: { flags: ["marketplace.orders.enabled"] }
30
+ var OrderModel = defineSchemaModel({
31
+ name: "OrderModel",
32
+ description: "An order",
33
+ fields: {
34
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
35
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ buyerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ status: { type: OrderStatusEnum, isOptional: false },
39
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
40
+ shippingTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
41
+ taxTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
42
+ total: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
43
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
44
+ items: { type: OrderItemModel, isArray: true, isOptional: true },
45
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
46
+ }
56
47
  });
57
- const CheckoutPresentation = definePresentation({
58
- meta: {
59
- key: "marketplace.checkout",
60
- version: "1.0.0",
61
- title: "Checkout",
62
- description: "Checkout flow with cart and payment",
63
- domain: "marketplace",
64
- owners: ["@marketplace-team"],
65
- tags: [
66
- "marketplace",
67
- "checkout",
68
- "cart"
69
- ],
70
- stability: StabilityEnum.Experimental,
71
- goal: "Guide the user through the payment and order confirmation process.",
72
- context: "The final stage of the purchasing journey."
73
- },
74
- source: {
75
- type: "component",
76
- framework: "react",
77
- componentKey: "Checkout",
78
- props: OrderModel
79
- },
80
- targets: ["react"],
81
- policy: { flags: ["marketplace.checkout.enabled"] }
48
+ var CreateOrderInputModel = defineSchemaModel({
49
+ name: "CreateOrderInput",
50
+ fields: {
51
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
+ items: {
53
+ type: ScalarTypeEnum.JSON(),
54
+ isOptional: false,
55
+ description: "Array of {productId, variantId?, quantity}"
56
+ },
57
+ shippingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
58
+ billingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
59
+ buyerNote: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
60
+ }
61
+ });
62
+ var UpdateOrderStatusInputModel = defineSchemaModel({
63
+ name: "UpdateOrderStatusInput",
64
+ fields: {
65
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
66
+ status: { type: OrderStatusEnum, isOptional: false },
67
+ trackingNumber: {
68
+ type: ScalarTypeEnum.String_unsecure(),
69
+ isOptional: true
70
+ },
71
+ trackingUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
72
+ note: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
73
+ }
82
74
  });
83
75
 
84
- //#endregion
85
- export { CheckoutPresentation, OrderDetailPresentation, OrderListPresentation };
86
- //# sourceMappingURL=order.presentation.js.map
76
+ // src/order/order.presentation.ts
77
+ import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
78
+ var OrderListPresentation = definePresentation({
79
+ meta: {
80
+ key: "marketplace.order.list",
81
+ version: "1.0.0",
82
+ title: "Order List",
83
+ description: "List of orders with status and tracking",
84
+ domain: "marketplace",
85
+ owners: ["@marketplace-team"],
86
+ tags: ["marketplace", "order", "list"],
87
+ stability: StabilityEnum.Experimental,
88
+ goal: "Provide a comprehensive view of all orders for the user.",
89
+ context: "Used in the buyer and seller dashboards to track order progress."
90
+ },
91
+ source: {
92
+ type: "component",
93
+ framework: "react",
94
+ componentKey: "OrderList",
95
+ props: OrderModel
96
+ },
97
+ targets: ["react", "markdown"],
98
+ policy: {
99
+ flags: ["marketplace.orders.enabled"]
100
+ }
101
+ });
102
+ var OrderDetailPresentation = definePresentation({
103
+ meta: {
104
+ key: "marketplace.order.detail",
105
+ version: "1.0.0",
106
+ title: "Order Details",
107
+ description: "Order detail with items and shipping info",
108
+ domain: "marketplace",
109
+ owners: ["@marketplace-team"],
110
+ tags: ["marketplace", "order", "detail"],
111
+ stability: StabilityEnum.Experimental,
112
+ goal: "Display all details of a single order.",
113
+ context: "Accessed from the order list to see specific items, shipping, and payment details."
114
+ },
115
+ source: {
116
+ type: "component",
117
+ framework: "react",
118
+ componentKey: "OrderDetail",
119
+ props: OrderModel
120
+ },
121
+ targets: ["react", "markdown"],
122
+ policy: {
123
+ flags: ["marketplace.orders.enabled"]
124
+ }
125
+ });
126
+ var CheckoutPresentation = definePresentation({
127
+ meta: {
128
+ key: "marketplace.checkout",
129
+ version: "1.0.0",
130
+ title: "Checkout",
131
+ description: "Checkout flow with cart and payment",
132
+ domain: "marketplace",
133
+ owners: ["@marketplace-team"],
134
+ tags: ["marketplace", "checkout", "cart"],
135
+ stability: StabilityEnum.Experimental,
136
+ goal: "Guide the user through the payment and order confirmation process.",
137
+ context: "The final stage of the purchasing journey."
138
+ },
139
+ source: {
140
+ type: "component",
141
+ framework: "react",
142
+ componentKey: "Checkout",
143
+ props: OrderModel
144
+ },
145
+ targets: ["react"],
146
+ policy: {
147
+ flags: ["marketplace.checkout.enabled"]
148
+ }
149
+ });
150
+ export {
151
+ OrderListPresentation,
152
+ OrderDetailPresentation,
153
+ CheckoutPresentation
154
+ };