@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,152 @@
1
+ // src/review/review.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var ReviewStatusEnum = defineEnum("ReviewStatus", [
4
+ "PENDING",
5
+ "APPROVED",
6
+ "REJECTED",
7
+ "FLAGGED"
8
+ ]);
9
+
10
+ // src/review/review.schema.ts
11
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
12
+ var ReviewModel = defineSchemaModel({
13
+ name: "ReviewModel",
14
+ description: "A customer review",
15
+ fields: {
16
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
18
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
19
+ authorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
20
+ rating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
21
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
22
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
23
+ status: { type: ReviewStatusEnum, isOptional: false },
24
+ isVerifiedPurchase: { type: ScalarTypeEnum.Boolean(), isOptional: false },
25
+ helpfulCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
26
+ hasResponse: { type: ScalarTypeEnum.Boolean(), isOptional: false },
27
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
28
+ }
29
+ });
30
+ var CreateReviewInputModel = defineSchemaModel({
31
+ name: "CreateReviewInput",
32
+ fields: {
33
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
34
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
35
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
36
+ rating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
37
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
38
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
39
+ }
40
+ });
41
+ var ListReviewsInputModel = defineSchemaModel({
42
+ name: "ListReviewsInput",
43
+ fields: {
44
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
45
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
46
+ status: { type: ReviewStatusEnum, isOptional: true },
47
+ minRating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
48
+ limit: {
49
+ type: ScalarTypeEnum.Int_unsecure(),
50
+ isOptional: true,
51
+ defaultValue: 20
52
+ },
53
+ offset: {
54
+ type: ScalarTypeEnum.Int_unsecure(),
55
+ isOptional: true,
56
+ defaultValue: 0
57
+ }
58
+ }
59
+ });
60
+ var ListReviewsOutputModel = defineSchemaModel({
61
+ name: "ListReviewsOutput",
62
+ fields: {
63
+ reviews: { type: ReviewModel, isArray: true, isOptional: false },
64
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
65
+ averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
66
+ ratingDistribution: { type: ScalarTypeEnum.JSON(), isOptional: false }
67
+ }
68
+ });
69
+
70
+ // src/review/review.operations.ts
71
+ import {
72
+ defineCommand,
73
+ defineQuery
74
+ } from "@contractspec/lib.contracts/operations";
75
+ var OWNERS = ["@example.marketplace"];
76
+ var CreateReviewContract = defineCommand({
77
+ meta: {
78
+ key: "marketplace.review.create",
79
+ version: "1.0.0",
80
+ stability: "stable",
81
+ owners: [...OWNERS],
82
+ tags: ["marketplace", "review", "create"],
83
+ description: "Create a product/store review.",
84
+ goal: "Allow buyers to leave feedback.",
85
+ context: "Post-purchase."
86
+ },
87
+ io: { input: CreateReviewInputModel, output: ReviewModel },
88
+ policy: { auth: "user" },
89
+ sideEffects: {
90
+ emits: [
91
+ {
92
+ key: "marketplace.review.created",
93
+ version: "1.0.0",
94
+ when: "Review is created",
95
+ payload: ReviewModel
96
+ }
97
+ ],
98
+ audit: ["marketplace.review.created"]
99
+ },
100
+ acceptance: {
101
+ scenarios: [
102
+ {
103
+ key: "create-review-happy-path",
104
+ given: ["User purchased product"],
105
+ when: ["User leaves a review"],
106
+ then: ["Review is created", "ReviewCreated event is emitted"]
107
+ }
108
+ ],
109
+ examples: [
110
+ {
111
+ key: "create-5-star",
112
+ input: { productId: "prod-456", rating: 5, comment: "Great product!" },
113
+ output: { id: "rev-789", status: "published" }
114
+ }
115
+ ]
116
+ }
117
+ });
118
+ var ListReviewsContract = defineQuery({
119
+ meta: {
120
+ key: "marketplace.review.list",
121
+ version: "1.0.0",
122
+ stability: "stable",
123
+ owners: [...OWNERS],
124
+ tags: ["marketplace", "review", "list"],
125
+ description: "List reviews with filters.",
126
+ goal: "Display product/store reviews.",
127
+ context: "Product page, store page."
128
+ },
129
+ io: { input: ListReviewsInputModel, output: ListReviewsOutputModel },
130
+ policy: { auth: "anonymous" },
131
+ acceptance: {
132
+ scenarios: [
133
+ {
134
+ key: "list-reviews-happy-path",
135
+ given: ["Product has reviews"],
136
+ when: ["User views reviews"],
137
+ then: ["List of reviews is returned"]
138
+ }
139
+ ],
140
+ examples: [
141
+ {
142
+ key: "list-product-reviews",
143
+ input: { productId: "prod-456", limit: 10 },
144
+ output: { items: [], total: 10, hasMore: false }
145
+ }
146
+ ]
147
+ }
148
+ });
149
+ export {
150
+ ListReviewsContract,
151
+ CreateReviewContract
152
+ };
@@ -0,0 +1,123 @@
1
+ // src/review/review.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var ReviewStatusEnum = defineEnum("ReviewStatus", [
4
+ "PENDING",
5
+ "APPROVED",
6
+ "REJECTED",
7
+ "FLAGGED"
8
+ ]);
9
+
10
+ // src/review/review.schema.ts
11
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
12
+ var ReviewModel = defineSchemaModel({
13
+ name: "ReviewModel",
14
+ description: "A customer review",
15
+ fields: {
16
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
18
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
19
+ authorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
20
+ rating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
21
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
22
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
23
+ status: { type: ReviewStatusEnum, isOptional: false },
24
+ isVerifiedPurchase: { type: ScalarTypeEnum.Boolean(), isOptional: false },
25
+ helpfulCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
26
+ hasResponse: { type: ScalarTypeEnum.Boolean(), isOptional: false },
27
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
28
+ }
29
+ });
30
+ var CreateReviewInputModel = defineSchemaModel({
31
+ name: "CreateReviewInput",
32
+ fields: {
33
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
34
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
35
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
36
+ rating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
37
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
38
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
39
+ }
40
+ });
41
+ var ListReviewsInputModel = defineSchemaModel({
42
+ name: "ListReviewsInput",
43
+ fields: {
44
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
45
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
46
+ status: { type: ReviewStatusEnum, isOptional: true },
47
+ minRating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
48
+ limit: {
49
+ type: ScalarTypeEnum.Int_unsecure(),
50
+ isOptional: true,
51
+ defaultValue: 20
52
+ },
53
+ offset: {
54
+ type: ScalarTypeEnum.Int_unsecure(),
55
+ isOptional: true,
56
+ defaultValue: 0
57
+ }
58
+ }
59
+ });
60
+ var ListReviewsOutputModel = defineSchemaModel({
61
+ name: "ListReviewsOutput",
62
+ fields: {
63
+ reviews: { type: ReviewModel, isArray: true, isOptional: false },
64
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
65
+ averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
66
+ ratingDistribution: { type: ScalarTypeEnum.JSON(), isOptional: false }
67
+ }
68
+ });
69
+
70
+ // src/review/review.presentation.ts
71
+ import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
72
+ var ReviewListPresentation = definePresentation({
73
+ meta: {
74
+ key: "marketplace.review.viewList",
75
+ version: "1.0.0",
76
+ title: "Review List",
77
+ description: "List of product reviews",
78
+ domain: "marketplace",
79
+ owners: ["@marketplace-team"],
80
+ tags: ["marketplace", "review", "list"],
81
+ stability: StabilityEnum.Experimental,
82
+ goal: "Show users reviews and ratings for a product.",
83
+ context: "Displayed on the product detail page."
84
+ },
85
+ source: {
86
+ type: "component",
87
+ framework: "react",
88
+ componentKey: "ReviewList",
89
+ props: ReviewModel
90
+ },
91
+ targets: ["react", "markdown"],
92
+ policy: {
93
+ flags: ["marketplace.reviews.enabled"]
94
+ }
95
+ });
96
+ var ReviewFormPresentation = definePresentation({
97
+ meta: {
98
+ key: "marketplace.review.form",
99
+ version: "1.0.0",
100
+ title: "Review Form",
101
+ description: "Form for submitting product reviews",
102
+ domain: "marketplace",
103
+ owners: ["@marketplace-team"],
104
+ tags: ["marketplace", "review", "form"],
105
+ stability: StabilityEnum.Experimental,
106
+ goal: "Enable users to submit their feedback and rating for a purchase.",
107
+ context: "Used in the user order history or product page."
108
+ },
109
+ source: {
110
+ type: "component",
111
+ framework: "react",
112
+ componentKey: "ReviewForm",
113
+ props: ReviewModel
114
+ },
115
+ targets: ["react"],
116
+ policy: {
117
+ flags: ["marketplace.reviews.enabled"]
118
+ }
119
+ });
120
+ export {
121
+ ReviewListPresentation,
122
+ ReviewFormPresentation
123
+ };
@@ -0,0 +1,74 @@
1
+ // src/review/review.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var ReviewStatusEnum = defineEnum("ReviewStatus", [
4
+ "PENDING",
5
+ "APPROVED",
6
+ "REJECTED",
7
+ "FLAGGED"
8
+ ]);
9
+
10
+ // src/review/review.schema.ts
11
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
12
+ var ReviewModel = defineSchemaModel({
13
+ name: "ReviewModel",
14
+ description: "A customer review",
15
+ fields: {
16
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
18
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
19
+ authorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
20
+ rating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
21
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
22
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
23
+ status: { type: ReviewStatusEnum, isOptional: false },
24
+ isVerifiedPurchase: { type: ScalarTypeEnum.Boolean(), isOptional: false },
25
+ helpfulCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
26
+ hasResponse: { type: ScalarTypeEnum.Boolean(), isOptional: false },
27
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
28
+ }
29
+ });
30
+ var CreateReviewInputModel = defineSchemaModel({
31
+ name: "CreateReviewInput",
32
+ fields: {
33
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
34
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
35
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
36
+ rating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
37
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
38
+ content: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
39
+ }
40
+ });
41
+ var ListReviewsInputModel = defineSchemaModel({
42
+ name: "ListReviewsInput",
43
+ fields: {
44
+ productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
45
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
46
+ status: { type: ReviewStatusEnum, isOptional: true },
47
+ minRating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
48
+ limit: {
49
+ type: ScalarTypeEnum.Int_unsecure(),
50
+ isOptional: true,
51
+ defaultValue: 20
52
+ },
53
+ offset: {
54
+ type: ScalarTypeEnum.Int_unsecure(),
55
+ isOptional: true,
56
+ defaultValue: 0
57
+ }
58
+ }
59
+ });
60
+ var ListReviewsOutputModel = defineSchemaModel({
61
+ name: "ListReviewsOutput",
62
+ fields: {
63
+ reviews: { type: ReviewModel, isArray: true, isOptional: false },
64
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
65
+ averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
66
+ ratingDistribution: { type: ScalarTypeEnum.JSON(), isOptional: false }
67
+ }
68
+ });
69
+ export {
70
+ ReviewModel,
71
+ ListReviewsOutputModel,
72
+ ListReviewsInputModel,
73
+ CreateReviewInputModel
74
+ };
@@ -0,0 +1,12 @@
1
+ // src/seeders/index.ts
2
+ async function seedMarketplace(params) {
3
+ const { projectId, db } = params;
4
+ const existing = await db.query(`SELECT COUNT(*) as count FROM marketplace_store WHERE "projectId" = $1`, [projectId]);
5
+ if (existing.rows[0]?.count > 0)
6
+ return;
7
+ await db.execute(`INSERT INTO marketplace_store (id, "projectId", "organizationId", name, description, status)
8
+ VALUES ($1, $2, $3, $4, $5, $6)`, ["store_1", projectId, "org_demo", "Demo Store", "A demo store", "ACTIVE"]);
9
+ }
10
+ export {
11
+ seedMarketplace
12
+ };
@@ -0,0 +1,142 @@
1
+ // src/store/store.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var StoreStatusEnum = defineEnum("StoreStatus", [
4
+ "PENDING",
5
+ "ACTIVE",
6
+ "SUSPENDED",
7
+ "CLOSED"
8
+ ]);
9
+
10
+ // src/store/store.schema.ts
11
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
12
+ var StoreModel = defineSchemaModel({
13
+ name: "StoreModel",
14
+ description: "A seller store",
15
+ fields: {
16
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
18
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
19
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
20
+ status: { type: StoreStatusEnum, isOptional: false },
21
+ ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ logoFileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
23
+ isVerified: { type: ScalarTypeEnum.Boolean(), isOptional: false },
24
+ totalProducts: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
25
+ averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
26
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
27
+ }
28
+ });
29
+ var CreateStoreInputModel = defineSchemaModel({
30
+ name: "CreateStoreInput",
31
+ fields: {
32
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
33
+ slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
34
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
35
+ email: { type: ScalarTypeEnum.EmailAddress(), isOptional: true },
36
+ country: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
37
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
38
+ }
39
+ });
40
+
41
+ // src/store/store.operations.ts
42
+ import { defineCommand } from "@contractspec/lib.contracts/operations";
43
+ var OWNERS = ["@example.marketplace"];
44
+ var CreateStoreContract = defineCommand({
45
+ meta: {
46
+ key: "marketplace.store.create",
47
+ version: "1.0.0",
48
+ stability: "stable",
49
+ owners: [...OWNERS],
50
+ tags: ["marketplace", "store", "create"],
51
+ description: "Create a new seller store.",
52
+ goal: "Allow users to become sellers on the marketplace.",
53
+ context: "Seller onboarding."
54
+ },
55
+ io: { input: CreateStoreInputModel, output: StoreModel },
56
+ policy: { auth: "user" },
57
+ sideEffects: {
58
+ emits: [
59
+ {
60
+ key: "marketplace.store.created",
61
+ version: "1.0.0",
62
+ when: "Store is created",
63
+ payload: StoreModel
64
+ }
65
+ ],
66
+ audit: ["marketplace.store.created"]
67
+ },
68
+ acceptance: {
69
+ scenarios: [
70
+ {
71
+ key: "create-store-happy-path",
72
+ given: ["User is authenticated"],
73
+ when: ["User creates a new store"],
74
+ then: ["Store is created", "StoreCreated event is emitted"]
75
+ }
76
+ ],
77
+ examples: [
78
+ {
79
+ key: "create-fashion-store",
80
+ input: { name: "Fashion Boutique", category: "clothing" },
81
+ output: { id: "store-123", status: "active" }
82
+ }
83
+ ]
84
+ }
85
+ });
86
+
87
+ // src/store/store.event.ts
88
+ import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
89
+ import { defineEvent } from "@contractspec/lib.contracts";
90
+ var StoreCreatedPayload = defineSchemaModel2({
91
+ name: "StoreCreatedEventPayload",
92
+ fields: {
93
+ storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
94
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
95
+ slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
96
+ ownerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
97
+ timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
98
+ }
99
+ });
100
+ var StoreStatusChangedPayload = defineSchemaModel2({
101
+ name: "StoreStatusChangedEventPayload",
102
+ fields: {
103
+ storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
104
+ previousStatus: {
105
+ type: ScalarTypeEnum2.String_unsecure(),
106
+ isOptional: false
107
+ },
108
+ newStatus: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
109
+ reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
110
+ timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
111
+ }
112
+ });
113
+ var StoreCreatedEvent = defineEvent({
114
+ meta: {
115
+ key: "marketplace.store.created",
116
+ version: "1.0.0",
117
+ description: "A new seller store has been created.",
118
+ stability: "experimental",
119
+ owners: ["@marketplace-team"],
120
+ tags: ["marketplace", "store"]
121
+ },
122
+ payload: StoreCreatedPayload
123
+ });
124
+ var StoreStatusChangedEvent = defineEvent({
125
+ meta: {
126
+ key: "marketplace.store.statusChanged",
127
+ version: "1.0.0",
128
+ description: "A store status has changed.",
129
+ stability: "experimental",
130
+ owners: ["@marketplace-team"],
131
+ tags: ["marketplace", "store"]
132
+ },
133
+ payload: StoreStatusChangedPayload
134
+ });
135
+ export {
136
+ StoreStatusEnum,
137
+ StoreStatusChangedEvent,
138
+ StoreModel,
139
+ StoreCreatedEvent,
140
+ CreateStoreInputModel,
141
+ CreateStoreContract
142
+ };
@@ -0,0 +1,11 @@
1
+ // src/store/store.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var StoreStatusEnum = defineEnum("StoreStatus", [
4
+ "PENDING",
5
+ "ACTIVE",
6
+ "SUSPENDED",
7
+ "CLOSED"
8
+ ]);
9
+ export {
10
+ StoreStatusEnum
11
+ };
@@ -0,0 +1,52 @@
1
+ // src/store/store.event.ts
2
+ import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
3
+ import { defineEvent } from "@contractspec/lib.contracts";
4
+ var StoreCreatedPayload = defineSchemaModel({
5
+ name: "StoreCreatedEventPayload",
6
+ fields: {
7
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
8
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
9
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
+ ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
12
+ }
13
+ });
14
+ var StoreStatusChangedPayload = defineSchemaModel({
15
+ name: "StoreStatusChangedEventPayload",
16
+ fields: {
17
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
18
+ previousStatus: {
19
+ type: ScalarTypeEnum.String_unsecure(),
20
+ isOptional: false
21
+ },
22
+ newStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
+ reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
24
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
25
+ }
26
+ });
27
+ var StoreCreatedEvent = defineEvent({
28
+ meta: {
29
+ key: "marketplace.store.created",
30
+ version: "1.0.0",
31
+ description: "A new seller store has been created.",
32
+ stability: "experimental",
33
+ owners: ["@marketplace-team"],
34
+ tags: ["marketplace", "store"]
35
+ },
36
+ payload: StoreCreatedPayload
37
+ });
38
+ var StoreStatusChangedEvent = defineEvent({
39
+ meta: {
40
+ key: "marketplace.store.statusChanged",
41
+ version: "1.0.0",
42
+ description: "A store status has changed.",
43
+ stability: "experimental",
44
+ owners: ["@marketplace-team"],
45
+ tags: ["marketplace", "store"]
46
+ },
47
+ payload: StoreStatusChangedPayload
48
+ });
49
+ export {
50
+ StoreStatusChangedEvent,
51
+ StoreCreatedEvent
52
+ };
@@ -0,0 +1,88 @@
1
+ // src/store/store.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var StoreStatusEnum = defineEnum("StoreStatus", [
4
+ "PENDING",
5
+ "ACTIVE",
6
+ "SUSPENDED",
7
+ "CLOSED"
8
+ ]);
9
+
10
+ // src/store/store.schema.ts
11
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
12
+ var StoreModel = defineSchemaModel({
13
+ name: "StoreModel",
14
+ description: "A seller store",
15
+ fields: {
16
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
18
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
19
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
20
+ status: { type: StoreStatusEnum, isOptional: false },
21
+ ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ logoFileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
23
+ isVerified: { type: ScalarTypeEnum.Boolean(), isOptional: false },
24
+ totalProducts: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
25
+ averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
26
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
27
+ }
28
+ });
29
+ var CreateStoreInputModel = defineSchemaModel({
30
+ name: "CreateStoreInput",
31
+ fields: {
32
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
33
+ slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
34
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
35
+ email: { type: ScalarTypeEnum.EmailAddress(), isOptional: true },
36
+ country: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
37
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
38
+ }
39
+ });
40
+
41
+ // src/store/store.operations.ts
42
+ import { defineCommand } from "@contractspec/lib.contracts/operations";
43
+ var OWNERS = ["@example.marketplace"];
44
+ var CreateStoreContract = defineCommand({
45
+ meta: {
46
+ key: "marketplace.store.create",
47
+ version: "1.0.0",
48
+ stability: "stable",
49
+ owners: [...OWNERS],
50
+ tags: ["marketplace", "store", "create"],
51
+ description: "Create a new seller store.",
52
+ goal: "Allow users to become sellers on the marketplace.",
53
+ context: "Seller onboarding."
54
+ },
55
+ io: { input: CreateStoreInputModel, output: StoreModel },
56
+ policy: { auth: "user" },
57
+ sideEffects: {
58
+ emits: [
59
+ {
60
+ key: "marketplace.store.created",
61
+ version: "1.0.0",
62
+ when: "Store is created",
63
+ payload: StoreModel
64
+ }
65
+ ],
66
+ audit: ["marketplace.store.created"]
67
+ },
68
+ acceptance: {
69
+ scenarios: [
70
+ {
71
+ key: "create-store-happy-path",
72
+ given: ["User is authenticated"],
73
+ when: ["User creates a new store"],
74
+ then: ["Store is created", "StoreCreated event is emitted"]
75
+ }
76
+ ],
77
+ examples: [
78
+ {
79
+ key: "create-fashion-store",
80
+ input: { name: "Fashion Boutique", category: "clothing" },
81
+ output: { id: "store-123", status: "active" }
82
+ }
83
+ ]
84
+ }
85
+ });
86
+ export {
87
+ CreateStoreContract
88
+ };