@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.
Files changed (60) hide show
  1. package/README.md +63 -131
  2. package/dist/browser/entities/index.js +470 -470
  3. package/dist/browser/index.js +945 -944
  4. package/dist/browser/order/index.js +155 -155
  5. package/dist/browser/order/order.event.js +1 -1
  6. package/dist/browser/payout/index.js +71 -71
  7. package/dist/browser/payout/payout.event.js +1 -1
  8. package/dist/browser/product/index.js +104 -104
  9. package/dist/browser/product/product.event.js +1 -1
  10. package/dist/browser/review/index.js +75 -75
  11. package/dist/browser/review/review.event.js +1 -1
  12. package/dist/browser/store/index.js +68 -68
  13. package/dist/browser/store/store.event.js +1 -1
  14. package/dist/browser/ui/MarketplaceDashboard.js +35 -35
  15. package/dist/browser/ui/hooks/index.js +1 -1
  16. package/dist/browser/ui/hooks/useMarketplaceData.js +1 -1
  17. package/dist/browser/ui/index.js +285 -284
  18. package/dist/entities/index.d.ts +110 -110
  19. package/dist/entities/index.js +470 -470
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +945 -944
  22. package/dist/node/entities/index.js +470 -470
  23. package/dist/node/index.js +945 -944
  24. package/dist/node/order/index.js +155 -155
  25. package/dist/node/order/order.event.js +1 -1
  26. package/dist/node/payout/index.js +71 -71
  27. package/dist/node/payout/payout.event.js +1 -1
  28. package/dist/node/product/index.js +104 -104
  29. package/dist/node/product/product.event.js +1 -1
  30. package/dist/node/review/index.js +75 -75
  31. package/dist/node/review/review.event.js +1 -1
  32. package/dist/node/store/index.js +68 -68
  33. package/dist/node/store/store.event.js +1 -1
  34. package/dist/node/ui/MarketplaceDashboard.js +35 -35
  35. package/dist/node/ui/hooks/index.js +1 -1
  36. package/dist/node/ui/hooks/useMarketplaceData.js +1 -1
  37. package/dist/node/ui/index.js +285 -284
  38. package/dist/order/index.d.ts +2 -2
  39. package/dist/order/index.js +155 -155
  40. package/dist/order/order.event.js +1 -1
  41. package/dist/payout/index.d.ts +2 -2
  42. package/dist/payout/index.js +71 -71
  43. package/dist/payout/payout.event.js +1 -1
  44. package/dist/product/index.d.ts +2 -2
  45. package/dist/product/index.js +104 -104
  46. package/dist/product/product.event.js +1 -1
  47. package/dist/review/index.d.ts +2 -2
  48. package/dist/review/index.js +75 -75
  49. package/dist/review/review.event.js +1 -1
  50. package/dist/store/index.d.ts +2 -2
  51. package/dist/store/index.js +68 -68
  52. package/dist/store/store.event.js +1 -1
  53. package/dist/ui/MarketplaceDashboard.js +35 -35
  54. package/dist/ui/hooks/index.d.ts +1 -1
  55. package/dist/ui/hooks/index.js +1 -1
  56. package/dist/ui/hooks/useMarketplaceData.js +1 -1
  57. package/dist/ui/index.d.ts +2 -2
  58. package/dist/ui/index.js +285 -284
  59. package/dist/ui/renderers/index.d.ts +1 -1
  60. package/package.json +6 -6
@@ -299,345 +299,490 @@ function createMarketplaceHandlers(db) {
299
299
  };
300
300
  }
301
301
 
302
- // src/store/store.enum.ts
302
+ // src/order/order.enum.ts
303
303
  import { defineEnum } from "@contractspec/lib.schema";
304
- var StoreStatusEnum = defineEnum("StoreStatus", [
304
+ var OrderStatusEnum = defineEnum("OrderStatus", [
305
305
  "PENDING",
306
- "ACTIVE",
307
- "SUSPENDED",
308
- "CLOSED"
306
+ "PAID",
307
+ "PROCESSING",
308
+ "SHIPPED",
309
+ "DELIVERED",
310
+ "COMPLETED",
311
+ "CANCELLED",
312
+ "REFUNDED",
313
+ "PARTIALLY_REFUNDED",
314
+ "DISPUTED"
309
315
  ]);
310
316
 
311
- // src/store/store.schema.ts
317
+ // src/order/order.event.ts
318
+ import { defineEvent } from "@contractspec/lib.contracts-spec";
312
319
  import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
313
- var StoreModel = defineSchemaModel({
314
- name: "StoreModel",
315
- description: "A seller store",
320
+ var OrderCreatedPayload = defineSchemaModel({
321
+ name: "OrderCreatedEventPayload",
316
322
  fields: {
317
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
318
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
319
- slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
320
- description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
321
- status: { type: StoreStatusEnum, isOptional: false },
322
- ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
323
- logoFileId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
324
- isVerified: { type: ScalarTypeEnum.Boolean(), isOptional: false },
325
- totalProducts: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
326
- averageRating: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
327
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
323
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
324
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
325
+ buyerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
326
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
327
+ total: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
328
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
329
+ itemCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
330
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
328
331
  }
329
332
  });
330
- var CreateStoreInputModel = defineSchemaModel({
331
- name: "CreateStoreInput",
333
+ var OrderPaidPayload = defineSchemaModel({
334
+ name: "OrderPaidEventPayload",
332
335
  fields: {
333
- name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
334
- slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
335
- description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
336
- email: { type: ScalarTypeEnum.EmailAddress(), isOptional: true },
337
- country: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
338
- currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
336
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
337
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
338
+ total: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
339
+ paymentMethod: {
340
+ type: ScalarTypeEnum.String_unsecure(),
341
+ isOptional: false
342
+ },
343
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
339
344
  }
340
345
  });
341
-
342
- // src/store/store.operations.ts
343
- import { defineCommand } from "@contractspec/lib.contracts-spec/operations";
344
- var OWNERS = ["@example.marketplace"];
345
- var CreateStoreContract = defineCommand({
346
- meta: {
347
- key: "marketplace.store.create",
348
- version: "1.0.0",
349
- stability: "stable",
350
- owners: [...OWNERS],
351
- tags: ["marketplace", "store", "create"],
352
- description: "Create a new seller store.",
353
- goal: "Allow users to become sellers on the marketplace.",
354
- context: "Seller onboarding."
355
- },
356
- io: { input: CreateStoreInputModel, output: StoreModel },
357
- policy: { auth: "user" },
358
- sideEffects: {
359
- emits: [
360
- {
361
- key: "marketplace.store.created",
362
- version: "1.0.0",
363
- when: "Store is created",
364
- payload: StoreModel
365
- }
366
- ],
367
- audit: ["marketplace.store.created"]
368
- },
369
- acceptance: {
370
- scenarios: [
371
- {
372
- key: "create-store-happy-path",
373
- given: ["User is authenticated"],
374
- when: ["User creates a new store"],
375
- then: ["Store is created", "StoreCreated event is emitted"]
376
- }
377
- ],
378
- examples: [
379
- {
380
- key: "create-fashion-store",
381
- input: { name: "Fashion Boutique", category: "clothing" },
382
- output: { id: "store-123", status: "active" }
383
- }
384
- ]
346
+ var OrderStatusUpdatedPayload = defineSchemaModel({
347
+ name: "OrderStatusUpdatedEventPayload",
348
+ fields: {
349
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
350
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
351
+ previousStatus: {
352
+ type: ScalarTypeEnum.String_unsecure(),
353
+ isOptional: false
354
+ },
355
+ newStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
356
+ updatedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
357
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
385
358
  }
386
359
  });
387
-
388
- // src/store/store.event.ts
389
- import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
390
- import { defineEvent } from "@contractspec/lib.contracts-spec";
391
- var StoreCreatedPayload = defineSchemaModel2({
392
- name: "StoreCreatedEventPayload",
360
+ var OrderShippedPayload = defineSchemaModel({
361
+ name: "OrderShippedEventPayload",
393
362
  fields: {
394
- storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
395
- name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
396
- slug: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
397
- ownerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
398
- timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
363
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
364
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
365
+ trackingNumber: {
366
+ type: ScalarTypeEnum.String_unsecure(),
367
+ isOptional: true
368
+ },
369
+ trackingUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
370
+ carrier: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
371
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
399
372
  }
400
373
  });
401
- var StoreStatusChangedPayload = defineSchemaModel2({
402
- name: "StoreStatusChangedEventPayload",
374
+ var OrderCompletedPayload = defineSchemaModel({
375
+ name: "OrderCompletedEventPayload",
403
376
  fields: {
404
- storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
405
- previousStatus: {
406
- type: ScalarTypeEnum2.String_unsecure(),
407
- isOptional: false
408
- },
409
- newStatus: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
410
- reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
411
- timestamp: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
377
+ orderId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
378
+ orderNumber: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
379
+ buyerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
380
+ storeId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
381
+ total: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
382
+ sellerPayout: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
383
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
412
384
  }
413
385
  });
414
- var StoreCreatedEvent = defineEvent({
386
+ var OrderCreatedEvent = defineEvent({
415
387
  meta: {
416
- key: "marketplace.store.created",
388
+ key: "marketplace.order.created",
417
389
  version: "1.0.0",
418
- description: "A new seller store has been created.",
390
+ description: "A new order has been created.",
419
391
  stability: "experimental",
420
392
  owners: ["@marketplace-team"],
421
- tags: ["marketplace", "store"]
393
+ tags: ["marketplace", "order"]
422
394
  },
423
- payload: StoreCreatedPayload
395
+ payload: OrderCreatedPayload
424
396
  });
425
- var StoreStatusChangedEvent = defineEvent({
397
+ var OrderPaidEvent = defineEvent({
426
398
  meta: {
427
- key: "marketplace.store.statusChanged",
399
+ key: "marketplace.order.paid",
428
400
  version: "1.0.0",
429
- description: "A store status has changed.",
401
+ description: "An order has been paid.",
430
402
  stability: "experimental",
431
403
  owners: ["@marketplace-team"],
432
- tags: ["marketplace", "store"]
404
+ tags: ["marketplace", "order"]
433
405
  },
434
- payload: StoreStatusChangedPayload
406
+ payload: OrderPaidPayload
407
+ });
408
+ var OrderStatusUpdatedEvent = defineEvent({
409
+ meta: {
410
+ key: "marketplace.order.statusUpdated",
411
+ version: "1.0.0",
412
+ description: "An order status has been updated.",
413
+ stability: "experimental",
414
+ owners: ["@marketplace-team"],
415
+ tags: ["marketplace", "order"]
416
+ },
417
+ payload: OrderStatusUpdatedPayload
418
+ });
419
+ var OrderShippedEvent = defineEvent({
420
+ meta: {
421
+ key: "marketplace.order.shipped",
422
+ version: "1.0.0",
423
+ description: "An order has been shipped.",
424
+ stability: "experimental",
425
+ owners: ["@marketplace-team"],
426
+ tags: ["marketplace", "order"]
427
+ },
428
+ payload: OrderShippedPayload
429
+ });
430
+ var OrderCompletedEvent = defineEvent({
431
+ meta: {
432
+ key: "marketplace.order.completed",
433
+ version: "1.0.0",
434
+ description: "An order has been completed.",
435
+ stability: "experimental",
436
+ owners: ["@marketplace-team"],
437
+ tags: ["marketplace", "order"]
438
+ },
439
+ payload: OrderCompletedPayload
435
440
  });
436
- // src/product/product.enum.ts
437
- import { defineEnum as defineEnum2 } from "@contractspec/lib.schema";
438
- var ProductStatusEnum = defineEnum2("ProductStatus", [
439
- "DRAFT",
440
- "PENDING_REVIEW",
441
- "ACTIVE",
442
- "OUT_OF_STOCK",
443
- "DISCONTINUED",
444
- "REJECTED"
445
- ]);
446
441
 
447
- // src/product/product.schema.ts
448
- import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
449
- var ProductModel = defineSchemaModel3({
450
- name: "ProductModel",
451
- description: "A product listing",
442
+ // src/order/order.schema.ts
443
+ import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
444
+ var OrderItemModel = defineSchemaModel2({
445
+ name: "OrderItemModel",
452
446
  fields: {
453
- id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
454
- storeId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
455
- name: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
456
- slug: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
457
- description: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
458
- status: { type: ProductStatusEnum, isOptional: false },
459
- price: { type: ScalarTypeEnum3.Float_unsecure(), isOptional: false },
460
- currency: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
461
- quantity: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
462
- categoryId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
463
- primaryImageId: {
464
- type: ScalarTypeEnum3.String_unsecure(),
465
- isOptional: true
466
- },
467
- averageRating: { type: ScalarTypeEnum3.Float_unsecure(), isOptional: false },
468
- totalSold: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
469
- createdAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
447
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
448
+ productId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
449
+ productName: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
450
+ unitPrice: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
451
+ quantity: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
452
+ subtotal: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false }
470
453
  }
471
454
  });
472
- var CreateProductInputModel = defineSchemaModel3({
473
- name: "CreateProductInput",
455
+ var OrderModel = defineSchemaModel2({
456
+ name: "OrderModel",
457
+ description: "An order",
474
458
  fields: {
475
- storeId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
476
- name: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
477
- slug: { type: ScalarTypeEnum3.NonEmptyString(), isOptional: false },
478
- description: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
479
- price: { type: ScalarTypeEnum3.Float_unsecure(), isOptional: false },
480
- currency: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
481
- quantity: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true },
482
- categoryId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
483
- sku: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
459
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
460
+ orderNumber: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
461
+ buyerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
462
+ storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
463
+ status: { type: OrderStatusEnum, isOptional: false },
464
+ subtotal: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
465
+ shippingTotal: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
466
+ taxTotal: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
467
+ total: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
468
+ currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
469
+ items: { type: OrderItemModel, isArray: true, isOptional: true },
470
+ createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
484
471
  }
485
472
  });
486
- var ListProductsInputModel = defineSchemaModel3({
487
- name: "ListProductsInput",
473
+ var CreateOrderInputModel = defineSchemaModel2({
474
+ name: "CreateOrderInput",
488
475
  fields: {
489
- storeId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
490
- categoryId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
491
- status: { type: ProductStatusEnum, isOptional: true },
492
- search: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
493
- minPrice: { type: ScalarTypeEnum3.Float_unsecure(), isOptional: true },
494
- maxPrice: { type: ScalarTypeEnum3.Float_unsecure(), isOptional: true },
495
- limit: {
496
- type: ScalarTypeEnum3.Int_unsecure(),
497
- isOptional: true,
498
- defaultValue: 20
476
+ storeId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
477
+ items: {
478
+ type: ScalarTypeEnum2.JSON(),
479
+ isOptional: false,
480
+ description: "Array of {productId, variantId?, quantity}"
499
481
  },
500
- offset: {
501
- type: ScalarTypeEnum3.Int_unsecure(),
502
- isOptional: true,
503
- defaultValue: 0
504
- }
482
+ shippingAddress: { type: ScalarTypeEnum2.JSON(), isOptional: true },
483
+ billingAddress: { type: ScalarTypeEnum2.JSON(), isOptional: true },
484
+ buyerNote: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
505
485
  }
506
486
  });
507
- var ListProductsOutputModel = defineSchemaModel3({
508
- name: "ListProductsOutput",
487
+ var UpdateOrderStatusInputModel = defineSchemaModel2({
488
+ name: "UpdateOrderStatusInput",
509
489
  fields: {
510
- products: { type: ProductModel, isArray: true, isOptional: false },
511
- total: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false }
490
+ orderId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
491
+ status: { type: OrderStatusEnum, isOptional: false },
492
+ trackingNumber: {
493
+ type: ScalarTypeEnum2.String_unsecure(),
494
+ isOptional: true
495
+ },
496
+ trackingUrl: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
497
+ note: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
512
498
  }
513
499
  });
514
500
 
515
- // src/product/product.operations.ts
516
- import {
517
- defineCommand as defineCommand2,
518
- defineQuery
519
- } from "@contractspec/lib.contracts-spec/operations";
520
- var OWNERS2 = ["@example.marketplace"];
521
- var CreateProductContract = defineCommand2({
501
+ // src/order/order.operations.ts
502
+ import { defineCommand } from "@contractspec/lib.contracts-spec/operations";
503
+ var OWNERS = ["@example.marketplace"];
504
+ var CreateOrderContract = defineCommand({
522
505
  meta: {
523
- key: "marketplace.product.create",
506
+ key: "marketplace.order.create",
524
507
  version: "1.0.0",
525
508
  stability: "stable",
526
- owners: [...OWNERS2],
527
- tags: ["marketplace", "product", "create"],
528
- description: "Create a new product listing.",
529
- goal: "Allow sellers to list products.",
530
- context: "Product management."
509
+ owners: [...OWNERS],
510
+ tags: ["marketplace", "order", "create"],
511
+ description: "Create a new order.",
512
+ goal: "Allow buyers to purchase products.",
513
+ context: "Checkout flow."
531
514
  },
532
- io: { input: CreateProductInputModel, output: ProductModel },
515
+ io: { input: CreateOrderInputModel, output: OrderModel },
533
516
  policy: { auth: "user" },
534
517
  sideEffects: {
535
518
  emits: [
536
519
  {
537
- key: "marketplace.product.created",
520
+ key: "marketplace.order.created",
538
521
  version: "1.0.0",
539
- when: "Product is created",
540
- payload: ProductModel
522
+ when: "Order is created",
523
+ payload: OrderModel
541
524
  }
542
525
  ],
543
- audit: ["marketplace.product.created"]
526
+ audit: ["marketplace.order.created"]
544
527
  },
545
528
  acceptance: {
546
529
  scenarios: [
547
530
  {
548
- key: "create-product-happy-path",
549
- given: ["User is a seller"],
550
- when: ["User creates a product listing"],
551
- then: ["Product is created", "ProductCreated event is emitted"]
531
+ key: "create-order-happy-path",
532
+ given: ["User is authenticated"],
533
+ when: ["User creates order with valid items"],
534
+ then: ["Order is created", "OrderCreated event is emitted"]
552
535
  }
553
536
  ],
554
537
  examples: [
555
538
  {
556
- key: "create-t-shirt",
539
+ key: "create-basic-order",
557
540
  input: {
558
- title: "Classic T-Shirt",
559
- price: 25,
560
- stock: 100,
561
- storeId: "store-123"
541
+ storeId: "store-123",
542
+ items: [{ productId: "prod-456", quantity: 1, unitPrice: 100 }]
562
543
  },
563
- output: {
564
- id: "prod-456",
565
- title: "Classic T-Shirt",
566
- status: "published"
567
- }
544
+ output: { id: "order-789", status: "pending", total: 100 }
568
545
  }
569
546
  ]
570
547
  }
571
548
  });
572
- var ListProductsContract = defineQuery({
549
+ var UpdateOrderStatusContract = defineCommand({
573
550
  meta: {
574
- key: "marketplace.product.list",
551
+ key: "marketplace.order.updateStatus",
575
552
  version: "1.0.0",
576
553
  stability: "stable",
577
- owners: [...OWNERS2],
578
- tags: ["marketplace", "product", "list"],
579
- description: "List products with filters.",
580
- goal: "Browse products on the marketplace.",
581
- context: "Product catalog, search."
554
+ owners: [...OWNERS],
555
+ tags: ["marketplace", "order", "status"],
556
+ description: "Update order status.",
557
+ goal: "Track order fulfillment.",
558
+ context: "Order management."
582
559
  },
583
- io: { input: ListProductsInputModel, output: ListProductsOutputModel },
584
- policy: { auth: "anonymous" },
585
- acceptance: {
586
- scenarios: [
560
+ io: { input: UpdateOrderStatusInputModel, output: OrderModel },
561
+ policy: { auth: "user" },
562
+ sideEffects: {
563
+ emits: [
587
564
  {
588
- key: "list-products-happy-path",
589
- given: ["Products exist"],
590
- when: ["User searches for products"],
591
- then: ["List of products is returned"]
565
+ key: "marketplace.order.statusUpdated",
566
+ version: "1.0.0",
567
+ when: "Status changes",
568
+ payload: OrderModel
569
+ }
570
+ ],
571
+ audit: ["marketplace.order.statusUpdated"]
572
+ },
573
+ acceptance: {
574
+ scenarios: [
575
+ {
576
+ key: "update-status-happy-path",
577
+ given: ["Order exists"],
578
+ when: ["Seller updates order status"],
579
+ then: ["Status is updated", "OrderStatusUpdated event is emitted"]
592
580
  }
593
581
  ],
594
582
  examples: [
595
583
  {
596
- key: "search-t-shirts",
597
- input: { search: "t-shirt", limit: 20 },
598
- output: { items: [], total: 50, hasMore: true }
584
+ key: "mark-shipped",
585
+ input: {
586
+ orderId: "order-789",
587
+ status: "shipped",
588
+ trackingNumber: "TRACK123"
589
+ },
590
+ output: { id: "order-789", status: "shipped" }
599
591
  }
600
592
  ]
601
593
  }
602
594
  });
595
+ // src/payout/payout.enum.ts
596
+ import { defineEnum as defineEnum2 } from "@contractspec/lib.schema";
597
+ var PayoutStatusEnum = defineEnum2("PayoutStatus", [
598
+ "PENDING",
599
+ "PROCESSING",
600
+ "PAID",
601
+ "FAILED",
602
+ "CANCELLED"
603
+ ]);
603
604
 
604
- // src/product/product.event.ts
605
- import { ScalarTypeEnum as ScalarTypeEnum4, defineSchemaModel as defineSchemaModel4 } from "@contractspec/lib.schema";
605
+ // src/payout/payout.event.ts
606
606
  import { defineEvent as defineEvent2 } from "@contractspec/lib.contracts-spec";
607
- var ProductCreatedPayload = defineSchemaModel4({
608
- name: "ProductCreatedEventPayload",
607
+ import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
608
+ var PayoutCreatedPayload = defineSchemaModel3({
609
+ name: "PayoutCreatedEventPayload",
610
+ fields: {
611
+ payoutId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
612
+ payoutNumber: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
613
+ storeId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
614
+ netAmount: { type: ScalarTypeEnum3.Float_unsecure(), isOptional: false },
615
+ currency: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
616
+ orderCount: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
617
+ timestamp: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
618
+ }
619
+ });
620
+ var PayoutPaidPayload = defineSchemaModel3({
621
+ name: "PayoutPaidEventPayload",
622
+ fields: {
623
+ payoutId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
624
+ payoutNumber: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
625
+ storeId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
626
+ netAmount: { type: ScalarTypeEnum3.Float_unsecure(), isOptional: false },
627
+ paymentReference: {
628
+ type: ScalarTypeEnum3.String_unsecure(),
629
+ isOptional: true
630
+ },
631
+ timestamp: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
632
+ }
633
+ });
634
+ var PayoutCreatedEvent = defineEvent2({
635
+ meta: {
636
+ key: "marketplace.payout.created",
637
+ version: "1.0.0",
638
+ description: "A payout has been created.",
639
+ stability: "experimental",
640
+ owners: ["@marketplace-team"],
641
+ tags: ["marketplace", "payout"]
642
+ },
643
+ payload: PayoutCreatedPayload
644
+ });
645
+ var PayoutPaidEvent = defineEvent2({
646
+ meta: {
647
+ key: "marketplace.payout.paid",
648
+ version: "1.0.0",
649
+ description: "A payout has been sent.",
650
+ stability: "experimental",
651
+ owners: ["@marketplace-team"],
652
+ tags: ["marketplace", "payout"]
653
+ },
654
+ payload: PayoutPaidPayload
655
+ });
656
+
657
+ // src/payout/payout.schema.ts
658
+ import { defineSchemaModel as defineSchemaModel4, ScalarTypeEnum as ScalarTypeEnum4 } from "@contractspec/lib.schema";
659
+ var PayoutModel = defineSchemaModel4({
660
+ name: "PayoutModel",
661
+ description: "A payout to seller",
609
662
  fields: {
610
- productId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
663
+ id: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
664
+ payoutNumber: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
611
665
  storeId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
612
- name: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
613
- price: { type: ScalarTypeEnum4.Float_unsecure(), isOptional: false },
666
+ status: { type: PayoutStatusEnum, isOptional: false },
667
+ grossAmount: { type: ScalarTypeEnum4.Float_unsecure(), isOptional: false },
668
+ platformFees: { type: ScalarTypeEnum4.Float_unsecure(), isOptional: false },
669
+ netAmount: { type: ScalarTypeEnum4.Float_unsecure(), isOptional: false },
614
670
  currency: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
615
- timestamp: { type: ScalarTypeEnum4.DateTime(), isOptional: false }
671
+ periodStart: { type: ScalarTypeEnum4.DateTime(), isOptional: false },
672
+ periodEnd: { type: ScalarTypeEnum4.DateTime(), isOptional: false },
673
+ orderCount: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: false },
674
+ createdAt: { type: ScalarTypeEnum4.DateTime(), isOptional: false },
675
+ paidAt: { type: ScalarTypeEnum4.DateTime(), isOptional: true }
616
676
  }
617
677
  });
618
- var ProductPublishedPayload = defineSchemaModel4({
619
- name: "ProductPublishedEventPayload",
678
+ var ListPayoutsInputModel = defineSchemaModel4({
679
+ name: "ListPayoutsInput",
620
680
  fields: {
621
- productId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
622
681
  storeId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
623
- timestamp: { type: ScalarTypeEnum4.DateTime(), isOptional: false }
682
+ status: { type: PayoutStatusEnum, isOptional: true },
683
+ limit: {
684
+ type: ScalarTypeEnum4.Int_unsecure(),
685
+ isOptional: true,
686
+ defaultValue: 20
687
+ },
688
+ offset: {
689
+ type: ScalarTypeEnum4.Int_unsecure(),
690
+ isOptional: true,
691
+ defaultValue: 0
692
+ }
693
+ }
694
+ });
695
+ var ListPayoutsOutputModel = defineSchemaModel4({
696
+ name: "ListPayoutsOutput",
697
+ fields: {
698
+ payouts: { type: PayoutModel, isArray: true, isOptional: false },
699
+ total: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: false },
700
+ totalPending: { type: ScalarTypeEnum4.Float_unsecure(), isOptional: false }
701
+ }
702
+ });
703
+
704
+ // src/payout/payout.operations.ts
705
+ import { defineQuery } from "@contractspec/lib.contracts-spec/operations";
706
+ var OWNERS2 = ["@example.marketplace"];
707
+ var ListPayoutsContract = defineQuery({
708
+ meta: {
709
+ key: "marketplace.payout.list",
710
+ version: "1.0.0",
711
+ stability: "stable",
712
+ owners: [...OWNERS2],
713
+ tags: ["marketplace", "payout", "list"],
714
+ description: "List payouts for a store.",
715
+ goal: "View payout history.",
716
+ context: "Seller dashboard."
717
+ },
718
+ io: { input: ListPayoutsInputModel, output: ListPayoutsOutputModel },
719
+ policy: { auth: "user" },
720
+ acceptance: {
721
+ scenarios: [
722
+ {
723
+ key: "list-payouts-happy-path",
724
+ given: ["Store has payout history"],
725
+ when: ["Seller lists payouts"],
726
+ then: ["List of payouts is returned"]
727
+ }
728
+ ],
729
+ examples: [
730
+ {
731
+ key: "list-recent",
732
+ input: { limit: 10, offset: 0 },
733
+ output: { items: [], total: 5, hasMore: false }
734
+ }
735
+ ]
736
+ }
737
+ });
738
+ // src/product/product.enum.ts
739
+ import { defineEnum as defineEnum3 } from "@contractspec/lib.schema";
740
+ var ProductStatusEnum = defineEnum3("ProductStatus", [
741
+ "DRAFT",
742
+ "PENDING_REVIEW",
743
+ "ACTIVE",
744
+ "OUT_OF_STOCK",
745
+ "DISCONTINUED",
746
+ "REJECTED"
747
+ ]);
748
+
749
+ // src/product/product.event.ts
750
+ import { defineEvent as defineEvent3 } from "@contractspec/lib.contracts-spec";
751
+ import { defineSchemaModel as defineSchemaModel5, ScalarTypeEnum as ScalarTypeEnum5 } from "@contractspec/lib.schema";
752
+ var ProductCreatedPayload = defineSchemaModel5({
753
+ name: "ProductCreatedEventPayload",
754
+ fields: {
755
+ productId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
756
+ storeId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
757
+ name: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
758
+ price: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
759
+ currency: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
760
+ timestamp: { type: ScalarTypeEnum5.DateTime(), isOptional: false }
761
+ }
762
+ });
763
+ var ProductPublishedPayload = defineSchemaModel5({
764
+ name: "ProductPublishedEventPayload",
765
+ fields: {
766
+ productId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
767
+ storeId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
768
+ timestamp: { type: ScalarTypeEnum5.DateTime(), isOptional: false }
624
769
  }
625
770
  });
626
- var InventoryUpdatedPayload = defineSchemaModel4({
771
+ var InventoryUpdatedPayload = defineSchemaModel5({
627
772
  name: "InventoryUpdatedEventPayload",
628
773
  fields: {
629
- productId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
630
- variantId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
774
+ productId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
775
+ variantId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
631
776
  previousQuantity: {
632
- type: ScalarTypeEnum4.Int_unsecure(),
777
+ type: ScalarTypeEnum5.Int_unsecure(),
633
778
  isOptional: false
634
779
  },
635
- newQuantity: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: false },
636
- reason: { type: ScalarTypeEnum4.String_unsecure(), isOptional: false },
637
- timestamp: { type: ScalarTypeEnum4.DateTime(), isOptional: false }
780
+ newQuantity: { type: ScalarTypeEnum5.Int_unsecure(), isOptional: false },
781
+ reason: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
782
+ timestamp: { type: ScalarTypeEnum5.DateTime(), isOptional: false }
638
783
  }
639
784
  });
640
- var ProductCreatedEvent = defineEvent2({
785
+ var ProductCreatedEvent = defineEvent3({
641
786
  meta: {
642
787
  key: "marketplace.product.created",
643
788
  version: "1.0.0",
@@ -648,7 +793,7 @@ var ProductCreatedEvent = defineEvent2({
648
793
  },
649
794
  payload: ProductCreatedPayload
650
795
  });
651
- var ProductPublishedEvent = defineEvent2({
796
+ var ProductPublishedEvent = defineEvent3({
652
797
  meta: {
653
798
  key: "marketplace.product.published",
654
799
  version: "1.0.0",
@@ -659,7 +804,7 @@ var ProductPublishedEvent = defineEvent2({
659
804
  },
660
805
  payload: ProductPublishedPayload
661
806
  });
662
- var InventoryUpdatedEvent = defineEvent2({
807
+ var InventoryUpdatedEvent = defineEvent3({
663
808
  meta: {
664
809
  key: "marketplace.inventory.updated",
665
810
  version: "1.0.0",
@@ -670,523 +815,291 @@ var InventoryUpdatedEvent = defineEvent2({
670
815
  },
671
816
  payload: InventoryUpdatedPayload
672
817
  });
673
- // src/order/order.enum.ts
674
- import { defineEnum as defineEnum3 } from "@contractspec/lib.schema";
675
- var OrderStatusEnum = defineEnum3("OrderStatus", [
676
- "PENDING",
677
- "PAID",
678
- "PROCESSING",
679
- "SHIPPED",
680
- "DELIVERED",
681
- "COMPLETED",
682
- "CANCELLED",
683
- "REFUNDED",
684
- "PARTIALLY_REFUNDED",
685
- "DISPUTED"
686
- ]);
687
818
 
688
- // src/order/order.schema.ts
689
- import { defineSchemaModel as defineSchemaModel5, ScalarTypeEnum as ScalarTypeEnum5 } from "@contractspec/lib.schema";
690
- var OrderItemModel = defineSchemaModel5({
691
- name: "OrderItemModel",
819
+ // src/product/product.schema.ts
820
+ import { defineSchemaModel as defineSchemaModel6, ScalarTypeEnum as ScalarTypeEnum6 } from "@contractspec/lib.schema";
821
+ var ProductModel = defineSchemaModel6({
822
+ name: "ProductModel",
823
+ description: "A product listing",
692
824
  fields: {
693
- id: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
694
- productId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
695
- productName: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
696
- unitPrice: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
697
- quantity: { type: ScalarTypeEnum5.Int_unsecure(), isOptional: false },
698
- subtotal: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false }
825
+ id: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
826
+ storeId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
827
+ name: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
828
+ slug: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
829
+ description: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
830
+ status: { type: ProductStatusEnum, isOptional: false },
831
+ price: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
832
+ currency: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
833
+ quantity: { type: ScalarTypeEnum6.Int_unsecure(), isOptional: false },
834
+ categoryId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
835
+ primaryImageId: {
836
+ type: ScalarTypeEnum6.String_unsecure(),
837
+ isOptional: true
838
+ },
839
+ averageRating: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
840
+ totalSold: { type: ScalarTypeEnum6.Int_unsecure(), isOptional: false },
841
+ createdAt: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
699
842
  }
700
843
  });
701
- var OrderModel = defineSchemaModel5({
702
- name: "OrderModel",
703
- description: "An order",
844
+ var CreateProductInputModel = defineSchemaModel6({
845
+ name: "CreateProductInput",
704
846
  fields: {
705
- id: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
706
- orderNumber: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
707
- buyerId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
708
- storeId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
709
- status: { type: OrderStatusEnum, isOptional: false },
710
- subtotal: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
711
- shippingTotal: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
712
- taxTotal: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
713
- total: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
714
- currency: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
715
- items: { type: OrderItemModel, isArray: true, isOptional: true },
716
- createdAt: { type: ScalarTypeEnum5.DateTime(), isOptional: false }
847
+ storeId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
848
+ name: { type: ScalarTypeEnum6.NonEmptyString(), isOptional: false },
849
+ slug: { type: ScalarTypeEnum6.NonEmptyString(), isOptional: false },
850
+ description: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
851
+ price: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
852
+ currency: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
853
+ quantity: { type: ScalarTypeEnum6.Int_unsecure(), isOptional: true },
854
+ categoryId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
855
+ sku: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true }
717
856
  }
718
857
  });
719
- var CreateOrderInputModel = defineSchemaModel5({
720
- name: "CreateOrderInput",
858
+ var ListProductsInputModel = defineSchemaModel6({
859
+ name: "ListProductsInput",
721
860
  fields: {
722
- storeId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
723
- items: {
724
- type: ScalarTypeEnum5.JSON(),
725
- isOptional: false,
726
- description: "Array of {productId, variantId?, quantity}"
861
+ storeId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
862
+ categoryId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
863
+ status: { type: ProductStatusEnum, isOptional: true },
864
+ search: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
865
+ minPrice: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: true },
866
+ maxPrice: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: true },
867
+ limit: {
868
+ type: ScalarTypeEnum6.Int_unsecure(),
869
+ isOptional: true,
870
+ defaultValue: 20
727
871
  },
728
- shippingAddress: { type: ScalarTypeEnum5.JSON(), isOptional: true },
729
- billingAddress: { type: ScalarTypeEnum5.JSON(), isOptional: true },
730
- buyerNote: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true }
872
+ offset: {
873
+ type: ScalarTypeEnum6.Int_unsecure(),
874
+ isOptional: true,
875
+ defaultValue: 0
876
+ }
731
877
  }
732
878
  });
733
- var UpdateOrderStatusInputModel = defineSchemaModel5({
734
- name: "UpdateOrderStatusInput",
879
+ var ListProductsOutputModel = defineSchemaModel6({
880
+ name: "ListProductsOutput",
735
881
  fields: {
736
- orderId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
737
- status: { type: OrderStatusEnum, isOptional: false },
738
- trackingNumber: {
739
- type: ScalarTypeEnum5.String_unsecure(),
740
- isOptional: true
741
- },
742
- trackingUrl: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
743
- note: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true }
882
+ products: { type: ProductModel, isArray: true, isOptional: false },
883
+ total: { type: ScalarTypeEnum6.Int_unsecure(), isOptional: false }
744
884
  }
745
885
  });
746
886
 
747
- // src/order/order.operations.ts
748
- import { defineCommand as defineCommand3 } from "@contractspec/lib.contracts-spec/operations";
887
+ // src/product/product.operations.ts
888
+ import {
889
+ defineCommand as defineCommand2,
890
+ defineQuery as defineQuery2
891
+ } from "@contractspec/lib.contracts-spec/operations";
749
892
  var OWNERS3 = ["@example.marketplace"];
750
- var CreateOrderContract = defineCommand3({
893
+ var CreateProductContract = defineCommand2({
751
894
  meta: {
752
- key: "marketplace.order.create",
895
+ key: "marketplace.product.create",
753
896
  version: "1.0.0",
754
897
  stability: "stable",
755
898
  owners: [...OWNERS3],
756
- tags: ["marketplace", "order", "create"],
757
- description: "Create a new order.",
758
- goal: "Allow buyers to purchase products.",
759
- context: "Checkout flow."
899
+ tags: ["marketplace", "product", "create"],
900
+ description: "Create a new product listing.",
901
+ goal: "Allow sellers to list products.",
902
+ context: "Product management."
760
903
  },
761
- io: { input: CreateOrderInputModel, output: OrderModel },
904
+ io: { input: CreateProductInputModel, output: ProductModel },
762
905
  policy: { auth: "user" },
763
906
  sideEffects: {
764
907
  emits: [
765
908
  {
766
- key: "marketplace.order.created",
909
+ key: "marketplace.product.created",
767
910
  version: "1.0.0",
768
- when: "Order is created",
769
- payload: OrderModel
911
+ when: "Product is created",
912
+ payload: ProductModel
770
913
  }
771
914
  ],
772
- audit: ["marketplace.order.created"]
915
+ audit: ["marketplace.product.created"]
773
916
  },
774
917
  acceptance: {
775
918
  scenarios: [
776
919
  {
777
- key: "create-order-happy-path",
778
- given: ["User is authenticated"],
779
- when: ["User creates order with valid items"],
780
- then: ["Order is created", "OrderCreated event is emitted"]
920
+ key: "create-product-happy-path",
921
+ given: ["User is a seller"],
922
+ when: ["User creates a product listing"],
923
+ then: ["Product is created", "ProductCreated event is emitted"]
781
924
  }
782
925
  ],
783
926
  examples: [
784
927
  {
785
- key: "create-basic-order",
928
+ key: "create-t-shirt",
786
929
  input: {
787
- storeId: "store-123",
788
- items: [{ productId: "prod-456", quantity: 1, unitPrice: 100 }]
930
+ title: "Classic T-Shirt",
931
+ price: 25,
932
+ stock: 100,
933
+ storeId: "store-123"
789
934
  },
790
- output: { id: "order-789", status: "pending", total: 100 }
935
+ output: {
936
+ id: "prod-456",
937
+ title: "Classic T-Shirt",
938
+ status: "published"
939
+ }
791
940
  }
792
941
  ]
793
942
  }
794
943
  });
795
- var UpdateOrderStatusContract = defineCommand3({
944
+ var ListProductsContract = defineQuery2({
796
945
  meta: {
797
- key: "marketplace.order.updateStatus",
946
+ key: "marketplace.product.list",
798
947
  version: "1.0.0",
799
948
  stability: "stable",
800
949
  owners: [...OWNERS3],
801
- tags: ["marketplace", "order", "status"],
802
- description: "Update order status.",
803
- goal: "Track order fulfillment.",
804
- context: "Order management."
805
- },
806
- io: { input: UpdateOrderStatusInputModel, output: OrderModel },
807
- policy: { auth: "user" },
808
- sideEffects: {
809
- emits: [
810
- {
811
- key: "marketplace.order.statusUpdated",
812
- version: "1.0.0",
813
- when: "Status changes",
814
- payload: OrderModel
815
- }
816
- ],
817
- audit: ["marketplace.order.statusUpdated"]
950
+ tags: ["marketplace", "product", "list"],
951
+ description: "List products with filters.",
952
+ goal: "Browse products on the marketplace.",
953
+ context: "Product catalog, search."
818
954
  },
955
+ io: { input: ListProductsInputModel, output: ListProductsOutputModel },
956
+ policy: { auth: "anonymous" },
819
957
  acceptance: {
820
958
  scenarios: [
821
959
  {
822
- key: "update-status-happy-path",
823
- given: ["Order exists"],
824
- when: ["Seller updates order status"],
825
- then: ["Status is updated", "OrderStatusUpdated event is emitted"]
960
+ key: "list-products-happy-path",
961
+ given: ["Products exist"],
962
+ when: ["User searches for products"],
963
+ then: ["List of products is returned"]
826
964
  }
827
965
  ],
828
966
  examples: [
829
967
  {
830
- key: "mark-shipped",
831
- input: {
832
- orderId: "order-789",
833
- status: "shipped",
834
- trackingNumber: "TRACK123"
835
- },
836
- output: { id: "order-789", status: "shipped" }
968
+ key: "search-t-shirts",
969
+ input: { search: "t-shirt", limit: 20 },
970
+ output: { items: [], total: 50, hasMore: true }
837
971
  }
838
972
  ]
839
973
  }
840
974
  });
841
-
842
- // src/order/order.event.ts
843
- import { ScalarTypeEnum as ScalarTypeEnum6, defineSchemaModel as defineSchemaModel6 } from "@contractspec/lib.schema";
844
- import { defineEvent as defineEvent3 } from "@contractspec/lib.contracts-spec";
845
- var OrderCreatedPayload = defineSchemaModel6({
846
- name: "OrderCreatedEventPayload",
847
- fields: {
848
- orderId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
849
- orderNumber: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
850
- buyerId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
851
- storeId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
852
- total: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
853
- currency: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
854
- itemCount: { type: ScalarTypeEnum6.Int_unsecure(), isOptional: false },
855
- timestamp: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
856
- }
857
- });
858
- var OrderPaidPayload = defineSchemaModel6({
859
- name: "OrderPaidEventPayload",
860
- fields: {
861
- orderId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
862
- orderNumber: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
863
- total: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
864
- paymentMethod: {
865
- type: ScalarTypeEnum6.String_unsecure(),
866
- isOptional: false
867
- },
868
- timestamp: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
869
- }
870
- });
871
- var OrderStatusUpdatedPayload = defineSchemaModel6({
872
- name: "OrderStatusUpdatedEventPayload",
873
- fields: {
874
- orderId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
875
- orderNumber: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
876
- previousStatus: {
877
- type: ScalarTypeEnum6.String_unsecure(),
878
- isOptional: false
879
- },
880
- newStatus: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
881
- updatedBy: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
882
- timestamp: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
883
- }
884
- });
885
- var OrderShippedPayload = defineSchemaModel6({
886
- name: "OrderShippedEventPayload",
887
- fields: {
888
- orderId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
889
- orderNumber: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
890
- trackingNumber: {
891
- type: ScalarTypeEnum6.String_unsecure(),
892
- isOptional: true
893
- },
894
- trackingUrl: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
895
- carrier: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
896
- timestamp: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
897
- }
898
- });
899
- var OrderCompletedPayload = defineSchemaModel6({
900
- name: "OrderCompletedEventPayload",
901
- fields: {
902
- orderId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
903
- orderNumber: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
904
- buyerId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
905
- storeId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
906
- total: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
907
- sellerPayout: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
908
- timestamp: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
909
- }
910
- });
911
- var OrderCreatedEvent = defineEvent3({
912
- meta: {
913
- key: "marketplace.order.created",
914
- version: "1.0.0",
915
- description: "A new order has been created.",
916
- stability: "experimental",
917
- owners: ["@marketplace-team"],
918
- tags: ["marketplace", "order"]
919
- },
920
- payload: OrderCreatedPayload
921
- });
922
- var OrderPaidEvent = defineEvent3({
923
- meta: {
924
- key: "marketplace.order.paid",
925
- version: "1.0.0",
926
- description: "An order has been paid.",
927
- stability: "experimental",
928
- owners: ["@marketplace-team"],
929
- tags: ["marketplace", "order"]
930
- },
931
- payload: OrderPaidPayload
932
- });
933
- var OrderStatusUpdatedEvent = defineEvent3({
934
- meta: {
935
- key: "marketplace.order.statusUpdated",
936
- version: "1.0.0",
937
- description: "An order status has been updated.",
938
- stability: "experimental",
939
- owners: ["@marketplace-team"],
940
- tags: ["marketplace", "order"]
941
- },
942
- payload: OrderStatusUpdatedPayload
943
- });
944
- var OrderShippedEvent = defineEvent3({
945
- meta: {
946
- key: "marketplace.order.shipped",
947
- version: "1.0.0",
948
- description: "An order has been shipped.",
949
- stability: "experimental",
950
- owners: ["@marketplace-team"],
951
- tags: ["marketplace", "order"]
952
- },
953
- payload: OrderShippedPayload
954
- });
955
- var OrderCompletedEvent = defineEvent3({
956
- meta: {
957
- key: "marketplace.order.completed",
958
- version: "1.0.0",
959
- description: "An order has been completed.",
960
- stability: "experimental",
961
- owners: ["@marketplace-team"],
962
- tags: ["marketplace", "order"]
963
- },
964
- payload: OrderCompletedPayload
965
- });
966
- // src/payout/payout.enum.ts
975
+ // src/review/review.enum.ts
967
976
  import { defineEnum as defineEnum4 } from "@contractspec/lib.schema";
968
- var PayoutStatusEnum = defineEnum4("PayoutStatus", [
977
+ var ReviewStatusEnum = defineEnum4("ReviewStatus", [
969
978
  "PENDING",
970
- "PROCESSING",
971
- "PAID",
972
- "FAILED",
973
- "CANCELLED"
979
+ "APPROVED",
980
+ "REJECTED",
981
+ "FLAGGED"
974
982
  ]);
975
983
 
976
- // src/payout/payout.schema.ts
977
- import { defineSchemaModel as defineSchemaModel7, ScalarTypeEnum as ScalarTypeEnum7 } from "@contractspec/lib.schema";
978
- var PayoutModel = defineSchemaModel7({
979
- name: "PayoutModel",
980
- description: "A payout to seller",
981
- fields: {
982
- id: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
983
- payoutNumber: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
984
- storeId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
985
- status: { type: PayoutStatusEnum, isOptional: false },
986
- grossAmount: { type: ScalarTypeEnum7.Float_unsecure(), isOptional: false },
987
- platformFees: { type: ScalarTypeEnum7.Float_unsecure(), isOptional: false },
988
- netAmount: { type: ScalarTypeEnum7.Float_unsecure(), isOptional: false },
989
- currency: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
990
- periodStart: { type: ScalarTypeEnum7.DateTime(), isOptional: false },
991
- periodEnd: { type: ScalarTypeEnum7.DateTime(), isOptional: false },
992
- orderCount: { type: ScalarTypeEnum7.Int_unsecure(), isOptional: false },
993
- createdAt: { type: ScalarTypeEnum7.DateTime(), isOptional: false },
994
- paidAt: { type: ScalarTypeEnum7.DateTime(), isOptional: true }
995
- }
996
- });
997
- var ListPayoutsInputModel = defineSchemaModel7({
998
- name: "ListPayoutsInput",
999
- fields: {
1000
- storeId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
1001
- status: { type: PayoutStatusEnum, isOptional: true },
1002
- limit: {
1003
- type: ScalarTypeEnum7.Int_unsecure(),
1004
- isOptional: true,
1005
- defaultValue: 20
1006
- },
1007
- offset: {
1008
- type: ScalarTypeEnum7.Int_unsecure(),
1009
- isOptional: true,
1010
- defaultValue: 0
1011
- }
1012
- }
1013
- });
1014
- var ListPayoutsOutputModel = defineSchemaModel7({
1015
- name: "ListPayoutsOutput",
1016
- fields: {
1017
- payouts: { type: PayoutModel, isArray: true, isOptional: false },
1018
- total: { type: ScalarTypeEnum7.Int_unsecure(), isOptional: false },
1019
- totalPending: { type: ScalarTypeEnum7.Float_unsecure(), isOptional: false }
1020
- }
1021
- });
1022
-
1023
- // src/payout/payout.operations.ts
1024
- import { defineQuery as defineQuery2 } from "@contractspec/lib.contracts-spec/operations";
1025
- var OWNERS4 = ["@example.marketplace"];
1026
- var ListPayoutsContract = defineQuery2({
1027
- meta: {
1028
- key: "marketplace.payout.list",
1029
- version: "1.0.0",
1030
- stability: "stable",
1031
- owners: [...OWNERS4],
1032
- tags: ["marketplace", "payout", "list"],
1033
- description: "List payouts for a store.",
1034
- goal: "View payout history.",
1035
- context: "Seller dashboard."
1036
- },
1037
- io: { input: ListPayoutsInputModel, output: ListPayoutsOutputModel },
1038
- policy: { auth: "user" },
1039
- acceptance: {
1040
- scenarios: [
1041
- {
1042
- key: "list-payouts-happy-path",
1043
- given: ["Store has payout history"],
1044
- when: ["Seller lists payouts"],
1045
- then: ["List of payouts is returned"]
1046
- }
1047
- ],
1048
- examples: [
1049
- {
1050
- key: "list-recent",
1051
- input: { limit: 10, offset: 0 },
1052
- output: { items: [], total: 5, hasMore: false }
1053
- }
1054
- ]
1055
- }
1056
- });
1057
-
1058
- // src/payout/payout.event.ts
1059
- import { ScalarTypeEnum as ScalarTypeEnum8, defineSchemaModel as defineSchemaModel8 } from "@contractspec/lib.schema";
984
+ // src/review/review.event.ts
1060
985
  import { defineEvent as defineEvent4 } from "@contractspec/lib.contracts-spec";
1061
- var PayoutCreatedPayload = defineSchemaModel8({
1062
- name: "PayoutCreatedEventPayload",
986
+ import { defineSchemaModel as defineSchemaModel7, ScalarTypeEnum as ScalarTypeEnum7 } from "@contractspec/lib.schema";
987
+ var ReviewCreatedPayload = defineSchemaModel7({
988
+ name: "ReviewCreatedEventPayload",
1063
989
  fields: {
1064
- payoutId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1065
- payoutNumber: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1066
- storeId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1067
- netAmount: { type: ScalarTypeEnum8.Float_unsecure(), isOptional: false },
1068
- currency: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1069
- orderCount: { type: ScalarTypeEnum8.Int_unsecure(), isOptional: false },
1070
- timestamp: { type: ScalarTypeEnum8.DateTime(), isOptional: false }
990
+ reviewId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
991
+ productId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
992
+ storeId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: true },
993
+ authorId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
994
+ rating: { type: ScalarTypeEnum7.Int_unsecure(), isOptional: false },
995
+ isVerifiedPurchase: { type: ScalarTypeEnum7.Boolean(), isOptional: false },
996
+ timestamp: { type: ScalarTypeEnum7.DateTime(), isOptional: false }
1071
997
  }
1072
998
  });
1073
- var PayoutPaidPayload = defineSchemaModel8({
1074
- name: "PayoutPaidEventPayload",
999
+ var ReviewRespondedPayload = defineSchemaModel7({
1000
+ name: "ReviewRespondedEventPayload",
1075
1001
  fields: {
1076
- payoutId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1077
- payoutNumber: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1078
- storeId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1079
- netAmount: { type: ScalarTypeEnum8.Float_unsecure(), isOptional: false },
1080
- paymentReference: {
1081
- type: ScalarTypeEnum8.String_unsecure(),
1082
- isOptional: true
1083
- },
1084
- timestamp: { type: ScalarTypeEnum8.DateTime(), isOptional: false }
1002
+ reviewId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
1003
+ responseId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
1004
+ authorId: { type: ScalarTypeEnum7.String_unsecure(), isOptional: false },
1005
+ timestamp: { type: ScalarTypeEnum7.DateTime(), isOptional: false }
1085
1006
  }
1086
1007
  });
1087
- var PayoutCreatedEvent = defineEvent4({
1008
+ var ReviewCreatedEvent = defineEvent4({
1088
1009
  meta: {
1089
- key: "marketplace.payout.created",
1010
+ key: "marketplace.review.created",
1090
1011
  version: "1.0.0",
1091
- description: "A payout has been created.",
1012
+ description: "A review has been created.",
1092
1013
  stability: "experimental",
1093
1014
  owners: ["@marketplace-team"],
1094
- tags: ["marketplace", "payout"]
1015
+ tags: ["marketplace", "review"]
1095
1016
  },
1096
- payload: PayoutCreatedPayload
1017
+ payload: ReviewCreatedPayload
1097
1018
  });
1098
- var PayoutPaidEvent = defineEvent4({
1019
+ var ReviewRespondedEvent = defineEvent4({
1099
1020
  meta: {
1100
- key: "marketplace.payout.paid",
1021
+ key: "marketplace.review.responded",
1101
1022
  version: "1.0.0",
1102
- description: "A payout has been sent.",
1023
+ description: "A seller has responded to a review.",
1103
1024
  stability: "experimental",
1104
1025
  owners: ["@marketplace-team"],
1105
- tags: ["marketplace", "payout"]
1026
+ tags: ["marketplace", "review"]
1106
1027
  },
1107
- payload: PayoutPaidPayload
1028
+ payload: ReviewRespondedPayload
1108
1029
  });
1109
- // src/review/review.enum.ts
1110
- import { defineEnum as defineEnum5 } from "@contractspec/lib.schema";
1111
- var ReviewStatusEnum = defineEnum5("ReviewStatus", [
1112
- "PENDING",
1113
- "APPROVED",
1114
- "REJECTED",
1115
- "FLAGGED"
1116
- ]);
1117
1030
 
1118
1031
  // src/review/review.schema.ts
1119
- import { defineSchemaModel as defineSchemaModel9, ScalarTypeEnum as ScalarTypeEnum9 } from "@contractspec/lib.schema";
1120
- var ReviewModel = defineSchemaModel9({
1032
+ import { defineSchemaModel as defineSchemaModel8, ScalarTypeEnum as ScalarTypeEnum8 } from "@contractspec/lib.schema";
1033
+ var ReviewModel = defineSchemaModel8({
1121
1034
  name: "ReviewModel",
1122
1035
  description: "A customer review",
1123
1036
  fields: {
1124
- id: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
1125
- productId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1126
- storeId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1127
- authorId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
1128
- rating: { type: ScalarTypeEnum9.Int_unsecure(), isOptional: false },
1129
- title: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1130
- content: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1037
+ id: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1038
+ productId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1039
+ storeId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1040
+ authorId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: false },
1041
+ rating: { type: ScalarTypeEnum8.Int_unsecure(), isOptional: false },
1042
+ title: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1043
+ content: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1131
1044
  status: { type: ReviewStatusEnum, isOptional: false },
1132
- isVerifiedPurchase: { type: ScalarTypeEnum9.Boolean(), isOptional: false },
1133
- helpfulCount: { type: ScalarTypeEnum9.Int_unsecure(), isOptional: false },
1134
- hasResponse: { type: ScalarTypeEnum9.Boolean(), isOptional: false },
1135
- createdAt: { type: ScalarTypeEnum9.DateTime(), isOptional: false }
1045
+ isVerifiedPurchase: { type: ScalarTypeEnum8.Boolean(), isOptional: false },
1046
+ helpfulCount: { type: ScalarTypeEnum8.Int_unsecure(), isOptional: false },
1047
+ hasResponse: { type: ScalarTypeEnum8.Boolean(), isOptional: false },
1048
+ createdAt: { type: ScalarTypeEnum8.DateTime(), isOptional: false }
1136
1049
  }
1137
1050
  });
1138
- var CreateReviewInputModel = defineSchemaModel9({
1051
+ var CreateReviewInputModel = defineSchemaModel8({
1139
1052
  name: "CreateReviewInput",
1140
1053
  fields: {
1141
- productId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1142
- storeId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1143
- orderId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1144
- rating: { type: ScalarTypeEnum9.Int_unsecure(), isOptional: false },
1145
- title: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1146
- content: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true }
1054
+ productId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1055
+ storeId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1056
+ orderId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1057
+ rating: { type: ScalarTypeEnum8.Int_unsecure(), isOptional: false },
1058
+ title: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1059
+ content: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true }
1147
1060
  }
1148
1061
  });
1149
- var ListReviewsInputModel = defineSchemaModel9({
1062
+ var ListReviewsInputModel = defineSchemaModel8({
1150
1063
  name: "ListReviewsInput",
1151
1064
  fields: {
1152
- productId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1153
- storeId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1065
+ productId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1066
+ storeId: { type: ScalarTypeEnum8.String_unsecure(), isOptional: true },
1154
1067
  status: { type: ReviewStatusEnum, isOptional: true },
1155
- minRating: { type: ScalarTypeEnum9.Int_unsecure(), isOptional: true },
1068
+ minRating: { type: ScalarTypeEnum8.Int_unsecure(), isOptional: true },
1156
1069
  limit: {
1157
- type: ScalarTypeEnum9.Int_unsecure(),
1070
+ type: ScalarTypeEnum8.Int_unsecure(),
1158
1071
  isOptional: true,
1159
1072
  defaultValue: 20
1160
1073
  },
1161
1074
  offset: {
1162
- type: ScalarTypeEnum9.Int_unsecure(),
1075
+ type: ScalarTypeEnum8.Int_unsecure(),
1163
1076
  isOptional: true,
1164
1077
  defaultValue: 0
1165
1078
  }
1166
1079
  }
1167
1080
  });
1168
- var ListReviewsOutputModel = defineSchemaModel9({
1081
+ var ListReviewsOutputModel = defineSchemaModel8({
1169
1082
  name: "ListReviewsOutput",
1170
1083
  fields: {
1171
1084
  reviews: { type: ReviewModel, isArray: true, isOptional: false },
1172
- total: { type: ScalarTypeEnum9.Int_unsecure(), isOptional: false },
1173
- averageRating: { type: ScalarTypeEnum9.Float_unsecure(), isOptional: false },
1174
- ratingDistribution: { type: ScalarTypeEnum9.JSON(), isOptional: false }
1085
+ total: { type: ScalarTypeEnum8.Int_unsecure(), isOptional: false },
1086
+ averageRating: { type: ScalarTypeEnum8.Float_unsecure(), isOptional: false },
1087
+ ratingDistribution: { type: ScalarTypeEnum8.JSON(), isOptional: false }
1175
1088
  }
1176
1089
  });
1177
1090
 
1178
1091
  // src/review/review.operations.ts
1179
1092
  import {
1180
- defineCommand as defineCommand4,
1093
+ defineCommand as defineCommand3,
1181
1094
  defineQuery as defineQuery3
1182
1095
  } from "@contractspec/lib.contracts-spec/operations";
1183
- var OWNERS5 = ["@example.marketplace"];
1184
- var CreateReviewContract = defineCommand4({
1096
+ var OWNERS4 = ["@example.marketplace"];
1097
+ var CreateReviewContract = defineCommand3({
1185
1098
  meta: {
1186
1099
  key: "marketplace.review.create",
1187
1100
  version: "1.0.0",
1188
1101
  stability: "stable",
1189
- owners: [...OWNERS5],
1102
+ owners: [...OWNERS4],
1190
1103
  tags: ["marketplace", "review", "create"],
1191
1104
  description: "Create a product/store review.",
1192
1105
  goal: "Allow buyers to leave feedback.",
@@ -1228,7 +1141,7 @@ var ListReviewsContract = defineQuery3({
1228
1141
  key: "marketplace.review.list",
1229
1142
  version: "1.0.0",
1230
1143
  stability: "stable",
1231
- owners: [...OWNERS5],
1144
+ owners: [...OWNERS4],
1232
1145
  tags: ["marketplace", "review", "list"],
1233
1146
  description: "List reviews with filters.",
1234
1147
  goal: "Display product/store reviews.",
@@ -1254,299 +1167,143 @@ var ListReviewsContract = defineQuery3({
1254
1167
  ]
1255
1168
  }
1256
1169
  });
1257
-
1258
- // src/review/review.event.ts
1259
- import { ScalarTypeEnum as ScalarTypeEnum10, defineSchemaModel as defineSchemaModel10 } from "@contractspec/lib.schema";
1260
- import { defineEvent as defineEvent5 } from "@contractspec/lib.contracts-spec";
1261
- var ReviewCreatedPayload = defineSchemaModel10({
1262
- name: "ReviewCreatedEventPayload",
1170
+ // src/store/store.enum.ts
1171
+ import { defineEnum as defineEnum5 } from "@contractspec/lib.schema";
1172
+ var StoreStatusEnum = defineEnum5("StoreStatus", [
1173
+ "PENDING",
1174
+ "ACTIVE",
1175
+ "SUSPENDED",
1176
+ "CLOSED"
1177
+ ]);
1178
+
1179
+ // src/store/store.event.ts
1180
+ import { defineEvent as defineEvent5 } from "@contractspec/lib.contracts-spec";
1181
+ import { defineSchemaModel as defineSchemaModel9, ScalarTypeEnum as ScalarTypeEnum9 } from "@contractspec/lib.schema";
1182
+ var StoreCreatedPayload = defineSchemaModel9({
1183
+ name: "StoreCreatedEventPayload",
1263
1184
  fields: {
1264
- reviewId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1265
- productId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: true },
1266
- storeId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: true },
1267
- authorId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1268
- rating: { type: ScalarTypeEnum10.Int_unsecure(), isOptional: false },
1269
- isVerifiedPurchase: { type: ScalarTypeEnum10.Boolean(), isOptional: false },
1270
- timestamp: { type: ScalarTypeEnum10.DateTime(), isOptional: false }
1185
+ storeId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
1186
+ name: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
1187
+ slug: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
1188
+ ownerId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
1189
+ timestamp: { type: ScalarTypeEnum9.DateTime(), isOptional: false }
1271
1190
  }
1272
1191
  });
1273
- var ReviewRespondedPayload = defineSchemaModel10({
1274
- name: "ReviewRespondedEventPayload",
1192
+ var StoreStatusChangedPayload = defineSchemaModel9({
1193
+ name: "StoreStatusChangedEventPayload",
1275
1194
  fields: {
1276
- reviewId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1277
- responseId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1278
- authorId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1279
- timestamp: { type: ScalarTypeEnum10.DateTime(), isOptional: false }
1195
+ storeId: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
1196
+ previousStatus: {
1197
+ type: ScalarTypeEnum9.String_unsecure(),
1198
+ isOptional: false
1199
+ },
1200
+ newStatus: { type: ScalarTypeEnum9.String_unsecure(), isOptional: false },
1201
+ reason: { type: ScalarTypeEnum9.String_unsecure(), isOptional: true },
1202
+ timestamp: { type: ScalarTypeEnum9.DateTime(), isOptional: false }
1280
1203
  }
1281
1204
  });
1282
- var ReviewCreatedEvent = defineEvent5({
1205
+ var StoreCreatedEvent = defineEvent5({
1283
1206
  meta: {
1284
- key: "marketplace.review.created",
1207
+ key: "marketplace.store.created",
1285
1208
  version: "1.0.0",
1286
- description: "A review has been created.",
1209
+ description: "A new seller store has been created.",
1287
1210
  stability: "experimental",
1288
1211
  owners: ["@marketplace-team"],
1289
- tags: ["marketplace", "review"]
1212
+ tags: ["marketplace", "store"]
1290
1213
  },
1291
- payload: ReviewCreatedPayload
1214
+ payload: StoreCreatedPayload
1292
1215
  });
1293
- var ReviewRespondedEvent = defineEvent5({
1216
+ var StoreStatusChangedEvent = defineEvent5({
1294
1217
  meta: {
1295
- key: "marketplace.review.responded",
1218
+ key: "marketplace.store.statusChanged",
1296
1219
  version: "1.0.0",
1297
- description: "A seller has responded to a review.",
1220
+ description: "A store status has changed.",
1298
1221
  stability: "experimental",
1299
1222
  owners: ["@marketplace-team"],
1300
- tags: ["marketplace", "review"]
1223
+ tags: ["marketplace", "store"]
1301
1224
  },
1302
- payload: ReviewRespondedPayload
1225
+ payload: StoreStatusChangedPayload
1303
1226
  });
1304
- // src/ui/renderers/marketplace.markdown.ts
1305
- var mockStores = [
1306
- {
1307
- id: "store-1",
1308
- name: "Tech Gadgets Store",
1309
- status: "ACTIVE",
1310
- productCount: 45,
1311
- rating: 4.8
1312
- },
1313
- {
1314
- id: "store-2",
1315
- name: "Home & Garden",
1316
- status: "ACTIVE",
1317
- productCount: 120,
1318
- rating: 4.5
1319
- },
1320
- {
1321
- id: "store-3",
1322
- name: "Fashion Boutique",
1323
- status: "PENDING",
1324
- productCount: 0,
1325
- rating: 0
1227
+
1228
+ // src/store/store.schema.ts
1229
+ import { defineSchemaModel as defineSchemaModel10, ScalarTypeEnum as ScalarTypeEnum10 } from "@contractspec/lib.schema";
1230
+ var StoreModel = defineSchemaModel10({
1231
+ name: "StoreModel",
1232
+ description: "A seller store",
1233
+ fields: {
1234
+ id: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1235
+ name: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1236
+ slug: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1237
+ description: { type: ScalarTypeEnum10.String_unsecure(), isOptional: true },
1238
+ status: { type: StoreStatusEnum, isOptional: false },
1239
+ ownerId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: false },
1240
+ logoFileId: { type: ScalarTypeEnum10.String_unsecure(), isOptional: true },
1241
+ isVerified: { type: ScalarTypeEnum10.Boolean(), isOptional: false },
1242
+ totalProducts: { type: ScalarTypeEnum10.Int_unsecure(), isOptional: false },
1243
+ averageRating: { type: ScalarTypeEnum10.Float_unsecure(), isOptional: false },
1244
+ createdAt: { type: ScalarTypeEnum10.DateTime(), isOptional: false }
1326
1245
  }
1327
- ];
1328
- var mockProducts = [
1329
- {
1330
- id: "prod-1",
1331
- name: "Wireless Earbuds",
1332
- storeId: "store-1",
1333
- price: 79.99,
1334
- currency: "USD",
1335
- status: "ACTIVE",
1336
- stock: 150
1337
- },
1338
- {
1339
- id: "prod-2",
1340
- name: "Smart Watch",
1341
- storeId: "store-1",
1342
- price: 249.99,
1343
- currency: "USD",
1344
- status: "ACTIVE",
1345
- stock: 50
1346
- },
1347
- {
1348
- id: "prod-3",
1349
- name: "Garden Tools Set",
1350
- storeId: "store-2",
1351
- price: 89.99,
1352
- currency: "USD",
1353
- status: "ACTIVE",
1354
- stock: 30
1355
- },
1356
- {
1357
- id: "prod-4",
1358
- name: "Indoor Plant Kit",
1359
- storeId: "store-2",
1360
- price: 45.99,
1361
- currency: "USD",
1362
- status: "ACTIVE",
1363
- stock: 75
1364
- },
1365
- {
1366
- id: "prod-5",
1367
- name: "LED Desk Lamp",
1368
- storeId: "store-1",
1369
- price: 34.99,
1370
- currency: "USD",
1371
- status: "OUT_OF_STOCK",
1372
- stock: 0
1246
+ });
1247
+ var CreateStoreInputModel = defineSchemaModel10({
1248
+ name: "CreateStoreInput",
1249
+ fields: {
1250
+ name: { type: ScalarTypeEnum10.NonEmptyString(), isOptional: false },
1251
+ slug: { type: ScalarTypeEnum10.NonEmptyString(), isOptional: false },
1252
+ description: { type: ScalarTypeEnum10.String_unsecure(), isOptional: true },
1253
+ email: { type: ScalarTypeEnum10.EmailAddress(), isOptional: true },
1254
+ country: { type: ScalarTypeEnum10.String_unsecure(), isOptional: true },
1255
+ currency: { type: ScalarTypeEnum10.String_unsecure(), isOptional: true }
1373
1256
  }
1374
- ];
1375
- var mockOrders = [
1376
- {
1377
- id: "ord-1",
1378
- storeId: "store-1",
1379
- customerId: "cust-1",
1380
- total: 329.98,
1381
- currency: "USD",
1382
- status: "DELIVERED",
1383
- itemCount: 2,
1384
- createdAt: "2024-01-15T10:00:00Z"
1385
- },
1386
- {
1387
- id: "ord-2",
1388
- storeId: "store-2",
1389
- customerId: "cust-2",
1390
- total: 135.98,
1391
- currency: "USD",
1392
- status: "SHIPPED",
1393
- itemCount: 2,
1394
- createdAt: "2024-01-14T14:00:00Z"
1257
+ });
1258
+
1259
+ // src/store/store.operations.ts
1260
+ import { defineCommand as defineCommand4 } from "@contractspec/lib.contracts-spec/operations";
1261
+ var OWNERS5 = ["@example.marketplace"];
1262
+ var CreateStoreContract = defineCommand4({
1263
+ meta: {
1264
+ key: "marketplace.store.create",
1265
+ version: "1.0.0",
1266
+ stability: "stable",
1267
+ owners: [...OWNERS5],
1268
+ tags: ["marketplace", "store", "create"],
1269
+ description: "Create a new seller store.",
1270
+ goal: "Allow users to become sellers on the marketplace.",
1271
+ context: "Seller onboarding."
1395
1272
  },
1396
- {
1397
- id: "ord-3",
1398
- storeId: "store-1",
1399
- customerId: "cust-3",
1400
- total: 79.99,
1401
- currency: "USD",
1402
- status: "PROCESSING",
1403
- itemCount: 1,
1404
- createdAt: "2024-01-16T08:00:00Z"
1273
+ io: { input: CreateStoreInputModel, output: StoreModel },
1274
+ policy: { auth: "user" },
1275
+ sideEffects: {
1276
+ emits: [
1277
+ {
1278
+ key: "marketplace.store.created",
1279
+ version: "1.0.0",
1280
+ when: "Store is created",
1281
+ payload: StoreModel
1282
+ }
1283
+ ],
1284
+ audit: ["marketplace.store.created"]
1405
1285
  },
1406
- {
1407
- id: "ord-4",
1408
- storeId: "store-2",
1409
- customerId: "cust-4",
1410
- total: 45.99,
1411
- currency: "USD",
1412
- status: "PENDING",
1413
- itemCount: 1,
1414
- createdAt: "2024-01-16T12:00:00Z"
1415
- }
1416
- ];
1417
- function formatCurrency(value, currency = "USD") {
1418
- return new Intl.NumberFormat("en-US", {
1419
- style: "currency",
1420
- currency,
1421
- minimumFractionDigits: 2
1422
- }).format(value);
1423
- }
1424
- var marketplaceDashboardMarkdownRenderer = {
1425
- target: "markdown",
1426
- render: async (desc) => {
1427
- if (desc.source.type !== "component" || desc.source.componentKey !== "MarketplaceDashboard") {
1428
- throw new Error("marketplaceDashboardMarkdownRenderer: not MarketplaceDashboard");
1429
- }
1430
- const stores = mockStores;
1431
- const products = mockProducts;
1432
- const orders = mockOrders;
1433
- const activeStores = stores.filter((s) => s.status === "ACTIVE");
1434
- const activeProducts = products.filter((p) => p.status === "ACTIVE");
1435
- const totalRevenue = orders.reduce((sum, o) => sum + o.total, 0);
1436
- const pendingOrders = orders.filter((o) => o.status === "PENDING" || o.status === "PROCESSING");
1437
- const lines = [
1438
- "# Marketplace Dashboard",
1439
- "",
1440
- "> Two-sided marketplace overview",
1441
- "",
1442
- "## Summary",
1443
- "",
1444
- "| Metric | Value |",
1445
- "|--------|-------|",
1446
- `| Active Stores | ${activeStores.length} |`,
1447
- `| Active Products | ${activeProducts.length} |`,
1448
- `| Total Orders | ${orders.length} |`,
1449
- `| Total Revenue | ${formatCurrency(totalRevenue)} |`,
1450
- `| Pending Orders | ${pendingOrders.length} |`,
1451
- "",
1452
- "## Top Stores",
1453
- "",
1454
- "| Store | Products | Rating | Status |",
1455
- "|-------|----------|--------|--------|"
1456
- ];
1457
- for (const store of stores.slice(0, 5)) {
1458
- lines.push(`| ${store.name} | ${store.productCount} | ⭐ ${store.rating || "N/A"} | ${store.status} |`);
1459
- }
1460
- lines.push("");
1461
- lines.push("## Recent Orders");
1462
- lines.push("");
1463
- lines.push("| Order | Items | Total | Status | Date |");
1464
- lines.push("|-------|-------|-------|--------|------|");
1465
- for (const order of orders.slice(0, 10)) {
1466
- const date = new Date(order.createdAt).toLocaleDateString();
1467
- lines.push(`| ${order.id} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`);
1468
- }
1469
- return {
1470
- mimeType: "text/markdown",
1471
- body: lines.join(`
1472
- `)
1473
- };
1474
- }
1475
- };
1476
- var productCatalogMarkdownRenderer = {
1477
- target: "markdown",
1478
- render: async (desc) => {
1479
- if (desc.source.type !== "component" || desc.source.componentKey !== "ProductCatalog") {
1480
- throw new Error("productCatalogMarkdownRenderer: not ProductCatalog");
1481
- }
1482
- const products = mockProducts;
1483
- const stores = mockStores;
1484
- const lines = [
1485
- "# Product Catalog",
1486
- "",
1487
- "> Browse products across all marketplace stores",
1488
- ""
1489
- ];
1490
- for (const store of stores.filter((s) => s.status === "ACTIVE")) {
1491
- const storeProducts = products.filter((p) => p.storeId === store.id);
1492
- if (storeProducts.length === 0)
1493
- continue;
1494
- lines.push(`## ${store.name}`);
1495
- lines.push("");
1496
- lines.push("| Product | Price | Stock | Status |");
1497
- lines.push("|---------|-------|-------|--------|");
1498
- for (const product of storeProducts) {
1499
- const stockStatus = product.stock > 0 ? `${product.stock} in stock` : "Out of stock";
1500
- lines.push(`| ${product.name} | ${formatCurrency(product.price, product.currency)} | ${stockStatus} | ${product.status} |`);
1286
+ acceptance: {
1287
+ scenarios: [
1288
+ {
1289
+ key: "create-store-happy-path",
1290
+ given: ["User is authenticated"],
1291
+ when: ["User creates a new store"],
1292
+ then: ["Store is created", "StoreCreated event is emitted"]
1501
1293
  }
1502
- lines.push("");
1503
- }
1504
- return {
1505
- mimeType: "text/markdown",
1506
- body: lines.join(`
1507
- `)
1508
- };
1509
- }
1510
- };
1511
- var orderListMarkdownRenderer = {
1512
- target: "markdown",
1513
- render: async (desc) => {
1514
- if (desc.source.type !== "component" || desc.source.componentKey !== "OrderList") {
1515
- throw new Error("orderListMarkdownRenderer: not OrderList");
1516
- }
1517
- const orders = mockOrders;
1518
- const stores = mockStores;
1519
- const lines = [
1520
- "# Orders",
1521
- "",
1522
- "> Manage marketplace orders",
1523
- "",
1524
- "| Order ID | Store | Items | Total | Status | Created |",
1525
- "|----------|-------|-------|-------|--------|---------|"
1526
- ];
1527
- for (const order of orders) {
1528
- const store = stores.find((s) => s.id === order.storeId);
1529
- const date = new Date(order.createdAt).toLocaleDateString();
1530
- lines.push(`| ${order.id} | ${store?.name ?? "Unknown"} | ${order.itemCount} | ${formatCurrency(order.total, order.currency)} | ${order.status} | ${date} |`);
1531
- }
1532
- lines.push("");
1533
- lines.push("## Order Status Legend");
1534
- lines.push("");
1535
- lines.push("- **PENDING**: Awaiting payment confirmation");
1536
- lines.push("- **PROCESSING**: Being prepared");
1537
- lines.push("- **SHIPPED**: In transit");
1538
- lines.push("- **DELIVERED**: Order completed");
1539
- lines.push("- **CANCELLED**: Order cancelled");
1540
- return {
1541
- mimeType: "text/markdown",
1542
- body: lines.join(`
1543
- `)
1544
- };
1294
+ ],
1295
+ examples: [
1296
+ {
1297
+ key: "create-fashion-store",
1298
+ input: { name: "Fashion Boutique", category: "clothing" },
1299
+ output: { id: "store-123", status: "active" }
1300
+ }
1301
+ ]
1545
1302
  }
1546
- };
1303
+ });
1547
1304
  // src/ui/hooks/useMarketplaceData.ts
1548
- import { useCallback, useEffect, useState } from "react";
1549
1305
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
1306
+ import { useCallback, useEffect, useState } from "react";
1550
1307
  "use client";
1551
1308
  function useMarketplaceData(projectId = "local-project") {
1552
1309
  const { handlers } = useTemplateRuntime();
@@ -1598,8 +1355,10 @@ function useMarketplaceData(projectId = "local-project") {
1598
1355
  };
1599
1356
  }
1600
1357
 
1358
+ // src/ui/hooks/index.ts
1359
+ "use client";
1360
+
1601
1361
  // src/ui/MarketplaceDashboard.tsx
1602
- import { useState as useState2 } from "react";
1603
1362
  import {
1604
1363
  Button,
1605
1364
  ErrorState,
@@ -1607,6 +1366,7 @@ import {
1607
1366
  StatCard,
1608
1367
  StatCardGroup
1609
1368
  } from "@contractspec/lib.design-system";
1369
+ import { useState as useState2 } from "react";
1610
1370
  import { jsxDEV } from "react/jsx-dev-runtime";
1611
1371
  "use client";
1612
1372
  var STATUS_COLORS = {
@@ -1622,7 +1382,7 @@ var STATUS_COLORS = {
1622
1382
  DELIVERED: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
1623
1383
  CANCELLED: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"
1624
1384
  };
1625
- function formatCurrency2(value, currency = "USD") {
1385
+ function formatCurrency(value, currency = "USD") {
1626
1386
  return new Intl.NumberFormat("en-US", {
1627
1387
  style: "currency",
1628
1388
  currency,
@@ -1658,7 +1418,7 @@ function MarketplaceDashboard() {
1658
1418
  className: "flex items-center justify-between",
1659
1419
  children: [
1660
1420
  /* @__PURE__ */ jsxDEV("h2", {
1661
- className: "text-2xl font-bold",
1421
+ className: "font-bold text-2xl",
1662
1422
  children: "Marketplace"
1663
1423
  }, undefined, false, undefined, this),
1664
1424
  /* @__PURE__ */ jsxDEV(Button, {
@@ -1692,20 +1452,20 @@ function MarketplaceDashboard() {
1692
1452
  }, undefined, false, undefined, this),
1693
1453
  /* @__PURE__ */ jsxDEV(StatCard, {
1694
1454
  label: "Revenue",
1695
- value: formatCurrency2(stats.totalRevenue),
1455
+ value: formatCurrency(stats.totalRevenue),
1696
1456
  hint: "total"
1697
1457
  }, undefined, false, undefined, this)
1698
1458
  ]
1699
1459
  }, undefined, true, undefined, this),
1700
1460
  /* @__PURE__ */ jsxDEV("nav", {
1701
- className: "bg-muted flex gap-1 rounded-lg p-1",
1461
+ className: "flex gap-1 rounded-lg bg-muted p-1",
1702
1462
  role: "tablist",
1703
1463
  children: tabs.map((tab) => /* @__PURE__ */ jsxDEV(Button, {
1704
1464
  type: "button",
1705
1465
  role: "tab",
1706
1466
  "aria-selected": activeTab === tab.id,
1707
1467
  onClick: () => setActiveTab(tab.id),
1708
- className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 text-sm font-medium transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
1468
+ className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
1709
1469
  children: [
1710
1470
  /* @__PURE__ */ jsxDEV("span", {
1711
1471
  children: tab.icon
@@ -1719,35 +1479,35 @@ function MarketplaceDashboard() {
1719
1479
  role: "tabpanel",
1720
1480
  children: [
1721
1481
  activeTab === "stores" && /* @__PURE__ */ jsxDEV("div", {
1722
- className: "border-border rounded-lg border",
1482
+ className: "rounded-lg border border-border",
1723
1483
  children: /* @__PURE__ */ jsxDEV("table", {
1724
1484
  className: "w-full",
1725
1485
  children: [
1726
1486
  /* @__PURE__ */ jsxDEV("thead", {
1727
- className: "border-border bg-muted/30 border-b",
1487
+ className: "border-border border-b bg-muted/30",
1728
1488
  children: /* @__PURE__ */ jsxDEV("tr", {
1729
1489
  children: [
1730
1490
  /* @__PURE__ */ jsxDEV("th", {
1731
- className: "px-4 py-3 text-left text-sm font-medium",
1491
+ className: "px-4 py-3 text-left font-medium text-sm",
1732
1492
  children: "Store"
1733
1493
  }, undefined, false, undefined, this),
1734
1494
  /* @__PURE__ */ jsxDEV("th", {
1735
- className: "px-4 py-3 text-left text-sm font-medium",
1495
+ className: "px-4 py-3 text-left font-medium text-sm",
1736
1496
  children: "Status"
1737
1497
  }, undefined, false, undefined, this),
1738
1498
  /* @__PURE__ */ jsxDEV("th", {
1739
- className: "px-4 py-3 text-left text-sm font-medium",
1499
+ className: "px-4 py-3 text-left font-medium text-sm",
1740
1500
  children: "Rating"
1741
1501
  }, undefined, false, undefined, this),
1742
1502
  /* @__PURE__ */ jsxDEV("th", {
1743
- className: "px-4 py-3 text-left text-sm font-medium",
1503
+ className: "px-4 py-3 text-left font-medium text-sm",
1744
1504
  children: "Reviews"
1745
1505
  }, undefined, false, undefined, this)
1746
1506
  ]
1747
1507
  }, undefined, true, undefined, this)
1748
1508
  }, undefined, false, undefined, this),
1749
1509
  /* @__PURE__ */ jsxDEV("tbody", {
1750
- className: "divide-border divide-y",
1510
+ className: "divide-y divide-border",
1751
1511
  children: [
1752
1512
  stores.map((store) => /* @__PURE__ */ jsxDEV("tr", {
1753
1513
  className: "hover:bg-muted/50",
@@ -1768,7 +1528,7 @@ function MarketplaceDashboard() {
1768
1528
  /* @__PURE__ */ jsxDEV("td", {
1769
1529
  className: "px-4 py-3",
1770
1530
  children: /* @__PURE__ */ jsxDEV("span", {
1771
- className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[store.status] ?? ""}`,
1531
+ className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[store.status] ?? ""}`,
1772
1532
  children: store.status
1773
1533
  }, undefined, false, undefined, this)
1774
1534
  }, undefined, false, undefined, this),
@@ -1783,7 +1543,7 @@ function MarketplaceDashboard() {
1783
1543
  }, undefined, true, undefined, this)
1784
1544
  }, undefined, false, undefined, this),
1785
1545
  /* @__PURE__ */ jsxDEV("td", {
1786
- className: "text-muted-foreground px-4 py-3 text-sm",
1546
+ className: "px-4 py-3 text-muted-foreground text-sm",
1787
1547
  children: [
1788
1548
  store.reviewCount,
1789
1549
  " reviews"
@@ -1794,7 +1554,7 @@ function MarketplaceDashboard() {
1794
1554
  stores.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
1795
1555
  children: /* @__PURE__ */ jsxDEV("td", {
1796
1556
  colSpan: 4,
1797
- className: "text-muted-foreground px-4 py-8 text-center",
1557
+ className: "px-4 py-8 text-center text-muted-foreground",
1798
1558
  children: "No stores found"
1799
1559
  }, undefined, false, undefined, this)
1800
1560
  }, undefined, false, undefined, this)
@@ -1804,35 +1564,35 @@ function MarketplaceDashboard() {
1804
1564
  }, undefined, true, undefined, this)
1805
1565
  }, undefined, false, undefined, this),
1806
1566
  activeTab === "products" && /* @__PURE__ */ jsxDEV("div", {
1807
- className: "border-border rounded-lg border",
1567
+ className: "rounded-lg border border-border",
1808
1568
  children: /* @__PURE__ */ jsxDEV("table", {
1809
1569
  className: "w-full",
1810
1570
  children: [
1811
1571
  /* @__PURE__ */ jsxDEV("thead", {
1812
- className: "border-border bg-muted/30 border-b",
1572
+ className: "border-border border-b bg-muted/30",
1813
1573
  children: /* @__PURE__ */ jsxDEV("tr", {
1814
1574
  children: [
1815
1575
  /* @__PURE__ */ jsxDEV("th", {
1816
- className: "px-4 py-3 text-left text-sm font-medium",
1576
+ className: "px-4 py-3 text-left font-medium text-sm",
1817
1577
  children: "Product"
1818
1578
  }, undefined, false, undefined, this),
1819
1579
  /* @__PURE__ */ jsxDEV("th", {
1820
- className: "px-4 py-3 text-left text-sm font-medium",
1580
+ className: "px-4 py-3 text-left font-medium text-sm",
1821
1581
  children: "Price"
1822
1582
  }, undefined, false, undefined, this),
1823
1583
  /* @__PURE__ */ jsxDEV("th", {
1824
- className: "px-4 py-3 text-left text-sm font-medium",
1584
+ className: "px-4 py-3 text-left font-medium text-sm",
1825
1585
  children: "Stock"
1826
1586
  }, undefined, false, undefined, this),
1827
1587
  /* @__PURE__ */ jsxDEV("th", {
1828
- className: "px-4 py-3 text-left text-sm font-medium",
1588
+ className: "px-4 py-3 text-left font-medium text-sm",
1829
1589
  children: "Status"
1830
1590
  }, undefined, false, undefined, this)
1831
1591
  ]
1832
1592
  }, undefined, true, undefined, this)
1833
1593
  }, undefined, false, undefined, this),
1834
1594
  /* @__PURE__ */ jsxDEV("tbody", {
1835
- className: "divide-border divide-y",
1595
+ className: "divide-y divide-border",
1836
1596
  children: [
1837
1597
  products.map((product) => /* @__PURE__ */ jsxDEV("tr", {
1838
1598
  className: "hover:bg-muted/50",
@@ -1852,7 +1612,7 @@ function MarketplaceDashboard() {
1852
1612
  }, undefined, true, undefined, this),
1853
1613
  /* @__PURE__ */ jsxDEV("td", {
1854
1614
  className: "px-4 py-3 font-mono",
1855
- children: formatCurrency2(product.price, product.currency)
1615
+ children: formatCurrency(product.price, product.currency)
1856
1616
  }, undefined, false, undefined, this),
1857
1617
  /* @__PURE__ */ jsxDEV("td", {
1858
1618
  className: "px-4 py-3",
@@ -1861,7 +1621,7 @@ function MarketplaceDashboard() {
1861
1621
  /* @__PURE__ */ jsxDEV("td", {
1862
1622
  className: "px-4 py-3",
1863
1623
  children: /* @__PURE__ */ jsxDEV("span", {
1864
- className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[product.status] ?? ""}`,
1624
+ className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[product.status] ?? ""}`,
1865
1625
  children: product.status
1866
1626
  }, undefined, false, undefined, this)
1867
1627
  }, undefined, false, undefined, this)
@@ -1870,7 +1630,7 @@ function MarketplaceDashboard() {
1870
1630
  products.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
1871
1631
  children: /* @__PURE__ */ jsxDEV("td", {
1872
1632
  colSpan: 4,
1873
- className: "text-muted-foreground px-4 py-8 text-center",
1633
+ className: "px-4 py-8 text-center text-muted-foreground",
1874
1634
  children: "No products found"
1875
1635
  }, undefined, false, undefined, this)
1876
1636
  }, undefined, false, undefined, this)
@@ -1880,39 +1640,39 @@ function MarketplaceDashboard() {
1880
1640
  }, undefined, true, undefined, this)
1881
1641
  }, undefined, false, undefined, this),
1882
1642
  activeTab === "orders" && /* @__PURE__ */ jsxDEV("div", {
1883
- className: "border-border rounded-lg border",
1643
+ className: "rounded-lg border border-border",
1884
1644
  children: /* @__PURE__ */ jsxDEV("table", {
1885
1645
  className: "w-full",
1886
1646
  children: [
1887
1647
  /* @__PURE__ */ jsxDEV("thead", {
1888
- className: "border-border bg-muted/30 border-b",
1648
+ className: "border-border border-b bg-muted/30",
1889
1649
  children: /* @__PURE__ */ jsxDEV("tr", {
1890
1650
  children: [
1891
1651
  /* @__PURE__ */ jsxDEV("th", {
1892
- className: "px-4 py-3 text-left text-sm font-medium",
1652
+ className: "px-4 py-3 text-left font-medium text-sm",
1893
1653
  children: "Order ID"
1894
1654
  }, undefined, false, undefined, this),
1895
1655
  /* @__PURE__ */ jsxDEV("th", {
1896
- className: "px-4 py-3 text-left text-sm font-medium",
1656
+ className: "px-4 py-3 text-left font-medium text-sm",
1897
1657
  children: "Customer"
1898
1658
  }, undefined, false, undefined, this),
1899
1659
  /* @__PURE__ */ jsxDEV("th", {
1900
- className: "px-4 py-3 text-left text-sm font-medium",
1660
+ className: "px-4 py-3 text-left font-medium text-sm",
1901
1661
  children: "Total"
1902
1662
  }, undefined, false, undefined, this),
1903
1663
  /* @__PURE__ */ jsxDEV("th", {
1904
- className: "px-4 py-3 text-left text-sm font-medium",
1664
+ className: "px-4 py-3 text-left font-medium text-sm",
1905
1665
  children: "Status"
1906
1666
  }, undefined, false, undefined, this),
1907
1667
  /* @__PURE__ */ jsxDEV("th", {
1908
- className: "px-4 py-3 text-left text-sm font-medium",
1668
+ className: "px-4 py-3 text-left font-medium text-sm",
1909
1669
  children: "Date"
1910
1670
  }, undefined, false, undefined, this)
1911
1671
  ]
1912
1672
  }, undefined, true, undefined, this)
1913
1673
  }, undefined, false, undefined, this),
1914
1674
  /* @__PURE__ */ jsxDEV("tbody", {
1915
- className: "divide-border divide-y",
1675
+ className: "divide-y divide-border",
1916
1676
  children: [
1917
1677
  orders.map((order) => /* @__PURE__ */ jsxDEV("tr", {
1918
1678
  className: "hover:bg-muted/50",
@@ -1927,17 +1687,17 @@ function MarketplaceDashboard() {
1927
1687
  }, undefined, false, undefined, this),
1928
1688
  /* @__PURE__ */ jsxDEV("td", {
1929
1689
  className: "px-4 py-3 font-mono",
1930
- children: formatCurrency2(order.total, order.currency)
1690
+ children: formatCurrency(order.total, order.currency)
1931
1691
  }, undefined, false, undefined, this),
1932
1692
  /* @__PURE__ */ jsxDEV("td", {
1933
1693
  className: "px-4 py-3",
1934
1694
  children: /* @__PURE__ */ jsxDEV("span", {
1935
- className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[order.status] ?? ""}`,
1695
+ className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[order.status] ?? ""}`,
1936
1696
  children: order.status
1937
1697
  }, undefined, false, undefined, this)
1938
1698
  }, undefined, false, undefined, this),
1939
1699
  /* @__PURE__ */ jsxDEV("td", {
1940
- className: "text-muted-foreground px-4 py-3 text-sm",
1700
+ className: "px-4 py-3 text-muted-foreground text-sm",
1941
1701
  children: order.createdAt.toLocaleDateString()
1942
1702
  }, undefined, false, undefined, this)
1943
1703
  ]
@@ -1945,7 +1705,7 @@ function MarketplaceDashboard() {
1945
1705
  orders.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
1946
1706
  children: /* @__PURE__ */ jsxDEV("td", {
1947
1707
  colSpan: 5,
1948
- className: "text-muted-foreground px-4 py-8 text-center",
1708
+ className: "px-4 py-8 text-center text-muted-foreground",
1949
1709
  children: "No orders found"
1950
1710
  }, undefined, false, undefined, this)
1951
1711
  }, undefined, false, undefined, this)
@@ -1960,8 +1720,249 @@ function MarketplaceDashboard() {
1960
1720
  }, undefined, true, undefined, this);
1961
1721
  }
1962
1722
 
1963
- // src/ui/hooks/index.ts
1964
- "use client";
1723
+ // src/ui/renderers/marketplace.markdown.ts
1724
+ var mockStores = [
1725
+ {
1726
+ id: "store-1",
1727
+ name: "Tech Gadgets Store",
1728
+ status: "ACTIVE",
1729
+ productCount: 45,
1730
+ rating: 4.8
1731
+ },
1732
+ {
1733
+ id: "store-2",
1734
+ name: "Home & Garden",
1735
+ status: "ACTIVE",
1736
+ productCount: 120,
1737
+ rating: 4.5
1738
+ },
1739
+ {
1740
+ id: "store-3",
1741
+ name: "Fashion Boutique",
1742
+ status: "PENDING",
1743
+ productCount: 0,
1744
+ rating: 0
1745
+ }
1746
+ ];
1747
+ var mockProducts = [
1748
+ {
1749
+ id: "prod-1",
1750
+ name: "Wireless Earbuds",
1751
+ storeId: "store-1",
1752
+ price: 79.99,
1753
+ currency: "USD",
1754
+ status: "ACTIVE",
1755
+ stock: 150
1756
+ },
1757
+ {
1758
+ id: "prod-2",
1759
+ name: "Smart Watch",
1760
+ storeId: "store-1",
1761
+ price: 249.99,
1762
+ currency: "USD",
1763
+ status: "ACTIVE",
1764
+ stock: 50
1765
+ },
1766
+ {
1767
+ id: "prod-3",
1768
+ name: "Garden Tools Set",
1769
+ storeId: "store-2",
1770
+ price: 89.99,
1771
+ currency: "USD",
1772
+ status: "ACTIVE",
1773
+ stock: 30
1774
+ },
1775
+ {
1776
+ id: "prod-4",
1777
+ name: "Indoor Plant Kit",
1778
+ storeId: "store-2",
1779
+ price: 45.99,
1780
+ currency: "USD",
1781
+ status: "ACTIVE",
1782
+ stock: 75
1783
+ },
1784
+ {
1785
+ id: "prod-5",
1786
+ name: "LED Desk Lamp",
1787
+ storeId: "store-1",
1788
+ price: 34.99,
1789
+ currency: "USD",
1790
+ status: "OUT_OF_STOCK",
1791
+ stock: 0
1792
+ }
1793
+ ];
1794
+ var mockOrders = [
1795
+ {
1796
+ id: "ord-1",
1797
+ storeId: "store-1",
1798
+ customerId: "cust-1",
1799
+ total: 329.98,
1800
+ currency: "USD",
1801
+ status: "DELIVERED",
1802
+ itemCount: 2,
1803
+ createdAt: "2024-01-15T10:00:00Z"
1804
+ },
1805
+ {
1806
+ id: "ord-2",
1807
+ storeId: "store-2",
1808
+ customerId: "cust-2",
1809
+ total: 135.98,
1810
+ currency: "USD",
1811
+ status: "SHIPPED",
1812
+ itemCount: 2,
1813
+ createdAt: "2024-01-14T14:00:00Z"
1814
+ },
1815
+ {
1816
+ id: "ord-3",
1817
+ storeId: "store-1",
1818
+ customerId: "cust-3",
1819
+ total: 79.99,
1820
+ currency: "USD",
1821
+ status: "PROCESSING",
1822
+ itemCount: 1,
1823
+ createdAt: "2024-01-16T08:00:00Z"
1824
+ },
1825
+ {
1826
+ id: "ord-4",
1827
+ storeId: "store-2",
1828
+ customerId: "cust-4",
1829
+ total: 45.99,
1830
+ currency: "USD",
1831
+ status: "PENDING",
1832
+ itemCount: 1,
1833
+ createdAt: "2024-01-16T12:00:00Z"
1834
+ }
1835
+ ];
1836
+ function formatCurrency2(value, currency = "USD") {
1837
+ return new Intl.NumberFormat("en-US", {
1838
+ style: "currency",
1839
+ currency,
1840
+ minimumFractionDigits: 2
1841
+ }).format(value);
1842
+ }
1843
+ var marketplaceDashboardMarkdownRenderer = {
1844
+ target: "markdown",
1845
+ render: async (desc) => {
1846
+ if (desc.source.type !== "component" || desc.source.componentKey !== "MarketplaceDashboard") {
1847
+ throw new Error("marketplaceDashboardMarkdownRenderer: not MarketplaceDashboard");
1848
+ }
1849
+ const stores = mockStores;
1850
+ const products = mockProducts;
1851
+ const orders = mockOrders;
1852
+ const activeStores = stores.filter((s) => s.status === "ACTIVE");
1853
+ const activeProducts = products.filter((p) => p.status === "ACTIVE");
1854
+ const totalRevenue = orders.reduce((sum, o) => sum + o.total, 0);
1855
+ const pendingOrders = orders.filter((o) => o.status === "PENDING" || o.status === "PROCESSING");
1856
+ const lines = [
1857
+ "# Marketplace Dashboard",
1858
+ "",
1859
+ "> Two-sided marketplace overview",
1860
+ "",
1861
+ "## Summary",
1862
+ "",
1863
+ "| Metric | Value |",
1864
+ "|--------|-------|",
1865
+ `| Active Stores | ${activeStores.length} |`,
1866
+ `| Active Products | ${activeProducts.length} |`,
1867
+ `| Total Orders | ${orders.length} |`,
1868
+ `| Total Revenue | ${formatCurrency2(totalRevenue)} |`,
1869
+ `| Pending Orders | ${pendingOrders.length} |`,
1870
+ "",
1871
+ "## Top Stores",
1872
+ "",
1873
+ "| Store | Products | Rating | Status |",
1874
+ "|-------|----------|--------|--------|"
1875
+ ];
1876
+ for (const store of stores.slice(0, 5)) {
1877
+ lines.push(`| ${store.name} | ${store.productCount} | ⭐ ${store.rating || "N/A"} | ${store.status} |`);
1878
+ }
1879
+ lines.push("");
1880
+ lines.push("## Recent Orders");
1881
+ lines.push("");
1882
+ lines.push("| Order | Items | Total | Status | Date |");
1883
+ lines.push("|-------|-------|-------|--------|------|");
1884
+ for (const order of orders.slice(0, 10)) {
1885
+ const date = new Date(order.createdAt).toLocaleDateString();
1886
+ lines.push(`| ${order.id} | ${order.itemCount} | ${formatCurrency2(order.total, order.currency)} | ${order.status} | ${date} |`);
1887
+ }
1888
+ return {
1889
+ mimeType: "text/markdown",
1890
+ body: lines.join(`
1891
+ `)
1892
+ };
1893
+ }
1894
+ };
1895
+ var productCatalogMarkdownRenderer = {
1896
+ target: "markdown",
1897
+ render: async (desc) => {
1898
+ if (desc.source.type !== "component" || desc.source.componentKey !== "ProductCatalog") {
1899
+ throw new Error("productCatalogMarkdownRenderer: not ProductCatalog");
1900
+ }
1901
+ const products = mockProducts;
1902
+ const stores = mockStores;
1903
+ const lines = [
1904
+ "# Product Catalog",
1905
+ "",
1906
+ "> Browse products across all marketplace stores",
1907
+ ""
1908
+ ];
1909
+ for (const store of stores.filter((s) => s.status === "ACTIVE")) {
1910
+ const storeProducts = products.filter((p) => p.storeId === store.id);
1911
+ if (storeProducts.length === 0)
1912
+ continue;
1913
+ lines.push(`## ${store.name}`);
1914
+ lines.push("");
1915
+ lines.push("| Product | Price | Stock | Status |");
1916
+ lines.push("|---------|-------|-------|--------|");
1917
+ for (const product of storeProducts) {
1918
+ const stockStatus = product.stock > 0 ? `${product.stock} in stock` : "Out of stock";
1919
+ lines.push(`| ${product.name} | ${formatCurrency2(product.price, product.currency)} | ${stockStatus} | ${product.status} |`);
1920
+ }
1921
+ lines.push("");
1922
+ }
1923
+ return {
1924
+ mimeType: "text/markdown",
1925
+ body: lines.join(`
1926
+ `)
1927
+ };
1928
+ }
1929
+ };
1930
+ var orderListMarkdownRenderer = {
1931
+ target: "markdown",
1932
+ render: async (desc) => {
1933
+ if (desc.source.type !== "component" || desc.source.componentKey !== "OrderList") {
1934
+ throw new Error("orderListMarkdownRenderer: not OrderList");
1935
+ }
1936
+ const orders = mockOrders;
1937
+ const stores = mockStores;
1938
+ const lines = [
1939
+ "# Orders",
1940
+ "",
1941
+ "> Manage marketplace orders",
1942
+ "",
1943
+ "| Order ID | Store | Items | Total | Status | Created |",
1944
+ "|----------|-------|-------|-------|--------|---------|"
1945
+ ];
1946
+ for (const order of orders) {
1947
+ const store = stores.find((s) => s.id === order.storeId);
1948
+ const date = new Date(order.createdAt).toLocaleDateString();
1949
+ lines.push(`| ${order.id} | ${store?.name ?? "Unknown"} | ${order.itemCount} | ${formatCurrency2(order.total, order.currency)} | ${order.status} | ${date} |`);
1950
+ }
1951
+ lines.push("");
1952
+ lines.push("## Order Status Legend");
1953
+ lines.push("");
1954
+ lines.push("- **PENDING**: Awaiting payment confirmation");
1955
+ lines.push("- **PROCESSING**: Being prepared");
1956
+ lines.push("- **SHIPPED**: In transit");
1957
+ lines.push("- **DELIVERED**: Order completed");
1958
+ lines.push("- **CANCELLED**: Order cancelled");
1959
+ return {
1960
+ mimeType: "text/markdown",
1961
+ body: lines.join(`
1962
+ `)
1963
+ };
1964
+ }
1965
+ };
1965
1966
  export {
1966
1967
  useMarketplaceData,
1967
1968
  productCatalogMarkdownRenderer,