@happyvertical/smrt-commerce 0.55.23 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +9 -9
- package/README.md +75 -4
- package/agents/customer-vendor-ui.md +61 -2
- package/agents/purchasing-ui.md +4 -3
- package/agents/quote-ui.md +3 -2
- package/dist/chunks/types-zVnIjSOk.js.map +1 -1
- package/dist/collections/ContractCollection.d.ts +2 -0
- package/dist/collections/ContractCollection.d.ts.map +1 -1
- package/dist/collections/PurchaseContractCollection.d.ts +8 -0
- package/dist/collections/PurchaseContractCollection.d.ts.map +1 -0
- package/dist/collections/SalesContractCollection.d.ts +8 -0
- package/dist/collections/SalesContractCollection.d.ts.map +1 -0
- package/dist/collections/index.d.ts +2 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +502 -88
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2253 -847
- package/dist/migrations/partyLinks.d.ts +39 -0
- package/dist/migrations/partyLinks.d.ts.map +1 -0
- package/dist/models/Contract.d.ts +37 -27
- package/dist/models/Contract.d.ts.map +1 -1
- package/dist/models/ContractLineItem.d.ts.map +1 -1
- package/dist/models/Customer.d.ts +13 -1
- package/dist/models/Customer.d.ts.map +1 -1
- package/dist/models/Invoice.d.ts.map +1 -1
- package/dist/models/InvoiceLineItem.d.ts.map +1 -1
- package/dist/models/PaymentAllocation.d.ts.map +1 -1
- package/dist/models/Vendor.d.ts +6 -1
- package/dist/models/Vendor.d.ts.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/party-contacts.d.ts +146 -0
- package/dist/party-contacts.d.ts.map +1 -0
- package/dist/recipes.d.ts +2 -32
- package/dist/recipes.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +967 -365
- package/dist/svelte/components/CustomerDetail.svelte +16 -5
- package/dist/svelte/components/CustomerDetail.svelte.d.ts +5 -0
- package/dist/svelte/components/CustomerDetail.svelte.d.ts.map +1 -1
- package/dist/svelte/components/CustomerDirectory.svelte +16 -5
- package/dist/svelte/components/CustomerDirectory.svelte.d.ts +5 -0
- package/dist/svelte/components/CustomerDirectory.svelte.d.ts.map +1 -1
- package/dist/svelte/components/CustomerForm.svelte +23 -0
- package/dist/svelte/components/CustomerForm.svelte.d.ts +9 -2
- package/dist/svelte/components/CustomerForm.svelte.d.ts.map +1 -1
- package/dist/svelte/components/PartyContactFields.svelte +4 -0
- package/dist/svelte/components/PartyContactFields.svelte.d.ts.map +1 -1
- package/dist/svelte/components/VendorDetail.svelte +16 -5
- package/dist/svelte/components/VendorDetail.svelte.d.ts +5 -0
- package/dist/svelte/components/VendorDetail.svelte.d.ts.map +1 -1
- package/dist/svelte/components/VendorDirectory.svelte +16 -5
- package/dist/svelte/components/VendorDirectory.svelte.d.ts +5 -0
- package/dist/svelte/components/VendorDirectory.svelte.d.ts.map +1 -1
- package/dist/svelte/components/VendorForm.svelte +23 -0
- package/dist/svelte/components/VendorForm.svelte.d.ts +9 -2
- package/dist/svelte/components/VendorForm.svelte.d.ts.map +1 -1
- package/dist/svelte/index.d.ts +1 -1
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/party-types.d.ts +15 -1
- package/dist/svelte/party-types.d.ts.map +1 -1
- package/dist/svelte/party-types.js +1 -0
- package/dist/types/index.d.ts +25 -4
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +11 -11
package/AGENTS.md
CHANGED
|
@@ -4,8 +4,8 @@ E-commerce with Contract STI hierarchy, invoice lifecycle, payment tracking, pay
|
|
|
4
4
|
|
|
5
5
|
## Models
|
|
6
6
|
|
|
7
|
-
- **Customer** / **Vendor**: linked to Profile via string ID (not FK). Customer has creditLimit, paymentTerms, customerType (DTC / WHOLESALE / RETAIL). Vendor has leadTimeDays, minimumOrder, and `payoutAddresses: Record<string, string>` — a flat map from payout-rail-qualified currency code (`USDC-base`, `BTC`, `USD-stripe`, ...) to destination string (EVM address, BTC address, Stripe Connect account id, IBAN). Use `getPayoutAddress(currency)` for a `Map.get`-style lookup; missing entries return `undefined` (caller decides skip-vs-error).
|
|
8
|
-
- **Contract
|
|
7
|
+
- **Customer** / **Vendor**: linked to Profile via string ID (not FK). `contacts` (JSON) is written via [`savePartyContacts()`](agents/customer-vendor-ui.md#contact-rows-3501). Customer has creditLimit, paymentTerms, customerType (DTC / WHOLESALE / RETAIL). Vendor has leadTimeDays, minimumOrder, and `payoutAddresses: Record<string, string>` — a flat map from payout-rail-qualified currency code (`USDC-base`, `BTC`, `USD-stripe`, ...) to destination string (EVM address, BTC address, Stripe Connect account id, IBAN). Use `getPayoutAddress(currency)` for a `Map.get`-style lookup; missing entries return `undefined` (caller decides skip-vs-error).
|
|
8
|
+
- **Contract**: concrete STI base. Abstract **SalesContract** owns `customerId`; **PurchaseContract** owns `vendorId`. `channelId` is open-ended. Before upgrade, run `preflightCommercePartyLinks(db)` and repair linked base rows, stray parties, and wrong-branch links. See [README](README.md).
|
|
9
9
|
- **WholesaleOrder**: B2B order. Conventional pairing — customer has `customerType: 'wholesale'`, NET-30/60 terms, delivered via wholesale-portal channel.
|
|
10
10
|
- **ProductionOrder**: manufacturing equivalent of a PurchaseOrder — commission your factory to make finished goods. Consumes raw materials per BOM (`@happyvertical/smrt-manufacturing`) and produces SKU stock (`@happyvertical/smrt-inventory`).
|
|
11
11
|
- **Cart**: transient order-in-progress. Same shape as Order; the application promotes the row from `_meta_type: Cart` to `_meta_type: Order` at checkout instead of copying data between tables.
|
|
@@ -13,9 +13,9 @@ E-commerce with Contract STI hierarchy, invoice lifecycle, payment tracking, pay
|
|
|
13
13
|
- **ContractLineItem**: items on contracts.
|
|
14
14
|
- **Invoice**: status machine `DRAFT → SENT → VIEWED → PARTIAL → PAID` (also OVERDUE, CANCELLED, WRITTEN_OFF). `recognizeRevenue()` creates balanced AR journal entry (DR: Accounts Receivable, CR: Revenue, CR: Tax Payable).
|
|
15
15
|
- **InvoiceLineItem**: fractional-quantity line items with safe minor-unit validation/recalculation on save; editor-mode recovery and existing-column migration are documented in [invoice quantity persistence](agents/invoice-quantity.md).
|
|
16
|
-
- **Payment** / **PaymentAllocation**: tracks payments against invoices
|
|
17
|
-
- **PaymentInstrument**: reusable saved payment method ("card on file"). Stores only provider references and non-sensitive display metadata (`providerCustomerId`, `providerPaymentMethodId`, brand / last4 / expiry), never raw card data.
|
|
18
|
-
- **PaymentIntent**: short-lived pre-payment commitment with multi-option semantics. Locks a USD price for a fixed window (default 15 minutes) and lists one or more `PaymentOption`s describing different rails (`backendId`, `currency`, `payTo`, `nativeAmount`, optional `chain` / `memo` / `x402Capable` / `expiresAt`). First option to receive payment wins; the others are implicitly retired. State machine `awaiting_payment → paid → (issued | retired)` plus `expired` and `cancelled`. Mutate via dedicated `markPaid` / `markIssued` / `expire` / `cancel` / `retire` helpers — direct status assignment bypasses the invariant checks. Idempotency
|
|
16
|
+
- **Payment** / **PaymentAllocation**: tracks payments against invoices (status: see Gotchas). Carries optional backend-adapter fields for PaymentBackend-routed flows: `backendId` (rail adapter id — `base-usdc`, `btc`, `stripe`, distinct from `externalProvider` which names an accounting sync destination), `backendTxRef` (chain tx hash or gateway settlement id), `nativeAmount` / `nativeCurrency` (what actually arrived), `usdAtQuote` / `usdAtConfirmation` (drift accounting for volatile-currency rails). `Payment.usdDrift()` returns the confirmation - quote delta, or `0` when either side is unset.
|
|
17
|
+
- **PaymentInstrument**: reusable saved payment method ("card on file"). Stores only provider references and non-sensitive display metadata (`providerCustomerId`, `providerPaymentMethodId`, brand / last4 / expiry), never raw card data. `isDefault` is domain-managed, not API-writable: `PaymentInstrumentCollection.setDefaultForCustomer(customerId, instrumentId)` validates the target and clears the customer's other defaults (one per customer).
|
|
18
|
+
- **PaymentIntent**: short-lived pre-payment commitment with multi-option semantics. Locks a USD price for a fixed window (default 15 minutes) and lists one or more `PaymentOption`s describing different rails (`backendId`, `currency`, `payTo`, `nativeAmount`, optional `chain` / `memo` / `x402Capable` / `expiresAt`). First option to receive payment wins; the others are implicitly retired. State machine `awaiting_payment → paid → (issued | retired)` plus `expired` and `cancelled`. Mutate via dedicated `markPaid` / `markIssued` / `expire` / `cancel` / `retire` helpers — direct status assignment bypasses the invariant checks. Idempotency: see the natural-key Gotcha.
|
|
19
19
|
- **Payout**: operator-to-supplier remittance. Distinct from Payment because direction, status machine, and chain semantics differ. Status machine `pending → sent → confirmed → failed` (failed is terminal but resettable via `resetFromFailed()` after fixing the underlying problem). References source `paymentId` (plain string) and destination `vendorId` (foreign key). Amount invariant `supplierNet === grossAmount - operatorFee` enforced exactly on save (integer minor units, no tolerance — #2401). `PayoutCollection.createFromPayment()` is the typical entry point; it pulls native amount / currency from the source Payment.
|
|
20
20
|
- **Fulfillment** / **FulfillmentLineItem**: shipment/delivery tracking.
|
|
21
21
|
|
|
@@ -36,7 +36,7 @@ retry identity, parent corrections and supported dialects.
|
|
|
36
36
|
|
|
37
37
|
## Ledger Integration
|
|
38
38
|
|
|
39
|
-
`@happyvertical/smrt-ledgers` is a regular dependency, loaded lazily via dynamic `import()`
|
|
39
|
+
`@happyvertical/smrt-ledgers` is a regular dependency, loaded lazily via dynamic `import()` (never a static import) so the package graph stays a DAG (#1582). Invoice stores `arJournalId` and `revenueJournalId` as string references. `recognizeRevenue()` creates a balanced AR journal entry; `getArJournal()` returns null when no journal has been recognized yet.
|
|
40
40
|
|
|
41
41
|
## Billing-period close (#3060)
|
|
42
42
|
|
|
@@ -150,6 +150,7 @@ for usage.
|
|
|
150
150
|
## Cross-Package References
|
|
151
151
|
|
|
152
152
|
- `customerId` → `@foreignKey('Customer')` (hard reference within package)
|
|
153
|
+
- `vendorId` → `@foreignKey('Vendor')` on PurchaseContract only
|
|
153
154
|
- `profileId` → plain string to smrt-profiles
|
|
154
155
|
- `arJournalId`, `revenueJournalId` → plain string to smrt-ledgers
|
|
155
156
|
- `skuId` (on `PaymentIntent`, `LicenseSale`) → plain string to smrt-products
|
|
@@ -171,16 +172,15 @@ for usage.
|
|
|
171
172
|
- **Invoice controls payment status**: not the Payment model — use `Invoice.updatePaymentStatus()`
|
|
172
173
|
- **Tax rate is external**: no tax rate field on Invoice — rate must be calculated externally
|
|
173
174
|
- **Profile linking**: separate `ProfileCollection.create()` needed to fetch actual Profile object
|
|
174
|
-
- **PaymentIntent natural key**: `conflictColumns: ['tenant_id', 'offering_ref', 'licensee_email', 'idempotency_key']` — a retried `create` with the same tuple upserts the existing row. Use `getOrCreateByIdempotencyKey()` to branch on `{ intent, created }`. Empty natural-key inputs (e.g. blank `idempotencyKey`) disable dedup by design.
|
|
175
|
+
- **PaymentIntent natural key**: `conflictColumns: ['tenant_id', 'offering_ref', 'licensee_email', 'idempotency_key']` — a retried `create` with the same tuple upserts the existing row. Use `PaymentIntentCollection.getOrCreateByIdempotencyKey()` to branch on `{ intent, created }`. Empty natural-key inputs (e.g. blank `idempotencyKey`) disable dedup by design.
|
|
175
176
|
- **Payout state-machine guards**: `markSent` requires a non-empty `backendTxRef`; `markConfirmed` only valid from `SENT`; `markFailed` only valid from `PENDING` / `SENT` (a confirmed payout can't fail — that path is a refund). `resetFromFailed()` is the dedicated escape hatch from `FAILED` back to `PENDING` after an operator fixes the underlying problem; it clears `backendTxRef` so the next attempt picks up a fresh one.
|
|
176
|
-
- **PaymentInstrument defaults**: `isDefault` is domain-managed, not API-writable. Call `setDefaultForCustomer(customerId, instrumentId)` so the target is validated and the customer's other instruments are cleared.
|
|
177
177
|
- **LicenseSale immutability**: rights snapshot freezes on save-with-status-ACCEPTED. The captured snapshot lives in a module-scoped `WeakMap<LicenseSale, string>` so it doesn't interact with the schema or round-trip through `_meta_data`. Drafts (status != ACCEPTED) remain mutable. To "change" an issued license: `revoke()` it, then issue a new `LicenseSale` row.
|
|
178
178
|
- **Vendor.payoutAddresses normalization**: the constructor accepts either a `Record<string, string>` or a pre-serialized JSON string. `initialize()` re-normalizes after the framework's option-override pass; `save()` re-normalizes defensively against direct field assignment. Non-string values inside the input map are silently dropped to preserve the typed invariant downstream.
|
|
179
179
|
|
|
180
180
|
## Commercial UI
|
|
181
181
|
|
|
182
182
|
`CustomerSelect`/`VendorSelect` are the registered selectors for Customer and
|
|
183
|
-
Vendor (`selects` in `src/ui.ts`); models carry `ui.widget` hints. See
|
|
183
|
+
Vendor (`selects` in `src/ui.ts`); models carry `ui.widget` / `ui.format` hints. See
|
|
184
184
|
[customer/vendor UI](agents/customer-vendor-ui.md#selectors-3602).
|
|
185
185
|
|
|
186
186
|
See [commercial UI composition](agents/commercial-ui.md) for native form recovery, amount compatibility and backend ownership. Package-owned guides under `agents/` ship with the package.
|
package/README.md
CHANGED
|
@@ -82,11 +82,47 @@ await payment.recordPayment({
|
|
|
82
82
|
|
|
83
83
|
### Models
|
|
84
84
|
|
|
85
|
+
#### Upgrading contract parties (#3898)
|
|
86
|
+
|
|
87
|
+
`Contract` no longer declares `customerId` or `vendorId`. Narrow a contract to
|
|
88
|
+
`SalesContract` to read `customerId`, or to `PurchaseContract` to read `vendorId`.
|
|
89
|
+
The nine leaf qualified names and the `contracts` table stay the same; a
|
|
90
|
+
`db:migrate --dry-run` against a v0.55.19 schema reports no DDL changes on
|
|
91
|
+
SQLite or PostgreSQL. Sales leaves no longer accept `vendorId`; purchase leaves
|
|
92
|
+
no longer accept `customerId`. `Order`, `Estimate`, `Agreement`, `Lease`, and
|
|
93
|
+
`WholesaleOrder` require a customer on save. `PurchaseOrder` requires a vendor.
|
|
94
|
+
`Cart`, `LicenseSale`, and `ProductionOrder` retain optional parties on their side.
|
|
95
|
+
|
|
96
|
+
Before upgrading existing data, run the read-only
|
|
97
|
+
`preflightCommercePartyLinks(db)` and inspect its stray party links, missing
|
|
98
|
+
required parties, base-typed rows, discriminator mismatches, and invalid
|
|
99
|
+
document references. Its `unqualifiedDiscriminatorRows` lists legacy simple
|
|
100
|
+
`_meta_type` values such as `Order` and `PurchaseOrder`; retype them to the
|
|
101
|
+
qualified class name before upgrading, since branch collections cannot read
|
|
102
|
+
them. The report checks invoice, payment, fulfillment, ad group,
|
|
103
|
+
and expense links when those tables exist. A linked base-typed or wrong-branch
|
|
104
|
+
contract blocks the next save of its document even when the link is unchanged.
|
|
105
|
+
Registered custom descendants of either contract branch are accepted in link
|
|
106
|
+
checks; load those model classes before running the preflight.
|
|
107
|
+
Tenant-owned documents linked to global or other-tenant contracts are also
|
|
108
|
+
reported because the save-time lookup is tenant-scoped. Retype the contract to
|
|
109
|
+
the correct leaf, assign it to the document's tenant, or repair the link before
|
|
110
|
+
deployment. The deprecated `ContractCollection` party finders now return the
|
|
111
|
+
appropriate branch
|
|
112
|
+
only, so retype legacy base rows with party links before relying on those
|
|
113
|
+
finders. Clear stray party columns and fill required parties before deploying
|
|
114
|
+
writers that save affected rows. Missing required parties remain readable but
|
|
115
|
+
fail their next save. Regenerate cached manifests, planner catalogs, and
|
|
116
|
+
generated screens after upgrading.
|
|
117
|
+
This preflight never edits rows; an operator chooses the data correction.
|
|
118
|
+
|
|
85
119
|
| Export | Description |
|
|
86
120
|
|--------|------------|
|
|
87
|
-
| `Customer` | Customer record with creditLimit, paymentTerms, tax exemption, addresses |
|
|
88
|
-
| `Vendor` | Vendor/supplier with leadTimeDays, minimumOrderAmount, currency |
|
|
121
|
+
| `Customer` | Customer record with creditLimit, paymentTerms, tax exemption, addresses, contacts |
|
|
122
|
+
| `Vendor` | Vendor/supplier with leadTimeDays, minimumOrderAmount, currency, contacts |
|
|
89
123
|
| `Contract` | STI base class for all commercial agreements |
|
|
124
|
+
| `SalesContract` | Abstract customer-side Contract branch; owns `customerId` |
|
|
125
|
+
| `PurchaseContract` | Abstract supplier-side Contract branch; owns `vendorId` |
|
|
90
126
|
| `Estimate` | Quote or proposal sent to a customer |
|
|
91
127
|
| `Order` | Customer purchase order |
|
|
92
128
|
| `Lease` | Rental or lease agreement |
|
|
@@ -105,7 +141,7 @@ await payment.recordPayment({
|
|
|
105
141
|
|
|
106
142
|
### Collections
|
|
107
143
|
|
|
108
|
-
`CustomerCollection`, `VendorCollection`, `ContractCollection`, `InvoiceCollection`, `InvoiceLineItemCollection`, `PaymentCollection`, `PaymentAllocationCollection`, `FulfillmentCollection`
|
|
144
|
+
`CustomerCollection`, `VendorCollection`, `ContractCollection`, `SalesContractCollection`, `PurchaseContractCollection`, `InvoiceCollection`, `InvoiceLineItemCollection`, `PaymentCollection`, `PaymentAllocationCollection`, `FulfillmentCollection`
|
|
109
145
|
|
|
110
146
|
`PaymentAllocationCollection.allocatePayment()` splits a payment across invoices
|
|
111
147
|
in one transaction using stable allocation IDs for retries. Direct allocation
|
|
@@ -118,7 +154,7 @@ replay, parent revision refresh and compatibility requirements.
|
|
|
118
154
|
|
|
119
155
|
| Export | Values |
|
|
120
156
|
|--------|--------|
|
|
121
|
-
| `ContractType` | `estimate`, `order`, `lease`, `agreement`, `purchase_order` |
|
|
157
|
+
| `ContractType` | `estimate`, `order`, `lease`, `agreement`, `purchase_order`, `wholesale_order`, `production_order`, `cart`, `license_sale` |
|
|
122
158
|
| `ContractStatus` | `draft`, `sent`, `accepted`, `declined`, `completed`, `cancelled` |
|
|
123
159
|
| `CustomerStatus` | `active`, `inactive`, `suspended` |
|
|
124
160
|
| `VendorStatus` | `active`, `inactive`, `suspended` |
|
|
@@ -550,6 +586,41 @@ native forms, recovery, amount units and consumer adoption, plus the focused
|
|
|
550
586
|
[customer/vendor](agents/customer-vendor-ui.md) and
|
|
551
587
|
[quotation](agents/quote-ui.md) contracts for selector restrictions.
|
|
552
588
|
|
|
589
|
+
## Customer and vendor contacts
|
|
590
|
+
|
|
591
|
+
`Customer.contacts` and `Vendor.contacts` hold the people to reach at a party
|
|
592
|
+
(`PartyContact`: `id`, `name`, `label`, `email`, `phone`, `address`) as a JSON
|
|
593
|
+
column; existing databases need `smrt db:migrate` for the new `contacts`
|
|
594
|
+
columns. The form's contact rows are written with `savePartyContacts()`:
|
|
595
|
+
|
|
596
|
+
```typescript
|
|
597
|
+
import {
|
|
598
|
+
applyPartyContactIntent,
|
|
599
|
+
PartyContactValidationError,
|
|
600
|
+
readPartyContactRows,
|
|
601
|
+
savePartyContacts,
|
|
602
|
+
} from '@happyvertical/smrt-commerce';
|
|
603
|
+
|
|
604
|
+
const form = await request.formData();
|
|
605
|
+
// Throws PartyContactPayloadError when the form's contactCount marker is absent
|
|
606
|
+
// (block not rendered, or fieldNames differ), so a save never deletes by accident.
|
|
607
|
+
const rows = readPartyContactRows(form); // pass the form's fieldNames if overridden
|
|
608
|
+
const { contacts, handled } = applyPartyContactIntent(rows, String(form.get('intent')));
|
|
609
|
+
if (handled) return { values: { ...values, contacts } }; // add/remove round trip, no save
|
|
610
|
+
try {
|
|
611
|
+
await savePartyContacts(vendors, vendorId, rows, { expectedTenantId });
|
|
612
|
+
} catch (error) {
|
|
613
|
+
if (error instanceof PartyContactValidationError)
|
|
614
|
+
return fail(400, { values: { ...values, contacts: rows }, errors: { contacts: toMessages(error.errors) } });
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
`savePartyContacts` also accepts the `FormData` itself (with `fieldNames`) and
|
|
620
|
+
reads it the same way. The rows replace the party's contacts: posted ids are kept, new rows get an
|
|
621
|
+
id, unposted rows are removed, blank rows are dropped. See
|
|
622
|
+
[customer/vendor UI](agents/customer-vendor-ui.md#contact-rows-3501).
|
|
623
|
+
|
|
553
624
|
## Customer and vendor selectors
|
|
554
625
|
|
|
555
626
|
`CustomerSelect` and `VendorSelect` from `@happyvertical/smrt-commerce/svelte`
|
|
@@ -34,7 +34,7 @@ Import the provider-free surfaces from `@happyvertical/smrt-commerce/svelte`:
|
|
|
34
34
|
/>
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
The caller owns action URLs, server authorization, tenancy checks, request tokens, persistence, and retry behavior. Capability props only decide whether an affordance is rendered. The components never create a Profile, Customer, Vendor, or contact relationship and never generate request tokens.
|
|
37
|
+
The caller owns action URLs, server authorization, tenancy checks, request tokens, persistence, and retry behavior. Capability props only decide whether an affordance is rendered. The components never create a Profile, Customer, Vendor, or contact relationship and never generate request tokens; the server writes posted contact rows with `savePartyContacts()` ([contact rows](#contact-rows-3501)).
|
|
38
38
|
|
|
39
39
|
`CustomerDisplayData.creditLimitMinor` and `VendorDisplayData.minimumOrderMinor` are integer currency minor units. Detail components convert them only for display and accept an explicit `minorUnitExponent`. Form values deliberately use retained strings such as `1250.00`; the server validates and converts those major-unit strings to the model's integer minor units.
|
|
40
40
|
|
|
@@ -42,6 +42,23 @@ The caller owns action URLs, server authorization, tenancy checks, request token
|
|
|
42
42
|
|
|
43
43
|
Forms use the provider-free `Form`, `Input`, `Select`, `Textarea`, and `Checkbox` controls from `@happyvertical/smrt-ui/forms`. They default to native `POST` submission through `preventDefault={false}`. `transport.hiddenFields`, `transport.intentName`, and the field-name maps let an application preserve its existing payload contract. Repeatable contact rows submit repeated field names in DOM order. Add and remove controls are native submitters, so they work without JavaScript; the server returns the revised rows and retained values.
|
|
44
44
|
|
|
45
|
+
`CustomerForm` and `VendorForm` accept submit hooks so a host never has to find
|
|
46
|
+
the form after mount (#3501). `enhance` (`PartyFormEnhance`, action-shaped) is
|
|
47
|
+
applied to the mounted native `<form>` and destroyed with it; SvelteKit's
|
|
48
|
+
`enhance` from `$app/forms` fits directly, or wrap it to pass a submit callback.
|
|
49
|
+
An `ssr = false` app needs it, because a plain native post answers with the
|
|
50
|
+
empty shell. `onsubmit` receives the native submit event (submission stays
|
|
51
|
+
native unless it calls `preventDefault()`), and the `getFormElement()` instance
|
|
52
|
+
method returns the native element while mounted.
|
|
53
|
+
|
|
54
|
+
```svelte
|
|
55
|
+
<script lang="ts">
|
|
56
|
+
import { enhance } from '$app/forms';
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<VendorForm values={form?.values ?? data.values} errors={form?.errors} transport={{ action: '?/save' }} {enhance} />
|
|
60
|
+
```
|
|
61
|
+
|
|
45
62
|
Directory search forms accept `hiddenFields` as a string record for caller-owned GET state such as sort direction and page size. Fields whose names equal the resolved `queryName` or `statusName` are omitted so the visible search controls remain authoritative.
|
|
46
63
|
|
|
47
64
|
Customer shipping and billing addresses use the shared `CountrySelect` and
|
|
@@ -73,6 +90,13 @@ Use the `extension` snippets for application fields such as construction roles a
|
|
|
73
90
|
|
|
74
91
|
Directory entries carry caller-owned detail links and pagination links. Detail edit links and form submit buttons appear only when their capability props allow them; the server must still authorize every request.
|
|
75
92
|
|
|
93
|
+
`CustomerDirectory`, `CustomerDetail`, `VendorDirectory`, and `VendorDetail`
|
|
94
|
+
render a `PageHeader` (the page `h1`, a subtitle, and the add/edit action) by
|
|
95
|
+
default. A host that frames every page itself passes `headless` to render only
|
|
96
|
+
the body, then renders its own heading and create/edit affordance; or passes a
|
|
97
|
+
`header` snippet to replace the built-in header in place (#3501). `backHref`
|
|
98
|
+
stays independent of both.
|
|
99
|
+
|
|
76
100
|
Directory empty and filter behavior follows this contract:
|
|
77
101
|
|
|
78
102
|
| State | Empty guidance | Native form behavior |
|
|
@@ -92,6 +116,27 @@ The registry keys are `customer-directory`, `customer-detail`, `customer-form`,
|
|
|
92
116
|
|
|
93
117
|
The form playground previews handle save, add-contact, and remove-contact intents in memory. They deliberately return a simulated validation error on save so retained values and retry behavior can be inspected without a backend.
|
|
94
118
|
|
|
119
|
+
## Contact rows (#3501)
|
|
120
|
+
|
|
121
|
+
`Customer.contacts` / `Vendor.contacts` store `PartyContact` rows (JSON
|
|
122
|
+
column; additive schema, run `smrt db:migrate`). The root package exports the
|
|
123
|
+
server half of the form's contact payload:
|
|
124
|
+
|
|
125
|
+
| Export | Contract |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `readPartyContactRows(form, fieldNames?)` | Zips the repeated `contactId`, `contactName`, `contactLabel`, `contactEmail`, `contactPhone`, `contactAddress` values (or the form's `fieldNames` overrides) in DOM order into raw `PartyContactInput` rows. The editable contact block always posts a hidden `contactCount` marker with its row count; a missing marker (`reason: 'missing'`) or any disagreeing count (`'misaligned'`) throws `PartyContactPayloadError`, so zero rows mean an empty list only when the block rendered. |
|
|
128
|
+
| `applyPartyContactIntent(rows, intent, intents?)` | `addContact` appends a blank row; `removeContact:<n>` (or a caller `parseRemoveIntent`) drops row `n`. `handled: true` means render the returned rows and do not save, including for a stale index. |
|
|
129
|
+
| `validatePartyContactRows(rows)` | Trims, drops blank rows, and returns `errors` aligned with the submitted rows using codes `too_long` (limits in `PARTY_CONTACT_MAX_LENGTHS`, matching the inputs) and `invalid_email`. |
|
|
130
|
+
| `savePartyContacts(collection, partyId, formOrRows, { fieldNames?, expectedTenantId? })` | Given the posted form, reads it with `readPartyContactRows` (marker enforced); an array is taken as rows already read that way. Loads the party with `collection.get()` (so the active tenant context scopes it) and replaces its contacts: posted ids are kept, new rows get a random id, unposted rows are removed. A posted id the party does not have is `unknown_contact` on `id`. Invalid input throws `PartyContactValidationError` (`errors`, nothing written); a missing or other-tenant party throws `PartyContactPartyNotFoundError`. |
|
|
131
|
+
|
|
132
|
+
Error codes are not messages: map `PartyContactValidationError.errors` to
|
|
133
|
+
localized strings for `PartyFormErrors.contacts`, and return the submitted
|
|
134
|
+
rows as retained `values.contacts`. A form with custom contact `fieldNames`
|
|
135
|
+
must pass the same names when reading; with mismatched names the marker is
|
|
136
|
+
not found and the read fails closed instead of removing every contact. Saves are a read-modify-write of the party
|
|
137
|
+
row (last writer wins). Map saved contacts to `CustomerDisplayData.contacts` /
|
|
138
|
+
`VendorDisplayData.contacts` for the detail screens.
|
|
139
|
+
|
|
95
140
|
## Selectors (#3602)
|
|
96
141
|
|
|
97
142
|
`CustomerSelect` and `VendorSelect` are field-sized pickers built on the shared
|
|
@@ -119,6 +164,20 @@ so the scanner can read it.
|
|
|
119
164
|
|
|
120
165
|
Widget hints (`@field({ ui: { widget } })`, #3599) are presentation-only and
|
|
121
166
|
the build rejects them on non-text fields; `currency` is a currency-code
|
|
122
|
-
picker for ISO 4217 strings and is never applied to minor-unit amounts
|
|
167
|
+
picker for ISO 4217 strings and is never applied to minor-unit amounts;
|
|
168
|
+
amounts take `ui: { format: 'money' }` instead (#3718).
|
|
123
169
|
Behaviour tests run under jsdom: `pnpm exec vitest run --config
|
|
124
170
|
vitest.selects.config.ts` (also part of `pnpm test:ui`).
|
|
171
|
+
|
|
172
|
+
## Record page hints (#3718)
|
|
173
|
+
|
|
174
|
+
Minor-unit amounts on Contract, Invoice, their line items, Payment,
|
|
175
|
+
PaymentAllocation, `Customer.creditLimit` and `Vendor.minimumOrderAmount`
|
|
176
|
+
carry `ui: { format: 'money' }` (#3718; `widget: 'currency'` stays the
|
|
177
|
+
currency-code picker on the text `currency` field). Payout and Payment's
|
|
178
|
+
native/USD drift amounts are not hinted: their currency is a payout rail or
|
|
179
|
+
fixed USD, not the record's `currency`. The line-item FKs
|
|
180
|
+
(`ContractLineItem.contractId`, `InvoiceLineItem.invoiceId`,
|
|
181
|
+
`FulfillmentLineItem.fulfillmentId`) carry `role: 'items'`, so record pages
|
|
182
|
+
render them as a line-items table with a totals block;
|
|
183
|
+
`src/__tests__/money-hints-manifest.test.ts` pins both.
|
package/agents/purchasing-ui.md
CHANGED
|
@@ -100,9 +100,10 @@ unavailable vendor or explicitly permit keeping the existing relationship.
|
|
|
100
100
|
`shipTo` is a delivery address/instructions snapshot, not a Profile reference.
|
|
101
101
|
`PurchaseOrder.expectedDate` and `.shipTo` use existing STI metadata, default to
|
|
102
102
|
empty strings, and accept `PurchaseOrderOptions`; no table migration is needed.
|
|
103
|
-
|
|
104
|
-
existing SQLite/PostgreSQL Contract schema
|
|
105
|
-
ON UPDATE CASCADE foreign keys and is not a supported
|
|
103
|
+
`PurchaseContract` owns `vendorId`; `Contract` owns `reference` and `notes`.
|
|
104
|
+
Header persistence uses the existing SQLite/PostgreSQL Contract schema. DuckDB
|
|
105
|
+
rejects its existing ON UPDATE CASCADE foreign keys and is not a supported
|
|
106
|
+
Contract storage lane. Caller retry identities
|
|
106
107
|
are rendered unchanged; the form itself never persists or retries a mutation.
|
|
107
108
|
|
|
108
109
|
Header regression evidence uses the purchasing SSR suite and the shared quote
|
package/agents/quote-ui.md
CHANGED
|
@@ -8,8 +8,9 @@ Commerce playground has interactive vendor quotation and customer estimate demos
|
|
|
8
8
|
`kind: 'vendor-quotation'` means received supplier evidence;
|
|
9
9
|
`kind: 'customer-estimate'` means pricing proposed to a customer. Neither widget
|
|
10
10
|
selects pricing, accepts budgets, awards work, sends messages or mutates a model.
|
|
11
|
-
Adapt
|
|
12
|
-
`
|
|
11
|
+
Adapt Commerce `Estimate` fields (`currency`, `totalAmount`, `status`,
|
|
12
|
+
`customerId`) to customer-estimate DTOs. A received vendor quotation is
|
|
13
|
+
caller-held evidence or a draft `PurchaseOrder`, not an `Estimate.vendorId`;
|
|
13
14
|
construction package allocation and approval policy remain caller extensions.
|
|
14
15
|
Client records need not become Commerce Customers.
|
|
15
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-zVnIjSOk.js","names":["CustomerStatus","CustomerType","VendorStatus","ContractType","ContractStatus","FulfillmentType","FulfillmentStatus","PaymentMethod","PaymentStatus","PaymentInstrumentStatus","PayoutStatus","PaymentIntentStatus","InvoiceStatus"],"sources":["../../src/types/index.ts"],"sourcesContent":["/**\n * Commerce package type definitions\n * @packageDocumentation\n */\n\nimport type { SmrtObjectOptions } from '@happyvertical/smrt-core';\nimport type {\n InvoiceCalculationContext,\n InvoiceLineDraft,\n} from '../svelte/invoices/calculations.js';\n\n// ============================================================================\n// Customer/Vendor Types\n// ============================================================================\n\nexport enum CustomerStatus {\n ACTIVE = 'active',\n INACTIVE = 'inactive',\n SUSPENDED = 'suspended',\n}\n\n/**\n * Customer classification — drives channel access, pricing tier, and credit terms.\n *\n * - DTC: direct-to-consumer (end shopper). Pays via storefront checkout.\n * - WHOLESALE: B2B buyer with negotiated terms (NET-30, line sheets, etc.).\n * - RETAIL: in-store walk-in / point-of-sale customer.\n */\nexport enum CustomerType {\n DTC = 'dtc',\n WHOLESALE = 'wholesale',\n RETAIL = 'retail',\n}\n\nexport enum VendorStatus {\n ACTIVE = 'active',\n INACTIVE = 'inactive',\n SUSPENDED = 'suspended',\n}\n\n// ============================================================================\n// Contract Types\n// ============================================================================\n\nexport enum ContractType {\n ESTIMATE = 'estimate',\n ORDER = 'order',\n LEASE = 'lease',\n AGREEMENT = 'agreement',\n PURCHASE_ORDER = 'purchase_order',\n WHOLESALE_ORDER = 'wholesale_order',\n PRODUCTION_ORDER = 'production_order',\n CART = 'cart',\n /**\n * Industry-neutral licensing primitive. The `LicenseSale` STI subtype\n * carries an immutable rights snapshot, a licensee email, optional\n * legal-entity / jurisdiction fields, and a signed-PDF reference.\n * Any application that sells rights for a fee (stock media,\n * music licensing, code-asset marketplace, license keys, etc.)\n * uses this subtype.\n */\n LICENSE_SALE = 'license_sale',\n}\n\nexport enum ContractStatus {\n DRAFT = 'draft',\n SENT = 'sent',\n ACCEPTED = 'accepted',\n DECLINED = 'declined',\n COMPLETED = 'completed',\n CANCELLED = 'cancelled',\n}\n\n// ============================================================================\n// Fulfillment Types\n// ============================================================================\n\nexport enum FulfillmentType {\n SHIPMENT = 'shipment',\n DELIVERY = 'delivery',\n PICKUP = 'pickup',\n DIGITAL = 'digital',\n SERVICE = 'service',\n}\n\nexport enum FulfillmentStatus {\n PENDING = 'pending',\n PROCESSING = 'processing',\n SHIPPED = 'shipped',\n DELIVERED = 'delivered',\n CANCELLED = 'cancelled',\n}\n\n// ============================================================================\n// Payment Types\n// ============================================================================\n\nexport enum PaymentMethod {\n CASH = 'cash',\n CHECK = 'check',\n CREDIT_CARD = 'credit_card',\n BANK_TRANSFER = 'bank_transfer',\n CRYPTO = 'crypto',\n OTHER = 'other',\n}\n\nexport enum PaymentStatus {\n PENDING = 'pending',\n COMPLETED = 'completed',\n FAILED = 'failed',\n REFUNDED = 'refunded',\n CANCELLED = 'cancelled',\n}\n\n/**\n * Lifecycle status for a saved {@link PaymentInstrument} (card on file).\n * `active` while chargeable, `expired` once the card lapses, `removed` when the\n * customer detaches it.\n */\nexport enum PaymentInstrumentStatus {\n ACTIVE = 'active',\n EXPIRED = 'expired',\n REMOVED = 'removed',\n}\n\n// ============================================================================\n// Payout Types\n// ============================================================================\n\n/**\n * Status machine for {@link Payout}.\n *\n * `pending → sent → confirmed → failed`. `failed` is terminal but the\n * model exposes a dedicated `resetFromFailed()` so an operator can\n * deliberately requeue a payout after fixing the underlying problem;\n * the reset moves the row back to `pending` and clears the failure\n * metadata.\n *\n * Skipping intermediate states is rejected — a `pending` payout cannot\n * jump straight to `confirmed`, and a `sent` payout cannot regress to\n * `pending` without going through `resetFromFailed()` first.\n */\nexport enum PayoutStatus {\n PENDING = 'pending',\n SENT = 'sent',\n CONFIRMED = 'confirmed',\n FAILED = 'failed',\n}\n\n// ============================================================================\n// PaymentIntent Types\n// ============================================================================\n\n/**\n * Status machine for {@link PaymentIntent}.\n *\n * `awaiting_payment → paid → (issued | retired)`, with `expired` and\n * `cancelled` as alternate terminal states reachable from\n * `awaiting_payment`.\n *\n * - `AWAITING_PAYMENT` — open quote, accepting any of the listed\n * payment options.\n * - `PAID` — one option was satisfied by an incoming payment. The\n * other options are implicitly retired; later inbound funds to a\n * retired option must be flagged for refund by the consumer.\n * - `ISSUED` — downstream rights / contract / fulfillment have been\n * created and linked. Terminal happy-path state.\n * - `RETIRED` — paid but the satisfaction was reversed (refund,\n * chargeback, etc.). Terminal.\n * - `EXPIRED` — the USD-price-lock window passed without payment.\n * Terminal.\n * - `CANCELLED` — the buyer or the system explicitly cancelled the\n * intent before it was paid. Terminal.\n */\nexport enum PaymentIntentStatus {\n AWAITING_PAYMENT = 'awaiting_payment',\n PAID = 'paid',\n ISSUED = 'issued',\n RETIRED = 'retired',\n EXPIRED = 'expired',\n CANCELLED = 'cancelled',\n}\n\n/**\n * One way for a {@link PaymentIntent} to be satisfied. The intent lists\n * an array of these; satisfying any one of them transitions the intent\n * to `PAID` and implicitly retires the rest.\n *\n * Industry-neutral: a marketplace that accepts USDC-on-Base and BTC\n * lists two options; a SaaS billing flow that accepts Stripe and\n * PayPal lists two; a kiosk that accepts only one rail lists one.\n */\nexport interface PaymentOption {\n /**\n * Stable id of the `PaymentBackend` adapter that fulfills this\n * option — must match a `backendId` the consumer's payment-routing\n * layer recognises. Examples: `base-usdc`, `solana-usdc`, `btc`,\n * `stripe`, `paypal`.\n */\n backendId: string;\n /**\n * Payout-rail-qualified currency code, e.g. `USDC-base`, `BTC`,\n * `USD-stripe`. The same convention used by\n * `Vendor.payoutAddresses` and `Payment.nativeCurrency`.\n */\n currency: string;\n /**\n * Optional chain identifier for blockchain-backed options (`base`,\n * `ethereum`, `solana`, ...). Pure-fiat options leave this empty.\n */\n chain?: string;\n /**\n * Destination address / account id the buyer should send funds to\n * for this option (EVM address, BTC address, Stripe payment-intent\n * id, etc.).\n */\n payTo: string;\n /**\n * Amount denominated in `currency`. Stored at decimal precision —\n * a USDC option might be `199.0`, a BTC option `0.00713`.\n */\n nativeAmount: number;\n /**\n * Optional on-chain memo / payment reference (Solana memo, BTC OP_RETURN\n * tag, Stripe metadata key). Some backends use this to disambiguate\n * which intent an inbound payment satisfies.\n */\n memo?: string;\n /**\n * Whether this option supports the x402 HTTP-402 payment-required\n * flow. Consumers that build agent-driven flows use this flag to\n * filter the offered options.\n */\n x402Capable?: boolean;\n /**\n * Optional per-option expiry — when a single rail's quote becomes\n * stale earlier than the intent-wide price-lock window (e.g. a\n * volatile-currency option that re-quotes more aggressively). ISO\n * 8601 string. Empty / missing means \"inherit the intent's\n * `priceLockExpiresAt`\".\n */\n expiresAt?: string;\n}\n\n// ============================================================================\n// Invoice Types\n// ============================================================================\n\nexport enum InvoiceStatus {\n DRAFT = 'draft',\n SENT = 'sent',\n VIEWED = 'viewed',\n PARTIAL = 'partial',\n PAID = 'paid',\n OVERDUE = 'overdue',\n CANCELLED = 'cancelled',\n WRITTEN_OFF = 'written_off',\n}\n\n// ============================================================================\n// Common Interfaces\n// ============================================================================\n\n/**\n * Address structure used for billing and shipping\n */\nexport interface Address {\n street1?: string;\n street2?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n country?: string;\n}\n\n/**\n * Options for recording a payment with ledger integration\n */\nexport interface RecordPaymentOptions {\n /** The ledger to record the journal entry in */\n ledgerId: string;\n /** Account ID for receivables (credit side) */\n receivablesAccountId: string;\n /** Account ID for cash/bank (debit side) */\n cashAccountId: string;\n}\n\n/**\n * Options for recognizing revenue on an invoice\n */\nexport interface RecognizeRevenueOptions {\n /** Account ID for accounts receivable (debit side) */\n arAccountId: string;\n /** Account ID for revenue (credit side) */\n revenueAccountId: string;\n /** Account ID for tax payable (credit side, optional) */\n taxAccountId?: string;\n}\n\n// ============================================================================\n// Accounting-provider sync shapes\n// ============================================================================\n\n/**\n * A single line item in the format expected by `@happyvertical/accounting`\n * providers (QBO, Stripe, …). Mirrors the object built by\n * {@link InvoiceLineItem.toAccountingLineItem}. The SDK isn't a dependency of\n * this package, so the shape is declared locally rather than imported.\n */\nexport interface AccountingLineItemInput {\n description: string;\n sku?: string;\n quantity: number;\n unitPrice: number;\n discount?: number;\n taxRate?: number;\n amount: number;\n periodStart?: Date;\n periodEnd?: Date;\n}\n\n/**\n * An invoice in the format expected by `@happyvertical/accounting` providers.\n * Mirrors the object built by {@link Invoice.toAccountingInput}; money is in\n * currency **major** units, as the SDK expects.\n */\nexport interface AccountingInvoiceInput {\n id: string;\n externalId?: string;\n invoiceNumber: string;\n customerId: string;\n customerExternalId?: string;\n issueDate: Date;\n dueDate: Date;\n lineItems: AccountingLineItemInput[];\n subtotal: number;\n taxAmount: number;\n totalAmount: number;\n currency: string;\n reference?: string;\n memo?: string;\n}\n\n// ============================================================================\n// Model constructor option interfaces\n//\n// Each model's `constructor(options)` accepts a partial bag of its own fields.\n// Declaring a dedicated `XxxOptions extends SmrtObjectOptions` interface keeps\n// the constructors strongly typed (no `any`) while still allowing the\n// framework's base options (db, ai, fs, _className, …) through.\n// ============================================================================\n\n/**\n * Constructor options for {@link Customer}.\n */\nexport interface CustomerOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n profileId?: string;\n creditLimit?: number;\n paymentTerms?: string;\n taxExempt?: boolean;\n taxId?: string;\n defaultShippingAddress?: Address;\n defaultBillingAddress?: Address;\n status?: CustomerStatus;\n customerType?: CustomerType | null;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link Vendor}.\n */\nexport interface VendorOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n profileId?: string;\n leadTimeDays?: number;\n minimumOrderAmount?: number;\n paymentTerms?: string;\n currency?: string;\n defaultContactEmail?: string;\n defaultContactPhone?: string;\n status?: VendorStatus;\n notes?: string;\n payoutAddresses?: Record<string, string> | string | null;\n}\n\n/**\n * Constructor options for {@link Contract} and its STI subtypes.\n */\nexport interface ContractOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n contractType?: ContractType;\n status?: ContractStatus;\n customerId?: string | null;\n vendorId?: string | null;\n subtotal?: number;\n taxAmount?: number;\n totalAmount?: number;\n currency?: string;\n issueDate?: Date;\n dueDate?: Date | null;\n expiryDate?: Date | null;\n reference?: string;\n notes?: string;\n terms?: string;\n channelId?: string;\n}\n\n/** Purchase-order header options stored in the existing STI metadata. */\nexport interface PurchaseOrderOptions extends ContractOptions {\n /** Expected delivery calendar date (YYYY-MM-DD); empty means unspecified. */\n expectedDate?: string;\n /** Delivery address/instructions snapshot. */\n shipTo?: string;\n}\n\n/**\n * Constructor options for {@link LicenseSale} (Contract STI subtype). Extends\n * {@link ContractOptions} with the licensing-specific meta fields.\n */\nexport interface LicenseSaleOptions extends ContractOptions {\n skuId?: string;\n paymentId?: string;\n licenseeEmail?: string;\n licenseeLegalEntity?: string;\n licenseeJurisdiction?: string;\n rightsMedium?: string;\n rightsDistributionScope?: string;\n rightsExclusivity?: string;\n rightsDuration?: string;\n rightsTerritory?: string;\n rightsSublicensing?: boolean;\n rightsDerivatives?: boolean;\n pdfUrl?: string;\n pdfHash?: string;\n onChainHashRegistryRef?: string;\n}\n\n/**\n * Constructor options for {@link ContractLineItem}.\n */\nexport interface ContractLineItemOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n contractId?: string;\n description?: string;\n quantity?: number;\n unitPrice?: number;\n discount?: number;\n taxRate?: number;\n amount?: number;\n productId?: string;\n sku?: string;\n startDate?: Date | null;\n endDate?: Date | null;\n billingPeriod?: string;\n sortOrder?: number;\n}\n\n/**\n * How the provider collects an invoice (#3190): `charge_automatically`\n * charges the payer's saved card; `send_invoice` asks the payer to pay. Empty\n * for an invoice never pushed to a provider, or pushed before it was recorded.\n */\nexport type InvoiceCollectionMethod =\n | ''\n | 'send_invoice'\n | 'charge_automatically';\n\n/**\n * Constructor options for {@link Invoice}.\n */\nexport interface InvoiceOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n customerId?: string;\n contractId?: string;\n invoiceNumber?: string;\n reference?: string;\n issueDate?: Date;\n dueDate?: Date;\n paidDate?: Date | null;\n subtotal?: number;\n taxAmount?: number;\n providerTaxAmount?: number;\n totalAmount?: number;\n amountPaid?: number;\n currency?: string;\n status?: InvoiceStatus;\n arJournalId?: string;\n revenueJournalId?: string;\n externalId?: string;\n customerExternalId?: string;\n externalProvider?: string;\n syncedAt?: Date | null;\n collectionMethod?: InvoiceCollectionMethod;\n sentAt?: Date | null;\n viewedAt?: Date | null;\n remindersSent?: number;\n lastReminderAt?: Date | null;\n notes?: string;\n customerNotes?: string;\n terms?: string;\n}\n\n/** Retained editing modes, validated against resolved model fields before reuse. */\nexport interface InvoiceLineEditorState {\n /** Lossless editor draft; never authoritative for ordinary model saves. */\n draft: InvoiceLineDraft;\n /** Context used to resolve that draft; caller authority must still match on reload. */\n context: InvoiceCalculationContext;\n}\n\n/** Constructor options for {@link InvoiceLineItem}. */\nexport interface InvoiceLineItemOptions extends SmrtObjectOptions {\n /** Optional retained editor modes and their original calculation context. */\n invoiceEditorState?: InvoiceLineEditorState | null;\n /** Serialized editor state loaded from persistence; malformed JSON is ignored. */\n invoiceEditorStateJson?: string;\n tenantId?: string | null;\n invoiceId?: string;\n description?: string;\n sku?: string;\n quantity?: number;\n unitPrice?: number;\n discount?: number;\n taxRate?: number;\n amount?: number;\n sourceType?: string;\n sourceId?: string;\n periodStart?: Date | null;\n periodEnd?: Date | null;\n revenueAccountId?: string;\n sortOrder?: number;\n}\n\n/**\n * Constructor options for {@link Fulfillment}.\n */\nexport interface FulfillmentOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n contractId?: string;\n fulfillmentType?: FulfillmentType;\n status?: FulfillmentStatus;\n trackingNumber?: string;\n carrier?: string;\n shippingAddress?: Address;\n shippedAt?: Date | null;\n deliveredAt?: Date | null;\n estimatedDelivery?: Date | null;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link FulfillmentLineItem}.\n */\nexport interface FulfillmentLineItemOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n fulfillmentId?: string;\n contractLineItemId?: string;\n quantityFulfilled?: number;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link Payment}.\n */\nexport interface PaymentOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n contractId?: string | null;\n customerId?: string | null;\n amount?: number;\n currency?: string;\n method?: PaymentMethod;\n status?: PaymentStatus;\n transactionId?: string;\n reference?: string;\n journalId?: string;\n paidAt?: Date | null;\n notes?: string;\n externalId?: string;\n externalProvider?: string;\n syncedAt?: Date | null;\n backendId?: string;\n backendTxRef?: string;\n nativeAmount?: number;\n nativeCurrency?: string;\n usdAtQuote?: number;\n usdAtConfirmation?: number;\n}\n\n/**\n * Constructor options for {@link PaymentInstrument}.\n */\nexport interface PaymentInstrumentOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n customerId?: string;\n backendId?: string;\n providerCustomerId?: string;\n providerPaymentMethodId?: string;\n type?: string;\n brand?: string;\n last4?: string;\n expMonth?: number;\n expYear?: number;\n isDefault?: boolean;\n status?: PaymentInstrumentStatus;\n}\n\n/**\n * Constructor options for {@link PaymentAllocation}.\n */\nexport interface PaymentAllocationOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n paymentId?: string;\n invoiceId?: string;\n amount?: number;\n allocatedAt?: Date;\n allocatedBy?: string;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link PaymentIntent}.\n */\nexport interface PaymentIntentOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n skuId?: string;\n offeringRef?: string;\n licenseeEmail?: string;\n customerId?: string;\n paymentOptions?: PaymentOption[] | string;\n usdPriceLocked?: number;\n priceLockWindowMs?: number;\n priceLockExpiresAt?: Date | number | string | null;\n status?: PaymentIntentStatus;\n idempotencyKey?: string;\n paidOptionBackendId?: string;\n paymentId?: string;\n paidAt?: Date | number | string | null;\n issuedAt?: Date | number | string | null;\n expiredAt?: Date | number | string | null;\n cancelledAt?: Date | number | string | null;\n retiredAt?: Date | number | string | null;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link Payout}.\n */\nexport interface PayoutOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n paymentId?: string;\n vendorId?: string;\n grossAmount?: number;\n operatorFee?: number;\n supplierNet?: number;\n currency?: string;\n backendId?: string;\n backendTxRef?: string;\n status?: PayoutStatus;\n sentAt?: Date | number | string | null;\n confirmedAt?: Date | number | string | null;\n failedAt?: Date | number | string | null;\n failureReason?: string;\n notes?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,IAAK,iBAAL,kBAAKA,oBAAL;CACLA,gBAAA,YAAS;CACTA,gBAAA,cAAW;CACXA,gBAAA,eAAY;CAHF,OAAAA;AAAA,EAAA,CAAA,kBAAA,CAAA,CAAA;AAaL,IAAK,eAAL,kBAAKC,kBAAL;CACLA,cAAA,SAAM;CACNA,cAAA,eAAY;CACZA,cAAA,YAAS;CAHC,OAAAA;AAAA,EAAA,CAAA,gBAAA,CAAA,CAAA;AAML,IAAK,eAAL,kBAAKC,kBAAL;CACLA,cAAA,YAAS;CACTA,cAAA,cAAW;CACXA,cAAA,eAAY;CAHF,OAAAA;AAAA,EAAA,CAAA,gBAAA,CAAA,CAAA;A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;CACLA,yBAAA,YAAS;CACTA,yBAAA,aAAU;CACVA,yBAAA,aAAU;CAHA,OAAAA;AAAA,EAAA,CAAA,2BAAA,CAAA,CAAA;AAuBL,IAAK,eAAL,kBAAKC,kBAAL;CACLA,cAAA,aAAU;CACVA,cAAA,UAAO;CACPA,cAAA,eAAY;CACZA,cAAA,YAAS;CAJC,OAAAA;AAAA,EAAA,CAAA,gBAAA,CAAA,CAAA;AAgCL,IAAK,sBAAL,kBAAKC,yBAAL;CACLA,qBAAA,sBAAmB;CACnBA,qBAAA,UAAO;CACPA,qBAAA,YAAS;CACTA,qBAAA,aAAU;CACVA,qBAAA,aAAU;CACVA,qBAAA,eAAY;CANF,OAAAA;AAAA,EAAA,CAAA,uBAAA,CAAA,CAAA;AA0EL,IAAK,gBAAL,kBAAKC,mBAAL;CACLA,eAAA,WAAQ;CACRA,eAAA,UAAO;CACPA,eAAA,YAAS;CACTA,eAAA,aAAU;CACVA,eAAA,UAAO;CACPA,eAAA,aAAU;CACVA,eAAA,eAAY;CACZA,eAAA,iBAAc;CARJ,OAAAA;AAAA,EAAA,CAAA,iBAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"types-zVnIjSOk.js","names":["CustomerStatus","CustomerType","VendorStatus","ContractType","ContractStatus","FulfillmentType","FulfillmentStatus","PaymentMethod","PaymentStatus","PaymentInstrumentStatus","PayoutStatus","PaymentIntentStatus","InvoiceStatus"],"sources":["../../src/types/index.ts"],"sourcesContent":["/**\n * Commerce package type definitions\n * @packageDocumentation\n */\n\nimport type { SmrtObjectOptions } from '@happyvertical/smrt-core';\nimport type {\n InvoiceCalculationContext,\n InvoiceLineDraft,\n} from '../svelte/invoices/calculations.js';\n\n// ============================================================================\n// Customer/Vendor Types\n// ============================================================================\n\nexport enum CustomerStatus {\n ACTIVE = 'active',\n INACTIVE = 'inactive',\n SUSPENDED = 'suspended',\n}\n\n/**\n * Customer classification — drives channel access, pricing tier, and credit terms.\n *\n * - DTC: direct-to-consumer (end shopper). Pays via storefront checkout.\n * - WHOLESALE: B2B buyer with negotiated terms (NET-30, line sheets, etc.).\n * - RETAIL: in-store walk-in / point-of-sale customer.\n */\nexport enum CustomerType {\n DTC = 'dtc',\n WHOLESALE = 'wholesale',\n RETAIL = 'retail',\n}\n\nexport enum VendorStatus {\n ACTIVE = 'active',\n INACTIVE = 'inactive',\n SUSPENDED = 'suspended',\n}\n\n// ============================================================================\n// Contract Types\n// ============================================================================\n\nexport enum ContractType {\n ESTIMATE = 'estimate',\n ORDER = 'order',\n LEASE = 'lease',\n AGREEMENT = 'agreement',\n PURCHASE_ORDER = 'purchase_order',\n WHOLESALE_ORDER = 'wholesale_order',\n PRODUCTION_ORDER = 'production_order',\n CART = 'cart',\n /**\n * Industry-neutral licensing primitive. The `LicenseSale` STI subtype\n * carries an immutable rights snapshot, a licensee email, optional\n * legal-entity / jurisdiction fields, and a signed-PDF reference.\n * Any application that sells rights for a fee (stock media,\n * music licensing, code-asset marketplace, license keys, etc.)\n * uses this subtype.\n */\n LICENSE_SALE = 'license_sale',\n}\n\nexport enum ContractStatus {\n DRAFT = 'draft',\n SENT = 'sent',\n ACCEPTED = 'accepted',\n DECLINED = 'declined',\n COMPLETED = 'completed',\n CANCELLED = 'cancelled',\n}\n\n// ============================================================================\n// Fulfillment Types\n// ============================================================================\n\nexport enum FulfillmentType {\n SHIPMENT = 'shipment',\n DELIVERY = 'delivery',\n PICKUP = 'pickup',\n DIGITAL = 'digital',\n SERVICE = 'service',\n}\n\nexport enum FulfillmentStatus {\n PENDING = 'pending',\n PROCESSING = 'processing',\n SHIPPED = 'shipped',\n DELIVERED = 'delivered',\n CANCELLED = 'cancelled',\n}\n\n// ============================================================================\n// Payment Types\n// ============================================================================\n\nexport enum PaymentMethod {\n CASH = 'cash',\n CHECK = 'check',\n CREDIT_CARD = 'credit_card',\n BANK_TRANSFER = 'bank_transfer',\n CRYPTO = 'crypto',\n OTHER = 'other',\n}\n\nexport enum PaymentStatus {\n PENDING = 'pending',\n COMPLETED = 'completed',\n FAILED = 'failed',\n REFUNDED = 'refunded',\n CANCELLED = 'cancelled',\n}\n\n/**\n * Lifecycle status for a saved {@link PaymentInstrument} (card on file).\n * `active` while chargeable, `expired` once the card lapses, `removed` when the\n * customer detaches it.\n */\nexport enum PaymentInstrumentStatus {\n ACTIVE = 'active',\n EXPIRED = 'expired',\n REMOVED = 'removed',\n}\n\n// ============================================================================\n// Payout Types\n// ============================================================================\n\n/**\n * Status machine for {@link Payout}.\n *\n * `pending → sent → confirmed → failed`. `failed` is terminal but the\n * model exposes a dedicated `resetFromFailed()` so an operator can\n * deliberately requeue a payout after fixing the underlying problem;\n * the reset moves the row back to `pending` and clears the failure\n * metadata.\n *\n * Skipping intermediate states is rejected — a `pending` payout cannot\n * jump straight to `confirmed`, and a `sent` payout cannot regress to\n * `pending` without going through `resetFromFailed()` first.\n */\nexport enum PayoutStatus {\n PENDING = 'pending',\n SENT = 'sent',\n CONFIRMED = 'confirmed',\n FAILED = 'failed',\n}\n\n// ============================================================================\n// PaymentIntent Types\n// ============================================================================\n\n/**\n * Status machine for {@link PaymentIntent}.\n *\n * `awaiting_payment → paid → (issued | retired)`, with `expired` and\n * `cancelled` as alternate terminal states reachable from\n * `awaiting_payment`.\n *\n * - `AWAITING_PAYMENT` — open quote, accepting any of the listed\n * payment options.\n * - `PAID` — one option was satisfied by an incoming payment. The\n * other options are implicitly retired; later inbound funds to a\n * retired option must be flagged for refund by the consumer.\n * - `ISSUED` — downstream rights / contract / fulfillment have been\n * created and linked. Terminal happy-path state.\n * - `RETIRED` — paid but the satisfaction was reversed (refund,\n * chargeback, etc.). Terminal.\n * - `EXPIRED` — the USD-price-lock window passed without payment.\n * Terminal.\n * - `CANCELLED` — the buyer or the system explicitly cancelled the\n * intent before it was paid. Terminal.\n */\nexport enum PaymentIntentStatus {\n AWAITING_PAYMENT = 'awaiting_payment',\n PAID = 'paid',\n ISSUED = 'issued',\n RETIRED = 'retired',\n EXPIRED = 'expired',\n CANCELLED = 'cancelled',\n}\n\n/**\n * One way for a {@link PaymentIntent} to be satisfied. The intent lists\n * an array of these; satisfying any one of them transitions the intent\n * to `PAID` and implicitly retires the rest.\n *\n * Industry-neutral: a marketplace that accepts USDC-on-Base and BTC\n * lists two options; a SaaS billing flow that accepts Stripe and\n * PayPal lists two; a kiosk that accepts only one rail lists one.\n */\nexport interface PaymentOption {\n /**\n * Stable id of the `PaymentBackend` adapter that fulfills this\n * option — must match a `backendId` the consumer's payment-routing\n * layer recognises. Examples: `base-usdc`, `solana-usdc`, `btc`,\n * `stripe`, `paypal`.\n */\n backendId: string;\n /**\n * Payout-rail-qualified currency code, e.g. `USDC-base`, `BTC`,\n * `USD-stripe`. The same convention used by\n * `Vendor.payoutAddresses` and `Payment.nativeCurrency`.\n */\n currency: string;\n /**\n * Optional chain identifier for blockchain-backed options (`base`,\n * `ethereum`, `solana`, ...). Pure-fiat options leave this empty.\n */\n chain?: string;\n /**\n * Destination address / account id the buyer should send funds to\n * for this option (EVM address, BTC address, Stripe payment-intent\n * id, etc.).\n */\n payTo: string;\n /**\n * Amount denominated in `currency`. Stored at decimal precision —\n * a USDC option might be `199.0`, a BTC option `0.00713`.\n */\n nativeAmount: number;\n /**\n * Optional on-chain memo / payment reference (Solana memo, BTC OP_RETURN\n * tag, Stripe metadata key). Some backends use this to disambiguate\n * which intent an inbound payment satisfies.\n */\n memo?: string;\n /**\n * Whether this option supports the x402 HTTP-402 payment-required\n * flow. Consumers that build agent-driven flows use this flag to\n * filter the offered options.\n */\n x402Capable?: boolean;\n /**\n * Optional per-option expiry — when a single rail's quote becomes\n * stale earlier than the intent-wide price-lock window (e.g. a\n * volatile-currency option that re-quotes more aggressively). ISO\n * 8601 string. Empty / missing means \"inherit the intent's\n * `priceLockExpiresAt`\".\n */\n expiresAt?: string;\n}\n\n// ============================================================================\n// Invoice Types\n// ============================================================================\n\nexport enum InvoiceStatus {\n DRAFT = 'draft',\n SENT = 'sent',\n VIEWED = 'viewed',\n PARTIAL = 'partial',\n PAID = 'paid',\n OVERDUE = 'overdue',\n CANCELLED = 'cancelled',\n WRITTEN_OFF = 'written_off',\n}\n\n// ============================================================================\n// Common Interfaces\n// ============================================================================\n\n/**\n * Address structure used for billing and shipping\n */\nexport interface Address {\n street1?: string;\n street2?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n country?: string;\n}\n\n/**\n * A person to reach at a customer or vendor, stored on the party row\n * (`Customer.contacts` / `Vendor.contacts`, #3501). Every field is plain\n * text; `id` is a stable random identifier assigned when the row is first\n * saved. Write rows through `savePartyContacts()`.\n */\nexport interface PartyContact {\n id: string;\n name: string;\n /** Role or relationship, for example \"Accounts payable\". */\n label: string;\n email: string;\n phone: string;\n address: string;\n}\n\n/**\n * Options for recording a payment with ledger integration\n */\nexport interface RecordPaymentOptions {\n /** The ledger to record the journal entry in */\n ledgerId: string;\n /** Account ID for receivables (credit side) */\n receivablesAccountId: string;\n /** Account ID for cash/bank (debit side) */\n cashAccountId: string;\n}\n\n/**\n * Options for recognizing revenue on an invoice\n */\nexport interface RecognizeRevenueOptions {\n /** Account ID for accounts receivable (debit side) */\n arAccountId: string;\n /** Account ID for revenue (credit side) */\n revenueAccountId: string;\n /** Account ID for tax payable (credit side, optional) */\n taxAccountId?: string;\n}\n\n// ============================================================================\n// Accounting-provider sync shapes\n// ============================================================================\n\n/**\n * A single line item in the format expected by `@happyvertical/accounting`\n * providers (QBO, Stripe, …). Mirrors the object built by\n * {@link InvoiceLineItem.toAccountingLineItem}. The SDK isn't a dependency of\n * this package, so the shape is declared locally rather than imported.\n */\nexport interface AccountingLineItemInput {\n description: string;\n sku?: string;\n quantity: number;\n unitPrice: number;\n discount?: number;\n taxRate?: number;\n amount: number;\n periodStart?: Date;\n periodEnd?: Date;\n}\n\n/**\n * An invoice in the format expected by `@happyvertical/accounting` providers.\n * Mirrors the object built by {@link Invoice.toAccountingInput}; money is in\n * currency **major** units, as the SDK expects.\n */\nexport interface AccountingInvoiceInput {\n id: string;\n externalId?: string;\n invoiceNumber: string;\n customerId: string;\n customerExternalId?: string;\n issueDate: Date;\n dueDate: Date;\n lineItems: AccountingLineItemInput[];\n subtotal: number;\n taxAmount: number;\n totalAmount: number;\n currency: string;\n reference?: string;\n memo?: string;\n}\n\n// ============================================================================\n// Model constructor option interfaces\n//\n// Each model's `constructor(options)` accepts a partial bag of its own fields.\n// Declaring a dedicated `XxxOptions extends SmrtObjectOptions` interface keeps\n// the constructors strongly typed (no `any`) while still allowing the\n// framework's base options (db, ai, fs, _className, …) through.\n// ============================================================================\n\n/**\n * Constructor options for {@link Customer}.\n */\nexport interface CustomerOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n profileId?: string;\n creditLimit?: number;\n paymentTerms?: string;\n taxExempt?: boolean;\n taxId?: string;\n defaultShippingAddress?: Address;\n defaultBillingAddress?: Address;\n status?: CustomerStatus;\n customerType?: CustomerType | null;\n notes?: string;\n contacts?: PartyContact[] | string | null;\n}\n\n/**\n * Constructor options for {@link Vendor}.\n */\nexport interface VendorOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n profileId?: string;\n leadTimeDays?: number;\n minimumOrderAmount?: number;\n paymentTerms?: string;\n currency?: string;\n defaultContactEmail?: string;\n defaultContactPhone?: string;\n status?: VendorStatus;\n notes?: string;\n payoutAddresses?: Record<string, string> | string | null;\n contacts?: PartyContact[] | string | null;\n}\n\n/**\n * Constructor options for {@link Contract} and its STI subtypes.\n */\nexport interface ContractOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n contractType?: ContractType;\n status?: ContractStatus;\n subtotal?: number;\n taxAmount?: number;\n totalAmount?: number;\n currency?: string;\n issueDate?: Date;\n dueDate?: Date | null;\n expiryDate?: Date | null;\n reference?: string;\n notes?: string;\n terms?: string;\n channelId?: string;\n}\n\nexport interface SalesContractOptions extends ContractOptions {\n customerId?: string | null;\n}\n\nexport interface PurchaseContractOptions extends ContractOptions {\n vendorId?: string | null;\n}\n\n/** Purchase-order header options stored in the existing STI metadata. */\nexport interface PurchaseOrderOptions extends PurchaseContractOptions {\n /** Expected delivery calendar date (YYYY-MM-DD); empty means unspecified. */\n expectedDate?: string;\n /** Delivery address/instructions snapshot. */\n shipTo?: string;\n}\n\n/**\n * Constructor options for {@link LicenseSale} (Contract STI subtype). Extends\n * {@link ContractOptions} with the licensing-specific meta fields.\n */\nexport interface LicenseSaleOptions extends SalesContractOptions {\n skuId?: string;\n paymentId?: string;\n licenseeEmail?: string;\n licenseeLegalEntity?: string;\n licenseeJurisdiction?: string;\n rightsMedium?: string;\n rightsDistributionScope?: string;\n rightsExclusivity?: string;\n rightsDuration?: string;\n rightsTerritory?: string;\n rightsSublicensing?: boolean;\n rightsDerivatives?: boolean;\n pdfUrl?: string;\n pdfHash?: string;\n onChainHashRegistryRef?: string;\n}\n\n/**\n * Constructor options for {@link ContractLineItem}.\n */\nexport interface ContractLineItemOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n contractId?: string;\n description?: string;\n quantity?: number;\n unitPrice?: number;\n discount?: number;\n taxRate?: number;\n amount?: number;\n productId?: string;\n sku?: string;\n startDate?: Date | null;\n endDate?: Date | null;\n billingPeriod?: string;\n sortOrder?: number;\n}\n\n/**\n * How the provider collects an invoice (#3190): `charge_automatically`\n * charges the payer's saved card; `send_invoice` asks the payer to pay. Empty\n * for an invoice never pushed to a provider, or pushed before it was recorded.\n */\nexport type InvoiceCollectionMethod =\n | ''\n | 'send_invoice'\n | 'charge_automatically';\n\n/**\n * Constructor options for {@link Invoice}.\n */\nexport interface InvoiceOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n customerId?: string;\n contractId?: string;\n invoiceNumber?: string;\n reference?: string;\n issueDate?: Date;\n dueDate?: Date;\n paidDate?: Date | null;\n subtotal?: number;\n taxAmount?: number;\n providerTaxAmount?: number;\n totalAmount?: number;\n amountPaid?: number;\n currency?: string;\n status?: InvoiceStatus;\n arJournalId?: string;\n revenueJournalId?: string;\n externalId?: string;\n customerExternalId?: string;\n externalProvider?: string;\n syncedAt?: Date | null;\n collectionMethod?: InvoiceCollectionMethod;\n sentAt?: Date | null;\n viewedAt?: Date | null;\n remindersSent?: number;\n lastReminderAt?: Date | null;\n notes?: string;\n customerNotes?: string;\n terms?: string;\n}\n\n/** Retained editing modes, validated against resolved model fields before reuse. */\nexport interface InvoiceLineEditorState {\n /** Lossless editor draft; never authoritative for ordinary model saves. */\n draft: InvoiceLineDraft;\n /** Context used to resolve that draft; caller authority must still match on reload. */\n context: InvoiceCalculationContext;\n}\n\n/** Constructor options for {@link InvoiceLineItem}. */\nexport interface InvoiceLineItemOptions extends SmrtObjectOptions {\n /** Optional retained editor modes and their original calculation context. */\n invoiceEditorState?: InvoiceLineEditorState | null;\n /** Serialized editor state loaded from persistence; malformed JSON is ignored. */\n invoiceEditorStateJson?: string;\n tenantId?: string | null;\n invoiceId?: string;\n description?: string;\n sku?: string;\n quantity?: number;\n unitPrice?: number;\n discount?: number;\n taxRate?: number;\n amount?: number;\n sourceType?: string;\n sourceId?: string;\n periodStart?: Date | null;\n periodEnd?: Date | null;\n revenueAccountId?: string;\n sortOrder?: number;\n}\n\n/**\n * Constructor options for {@link Fulfillment}.\n */\nexport interface FulfillmentOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n contractId?: string;\n fulfillmentType?: FulfillmentType;\n status?: FulfillmentStatus;\n trackingNumber?: string;\n carrier?: string;\n shippingAddress?: Address;\n shippedAt?: Date | null;\n deliveredAt?: Date | null;\n estimatedDelivery?: Date | null;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link FulfillmentLineItem}.\n */\nexport interface FulfillmentLineItemOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n fulfillmentId?: string;\n contractLineItemId?: string;\n quantityFulfilled?: number;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link Payment}.\n */\nexport interface PaymentOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n contractId?: string | null;\n customerId?: string | null;\n amount?: number;\n currency?: string;\n method?: PaymentMethod;\n status?: PaymentStatus;\n transactionId?: string;\n reference?: string;\n journalId?: string;\n paidAt?: Date | null;\n notes?: string;\n externalId?: string;\n externalProvider?: string;\n syncedAt?: Date | null;\n backendId?: string;\n backendTxRef?: string;\n nativeAmount?: number;\n nativeCurrency?: string;\n usdAtQuote?: number;\n usdAtConfirmation?: number;\n}\n\n/**\n * Constructor options for {@link PaymentInstrument}.\n */\nexport interface PaymentInstrumentOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n customerId?: string;\n backendId?: string;\n providerCustomerId?: string;\n providerPaymentMethodId?: string;\n type?: string;\n brand?: string;\n last4?: string;\n expMonth?: number;\n expYear?: number;\n isDefault?: boolean;\n status?: PaymentInstrumentStatus;\n}\n\n/**\n * Constructor options for {@link PaymentAllocation}.\n */\nexport interface PaymentAllocationOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n paymentId?: string;\n invoiceId?: string;\n amount?: number;\n allocatedAt?: Date;\n allocatedBy?: string;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link PaymentIntent}.\n */\nexport interface PaymentIntentOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n skuId?: string;\n offeringRef?: string;\n licenseeEmail?: string;\n customerId?: string;\n paymentOptions?: PaymentOption[] | string;\n usdPriceLocked?: number;\n priceLockWindowMs?: number;\n priceLockExpiresAt?: Date | number | string | null;\n status?: PaymentIntentStatus;\n idempotencyKey?: string;\n paidOptionBackendId?: string;\n paymentId?: string;\n paidAt?: Date | number | string | null;\n issuedAt?: Date | number | string | null;\n expiredAt?: Date | number | string | null;\n cancelledAt?: Date | number | string | null;\n retiredAt?: Date | number | string | null;\n notes?: string;\n}\n\n/**\n * Constructor options for {@link Payout}.\n */\nexport interface PayoutOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n paymentId?: string;\n vendorId?: string;\n grossAmount?: number;\n operatorFee?: number;\n supplierNet?: number;\n currency?: string;\n backendId?: string;\n backendTxRef?: string;\n status?: PayoutStatus;\n sentAt?: Date | number | string | null;\n confirmedAt?: Date | number | string | null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 +12,7 @@ export declare class ContractCollection extends SmrtCollection<Contract> {
|
|
|
12
12
|
*
|
|
13
13
|
* @param customerId - Customer ID
|
|
14
14
|
* @returns Array of contracts
|
|
15
|
+
* @deprecated Use SalesContractCollection.findByCustomer.
|
|
15
16
|
*/
|
|
16
17
|
findByCustomer(customerId: string): Promise<Contract[]>;
|
|
17
18
|
/**
|
|
@@ -19,6 +20,7 @@ export declare class ContractCollection extends SmrtCollection<Contract> {
|
|
|
19
20
|
*
|
|
20
21
|
* @param vendorId - Vendor ID
|
|
21
22
|
* @returns Array of contracts
|
|
23
|
+
* @deprecated Use PurchaseContractCollection.findByVendor.
|
|
22
24
|
*/
|
|
23
25
|
findByVendor(vendorId: string): Promise<Contract[]>;
|
|
24
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractCollection.d.ts","sourceRoot":"","sources":["../../src/collections/ContractCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ContractCollection.d.ts","sourceRoot":"","sources":["../../src/collections/ContractCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjE,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,QAAQ,CAAC;IAC9D,MAAM,CAAC,QAAQ,CAAC,UAAU,kBAAY;IAEtC;;;;;;OAMG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAQ7D;;;;;;OAMG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAQzD;;;;;OAKG;IACG,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAOjE;;;;;OAKG;IACG,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAO/D;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIvC;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIzC;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAgBxC;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAkBxC;;;;;;OAMG;IACG,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAc1E;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIzD;;;;;;;;OAQG;IACG,UAAU,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIvC;;;;;;;;OAQG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAO7D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
+
import { PurchaseContract } from '../models/Contract.js';
|
|
3
|
+
/** Read supplier-side contracts across every purchase STI subtype. */
|
|
4
|
+
export declare class PurchaseContractCollection extends SmrtCollection<PurchaseContract> {
|
|
5
|
+
static readonly _itemClass: typeof PurchaseContract;
|
|
6
|
+
findByVendor(vendorId: string): Promise<PurchaseContract[]>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=PurchaseContractCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PurchaseContractCollection.d.ts","sourceRoot":"","sources":["../../src/collections/PurchaseContractCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,sEAAsE;AACtE,qBAAa,0BAA2B,SAAQ,cAAc,CAAC,gBAAgB,CAAC;IAC9E,MAAM,CAAC,QAAQ,CAAC,UAAU,0BAAoB;IAExC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAMlE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
+
import { SalesContract } from '../models/Contract.js';
|
|
3
|
+
/** Read customer-side contracts across every sales STI subtype. */
|
|
4
|
+
export declare class SalesContractCollection extends SmrtCollection<SalesContract> {
|
|
5
|
+
static readonly _itemClass: typeof SalesContract;
|
|
6
|
+
findByCustomer(customerId: string): Promise<SalesContract[]>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=SalesContractCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SalesContractCollection.d.ts","sourceRoot":"","sources":["../../src/collections/SalesContractCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,mEAAmE;AACnE,qBAAa,uBAAwB,SAAQ,cAAc,CAAC,aAAa,CAAC;IACxE,MAAM,CAAC,QAAQ,CAAC,UAAU,uBAAiB;IAErC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAMnE"}
|
|
@@ -14,5 +14,7 @@ export { PaymentCollection } from './PaymentCollection.js';
|
|
|
14
14
|
export { PaymentInstrumentCollection } from './PaymentInstrumentCollection.js';
|
|
15
15
|
export { PaymentIntentCollection, type PaymentIntentIdempotencyArgs, type PaymentIntentSeed, } from './PaymentIntentCollection.js';
|
|
16
16
|
export { type CreatePayoutFromPaymentArgs, PayoutCollection, } from './PayoutCollection.js';
|
|
17
|
+
export { PurchaseContractCollection } from './PurchaseContractCollection.js';
|
|
18
|
+
export { SalesContractCollection } from './SalesContractCollection.js';
|
|
17
19
|
export { VendorCollection } from './VendorCollection.js';
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collections/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,uBAAuB,EACvB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,2BAA2B,EAChC,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collections/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACL,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,uBAAuB,EACvB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,2BAA2B,EAChC,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -62,12 +62,14 @@
|
|
|
62
62
|
*/
|
|
63
63
|
import './__smrt-register__.js';
|
|
64
64
|
export * from './billing/index.js';
|
|
65
|
-
export { ContractCollection, ContractLineItemCollection, type CreatePayoutFromPaymentArgs, CustomerCollection, FulfillmentCollection, FulfillmentLineItemCollection, InvoiceCollection, InvoiceLineItemCollection, type InvoiceNumberOptions, PaymentAllocationCollection, PaymentCollection, PaymentInstrumentCollection, PaymentIntentCollection, type PaymentIntentIdempotencyArgs, type PaymentIntentSeed, PayoutCollection, UNPAID_STATUSES, VendorCollection, } from './collections/index.js';
|
|
65
|
+
export { ContractCollection, ContractLineItemCollection, type CreatePayoutFromPaymentArgs, CustomerCollection, FulfillmentCollection, FulfillmentLineItemCollection, InvoiceCollection, InvoiceLineItemCollection, type InvoiceNumberOptions, PaymentAllocationCollection, PaymentCollection, PaymentInstrumentCollection, PaymentIntentCollection, type PaymentIntentIdempotencyArgs, type PaymentIntentSeed, PayoutCollection, PurchaseContractCollection, SalesContractCollection, UNPAID_STATUSES, VendorCollection, } from './collections/index.js';
|
|
66
66
|
export { type InvoiceEditorStorageEngine, type InvoiceEditorStorageMigrationResult, type InvoiceEditorStoragePreflight, migrateInvoiceEditorStorage, preflightInvoiceEditorStorage, } from './migrations/invoiceEditorStorage.js';
|
|
67
67
|
export { COMMERCE_MONEY_COLUMNS, COMMERCE_MONEY_MINOR_UNITS_BACKFILL, COMMERCE_NATIVE_UNIT_COLUMNS, migrateCommerceMoneyToMinorUnits, preflightCommerceMoneyMinorUnits, } from './migrations/moneyMinorUnits.js';
|
|
68
|
-
export {
|
|
68
|
+
export { type CommerceContractTypeGroup, type CommercePartyLinkRow, type CommercePartyLinksPreflight, preflightCommercePartyLinks, } from './migrations/partyLinks.js';
|
|
69
|
+
export { Agreement, BillingAccount, type BillingCloseKind, BillingLineSource, type BillingLineSourceType, BillingPaymentAttempt, type BillingPaymentAttemptFlag, type BillingPaymentAttemptPurpose, type BillingPaymentAttemptTransition, BillingPeriodClose, type BillingPeriodCloseStatus, type BillingStanding, Cart, Contract, ContractLineItem, Customer, Estimate, Fulfillment, FulfillmentLineItem, Invoice, InvoiceLineItem, Lease, type LicenseRightsSnapshot, LicenseSale, Order, Payment, PaymentAllocation, PaymentInstrument, PaymentIntent, Payout, ProductionOrder, PurchaseContract, PurchaseOrder, SalesContract, Vendor, WholesaleOrder, } from './models/index.js';
|
|
69
70
|
export { assertIntegerMinorUnits } from './money.js';
|
|
71
|
+
export { applyPartyContactIntent, DEFAULT_PARTY_CONTACT_FIELD_NAMES, normalizePartyContacts, PARTY_CONTACT_MAX_LENGTHS, type PartyContactErrorCode, type PartyContactField, type PartyContactFieldNames, type PartyContactFormSource, type PartyContactInput, type PartyContactIntents, PartyContactPartyNotFoundError, PartyContactPayloadError, type PartyContactRowErrors, PartyContactValidationError, readPartyContactRows, type SavePartyContactsOptions, savePartyContacts, validatePartyContactRows, } from './party-contacts.js';
|
|
70
72
|
export { AgreementsRecipe, CustomersRecipe, EstimatesRecipe, FulfillmentRecipe, InvoicingRecipe, LeasesRecipe, LicensesRecipe, PurchasesRecipe, SalesRecipe, VendorsRecipe, WholesaleRecipe, } from './recipes.js';
|
|
71
|
-
export { type Address, ContractStatus, ContractType, CustomerStatus, CustomerType, FulfillmentStatus, FulfillmentType, type InvoiceCollectionMethod, InvoiceStatus, PaymentInstrumentStatus, PaymentIntentStatus, PaymentMethod, type PaymentOption, PaymentStatus, PayoutStatus, type PurchaseOrderOptions, type RecognizeRevenueOptions, type RecordPaymentOptions, VendorStatus, } from './types/index.js';
|
|
73
|
+
export { type Address, ContractStatus, ContractType, CustomerStatus, CustomerType, FulfillmentStatus, FulfillmentType, type InvoiceCollectionMethod, InvoiceStatus, type PartyContact, PaymentInstrumentStatus, PaymentIntentStatus, PaymentMethod, type PaymentOption, PaymentStatus, PayoutStatus, type PurchaseContractOptions, type PurchaseOrderOptions, type RecognizeRevenueOptions, type RecordPaymentOptions, type SalesContractOptions, VendorStatus, } from './types/index.js';
|
|
72
74
|
export { COMMERCE_MODULE_META, COMMERCE_UI_SLOTS } from './ui.js';
|
|
73
75
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAKH,OAAO,wBAAwB,CAAC;AAGhC,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,2BAA2B,EAChC,kBAAkB,EAClB,qBAAqB,EACrB,6BAA6B,EAC7B,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,2BAA2B,EAC3B,iBAAiB,EACjB,2BAA2B,EAC3B,uBAAuB,EACvB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EACxC,KAAK,6BAA6B,EAClC,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,sBAAsB,EACtB,mCAAmC,EACnC,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAKH,OAAO,wBAAwB,CAAC;AAGhC,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,2BAA2B,EAChC,kBAAkB,EAClB,qBAAqB,EACrB,6BAA6B,EAC7B,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,2BAA2B,EAC3B,iBAAiB,EACjB,2BAA2B,EAC3B,uBAAuB,EACvB,KAAK,4BAA4B,EACjC,KAAK,i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