@happyvertical/smrt-commerce 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/AGENTS.md +44 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +7 -0
  4. package/README.md +146 -0
  5. package/dist/__smrt-register__.d.ts +2 -0
  6. package/dist/__smrt-register__.d.ts.map +1 -0
  7. package/dist/collections/ContractCollection.d.ts +87 -0
  8. package/dist/collections/ContractCollection.d.ts.map +1 -0
  9. package/dist/collections/CustomerCollection.d.ts +58 -0
  10. package/dist/collections/CustomerCollection.d.ts.map +1 -0
  11. package/dist/collections/FulfillmentCollection.d.ts +75 -0
  12. package/dist/collections/FulfillmentCollection.d.ts.map +1 -0
  13. package/dist/collections/InvoiceCollection.d.ts +162 -0
  14. package/dist/collections/InvoiceCollection.d.ts.map +1 -0
  15. package/dist/collections/InvoiceLineItemCollection.d.ts +90 -0
  16. package/dist/collections/InvoiceLineItemCollection.d.ts.map +1 -0
  17. package/dist/collections/PaymentAllocationCollection.d.ts +86 -0
  18. package/dist/collections/PaymentAllocationCollection.d.ts.map +1 -0
  19. package/dist/collections/PaymentCollection.d.ts +96 -0
  20. package/dist/collections/PaymentCollection.d.ts.map +1 -0
  21. package/dist/collections/PaymentIntentCollection.d.ts +66 -0
  22. package/dist/collections/PaymentIntentCollection.d.ts.map +1 -0
  23. package/dist/collections/PayoutCollection.d.ts +47 -0
  24. package/dist/collections/PayoutCollection.d.ts.map +1 -0
  25. package/dist/collections/VendorCollection.d.ts +59 -0
  26. package/dist/collections/VendorCollection.d.ts.map +1 -0
  27. package/dist/collections/index.d.ts +15 -0
  28. package/dist/collections/index.d.ts.map +1 -0
  29. package/dist/index.d.ts +5 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +5308 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/manifest.json +13852 -0
  34. package/dist/models/Contract.d.ts +425 -0
  35. package/dist/models/Contract.d.ts.map +1 -0
  36. package/dist/models/ContractLineItem.d.ts +92 -0
  37. package/dist/models/ContractLineItem.d.ts.map +1 -0
  38. package/dist/models/Customer.d.ts +98 -0
  39. package/dist/models/Customer.d.ts.map +1 -0
  40. package/dist/models/Fulfillment.d.ts +99 -0
  41. package/dist/models/Fulfillment.d.ts.map +1 -0
  42. package/dist/models/FulfillmentLineItem.d.ts +42 -0
  43. package/dist/models/FulfillmentLineItem.d.ts.map +1 -0
  44. package/dist/models/Invoice.d.ts +326 -0
  45. package/dist/models/Invoice.d.ts.map +1 -0
  46. package/dist/models/InvoiceLineItem.d.ts +120 -0
  47. package/dist/models/InvoiceLineItem.d.ts.map +1 -0
  48. package/dist/models/Payment.d.ts +269 -0
  49. package/dist/models/Payment.d.ts.map +1 -0
  50. package/dist/models/PaymentAllocation.d.ts +93 -0
  51. package/dist/models/PaymentAllocation.d.ts.map +1 -0
  52. package/dist/models/PaymentIntent.d.ts +341 -0
  53. package/dist/models/PaymentIntent.d.ts.map +1 -0
  54. package/dist/models/Payout.d.ts +200 -0
  55. package/dist/models/Payout.d.ts.map +1 -0
  56. package/dist/models/Vendor.d.ts +153 -0
  57. package/dist/models/Vendor.d.ts.map +1 -0
  58. package/dist/models/index.d.ts +17 -0
  59. package/dist/models/index.d.ts.map +1 -0
  60. package/dist/playground.d.ts +2 -0
  61. package/dist/playground.d.ts.map +1 -0
  62. package/dist/playground.js +108 -0
  63. package/dist/playground.js.map +1 -0
  64. package/dist/smrt-knowledge.json +5494 -0
  65. package/dist/svelte/components/InvoiceActions.svelte +191 -0
  66. package/dist/svelte/components/InvoiceActions.svelte.d.ts +26 -0
  67. package/dist/svelte/components/InvoiceActions.svelte.d.ts.map +1 -0
  68. package/dist/svelte/components/InvoiceCard.svelte +233 -0
  69. package/dist/svelte/components/InvoiceCard.svelte.d.ts +16 -0
  70. package/dist/svelte/components/InvoiceCard.svelte.d.ts.map +1 -0
  71. package/dist/svelte/components/InvoiceHeader.svelte +258 -0
  72. package/dist/svelte/components/InvoiceHeader.svelte.d.ts +26 -0
  73. package/dist/svelte/components/InvoiceHeader.svelte.d.ts.map +1 -0
  74. package/dist/svelte/components/InvoiceLineItems.svelte +322 -0
  75. package/dist/svelte/components/InvoiceLineItems.svelte.d.ts +24 -0
  76. package/dist/svelte/components/InvoiceLineItems.svelte.d.ts.map +1 -0
  77. package/dist/svelte/components/InvoiceTotals.svelte +193 -0
  78. package/dist/svelte/components/InvoiceTotals.svelte.d.ts +27 -0
  79. package/dist/svelte/components/InvoiceTotals.svelte.d.ts.map +1 -0
  80. package/dist/svelte/components/UnbilledItems.svelte +355 -0
  81. package/dist/svelte/components/UnbilledItems.svelte.d.ts +18 -0
  82. package/dist/svelte/components/UnbilledItems.svelte.d.ts.map +1 -0
  83. package/dist/svelte/i18n.d.ts +19 -0
  84. package/dist/svelte/i18n.d.ts.map +1 -0
  85. package/dist/svelte/i18n.js +19 -0
  86. package/dist/svelte/index.d.ts +40 -0
  87. package/dist/svelte/index.d.ts.map +1 -0
  88. package/dist/svelte/index.js +43 -0
  89. package/dist/svelte/playground.d.ts +103 -0
  90. package/dist/svelte/playground.d.ts.map +1 -0
  91. package/dist/svelte/playground.js +103 -0
  92. package/dist/svelte/types.d.ts +47 -0
  93. package/dist/svelte/types.d.ts.map +1 -0
  94. package/dist/svelte/types.js +4 -0
  95. package/dist/types/index.d.ts +234 -0
  96. package/dist/types/index.d.ts.map +1 -0
  97. package/dist/ui.d.ts +10 -0
  98. package/dist/ui.d.ts.map +1 -0
  99. package/dist/ui.js +85 -0
  100. package/dist/ui.js.map +1 -0
  101. package/package.json +87 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Commerce Svelte Components
3
+ *
4
+ * This module auto-registers all commerce UI components with the ModuleUIRegistry
5
+ * when imported. Import this module to enable registry-based component discovery.
6
+ *
7
+ * @example Direct imports
8
+ * ```typescript
9
+ * import { InvoiceCard, InvoiceHeader } from '@happyvertical/smrt-commerce/svelte';
10
+ * ```
11
+ *
12
+ * @example Registry-based discovery
13
+ * ```typescript
14
+ * import { ModuleUIRegistry } from '@happyvertical/smrt-ui/registry';
15
+ * import '@happyvertical/smrt-commerce/svelte'; // Auto-registers components
16
+ *
17
+ * const Component = ModuleUIRegistry.get('@happyvertical/smrt-commerce', 'invoice-card');
18
+ * ```
19
+ */
20
+ import { ModuleUIRegistry } from '@happyvertical/smrt-ui/registry';
21
+ import { COMMERCE_MODULE_META } from '../ui.js';
22
+ // Import components
23
+ import InvoiceActions from './components/InvoiceActions.svelte';
24
+ import InvoiceCard from './components/InvoiceCard.svelte';
25
+ import InvoiceHeader from './components/InvoiceHeader.svelte';
26
+ import InvoiceLineItems from './components/InvoiceLineItems.svelte';
27
+ import InvoiceTotals from './components/InvoiceTotals.svelte';
28
+ import UnbilledItems from './components/UnbilledItems.svelte';
29
+ // Export components
30
+ export { default as InvoiceActions } from './components/InvoiceActions.svelte';
31
+ export { default as InvoiceCard } from './components/InvoiceCard.svelte';
32
+ export { default as InvoiceHeader } from './components/InvoiceHeader.svelte';
33
+ export { default as InvoiceLineItems } from './components/InvoiceLineItems.svelte';
34
+ export { default as InvoiceTotals } from './components/InvoiceTotals.svelte';
35
+ export { default as UnbilledItems } from './components/UnbilledItems.svelte';
36
+ // Auto-register module and components with ModuleUIRegistry
37
+ ModuleUIRegistry.registerModule(COMMERCE_MODULE_META);
38
+ ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'invoice-card', InvoiceCard);
39
+ ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'invoice-header', InvoiceHeader);
40
+ ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'invoice-line-items', InvoiceLineItems);
41
+ ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'invoice-totals', InvoiceTotals);
42
+ ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'invoice-actions', InvoiceActions);
43
+ ModuleUIRegistry.register('@happyvertical/smrt-commerce', 'unbilled-items', UnbilledItems);
@@ -0,0 +1,103 @@
1
+ declare const _default: {
2
+ packageName: string;
3
+ displayName: string;
4
+ description: string | undefined;
5
+ moduleMeta: import("@happyvertical/smrt-types").SmrtModuleMeta;
6
+ entries: ({
7
+ id: string;
8
+ title: string;
9
+ description: string;
10
+ loadComponent: () => Promise<typeof import("./components/InvoiceCard.svelte")>;
11
+ order: number;
12
+ props: {
13
+ invoice: {
14
+ id: string;
15
+ invoiceNumber: string;
16
+ status: string;
17
+ issueDate: string;
18
+ dueDate: string;
19
+ totalAmount: number;
20
+ customerName: string;
21
+ projectName: string;
22
+ };
23
+ currency: string;
24
+ onclick: () => void;
25
+ status?: undefined;
26
+ onmarkpaid?: undefined;
27
+ onprint?: undefined;
28
+ onexport?: undefined;
29
+ items?: undefined;
30
+ onselectionchange?: undefined;
31
+ oncreate?: undefined;
32
+ };
33
+ modes: {
34
+ mock: {
35
+ label: string;
36
+ };
37
+ };
38
+ } | {
39
+ id: string;
40
+ title: string;
41
+ description: string;
42
+ loadComponent: () => Promise<typeof import("./components/InvoiceActions.svelte")>;
43
+ order: number;
44
+ props: {
45
+ status: string;
46
+ onmarkpaid: () => void;
47
+ onprint: () => void;
48
+ onexport: () => void;
49
+ invoice?: undefined;
50
+ currency?: undefined;
51
+ onclick?: undefined;
52
+ items?: undefined;
53
+ onselectionchange?: undefined;
54
+ oncreate?: undefined;
55
+ };
56
+ modes: {
57
+ mock: {
58
+ label: string;
59
+ };
60
+ };
61
+ } | {
62
+ id: string;
63
+ title: string;
64
+ description: string;
65
+ loadComponent: () => Promise<typeof import("./components/UnbilledItems.svelte")>;
66
+ order: number;
67
+ props: {
68
+ items: ({
69
+ id: string;
70
+ type: string;
71
+ description: string;
72
+ date: string;
73
+ amount: number;
74
+ category: string;
75
+ selected: boolean;
76
+ } | {
77
+ id: string;
78
+ type: string;
79
+ description: string;
80
+ date: string;
81
+ amount: number;
82
+ category: string;
83
+ selected?: undefined;
84
+ })[];
85
+ currency: string;
86
+ onselectionchange: () => void;
87
+ oncreate: () => void;
88
+ invoice?: undefined;
89
+ onclick?: undefined;
90
+ status?: undefined;
91
+ onmarkpaid?: undefined;
92
+ onprint?: undefined;
93
+ onexport?: undefined;
94
+ };
95
+ modes: {
96
+ mock: {
97
+ label: string;
98
+ };
99
+ };
100
+ })[];
101
+ };
102
+ export default _default;
103
+ //# sourceMappingURL=playground.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../src/svelte/playground.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,wBA+DE"}
@@ -0,0 +1,103 @@
1
+ import { COMMERCE_MODULE_META } from '../ui.js';
2
+ const noop = () => { };
3
+ const sampleInvoice = {
4
+ id: 'invoice-2026-0142',
5
+ invoiceNumber: 'INV-2026-0142',
6
+ status: 'sent',
7
+ issueDate: '2026-03-15T00:00:00.000Z',
8
+ dueDate: '2026-03-29T00:00:00.000Z',
9
+ totalAmount: 128450,
10
+ customerName: 'Riverstone Newsroom',
11
+ projectName: 'Editorial Systems Retainer',
12
+ };
13
+ const sampleUnbilledItems = [
14
+ {
15
+ id: 'unbilled-time-1',
16
+ type: 'time',
17
+ description: 'Governance workflow setup',
18
+ date: '2026-03-12T00:00:00.000Z',
19
+ amount: 42000,
20
+ category: 'Implementation',
21
+ selected: true,
22
+ },
23
+ {
24
+ id: 'unbilled-expense-1',
25
+ type: 'expense',
26
+ description: 'Contributor QA workshop',
27
+ date: '2026-03-14T00:00:00.000Z',
28
+ amount: 18500,
29
+ category: 'Training',
30
+ },
31
+ {
32
+ id: 'unbilled-time-2',
33
+ type: 'time',
34
+ description: 'Release validation and docs cleanup',
35
+ date: '2026-03-18T00:00:00.000Z',
36
+ amount: 33950,
37
+ category: 'QA',
38
+ },
39
+ ];
40
+ const loadInvoiceActions = () => import('./components/InvoiceActions.svelte');
41
+ const loadInvoiceCard = () => import('./components/InvoiceCard.svelte');
42
+ const loadUnbilledItems = () => import('./components/UnbilledItems.svelte');
43
+ export default {
44
+ packageName: '@happyvertical/smrt-commerce',
45
+ displayName: COMMERCE_MODULE_META.displayName,
46
+ description: COMMERCE_MODULE_META.description,
47
+ moduleMeta: COMMERCE_MODULE_META,
48
+ entries: [
49
+ {
50
+ id: 'invoice-card',
51
+ title: 'Invoice Card',
52
+ description: 'Compact invoice summary card used in billing and receivables views.',
53
+ loadComponent: loadInvoiceCard,
54
+ order: 1,
55
+ props: {
56
+ invoice: sampleInvoice,
57
+ currency: 'CAD',
58
+ onclick: noop,
59
+ },
60
+ modes: {
61
+ mock: {
62
+ label: 'Mock',
63
+ },
64
+ },
65
+ },
66
+ {
67
+ id: 'invoice-actions',
68
+ title: 'Invoice Actions',
69
+ description: 'Status-aware billing actions for sending, printing, exporting, and payment confirmation.',
70
+ loadComponent: loadInvoiceActions,
71
+ order: 2,
72
+ props: {
73
+ status: 'sent',
74
+ onmarkpaid: noop,
75
+ onprint: noop,
76
+ onexport: noop,
77
+ },
78
+ modes: {
79
+ mock: {
80
+ label: 'Mock',
81
+ },
82
+ },
83
+ },
84
+ {
85
+ id: 'unbilled-items',
86
+ title: 'Unbilled Items',
87
+ description: 'Selectable unbilled work list for creating a new invoice from accumulated items.',
88
+ loadComponent: loadUnbilledItems,
89
+ order: 3,
90
+ props: {
91
+ items: sampleUnbilledItems,
92
+ currency: 'CAD',
93
+ onselectionchange: noop,
94
+ oncreate: noop,
95
+ },
96
+ modes: {
97
+ mock: {
98
+ label: 'Mock',
99
+ },
100
+ },
101
+ },
102
+ ],
103
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Commerce component types
3
+ */
4
+ export type InvoiceStatus = 'draft' | 'sent' | 'viewed' | 'paid' | 'overdue' | 'cancelled';
5
+ export interface InvoiceData {
6
+ id: string;
7
+ invoiceNumber: string;
8
+ status: InvoiceStatus;
9
+ issueDate: Date | string;
10
+ dueDate?: Date | string | null;
11
+ totalAmount: number;
12
+ customerName?: string;
13
+ projectName?: string;
14
+ }
15
+ export interface LineItem {
16
+ /** Unique identifier */
17
+ id: string;
18
+ /** Item description */
19
+ description: string;
20
+ /** Quantity */
21
+ quantity: number;
22
+ /** Unit price in cents */
23
+ unitPrice: number;
24
+ /** Total amount in cents (quantity * unitPrice) */
25
+ amount: number;
26
+ /** Optional category */
27
+ category?: string;
28
+ /** Source type (expense, time, manual) */
29
+ sourceType?: 'expense' | 'time' | 'manual';
30
+ }
31
+ export interface UnbilledItem {
32
+ /** Unique identifier */
33
+ id: string;
34
+ /** Item type */
35
+ type: 'expense' | 'time';
36
+ /** Description */
37
+ description: string;
38
+ /** Date of item */
39
+ date: Date | string;
40
+ /** Amount in cents */
41
+ amount: number;
42
+ /** Category */
43
+ category?: string;
44
+ /** Selected state */
45
+ selected?: boolean;
46
+ }
47
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/svelte/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,SAAS,GACT,WAAW,CAAC;AAEhB,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,wBAAwB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB;IAChB,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Commerce component types
3
+ */
4
+ export {};
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Commerce package type definitions
3
+ * @packageDocumentation
4
+ */
5
+ export declare enum CustomerStatus {
6
+ ACTIVE = "active",
7
+ INACTIVE = "inactive",
8
+ SUSPENDED = "suspended"
9
+ }
10
+ /**
11
+ * Customer classification — drives channel access, pricing tier, and credit terms.
12
+ *
13
+ * - DTC: direct-to-consumer (end shopper). Pays via storefront checkout.
14
+ * - WHOLESALE: B2B buyer with negotiated terms (NET-30, line sheets, etc.).
15
+ * - RETAIL: in-store walk-in / point-of-sale customer.
16
+ */
17
+ export declare enum CustomerType {
18
+ DTC = "dtc",
19
+ WHOLESALE = "wholesale",
20
+ RETAIL = "retail"
21
+ }
22
+ export declare enum VendorStatus {
23
+ ACTIVE = "active",
24
+ INACTIVE = "inactive",
25
+ SUSPENDED = "suspended"
26
+ }
27
+ export declare enum ContractType {
28
+ ESTIMATE = "estimate",
29
+ ORDER = "order",
30
+ LEASE = "lease",
31
+ AGREEMENT = "agreement",
32
+ PURCHASE_ORDER = "purchase_order",
33
+ WHOLESALE_ORDER = "wholesale_order",
34
+ PRODUCTION_ORDER = "production_order",
35
+ CART = "cart",
36
+ /**
37
+ * Industry-neutral licensing primitive. The `LicenseSale` STI subtype
38
+ * carries an immutable rights snapshot, a licensee email, optional
39
+ * legal-entity / jurisdiction fields, and a signed-PDF reference.
40
+ * Any application that sells rights for a fee (stock media,
41
+ * music licensing, code-asset marketplace, license keys, etc.)
42
+ * uses this subtype.
43
+ */
44
+ LICENSE_SALE = "license_sale"
45
+ }
46
+ export declare enum ContractStatus {
47
+ DRAFT = "draft",
48
+ SENT = "sent",
49
+ ACCEPTED = "accepted",
50
+ DECLINED = "declined",
51
+ COMPLETED = "completed",
52
+ CANCELLED = "cancelled"
53
+ }
54
+ export declare enum FulfillmentType {
55
+ SHIPMENT = "shipment",
56
+ DELIVERY = "delivery",
57
+ PICKUP = "pickup",
58
+ DIGITAL = "digital",
59
+ SERVICE = "service"
60
+ }
61
+ export declare enum FulfillmentStatus {
62
+ PENDING = "pending",
63
+ PROCESSING = "processing",
64
+ SHIPPED = "shipped",
65
+ DELIVERED = "delivered",
66
+ CANCELLED = "cancelled"
67
+ }
68
+ export declare enum PaymentMethod {
69
+ CASH = "cash",
70
+ CHECK = "check",
71
+ CREDIT_CARD = "credit_card",
72
+ BANK_TRANSFER = "bank_transfer",
73
+ CRYPTO = "crypto",
74
+ OTHER = "other"
75
+ }
76
+ export declare enum PaymentStatus {
77
+ PENDING = "pending",
78
+ COMPLETED = "completed",
79
+ FAILED = "failed",
80
+ REFUNDED = "refunded",
81
+ CANCELLED = "cancelled"
82
+ }
83
+ /**
84
+ * Status machine for {@link Payout}.
85
+ *
86
+ * `pending → sent → confirmed → failed`. `failed` is terminal but the
87
+ * model exposes a dedicated `resetFromFailed()` so an operator can
88
+ * deliberately requeue a payout after fixing the underlying problem;
89
+ * the reset moves the row back to `pending` and clears the failure
90
+ * metadata.
91
+ *
92
+ * Skipping intermediate states is rejected — a `pending` payout cannot
93
+ * jump straight to `confirmed`, and a `sent` payout cannot regress to
94
+ * `pending` without going through `resetFromFailed()` first.
95
+ */
96
+ export declare enum PayoutStatus {
97
+ PENDING = "pending",
98
+ SENT = "sent",
99
+ CONFIRMED = "confirmed",
100
+ FAILED = "failed"
101
+ }
102
+ /**
103
+ * Status machine for {@link PaymentIntent}.
104
+ *
105
+ * `awaiting_payment → paid → (issued | retired)`, with `expired` and
106
+ * `cancelled` as alternate terminal states reachable from
107
+ * `awaiting_payment`.
108
+ *
109
+ * - `AWAITING_PAYMENT` — open quote, accepting any of the listed
110
+ * payment options.
111
+ * - `PAID` — one option was satisfied by an incoming payment. The
112
+ * other options are implicitly retired; later inbound funds to a
113
+ * retired option must be flagged for refund by the consumer.
114
+ * - `ISSUED` — downstream rights / contract / fulfillment have been
115
+ * created and linked. Terminal happy-path state.
116
+ * - `RETIRED` — paid but the satisfaction was reversed (refund,
117
+ * chargeback, etc.). Terminal.
118
+ * - `EXPIRED` — the USD-price-lock window passed without payment.
119
+ * Terminal.
120
+ * - `CANCELLED` — the buyer or the system explicitly cancelled the
121
+ * intent before it was paid. Terminal.
122
+ */
123
+ export declare enum PaymentIntentStatus {
124
+ AWAITING_PAYMENT = "awaiting_payment",
125
+ PAID = "paid",
126
+ ISSUED = "issued",
127
+ RETIRED = "retired",
128
+ EXPIRED = "expired",
129
+ CANCELLED = "cancelled"
130
+ }
131
+ /**
132
+ * One way for a {@link PaymentIntent} to be satisfied. The intent lists
133
+ * an array of these; satisfying any one of them transitions the intent
134
+ * to `PAID` and implicitly retires the rest.
135
+ *
136
+ * Industry-neutral: a marketplace that accepts USDC-on-Base and BTC
137
+ * lists two options; a SaaS billing flow that accepts Stripe and
138
+ * PayPal lists two; a kiosk that accepts only one rail lists one.
139
+ */
140
+ export interface PaymentOption {
141
+ /**
142
+ * Stable id of the `PaymentBackend` adapter that fulfills this
143
+ * option — must match a `backendId` the consumer's payment-routing
144
+ * layer recognises. Examples: `base-usdc`, `solana-usdc`, `btc`,
145
+ * `stripe`, `paypal`.
146
+ */
147
+ backendId: string;
148
+ /**
149
+ * Payout-rail-qualified currency code, e.g. `USDC-base`, `BTC`,
150
+ * `USD-stripe`. The same convention used by
151
+ * `Vendor.payoutAddresses` and `Payment.nativeCurrency`.
152
+ */
153
+ currency: string;
154
+ /**
155
+ * Optional chain identifier for blockchain-backed options (`base`,
156
+ * `ethereum`, `solana`, ...). Pure-fiat options leave this empty.
157
+ */
158
+ chain?: string;
159
+ /**
160
+ * Destination address / account id the buyer should send funds to
161
+ * for this option (EVM address, BTC address, Stripe payment-intent
162
+ * id, etc.).
163
+ */
164
+ payTo: string;
165
+ /**
166
+ * Amount denominated in `currency`. Stored at decimal precision —
167
+ * a USDC option might be `199.0`, a BTC option `0.00713`.
168
+ */
169
+ nativeAmount: number;
170
+ /**
171
+ * Optional on-chain memo / payment reference (Solana memo, BTC OP_RETURN
172
+ * tag, Stripe metadata key). Some backends use this to disambiguate
173
+ * which intent an inbound payment satisfies.
174
+ */
175
+ memo?: string;
176
+ /**
177
+ * Whether this option supports the x402 HTTP-402 payment-required
178
+ * flow. Consumers that build agent-driven flows use this flag to
179
+ * filter the offered options.
180
+ */
181
+ x402Capable?: boolean;
182
+ /**
183
+ * Optional per-option expiry — when a single rail's quote becomes
184
+ * stale earlier than the intent-wide price-lock window (e.g. a
185
+ * volatile-currency option that re-quotes more aggressively). ISO
186
+ * 8601 string. Empty / missing means "inherit the intent's
187
+ * `priceLockExpiresAt`".
188
+ */
189
+ expiresAt?: string;
190
+ }
191
+ export declare enum InvoiceStatus {
192
+ DRAFT = "draft",
193
+ SENT = "sent",
194
+ VIEWED = "viewed",
195
+ PARTIAL = "partial",
196
+ PAID = "paid",
197
+ OVERDUE = "overdue",
198
+ CANCELLED = "cancelled",
199
+ WRITTEN_OFF = "written_off"
200
+ }
201
+ /**
202
+ * Address structure used for billing and shipping
203
+ */
204
+ export interface Address {
205
+ street1?: string;
206
+ street2?: string;
207
+ city?: string;
208
+ state?: string;
209
+ postalCode?: string;
210
+ country?: string;
211
+ }
212
+ /**
213
+ * Options for recording a payment with ledger integration
214
+ */
215
+ export interface RecordPaymentOptions {
216
+ /** The ledger to record the journal entry in */
217
+ ledgerId: string;
218
+ /** Account ID for receivables (credit side) */
219
+ receivablesAccountId: string;
220
+ /** Account ID for cash/bank (debit side) */
221
+ cashAccountId: string;
222
+ }
223
+ /**
224
+ * Options for recognizing revenue on an invoice
225
+ */
226
+ export interface RecognizeRevenueOptions {
227
+ /** Account ID for accounts receivable (debit side) */
228
+ arAccountId: string;
229
+ /** Account ID for revenue (credit side) */
230
+ revenueAccountId: string;
231
+ /** Account ID for tax payable (credit side, optional) */
232
+ taxAccountId?: string;
233
+ }
234
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"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"}
package/dist/ui.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { ModuleUISlot, SmrtModuleMeta } from '@happyvertical/smrt-types';
2
+ /**
3
+ * Commerce module UI slots
4
+ */
5
+ export declare const COMMERCE_UI_SLOTS: Record<string, ModuleUISlot>;
6
+ /**
7
+ * Commerce module metadata
8
+ */
9
+ export declare const COMMERCE_MODULE_META: SmrtModuleMeta;
10
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAuD1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,cAuBlC,CAAC"}
package/dist/ui.js ADDED
@@ -0,0 +1,85 @@
1
+ const COMMERCE_UI_SLOTS = {
2
+ "invoice-card": {
3
+ id: "invoice-card",
4
+ label: "Invoice Card",
5
+ description: "Compact invoice display with status and amount",
6
+ icon: "file-text",
7
+ category: "display",
8
+ order: 1,
9
+ propsInterface: "InvoiceCardProps"
10
+ },
11
+ "invoice-header": {
12
+ id: "invoice-header",
13
+ label: "Invoice Header",
14
+ description: "Invoice header with customer and date information",
15
+ icon: "file-text",
16
+ category: "display",
17
+ order: 2,
18
+ propsInterface: "InvoiceHeaderProps"
19
+ },
20
+ "invoice-line-items": {
21
+ id: "invoice-line-items",
22
+ label: "Invoice Line Items",
23
+ description: "Table of invoice line items",
24
+ icon: "list",
25
+ category: "list",
26
+ order: 3,
27
+ propsInterface: "InvoiceLineItemsProps"
28
+ },
29
+ "invoice-totals": {
30
+ id: "invoice-totals",
31
+ label: "Invoice Totals",
32
+ description: "Invoice subtotal, tax, and total display",
33
+ icon: "calculator",
34
+ category: "display",
35
+ order: 4,
36
+ propsInterface: "InvoiceTotalsProps"
37
+ },
38
+ "invoice-actions": {
39
+ id: "invoice-actions",
40
+ label: "Invoice Actions",
41
+ description: "Action buttons for invoice operations",
42
+ icon: "more-horizontal",
43
+ category: "action",
44
+ order: 5,
45
+ propsInterface: "InvoiceActionsProps"
46
+ },
47
+ "unbilled-items": {
48
+ id: "unbilled-items",
49
+ label: "Unbilled Items",
50
+ description: "List of items ready for billing",
51
+ icon: "clock",
52
+ category: "list",
53
+ order: 6,
54
+ propsInterface: "UnbilledItemsProps"
55
+ }
56
+ };
57
+ const COMMERCE_MODULE_META = {
58
+ name: "@happyvertical/smrt-commerce",
59
+ displayName: "Commerce",
60
+ description: "Commerce models: contracts, invoices, payments",
61
+ uiSlots: COMMERCE_UI_SLOTS,
62
+ models: [
63
+ "Customer",
64
+ "Vendor",
65
+ "Contract",
66
+ "ContractLineItem",
67
+ "Fulfillment",
68
+ "FulfillmentLineItem",
69
+ "Payment"
70
+ ],
71
+ collections: [
72
+ "CustomerCollection",
73
+ "VendorCollection",
74
+ "ContractCollection",
75
+ "ContractLineItemCollection",
76
+ "FulfillmentCollection",
77
+ "FulfillmentLineItemCollection",
78
+ "PaymentCollection"
79
+ ]
80
+ };
81
+ export {
82
+ COMMERCE_MODULE_META,
83
+ COMMERCE_UI_SLOTS
84
+ };
85
+ //# sourceMappingURL=ui.js.map
package/dist/ui.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sources":["../src/ui.ts"],"sourcesContent":["/**\n * Commerce Module UI Slot Declarations\n *\n * This file defines the UI extension points for the commerce module.\n * UI components are implemented in the ./svelte subpath.\n *\n * @example Usage\n * ```typescript\n * // In application code\n * import { COMMERCE_MODULE_META } from '@happyvertical/smrt-commerce';\n * console.log(COMMERCE_MODULE_META.uiSlots);\n * ```\n */\n\nimport type { ModuleUISlot, SmrtModuleMeta } from '@happyvertical/smrt-types';\n\n/**\n * Commerce module UI slots\n */\nexport const COMMERCE_UI_SLOTS: Record<string, ModuleUISlot> = {\n 'invoice-card': {\n id: 'invoice-card',\n label: 'Invoice Card',\n description: 'Compact invoice display with status and amount',\n icon: 'file-text',\n category: 'display',\n order: 1,\n propsInterface: 'InvoiceCardProps',\n },\n 'invoice-header': {\n id: 'invoice-header',\n label: 'Invoice Header',\n description: 'Invoice header with customer and date information',\n icon: 'file-text',\n category: 'display',\n order: 2,\n propsInterface: 'InvoiceHeaderProps',\n },\n 'invoice-line-items': {\n id: 'invoice-line-items',\n label: 'Invoice Line Items',\n description: 'Table of invoice line items',\n icon: 'list',\n category: 'list',\n order: 3,\n propsInterface: 'InvoiceLineItemsProps',\n },\n 'invoice-totals': {\n id: 'invoice-totals',\n label: 'Invoice Totals',\n description: 'Invoice subtotal, tax, and total display',\n icon: 'calculator',\n category: 'display',\n order: 4,\n propsInterface: 'InvoiceTotalsProps',\n },\n 'invoice-actions': {\n id: 'invoice-actions',\n label: 'Invoice Actions',\n description: 'Action buttons for invoice operations',\n icon: 'more-horizontal',\n category: 'action',\n order: 5,\n propsInterface: 'InvoiceActionsProps',\n },\n 'unbilled-items': {\n id: 'unbilled-items',\n label: 'Unbilled Items',\n description: 'List of items ready for billing',\n icon: 'clock',\n category: 'list',\n order: 6,\n propsInterface: 'UnbilledItemsProps',\n },\n};\n\n/**\n * Commerce module metadata\n */\nexport const COMMERCE_MODULE_META: SmrtModuleMeta = {\n name: '@happyvertical/smrt-commerce',\n displayName: 'Commerce',\n description: 'Commerce models: contracts, invoices, payments',\n uiSlots: COMMERCE_UI_SLOTS,\n models: [\n 'Customer',\n 'Vendor',\n 'Contract',\n 'ContractLineItem',\n 'Fulfillment',\n 'FulfillmentLineItem',\n 'Payment',\n ],\n collections: [\n 'CustomerCollection',\n 'VendorCollection',\n 'ContractCollection',\n 'ContractLineItemCollection',\n 'FulfillmentCollection',\n 'FulfillmentLineItemCollection',\n 'PaymentCollection',\n ],\n};\n"],"names":[],"mappings":"AAmBO,MAAM,oBAAkD;AAAA,EAC7D,gBAAgB;AAAA,IACd,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,gBAAgB;AAAA,EAAA;AAAA,EAElB,kBAAkB;AAAA,IAChB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,gBAAgB;AAAA,EAAA;AAAA,EAElB,sBAAsB;AAAA,IACpB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,gBAAgB;AAAA,EAAA;AAAA,EAElB,kBAAkB;AAAA,IAChB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,gBAAgB;AAAA,EAAA;AAAA,EAElB,mBAAmB;AAAA,IACjB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,gBAAgB;AAAA,EAAA;AAAA,EAElB,kBAAkB;AAAA,IAChB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,gBAAgB;AAAA,EAAA;AAEpB;AAKO,MAAM,uBAAuC;AAAA,EAClD,MAAM;AAAA,EACN,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,EACT,QAAQ;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,aAAa;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}