@contractspec/example.marketplace 1.57.0 → 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 +41 -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 -137
- 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 -6
- 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 -14
- package/dist/ui/renderers/marketplace.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/marketplace.markdown.js +241 -236
- package/package.json +528 -109
- 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,721 @@
|
|
|
1
|
+
// src/entities/store.ts
|
|
2
|
+
import {
|
|
3
|
+
defineEntity,
|
|
4
|
+
defineEntityEnum,
|
|
5
|
+
field,
|
|
6
|
+
index
|
|
7
|
+
} from "@contractspec/lib.schema";
|
|
8
|
+
var StoreStatusEnum = defineEntityEnum({
|
|
9
|
+
name: "StoreStatus",
|
|
10
|
+
values: ["PENDING", "ACTIVE", "SUSPENDED", "CLOSED"],
|
|
11
|
+
schema: "marketplace",
|
|
12
|
+
description: "Status of a store."
|
|
13
|
+
});
|
|
14
|
+
var StoreTypeEnum = defineEntityEnum({
|
|
15
|
+
name: "StoreType",
|
|
16
|
+
values: ["INDIVIDUAL", "BUSINESS", "ENTERPRISE"],
|
|
17
|
+
schema: "marketplace",
|
|
18
|
+
description: "Type of store account."
|
|
19
|
+
});
|
|
20
|
+
var StoreEntity = defineEntity({
|
|
21
|
+
name: "Store",
|
|
22
|
+
description: "A seller storefront on the marketplace.",
|
|
23
|
+
schema: "marketplace",
|
|
24
|
+
map: "store",
|
|
25
|
+
fields: {
|
|
26
|
+
id: field.id({ description: "Unique store ID" }),
|
|
27
|
+
name: field.string({ description: "Store display name" }),
|
|
28
|
+
slug: field.string({ description: "URL-friendly identifier" }),
|
|
29
|
+
description: field.string({ isOptional: true }),
|
|
30
|
+
status: field.enum("StoreStatus", { default: "PENDING" }),
|
|
31
|
+
type: field.enum("StoreType", { default: "INDIVIDUAL" }),
|
|
32
|
+
ownerId: field.foreignKey({ description: "Store owner user ID" }),
|
|
33
|
+
organizationId: field.foreignKey({ isOptional: true }),
|
|
34
|
+
logoFileId: field.string({
|
|
35
|
+
isOptional: true,
|
|
36
|
+
description: "Logo file reference"
|
|
37
|
+
}),
|
|
38
|
+
bannerFileId: field.string({
|
|
39
|
+
isOptional: true,
|
|
40
|
+
description: "Banner file reference"
|
|
41
|
+
}),
|
|
42
|
+
email: field.string({ isOptional: true }),
|
|
43
|
+
phone: field.string({ isOptional: true }),
|
|
44
|
+
website: field.string({ isOptional: true }),
|
|
45
|
+
country: field.string({ isOptional: true }),
|
|
46
|
+
currency: field.string({ default: '"USD"' }),
|
|
47
|
+
timezone: field.string({ isOptional: true }),
|
|
48
|
+
commissionRate: field.decimal({
|
|
49
|
+
default: 0.1,
|
|
50
|
+
description: "Platform commission rate (e.g., 0.1 = 10%)"
|
|
51
|
+
}),
|
|
52
|
+
isVerified: field.boolean({ default: false }),
|
|
53
|
+
verifiedAt: field.dateTime({ isOptional: true }),
|
|
54
|
+
settings: field.json({ isOptional: true }),
|
|
55
|
+
metadata: field.json({ isOptional: true }),
|
|
56
|
+
totalProducts: field.int({ default: 0 }),
|
|
57
|
+
totalOrders: field.int({ default: 0 }),
|
|
58
|
+
totalRevenue: field.decimal({ default: 0 }),
|
|
59
|
+
averageRating: field.decimal({ default: 0 }),
|
|
60
|
+
createdAt: field.createdAt(),
|
|
61
|
+
updatedAt: field.updatedAt(),
|
|
62
|
+
products: field.hasMany("Product"),
|
|
63
|
+
orders: field.hasMany("Order"),
|
|
64
|
+
payouts: field.hasMany("Payout")
|
|
65
|
+
},
|
|
66
|
+
indexes: [
|
|
67
|
+
index.unique(["slug"]),
|
|
68
|
+
index.on(["ownerId"]),
|
|
69
|
+
index.on(["status"]),
|
|
70
|
+
index.on(["country", "status"]),
|
|
71
|
+
index.on(["averageRating"])
|
|
72
|
+
],
|
|
73
|
+
enums: [StoreStatusEnum, StoreTypeEnum]
|
|
74
|
+
});
|
|
75
|
+
var StoreCategoryEntity = defineEntity({
|
|
76
|
+
name: "StoreCategory",
|
|
77
|
+
description: "Category assignment for stores.",
|
|
78
|
+
schema: "marketplace",
|
|
79
|
+
map: "store_category",
|
|
80
|
+
fields: {
|
|
81
|
+
id: field.id(),
|
|
82
|
+
storeId: field.foreignKey(),
|
|
83
|
+
categoryId: field.foreignKey(),
|
|
84
|
+
isPrimary: field.boolean({ default: false }),
|
|
85
|
+
createdAt: field.createdAt(),
|
|
86
|
+
store: field.belongsTo("Store", ["storeId"], ["id"], {
|
|
87
|
+
onDelete: "Cascade"
|
|
88
|
+
})
|
|
89
|
+
},
|
|
90
|
+
indexes: [index.unique(["storeId", "categoryId"]), index.on(["categoryId"])]
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// src/entities/product.ts
|
|
94
|
+
import {
|
|
95
|
+
defineEntity as defineEntity2,
|
|
96
|
+
defineEntityEnum as defineEntityEnum2,
|
|
97
|
+
field as field2,
|
|
98
|
+
index as index2
|
|
99
|
+
} from "@contractspec/lib.schema";
|
|
100
|
+
var ProductStatusEnum = defineEntityEnum2({
|
|
101
|
+
name: "ProductStatus",
|
|
102
|
+
values: [
|
|
103
|
+
"DRAFT",
|
|
104
|
+
"PENDING_REVIEW",
|
|
105
|
+
"ACTIVE",
|
|
106
|
+
"OUT_OF_STOCK",
|
|
107
|
+
"DISCONTINUED",
|
|
108
|
+
"REJECTED"
|
|
109
|
+
],
|
|
110
|
+
schema: "marketplace",
|
|
111
|
+
description: "Status of a product listing."
|
|
112
|
+
});
|
|
113
|
+
var ProductTypeEnum = defineEntityEnum2({
|
|
114
|
+
name: "ProductType",
|
|
115
|
+
values: ["PHYSICAL", "DIGITAL", "SERVICE", "SUBSCRIPTION"],
|
|
116
|
+
schema: "marketplace",
|
|
117
|
+
description: "Type of product."
|
|
118
|
+
});
|
|
119
|
+
var ProductEntity = defineEntity2({
|
|
120
|
+
name: "Product",
|
|
121
|
+
description: "A product listing on the marketplace.",
|
|
122
|
+
schema: "marketplace",
|
|
123
|
+
map: "product",
|
|
124
|
+
fields: {
|
|
125
|
+
id: field2.id({ description: "Unique product ID" }),
|
|
126
|
+
storeId: field2.foreignKey(),
|
|
127
|
+
name: field2.string({ description: "Product name" }),
|
|
128
|
+
slug: field2.string({ description: "URL-friendly identifier" }),
|
|
129
|
+
description: field2.string({ isOptional: true }),
|
|
130
|
+
shortDescription: field2.string({ isOptional: true }),
|
|
131
|
+
status: field2.enum("ProductStatus", { default: "DRAFT" }),
|
|
132
|
+
type: field2.enum("ProductType", { default: "PHYSICAL" }),
|
|
133
|
+
price: field2.decimal({ description: "Base price" }),
|
|
134
|
+
compareAtPrice: field2.decimal({
|
|
135
|
+
isOptional: true,
|
|
136
|
+
description: "Original price for showing discounts"
|
|
137
|
+
}),
|
|
138
|
+
currency: field2.string({ default: '"USD"' }),
|
|
139
|
+
sku: field2.string({ isOptional: true }),
|
|
140
|
+
barcode: field2.string({ isOptional: true }),
|
|
141
|
+
quantity: field2.int({ default: 0 }),
|
|
142
|
+
trackInventory: field2.boolean({ default: true }),
|
|
143
|
+
allowBackorder: field2.boolean({ default: false }),
|
|
144
|
+
lowStockThreshold: field2.int({ default: 5 }),
|
|
145
|
+
weight: field2.decimal({ isOptional: true }),
|
|
146
|
+
weightUnit: field2.string({ default: '"kg"' }),
|
|
147
|
+
categoryId: field2.string({ isOptional: true }),
|
|
148
|
+
tags: field2.string({ isArray: true }),
|
|
149
|
+
primaryImageId: field2.string({ isOptional: true }),
|
|
150
|
+
seoTitle: field2.string({ isOptional: true }),
|
|
151
|
+
seoDescription: field2.string({ isOptional: true }),
|
|
152
|
+
attributes: field2.json({
|
|
153
|
+
isOptional: true,
|
|
154
|
+
description: "Custom product attributes"
|
|
155
|
+
}),
|
|
156
|
+
reviewCount: field2.int({ default: 0 }),
|
|
157
|
+
averageRating: field2.decimal({ default: 0 }),
|
|
158
|
+
totalSold: field2.int({ default: 0 }),
|
|
159
|
+
createdAt: field2.createdAt(),
|
|
160
|
+
updatedAt: field2.updatedAt(),
|
|
161
|
+
publishedAt: field2.dateTime({ isOptional: true }),
|
|
162
|
+
store: field2.belongsTo("Store", ["storeId"], ["id"]),
|
|
163
|
+
variants: field2.hasMany("ProductVariant"),
|
|
164
|
+
orderItems: field2.hasMany("OrderItem"),
|
|
165
|
+
reviews: field2.hasMany("Review")
|
|
166
|
+
},
|
|
167
|
+
indexes: [
|
|
168
|
+
index2.unique(["storeId", "slug"]),
|
|
169
|
+
index2.on(["storeId", "status"]),
|
|
170
|
+
index2.on(["status", "publishedAt"]),
|
|
171
|
+
index2.on(["categoryId", "status"]),
|
|
172
|
+
index2.on(["averageRating"]),
|
|
173
|
+
index2.on(["totalSold"]),
|
|
174
|
+
index2.on(["price"])
|
|
175
|
+
],
|
|
176
|
+
enums: [ProductStatusEnum, ProductTypeEnum]
|
|
177
|
+
});
|
|
178
|
+
var ProductVariantEntity = defineEntity2({
|
|
179
|
+
name: "ProductVariant",
|
|
180
|
+
description: "A variant of a product with specific options.",
|
|
181
|
+
schema: "marketplace",
|
|
182
|
+
map: "product_variant",
|
|
183
|
+
fields: {
|
|
184
|
+
id: field2.id(),
|
|
185
|
+
productId: field2.foreignKey(),
|
|
186
|
+
name: field2.string({ description: 'Variant name (e.g., "Large / Blue")' }),
|
|
187
|
+
options: field2.json({
|
|
188
|
+
description: 'Variant options (e.g., {size: "L", color: "Blue"})'
|
|
189
|
+
}),
|
|
190
|
+
price: field2.decimal({ description: "Variant-specific price" }),
|
|
191
|
+
compareAtPrice: field2.decimal({ isOptional: true }),
|
|
192
|
+
sku: field2.string({ isOptional: true }),
|
|
193
|
+
barcode: field2.string({ isOptional: true }),
|
|
194
|
+
quantity: field2.int({ default: 0 }),
|
|
195
|
+
imageId: field2.string({ isOptional: true }),
|
|
196
|
+
isActive: field2.boolean({ default: true }),
|
|
197
|
+
position: field2.int({ default: 0 }),
|
|
198
|
+
createdAt: field2.createdAt(),
|
|
199
|
+
updatedAt: field2.updatedAt(),
|
|
200
|
+
product: field2.belongsTo("Product", ["productId"], ["id"], {
|
|
201
|
+
onDelete: "Cascade"
|
|
202
|
+
})
|
|
203
|
+
},
|
|
204
|
+
indexes: [
|
|
205
|
+
index2.on(["productId", "sku"]),
|
|
206
|
+
index2.on(["productId", "position"]),
|
|
207
|
+
index2.on(["barcode"])
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
var CategoryEntity = defineEntity2({
|
|
211
|
+
name: "Category",
|
|
212
|
+
description: "Product category for organization.",
|
|
213
|
+
schema: "marketplace",
|
|
214
|
+
map: "category",
|
|
215
|
+
fields: {
|
|
216
|
+
id: field2.id(),
|
|
217
|
+
name: field2.string(),
|
|
218
|
+
slug: field2.string(),
|
|
219
|
+
description: field2.string({ isOptional: true }),
|
|
220
|
+
parentId: field2.string({ isOptional: true }),
|
|
221
|
+
path: field2.string({ description: "Full path for hierarchical queries" }),
|
|
222
|
+
level: field2.int({ default: 0 }),
|
|
223
|
+
position: field2.int({ default: 0 }),
|
|
224
|
+
imageId: field2.string({ isOptional: true }),
|
|
225
|
+
isActive: field2.boolean({ default: true }),
|
|
226
|
+
createdAt: field2.createdAt(),
|
|
227
|
+
updatedAt: field2.updatedAt(),
|
|
228
|
+
parent: field2.belongsTo("Category", ["parentId"], ["id"]),
|
|
229
|
+
children: field2.hasMany("Category")
|
|
230
|
+
},
|
|
231
|
+
indexes: [
|
|
232
|
+
index2.unique(["slug"]),
|
|
233
|
+
index2.on(["parentId", "position"]),
|
|
234
|
+
index2.on(["path"]),
|
|
235
|
+
index2.on(["isActive"])
|
|
236
|
+
]
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// src/entities/order.ts
|
|
240
|
+
import {
|
|
241
|
+
defineEntity as defineEntity3,
|
|
242
|
+
defineEntityEnum as defineEntityEnum3,
|
|
243
|
+
field as field3,
|
|
244
|
+
index as index3
|
|
245
|
+
} from "@contractspec/lib.schema";
|
|
246
|
+
var OrderStatusEnum = defineEntityEnum3({
|
|
247
|
+
name: "OrderStatus",
|
|
248
|
+
values: [
|
|
249
|
+
"PENDING",
|
|
250
|
+
"PAID",
|
|
251
|
+
"PROCESSING",
|
|
252
|
+
"SHIPPED",
|
|
253
|
+
"DELIVERED",
|
|
254
|
+
"COMPLETED",
|
|
255
|
+
"CANCELLED",
|
|
256
|
+
"REFUNDED",
|
|
257
|
+
"PARTIALLY_REFUNDED",
|
|
258
|
+
"DISPUTED"
|
|
259
|
+
],
|
|
260
|
+
schema: "marketplace",
|
|
261
|
+
description: "Status of an order."
|
|
262
|
+
});
|
|
263
|
+
var PaymentStatusEnum = defineEntityEnum3({
|
|
264
|
+
name: "PaymentStatus",
|
|
265
|
+
values: [
|
|
266
|
+
"PENDING",
|
|
267
|
+
"AUTHORIZED",
|
|
268
|
+
"CAPTURED",
|
|
269
|
+
"FAILED",
|
|
270
|
+
"REFUNDED",
|
|
271
|
+
"VOIDED"
|
|
272
|
+
],
|
|
273
|
+
schema: "marketplace",
|
|
274
|
+
description: "Status of payment."
|
|
275
|
+
});
|
|
276
|
+
var OrderEntity = defineEntity3({
|
|
277
|
+
name: "Order",
|
|
278
|
+
description: "A purchase order on the marketplace.",
|
|
279
|
+
schema: "marketplace",
|
|
280
|
+
map: "order",
|
|
281
|
+
fields: {
|
|
282
|
+
id: field3.id({ description: "Unique order ID" }),
|
|
283
|
+
orderNumber: field3.string({ description: "Human-readable order number" }),
|
|
284
|
+
buyerId: field3.foreignKey({ description: "Buyer user ID" }),
|
|
285
|
+
storeId: field3.foreignKey({ description: "Seller store ID" }),
|
|
286
|
+
status: field3.enum("OrderStatus", { default: "PENDING" }),
|
|
287
|
+
paymentStatus: field3.enum("PaymentStatus", { default: "PENDING" }),
|
|
288
|
+
subtotal: field3.decimal({ description: "Sum of item prices" }),
|
|
289
|
+
shippingTotal: field3.decimal({ default: 0 }),
|
|
290
|
+
taxTotal: field3.decimal({ default: 0 }),
|
|
291
|
+
discountTotal: field3.decimal({ default: 0 }),
|
|
292
|
+
total: field3.decimal({ description: "Final total" }),
|
|
293
|
+
currency: field3.string({ default: '"USD"' }),
|
|
294
|
+
platformFee: field3.decimal({ description: "Platform commission amount" }),
|
|
295
|
+
sellerPayout: field3.decimal({ description: "Amount due to seller" }),
|
|
296
|
+
shippingAddress: field3.json({ isOptional: true }),
|
|
297
|
+
billingAddress: field3.json({ isOptional: true }),
|
|
298
|
+
shippingMethod: field3.string({ isOptional: true }),
|
|
299
|
+
trackingNumber: field3.string({ isOptional: true }),
|
|
300
|
+
trackingUrl: field3.string({ isOptional: true }),
|
|
301
|
+
paymentMethod: field3.string({ isOptional: true }),
|
|
302
|
+
paymentIntentId: field3.string({ isOptional: true }),
|
|
303
|
+
buyerNote: field3.string({ isOptional: true }),
|
|
304
|
+
sellerNote: field3.string({ isOptional: true }),
|
|
305
|
+
internalNote: field3.string({ isOptional: true }),
|
|
306
|
+
createdAt: field3.createdAt(),
|
|
307
|
+
updatedAt: field3.updatedAt(),
|
|
308
|
+
paidAt: field3.dateTime({ isOptional: true }),
|
|
309
|
+
shippedAt: field3.dateTime({ isOptional: true }),
|
|
310
|
+
deliveredAt: field3.dateTime({ isOptional: true }),
|
|
311
|
+
completedAt: field3.dateTime({ isOptional: true }),
|
|
312
|
+
cancelledAt: field3.dateTime({ isOptional: true }),
|
|
313
|
+
store: field3.belongsTo("Store", ["storeId"], ["id"]),
|
|
314
|
+
items: field3.hasMany("OrderItem"),
|
|
315
|
+
refunds: field3.hasMany("Refund")
|
|
316
|
+
},
|
|
317
|
+
indexes: [
|
|
318
|
+
index3.unique(["orderNumber"]),
|
|
319
|
+
index3.on(["buyerId", "status"]),
|
|
320
|
+
index3.on(["storeId", "status"]),
|
|
321
|
+
index3.on(["status", "createdAt"]),
|
|
322
|
+
index3.on(["paymentStatus"]),
|
|
323
|
+
index3.on(["createdAt"])
|
|
324
|
+
],
|
|
325
|
+
enums: [OrderStatusEnum, PaymentStatusEnum]
|
|
326
|
+
});
|
|
327
|
+
var OrderItemEntity = defineEntity3({
|
|
328
|
+
name: "OrderItem",
|
|
329
|
+
description: "An item within an order.",
|
|
330
|
+
schema: "marketplace",
|
|
331
|
+
map: "order_item",
|
|
332
|
+
fields: {
|
|
333
|
+
id: field3.id(),
|
|
334
|
+
orderId: field3.foreignKey(),
|
|
335
|
+
productId: field3.foreignKey(),
|
|
336
|
+
variantId: field3.string({ isOptional: true }),
|
|
337
|
+
productName: field3.string(),
|
|
338
|
+
variantName: field3.string({ isOptional: true }),
|
|
339
|
+
sku: field3.string({ isOptional: true }),
|
|
340
|
+
unitPrice: field3.decimal(),
|
|
341
|
+
quantity: field3.int(),
|
|
342
|
+
subtotal: field3.decimal(),
|
|
343
|
+
quantityFulfilled: field3.int({ default: 0 }),
|
|
344
|
+
quantityRefunded: field3.int({ default: 0 }),
|
|
345
|
+
createdAt: field3.createdAt(),
|
|
346
|
+
updatedAt: field3.updatedAt(),
|
|
347
|
+
order: field3.belongsTo("Order", ["orderId"], ["id"], {
|
|
348
|
+
onDelete: "Cascade"
|
|
349
|
+
}),
|
|
350
|
+
product: field3.belongsTo("Product", ["productId"], ["id"])
|
|
351
|
+
},
|
|
352
|
+
indexes: [index3.on(["orderId"]), index3.on(["productId"])]
|
|
353
|
+
});
|
|
354
|
+
var RefundEntity = defineEntity3({
|
|
355
|
+
name: "Refund",
|
|
356
|
+
description: "A refund for an order.",
|
|
357
|
+
schema: "marketplace",
|
|
358
|
+
map: "refund",
|
|
359
|
+
fields: {
|
|
360
|
+
id: field3.id(),
|
|
361
|
+
orderId: field3.foreignKey(),
|
|
362
|
+
amount: field3.decimal(),
|
|
363
|
+
currency: field3.string(),
|
|
364
|
+
reason: field3.string(),
|
|
365
|
+
notes: field3.string({ isOptional: true }),
|
|
366
|
+
status: field3.string({ default: '"PENDING"' }),
|
|
367
|
+
refundId: field3.string({
|
|
368
|
+
isOptional: true,
|
|
369
|
+
description: "Payment provider refund ID"
|
|
370
|
+
}),
|
|
371
|
+
issuedBy: field3.foreignKey({ description: "User who issued the refund" }),
|
|
372
|
+
createdAt: field3.createdAt(),
|
|
373
|
+
processedAt: field3.dateTime({ isOptional: true }),
|
|
374
|
+
order: field3.belongsTo("Order", ["orderId"], ["id"]),
|
|
375
|
+
items: field3.hasMany("RefundItem")
|
|
376
|
+
},
|
|
377
|
+
indexes: [index3.on(["orderId"]), index3.on(["status"])]
|
|
378
|
+
});
|
|
379
|
+
var RefundItemEntity = defineEntity3({
|
|
380
|
+
name: "RefundItem",
|
|
381
|
+
description: "An item within a refund.",
|
|
382
|
+
schema: "marketplace",
|
|
383
|
+
map: "refund_item",
|
|
384
|
+
fields: {
|
|
385
|
+
id: field3.id(),
|
|
386
|
+
refundId: field3.foreignKey(),
|
|
387
|
+
orderItemId: field3.foreignKey(),
|
|
388
|
+
quantity: field3.int(),
|
|
389
|
+
amount: field3.decimal(),
|
|
390
|
+
createdAt: field3.createdAt(),
|
|
391
|
+
refund: field3.belongsTo("Refund", ["refundId"], ["id"], {
|
|
392
|
+
onDelete: "Cascade"
|
|
393
|
+
}),
|
|
394
|
+
orderItem: field3.belongsTo("OrderItem", ["orderItemId"], ["id"])
|
|
395
|
+
},
|
|
396
|
+
indexes: [index3.on(["refundId"]), index3.on(["orderItemId"])]
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// src/entities/payout.ts
|
|
400
|
+
import {
|
|
401
|
+
defineEntity as defineEntity4,
|
|
402
|
+
defineEntityEnum as defineEntityEnum4,
|
|
403
|
+
field as field4,
|
|
404
|
+
index as index4
|
|
405
|
+
} from "@contractspec/lib.schema";
|
|
406
|
+
var PayoutStatusEnum = defineEntityEnum4({
|
|
407
|
+
name: "PayoutStatus",
|
|
408
|
+
values: ["PENDING", "PROCESSING", "PAID", "FAILED", "CANCELLED"],
|
|
409
|
+
schema: "marketplace",
|
|
410
|
+
description: "Status of a payout."
|
|
411
|
+
});
|
|
412
|
+
var PayoutScheduleEnum = defineEntityEnum4({
|
|
413
|
+
name: "PayoutSchedule",
|
|
414
|
+
values: ["DAILY", "WEEKLY", "BIWEEKLY", "MONTHLY", "MANUAL"],
|
|
415
|
+
schema: "marketplace",
|
|
416
|
+
description: "Payout schedule frequency."
|
|
417
|
+
});
|
|
418
|
+
var PayoutEntity = defineEntity4({
|
|
419
|
+
name: "Payout",
|
|
420
|
+
description: "A payout to a seller.",
|
|
421
|
+
schema: "marketplace",
|
|
422
|
+
map: "payout",
|
|
423
|
+
fields: {
|
|
424
|
+
id: field4.id({ description: "Unique payout ID" }),
|
|
425
|
+
storeId: field4.foreignKey(),
|
|
426
|
+
payoutNumber: field4.string({ description: "Human-readable payout number" }),
|
|
427
|
+
status: field4.enum("PayoutStatus", { default: "PENDING" }),
|
|
428
|
+
grossAmount: field4.decimal({ description: "Total before fees" }),
|
|
429
|
+
platformFees: field4.decimal({ description: "Platform fees deducted" }),
|
|
430
|
+
otherDeductions: field4.decimal({ default: 0 }),
|
|
431
|
+
netAmount: field4.decimal({ description: "Final payout amount" }),
|
|
432
|
+
currency: field4.string({ default: '"USD"' }),
|
|
433
|
+
periodStart: field4.dateTime({ description: "Start of payout period" }),
|
|
434
|
+
periodEnd: field4.dateTime({ description: "End of payout period" }),
|
|
435
|
+
paymentMethod: field4.string({ isOptional: true }),
|
|
436
|
+
paymentReference: field4.string({ isOptional: true }),
|
|
437
|
+
bankAccountId: field4.string({ isOptional: true }),
|
|
438
|
+
bankAccountLast4: field4.string({ isOptional: true }),
|
|
439
|
+
notes: field4.string({ isOptional: true }),
|
|
440
|
+
failureReason: field4.string({ isOptional: true }),
|
|
441
|
+
orderCount: field4.int({ default: 0 }),
|
|
442
|
+
createdAt: field4.createdAt(),
|
|
443
|
+
updatedAt: field4.updatedAt(),
|
|
444
|
+
scheduledAt: field4.dateTime({ isOptional: true }),
|
|
445
|
+
processedAt: field4.dateTime({ isOptional: true }),
|
|
446
|
+
paidAt: field4.dateTime({ isOptional: true }),
|
|
447
|
+
store: field4.belongsTo("Store", ["storeId"], ["id"]),
|
|
448
|
+
items: field4.hasMany("PayoutItem")
|
|
449
|
+
},
|
|
450
|
+
indexes: [
|
|
451
|
+
index4.unique(["payoutNumber"]),
|
|
452
|
+
index4.on(["storeId", "status"]),
|
|
453
|
+
index4.on(["status", "scheduledAt"]),
|
|
454
|
+
index4.on(["periodStart", "periodEnd"])
|
|
455
|
+
],
|
|
456
|
+
enums: [PayoutStatusEnum]
|
|
457
|
+
});
|
|
458
|
+
var PayoutItemEntity = defineEntity4({
|
|
459
|
+
name: "PayoutItem",
|
|
460
|
+
description: "An order included in a payout.",
|
|
461
|
+
schema: "marketplace",
|
|
462
|
+
map: "payout_item",
|
|
463
|
+
fields: {
|
|
464
|
+
id: field4.id(),
|
|
465
|
+
payoutId: field4.foreignKey(),
|
|
466
|
+
orderId: field4.foreignKey(),
|
|
467
|
+
orderTotal: field4.decimal(),
|
|
468
|
+
platformFee: field4.decimal(),
|
|
469
|
+
netAmount: field4.decimal(),
|
|
470
|
+
createdAt: field4.createdAt(),
|
|
471
|
+
payout: field4.belongsTo("Payout", ["payoutId"], ["id"], {
|
|
472
|
+
onDelete: "Cascade"
|
|
473
|
+
}),
|
|
474
|
+
order: field4.belongsTo("Order", ["orderId"], ["id"])
|
|
475
|
+
},
|
|
476
|
+
indexes: [index4.on(["payoutId"]), index4.on(["orderId"])]
|
|
477
|
+
});
|
|
478
|
+
var BankAccountEntity = defineEntity4({
|
|
479
|
+
name: "BankAccount",
|
|
480
|
+
description: "A bank account for receiving payouts.",
|
|
481
|
+
schema: "marketplace",
|
|
482
|
+
map: "bank_account",
|
|
483
|
+
fields: {
|
|
484
|
+
id: field4.id(),
|
|
485
|
+
storeId: field4.foreignKey(),
|
|
486
|
+
accountHolderName: field4.string(),
|
|
487
|
+
accountType: field4.string({ default: '"CHECKING"' }),
|
|
488
|
+
bankName: field4.string({ isOptional: true }),
|
|
489
|
+
last4: field4.string({ description: "Last 4 digits of account" }),
|
|
490
|
+
routingLast4: field4.string({ isOptional: true }),
|
|
491
|
+
externalId: field4.string({
|
|
492
|
+
isOptional: true,
|
|
493
|
+
description: "External provider account ID"
|
|
494
|
+
}),
|
|
495
|
+
isDefault: field4.boolean({ default: false }),
|
|
496
|
+
isVerified: field4.boolean({ default: false }),
|
|
497
|
+
createdAt: field4.createdAt(),
|
|
498
|
+
updatedAt: field4.updatedAt(),
|
|
499
|
+
verifiedAt: field4.dateTime({ isOptional: true }),
|
|
500
|
+
store: field4.belongsTo("Store", ["storeId"], ["id"])
|
|
501
|
+
},
|
|
502
|
+
indexes: [index4.on(["storeId", "isDefault"]), index4.on(["externalId"])]
|
|
503
|
+
});
|
|
504
|
+
var PayoutSettingsEntity = defineEntity4({
|
|
505
|
+
name: "PayoutSettings",
|
|
506
|
+
description: "Payout configuration for a store.",
|
|
507
|
+
schema: "marketplace",
|
|
508
|
+
map: "payout_settings",
|
|
509
|
+
fields: {
|
|
510
|
+
id: field4.id(),
|
|
511
|
+
storeId: field4.foreignKey(),
|
|
512
|
+
schedule: field4.enum("PayoutSchedule", { default: "WEEKLY" }),
|
|
513
|
+
dayOfWeek: field4.int({
|
|
514
|
+
isOptional: true,
|
|
515
|
+
description: "Day for weekly/biweekly (0=Sunday)"
|
|
516
|
+
}),
|
|
517
|
+
dayOfMonth: field4.int({
|
|
518
|
+
isOptional: true,
|
|
519
|
+
description: "Day for monthly (1-28)"
|
|
520
|
+
}),
|
|
521
|
+
minimumPayout: field4.decimal({
|
|
522
|
+
default: 50,
|
|
523
|
+
description: "Minimum amount for payout"
|
|
524
|
+
}),
|
|
525
|
+
defaultBankAccountId: field4.string({ isOptional: true }),
|
|
526
|
+
createdAt: field4.createdAt(),
|
|
527
|
+
updatedAt: field4.updatedAt(),
|
|
528
|
+
store: field4.belongsTo("Store", ["storeId"], ["id"])
|
|
529
|
+
},
|
|
530
|
+
indexes: [index4.unique(["storeId"])],
|
|
531
|
+
enums: [PayoutScheduleEnum]
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// src/entities/review.ts
|
|
535
|
+
import {
|
|
536
|
+
defineEntity as defineEntity5,
|
|
537
|
+
defineEntityEnum as defineEntityEnum5,
|
|
538
|
+
field as field5,
|
|
539
|
+
index as index5
|
|
540
|
+
} from "@contractspec/lib.schema";
|
|
541
|
+
var ReviewStatusEnum = defineEntityEnum5({
|
|
542
|
+
name: "ReviewStatus",
|
|
543
|
+
values: ["PENDING", "APPROVED", "REJECTED", "FLAGGED"],
|
|
544
|
+
schema: "marketplace",
|
|
545
|
+
description: "Status of a review."
|
|
546
|
+
});
|
|
547
|
+
var ReviewTypeEnum = defineEntityEnum5({
|
|
548
|
+
name: "ReviewType",
|
|
549
|
+
values: ["PRODUCT", "STORE", "ORDER"],
|
|
550
|
+
schema: "marketplace",
|
|
551
|
+
description: "Type of review."
|
|
552
|
+
});
|
|
553
|
+
var ReviewEntity = defineEntity5({
|
|
554
|
+
name: "Review",
|
|
555
|
+
description: "A customer review on the marketplace.",
|
|
556
|
+
schema: "marketplace",
|
|
557
|
+
map: "review",
|
|
558
|
+
fields: {
|
|
559
|
+
id: field5.id({ description: "Unique review ID" }),
|
|
560
|
+
type: field5.enum("ReviewType", { default: "PRODUCT" }),
|
|
561
|
+
productId: field5.string({ isOptional: true }),
|
|
562
|
+
storeId: field5.string({ isOptional: true }),
|
|
563
|
+
orderId: field5.string({ isOptional: true }),
|
|
564
|
+
orderItemId: field5.string({ isOptional: true }),
|
|
565
|
+
authorId: field5.foreignKey({ description: "Reviewer user ID" }),
|
|
566
|
+
rating: field5.int({ description: "Rating 1-5" }),
|
|
567
|
+
title: field5.string({ isOptional: true }),
|
|
568
|
+
content: field5.string({ isOptional: true }),
|
|
569
|
+
isVerifiedPurchase: field5.boolean({ default: false }),
|
|
570
|
+
status: field5.enum("ReviewStatus", { default: "PENDING" }),
|
|
571
|
+
hasMedia: field5.boolean({ default: false }),
|
|
572
|
+
helpfulCount: field5.int({ default: 0 }),
|
|
573
|
+
notHelpfulCount: field5.int({ default: 0 }),
|
|
574
|
+
moderatedBy: field5.string({ isOptional: true }),
|
|
575
|
+
moderatedAt: field5.dateTime({ isOptional: true }),
|
|
576
|
+
moderationNote: field5.string({ isOptional: true }),
|
|
577
|
+
hasResponse: field5.boolean({ default: false }),
|
|
578
|
+
createdAt: field5.createdAt(),
|
|
579
|
+
updatedAt: field5.updatedAt(),
|
|
580
|
+
product: field5.belongsTo("Product", ["productId"], ["id"]),
|
|
581
|
+
store: field5.belongsTo("Store", ["storeId"], ["id"]),
|
|
582
|
+
responses: field5.hasMany("ReviewResponse"),
|
|
583
|
+
votes: field5.hasMany("ReviewVote")
|
|
584
|
+
},
|
|
585
|
+
indexes: [
|
|
586
|
+
index5.on(["productId", "status", "createdAt"]),
|
|
587
|
+
index5.on(["storeId", "status", "createdAt"]),
|
|
588
|
+
index5.on(["authorId"]),
|
|
589
|
+
index5.on(["orderId"]),
|
|
590
|
+
index5.on(["status"]),
|
|
591
|
+
index5.on(["rating"]),
|
|
592
|
+
index5.on(["isVerifiedPurchase", "status"])
|
|
593
|
+
],
|
|
594
|
+
enums: [ReviewStatusEnum, ReviewTypeEnum]
|
|
595
|
+
});
|
|
596
|
+
var ReviewResponseEntity = defineEntity5({
|
|
597
|
+
name: "ReviewResponse",
|
|
598
|
+
description: "A seller response to a review.",
|
|
599
|
+
schema: "marketplace",
|
|
600
|
+
map: "review_response",
|
|
601
|
+
fields: {
|
|
602
|
+
id: field5.id(),
|
|
603
|
+
reviewId: field5.foreignKey(),
|
|
604
|
+
authorId: field5.foreignKey(),
|
|
605
|
+
content: field5.string(),
|
|
606
|
+
createdAt: field5.createdAt(),
|
|
607
|
+
updatedAt: field5.updatedAt(),
|
|
608
|
+
review: field5.belongsTo("Review", ["reviewId"], ["id"], {
|
|
609
|
+
onDelete: "Cascade"
|
|
610
|
+
})
|
|
611
|
+
},
|
|
612
|
+
indexes: [index5.on(["reviewId"]), index5.on(["authorId"])]
|
|
613
|
+
});
|
|
614
|
+
var ReviewVoteEntity = defineEntity5({
|
|
615
|
+
name: "ReviewVote",
|
|
616
|
+
description: "A helpfulness vote on a review.",
|
|
617
|
+
schema: "marketplace",
|
|
618
|
+
map: "review_vote",
|
|
619
|
+
fields: {
|
|
620
|
+
id: field5.id(),
|
|
621
|
+
reviewId: field5.foreignKey(),
|
|
622
|
+
userId: field5.foreignKey(),
|
|
623
|
+
isHelpful: field5.boolean(),
|
|
624
|
+
createdAt: field5.createdAt(),
|
|
625
|
+
review: field5.belongsTo("Review", ["reviewId"], ["id"], {
|
|
626
|
+
onDelete: "Cascade"
|
|
627
|
+
})
|
|
628
|
+
},
|
|
629
|
+
indexes: [index5.unique(["reviewId", "userId"]), index5.on(["userId"])]
|
|
630
|
+
});
|
|
631
|
+
var ReviewReportEntity = defineEntity5({
|
|
632
|
+
name: "ReviewReport",
|
|
633
|
+
description: "A report/flag on a review.",
|
|
634
|
+
schema: "marketplace",
|
|
635
|
+
map: "review_report",
|
|
636
|
+
fields: {
|
|
637
|
+
id: field5.id(),
|
|
638
|
+
reviewId: field5.foreignKey(),
|
|
639
|
+
reporterId: field5.foreignKey(),
|
|
640
|
+
reason: field5.string({ description: "Report reason category" }),
|
|
641
|
+
details: field5.string({ isOptional: true }),
|
|
642
|
+
status: field5.string({ default: '"PENDING"' }),
|
|
643
|
+
resolvedBy: field5.string({ isOptional: true }),
|
|
644
|
+
resolvedAt: field5.dateTime({ isOptional: true }),
|
|
645
|
+
resolution: field5.string({ isOptional: true }),
|
|
646
|
+
createdAt: field5.createdAt(),
|
|
647
|
+
review: field5.belongsTo("Review", ["reviewId"], ["id"])
|
|
648
|
+
},
|
|
649
|
+
indexes: [
|
|
650
|
+
index5.on(["reviewId"]),
|
|
651
|
+
index5.on(["status"]),
|
|
652
|
+
index5.on(["reporterId"])
|
|
653
|
+
]
|
|
654
|
+
});
|
|
655
|
+
// src/entities/index.ts
|
|
656
|
+
var marketplaceEntities = [
|
|
657
|
+
StoreEntity,
|
|
658
|
+
StoreCategoryEntity,
|
|
659
|
+
ProductEntity,
|
|
660
|
+
ProductVariantEntity,
|
|
661
|
+
CategoryEntity,
|
|
662
|
+
OrderEntity,
|
|
663
|
+
OrderItemEntity,
|
|
664
|
+
RefundEntity,
|
|
665
|
+
RefundItemEntity,
|
|
666
|
+
PayoutEntity,
|
|
667
|
+
PayoutItemEntity,
|
|
668
|
+
BankAccountEntity,
|
|
669
|
+
PayoutSettingsEntity,
|
|
670
|
+
ReviewEntity,
|
|
671
|
+
ReviewResponseEntity,
|
|
672
|
+
ReviewVoteEntity,
|
|
673
|
+
ReviewReportEntity
|
|
674
|
+
];
|
|
675
|
+
var marketplaceSchemaContribution = {
|
|
676
|
+
moduleId: "@contractspec/example.marketplace",
|
|
677
|
+
entities: marketplaceEntities,
|
|
678
|
+
enums: [
|
|
679
|
+
StoreStatusEnum,
|
|
680
|
+
StoreTypeEnum,
|
|
681
|
+
ProductStatusEnum,
|
|
682
|
+
ProductTypeEnum,
|
|
683
|
+
OrderStatusEnum,
|
|
684
|
+
PaymentStatusEnum,
|
|
685
|
+
PayoutStatusEnum,
|
|
686
|
+
PayoutScheduleEnum,
|
|
687
|
+
ReviewStatusEnum,
|
|
688
|
+
ReviewTypeEnum
|
|
689
|
+
]
|
|
690
|
+
};
|
|
691
|
+
export {
|
|
692
|
+
marketplaceSchemaContribution,
|
|
693
|
+
marketplaceEntities,
|
|
694
|
+
StoreTypeEnum,
|
|
695
|
+
StoreStatusEnum,
|
|
696
|
+
StoreEntity,
|
|
697
|
+
StoreCategoryEntity,
|
|
698
|
+
ReviewVoteEntity,
|
|
699
|
+
ReviewTypeEnum,
|
|
700
|
+
ReviewStatusEnum,
|
|
701
|
+
ReviewResponseEntity,
|
|
702
|
+
ReviewReportEntity,
|
|
703
|
+
ReviewEntity,
|
|
704
|
+
RefundItemEntity,
|
|
705
|
+
RefundEntity,
|
|
706
|
+
ProductVariantEntity,
|
|
707
|
+
ProductTypeEnum,
|
|
708
|
+
ProductStatusEnum,
|
|
709
|
+
ProductEntity,
|
|
710
|
+
PayoutStatusEnum,
|
|
711
|
+
PayoutSettingsEntity,
|
|
712
|
+
PayoutScheduleEnum,
|
|
713
|
+
PayoutItemEntity,
|
|
714
|
+
PayoutEntity,
|
|
715
|
+
PaymentStatusEnum,
|
|
716
|
+
OrderStatusEnum,
|
|
717
|
+
OrderItemEntity,
|
|
718
|
+
OrderEntity,
|
|
719
|
+
CategoryEntity,
|
|
720
|
+
BankAccountEntity
|
|
721
|
+
};
|