@contractspec/example.marketplace 3.7.6 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +64 -131
  2. package/dist/browser/entities/index.js +470 -470
  3. package/dist/browser/index.js +1257 -1019
  4. package/dist/browser/marketplace.feature.js +175 -0
  5. package/dist/browser/order/index.js +155 -155
  6. package/dist/browser/order/order.event.js +1 -1
  7. package/dist/browser/payout/index.js +71 -71
  8. package/dist/browser/payout/payout.event.js +1 -1
  9. package/dist/browser/product/index.js +104 -104
  10. package/dist/browser/product/product.event.js +1 -1
  11. package/dist/browser/review/index.js +75 -75
  12. package/dist/browser/review/review.event.js +1 -1
  13. package/dist/browser/store/index.js +68 -68
  14. package/dist/browser/store/store.event.js +1 -1
  15. package/dist/browser/ui/MarketplaceDashboard.js +328 -110
  16. package/dist/browser/ui/MarketplaceDashboard.visualizations.js +216 -0
  17. package/dist/browser/ui/hooks/index.js +1 -1
  18. package/dist/browser/ui/hooks/useMarketplaceData.js +1 -1
  19. package/dist/browser/ui/index.js +590 -359
  20. package/dist/browser/ui/renderers/index.js +190 -4
  21. package/dist/browser/ui/renderers/marketplace.markdown.js +190 -4
  22. package/dist/browser/visualizations/catalog.js +126 -0
  23. package/dist/browser/visualizations/index.js +183 -0
  24. package/dist/browser/visualizations/selectors.js +177 -0
  25. package/dist/entities/index.d.ts +110 -110
  26. package/dist/entities/index.js +470 -470
  27. package/dist/index.d.ts +4 -3
  28. package/dist/index.js +1257 -1019
  29. package/dist/marketplace.feature.js +175 -0
  30. package/dist/node/entities/index.js +470 -470
  31. package/dist/node/index.js +1257 -1019
  32. package/dist/node/marketplace.feature.js +175 -0
  33. package/dist/node/order/index.js +155 -155
  34. package/dist/node/order/order.event.js +1 -1
  35. package/dist/node/payout/index.js +71 -71
  36. package/dist/node/payout/payout.event.js +1 -1
  37. package/dist/node/product/index.js +104 -104
  38. package/dist/node/product/product.event.js +1 -1
  39. package/dist/node/review/index.js +75 -75
  40. package/dist/node/review/review.event.js +1 -1
  41. package/dist/node/store/index.js +68 -68
  42. package/dist/node/store/store.event.js +1 -1
  43. package/dist/node/ui/MarketplaceDashboard.js +328 -110
  44. package/dist/node/ui/MarketplaceDashboard.visualizations.js +216 -0
  45. package/dist/node/ui/hooks/index.js +1 -1
  46. package/dist/node/ui/hooks/useMarketplaceData.js +1 -1
  47. package/dist/node/ui/index.js +590 -359
  48. package/dist/node/ui/renderers/index.js +190 -4
  49. package/dist/node/ui/renderers/marketplace.markdown.js +190 -4
  50. package/dist/node/visualizations/catalog.js +126 -0
  51. package/dist/node/visualizations/index.js +183 -0
  52. package/dist/node/visualizations/selectors.js +177 -0
  53. package/dist/order/index.d.ts +2 -2
  54. package/dist/order/index.js +155 -155
  55. package/dist/order/order.event.js +1 -1
  56. package/dist/payout/index.d.ts +2 -2
  57. package/dist/payout/index.js +71 -71
  58. package/dist/payout/payout.event.js +1 -1
  59. package/dist/product/index.d.ts +2 -2
  60. package/dist/product/index.js +104 -104
  61. package/dist/product/product.event.js +1 -1
  62. package/dist/review/index.d.ts +2 -2
  63. package/dist/review/index.js +75 -75
  64. package/dist/review/review.event.js +1 -1
  65. package/dist/store/index.d.ts +2 -2
  66. package/dist/store/index.js +68 -68
  67. package/dist/store/store.event.js +1 -1
  68. package/dist/ui/MarketplaceDashboard.js +328 -110
  69. package/dist/ui/MarketplaceDashboard.visualizations.d.ts +5 -0
  70. package/dist/ui/MarketplaceDashboard.visualizations.js +217 -0
  71. package/dist/ui/hooks/index.d.ts +1 -1
  72. package/dist/ui/hooks/index.js +1 -1
  73. package/dist/ui/hooks/useMarketplaceData.js +1 -1
  74. package/dist/ui/index.d.ts +2 -2
  75. package/dist/ui/index.js +590 -359
  76. package/dist/ui/renderers/index.d.ts +1 -1
  77. package/dist/ui/renderers/index.js +190 -4
  78. package/dist/ui/renderers/marketplace.markdown.js +190 -4
  79. package/dist/visualizations/catalog.d.ts +10 -0
  80. package/dist/visualizations/catalog.js +127 -0
  81. package/dist/visualizations/index.d.ts +2 -0
  82. package/dist/visualizations/index.js +184 -0
  83. package/dist/visualizations/selectors.d.ts +11 -0
  84. package/dist/visualizations/selectors.js +178 -0
  85. package/dist/visualizations/selectors.test.d.ts +1 -0
  86. package/package.json +66 -10
package/README.md CHANGED
@@ -1,141 +1,74 @@
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
- A comprehensive multi-vendor marketplace example demonstrating ContractSpec principles.
7
+ ## What This Demonstrates
7
8
 
8
- ## Features
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
+ - Contract-backed visualizations for order status, category value comparison, and recent order activity.
14
+ - Seeder pattern for demo data.
15
+ - Test-spec for operations validation.
9
16
 
10
- - **Multi-Vendor Stores**: Seller storefronts with profiles and verification
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
17
+ ## Running Locally
17
18
 
18
- ## Entities
19
-
20
- ### Store
21
- - `Store` - Seller storefront
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
- ```
19
+ From `packages/examples/marketplace`:
20
+ - `bun run dev`
21
+ - `bun run build`
22
+ - `bun run typecheck`
90
23
 
91
24
  ## Usage
92
25
 
93
- ```typescript
94
- import {
95
- CreateOrderContract,
96
- ListProductsContract,
97
- marketplaceSchemaContribution
98
- } from '@contractspec/example.marketplace';
99
-
100
- // List products
101
- const products = await executeQuery(ListProductsContract, {
102
- categoryId: 'electronics',
103
- minPrice: 10,
104
- maxPrice: 100,
105
- limit: 20,
106
- });
107
-
108
- // Create an order
109
- const order = await executeContract(CreateOrderContract, {
110
- storeId: 'store_123',
111
- items: [
112
- { productId: 'prod_456', quantity: 2 },
113
- { productId: 'prod_789', variantId: 'var_abc', quantity: 1 },
114
- ],
115
- shippingAddress: { ... },
116
- });
117
- ```
118
-
119
- ## Dependencies
120
-
121
- - `@contractspec/lib.identity-rbac` - User identity and roles
122
- - `@contractspec/lib.files` - Product images and media
123
- - `@contractspec/lib.metering` - Usage tracking and analytics
124
- - `@contractspec/module.audit-trail` - Action auditing
125
- - `@contractspec/module.notifications` - Order and payout notifications
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
26
+ Use `@contractspec/example.marketplace` as a reference implementation, or import its exported surfaces into a workspace that composes ContractSpec examples and bundles.
27
+
28
+ ## Architecture
29
+
30
+ - `src/docs/` contains docblocks and documentation-facing exports.
31
+ - `src/entities/` contains domain entities and value objects.
32
+ - `src/example.ts` is the runnable example entrypoint.
33
+ - `src/handlers/` contains handlers or demo adapters wired to contract surfaces.
34
+ - `src/index.ts` is the root public barrel and package entrypoint.
35
+ - `src/marketplace.capability.ts` defines a capability surface.
36
+ - `src/marketplace.feature.ts` defines a feature entrypoint.
37
+
38
+ ## Public Entry Points
39
+
40
+ - Export `.` resolves through `./src/index.ts`.
41
+ - Export `./docs` resolves through `./src/docs/index.ts`.
42
+ - Export `./docs/marketplace.docblock` resolves through `./src/docs/marketplace.docblock.ts`.
43
+ - Export `./entities` resolves through `./src/entities/index.ts`.
44
+ - Export `./entities/order` resolves through `./src/entities/order.ts`.
45
+ - Export `./entities/payout` resolves through `./src/entities/payout.ts`.
46
+ - Export `./entities/product` resolves through `./src/entities/product.ts`.
47
+ - Export `./entities/review` resolves through `./src/entities/review.ts`.
48
+ - Export `./entities/store` resolves through `./src/entities/store.ts`.
49
+ - Export `./example` resolves through `./src/example.ts`.
50
+ - The package publishes 52 total export subpaths; keep docs aligned with `package.json`.
51
+
52
+ ## Local Commands
53
+
54
+ - `bun run dev` contractspec-bun-build dev
55
+ - `bun run build` bun run prebuild && bun run build:bundle && bun run build:types
56
+ - `bun run lint` bun lint:fix
57
+ - `bun run lint:check` — biome check .
58
+ - `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
59
+ - `bun run typecheck` — tsc --noEmit
60
+ - `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
61
+ - `bun run publish:pkg:canary` — bun publish:pkg --tag canary
62
+ - `bun run clean` — rimraf dist .turbo
63
+ - `bun run build:bundle` — contractspec-bun-build transpile
64
+ - `bun run build:types` — contractspec-bun-build types
65
+ - `bun run prebuild` — contractspec-bun-build prebuild
66
+
67
+ ## Recent Updates
68
+
69
+ - Replace eslint+prettier by biomejs to optimize speed.
70
+ - Missing contract layers.
71
+
72
+ ## Notes
73
+
74
+ - Works alongside `@contractspec/lib.contracts-spec`, `@contractspec/lib.design-system`, `@contractspec/lib.example-shared-ui`, `@contractspec/lib.runtime-sandbox`, `@contractspec/lib.schema`, ...