@contractspec/example.marketplace 3.7.6 → 3.7.7
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/README.md +63 -131
- package/dist/browser/entities/index.js +470 -470
- package/dist/browser/index.js +945 -944
- package/dist/browser/order/index.js +155 -155
- package/dist/browser/order/order.event.js +1 -1
- package/dist/browser/payout/index.js +71 -71
- package/dist/browser/payout/payout.event.js +1 -1
- package/dist/browser/product/index.js +104 -104
- package/dist/browser/product/product.event.js +1 -1
- package/dist/browser/review/index.js +75 -75
- package/dist/browser/review/review.event.js +1 -1
- package/dist/browser/store/index.js +68 -68
- package/dist/browser/store/store.event.js +1 -1
- package/dist/browser/ui/MarketplaceDashboard.js +35 -35
- package/dist/browser/ui/hooks/index.js +1 -1
- package/dist/browser/ui/hooks/useMarketplaceData.js +1 -1
- package/dist/browser/ui/index.js +285 -284
- package/dist/entities/index.d.ts +110 -110
- package/dist/entities/index.js +470 -470
- package/dist/index.d.ts +3 -3
- package/dist/index.js +945 -944
- package/dist/node/entities/index.js +470 -470
- package/dist/node/index.js +945 -944
- package/dist/node/order/index.js +155 -155
- package/dist/node/order/order.event.js +1 -1
- package/dist/node/payout/index.js +71 -71
- package/dist/node/payout/payout.event.js +1 -1
- package/dist/node/product/index.js +104 -104
- package/dist/node/product/product.event.js +1 -1
- package/dist/node/review/index.js +75 -75
- package/dist/node/review/review.event.js +1 -1
- package/dist/node/store/index.js +68 -68
- package/dist/node/store/store.event.js +1 -1
- package/dist/node/ui/MarketplaceDashboard.js +35 -35
- package/dist/node/ui/hooks/index.js +1 -1
- package/dist/node/ui/hooks/useMarketplaceData.js +1 -1
- package/dist/node/ui/index.js +285 -284
- package/dist/order/index.d.ts +2 -2
- package/dist/order/index.js +155 -155
- package/dist/order/order.event.js +1 -1
- package/dist/payout/index.d.ts +2 -2
- package/dist/payout/index.js +71 -71
- package/dist/payout/payout.event.js +1 -1
- package/dist/product/index.d.ts +2 -2
- package/dist/product/index.js +104 -104
- package/dist/product/product.event.js +1 -1
- package/dist/review/index.d.ts +2 -2
- package/dist/review/index.js +75 -75
- package/dist/review/review.event.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +68 -68
- package/dist/store/store.event.js +1 -1
- package/dist/ui/MarketplaceDashboard.js +35 -35
- package/dist/ui/hooks/index.d.ts +1 -1
- package/dist/ui/hooks/index.js +1 -1
- package/dist/ui/hooks/useMarketplaceData.js +1 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +285 -284
- package/dist/ui/renderers/index.d.ts +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,141 +1,73 @@
|
|
|
1
1
|
# @contractspec/example.marketplace
|
|
2
2
|
|
|
3
|
-
Website: https://contractspec.io
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
+
**Marketplace example with orders, payouts, and reviews for ContractSpec.**
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## What This Demonstrates
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
- Multi-entity domain modeling (order, payout, product, review, store).
|
|
10
|
+
- Per-entity schema/enum/event/operations/presentation pattern.
|
|
11
|
+
- Capability and feature definition patterns.
|
|
12
|
+
- React UI with hooks, renderers, and dashboard component.
|
|
13
|
+
- Seeder pattern for demo data.
|
|
14
|
+
- Test-spec for operations validation.
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
- **Product Catalog**: Products with variants, categories, and inventory tracking
|
|
12
|
-
- **Order Management**: Full order lifecycle with status tracking
|
|
13
|
-
- **Payment Processing**: Commission calculation and seller payouts
|
|
14
|
-
- **Reviews & Ratings**: Customer feedback with seller responses
|
|
15
|
-
- **File Attachments**: Product images and media using @contractspec/lib.files
|
|
16
|
-
- **Usage Metering**: Platform analytics using @contractspec/lib.metering
|
|
16
|
+
## Running Locally
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- `
|
|
22
|
-
- `StoreCategory` - Store categorization
|
|
23
|
-
|
|
24
|
-
### Product
|
|
25
|
-
- `Product` - Product listing
|
|
26
|
-
- `ProductVariant` - Product variations (size, color)
|
|
27
|
-
- `Category` - Product categorization
|
|
28
|
-
|
|
29
|
-
### Order
|
|
30
|
-
- `Order` - Purchase transaction
|
|
31
|
-
- `OrderItem` - Items in an order
|
|
32
|
-
- `Refund` - Refund records
|
|
33
|
-
- `RefundItem` - Items being refunded
|
|
34
|
-
|
|
35
|
-
### Payout
|
|
36
|
-
- `Payout` - Payment to seller
|
|
37
|
-
- `PayoutItem` - Orders in a payout
|
|
38
|
-
- `BankAccount` - Seller payment destination
|
|
39
|
-
- `PayoutSettings` - Payout configuration
|
|
40
|
-
|
|
41
|
-
### Review
|
|
42
|
-
- `Review` - Customer review
|
|
43
|
-
- `ReviewResponse` - Seller response
|
|
44
|
-
- `ReviewVote` - Helpfulness votes
|
|
45
|
-
- `ReviewReport` - Flagged reviews
|
|
46
|
-
|
|
47
|
-
## Contracts
|
|
48
|
-
|
|
49
|
-
### Store Operations
|
|
50
|
-
- `marketplace.store.create` - Create a seller store
|
|
51
|
-
|
|
52
|
-
### Product Operations
|
|
53
|
-
- `marketplace.product.create` - Create a product
|
|
54
|
-
- `marketplace.product.list` - List/search products
|
|
55
|
-
|
|
56
|
-
### Order Operations
|
|
57
|
-
- `marketplace.order.create` - Create an order
|
|
58
|
-
- `marketplace.order.updateStatus` - Update order status
|
|
59
|
-
|
|
60
|
-
### Payout Operations
|
|
61
|
-
- `marketplace.payout.list` - List payouts
|
|
62
|
-
|
|
63
|
-
### Review Operations
|
|
64
|
-
- `marketplace.review.create` - Create a review
|
|
65
|
-
- `marketplace.review.list` - List reviews
|
|
66
|
-
|
|
67
|
-
## Events
|
|
68
|
-
|
|
69
|
-
- Store: `created`, `statusChanged`
|
|
70
|
-
- Product: `created`, `published`, `inventory.updated`
|
|
71
|
-
- Order: `created`, `paid`, `statusUpdated`, `shipped`, `completed`
|
|
72
|
-
- Payout: `created`, `paid`
|
|
73
|
-
- Review: `created`, `responded`
|
|
74
|
-
|
|
75
|
-
## Commission Model
|
|
76
|
-
|
|
77
|
-
The marketplace uses a configurable commission model:
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
// Default 10% commission
|
|
81
|
-
const commission = calculateCommission(orderTotal, 0.1);
|
|
82
|
-
|
|
83
|
-
// Result:
|
|
84
|
-
{
|
|
85
|
-
subtotal: 100,
|
|
86
|
-
platformFee: 10,
|
|
87
|
-
sellerPayout: 90
|
|
88
|
-
}
|
|
89
|
-
```
|
|
18
|
+
From `packages/examples/marketplace`:
|
|
19
|
+
- `bun run dev`
|
|
20
|
+
- `bun run build`
|
|
21
|
+
- `bun run typecheck`
|
|
90
22
|
|
|
91
23
|
## Usage
|
|
92
24
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
##
|
|
120
|
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
25
|
+
Use `@contractspec/example.marketplace` as a reference implementation, or import its exported surfaces into a workspace that composes ContractSpec examples and bundles.
|
|
26
|
+
|
|
27
|
+
## Architecture
|
|
28
|
+
|
|
29
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
30
|
+
- `src/entities/` contains domain entities and value objects.
|
|
31
|
+
- `src/example.ts` is the runnable example entrypoint.
|
|
32
|
+
- `src/handlers/` contains handlers or demo adapters wired to contract surfaces.
|
|
33
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
34
|
+
- `src/marketplace.capability.ts` defines a capability surface.
|
|
35
|
+
- `src/marketplace.feature.ts` defines a feature entrypoint.
|
|
36
|
+
|
|
37
|
+
## Public Entry Points
|
|
38
|
+
|
|
39
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
40
|
+
- Export `./docs` resolves through `./src/docs/index.ts`.
|
|
41
|
+
- Export `./docs/marketplace.docblock` resolves through `./src/docs/marketplace.docblock.ts`.
|
|
42
|
+
- Export `./entities` resolves through `./src/entities/index.ts`.
|
|
43
|
+
- Export `./entities/order` resolves through `./src/entities/order.ts`.
|
|
44
|
+
- Export `./entities/payout` resolves through `./src/entities/payout.ts`.
|
|
45
|
+
- Export `./entities/product` resolves through `./src/entities/product.ts`.
|
|
46
|
+
- Export `./entities/review` resolves through `./src/entities/review.ts`.
|
|
47
|
+
- Export `./entities/store` resolves through `./src/entities/store.ts`.
|
|
48
|
+
- Export `./example` resolves through `./src/example.ts`.
|
|
49
|
+
- The package publishes 52 total export subpaths; keep docs aligned with `package.json`.
|
|
50
|
+
|
|
51
|
+
## Local Commands
|
|
52
|
+
|
|
53
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
54
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
55
|
+
- `bun run lint` — bun lint:fix
|
|
56
|
+
- `bun run lint:check` — biome check .
|
|
57
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
58
|
+
- `bun run typecheck` — tsc --noEmit
|
|
59
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
60
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
61
|
+
- `bun run clean` — rimraf dist .turbo
|
|
62
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
63
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
64
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
|
65
|
+
|
|
66
|
+
## Recent Updates
|
|
67
|
+
|
|
68
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
69
|
+
- Missing contract layers.
|
|
70
|
+
|
|
71
|
+
## Notes
|
|
72
|
+
|
|
73
|
+
- Works alongside `@contractspec/lib.contracts-spec`, `@contractspec/lib.design-system`, `@contractspec/lib.example-shared-ui`, `@contractspec/lib.runtime-sandbox`, `@contractspec/lib.schema`, ...
|