@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
|
@@ -1,108 +1,172 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/product/product.enum.ts
|
|
3
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
4
|
+
var ProductStatusEnum = defineEnum("ProductStatus", [
|
|
5
|
+
"DRAFT",
|
|
6
|
+
"PENDING_REVIEW",
|
|
7
|
+
"ACTIVE",
|
|
8
|
+
"OUT_OF_STOCK",
|
|
9
|
+
"DISCONTINUED",
|
|
10
|
+
"REJECTED"
|
|
11
|
+
]);
|
|
3
12
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
policy: { auth: "user" },
|
|
29
|
-
sideEffects: {
|
|
30
|
-
emits: [{
|
|
31
|
-
key: "marketplace.product.created",
|
|
32
|
-
version: "1.0.0",
|
|
33
|
-
when: "Product is created",
|
|
34
|
-
payload: ProductModel
|
|
35
|
-
}],
|
|
36
|
-
audit: ["marketplace.product.created"]
|
|
37
|
-
},
|
|
38
|
-
acceptance: {
|
|
39
|
-
scenarios: [{
|
|
40
|
-
key: "create-product-happy-path",
|
|
41
|
-
given: ["User is a seller"],
|
|
42
|
-
when: ["User creates a product listing"],
|
|
43
|
-
then: ["Product is created", "ProductCreated event is emitted"]
|
|
44
|
-
}],
|
|
45
|
-
examples: [{
|
|
46
|
-
key: "create-t-shirt",
|
|
47
|
-
input: {
|
|
48
|
-
title: "Classic T-Shirt",
|
|
49
|
-
price: 25,
|
|
50
|
-
stock: 100,
|
|
51
|
-
storeId: "store-123"
|
|
52
|
-
},
|
|
53
|
-
output: {
|
|
54
|
-
id: "prod-456",
|
|
55
|
-
title: "Classic T-Shirt",
|
|
56
|
-
status: "published"
|
|
57
|
-
}
|
|
58
|
-
}]
|
|
59
|
-
}
|
|
13
|
+
// src/product/product.schema.ts
|
|
14
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
15
|
+
var ProductModel = defineSchemaModel({
|
|
16
|
+
name: "ProductModel",
|
|
17
|
+
description: "A product listing",
|
|
18
|
+
fields: {
|
|
19
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
20
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
23
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
24
|
+
status: { type: ProductStatusEnum, isOptional: false },
|
|
25
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
26
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
27
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
28
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
29
|
+
primaryImageId: {
|
|
30
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
31
|
+
isOptional: true
|
|
32
|
+
},
|
|
33
|
+
averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
34
|
+
totalSold: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
35
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
36
|
+
}
|
|
60
37
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}]
|
|
103
|
-
}
|
|
38
|
+
var CreateProductInputModel = defineSchemaModel({
|
|
39
|
+
name: "CreateProductInput",
|
|
40
|
+
fields: {
|
|
41
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
42
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
43
|
+
slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
44
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
45
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
46
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
47
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
48
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
49
|
+
sku: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
var ListProductsInputModel = defineSchemaModel({
|
|
53
|
+
name: "ListProductsInput",
|
|
54
|
+
fields: {
|
|
55
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
56
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
57
|
+
status: { type: ProductStatusEnum, isOptional: true },
|
|
58
|
+
search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
59
|
+
minPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
60
|
+
maxPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
61
|
+
limit: {
|
|
62
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
63
|
+
isOptional: true,
|
|
64
|
+
defaultValue: 20
|
|
65
|
+
},
|
|
66
|
+
offset: {
|
|
67
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
68
|
+
isOptional: true,
|
|
69
|
+
defaultValue: 0
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
var ListProductsOutputModel = defineSchemaModel({
|
|
74
|
+
name: "ListProductsOutput",
|
|
75
|
+
fields: {
|
|
76
|
+
products: { type: ProductModel, isArray: true, isOptional: false },
|
|
77
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
78
|
+
}
|
|
104
79
|
});
|
|
105
80
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
// src/product/product.operations.ts
|
|
82
|
+
import {
|
|
83
|
+
defineCommand,
|
|
84
|
+
defineQuery
|
|
85
|
+
} from "@contractspec/lib.contracts/operations";
|
|
86
|
+
var OWNERS = ["@example.marketplace"];
|
|
87
|
+
var CreateProductContract = defineCommand({
|
|
88
|
+
meta: {
|
|
89
|
+
key: "marketplace.product.create",
|
|
90
|
+
version: "1.0.0",
|
|
91
|
+
stability: "stable",
|
|
92
|
+
owners: [...OWNERS],
|
|
93
|
+
tags: ["marketplace", "product", "create"],
|
|
94
|
+
description: "Create a new product listing.",
|
|
95
|
+
goal: "Allow sellers to list products.",
|
|
96
|
+
context: "Product management."
|
|
97
|
+
},
|
|
98
|
+
io: { input: CreateProductInputModel, output: ProductModel },
|
|
99
|
+
policy: { auth: "user" },
|
|
100
|
+
sideEffects: {
|
|
101
|
+
emits: [
|
|
102
|
+
{
|
|
103
|
+
key: "marketplace.product.created",
|
|
104
|
+
version: "1.0.0",
|
|
105
|
+
when: "Product is created",
|
|
106
|
+
payload: ProductModel
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
audit: ["marketplace.product.created"]
|
|
110
|
+
},
|
|
111
|
+
acceptance: {
|
|
112
|
+
scenarios: [
|
|
113
|
+
{
|
|
114
|
+
key: "create-product-happy-path",
|
|
115
|
+
given: ["User is a seller"],
|
|
116
|
+
when: ["User creates a product listing"],
|
|
117
|
+
then: ["Product is created", "ProductCreated event is emitted"]
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
examples: [
|
|
121
|
+
{
|
|
122
|
+
key: "create-t-shirt",
|
|
123
|
+
input: {
|
|
124
|
+
title: "Classic T-Shirt",
|
|
125
|
+
price: 25,
|
|
126
|
+
stock: 100,
|
|
127
|
+
storeId: "store-123"
|
|
128
|
+
},
|
|
129
|
+
output: {
|
|
130
|
+
id: "prod-456",
|
|
131
|
+
title: "Classic T-Shirt",
|
|
132
|
+
status: "published"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
var ListProductsContract = defineQuery({
|
|
139
|
+
meta: {
|
|
140
|
+
key: "marketplace.product.list",
|
|
141
|
+
version: "1.0.0",
|
|
142
|
+
stability: "stable",
|
|
143
|
+
owners: [...OWNERS],
|
|
144
|
+
tags: ["marketplace", "product", "list"],
|
|
145
|
+
description: "List products with filters.",
|
|
146
|
+
goal: "Browse products on the marketplace.",
|
|
147
|
+
context: "Product catalog, search."
|
|
148
|
+
},
|
|
149
|
+
io: { input: ListProductsInputModel, output: ListProductsOutputModel },
|
|
150
|
+
policy: { auth: "anonymous" },
|
|
151
|
+
acceptance: {
|
|
152
|
+
scenarios: [
|
|
153
|
+
{
|
|
154
|
+
key: "list-products-happy-path",
|
|
155
|
+
given: ["Products exist"],
|
|
156
|
+
when: ["User searches for products"],
|
|
157
|
+
then: ["List of products is returned"]
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
examples: [
|
|
161
|
+
{
|
|
162
|
+
key: "search-t-shirts",
|
|
163
|
+
input: { search: "t-shirt", limit: 20 },
|
|
164
|
+
output: { items: [], total: 50, hasMore: true }
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
export {
|
|
170
|
+
ListProductsContract,
|
|
171
|
+
CreateProductContract
|
|
172
|
+
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const ProductCatalogPresentation: _contractspec_lib_contracts26.PresentationSpec;
|
|
5
|
-
declare const ProductDetailPresentation: _contractspec_lib_contracts26.PresentationSpec;
|
|
6
|
-
declare const ProductEditorPresentation: _contractspec_lib_contracts26.PresentationSpec;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { ProductCatalogPresentation, ProductDetailPresentation, ProductEditorPresentation };
|
|
1
|
+
export declare const ProductCatalogPresentation: import("@contractspec/lib.contracts").PresentationSpec;
|
|
2
|
+
export declare const ProductDetailPresentation: import("@contractspec/lib.contracts").PresentationSpec;
|
|
3
|
+
export declare const ProductEditorPresentation: import("@contractspec/lib.contracts").PresentationSpec;
|
|
9
4
|
//# sourceMappingURL=product.presentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product.presentation.d.ts","
|
|
1
|
+
{"version":3,"file":"product.presentation.d.ts","sourceRoot":"","sources":["../../src/product/product.presentation.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,0BAA0B,wDAuBrC,CAAC;AAEH,eAAO,MAAM,yBAAyB,wDAuBpC,CAAC;AAEH,eAAO,MAAM,yBAAyB,wDAuBpC,CAAC"}
|
|
@@ -1,86 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/product/product.enum.ts
|
|
3
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
4
|
+
var ProductStatusEnum = defineEnum("ProductStatus", [
|
|
5
|
+
"DRAFT",
|
|
6
|
+
"PENDING_REVIEW",
|
|
7
|
+
"ACTIVE",
|
|
8
|
+
"OUT_OF_STOCK",
|
|
9
|
+
"DISCONTINUED",
|
|
10
|
+
"REJECTED"
|
|
11
|
+
]);
|
|
3
12
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
targets: ["react", "markdown"],
|
|
29
|
-
policy: { flags: ["marketplace.products.enabled"] }
|
|
13
|
+
// src/product/product.schema.ts
|
|
14
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
15
|
+
var ProductModel = defineSchemaModel({
|
|
16
|
+
name: "ProductModel",
|
|
17
|
+
description: "A product listing",
|
|
18
|
+
fields: {
|
|
19
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
20
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
21
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
23
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
24
|
+
status: { type: ProductStatusEnum, isOptional: false },
|
|
25
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
26
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
27
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
28
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
29
|
+
primaryImageId: {
|
|
30
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
31
|
+
isOptional: true
|
|
32
|
+
},
|
|
33
|
+
averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
34
|
+
totalSold: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
35
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
36
|
+
}
|
|
30
37
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
stability: StabilityEnum.Experimental,
|
|
45
|
-
goal: "Provide comprehensive information about a specific product.",
|
|
46
|
-
context: "Product showcase including images, descriptions, and ratings."
|
|
47
|
-
},
|
|
48
|
-
source: {
|
|
49
|
-
type: "component",
|
|
50
|
-
framework: "react",
|
|
51
|
-
componentKey: "ProductDetail",
|
|
52
|
-
props: ProductModel
|
|
53
|
-
},
|
|
54
|
-
targets: ["react", "markdown"],
|
|
55
|
-
policy: { flags: ["marketplace.products.enabled"] }
|
|
38
|
+
var CreateProductInputModel = defineSchemaModel({
|
|
39
|
+
name: "CreateProductInput",
|
|
40
|
+
fields: {
|
|
41
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
42
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
43
|
+
slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
44
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
45
|
+
price: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
46
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
47
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
48
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
49
|
+
sku: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
50
|
+
}
|
|
56
51
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
52
|
+
var ListProductsInputModel = defineSchemaModel({
|
|
53
|
+
name: "ListProductsInput",
|
|
54
|
+
fields: {
|
|
55
|
+
storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
56
|
+
categoryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
57
|
+
status: { type: ProductStatusEnum, isOptional: true },
|
|
58
|
+
search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
59
|
+
minPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
60
|
+
maxPrice: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
|
|
61
|
+
limit: {
|
|
62
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
63
|
+
isOptional: true,
|
|
64
|
+
defaultValue: 20
|
|
65
|
+
},
|
|
66
|
+
offset: {
|
|
67
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
68
|
+
isOptional: true,
|
|
69
|
+
defaultValue: 0
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
var ListProductsOutputModel = defineSchemaModel({
|
|
74
|
+
name: "ListProductsOutput",
|
|
75
|
+
fields: {
|
|
76
|
+
products: { type: ProductModel, isArray: true, isOptional: false },
|
|
77
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
78
|
+
}
|
|
82
79
|
});
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
// src/product/product.presentation.ts
|
|
82
|
+
import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
|
|
83
|
+
var ProductCatalogPresentation = definePresentation({
|
|
84
|
+
meta: {
|
|
85
|
+
key: "marketplace.product.catalog",
|
|
86
|
+
version: "1.0.0",
|
|
87
|
+
title: "Product Catalog",
|
|
88
|
+
description: "Product catalog with search and filters",
|
|
89
|
+
domain: "marketplace",
|
|
90
|
+
owners: ["@marketplace-team"],
|
|
91
|
+
tags: ["marketplace", "product", "catalog"],
|
|
92
|
+
stability: StabilityEnum.Experimental,
|
|
93
|
+
goal: "Enable users to browse and search for products.",
|
|
94
|
+
context: "The primary shopping interface."
|
|
95
|
+
},
|
|
96
|
+
source: {
|
|
97
|
+
type: "component",
|
|
98
|
+
framework: "react",
|
|
99
|
+
componentKey: "ProductCatalog",
|
|
100
|
+
props: ProductModel
|
|
101
|
+
},
|
|
102
|
+
targets: ["react", "markdown"],
|
|
103
|
+
policy: {
|
|
104
|
+
flags: ["marketplace.products.enabled"]
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
var ProductDetailPresentation = definePresentation({
|
|
108
|
+
meta: {
|
|
109
|
+
key: "marketplace.product.detail",
|
|
110
|
+
version: "1.0.0",
|
|
111
|
+
title: "Product Details",
|
|
112
|
+
description: "Product detail page with images and reviews",
|
|
113
|
+
domain: "marketplace",
|
|
114
|
+
owners: ["@marketplace-team"],
|
|
115
|
+
tags: ["marketplace", "product", "detail"],
|
|
116
|
+
stability: StabilityEnum.Experimental,
|
|
117
|
+
goal: "Provide comprehensive information about a specific product.",
|
|
118
|
+
context: "Product showcase including images, descriptions, and ratings."
|
|
119
|
+
},
|
|
120
|
+
source: {
|
|
121
|
+
type: "component",
|
|
122
|
+
framework: "react",
|
|
123
|
+
componentKey: "ProductDetail",
|
|
124
|
+
props: ProductModel
|
|
125
|
+
},
|
|
126
|
+
targets: ["react", "markdown"],
|
|
127
|
+
policy: {
|
|
128
|
+
flags: ["marketplace.products.enabled"]
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
var ProductEditorPresentation = definePresentation({
|
|
132
|
+
meta: {
|
|
133
|
+
key: "marketplace.product.editor",
|
|
134
|
+
version: "1.0.0",
|
|
135
|
+
title: "Product Editor",
|
|
136
|
+
description: "Product editor for sellers",
|
|
137
|
+
domain: "marketplace",
|
|
138
|
+
owners: ["@marketplace-team"],
|
|
139
|
+
tags: ["marketplace", "product", "editor"],
|
|
140
|
+
stability: StabilityEnum.Experimental,
|
|
141
|
+
goal: "Allow sellers to create and modify product listings.",
|
|
142
|
+
context: "Management tool for store owners."
|
|
143
|
+
},
|
|
144
|
+
source: {
|
|
145
|
+
type: "component",
|
|
146
|
+
framework: "react",
|
|
147
|
+
componentKey: "ProductEditor",
|
|
148
|
+
props: ProductModel
|
|
149
|
+
},
|
|
150
|
+
targets: ["react"],
|
|
151
|
+
policy: {
|
|
152
|
+
flags: ["marketplace.seller.enabled"]
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
export {
|
|
156
|
+
ProductEditorPresentation,
|
|
157
|
+
ProductDetailPresentation,
|
|
158
|
+
ProductCatalogPresentation
|
|
159
|
+
};
|