@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,668 @@
1
+ // src/ui/renderers/marketplace.markdown.ts
2
+ var mockStores = [
3
+ {
4
+ id: "store-1",
5
+ name: "Tech Gadgets Store",
6
+ status: "ACTIVE",
7
+ productCount: 45,
8
+ rating: 4.8
9
+ },
10
+ {
11
+ id: "store-2",
12
+ name: "Home & Garden",
13
+ status: "ACTIVE",
14
+ productCount: 120,
15
+ rating: 4.5
16
+ },
17
+ {
18
+ id: "store-3",
19
+ name: "Fashion Boutique",
20
+ status: "PENDING",
21
+ productCount: 0,
22
+ rating: 0
23
+ }
24
+ ];
25
+ var mockProducts = [
26
+ {
27
+ id: "prod-1",
28
+ name: "Wireless Earbuds",
29
+ storeId: "store-1",
30
+ price: 79.99,
31
+ currency: "USD",
32
+ status: "ACTIVE",
33
+ stock: 150
34
+ },
35
+ {
36
+ id: "prod-2",
37
+ name: "Smart Watch",
38
+ storeId: "store-1",
39
+ price: 249.99,
40
+ currency: "USD",
41
+ status: "ACTIVE",
42
+ stock: 50
43
+ },
44
+ {
45
+ id: "prod-3",
46
+ name: "Garden Tools Set",
47
+ storeId: "store-2",
48
+ price: 89.99,
49
+ currency: "USD",
50
+ status: "ACTIVE",
51
+ stock: 30
52
+ },
53
+ {
54
+ id: "prod-4",
55
+ name: "Indoor Plant Kit",
56
+ storeId: "store-2",
57
+ price: 45.99,
58
+ currency: "USD",
59
+ status: "ACTIVE",
60
+ stock: 75
61
+ },
62
+ {
63
+ id: "prod-5",
64
+ name: "LED Desk Lamp",
65
+ storeId: "store-1",
66
+ price: 34.99,
67
+ currency: "USD",
68
+ status: "OUT_OF_STOCK",
69
+ stock: 0
70
+ }
71
+ ];
72
+ var mockOrders = [
73
+ {
74
+ id: "ord-1",
75
+ storeId: "store-1",
76
+ customerId: "cust-1",
77
+ total: 329.98,
78
+ currency: "USD",
79
+ status: "DELIVERED",
80
+ itemCount: 2,
81
+ createdAt: "2024-01-15T10:00:00Z"
82
+ },
83
+ {
84
+ id: "ord-2",
85
+ storeId: "store-2",
86
+ customerId: "cust-2",
87
+ total: 135.98,
88
+ currency: "USD",
89
+ status: "SHIPPED",
90
+ itemCount: 2,
91
+ createdAt: "2024-01-14T14:00:00Z"
92
+ },
93
+ {
94
+ id: "ord-3",
95
+ storeId: "store-1",
96
+ customerId: "cust-3",
97
+ total: 79.99,
98
+ currency: "USD",
99
+ status: "PROCESSING",
100
+ itemCount: 1,
101
+ createdAt: "2024-01-16T08:00:00Z"
102
+ },
103
+ {
104
+ id: "ord-4",
105
+ storeId: "store-2",
106
+ customerId: "cust-4",
107
+ total: 45.99,
108
+ currency: "USD",
109
+ status: "PENDING",
110
+ itemCount: 1,
111
+ createdAt: "2024-01-16T12:00:00Z"
112
+ }
113
+ ];
114
+ function formatCurrency(value, currency = "USD") {
115
+ return new Intl.NumberFormat("en-US", {
116
+ style: "currency",
117
+ currency,
118
+ minimumFractionDigits: 2
119
+ }).format(value);
120
+ }
121
+ var marketplaceDashboardMarkdownRenderer = {
122
+ target: "markdown",
123
+ render: async (desc) => {
124
+ if (desc.source.type !== "component" || desc.source.componentKey !== "MarketplaceDashboard") {
125
+ throw new Error("marketplaceDashboardMarkdownRenderer: not MarketplaceDashboard");
126
+ }
127
+ const stores = mockStores;
128
+ const products = mockProducts;
129
+ const orders = mockOrders;
130
+ const activeStores = stores.filter((s) => s.status === "ACTIVE");
131
+ const activeProducts = products.filter((p) => p.status === "ACTIVE");
132
+ const totalRevenue = orders.reduce((sum, o) => sum + o.total, 0);
133
+ const pendingOrders = orders.filter((o) => o.status === "PENDING" || o.status === "PROCESSING");
134
+ const lines = [
135
+ "# Marketplace Dashboard",
136
+ "",
137
+ "> Two-sided marketplace overview",
138
+ "",
139
+ "## Summary",
140
+ "",
141
+ "| Metric | Value |",
142
+ "|--------|-------|",
143
+ `| Active Stores | ${activeStores.length} |`,
144
+ `| Active Products | ${activeProducts.length} |`,
145
+ `| Total Orders | ${orders.length} |`,
146
+ `| Total Revenue | ${formatCurrency(totalRevenue)} |`,
147
+ `| Pending Orders | ${pendingOrders.length} |`,
148
+ "",
149
+ "## Top Stores",
150
+ "",
151
+ "| Store | Products | Rating | Status |",
152
+ "|-------|----------|--------|--------|"
153
+ ];
154
+ for (const store of stores.slice(0, 5)) {
155
+ lines.push(`| ${store.name} | ${store.productCount} | ⭐ ${store.rating || "N/A"} | ${store.status} |`);
156
+ }
157
+ lines.push("");
158
+ lines.push("## Recent Orders");
159
+ lines.push("");
160
+ lines.push("| Order | Items | Total | Status | Date |");
161
+ lines.push("|-------|-------|-------|--------|------|");
162
+ for (const order of orders.slice(0, 10)) {
163
+ const date = new Date(order.createdAt).toLocaleDateString();
164
+ lines.push(`| ${order.id} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`);
165
+ }
166
+ return {
167
+ mimeType: "text/markdown",
168
+ body: lines.join(`
169
+ `)
170
+ };
171
+ }
172
+ };
173
+ var productCatalogMarkdownRenderer = {
174
+ target: "markdown",
175
+ render: async (desc) => {
176
+ if (desc.source.type !== "component" || desc.source.componentKey !== "ProductCatalog") {
177
+ throw new Error("productCatalogMarkdownRenderer: not ProductCatalog");
178
+ }
179
+ const products = mockProducts;
180
+ const stores = mockStores;
181
+ const lines = [
182
+ "# Product Catalog",
183
+ "",
184
+ "> Browse products across all marketplace stores",
185
+ ""
186
+ ];
187
+ for (const store of stores.filter((s) => s.status === "ACTIVE")) {
188
+ const storeProducts = products.filter((p) => p.storeId === store.id);
189
+ if (storeProducts.length === 0)
190
+ continue;
191
+ lines.push(`## ${store.name}`);
192
+ lines.push("");
193
+ lines.push("| Product | Price | Stock | Status |");
194
+ lines.push("|---------|-------|-------|--------|");
195
+ for (const product of storeProducts) {
196
+ const stockStatus = product.stock > 0 ? `${product.stock} in stock` : "Out of stock";
197
+ lines.push(`| ${product.name} | ${formatCurrency(product.price, product.currency)} | ${stockStatus} | ${product.status} |`);
198
+ }
199
+ lines.push("");
200
+ }
201
+ return {
202
+ mimeType: "text/markdown",
203
+ body: lines.join(`
204
+ `)
205
+ };
206
+ }
207
+ };
208
+ var orderListMarkdownRenderer = {
209
+ target: "markdown",
210
+ render: async (desc) => {
211
+ if (desc.source.type !== "component" || desc.source.componentKey !== "OrderList") {
212
+ throw new Error("orderListMarkdownRenderer: not OrderList");
213
+ }
214
+ const orders = mockOrders;
215
+ const stores = mockStores;
216
+ const lines = [
217
+ "# Orders",
218
+ "",
219
+ "> Manage marketplace orders",
220
+ "",
221
+ "| Order ID | Store | Items | Total | Status | Created |",
222
+ "|----------|-------|-------|-------|--------|---------|"
223
+ ];
224
+ for (const order of orders) {
225
+ const store = stores.find((s) => s.id === order.storeId);
226
+ const date = new Date(order.createdAt).toLocaleDateString();
227
+ lines.push(`| ${order.id} | ${store?.name ?? "Unknown"} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`);
228
+ }
229
+ lines.push("");
230
+ lines.push("## Order Status Legend");
231
+ lines.push("");
232
+ lines.push("- **PENDING**: Awaiting payment confirmation");
233
+ lines.push("- **PROCESSING**: Being prepared");
234
+ lines.push("- **SHIPPED**: In transit");
235
+ lines.push("- **DELIVERED**: Order completed");
236
+ lines.push("- **CANCELLED**: Order cancelled");
237
+ return {
238
+ mimeType: "text/markdown",
239
+ body: lines.join(`
240
+ `)
241
+ };
242
+ }
243
+ };
244
+ // src/ui/hooks/useMarketplaceData.ts
245
+ import { useCallback, useEffect, useState } from "react";
246
+ import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
247
+ "use client";
248
+ function useMarketplaceData(projectId = "local-project") {
249
+ const { handlers } = useTemplateRuntime();
250
+ const marketplace = handlers.marketplace;
251
+ const [stores, setStores] = useState([]);
252
+ const [products, setProducts] = useState([]);
253
+ const [orders, setOrders] = useState([]);
254
+ const [loading, setLoading] = useState(true);
255
+ const [error, setError] = useState(null);
256
+ const [totalRevenue, setTotalRevenue] = useState(0);
257
+ const fetchData = useCallback(async () => {
258
+ try {
259
+ setLoading(true);
260
+ setError(null);
261
+ const [storeResult, productResult, orderResult] = await Promise.all([
262
+ marketplace.listStores({ projectId, limit: 100 }),
263
+ marketplace.listProducts({ limit: 100 }),
264
+ marketplace.listOrders({ projectId, limit: 100 })
265
+ ]);
266
+ setStores(storeResult.stores);
267
+ setProducts(productResult.products);
268
+ setOrders(orderResult.orders);
269
+ setTotalRevenue(orderResult.totalRevenue);
270
+ } catch (err) {
271
+ setError(err instanceof Error ? err : new Error("Failed to load marketplace"));
272
+ } finally {
273
+ setLoading(false);
274
+ }
275
+ }, [marketplace, projectId]);
276
+ useEffect(() => {
277
+ fetchData();
278
+ }, [fetchData]);
279
+ const stats = {
280
+ totalStores: stores.length,
281
+ activeStores: stores.filter((s) => s.status === "ACTIVE").length,
282
+ totalProducts: products.length,
283
+ totalOrders: orders.length,
284
+ totalRevenue,
285
+ pendingOrders: orders.filter((o) => o.status === "PENDING").length
286
+ };
287
+ return {
288
+ stores,
289
+ products,
290
+ orders,
291
+ loading,
292
+ error,
293
+ stats,
294
+ refetch: fetchData
295
+ };
296
+ }
297
+
298
+ // src/ui/MarketplaceDashboard.tsx
299
+ import { useState as useState2 } from "react";
300
+ import {
301
+ Button,
302
+ ErrorState,
303
+ LoaderBlock,
304
+ StatCard,
305
+ StatCardGroup
306
+ } from "@contractspec/lib.design-system";
307
+ import { jsxDEV } from "react/jsx-dev-runtime";
308
+ "use client";
309
+ var STATUS_COLORS = {
310
+ ACTIVE: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
311
+ PENDING: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",
312
+ SUSPENDED: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",
313
+ DRAFT: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
314
+ OUT_OF_STOCK: "bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400",
315
+ ARCHIVED: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
316
+ CONFIRMED: "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",
317
+ PROCESSING: "bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-400",
318
+ SHIPPED: "bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",
319
+ DELIVERED: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
320
+ CANCELLED: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"
321
+ };
322
+ function formatCurrency2(value, currency = "USD") {
323
+ return new Intl.NumberFormat("en-US", {
324
+ style: "currency",
325
+ currency,
326
+ minimumFractionDigits: 0,
327
+ maximumFractionDigits: 2
328
+ }).format(value);
329
+ }
330
+ function MarketplaceDashboard() {
331
+ const [activeTab, setActiveTab] = useState2("stores");
332
+ const { stores, products, orders, loading, error, stats, refetch } = useMarketplaceData();
333
+ const tabs = [
334
+ { id: "stores", label: "Stores", icon: "\uD83C\uDFEA" },
335
+ { id: "products", label: "Products", icon: "\uD83D\uDCE6" },
336
+ { id: "orders", label: "Orders", icon: "\uD83D\uDED2" }
337
+ ];
338
+ if (loading) {
339
+ return /* @__PURE__ */ jsxDEV(LoaderBlock, {
340
+ label: "Loading Marketplace..."
341
+ }, undefined, false, undefined, this);
342
+ }
343
+ if (error) {
344
+ return /* @__PURE__ */ jsxDEV(ErrorState, {
345
+ title: "Failed to load Marketplace",
346
+ description: error.message,
347
+ onRetry: refetch,
348
+ retryLabel: "Retry"
349
+ }, undefined, false, undefined, this);
350
+ }
351
+ return /* @__PURE__ */ jsxDEV("div", {
352
+ className: "space-y-6",
353
+ children: [
354
+ /* @__PURE__ */ jsxDEV("div", {
355
+ className: "flex items-center justify-between",
356
+ children: [
357
+ /* @__PURE__ */ jsxDEV("h2", {
358
+ className: "text-2xl font-bold",
359
+ children: "Marketplace"
360
+ }, undefined, false, undefined, this),
361
+ /* @__PURE__ */ jsxDEV(Button, {
362
+ onClick: () => alert("Create store modal"),
363
+ children: [
364
+ /* @__PURE__ */ jsxDEV("span", {
365
+ className: "mr-2",
366
+ children: "+"
367
+ }, undefined, false, undefined, this),
368
+ " New Store"
369
+ ]
370
+ }, undefined, true, undefined, this)
371
+ ]
372
+ }, undefined, true, undefined, this),
373
+ /* @__PURE__ */ jsxDEV(StatCardGroup, {
374
+ children: [
375
+ /* @__PURE__ */ jsxDEV(StatCard, {
376
+ label: "Stores",
377
+ value: stats.totalStores,
378
+ hint: `${stats.activeStores} active`
379
+ }, undefined, false, undefined, this),
380
+ /* @__PURE__ */ jsxDEV(StatCard, {
381
+ label: "Products",
382
+ value: stats.totalProducts,
383
+ hint: "listed"
384
+ }, undefined, false, undefined, this),
385
+ /* @__PURE__ */ jsxDEV(StatCard, {
386
+ label: "Orders",
387
+ value: stats.totalOrders,
388
+ hint: `${stats.pendingOrders} pending`
389
+ }, undefined, false, undefined, this),
390
+ /* @__PURE__ */ jsxDEV(StatCard, {
391
+ label: "Revenue",
392
+ value: formatCurrency2(stats.totalRevenue),
393
+ hint: "total"
394
+ }, undefined, false, undefined, this)
395
+ ]
396
+ }, undefined, true, undefined, this),
397
+ /* @__PURE__ */ jsxDEV("nav", {
398
+ className: "bg-muted flex gap-1 rounded-lg p-1",
399
+ role: "tablist",
400
+ children: tabs.map((tab) => /* @__PURE__ */ jsxDEV(Button, {
401
+ type: "button",
402
+ role: "tab",
403
+ "aria-selected": activeTab === tab.id,
404
+ onClick: () => setActiveTab(tab.id),
405
+ className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 text-sm font-medium transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
406
+ children: [
407
+ /* @__PURE__ */ jsxDEV("span", {
408
+ children: tab.icon
409
+ }, undefined, false, undefined, this),
410
+ tab.label
411
+ ]
412
+ }, tab.id, true, undefined, this))
413
+ }, undefined, false, undefined, this),
414
+ /* @__PURE__ */ jsxDEV("div", {
415
+ className: "min-h-[400px]",
416
+ role: "tabpanel",
417
+ children: [
418
+ activeTab === "stores" && /* @__PURE__ */ jsxDEV("div", {
419
+ className: "border-border rounded-lg border",
420
+ children: /* @__PURE__ */ jsxDEV("table", {
421
+ className: "w-full",
422
+ children: [
423
+ /* @__PURE__ */ jsxDEV("thead", {
424
+ className: "border-border bg-muted/30 border-b",
425
+ children: /* @__PURE__ */ jsxDEV("tr", {
426
+ children: [
427
+ /* @__PURE__ */ jsxDEV("th", {
428
+ className: "px-4 py-3 text-left text-sm font-medium",
429
+ children: "Store"
430
+ }, undefined, false, undefined, this),
431
+ /* @__PURE__ */ jsxDEV("th", {
432
+ className: "px-4 py-3 text-left text-sm font-medium",
433
+ children: "Status"
434
+ }, undefined, false, undefined, this),
435
+ /* @__PURE__ */ jsxDEV("th", {
436
+ className: "px-4 py-3 text-left text-sm font-medium",
437
+ children: "Rating"
438
+ }, undefined, false, undefined, this),
439
+ /* @__PURE__ */ jsxDEV("th", {
440
+ className: "px-4 py-3 text-left text-sm font-medium",
441
+ children: "Reviews"
442
+ }, undefined, false, undefined, this)
443
+ ]
444
+ }, undefined, true, undefined, this)
445
+ }, undefined, false, undefined, this),
446
+ /* @__PURE__ */ jsxDEV("tbody", {
447
+ className: "divide-border divide-y",
448
+ children: [
449
+ stores.map((store) => /* @__PURE__ */ jsxDEV("tr", {
450
+ className: "hover:bg-muted/50",
451
+ children: [
452
+ /* @__PURE__ */ jsxDEV("td", {
453
+ className: "px-4 py-3",
454
+ children: [
455
+ /* @__PURE__ */ jsxDEV("div", {
456
+ className: "font-medium",
457
+ children: store.name
458
+ }, undefined, false, undefined, this),
459
+ /* @__PURE__ */ jsxDEV("div", {
460
+ className: "text-muted-foreground text-sm",
461
+ children: store.description
462
+ }, undefined, false, undefined, this)
463
+ ]
464
+ }, undefined, true, undefined, this),
465
+ /* @__PURE__ */ jsxDEV("td", {
466
+ className: "px-4 py-3",
467
+ children: /* @__PURE__ */ jsxDEV("span", {
468
+ className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[store.status] ?? ""}`,
469
+ children: store.status
470
+ }, undefined, false, undefined, this)
471
+ }, undefined, false, undefined, this),
472
+ /* @__PURE__ */ jsxDEV("td", {
473
+ className: "px-4 py-3",
474
+ children: /* @__PURE__ */ jsxDEV("span", {
475
+ className: "flex items-center gap-1",
476
+ children: [
477
+ "⭐ ",
478
+ store.rating.toFixed(1)
479
+ ]
480
+ }, undefined, true, undefined, this)
481
+ }, undefined, false, undefined, this),
482
+ /* @__PURE__ */ jsxDEV("td", {
483
+ className: "text-muted-foreground px-4 py-3 text-sm",
484
+ children: [
485
+ store.reviewCount,
486
+ " reviews"
487
+ ]
488
+ }, undefined, true, undefined, this)
489
+ ]
490
+ }, store.id, true, undefined, this)),
491
+ stores.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
492
+ children: /* @__PURE__ */ jsxDEV("td", {
493
+ colSpan: 4,
494
+ className: "text-muted-foreground px-4 py-8 text-center",
495
+ children: "No stores found"
496
+ }, undefined, false, undefined, this)
497
+ }, undefined, false, undefined, this)
498
+ ]
499
+ }, undefined, true, undefined, this)
500
+ ]
501
+ }, undefined, true, undefined, this)
502
+ }, undefined, false, undefined, this),
503
+ activeTab === "products" && /* @__PURE__ */ jsxDEV("div", {
504
+ className: "border-border rounded-lg border",
505
+ children: /* @__PURE__ */ jsxDEV("table", {
506
+ className: "w-full",
507
+ children: [
508
+ /* @__PURE__ */ jsxDEV("thead", {
509
+ className: "border-border bg-muted/30 border-b",
510
+ children: /* @__PURE__ */ jsxDEV("tr", {
511
+ children: [
512
+ /* @__PURE__ */ jsxDEV("th", {
513
+ className: "px-4 py-3 text-left text-sm font-medium",
514
+ children: "Product"
515
+ }, undefined, false, undefined, this),
516
+ /* @__PURE__ */ jsxDEV("th", {
517
+ className: "px-4 py-3 text-left text-sm font-medium",
518
+ children: "Price"
519
+ }, undefined, false, undefined, this),
520
+ /* @__PURE__ */ jsxDEV("th", {
521
+ className: "px-4 py-3 text-left text-sm font-medium",
522
+ children: "Stock"
523
+ }, undefined, false, undefined, this),
524
+ /* @__PURE__ */ jsxDEV("th", {
525
+ className: "px-4 py-3 text-left text-sm font-medium",
526
+ children: "Status"
527
+ }, undefined, false, undefined, this)
528
+ ]
529
+ }, undefined, true, undefined, this)
530
+ }, undefined, false, undefined, this),
531
+ /* @__PURE__ */ jsxDEV("tbody", {
532
+ className: "divide-border divide-y",
533
+ children: [
534
+ products.map((product) => /* @__PURE__ */ jsxDEV("tr", {
535
+ className: "hover:bg-muted/50",
536
+ children: [
537
+ /* @__PURE__ */ jsxDEV("td", {
538
+ className: "px-4 py-3",
539
+ children: [
540
+ /* @__PURE__ */ jsxDEV("div", {
541
+ className: "font-medium",
542
+ children: product.name
543
+ }, undefined, false, undefined, this),
544
+ /* @__PURE__ */ jsxDEV("div", {
545
+ className: "text-muted-foreground text-sm",
546
+ children: product.category
547
+ }, undefined, false, undefined, this)
548
+ ]
549
+ }, undefined, true, undefined, this),
550
+ /* @__PURE__ */ jsxDEV("td", {
551
+ className: "px-4 py-3 font-mono",
552
+ children: formatCurrency2(product.price, product.currency)
553
+ }, undefined, false, undefined, this),
554
+ /* @__PURE__ */ jsxDEV("td", {
555
+ className: "px-4 py-3",
556
+ children: product.stock
557
+ }, undefined, false, undefined, this),
558
+ /* @__PURE__ */ jsxDEV("td", {
559
+ className: "px-4 py-3",
560
+ children: /* @__PURE__ */ jsxDEV("span", {
561
+ className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[product.status] ?? ""}`,
562
+ children: product.status
563
+ }, undefined, false, undefined, this)
564
+ }, undefined, false, undefined, this)
565
+ ]
566
+ }, product.id, true, undefined, this)),
567
+ products.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
568
+ children: /* @__PURE__ */ jsxDEV("td", {
569
+ colSpan: 4,
570
+ className: "text-muted-foreground px-4 py-8 text-center",
571
+ children: "No products found"
572
+ }, undefined, false, undefined, this)
573
+ }, undefined, false, undefined, this)
574
+ ]
575
+ }, undefined, true, undefined, this)
576
+ ]
577
+ }, undefined, true, undefined, this)
578
+ }, undefined, false, undefined, this),
579
+ activeTab === "orders" && /* @__PURE__ */ jsxDEV("div", {
580
+ className: "border-border rounded-lg border",
581
+ children: /* @__PURE__ */ jsxDEV("table", {
582
+ className: "w-full",
583
+ children: [
584
+ /* @__PURE__ */ jsxDEV("thead", {
585
+ className: "border-border bg-muted/30 border-b",
586
+ children: /* @__PURE__ */ jsxDEV("tr", {
587
+ children: [
588
+ /* @__PURE__ */ jsxDEV("th", {
589
+ className: "px-4 py-3 text-left text-sm font-medium",
590
+ children: "Order ID"
591
+ }, undefined, false, undefined, this),
592
+ /* @__PURE__ */ jsxDEV("th", {
593
+ className: "px-4 py-3 text-left text-sm font-medium",
594
+ children: "Customer"
595
+ }, undefined, false, undefined, this),
596
+ /* @__PURE__ */ jsxDEV("th", {
597
+ className: "px-4 py-3 text-left text-sm font-medium",
598
+ children: "Total"
599
+ }, undefined, false, undefined, this),
600
+ /* @__PURE__ */ jsxDEV("th", {
601
+ className: "px-4 py-3 text-left text-sm font-medium",
602
+ children: "Status"
603
+ }, undefined, false, undefined, this),
604
+ /* @__PURE__ */ jsxDEV("th", {
605
+ className: "px-4 py-3 text-left text-sm font-medium",
606
+ children: "Date"
607
+ }, undefined, false, undefined, this)
608
+ ]
609
+ }, undefined, true, undefined, this)
610
+ }, undefined, false, undefined, this),
611
+ /* @__PURE__ */ jsxDEV("tbody", {
612
+ className: "divide-border divide-y",
613
+ children: [
614
+ orders.map((order) => /* @__PURE__ */ jsxDEV("tr", {
615
+ className: "hover:bg-muted/50",
616
+ children: [
617
+ /* @__PURE__ */ jsxDEV("td", {
618
+ className: "px-4 py-3 font-mono text-sm",
619
+ children: order.id
620
+ }, undefined, false, undefined, this),
621
+ /* @__PURE__ */ jsxDEV("td", {
622
+ className: "px-4 py-3 text-sm",
623
+ children: order.customerId
624
+ }, undefined, false, undefined, this),
625
+ /* @__PURE__ */ jsxDEV("td", {
626
+ className: "px-4 py-3 font-mono",
627
+ children: formatCurrency2(order.total, order.currency)
628
+ }, undefined, false, undefined, this),
629
+ /* @__PURE__ */ jsxDEV("td", {
630
+ className: "px-4 py-3",
631
+ children: /* @__PURE__ */ jsxDEV("span", {
632
+ className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[order.status] ?? ""}`,
633
+ children: order.status
634
+ }, undefined, false, undefined, this)
635
+ }, undefined, false, undefined, this),
636
+ /* @__PURE__ */ jsxDEV("td", {
637
+ className: "text-muted-foreground px-4 py-3 text-sm",
638
+ children: order.createdAt.toLocaleDateString()
639
+ }, undefined, false, undefined, this)
640
+ ]
641
+ }, order.id, true, undefined, this)),
642
+ orders.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
643
+ children: /* @__PURE__ */ jsxDEV("td", {
644
+ colSpan: 5,
645
+ className: "text-muted-foreground px-4 py-8 text-center",
646
+ children: "No orders found"
647
+ }, undefined, false, undefined, this)
648
+ }, undefined, false, undefined, this)
649
+ ]
650
+ }, undefined, true, undefined, this)
651
+ ]
652
+ }, undefined, true, undefined, this)
653
+ }, undefined, false, undefined, this)
654
+ ]
655
+ }, undefined, true, undefined, this)
656
+ ]
657
+ }, undefined, true, undefined, this);
658
+ }
659
+
660
+ // src/ui/hooks/index.ts
661
+ "use client";
662
+ export {
663
+ useMarketplaceData,
664
+ productCatalogMarkdownRenderer,
665
+ orderListMarkdownRenderer,
666
+ marketplaceDashboardMarkdownRenderer,
667
+ MarketplaceDashboard
668
+ };