@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
@@ -0,0 +1,172 @@
1
+ // src/order/order.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var OrderStatusEnum = defineEnum("OrderStatus", [
4
+ "PENDING",
5
+ "PAID",
6
+ "PROCESSING",
7
+ "SHIPPED",
8
+ "DELIVERED",
9
+ "COMPLETED",
10
+ "CANCELLED",
11
+ "REFUNDED",
12
+ "PARTIALLY_REFUNDED",
13
+ "DISPUTED"
14
+ ]);
15
+
16
+ // src/order/order.schema.ts
17
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
18
+ var OrderItemModel = defineSchemaModel({
19
+ name: "OrderItemModel",
20
+ fields: {
21
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
+ productName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ unitPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
25
+ quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
26
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
27
+ }
28
+ });
29
+ var OrderModel = defineSchemaModel({
30
+ name: "OrderModel",
31
+ description: "An order",
32
+ fields: {
33
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
34
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
35
+ buyerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ status: { type: OrderStatusEnum, isOptional: false },
38
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
39
+ shippingTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
40
+ taxTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
41
+ total: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
42
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
+ items: { type: OrderItemModel, isArray: true, isOptional: true },
44
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
45
+ }
46
+ });
47
+ var CreateOrderInputModel = defineSchemaModel({
48
+ name: "CreateOrderInput",
49
+ fields: {
50
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
+ items: {
52
+ type: ScalarTypeEnum.JSON(),
53
+ isOptional: false,
54
+ description: "Array of {productId, variantId?, quantity}"
55
+ },
56
+ shippingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
57
+ billingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
58
+ buyerNote: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
59
+ }
60
+ });
61
+ var UpdateOrderStatusInputModel = defineSchemaModel({
62
+ name: "UpdateOrderStatusInput",
63
+ fields: {
64
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
+ status: { type: OrderStatusEnum, isOptional: false },
66
+ trackingNumber: {
67
+ type: ScalarTypeEnum.String_unsecure(),
68
+ isOptional: true
69
+ },
70
+ trackingUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
71
+ note: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
72
+ }
73
+ });
74
+
75
+ // src/order/order.operations.ts
76
+ import { defineCommand } from "@contractspec/lib.contracts/operations";
77
+ var OWNERS = ["@example.marketplace"];
78
+ var CreateOrderContract = defineCommand({
79
+ meta: {
80
+ key: "marketplace.order.create",
81
+ version: "1.0.0",
82
+ stability: "stable",
83
+ owners: [...OWNERS],
84
+ tags: ["marketplace", "order", "create"],
85
+ description: "Create a new order.",
86
+ goal: "Allow buyers to purchase products.",
87
+ context: "Checkout flow."
88
+ },
89
+ io: { input: CreateOrderInputModel, output: OrderModel },
90
+ policy: { auth: "user" },
91
+ sideEffects: {
92
+ emits: [
93
+ {
94
+ key: "marketplace.order.created",
95
+ version: "1.0.0",
96
+ when: "Order is created",
97
+ payload: OrderModel
98
+ }
99
+ ],
100
+ audit: ["marketplace.order.created"]
101
+ },
102
+ acceptance: {
103
+ scenarios: [
104
+ {
105
+ key: "create-order-happy-path",
106
+ given: ["User is authenticated"],
107
+ when: ["User creates order with valid items"],
108
+ then: ["Order is created", "OrderCreated event is emitted"]
109
+ }
110
+ ],
111
+ examples: [
112
+ {
113
+ key: "create-basic-order",
114
+ input: {
115
+ storeId: "store-123",
116
+ items: [{ productId: "prod-456", quantity: 1, unitPrice: 100 }]
117
+ },
118
+ output: { id: "order-789", status: "pending", total: 100 }
119
+ }
120
+ ]
121
+ }
122
+ });
123
+ var UpdateOrderStatusContract = defineCommand({
124
+ meta: {
125
+ key: "marketplace.order.updateStatus",
126
+ version: "1.0.0",
127
+ stability: "stable",
128
+ owners: [...OWNERS],
129
+ tags: ["marketplace", "order", "status"],
130
+ description: "Update order status.",
131
+ goal: "Track order fulfillment.",
132
+ context: "Order management."
133
+ },
134
+ io: { input: UpdateOrderStatusInputModel, output: OrderModel },
135
+ policy: { auth: "user" },
136
+ sideEffects: {
137
+ emits: [
138
+ {
139
+ key: "marketplace.order.statusUpdated",
140
+ version: "1.0.0",
141
+ when: "Status changes",
142
+ payload: OrderModel
143
+ }
144
+ ],
145
+ audit: ["marketplace.order.statusUpdated"]
146
+ },
147
+ acceptance: {
148
+ scenarios: [
149
+ {
150
+ key: "update-status-happy-path",
151
+ given: ["Order exists"],
152
+ when: ["Seller updates order status"],
153
+ then: ["Status is updated", "OrderStatusUpdated event is emitted"]
154
+ }
155
+ ],
156
+ examples: [
157
+ {
158
+ key: "mark-shipped",
159
+ input: {
160
+ orderId: "order-789",
161
+ status: "shipped",
162
+ trackingNumber: "TRACK123"
163
+ },
164
+ output: { id: "order-789", status: "shipped" }
165
+ }
166
+ ]
167
+ }
168
+ });
169
+ export {
170
+ UpdateOrderStatusContract,
171
+ CreateOrderContract
172
+ };
@@ -0,0 +1,153 @@
1
+ // src/order/order.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var OrderStatusEnum = defineEnum("OrderStatus", [
4
+ "PENDING",
5
+ "PAID",
6
+ "PROCESSING",
7
+ "SHIPPED",
8
+ "DELIVERED",
9
+ "COMPLETED",
10
+ "CANCELLED",
11
+ "REFUNDED",
12
+ "PARTIALLY_REFUNDED",
13
+ "DISPUTED"
14
+ ]);
15
+
16
+ // src/order/order.schema.ts
17
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
18
+ var OrderItemModel = defineSchemaModel({
19
+ name: "OrderItemModel",
20
+ fields: {
21
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
+ productName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ unitPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
25
+ quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
26
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
27
+ }
28
+ });
29
+ var OrderModel = defineSchemaModel({
30
+ name: "OrderModel",
31
+ description: "An order",
32
+ fields: {
33
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
34
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
35
+ buyerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ status: { type: OrderStatusEnum, isOptional: false },
38
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
39
+ shippingTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
40
+ taxTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
41
+ total: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
42
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
+ items: { type: OrderItemModel, isArray: true, isOptional: true },
44
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
45
+ }
46
+ });
47
+ var CreateOrderInputModel = defineSchemaModel({
48
+ name: "CreateOrderInput",
49
+ fields: {
50
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
+ items: {
52
+ type: ScalarTypeEnum.JSON(),
53
+ isOptional: false,
54
+ description: "Array of {productId, variantId?, quantity}"
55
+ },
56
+ shippingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
57
+ billingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
58
+ buyerNote: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
59
+ }
60
+ });
61
+ var UpdateOrderStatusInputModel = defineSchemaModel({
62
+ name: "UpdateOrderStatusInput",
63
+ fields: {
64
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
+ status: { type: OrderStatusEnum, isOptional: false },
66
+ trackingNumber: {
67
+ type: ScalarTypeEnum.String_unsecure(),
68
+ isOptional: true
69
+ },
70
+ trackingUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
71
+ note: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
72
+ }
73
+ });
74
+
75
+ // src/order/order.presentation.ts
76
+ import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
77
+ var OrderListPresentation = definePresentation({
78
+ meta: {
79
+ key: "marketplace.order.list",
80
+ version: "1.0.0",
81
+ title: "Order List",
82
+ description: "List of orders with status and tracking",
83
+ domain: "marketplace",
84
+ owners: ["@marketplace-team"],
85
+ tags: ["marketplace", "order", "list"],
86
+ stability: StabilityEnum.Experimental,
87
+ goal: "Provide a comprehensive view of all orders for the user.",
88
+ context: "Used in the buyer and seller dashboards to track order progress."
89
+ },
90
+ source: {
91
+ type: "component",
92
+ framework: "react",
93
+ componentKey: "OrderList",
94
+ props: OrderModel
95
+ },
96
+ targets: ["react", "markdown"],
97
+ policy: {
98
+ flags: ["marketplace.orders.enabled"]
99
+ }
100
+ });
101
+ var OrderDetailPresentation = definePresentation({
102
+ meta: {
103
+ key: "marketplace.order.detail",
104
+ version: "1.0.0",
105
+ title: "Order Details",
106
+ description: "Order detail with items and shipping info",
107
+ domain: "marketplace",
108
+ owners: ["@marketplace-team"],
109
+ tags: ["marketplace", "order", "detail"],
110
+ stability: StabilityEnum.Experimental,
111
+ goal: "Display all details of a single order.",
112
+ context: "Accessed from the order list to see specific items, shipping, and payment details."
113
+ },
114
+ source: {
115
+ type: "component",
116
+ framework: "react",
117
+ componentKey: "OrderDetail",
118
+ props: OrderModel
119
+ },
120
+ targets: ["react", "markdown"],
121
+ policy: {
122
+ flags: ["marketplace.orders.enabled"]
123
+ }
124
+ });
125
+ var CheckoutPresentation = definePresentation({
126
+ meta: {
127
+ key: "marketplace.checkout",
128
+ version: "1.0.0",
129
+ title: "Checkout",
130
+ description: "Checkout flow with cart and payment",
131
+ domain: "marketplace",
132
+ owners: ["@marketplace-team"],
133
+ tags: ["marketplace", "checkout", "cart"],
134
+ stability: StabilityEnum.Experimental,
135
+ goal: "Guide the user through the payment and order confirmation process.",
136
+ context: "The final stage of the purchasing journey."
137
+ },
138
+ source: {
139
+ type: "component",
140
+ framework: "react",
141
+ componentKey: "Checkout",
142
+ props: OrderModel
143
+ },
144
+ targets: ["react"],
145
+ policy: {
146
+ flags: ["marketplace.checkout.enabled"]
147
+ }
148
+ });
149
+ export {
150
+ OrderListPresentation,
151
+ OrderDetailPresentation,
152
+ CheckoutPresentation
153
+ };
@@ -0,0 +1,79 @@
1
+ // src/order/order.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var OrderStatusEnum = defineEnum("OrderStatus", [
4
+ "PENDING",
5
+ "PAID",
6
+ "PROCESSING",
7
+ "SHIPPED",
8
+ "DELIVERED",
9
+ "COMPLETED",
10
+ "CANCELLED",
11
+ "REFUNDED",
12
+ "PARTIALLY_REFUNDED",
13
+ "DISPUTED"
14
+ ]);
15
+
16
+ // src/order/order.schema.ts
17
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
18
+ var OrderItemModel = defineSchemaModel({
19
+ name: "OrderItemModel",
20
+ fields: {
21
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
+ productName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ unitPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
25
+ quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
26
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
27
+ }
28
+ });
29
+ var OrderModel = defineSchemaModel({
30
+ name: "OrderModel",
31
+ description: "An order",
32
+ fields: {
33
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
34
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
35
+ buyerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ status: { type: OrderStatusEnum, isOptional: false },
38
+ subtotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
39
+ shippingTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
40
+ taxTotal: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
41
+ total: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
42
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
+ items: { type: OrderItemModel, isArray: true, isOptional: true },
44
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
45
+ }
46
+ });
47
+ var CreateOrderInputModel = defineSchemaModel({
48
+ name: "CreateOrderInput",
49
+ fields: {
50
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
+ items: {
52
+ type: ScalarTypeEnum.JSON(),
53
+ isOptional: false,
54
+ description: "Array of {productId, variantId?, quantity}"
55
+ },
56
+ shippingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
57
+ billingAddress: { type: ScalarTypeEnum.JSON(), isOptional: true },
58
+ buyerNote: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
59
+ }
60
+ });
61
+ var UpdateOrderStatusInputModel = defineSchemaModel({
62
+ name: "UpdateOrderStatusInput",
63
+ fields: {
64
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
+ status: { type: OrderStatusEnum, isOptional: false },
66
+ trackingNumber: {
67
+ type: ScalarTypeEnum.String_unsecure(),
68
+ isOptional: true
69
+ },
70
+ trackingUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
71
+ note: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
72
+ }
73
+ });
74
+ export {
75
+ UpdateOrderStatusInputModel,
76
+ OrderModel,
77
+ OrderItemModel,
78
+ CreateOrderInputModel
79
+ };
@@ -0,0 +1,152 @@
1
+ // src/payout/payout.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var PayoutStatusEnum = defineEnum("PayoutStatus", [
4
+ "PENDING",
5
+ "PROCESSING",
6
+ "PAID",
7
+ "FAILED",
8
+ "CANCELLED"
9
+ ]);
10
+
11
+ // src/payout/payout.schema.ts
12
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
13
+ var PayoutModel = defineSchemaModel({
14
+ name: "PayoutModel",
15
+ description: "A payout to seller",
16
+ fields: {
17
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
18
+ payoutNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
19
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
20
+ status: { type: PayoutStatusEnum, isOptional: false },
21
+ grossAmount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
22
+ platformFees: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
23
+ netAmount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
24
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
25
+ periodStart: { type: ScalarTypeEnum.DateTime(), isOptional: false },
26
+ periodEnd: { type: ScalarTypeEnum.DateTime(), isOptional: false },
27
+ orderCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
28
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
29
+ paidAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
30
+ }
31
+ });
32
+ var ListPayoutsInputModel = defineSchemaModel({
33
+ name: "ListPayoutsInput",
34
+ fields: {
35
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
36
+ status: { type: PayoutStatusEnum, isOptional: true },
37
+ limit: {
38
+ type: ScalarTypeEnum.Int_unsecure(),
39
+ isOptional: true,
40
+ defaultValue: 20
41
+ },
42
+ offset: {
43
+ type: ScalarTypeEnum.Int_unsecure(),
44
+ isOptional: true,
45
+ defaultValue: 0
46
+ }
47
+ }
48
+ });
49
+ var ListPayoutsOutputModel = defineSchemaModel({
50
+ name: "ListPayoutsOutput",
51
+ fields: {
52
+ payouts: { type: PayoutModel, isArray: true, isOptional: false },
53
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
54
+ totalPending: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
55
+ }
56
+ });
57
+
58
+ // src/payout/payout.operations.ts
59
+ import { defineQuery } from "@contractspec/lib.contracts/operations";
60
+ var OWNERS = ["@example.marketplace"];
61
+ var ListPayoutsContract = defineQuery({
62
+ meta: {
63
+ key: "marketplace.payout.list",
64
+ version: "1.0.0",
65
+ stability: "stable",
66
+ owners: [...OWNERS],
67
+ tags: ["marketplace", "payout", "list"],
68
+ description: "List payouts for a store.",
69
+ goal: "View payout history.",
70
+ context: "Seller dashboard."
71
+ },
72
+ io: { input: ListPayoutsInputModel, output: ListPayoutsOutputModel },
73
+ policy: { auth: "user" },
74
+ acceptance: {
75
+ scenarios: [
76
+ {
77
+ key: "list-payouts-happy-path",
78
+ given: ["Store has payout history"],
79
+ when: ["Seller lists payouts"],
80
+ then: ["List of payouts is returned"]
81
+ }
82
+ ],
83
+ examples: [
84
+ {
85
+ key: "list-recent",
86
+ input: { limit: 10, offset: 0 },
87
+ output: { items: [], total: 5, hasMore: false }
88
+ }
89
+ ]
90
+ }
91
+ });
92
+
93
+ // src/payout/payout.event.ts
94
+ import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
95
+ import { defineEvent } from "@contractspec/lib.contracts";
96
+ var PayoutCreatedPayload = defineSchemaModel2({
97
+ name: "PayoutCreatedEventPayload",
98
+ fields: {
99
+ payoutId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
100
+ payoutNumber: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
101
+ storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
102
+ netAmount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
103
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
104
+ orderCount: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
105
+ timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
106
+ }
107
+ });
108
+ var PayoutPaidPayload = defineSchemaModel2({
109
+ name: "PayoutPaidEventPayload",
110
+ fields: {
111
+ payoutId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
112
+ payoutNumber: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
113
+ storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
114
+ netAmount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
115
+ paymentReference: {
116
+ type: ScalarTypeEnum2.String_unsecure(),
117
+ isOptional: true
118
+ },
119
+ timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
120
+ }
121
+ });
122
+ var PayoutCreatedEvent = defineEvent({
123
+ meta: {
124
+ key: "marketplace.payout.created",
125
+ version: "1.0.0",
126
+ description: "A payout has been created.",
127
+ stability: "experimental",
128
+ owners: ["@marketplace-team"],
129
+ tags: ["marketplace", "payout"]
130
+ },
131
+ payload: PayoutCreatedPayload
132
+ });
133
+ var PayoutPaidEvent = defineEvent({
134
+ meta: {
135
+ key: "marketplace.payout.paid",
136
+ version: "1.0.0",
137
+ description: "A payout has been sent.",
138
+ stability: "experimental",
139
+ owners: ["@marketplace-team"],
140
+ tags: ["marketplace", "payout"]
141
+ },
142
+ payload: PayoutPaidPayload
143
+ });
144
+ export {
145
+ PayoutStatusEnum,
146
+ PayoutPaidEvent,
147
+ PayoutModel,
148
+ PayoutCreatedEvent,
149
+ ListPayoutsOutputModel,
150
+ ListPayoutsInputModel,
151
+ ListPayoutsContract
152
+ };
@@ -0,0 +1,12 @@
1
+ // src/payout/payout.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var PayoutStatusEnum = defineEnum("PayoutStatus", [
4
+ "PENDING",
5
+ "PROCESSING",
6
+ "PAID",
7
+ "FAILED",
8
+ "CANCELLED"
9
+ ]);
10
+ export {
11
+ PayoutStatusEnum
12
+ };
@@ -0,0 +1,55 @@
1
+ // src/payout/payout.event.ts
2
+ import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
3
+ import { defineEvent } from "@contractspec/lib.contracts";
4
+ var PayoutCreatedPayload = defineSchemaModel({
5
+ name: "PayoutCreatedEventPayload",
6
+ fields: {
7
+ payoutId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
8
+ payoutNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
9
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
+ netAmount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
11
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
12
+ orderCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
13
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
14
+ }
15
+ });
16
+ var PayoutPaidPayload = defineSchemaModel({
17
+ name: "PayoutPaidEventPayload",
18
+ fields: {
19
+ payoutId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
20
+ payoutNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
21
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ netAmount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
23
+ paymentReference: {
24
+ type: ScalarTypeEnum.String_unsecure(),
25
+ isOptional: true
26
+ },
27
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
28
+ }
29
+ });
30
+ var PayoutCreatedEvent = defineEvent({
31
+ meta: {
32
+ key: "marketplace.payout.created",
33
+ version: "1.0.0",
34
+ description: "A payout has been created.",
35
+ stability: "experimental",
36
+ owners: ["@marketplace-team"],
37
+ tags: ["marketplace", "payout"]
38
+ },
39
+ payload: PayoutCreatedPayload
40
+ });
41
+ var PayoutPaidEvent = defineEvent({
42
+ meta: {
43
+ key: "marketplace.payout.paid",
44
+ version: "1.0.0",
45
+ description: "A payout has been sent.",
46
+ stability: "experimental",
47
+ owners: ["@marketplace-team"],
48
+ tags: ["marketplace", "payout"]
49
+ },
50
+ payload: PayoutPaidPayload
51
+ });
52
+ export {
53
+ PayoutPaidEvent,
54
+ PayoutCreatedEvent
55
+ };