@contractspec/example.marketplace 0.0.0-canary-20260113170453

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 (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -0
  3. package/dist/docs/index.d.ts +1 -0
  4. package/dist/docs/index.js +1 -0
  5. package/dist/docs/marketplace.docblock.d.ts +1 -0
  6. package/dist/docs/marketplace.docblock.js +115 -0
  7. package/dist/docs/marketplace.docblock.js.map +1 -0
  8. package/dist/entities/index.d.ts +309 -0
  9. package/dist/entities/index.d.ts.map +1 -0
  10. package/dist/entities/index.js +46 -0
  11. package/dist/entities/index.js.map +1 -0
  12. package/dist/entities/order.d.ts +105 -0
  13. package/dist/entities/order.d.ts.map +1 -0
  14. package/dist/entities/order.js +173 -0
  15. package/dist/entities/order.js.map +1 -0
  16. package/dist/entities/payout.d.ts +92 -0
  17. package/dist/entities/payout.d.ts.map +1 -0
  18. package/dist/entities/payout.js +162 -0
  19. package/dist/entities/payout.js.map +1 -0
  20. package/dist/entities/product.d.ts +93 -0
  21. package/dist/entities/product.d.ts.map +1 -0
  22. package/dist/entities/product.js +161 -0
  23. package/dist/entities/product.js.map +1 -0
  24. package/dist/entities/review.d.ts +83 -0
  25. package/dist/entities/review.d.ts.map +1 -0
  26. package/dist/entities/review.js +152 -0
  27. package/dist/entities/review.js.map +1 -0
  28. package/dist/entities/store.d.ts +60 -0
  29. package/dist/entities/store.d.ts.map +1 -0
  30. package/dist/entities/store.js +110 -0
  31. package/dist/entities/store.js.map +1 -0
  32. package/dist/example.d.ts +7 -0
  33. package/dist/example.d.ts.map +1 -0
  34. package/dist/example.js +58 -0
  35. package/dist/example.js.map +1 -0
  36. package/dist/handlers/index.d.ts +2 -0
  37. package/dist/handlers/index.js +3 -0
  38. package/dist/handlers/marketplace.handlers.d.ts +155 -0
  39. package/dist/handlers/marketplace.handlers.d.ts.map +1 -0
  40. package/dist/handlers/marketplace.handlers.js +329 -0
  41. package/dist/handlers/marketplace.handlers.js.map +1 -0
  42. package/dist/index.d.ts +31 -0
  43. package/dist/index.js +32 -0
  44. package/dist/marketplace.capability.d.ts +9 -0
  45. package/dist/marketplace.capability.d.ts.map +1 -0
  46. package/dist/marketplace.capability.js +34 -0
  47. package/dist/marketplace.capability.js.map +1 -0
  48. package/dist/marketplace.feature.d.ts +12 -0
  49. package/dist/marketplace.feature.d.ts.map +1 -0
  50. package/dist/marketplace.feature.js +315 -0
  51. package/dist/marketplace.feature.js.map +1 -0
  52. package/dist/order/index.d.ts +5 -0
  53. package/dist/order/index.js +6 -0
  54. package/dist/order/order.enum.d.ts +10 -0
  55. package/dist/order/order.enum.d.ts.map +1 -0
  56. package/dist/order/order.enum.js +22 -0
  57. package/dist/order/order.enum.js.map +1 -0
  58. package/dist/order/order.event.d.ts +145 -0
  59. package/dist/order/order.event.d.ts.map +1 -0
  60. package/dist/order/order.event.js +216 -0
  61. package/dist/order/order.event.js.map +1 -0
  62. package/dist/order/order.operations.d.ts +368 -0
  63. package/dist/order/order.operations.d.ts.map +1 -0
  64. package/dist/order/order.operations.js +119 -0
  65. package/dist/order/order.operations.js.map +1 -0
  66. package/dist/order/order.presentation.d.ts +9 -0
  67. package/dist/order/order.presentation.d.ts.map +1 -0
  68. package/dist/order/order.presentation.js +86 -0
  69. package/dist/order/order.presentation.js.map +1 -0
  70. package/dist/order/order.schema.d.ts +165 -0
  71. package/dist/order/order.schema.d.ts.map +1 -0
  72. package/dist/order/order.schema.js +155 -0
  73. package/dist/order/order.schema.js.map +1 -0
  74. package/dist/payout/index.d.ts +5 -0
  75. package/dist/payout/index.js +6 -0
  76. package/dist/payout/payout.enum.d.ts +10 -0
  77. package/dist/payout/payout.enum.d.ts.map +1 -0
  78. package/dist/payout/payout.enum.js +17 -0
  79. package/dist/payout/payout.enum.js.map +1 -0
  80. package/dist/payout/payout.event.d.ts +63 -0
  81. package/dist/payout/payout.event.d.ts.map +1 -0
  82. package/dist/payout/payout.event.js +92 -0
  83. package/dist/payout/payout.event.js.map +1 -0
  84. package/dist/payout/payout.operations.d.ts +97 -0
  85. package/dist/payout/payout.operations.d.ts.map +1 -0
  86. package/dist/payout/payout.operations.js +53 -0
  87. package/dist/payout/payout.operations.js.map +1 -0
  88. package/dist/payout/payout.presentation.d.ts +8 -0
  89. package/dist/payout/payout.presentation.d.ts.map +1 -0
  90. package/dist/payout/payout.presentation.js +60 -0
  91. package/dist/payout/payout.presentation.js.map +1 -0
  92. package/dist/payout/payout.schema.d.ts +157 -0
  93. package/dist/payout/payout.schema.d.ts.map +1 -0
  94. package/dist/payout/payout.schema.js +116 -0
  95. package/dist/payout/payout.schema.js.map +1 -0
  96. package/dist/product/index.d.ts +5 -0
  97. package/dist/product/index.js +6 -0
  98. package/dist/product/product.enum.d.ts +10 -0
  99. package/dist/product/product.enum.d.ts.map +1 -0
  100. package/dist/product/product.enum.js +18 -0
  101. package/dist/product/product.enum.js.map +1 -0
  102. package/dist/product/product.event.d.ts +73 -0
  103. package/dist/product/product.event.d.ts.map +1 -0
  104. package/dist/product/product.event.js +120 -0
  105. package/dist/product/product.event.js.map +1 -0
  106. package/dist/product/product.operations.d.ts +273 -0
  107. package/dist/product/product.operations.d.ts.map +1 -0
  108. package/dist/product/product.operations.js +108 -0
  109. package/dist/product/product.operations.js.map +1 -0
  110. package/dist/product/product.presentation.d.ts +9 -0
  111. package/dist/product/product.presentation.d.ts.map +1 -0
  112. package/dist/product/product.presentation.js +86 -0
  113. package/dist/product/product.presentation.js.map +1 -0
  114. package/dist/product/product.schema.d.ts +218 -0
  115. package/dist/product/product.schema.d.ts.map +1 -0
  116. package/dist/product/product.schema.js +176 -0
  117. package/dist/product/product.schema.js.map +1 -0
  118. package/dist/review/index.d.ts +5 -0
  119. package/dist/review/index.js +6 -0
  120. package/dist/review/review.enum.d.ts +10 -0
  121. package/dist/review/review.enum.d.ts.map +1 -0
  122. package/dist/review/review.enum.js +16 -0
  123. package/dist/review/review.enum.js.map +1 -0
  124. package/dist/review/review.event.d.ts +55 -0
  125. package/dist/review/review.event.d.ts.map +1 -0
  126. package/dist/review/review.event.js +84 -0
  127. package/dist/review/review.event.js.map +1 -0
  128. package/dist/review/review.operations.d.ts +237 -0
  129. package/dist/review/review.operations.d.ts.map +1 -0
  130. package/dist/review/review.operations.js +106 -0
  131. package/dist/review/review.operations.js.map +1 -0
  132. package/dist/review/review.presentation.d.ts +8 -0
  133. package/dist/review/review.presentation.d.ts.map +1 -0
  134. package/dist/review/review.presentation.js +60 -0
  135. package/dist/review/review.presentation.js.map +1 -0
  136. package/dist/review/review.schema.d.ts +190 -0
  137. package/dist/review/review.schema.d.ts.map +1 -0
  138. package/dist/review/review.schema.js +156 -0
  139. package/dist/review/review.schema.js.map +1 -0
  140. package/dist/seeders/index.d.ts +10 -0
  141. package/dist/seeders/index.d.ts.map +1 -0
  142. package/dist/seeders/index.js +18 -0
  143. package/dist/seeders/index.js.map +1 -0
  144. package/dist/store/index.d.ts +5 -0
  145. package/dist/store/index.js +6 -0
  146. package/dist/store/store.enum.d.ts +10 -0
  147. package/dist/store/store.enum.d.ts.map +1 -0
  148. package/dist/store/store.enum.js +16 -0
  149. package/dist/store/store.enum.js.map +1 -0
  150. package/dist/store/store.event.d.ts +51 -0
  151. package/dist/store/store.event.d.ts.map +1 -0
  152. package/dist/store/store.event.js +80 -0
  153. package/dist/store/store.event.js.map +1 -0
  154. package/dist/store/store.operations.d.ts +131 -0
  155. package/dist/store/store.operations.d.ts.map +1 -0
  156. package/dist/store/store.operations.js +61 -0
  157. package/dist/store/store.operations.js.map +1 -0
  158. package/dist/store/store.presentation.d.ts +8 -0
  159. package/dist/store/store.presentation.d.ts.map +1 -0
  160. package/dist/store/store.presentation.js +60 -0
  161. package/dist/store/store.presentation.js.map +1 -0
  162. package/dist/store/store.schema.d.ts +84 -0
  163. package/dist/store/store.schema.d.ts.map +1 -0
  164. package/dist/store/store.schema.js +93 -0
  165. package/dist/store/store.schema.js.map +1 -0
  166. package/dist/tests/operations.test-spec.d.ts +11 -0
  167. package/dist/tests/operations.test-spec.d.ts.map +1 -0
  168. package/dist/tests/operations.test-spec.js +152 -0
  169. package/dist/tests/operations.test-spec.js.map +1 -0
  170. package/dist/ui/MarketplaceDashboard.d.ts +7 -0
  171. package/dist/ui/MarketplaceDashboard.d.ts.map +1 -0
  172. package/dist/ui/MarketplaceDashboard.js +319 -0
  173. package/dist/ui/MarketplaceDashboard.js.map +1 -0
  174. package/dist/ui/hooks/index.d.ts +2 -0
  175. package/dist/ui/hooks/index.js +5 -0
  176. package/dist/ui/hooks/useMarketplaceData.d.ts +23 -0
  177. package/dist/ui/hooks/useMarketplaceData.d.ts.map +1 -0
  178. package/dist/ui/hooks/useMarketplaceData.js +64 -0
  179. package/dist/ui/hooks/useMarketplaceData.js.map +1 -0
  180. package/dist/ui/index.d.ts +6 -0
  181. package/dist/ui/index.js +6 -0
  182. package/dist/ui/renderers/index.d.ts +2 -0
  183. package/dist/ui/renderers/index.js +3 -0
  184. package/dist/ui/renderers/marketplace.markdown.d.ts +28 -0
  185. package/dist/ui/renderers/marketplace.markdown.d.ts.map +1 -0
  186. package/dist/ui/renderers/marketplace.markdown.js +244 -0
  187. package/dist/ui/renderers/marketplace.markdown.js.map +1 -0
  188. package/package.json +149 -0
@@ -0,0 +1,244 @@
1
+ //#region src/ui/renderers/marketplace.markdown.ts
2
+ const 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
+ const 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
+ const 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
+ /**
122
+ * Markdown renderer for Marketplace Dashboard
123
+ */
124
+ const marketplaceDashboardMarkdownRenderer = {
125
+ target: "markdown",
126
+ render: async (desc) => {
127
+ if (desc.source.type !== "component" || desc.source.componentKey !== "MarketplaceDashboard") throw new Error("marketplaceDashboardMarkdownRenderer: not MarketplaceDashboard");
128
+ const stores = mockStores;
129
+ const products = mockProducts;
130
+ const orders = mockOrders;
131
+ const activeStores = stores.filter((s) => s.status === "ACTIVE");
132
+ const activeProducts = products.filter((p) => p.status === "ACTIVE");
133
+ const totalRevenue = orders.reduce((sum, o) => sum + o.total, 0);
134
+ const pendingOrders = orders.filter((o) => o.status === "PENDING" || o.status === "PROCESSING");
135
+ const lines = [
136
+ "# Marketplace Dashboard",
137
+ "",
138
+ "> Two-sided marketplace overview",
139
+ "",
140
+ "## Summary",
141
+ "",
142
+ "| Metric | Value |",
143
+ "|--------|-------|",
144
+ `| Active Stores | ${activeStores.length} |`,
145
+ `| Active Products | ${activeProducts.length} |`,
146
+ `| Total Orders | ${orders.length} |`,
147
+ `| Total Revenue | ${formatCurrency(totalRevenue)} |`,
148
+ `| Pending Orders | ${pendingOrders.length} |`,
149
+ "",
150
+ "## Top Stores",
151
+ "",
152
+ "| Store | Products | Rating | Status |",
153
+ "|-------|----------|--------|--------|"
154
+ ];
155
+ for (const store of stores.slice(0, 5)) lines.push(`| ${store.name} | ${store.productCount} | ⭐ ${store.rating || "N/A"} | ${store.status} |`);
156
+ lines.push("");
157
+ lines.push("## Recent Orders");
158
+ lines.push("");
159
+ lines.push("| Order | Items | Total | Status | Date |");
160
+ lines.push("|-------|-------|-------|--------|------|");
161
+ for (const order of orders.slice(0, 10)) {
162
+ const date = new Date(order.createdAt).toLocaleDateString();
163
+ lines.push(`| ${order.id} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`);
164
+ }
165
+ return {
166
+ mimeType: "text/markdown",
167
+ body: lines.join("\n")
168
+ };
169
+ }
170
+ };
171
+ /**
172
+ * Markdown renderer for Product Catalog
173
+ */
174
+ const productCatalogMarkdownRenderer = {
175
+ target: "markdown",
176
+ render: async (desc) => {
177
+ if (desc.source.type !== "component" || desc.source.componentKey !== "ProductCatalog") throw new Error("productCatalogMarkdownRenderer: not ProductCatalog");
178
+ const products = mockProducts;
179
+ const stores = mockStores;
180
+ const lines = [
181
+ "# Product Catalog",
182
+ "",
183
+ "> Browse products across all marketplace stores",
184
+ ""
185
+ ];
186
+ for (const store of stores.filter((s) => s.status === "ACTIVE")) {
187
+ const storeProducts = products.filter((p) => p.storeId === store.id);
188
+ if (storeProducts.length === 0) continue;
189
+ lines.push(`## ${store.name}`);
190
+ lines.push("");
191
+ lines.push("| Product | Price | Stock | Status |");
192
+ lines.push("|---------|-------|-------|--------|");
193
+ for (const product of storeProducts) {
194
+ const stockStatus = product.stock > 0 ? `${product.stock} in stock` : "Out of stock";
195
+ lines.push(`| ${product.name} | ${formatCurrency(product.price, product.currency)} | ${stockStatus} | ${product.status} |`);
196
+ }
197
+ lines.push("");
198
+ }
199
+ return {
200
+ mimeType: "text/markdown",
201
+ body: lines.join("\n")
202
+ };
203
+ }
204
+ };
205
+ /**
206
+ * Markdown renderer for Order List
207
+ */
208
+ const orderListMarkdownRenderer = {
209
+ target: "markdown",
210
+ render: async (desc) => {
211
+ if (desc.source.type !== "component" || desc.source.componentKey !== "OrderList") throw new Error("orderListMarkdownRenderer: not OrderList");
212
+ const orders = mockOrders;
213
+ const stores = mockStores;
214
+ const lines = [
215
+ "# Orders",
216
+ "",
217
+ "> Manage marketplace orders",
218
+ "",
219
+ "| Order ID | Store | Items | Total | Status | Created |",
220
+ "|----------|-------|-------|-------|--------|---------|"
221
+ ];
222
+ for (const order of orders) {
223
+ const store = stores.find((s) => s.id === order.storeId);
224
+ const date = new Date(order.createdAt).toLocaleDateString();
225
+ lines.push(`| ${order.id} | ${store?.name ?? "Unknown"} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`);
226
+ }
227
+ lines.push("");
228
+ lines.push("## Order Status Legend");
229
+ lines.push("");
230
+ lines.push("- **PENDING**: Awaiting payment confirmation");
231
+ lines.push("- **PROCESSING**: Being prepared");
232
+ lines.push("- **SHIPPED**: In transit");
233
+ lines.push("- **DELIVERED**: Order completed");
234
+ lines.push("- **CANCELLED**: Order cancelled");
235
+ return {
236
+ mimeType: "text/markdown",
237
+ body: lines.join("\n")
238
+ };
239
+ }
240
+ };
241
+
242
+ //#endregion
243
+ export { marketplaceDashboardMarkdownRenderer, orderListMarkdownRenderer, productCatalogMarkdownRenderer };
244
+ //# sourceMappingURL=marketplace.markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketplace.markdown.js","names":[],"sources":["../../../src/ui/renderers/marketplace.markdown.ts"],"sourcesContent":["/**\n * Markdown renderers for Marketplace presentations\n */\nimport type { PresentationRenderer } from '@contractspec/lib.contracts';\n\n// Mock data for marketplace rendering\nconst mockStores = [\n {\n id: 'store-1',\n name: 'Tech Gadgets Store',\n status: 'ACTIVE',\n productCount: 45,\n rating: 4.8,\n },\n {\n id: 'store-2',\n name: 'Home & Garden',\n status: 'ACTIVE',\n productCount: 120,\n rating: 4.5,\n },\n {\n id: 'store-3',\n name: 'Fashion Boutique',\n status: 'PENDING',\n productCount: 0,\n rating: 0,\n },\n];\n\nconst mockProducts = [\n {\n id: 'prod-1',\n name: 'Wireless Earbuds',\n storeId: 'store-1',\n price: 79.99,\n currency: 'USD',\n status: 'ACTIVE',\n stock: 150,\n },\n {\n id: 'prod-2',\n name: 'Smart Watch',\n storeId: 'store-1',\n price: 249.99,\n currency: 'USD',\n status: 'ACTIVE',\n stock: 50,\n },\n {\n id: 'prod-3',\n name: 'Garden Tools Set',\n storeId: 'store-2',\n price: 89.99,\n currency: 'USD',\n status: 'ACTIVE',\n stock: 30,\n },\n {\n id: 'prod-4',\n name: 'Indoor Plant Kit',\n storeId: 'store-2',\n price: 45.99,\n currency: 'USD',\n status: 'ACTIVE',\n stock: 75,\n },\n {\n id: 'prod-5',\n name: 'LED Desk Lamp',\n storeId: 'store-1',\n price: 34.99,\n currency: 'USD',\n status: 'OUT_OF_STOCK',\n stock: 0,\n },\n];\n\nconst mockOrders = [\n {\n id: 'ord-1',\n storeId: 'store-1',\n customerId: 'cust-1',\n total: 329.98,\n currency: 'USD',\n status: 'DELIVERED',\n itemCount: 2,\n createdAt: '2024-01-15T10:00:00Z',\n },\n {\n id: 'ord-2',\n storeId: 'store-2',\n customerId: 'cust-2',\n total: 135.98,\n currency: 'USD',\n status: 'SHIPPED',\n itemCount: 2,\n createdAt: '2024-01-14T14:00:00Z',\n },\n {\n id: 'ord-3',\n storeId: 'store-1',\n customerId: 'cust-3',\n total: 79.99,\n currency: 'USD',\n status: 'PROCESSING',\n itemCount: 1,\n createdAt: '2024-01-16T08:00:00Z',\n },\n {\n id: 'ord-4',\n storeId: 'store-2',\n customerId: 'cust-4',\n total: 45.99,\n currency: 'USD',\n status: 'PENDING',\n itemCount: 1,\n createdAt: '2024-01-16T12:00:00Z',\n },\n];\n\nfunction formatCurrency(value: number, currency = 'USD'): string {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n minimumFractionDigits: 2,\n }).format(value);\n}\n\n/**\n * Markdown renderer for Marketplace Dashboard\n */\nexport const marketplaceDashboardMarkdownRenderer: PresentationRenderer<{\n mimeType: string;\n body: string;\n}> = {\n target: 'markdown',\n render: async (desc) => {\n if (\n desc.source.type !== 'component' ||\n desc.source.componentKey !== 'MarketplaceDashboard'\n ) {\n throw new Error(\n 'marketplaceDashboardMarkdownRenderer: not MarketplaceDashboard'\n );\n }\n\n const stores = mockStores;\n const products = mockProducts;\n const orders = mockOrders;\n\n // Calculate stats\n const activeStores = stores.filter((s) => s.status === 'ACTIVE');\n const activeProducts = products.filter((p) => p.status === 'ACTIVE');\n const totalRevenue = orders.reduce((sum, o) => sum + o.total, 0);\n const pendingOrders = orders.filter(\n (o) => o.status === 'PENDING' || o.status === 'PROCESSING'\n );\n\n const lines: string[] = [\n '# Marketplace Dashboard',\n '',\n '> Two-sided marketplace overview',\n '',\n '## Summary',\n '',\n '| Metric | Value |',\n '|--------|-------|',\n `| Active Stores | ${activeStores.length} |`,\n `| Active Products | ${activeProducts.length} |`,\n `| Total Orders | ${orders.length} |`,\n `| Total Revenue | ${formatCurrency(totalRevenue)} |`,\n `| Pending Orders | ${pendingOrders.length} |`,\n '',\n '## Top Stores',\n '',\n '| Store | Products | Rating | Status |',\n '|-------|----------|--------|--------|',\n ];\n\n for (const store of stores.slice(0, 5)) {\n lines.push(\n `| ${store.name} | ${store.productCount} | ⭐ ${store.rating || 'N/A'} | ${store.status} |`\n );\n }\n\n lines.push('');\n lines.push('## Recent Orders');\n lines.push('');\n lines.push('| Order | Items | Total | Status | Date |');\n lines.push('|-------|-------|-------|--------|------|');\n\n for (const order of orders.slice(0, 10)) {\n const date = new Date(order.createdAt).toLocaleDateString();\n lines.push(\n `| ${order.id} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`\n );\n }\n\n return {\n mimeType: 'text/markdown',\n body: lines.join('\\n'),\n };\n },\n};\n\n/**\n * Markdown renderer for Product Catalog\n */\nexport const productCatalogMarkdownRenderer: PresentationRenderer<{\n mimeType: string;\n body: string;\n}> = {\n target: 'markdown',\n render: async (desc) => {\n if (\n desc.source.type !== 'component' ||\n desc.source.componentKey !== 'ProductCatalog'\n ) {\n throw new Error('productCatalogMarkdownRenderer: not ProductCatalog');\n }\n\n const products = mockProducts;\n const stores = mockStores;\n\n const lines: string[] = [\n '# Product Catalog',\n '',\n '> Browse products across all marketplace stores',\n '',\n ];\n\n // Group by store\n for (const store of stores.filter((s) => s.status === 'ACTIVE')) {\n const storeProducts = products.filter((p) => p.storeId === store.id);\n\n if (storeProducts.length === 0) continue;\n\n lines.push(`## ${store.name}`);\n lines.push('');\n lines.push('| Product | Price | Stock | Status |');\n lines.push('|---------|-------|-------|--------|');\n\n for (const product of storeProducts) {\n const stockStatus =\n product.stock > 0 ? `${product.stock} in stock` : 'Out of stock';\n lines.push(\n `| ${product.name} | ${formatCurrency(product.price, product.currency)} | ${stockStatus} | ${product.status} |`\n );\n }\n\n lines.push('');\n }\n\n return {\n mimeType: 'text/markdown',\n body: lines.join('\\n'),\n };\n },\n};\n\n/**\n * Markdown renderer for Order List\n */\nexport const orderListMarkdownRenderer: PresentationRenderer<{\n mimeType: string;\n body: string;\n}> = {\n target: 'markdown',\n render: async (desc) => {\n if (\n desc.source.type !== 'component' ||\n desc.source.componentKey !== 'OrderList'\n ) {\n throw new Error('orderListMarkdownRenderer: not OrderList');\n }\n\n const orders = mockOrders;\n const stores = mockStores;\n\n const lines: string[] = [\n '# Orders',\n '',\n '> Manage marketplace orders',\n '',\n '| Order ID | Store | Items | Total | Status | Created |',\n '|----------|-------|-------|-------|--------|---------|',\n ];\n\n for (const order of orders) {\n const store = stores.find((s) => s.id === order.storeId);\n const date = new Date(order.createdAt).toLocaleDateString();\n lines.push(\n `| ${order.id} | ${store?.name ?? 'Unknown'} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`\n );\n }\n\n lines.push('');\n lines.push('## Order Status Legend');\n lines.push('');\n lines.push('- **PENDING**: Awaiting payment confirmation');\n lines.push('- **PROCESSING**: Being prepared');\n lines.push('- **SHIPPED**: In transit');\n lines.push('- **DELIVERED**: Order completed');\n lines.push('- **CANCELLED**: Order cancelled');\n\n return {\n mimeType: 'text/markdown',\n body: lines.join('\\n'),\n };\n },\n};\n"],"mappings":";AAMA,MAAM,aAAa;CACjB;EACE,IAAI;EACJ,MAAM;EACN,QAAQ;EACR,cAAc;EACd,QAAQ;EACT;CACD;EACE,IAAI;EACJ,MAAM;EACN,QAAQ;EACR,cAAc;EACd,QAAQ;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AAC,KAAK,MAAM,OAAO,KAAK,KAAK,IAC/I;;AAGH,QAAM,KAAK,GAAG;AACd,QAAM,KAAK,yBAAyB;AACpC,QAAM,KAAK,GAAG;AACd,QAAM,KAAK,+CAA+C;AAC1D,QAAM,KAAK,mCAAmC;AAC9C,QAAM,KAAK,4BAA4B;AACvC,QAAM,KAAK,mCAAmC;AAC9C,QAAM,KAAK,mCAAmC;AAE9C,SAAO;GACL,UAAU;GACV,MAAM,MAAM,KAAK,KAAK;GACvB;;CAEJ"}
package/package.json ADDED
@@ -0,0 +1,149 @@
1
+ {
2
+ "name": "@contractspec/example.marketplace",
3
+ "version": "0.0.0-canary-20260113170453",
4
+ "description": "Marketplace example with orders, payouts, and reviews for ContractSpec",
5
+ "types": "./dist/index.d.ts",
6
+ "type": "module",
7
+ "scripts": {
8
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
9
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
10
+ "build": "bun build:types && bun build:bundle",
11
+ "build:bundle": "tsdown",
12
+ "build:types": "tsc --noEmit",
13
+ "dev": "bun build:bundle --watch",
14
+ "clean": "rimraf dist .turbo",
15
+ "lint": "bun lint:fix",
16
+ "lint:fix": "eslint src --fix",
17
+ "lint:check": "eslint src"
18
+ },
19
+ "dependencies": {
20
+ "@contractspec/lib.schema": "0.0.0-canary-20260113170453",
21
+ "@contractspec/lib.contracts": "0.0.0-canary-20260113170453",
22
+ "@contractspec/lib.example-shared-ui": "0.0.0-canary-20260113170453",
23
+ "@contractspec/lib.design-system": "0.0.0-canary-20260113170453",
24
+ "@contractspec/lib.runtime-sandbox": "0.0.0-canary-20260113170453",
25
+ "react": "19.2.3",
26
+ "react-dom": "19.2.3"
27
+ },
28
+ "devDependencies": {
29
+ "@contractspec/tool.typescript": "0.0.0-canary-20260113170453",
30
+ "@contractspec/tool.tsdown": "0.0.0-canary-20260113170453",
31
+ "typescript": "^5.9.3",
32
+ "@types/react": "^19.2.8",
33
+ "@types/react-dom": "^19.2.2"
34
+ },
35
+ "exports": {
36
+ ".": "./dist/index.js",
37
+ "./docs": "./dist/docs/index.js",
38
+ "./docs/marketplace.docblock": "./dist/docs/marketplace.docblock.js",
39
+ "./entities": "./dist/entities/index.js",
40
+ "./entities/order": "./dist/entities/order.js",
41
+ "./entities/payout": "./dist/entities/payout.js",
42
+ "./entities/product": "./dist/entities/product.js",
43
+ "./entities/review": "./dist/entities/review.js",
44
+ "./entities/store": "./dist/entities/store.js",
45
+ "./example": "./dist/example.js",
46
+ "./handlers": "./dist/handlers/index.js",
47
+ "./handlers/marketplace.handlers": "./dist/handlers/marketplace.handlers.js",
48
+ "./marketplace.capability": "./dist/marketplace.capability.js",
49
+ "./marketplace.feature": "./dist/marketplace.feature.js",
50
+ "./order": "./dist/order/index.js",
51
+ "./order/order.enum": "./dist/order/order.enum.js",
52
+ "./order/order.event": "./dist/order/order.event.js",
53
+ "./order/order.operations": "./dist/order/order.operations.js",
54
+ "./order/order.presentation": "./dist/order/order.presentation.js",
55
+ "./order/order.schema": "./dist/order/order.schema.js",
56
+ "./payout": "./dist/payout/index.js",
57
+ "./payout/payout.enum": "./dist/payout/payout.enum.js",
58
+ "./payout/payout.event": "./dist/payout/payout.event.js",
59
+ "./payout/payout.operations": "./dist/payout/payout.operations.js",
60
+ "./payout/payout.presentation": "./dist/payout/payout.presentation.js",
61
+ "./payout/payout.schema": "./dist/payout/payout.schema.js",
62
+ "./product": "./dist/product/index.js",
63
+ "./product/product.enum": "./dist/product/product.enum.js",
64
+ "./product/product.event": "./dist/product/product.event.js",
65
+ "./product/product.operations": "./dist/product/product.operations.js",
66
+ "./product/product.presentation": "./dist/product/product.presentation.js",
67
+ "./product/product.schema": "./dist/product/product.schema.js",
68
+ "./review": "./dist/review/index.js",
69
+ "./review/review.enum": "./dist/review/review.enum.js",
70
+ "./review/review.event": "./dist/review/review.event.js",
71
+ "./review/review.operations": "./dist/review/review.operations.js",
72
+ "./review/review.presentation": "./dist/review/review.presentation.js",
73
+ "./review/review.schema": "./dist/review/review.schema.js",
74
+ "./seeders": "./dist/seeders/index.js",
75
+ "./store": "./dist/store/index.js",
76
+ "./store/store.enum": "./dist/store/store.enum.js",
77
+ "./store/store.event": "./dist/store/store.event.js",
78
+ "./store/store.operations": "./dist/store/store.operations.js",
79
+ "./store/store.presentation": "./dist/store/store.presentation.js",
80
+ "./store/store.schema": "./dist/store/store.schema.js",
81
+ "./tests/operations.test-spec": "./dist/tests/operations.test-spec.js",
82
+ "./ui": "./dist/ui/index.js",
83
+ "./ui/hooks": "./dist/ui/hooks/index.js",
84
+ "./ui/hooks/useMarketplaceData": "./dist/ui/hooks/useMarketplaceData.js",
85
+ "./ui/MarketplaceDashboard": "./dist/ui/MarketplaceDashboard.js",
86
+ "./ui/renderers": "./dist/ui/renderers/index.js",
87
+ "./ui/renderers/marketplace.markdown": "./dist/ui/renderers/marketplace.markdown.js",
88
+ "./*": "./*"
89
+ },
90
+ "files": [
91
+ "dist",
92
+ "README.md"
93
+ ],
94
+ "publishConfig": {
95
+ "access": "public",
96
+ "exports": {
97
+ ".": "./dist/index.js",
98
+ "./docs": "./dist/docs/index.js",
99
+ "./docs/marketplace.docblock": "./dist/docs/marketplace.docblock.js",
100
+ "./entities": "./dist/entities/index.js",
101
+ "./entities/order": "./dist/entities/order.js",
102
+ "./entities/payout": "./dist/entities/payout.js",
103
+ "./entities/product": "./dist/entities/product.js",
104
+ "./entities/review": "./dist/entities/review.js",
105
+ "./entities/store": "./dist/entities/store.js",
106
+ "./example": "./dist/example.js",
107
+ "./marketplace.feature": "./dist/marketplace.feature.js",
108
+ "./order": "./dist/order/index.js",
109
+ "./order/order.contracts": "./dist/order/order.operations.js",
110
+ "./order/order.enum": "./dist/order/order.enum.js",
111
+ "./order/order.event": "./dist/order/order.event.js",
112
+ "./order/order.presentation": "./dist/order/order.presentation.js",
113
+ "./order/order.schema": "./dist/order/order.schema.js",
114
+ "./payout": "./dist/payout/index.js",
115
+ "./payout/payout.contracts": "./dist/payout/payout.operations.js",
116
+ "./payout/payout.enum": "./dist/payout/payout.enum.js",
117
+ "./payout/payout.event": "./dist/payout/payout.event.js",
118
+ "./payout/payout.presentation": "./dist/payout/payout.presentation.js",
119
+ "./payout/payout.schema": "./dist/payout/payout.schema.js",
120
+ "./product": "./dist/product/index.js",
121
+ "./product/product.contracts": "./dist/product/product.operations.js",
122
+ "./product/product.enum": "./dist/product/product.enum.js",
123
+ "./product/product.event": "./dist/product/product.event.js",
124
+ "./product/product.presentation": "./dist/product/product.presentation.js",
125
+ "./product/product.schema": "./dist/product/product.schema.js",
126
+ "./review": "./dist/review/index.js",
127
+ "./review/review.contracts": "./dist/review/review.operations.js",
128
+ "./review/review.enum": "./dist/review/review.enum.js",
129
+ "./review/review.event": "./dist/review/review.event.js",
130
+ "./review/review.presentation": "./dist/review/review.presentation.js",
131
+ "./review/review.schema": "./dist/review/review.schema.js",
132
+ "./store": "./dist/store/index.js",
133
+ "./store/store.contracts": "./dist/store/store.operations.js",
134
+ "./store/store.enum": "./dist/store/store.enum.js",
135
+ "./store/store.event": "./dist/store/store.event.js",
136
+ "./store/store.presentation": "./dist/store/store.presentation.js",
137
+ "./store/store.schema": "./dist/store/store.schema.js",
138
+ "./*": "./*"
139
+ },
140
+ "registry": "https://registry.npmjs.org/"
141
+ },
142
+ "license": "MIT",
143
+ "repository": {
144
+ "type": "git",
145
+ "url": "https://github.com/lssm-tech/contractspec.git",
146
+ "directory": "packages/examples/marketplace"
147
+ },
148
+ "homepage": "https://contractspec.io"
149
+ }