@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.
- package/dist/browser/docs/index.js +103 -0
- package/dist/browser/docs/marketplace.docblock.js +103 -0
- package/dist/browser/entities/index.js +721 -0
- package/dist/browser/entities/order.js +167 -0
- package/dist/browser/entities/payout.js +142 -0
- package/dist/browser/entities/product.js +152 -0
- package/dist/browser/entities/review.js +129 -0
- package/dist/browser/entities/store.js +97 -0
- package/dist/browser/example.js +42 -0
- package/dist/browser/handlers/index.js +303 -0
- package/dist/browser/handlers/marketplace.handlers.js +303 -0
- package/dist/browser/index.js +2016 -0
- package/dist/browser/marketplace.capability.js +40 -0
- package/dist/browser/marketplace.feature.js +137 -0
- package/dist/browser/order/index.js +307 -0
- package/dist/browser/order/order.enum.js +17 -0
- package/dist/browser/order/order.event.js +131 -0
- package/dist/browser/order/order.operations.js +172 -0
- package/dist/browser/order/order.presentation.js +153 -0
- package/dist/browser/order/order.schema.js +79 -0
- package/dist/browser/payout/index.js +152 -0
- package/dist/browser/payout/payout.enum.js +12 -0
- package/dist/browser/payout/payout.event.js +55 -0
- package/dist/browser/payout/payout.operations.js +94 -0
- package/dist/browser/payout/payout.presentation.js +111 -0
- package/dist/browser/payout/payout.schema.js +61 -0
- package/dist/browser/product/index.js +249 -0
- package/dist/browser/product/product.enum.js +13 -0
- package/dist/browser/product/product.event.js +74 -0
- package/dist/browser/product/product.operations.js +171 -0
- package/dist/browser/product/product.presentation.js +158 -0
- package/dist/browser/product/product.schema.js +84 -0
- package/dist/browser/review/index.js +206 -0
- package/dist/browser/review/review.enum.js +11 -0
- package/dist/browser/review/review.event.js +50 -0
- package/dist/browser/review/review.operations.js +152 -0
- package/dist/browser/review/review.presentation.js +123 -0
- package/dist/browser/review/review.schema.js +74 -0
- package/dist/browser/seeders/index.js +12 -0
- package/dist/browser/store/index.js +142 -0
- package/dist/browser/store/store.enum.js +11 -0
- package/dist/browser/store/store.event.js +52 -0
- package/dist/browser/store/store.operations.js +88 -0
- package/dist/browser/store/store.presentation.js +94 -0
- package/dist/browser/store/store.schema.js +43 -0
- package/dist/browser/tests/operations.test-spec.js +139 -0
- package/dist/browser/ui/MarketplaceDashboard.js +418 -0
- package/dist/browser/ui/hooks/index.js +59 -0
- package/dist/browser/ui/hooks/useMarketplaceData.js +56 -0
- package/dist/browser/ui/index.js +668 -0
- package/dist/browser/ui/renderers/index.js +248 -0
- package/dist/browser/ui/renderers/marketplace.markdown.js +248 -0
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +104 -1
- package/dist/docs/marketplace.docblock.d.ts +2 -1
- package/dist/docs/marketplace.docblock.d.ts.map +1 -0
- package/dist/docs/marketplace.docblock.js +46 -57
- package/dist/entities/index.d.ts +302 -307
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +719 -43
- package/dist/entities/order.d.ts +77 -82
- package/dist/entities/order.d.ts.map +1 -1
- package/dist/entities/order.js +162 -167
- package/dist/entities/payout.d.ts +64 -69
- package/dist/entities/payout.d.ts.map +1 -1
- package/dist/entities/payout.js +137 -156
- package/dist/entities/product.d.ts +69 -74
- package/dist/entities/product.d.ts.map +1 -1
- package/dist/entities/product.js +148 -156
- package/dist/entities/review.d.ts +55 -60
- package/dist/entities/review.d.ts.map +1 -1
- package/dist/entities/review.js +124 -146
- package/dist/entities/store.d.ts +40 -45
- package/dist/entities/store.d.ts.map +1 -1
- package/dist/entities/store.js +94 -106
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +40 -55
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +304 -3
- package/dist/handlers/marketplace.handlers.d.ts +138 -138
- package/dist/handlers/marketplace.handlers.d.ts.map +1 -1
- package/dist/handlers/marketplace.handlers.js +284 -309
- package/dist/index.d.ts +13 -31
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2017 -32
- package/dist/marketplace.capability.d.ts +3 -8
- package/dist/marketplace.capability.d.ts.map +1 -1
- package/dist/marketplace.capability.js +41 -34
- package/dist/marketplace.feature.d.ts +1 -7
- package/dist/marketplace.feature.d.ts.map +1 -1
- package/dist/marketplace.feature.js +136 -313
- package/dist/node/docs/index.js +103 -0
- package/dist/node/docs/marketplace.docblock.js +103 -0
- package/dist/node/entities/index.js +721 -0
- package/dist/node/entities/order.js +167 -0
- package/dist/node/entities/payout.js +142 -0
- package/dist/node/entities/product.js +152 -0
- package/dist/node/entities/review.js +129 -0
- package/dist/node/entities/store.js +97 -0
- package/dist/node/example.js +42 -0
- package/dist/node/handlers/index.js +303 -0
- package/dist/node/handlers/marketplace.handlers.js +303 -0
- package/dist/node/index.js +2016 -0
- package/dist/node/marketplace.capability.js +40 -0
- package/dist/node/marketplace.feature.js +137 -0
- package/dist/node/order/index.js +307 -0
- package/dist/node/order/order.enum.js +17 -0
- package/dist/node/order/order.event.js +131 -0
- package/dist/node/order/order.operations.js +172 -0
- package/dist/node/order/order.presentation.js +153 -0
- package/dist/node/order/order.schema.js +79 -0
- package/dist/node/payout/index.js +152 -0
- package/dist/node/payout/payout.enum.js +12 -0
- package/dist/node/payout/payout.event.js +55 -0
- package/dist/node/payout/payout.operations.js +94 -0
- package/dist/node/payout/payout.presentation.js +111 -0
- package/dist/node/payout/payout.schema.js +61 -0
- package/dist/node/product/index.js +249 -0
- package/dist/node/product/product.enum.js +13 -0
- package/dist/node/product/product.event.js +74 -0
- package/dist/node/product/product.operations.js +171 -0
- package/dist/node/product/product.presentation.js +158 -0
- package/dist/node/product/product.schema.js +84 -0
- package/dist/node/review/index.js +206 -0
- package/dist/node/review/review.enum.js +11 -0
- package/dist/node/review/review.event.js +50 -0
- package/dist/node/review/review.operations.js +152 -0
- package/dist/node/review/review.presentation.js +123 -0
- package/dist/node/review/review.schema.js +74 -0
- package/dist/node/seeders/index.js +12 -0
- package/dist/node/store/index.js +142 -0
- package/dist/node/store/store.enum.js +11 -0
- package/dist/node/store/store.event.js +52 -0
- package/dist/node/store/store.operations.js +88 -0
- package/dist/node/store/store.presentation.js +94 -0
- package/dist/node/store/store.schema.js +43 -0
- package/dist/node/tests/operations.test-spec.js +139 -0
- package/dist/node/ui/MarketplaceDashboard.js +418 -0
- package/dist/node/ui/hooks/index.js +59 -0
- package/dist/node/ui/hooks/useMarketplaceData.js +56 -0
- package/dist/node/ui/index.js +668 -0
- package/dist/node/ui/renderers/index.js +248 -0
- package/dist/node/ui/renderers/marketplace.markdown.js +248 -0
- package/dist/order/index.d.ts +8 -5
- package/dist/order/index.d.ts.map +1 -0
- package/dist/order/index.js +307 -5
- package/dist/order/order.enum.d.ts +1 -6
- package/dist/order/order.enum.d.ts.map +1 -1
- package/dist/order/order.enum.js +16 -20
- package/dist/order/order.event.d.ts +133 -139
- package/dist/order/order.event.d.ts.map +1 -1
- package/dist/order/order.event.js +121 -205
- package/dist/order/order.operations.d.ts +291 -297
- package/dist/order/order.operations.d.ts.map +1 -1
- package/dist/order/order.operations.js +169 -115
- package/dist/order/order.presentation.d.ts +3 -8
- package/dist/order/order.presentation.d.ts.map +1 -1
- package/dist/order/order.presentation.js +149 -81
- package/dist/order/order.schema.d.ts +143 -148
- package/dist/order/order.schema.d.ts.map +1 -1
- package/dist/order/order.schema.js +75 -150
- package/dist/payout/index.d.ts +8 -5
- package/dist/payout/index.d.ts.map +1 -0
- package/dist/payout/index.js +152 -5
- package/dist/payout/payout.enum.d.ts +1 -6
- package/dist/payout/payout.enum.d.ts.map +1 -1
- package/dist/payout/payout.enum.js +11 -15
- package/dist/payout/payout.event.d.ts +54 -60
- package/dist/payout/payout.event.d.ts.map +1 -1
- package/dist/payout/payout.event.js +51 -87
- package/dist/payout/payout.operations.d.ts +82 -88
- package/dist/payout/payout.operations.d.ts.map +1 -1
- package/dist/payout/payout.operations.js +92 -50
- package/dist/payout/payout.presentation.d.ts +2 -7
- package/dist/payout/payout.presentation.d.ts.map +1 -1
- package/dist/payout/payout.presentation.js +108 -56
- package/dist/payout/payout.schema.d.ts +139 -144
- package/dist/payout/payout.schema.d.ts.map +1 -1
- package/dist/payout/payout.schema.js +58 -112
- package/dist/product/index.d.ts +8 -5
- package/dist/product/index.d.ts.map +1 -0
- package/dist/product/index.js +249 -5
- package/dist/product/product.enum.d.ts +1 -6
- package/dist/product/product.enum.d.ts.map +1 -1
- package/dist/product/product.enum.js +12 -16
- package/dist/product/product.event.d.ts +63 -69
- package/dist/product/product.event.d.ts.map +1 -1
- package/dist/product/product.event.js +68 -113
- package/dist/product/product.operations.d.ts +225 -231
- package/dist/product/product.operations.d.ts.map +1 -1
- package/dist/product/product.operations.js +168 -104
- package/dist/product/product.presentation.d.ts +3 -8
- package/dist/product/product.presentation.d.ts.map +1 -1
- package/dist/product/product.presentation.js +154 -81
- package/dist/product/product.schema.d.ts +196 -201
- package/dist/product/product.schema.d.ts.map +1 -1
- package/dist/product/product.schema.js +80 -171
- package/dist/review/index.d.ts +8 -5
- package/dist/review/index.d.ts.map +1 -0
- package/dist/review/index.js +206 -5
- package/dist/review/review.enum.d.ts +1 -6
- package/dist/review/review.enum.d.ts.map +1 -1
- package/dist/review/review.enum.js +10 -14
- package/dist/review/review.event.d.ts +46 -52
- package/dist/review/review.event.d.ts.map +1 -1
- package/dist/review/review.event.js +46 -79
- package/dist/review/review.operations.d.ts +190 -196
- package/dist/review/review.operations.d.ts.map +1 -1
- package/dist/review/review.operations.js +149 -102
- package/dist/review/review.presentation.d.ts +2 -7
- package/dist/review/review.presentation.d.ts.map +1 -1
- package/dist/review/review.presentation.js +120 -56
- package/dist/review/review.schema.d.ts +164 -169
- package/dist/review/review.schema.d.ts.map +1 -1
- package/dist/review/review.schema.js +70 -151
- package/dist/seeders/index.d.ts +4 -8
- package/dist/seeders/index.d.ts.map +1 -1
- package/dist/seeders/index.js +11 -16
- package/dist/store/index.d.ts +8 -5
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +142 -5
- package/dist/store/store.enum.d.ts +1 -6
- package/dist/store/store.enum.d.ts.map +1 -1
- package/dist/store/store.enum.js +10 -14
- package/dist/store/store.event.d.ts +42 -48
- package/dist/store/store.event.d.ts.map +1 -1
- package/dist/store/store.event.js +48 -75
- package/dist/store/store.operations.d.ts +98 -104
- package/dist/store/store.operations.d.ts.map +1 -1
- package/dist/store/store.operations.js +86 -58
- package/dist/store/store.presentation.d.ts +2 -7
- package/dist/store/store.presentation.d.ts.map +1 -1
- package/dist/store/store.presentation.js +91 -56
- package/dist/store/store.schema.d.ts +70 -75
- package/dist/store/store.schema.d.ts.map +1 -1
- package/dist/store/store.schema.js +41 -90
- package/dist/tests/operations.test-spec.d.ts +5 -10
- package/dist/tests/operations.test-spec.d.ts.map +1 -1
- package/dist/tests/operations.test-spec.js +134 -146
- package/dist/ui/MarketplaceDashboard.d.ts +1 -6
- package/dist/ui/MarketplaceDashboard.d.ts.map +1 -1
- package/dist/ui/MarketplaceDashboard.js +413 -313
- package/dist/ui/hooks/index.d.ts +2 -2
- package/dist/ui/hooks/index.d.ts.map +1 -0
- package/dist/ui/hooks/index.js +59 -4
- package/dist/ui/hooks/useMarketplaceData.d.ts +16 -20
- package/dist/ui/hooks/useMarketplaceData.d.ts.map +1 -1
- package/dist/ui/hooks/useMarketplaceData.js +53 -60
- package/dist/ui/index.d.ts +7 -6
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +668 -5
- package/dist/ui/renderers/index.d.ts +2 -2
- package/dist/ui/renderers/index.d.ts.map +1 -0
- package/dist/ui/renderers/index.js +249 -3
- package/dist/ui/renderers/marketplace.markdown.d.ts +13 -15
- package/dist/ui/renderers/marketplace.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/marketplace.markdown.js +241 -236
- package/package.json +529 -110
- package/dist/docs/marketplace.docblock.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/entities/order.js.map +0 -1
- package/dist/entities/payout.js.map +0 -1
- package/dist/entities/product.js.map +0 -1
- package/dist/entities/review.js.map +0 -1
- package/dist/entities/store.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/marketplace.handlers.js.map +0 -1
- package/dist/marketplace.capability.js.map +0 -1
- package/dist/marketplace.feature.js.map +0 -1
- package/dist/order/order.enum.js.map +0 -1
- package/dist/order/order.event.js.map +0 -1
- package/dist/order/order.operations.js.map +0 -1
- package/dist/order/order.presentation.js.map +0 -1
- package/dist/order/order.schema.js.map +0 -1
- package/dist/payout/payout.enum.js.map +0 -1
- package/dist/payout/payout.event.js.map +0 -1
- package/dist/payout/payout.operations.js.map +0 -1
- package/dist/payout/payout.presentation.js.map +0 -1
- package/dist/payout/payout.schema.js.map +0 -1
- package/dist/product/product.enum.js.map +0 -1
- package/dist/product/product.event.js.map +0 -1
- package/dist/product/product.operations.js.map +0 -1
- package/dist/product/product.presentation.js.map +0 -1
- package/dist/product/product.schema.js.map +0 -1
- package/dist/review/review.enum.js.map +0 -1
- package/dist/review/review.event.js.map +0 -1
- package/dist/review/review.operations.js.map +0 -1
- package/dist/review/review.presentation.js.map +0 -1
- package/dist/review/review.schema.js.map +0 -1
- package/dist/seeders/index.js.map +0 -1
- package/dist/store/store.enum.js.map +0 -1
- package/dist/store/store.event.js.map +0 -1
- package/dist/store/store.operations.js.map +0 -1
- package/dist/store/store.presentation.js.map +0 -1
- package/dist/store/store.schema.js.map +0 -1
- package/dist/tests/operations.test-spec.js.map +0 -1
- package/dist/ui/MarketplaceDashboard.js.map +0 -1
- package/dist/ui/hooks/useMarketplaceData.js.map +0 -1
- package/dist/ui/renderers/marketplace.markdown.js.map +0 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// src/product/product.enum.ts
|
|
2
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var ProductStatusEnum = defineEnum("ProductStatus", [
|
|
4
|
+
"DRAFT",
|
|
5
|
+
"PENDING_REVIEW",
|
|
6
|
+
"ACTIVE",
|
|
7
|
+
"OUT_OF_STOCK",
|
|
8
|
+
"DISCONTINUED",
|
|
9
|
+
"REJECTED"
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
// src/product/product.schema.ts
|
|
13
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
14
|
+
var ProductModel = defineSchemaModel({
|
|
15
|
+
name: "ProductModel",
|
|
16
|
+
description: "A product listing",
|
|
17
|
+
fields: {
|
|
18
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
19
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
20
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
23
|
+
status: { type: ProductStatusEnum, isOptional: false },
|
|
24
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
25
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
26
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
27
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
28
|
+
primaryImageId: {
|
|
29
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
30
|
+
isOptional: true
|
|
31
|
+
},
|
|
32
|
+
averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
33
|
+
totalSold: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
34
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var CreateProductInputModel = defineSchemaModel({
|
|
38
|
+
name: "CreateProductInput",
|
|
39
|
+
fields: {
|
|
40
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
41
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
42
|
+
slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
43
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
44
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
45
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
46
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
47
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
48
|
+
sku: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
var ListProductsInputModel = defineSchemaModel({
|
|
52
|
+
name: "ListProductsInput",
|
|
53
|
+
fields: {
|
|
54
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
55
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
56
|
+
status: { type: ProductStatusEnum, isOptional: true },
|
|
57
|
+
search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
58
|
+
minPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
59
|
+
maxPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
60
|
+
limit: {
|
|
61
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
62
|
+
isOptional: true,
|
|
63
|
+
defaultValue: 20
|
|
64
|
+
},
|
|
65
|
+
offset: {
|
|
66
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
67
|
+
isOptional: true,
|
|
68
|
+
defaultValue: 0
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var ListProductsOutputModel = defineSchemaModel({
|
|
73
|
+
name: "ListProductsOutput",
|
|
74
|
+
fields: {
|
|
75
|
+
products: { type: ProductModel, isArray: true, isOptional: false },
|
|
76
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// src/product/product.operations.ts
|
|
81
|
+
import {
|
|
82
|
+
defineCommand,
|
|
83
|
+
defineQuery
|
|
84
|
+
} from "@contractspec/lib.contracts/operations";
|
|
85
|
+
var OWNERS = ["@example.marketplace"];
|
|
86
|
+
var CreateProductContract = defineCommand({
|
|
87
|
+
meta: {
|
|
88
|
+
key: "marketplace.product.create",
|
|
89
|
+
version: "1.0.0",
|
|
90
|
+
stability: "stable",
|
|
91
|
+
owners: [...OWNERS],
|
|
92
|
+
tags: ["marketplace", "product", "create"],
|
|
93
|
+
description: "Create a new product listing.",
|
|
94
|
+
goal: "Allow sellers to list products.",
|
|
95
|
+
context: "Product management."
|
|
96
|
+
},
|
|
97
|
+
io: { input: CreateProductInputModel, output: ProductModel },
|
|
98
|
+
policy: { auth: "user" },
|
|
99
|
+
sideEffects: {
|
|
100
|
+
emits: [
|
|
101
|
+
{
|
|
102
|
+
key: "marketplace.product.created",
|
|
103
|
+
version: "1.0.0",
|
|
104
|
+
when: "Product is created",
|
|
105
|
+
payload: ProductModel
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
audit: ["marketplace.product.created"]
|
|
109
|
+
},
|
|
110
|
+
acceptance: {
|
|
111
|
+
scenarios: [
|
|
112
|
+
{
|
|
113
|
+
key: "create-product-happy-path",
|
|
114
|
+
given: ["User is a seller"],
|
|
115
|
+
when: ["User creates a product listing"],
|
|
116
|
+
then: ["Product is created", "ProductCreated event is emitted"]
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
examples: [
|
|
120
|
+
{
|
|
121
|
+
key: "create-t-shirt",
|
|
122
|
+
input: {
|
|
123
|
+
title: "Classic T-Shirt",
|
|
124
|
+
price: 25,
|
|
125
|
+
stock: 100,
|
|
126
|
+
storeId: "store-123"
|
|
127
|
+
},
|
|
128
|
+
output: {
|
|
129
|
+
id: "prod-456",
|
|
130
|
+
title: "Classic T-Shirt",
|
|
131
|
+
status: "published"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
var ListProductsContract = defineQuery({
|
|
138
|
+
meta: {
|
|
139
|
+
key: "marketplace.product.list",
|
|
140
|
+
version: "1.0.0",
|
|
141
|
+
stability: "stable",
|
|
142
|
+
owners: [...OWNERS],
|
|
143
|
+
tags: ["marketplace", "product", "list"],
|
|
144
|
+
description: "List products with filters.",
|
|
145
|
+
goal: "Browse products on the marketplace.",
|
|
146
|
+
context: "Product catalog, search."
|
|
147
|
+
},
|
|
148
|
+
io: { input: ListProductsInputModel, output: ListProductsOutputModel },
|
|
149
|
+
policy: { auth: "anonymous" },
|
|
150
|
+
acceptance: {
|
|
151
|
+
scenarios: [
|
|
152
|
+
{
|
|
153
|
+
key: "list-products-happy-path",
|
|
154
|
+
given: ["Products exist"],
|
|
155
|
+
when: ["User searches for products"],
|
|
156
|
+
then: ["List of products is returned"]
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
examples: [
|
|
160
|
+
{
|
|
161
|
+
key: "search-t-shirts",
|
|
162
|
+
input: { search: "t-shirt", limit: 20 },
|
|
163
|
+
output: { items: [], total: 50, hasMore: true }
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
export {
|
|
169
|
+
ListProductsContract,
|
|
170
|
+
CreateProductContract
|
|
171
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// src/product/product.enum.ts
|
|
2
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var ProductStatusEnum = defineEnum("ProductStatus", [
|
|
4
|
+
"DRAFT",
|
|
5
|
+
"PENDING_REVIEW",
|
|
6
|
+
"ACTIVE",
|
|
7
|
+
"OUT_OF_STOCK",
|
|
8
|
+
"DISCONTINUED",
|
|
9
|
+
"REJECTED"
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
// src/product/product.schema.ts
|
|
13
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
14
|
+
var ProductModel = defineSchemaModel({
|
|
15
|
+
name: "ProductModel",
|
|
16
|
+
description: "A product listing",
|
|
17
|
+
fields: {
|
|
18
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
19
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
20
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
23
|
+
status: { type: ProductStatusEnum, isOptional: false },
|
|
24
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
25
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
26
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
27
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
28
|
+
primaryImageId: {
|
|
29
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
30
|
+
isOptional: true
|
|
31
|
+
},
|
|
32
|
+
averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
33
|
+
totalSold: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
34
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var CreateProductInputModel = defineSchemaModel({
|
|
38
|
+
name: "CreateProductInput",
|
|
39
|
+
fields: {
|
|
40
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
41
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
42
|
+
slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
43
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
44
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
45
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
46
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
47
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
48
|
+
sku: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
var ListProductsInputModel = defineSchemaModel({
|
|
52
|
+
name: "ListProductsInput",
|
|
53
|
+
fields: {
|
|
54
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
55
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
56
|
+
status: { type: ProductStatusEnum, isOptional: true },
|
|
57
|
+
search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
58
|
+
minPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
59
|
+
maxPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
60
|
+
limit: {
|
|
61
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
62
|
+
isOptional: true,
|
|
63
|
+
defaultValue: 20
|
|
64
|
+
},
|
|
65
|
+
offset: {
|
|
66
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
67
|
+
isOptional: true,
|
|
68
|
+
defaultValue: 0
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var ListProductsOutputModel = defineSchemaModel({
|
|
73
|
+
name: "ListProductsOutput",
|
|
74
|
+
fields: {
|
|
75
|
+
products: { type: ProductModel, isArray: true, isOptional: false },
|
|
76
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// src/product/product.presentation.ts
|
|
81
|
+
import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
|
|
82
|
+
var ProductCatalogPresentation = definePresentation({
|
|
83
|
+
meta: {
|
|
84
|
+
key: "marketplace.product.catalog",
|
|
85
|
+
version: "1.0.0",
|
|
86
|
+
title: "Product Catalog",
|
|
87
|
+
description: "Product catalog with search and filters",
|
|
88
|
+
domain: "marketplace",
|
|
89
|
+
owners: ["@marketplace-team"],
|
|
90
|
+
tags: ["marketplace", "product", "catalog"],
|
|
91
|
+
stability: StabilityEnum.Experimental,
|
|
92
|
+
goal: "Enable users to browse and search for products.",
|
|
93
|
+
context: "The primary shopping interface."
|
|
94
|
+
},
|
|
95
|
+
source: {
|
|
96
|
+
type: "component",
|
|
97
|
+
framework: "react",
|
|
98
|
+
componentKey: "ProductCatalog",
|
|
99
|
+
props: ProductModel
|
|
100
|
+
},
|
|
101
|
+
targets: ["react", "markdown"],
|
|
102
|
+
policy: {
|
|
103
|
+
flags: ["marketplace.products.enabled"]
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
var ProductDetailPresentation = definePresentation({
|
|
107
|
+
meta: {
|
|
108
|
+
key: "marketplace.product.detail",
|
|
109
|
+
version: "1.0.0",
|
|
110
|
+
title: "Product Details",
|
|
111
|
+
description: "Product detail page with images and reviews",
|
|
112
|
+
domain: "marketplace",
|
|
113
|
+
owners: ["@marketplace-team"],
|
|
114
|
+
tags: ["marketplace", "product", "detail"],
|
|
115
|
+
stability: StabilityEnum.Experimental,
|
|
116
|
+
goal: "Provide comprehensive information about a specific product.",
|
|
117
|
+
context: "Product showcase including images, descriptions, and ratings."
|
|
118
|
+
},
|
|
119
|
+
source: {
|
|
120
|
+
type: "component",
|
|
121
|
+
framework: "react",
|
|
122
|
+
componentKey: "ProductDetail",
|
|
123
|
+
props: ProductModel
|
|
124
|
+
},
|
|
125
|
+
targets: ["react", "markdown"],
|
|
126
|
+
policy: {
|
|
127
|
+
flags: ["marketplace.products.enabled"]
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
var ProductEditorPresentation = definePresentation({
|
|
131
|
+
meta: {
|
|
132
|
+
key: "marketplace.product.editor",
|
|
133
|
+
version: "1.0.0",
|
|
134
|
+
title: "Product Editor",
|
|
135
|
+
description: "Product editor for sellers",
|
|
136
|
+
domain: "marketplace",
|
|
137
|
+
owners: ["@marketplace-team"],
|
|
138
|
+
tags: ["marketplace", "product", "editor"],
|
|
139
|
+
stability: StabilityEnum.Experimental,
|
|
140
|
+
goal: "Allow sellers to create and modify product listings.",
|
|
141
|
+
context: "Management tool for store owners."
|
|
142
|
+
},
|
|
143
|
+
source: {
|
|
144
|
+
type: "component",
|
|
145
|
+
framework: "react",
|
|
146
|
+
componentKey: "ProductEditor",
|
|
147
|
+
props: ProductModel
|
|
148
|
+
},
|
|
149
|
+
targets: ["react"],
|
|
150
|
+
policy: {
|
|
151
|
+
flags: ["marketplace.seller.enabled"]
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
export {
|
|
155
|
+
ProductEditorPresentation,
|
|
156
|
+
ProductDetailPresentation,
|
|
157
|
+
ProductCatalogPresentation
|
|
158
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// src/product/product.enum.ts
|
|
2
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var ProductStatusEnum = defineEnum("ProductStatus", [
|
|
4
|
+
"DRAFT",
|
|
5
|
+
"PENDING_REVIEW",
|
|
6
|
+
"ACTIVE",
|
|
7
|
+
"OUT_OF_STOCK",
|
|
8
|
+
"DISCONTINUED",
|
|
9
|
+
"REJECTED"
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
// src/product/product.schema.ts
|
|
13
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
14
|
+
var ProductModel = defineSchemaModel({
|
|
15
|
+
name: "ProductModel",
|
|
16
|
+
description: "A product listing",
|
|
17
|
+
fields: {
|
|
18
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
19
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
20
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
23
|
+
status: { type: ProductStatusEnum, isOptional: false },
|
|
24
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
25
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
26
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
27
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
28
|
+
primaryImageId: {
|
|
29
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
30
|
+
isOptional: true
|
|
31
|
+
},
|
|
32
|
+
averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
33
|
+
totalSold: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
34
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var CreateProductInputModel = defineSchemaModel({
|
|
38
|
+
name: "CreateProductInput",
|
|
39
|
+
fields: {
|
|
40
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
41
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
42
|
+
slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
43
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
44
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
45
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
46
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
47
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
48
|
+
sku: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
var ListProductsInputModel = defineSchemaModel({
|
|
52
|
+
name: "ListProductsInput",
|
|
53
|
+
fields: {
|
|
54
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
55
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
56
|
+
status: { type: ProductStatusEnum, isOptional: true },
|
|
57
|
+
search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
58
|
+
minPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
59
|
+
maxPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
60
|
+
limit: {
|
|
61
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
62
|
+
isOptional: true,
|
|
63
|
+
defaultValue: 20
|
|
64
|
+
},
|
|
65
|
+
offset: {
|
|
66
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
67
|
+
isOptional: true,
|
|
68
|
+
defaultValue: 0
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var ListProductsOutputModel = defineSchemaModel({
|
|
73
|
+
name: "ListProductsOutput",
|
|
74
|
+
fields: {
|
|
75
|
+
products: { type: ProductModel, isArray: true, isOptional: false },
|
|
76
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
export {
|
|
80
|
+
ProductModel,
|
|
81
|
+
ListProductsOutputModel,
|
|
82
|
+
ListProductsInputModel,
|
|
83
|
+
CreateProductInputModel
|
|
84
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
|
|
150
|
+
// src/review/review.event.ts
|
|
151
|
+
import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
|
|
152
|
+
import { defineEvent } from "@contractspec/lib.contracts";
|
|
153
|
+
var ReviewCreatedPayload = defineSchemaModel2({
|
|
154
|
+
name: "ReviewCreatedEventPayload",
|
|
155
|
+
fields: {
|
|
156
|
+
reviewId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
157
|
+
productId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
158
|
+
storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
159
|
+
authorId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
160
|
+
rating: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
|
|
161
|
+
isVerifiedPurchase: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
|
|
162
|
+
timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
var ReviewRespondedPayload = defineSchemaModel2({
|
|
166
|
+
name: "ReviewRespondedEventPayload",
|
|
167
|
+
fields: {
|
|
168
|
+
reviewId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
169
|
+
responseId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
170
|
+
authorId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
171
|
+
timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
var ReviewCreatedEvent = defineEvent({
|
|
175
|
+
meta: {
|
|
176
|
+
key: "marketplace.review.created",
|
|
177
|
+
version: "1.0.0",
|
|
178
|
+
description: "A review has been created.",
|
|
179
|
+
stability: "experimental",
|
|
180
|
+
owners: ["@marketplace-team"],
|
|
181
|
+
tags: ["marketplace", "review"]
|
|
182
|
+
},
|
|
183
|
+
payload: ReviewCreatedPayload
|
|
184
|
+
});
|
|
185
|
+
var ReviewRespondedEvent = defineEvent({
|
|
186
|
+
meta: {
|
|
187
|
+
key: "marketplace.review.responded",
|
|
188
|
+
version: "1.0.0",
|
|
189
|
+
description: "A seller has responded to a review.",
|
|
190
|
+
stability: "experimental",
|
|
191
|
+
owners: ["@marketplace-team"],
|
|
192
|
+
tags: ["marketplace", "review"]
|
|
193
|
+
},
|
|
194
|
+
payload: ReviewRespondedPayload
|
|
195
|
+
});
|
|
196
|
+
export {
|
|
197
|
+
ReviewStatusEnum,
|
|
198
|
+
ReviewRespondedEvent,
|
|
199
|
+
ReviewModel,
|
|
200
|
+
ReviewCreatedEvent,
|
|
201
|
+
ListReviewsOutputModel,
|
|
202
|
+
ListReviewsInputModel,
|
|
203
|
+
ListReviewsContract,
|
|
204
|
+
CreateReviewInputModel,
|
|
205
|
+
CreateReviewContract
|
|
206
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/review/review.event.ts
|
|
2
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
3
|
+
import { defineEvent } from "@contractspec/lib.contracts";
|
|
4
|
+
var ReviewCreatedPayload = defineSchemaModel({
|
|
5
|
+
name: "ReviewCreatedEventPayload",
|
|
6
|
+
fields: {
|
|
7
|
+
reviewId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
8
|
+
productId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
9
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
10
|
+
authorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
+
rating: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
12
|
+
isVerifiedPurchase: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
13
|
+
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
var ReviewRespondedPayload = defineSchemaModel({
|
|
17
|
+
name: "ReviewRespondedEventPayload",
|
|
18
|
+
fields: {
|
|
19
|
+
reviewId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
20
|
+
responseId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
authorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var ReviewCreatedEvent = defineEvent({
|
|
26
|
+
meta: {
|
|
27
|
+
key: "marketplace.review.created",
|
|
28
|
+
version: "1.0.0",
|
|
29
|
+
description: "A review has been created.",
|
|
30
|
+
stability: "experimental",
|
|
31
|
+
owners: ["@marketplace-team"],
|
|
32
|
+
tags: ["marketplace", "review"]
|
|
33
|
+
},
|
|
34
|
+
payload: ReviewCreatedPayload
|
|
35
|
+
});
|
|
36
|
+
var ReviewRespondedEvent = defineEvent({
|
|
37
|
+
meta: {
|
|
38
|
+
key: "marketplace.review.responded",
|
|
39
|
+
version: "1.0.0",
|
|
40
|
+
description: "A seller has responded to a review.",
|
|
41
|
+
stability: "experimental",
|
|
42
|
+
owners: ["@marketplace-team"],
|
|
43
|
+
tags: ["marketplace", "review"]
|
|
44
|
+
},
|
|
45
|
+
payload: ReviewRespondedPayload
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
ReviewRespondedEvent,
|
|
49
|
+
ReviewCreatedEvent
|
|
50
|
+
};
|